summaryrefslogtreecommitdiff
path: root/wizards/source/tools/Misc.xba
diff options
context:
space:
mode:
authorBehrend Cornelius <bc@openoffice.org>2001-11-14 17:38:23 +0000
committerBehrend Cornelius <bc@openoffice.org>2001-11-14 17:38:23 +0000
commit5f9687cfe3217cef7a0de7686086ed712fba6e74 (patch)
treeb1a3604ad4fb8f277d03b52efc49789e95d1731e /wizards/source/tools/Misc.xba
parentddd50ffe8907da4e8e468f0518dd57f47106155e (diff)
#94577# CheckSheetName Routine improved
Diffstat (limited to 'wizards/source/tools/Misc.xba')
-rw-r--r--wizards/source/tools/Misc.xba100
1 files changed, 46 insertions, 54 deletions
diff --git a/wizards/source/tools/Misc.xba b/wizards/source/tools/Misc.xba
index cc0c7d3ce814..2268780b6e5c 100644
--- a/wizards/source/tools/Misc.xba
+++ b/wizards/source/tools/Misc.xba
@@ -58,7 +58,7 @@ Dim oDBSource as Object
RegisterNewDataSource(DSName, PropertyList())
End If
oDBSource = oDBContext.GetByName(DSName)
- ConnectToDatabase = oDBSource.GetConnection(UserID, Password)
+ ConnectToDatabase = oDBSource.GetConnection(UserID, Password)
Else
Msgbox(&quot;DataSource &quot; &amp; DSName &amp; &quot; is not registered&quot; , 16, GetProductname())
ConnectToDatabase() = NULL
@@ -69,7 +69,7 @@ NOCONNECTION:
Msgbox(Error$, 16, GetProductName())
Resume LEAVESUB
LEAVESUB:
- End If
+ End If
End Function
@@ -114,15 +114,13 @@ Dim sProdName as String
oProdNameAccess = GetRegistryKeyContent(&quot;org.openoffice.Setup/Product&quot;)
sProdName = oProdNameAccess.getByName(&quot;ooName&quot;)
sVersion = oProdNameAccess.getByName(&quot;ooSetupVersion&quot;)
- GetProductName = sProdName &amp; &quot;.&quot; &amp; sVersion
+ GetProductName = sProdName &amp; sVersion
End Function
&apos; Opens a Document, checks beforehand, wether it has to be loaded
-&apos; or wether it is already on the desktop.
-&apos; If the parameter bDisposable is set to False then then returned document
-&apos; should not be disposed afterwards, because it is already opened.
-Function OpenDocument(DocPath as String, Args(), Optional bDisposable as Boolean)
+&apos; or wether it is already on the desktop
+Function OpenDocument(DocPath as String, Args())
Dim oComponents as Object
Dim oComponent as Object
&apos; Search if one of the active Components ist the one that you search for
@@ -132,16 +130,10 @@ Dim oComponent as Object
If hasUnoInterfaces(oComponent,&quot;com.sun.star.frame.XModel&quot;) then
If UCase(oComponent.URL) = UCase(DocPath) then
OpenDocument() = oComponent
- If Not IsMissing(bDisposable) Then
- bDisposable = False
- End If
Exit Function
End If
End If
Wend
- If Not IsMissing(bDisposable) Then
- bDisposable = True
- End If
OpenDocument() = StarDesktop.LoadComponentFromURL(DocPath,&quot;_blank&quot;,0,Args())
End Function
@@ -548,50 +540,50 @@ Dim oWindowPointer as Object
End Sub
-
-Function CheckNewSheetname(oSheets as Object, Sheetname as String)
-Dim SpecialSignsList(32) as String
-Dim i as Integer
- SpecialSignsList(0) = &quot;-&quot;
- SpecialSignsList(1) = &quot;.&quot;
- SpecialSignsList(2) = &quot;!&quot;
- SpecialSignsList(3) = &quot;?&quot;
- SpecialSignsList(4) = &quot;/&quot;
- SpecialSignsList(5) = &quot;\&quot;
- SpecialSignsList(6) = &quot;,&quot;
- SpecialSignsList(7) = &quot;;&quot;
- SpecialSignsList(8) = &quot;&apos;&quot;
- SpecialSignsList(9) = &quot;(&quot;
- SpecialSignsList(10) = &quot;)&quot;
- SpecialSignsList(11) = &quot;{&quot;
- SpecialSignsList(12) = &quot;}&quot;
- SpecialSignsList(13) = &quot;[&quot;
- SpecialSignsList(14) = &quot;]&quot;
- SpecialSignsList(15) = &quot;:&quot;
- SpecialSignsList(16) = &quot;&quot;&quot;&quot;
- SpecialSignsList(17) = &quot;$&quot;
- SpecialSignsList(18) = &quot;&amp;&quot;
- SpecialSignsList(19) = &quot;%&quot;
- SpecialSignsList(20) = &quot;=&quot;
- SpecialSignsList(21) = &quot;*&quot;
- SpecialSignsList(22) = &quot;?§&quot;
- SpecialSignsList(23) = &quot;@&quot;
- SpecialSignsList(24) = &quot;&lt;&quot;
- SpecialSignsList(25) = &quot;&gt;&quot;
- SpecialSignsList(26) = &quot;#&quot;
- SpecialSignsList(27) = &quot;+&quot;
- SpecialSignsList(28) = &quot;~&quot;
- SpecialSignsList(29) = &quot;|&quot;
- SpecialSignsList(30) = &quot;??&quot;
- SpecialSignsList(31) = &quot;^&quot;
- SpecialSignsList(32) = &quot;?°&quot;
- For i = 0 To Ubound(SpecialSignsList())
- SheetName = ReplaceString(Sheetname, &quot;_&quot;, SpecialSignsList(i)
- Next i
+Function CheckNewSheetname(oSheets as Object, Sheetname as String, Optional oLocale) as String
+Dim nStartFlags as Long
+Dim nContFlags as Long
+Dim oCharService as Object
+Dim iSheetNameLength as Integer
+Dim iResultPos as Integer
+Dim WrongChar as String
+Dim oResult as Object
+ nStartFlags = com.sun.star.i18n.KParseTokens.ANY_LETTER_OR_NUMBER + com.sun.star.i18n.KParseTokens.ASC_UNDERSCORE
+ nContFlags = nStartFlags
+ oCharService = CreateUnoService(&quot;com.sun.star.i18n.CharacterClassification&quot;)
+ iSheetNameLength = Len(SheetName)
+ If IsMissing(oLocale) Then
+ oLocale = ThisComponent.CharLocale
+ End If
+ Do
+ oResult =oCharService.parsePredefinedToken(com.sun.star.i18n.KParseType.IDENTNAME, SheetName, 0, oLocale, nStartFlags, &quot;&quot;, nContFlags, &quot; &quot;)
+ iResultPos = oResult.EndPos
+ If iResultPos &lt; iSheetNameLength Then
+ WrongChar = Mid(SheetName, iResultPos+1,1)
+ SheetName = ReplaceString(SheetName,&quot;_&quot;, WrongChar)
+ End If
+ Loop Until iResultPos = iSheetNameLength
CheckNewSheetname = SheetName
End Function
+Sub AddNewSheetName(oSheets as Object, ByVal SheetName as String)
+Dim Count as Integer
+Dim bSheetIsThere as Boolean
+Dim iSheetNameLength as Integer
+ iSheetNameLength = Len(SheetName)
+ Count = 2
+ Do
+ bSheetIsThere = oSheets.HasByName(SheetName)
+ If bSheetIsThere Then
+ SheetName = Right(SheetName,iSheetNameLength) &amp; &quot;_&quot; &amp; Count
+ Count = Count + 1
+ End If
+ Loop Until Not bSheetIsThere
+ AddNewSheetname = SheetName
+End Sub
+
+
Function GetSheetIndex(oSheets, sName) as Integer
Dim i as Integer
For i = 0 To oSheets.Count-1
@@ -686,7 +678,7 @@ Dim oDisp as Object
oUrl.Complete = &quot;slot:&quot; &amp; CStr(SlotID)
oTrans.parsestrict(oUrl)
- oDisp = StarDesktop.currentFrame.queryDispatch(oUrl, &quot;_self&quot;, 0)
+ oDisp = StarDesktop.ActiveFrame.queryDispatch(oUrl, &quot;_self&quot;, 0)
oDisp.dispatch(oUrl, oArg())
End Sub