summaryrefslogtreecommitdiff
path: root/wizards/source
diff options
context:
space:
mode:
authorBehrend Cornelius <bc@openoffice.org>2001-05-04 14:15:30 +0000
committerBehrend Cornelius <bc@openoffice.org>2001-05-04 14:15:30 +0000
commit0aa1eda1a2af438d7061ba2a6d53866141f5fda6 (patch)
tree81b25654aab1365b6172a31c1ac043f08fd5d09d /wizards/source
parent6dca4e2d819ea121096ba1be8ab18c5307a901f7 (diff)
## several changes
Diffstat (limited to 'wizards/source')
-rw-r--r--wizards/source/tools/Misc.xba267
-rw-r--r--wizards/source/tools/Strings.xba7
2 files changed, 76 insertions, 198 deletions
diff --git a/wizards/source/tools/Misc.xba b/wizards/source/tools/Misc.xba
index 1e99ed8cf448..576bc58c525c 100644
--- a/wizards/source/tools/Misc.xba
+++ b/wizards/source/tools/Misc.xba
@@ -7,18 +7,69 @@ Const SBUSER = 1
Dim Taskindex as Integer
Dim oResSrv as Object
+Sub Main()
+Dim PropList(3,1)&apos; as String
+ PropList(0,0) = &quot;URL&quot;
+ PropList(0,1) = &quot;sdbc:odbc:Erica_Test_Unicode&quot;
+ PropList(1,0) = &quot;User&quot;
+ PropList(1,1) = &quot;extra&quot;
+ PropList(2,0) = &quot;Password&quot;
+ PropList(2,1) = &quot;extra&quot;
+ PropList(3,0) = &quot;IsPasswordRequired&quot;
+ PropList(3,1) = True
+&apos; RegisterNewDataSource(&quot;Doc_Erica_Test_Unicode&quot;, PropList())
+End Sub
+
+
+Function RegisterNewDataSource(DSName as String, PropertyList(), Optional DriverProperties() as New com.sun.star.beans.PropertyValue)
+Dim oDataSource as Object
+Dim oDBContext as Object
+Dim oPropInfo as Object
+Dim i as Integer
+ oDBContext = createUnoService(&quot;com.sun.star.sdb.DatabaseContext&quot;)
+ oDataSource = createUnoService(&quot;com.sun.star.sdb.DataSource&quot;)
+ For i = 0 To Ubound(PropertyList(), 1)
+ sPropName = PropertyList(i,0)
+ sPropValue = PropertyList(i,1)
+ oDataSource.SetPropertyValue(sPropName,sPropValue) &apos;GetByName(sPropName) = sPropValue &apos;oPropInfo.GetPropertyByName(sPropName)) = sPropValue &apos; PropertyList(i,0))) = PropertyList(i,1)
+ Next i
+ If Not IsMissing(DriverProperties()) Then
+ oDataSource.Info() = DriverProperties()
+ End If
+ oDBContext.RegisterObject(DSName, oDataSource)
+ RegisterNewDataSource () = oDataSource
+End Function
+
+
&apos; Connects to a registered Database
-Function ConnecttoDatabase(DBName as String, UserID as String, Password as String )
+Function ConnecttoDatabase(DSName as String, UserID as String, Password as String, Optional Propertylist(), Optional DriverProperties() as New com.sun.star.beans.PropertyValue)
Dim oDBContext as Object
Dim oDBSource as Object
+ On Local Error Goto NOCONNECTION
oDBContext = CreateUnoService(&quot;com.sun.star.sdb.DatabaseContext&quot;)
- If oDBContext.HasbyName(DBName) Then
- oDBSource = oDBContext.GetByName(DBName)
+ If oDBContext.HasbyName(DSName) Then
+ oDBSource = oDBContext.GetByName(DSName)
ConnectToDatabase = oDBSource.GetConnection(UserID, Password)
Else
- Msgbox(&quot;DataSource &quot; &amp; DBName &amp; &quot; is not registered&quot; , 16, GetProductname)
- ConnectToDatabase() = NULL
+ If Not IsMissing(Namelist()) Then
+ If Not IsMissing(DriverProperties()) Then
+ RegisterNewDataSource(DSName, PropertyList(), DriverProperties())
+ Else
+ RegisterNewDataSource(DSName, PropertyList())
+ End If
+ oDBSource = oDBContext.GetByName(DSName)
+ ConnectToDatabase = oDBSource.GetConnection(UserID, Password)
+ Else
+ Msgbox(&quot;DataSource &quot; &amp; DSName &amp; &quot; is not registered&quot; , 16, GetProductname())
+ ConnectToDatabase() = NULL
+ End If
End If
+NOCONNECTION:
+ If Err &lt;&gt; 0 Then
+ Msgbox(Error$, 16, GetProductName())
+ Resume LEAVESUB
+ LEAVESUB:
+ End If
End Function
@@ -107,98 +158,6 @@ Dim MaxArrIndex as integer
End Function
-&apos; clears up a Listbox and refills it with the delivered Array &apos;ValList()&apos;
-Sub FillUpCombo(LocListbox as Object, ValList() as String)
-Dim i as integer
-Dim a as Integer
- LocListbox.Clear
- &apos; Trage die ??bersetzungsrelevanten Verzeichnisnamen in die Listbox ein
- a = 0
- For i = 0 to Ubound(ValList())
- If ValList(i) &lt;&gt; &quot;&quot; Then
- LocListbox.List(a) = ValList(i)
- a = a + 1
- End If
- Next
-End Sub
-
-
-Sub WritedbgInfo(LocObject as Object)
-Dim locUrl as String
-Dim oLocDocument as Object
-Dim oLocText as Object
-Dim oLocCursor as Object
-Dim NoArgs()
-Dim sObjectStrings(2) as String
-Dim sProperties() as String
-Dim n as Integer
-Dim m as Integer
- sObjectStrings(0) = LocObject.dbg_Properties
- sObjectStrings(1) = LocObject.dbg_Methods
- sObjectStrings(2) = LocObject.dbg_SupportedInterfaces
- LocUrl = &quot;private:factory/swriter&quot;
- oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,&quot;_blank&quot;,0,NoArgs)
- oLocText = oLocDocument.text
- oLocCursor = oLocText.createTextCursor()
- oLocCursor.gotoStart(False)
- If Vartype(LocObject) = 9 then &apos; an Object Variable
- For n = 0 To 2
- sProperties() = ArrayoutofString(sObjectStrings(n),&quot;;&quot;, MaxIndex)
- For m = 0 To MaxIndex
- oLocText.insertString(oLocCursor,sProperties(m),False)
- oLocText.insertControlCharacter(oLocCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
- Next m
- Next n
- Elseif Vartype(LocObject) = 8 Then &apos; a String Variable
- oLocText.insertString(oLocCursor,LocObject,False)
- ElseIf Vartype(LocObject) = 1 Then
- Msgbox(&quot;Variable is Null!&quot;, 16, GetProductName())
- End If
-End Sub
-
-
-Sub WriteDbgString(LocString as string)
-Dim oLocDesktop as object
-Dim LocUrl as String
-Dim oLocDocument as Object
-Dim oLocCursor as Object
-Dim oLocText as Object
-
- LocUrl = &quot;private:factory/swriter&quot;
- oLocDocument = StarDesktop.LoadComponentFromURL(LocUrl,&quot;_blank&quot;,0,NoArgs)
- oLocText = oLocDocument.text
- oLocCursor = oLocText.createTextCursor()
- oLocCursor.gotoStart(False)
- oLocText.insertString(oLocCursor,LocString,False)
-End Sub
-
-
-Sub printdbgInfo(LocObject)
- If Vartype(LocObject) = 9 then
- Msgbox LocObject.dbg_properties
- Msgbox LocObject.dbg_methods
- Msgbox LocObject.dbg_supportedinterfaces
- Elseif Vartype(LocObject) = 8 Then &apos; a String Variable
- Msgbox LocObject
- ElseIf Vartype(LocObject) = 0 Then
- Msgbox(&quot;Variable is Null!&quot;, 16, GetProductName())
- Else
- Msgbox(&quot;Type of Variable: &quot; &amp; Typename(LocObject), 48, GetProductName())
- End If
-End Sub
-
-
-Sub ShowArray(LocArray())
-Dim i as integer
-Dim msgstring
- msgstring = &quot;&quot;
- For i = Lbound(LocArray()) to Ubound(LocArray())
- msgstring = msgstring + LocArray(i) + chr(13)
- Next
- Msgbox msgstring
-End Sub
-
-
&apos; Gets a special configured PathSetting
Function GetPathSettings(sPathType as String, Optional bshowall as Boolean, Optional ListIndex as integer) as String
Dim oSettings, oPathSettings as Object
@@ -268,103 +227,6 @@ Dim MaxIndex as Integer
End Function
-Sub ShowPropertyValues(oLocObject as Object)
-Dim PropName as String
-Dim sValues as String
- On Local Error Goto NOPROPERTYSETINFO:
- sValues = &quot;&quot;
- For i = 0 To Ubound(oLocObject.PropertySetInfo.Properties)
- Propname = oLocObject.PropertySetInfo.Properties(i).Name
- sValues = sValues &amp; PropName &amp; &quot; = &quot; &amp; oLocObject.GetPropertyValue(PropName) &amp; chr(13)
- Next i
- Msgbox(sValues , 64, GetProductName())
- Exit Sub
-
-NOPROPERTYSETINFO:
- Msgbox(&quot;Sorry, No PropertySetInfo attached to the object&quot;, 16, GetProductName())
- Resume LEAVEPROC
- LEAVEPROC:
-End Sub
-
-
-Sub ShowNameValuePair(Pair())
-Dim i as Integer
-Dim ShowString as String
- ShowString = &quot;&quot;
- On Local Error Resume Next
- For i = 0 To Ubound(Pair())
- ShowString = ShowString &amp; Pair(i).Name &amp; &quot; = &quot;
- ShowString = ShowString &amp; Pair(i).Value &amp; chr(13)
- Next i
- Msgbox ShowString
-End Sub
-
-
-&apos; Retrieves all the Elements of aSequence of an object, with the
-&apos; possibility to define a filter(sfilter &lt;&gt; &quot;&quot;)
-Sub ShowElementNames(oLocElements() as Object, Optional sFiltername as String)
-Dim i as Integer
-Dim NameString as String
- NameString = &quot;&quot;
- For i = 0 To Ubound(oLocElements())
- If Not IsMissIng(sFilterName) Then
- If Instr(1, oLocElements(i), sFilterName) Then
- NameString = NameString &amp; oLocElements(i) &amp; chr(13)
- End If
- Else
- NameString = NameString &amp; oLocElements(i) &amp; chr(13)
- End If
- Next i
- Msgbox(NameString, 64, GetProductName())
-End Sub
-
-
-&apos; Retrieves all the supported servicenames of an object, with the
-&apos; possibility to define a filter(sfilter &lt;&gt; &quot;&quot;)
-Sub ShowSupportedServiceNames(oLocObject as Object, Optional sFilterName as String)
- On Local Error Goto NOSERVICENAMES
- If IsMissing(sFilterName) Then
- ShowElementNames(oLocobject.SupportedServiceNames())
- Else
- ShowElementNames(oLocobject.SupportedServiceNames(), sFilterName)
- End If
- Exit Sub
-
- NOSERVICENAMES:
- Msgbox(&quot;Sorry, No &apos;SupportedServiceNames&apos; - Property attached to the object&quot;, 16, GetProductName())
- Resume LEAVEPROC
- LEAVEPROC:
-End Sub
-
-
-&apos; Retrieves all the available Servicenames of an object, with the
-&apos; possibility to define a filter(sfilter &lt;&gt; &quot;&quot;)
-Sub ShowAvailableServiceNames(oLocObject as Object, Optional sFilterName as String)
- On Local Error Goto NOSERVICENAMES
- If IsMissing(sFilterName) Then
- ShowElementNames(oLocobject.AvailableServiceNames)
- Else
- ShowElementNames(oLocobject.AvailableServiceNames, sFilterName)
- End If
- Exit Sub
-
- NOSERVICENAMES:
- Msgbox(&quot;Sorry, No &apos;AvailableServiceNames&apos; - Property attached to the object&quot;, 16, GetProductName())
- Resume LEAVEPROC
- LEAVEPROC:
-End Sub
-
-
-Sub ShowCommands(oLocObject as Object)
- On Local Error Goto NOCOMMANDS
- ShowElementNames(oLocObject.QueryCommands)
- Exit Sub
- NOCOMMANDS:
- Msgbox(&quot;Sorry, No &apos;QueryCommands&apos; - Property attached to the object&quot;, 16, GetProductName())
- Resume LEAVEPROC
- LEAVEPROC:
-End Sub
-
Function InitResources(Description, ShortDescription as String) as boolean
On Error Goto ErrorOcurred
@@ -534,6 +396,7 @@ Function GetDocumentType(oDocument)
End Function
+
Function GetNumberFormatType(oDocFormats, oFormatObject as Object) as Integer
Dim ThisFormatKey as Long
Dim oObjectFormat as Object
@@ -729,6 +592,7 @@ Dim PropValue(1) as new com.sun.star.beans.PropertyValue
End Sub
+
Function ModifyPropertyValue(oContent() as Object, TargetProperties() as New com.sun.star.beans.PropertyValue )
Dim MaxIndex as Integer
Dim i as Integer
@@ -794,4 +658,19 @@ Dim oDisp as Object
oDisp.dispatch(oUrl, oArg())
End Sub
+
+&apos;returns the type of the office application
+&apos;FatOffice = 0, WebTop = 1
+&apos;This routine has to be changed if the Product Name is being changed!
+Function IsFatOffice() As Boolean
+ If sProductname = &quot;&quot; Then
+ sProductname = GetProductname()
+ End If
+ IsFatOffice = TRUE
+ &apos;The following line has to include the current productname
+ If Instr(1,sProductname,&quot;WebTop&quot;,1) &lt;&gt; 0 Then
+ IsFatOffice = FALSE
+ End If
+End Function
+
</script:module> \ No newline at end of file
diff --git a/wizards/source/tools/Strings.xba b/wizards/source/tools/Strings.xba
index c478804e5f08..2e70535b9d49 100644
--- a/wizards/source/tools/Strings.xba
+++ b/wizards/source/tools/Strings.xba
@@ -58,7 +58,6 @@ Dim BigLen%,PreLen%,PostLen%
End Function
-
&apos; Deletes the String &apos;SmallString&apos; out of the String &apos;BigString&apos;
&apos; in case SmallString&apos;s Position in BigString is right at the end
Function RTrimStr(ByVal BigString, SmallString as String) as String
@@ -247,7 +246,7 @@ Dim Separator as String
sProductname = GetProductname()
End If
If BigString &lt;&gt; &quot;&quot; Then
- If Instr(1,sProductname,&quot;Sun Webtop&quot;) = 0 Then
+ If IsFatOffice() Then
Separator = GetPathSeparator()
&apos; Is the delivered Path already a URL
If Instr(1,UCase(BigString),&quot;FILE:///&quot;) = 0 Then
@@ -333,10 +332,10 @@ Dim SepList() as String
End Function
-Function DirectorynameoutofPath(sPath as String, Separator as String) as String
+Function DirectoryNameoutofPath(sPath as String, Separator as String) as String
Dim LocFileName as String
LocFileName = FileNameoutofPath(sPath, Separator)
- DirectoryNameoutofPath = DeleteStr(sPath, Separator &amp; LocFileName)
+ DirectoryNameoutofPath = RTrimStr(sPath, Separator &amp; LocFileName)
End Function