diff options
author | Behrend Cornelius <bc@openoffice.org> | 2001-11-14 17:38:23 +0000 |
---|---|---|
committer | Behrend Cornelius <bc@openoffice.org> | 2001-11-14 17:38:23 +0000 |
commit | 5f9687cfe3217cef7a0de7686086ed712fba6e74 (patch) | |
tree | b1a3604ad4fb8f277d03b52efc49789e95d1731e /wizards/source/tools | |
parent | ddd50ffe8907da4e8e468f0518dd57f47106155e (diff) |
#94577# CheckSheetName Routine improved
Diffstat (limited to 'wizards/source/tools')
-rw-r--r-- | wizards/source/tools/Misc.xba | 100 | ||||
-rw-r--r-- | wizards/source/tools/Strings.xba | 2 |
2 files changed, 47 insertions, 55 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("DataSource " & DSName & " is not registered" , 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("org.openoffice.Setup/Product") sProdName = oProdNameAccess.getByName("ooName") sVersion = oProdNameAccess.getByName("ooSetupVersion") - GetProductName = sProdName & "." & sVersion + GetProductName = sProdName & sVersion End Function ' Opens a Document, checks beforehand, wether it has to be loaded -' or wether it is already on the desktop. -' If the parameter bDisposable is set to False then then returned document -' should not be disposed afterwards, because it is already opened. -Function OpenDocument(DocPath as String, Args(), Optional bDisposable as Boolean) +' or wether it is already on the desktop +Function OpenDocument(DocPath as String, Args()) Dim oComponents as Object Dim oComponent as Object ' 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,"com.sun.star.frame.XModel") 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,"_blank",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) = "-" - SpecialSignsList(1) = "." - SpecialSignsList(2) = "!" - SpecialSignsList(3) = "?" - SpecialSignsList(4) = "/" - SpecialSignsList(5) = "\" - SpecialSignsList(6) = "," - SpecialSignsList(7) = ";" - SpecialSignsList(8) = "'" - SpecialSignsList(9) = "(" - SpecialSignsList(10) = ")" - SpecialSignsList(11) = "{" - SpecialSignsList(12) = "}" - SpecialSignsList(13) = "[" - SpecialSignsList(14) = "]" - SpecialSignsList(15) = ":" - SpecialSignsList(16) = """" - SpecialSignsList(17) = "$" - SpecialSignsList(18) = "&" - SpecialSignsList(19) = "%" - SpecialSignsList(20) = "=" - SpecialSignsList(21) = "*" - SpecialSignsList(22) = "?§" - SpecialSignsList(23) = "@" - SpecialSignsList(24) = "<" - SpecialSignsList(25) = ">" - SpecialSignsList(26) = "#" - SpecialSignsList(27) = "+" - SpecialSignsList(28) = "~" - SpecialSignsList(29) = "|" - SpecialSignsList(30) = "??" - SpecialSignsList(31) = "^" - SpecialSignsList(32) = "?°" - For i = 0 To Ubound(SpecialSignsList()) - SheetName = ReplaceString(Sheetname, "_", 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("com.sun.star.i18n.CharacterClassification") + 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, "", nContFlags, " ") + iResultPos = oResult.EndPos + If iResultPos < iSheetNameLength Then + WrongChar = Mid(SheetName, iResultPos+1,1) + SheetName = ReplaceString(SheetName,"_", 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) & "_" & 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 = "slot:" & CStr(SlotID) oTrans.parsestrict(oUrl) - oDisp = StarDesktop.currentFrame.queryDispatch(oUrl, "_self", 0) + oDisp = StarDesktop.ActiveFrame.queryDispatch(oUrl, "_self", 0) oDisp.dispatch(oUrl, oArg()) End Sub diff --git a/wizards/source/tools/Strings.xba b/wizards/source/tools/Strings.xba index daf35db5ab81..601ab7404d3c 100644 --- a/wizards/source/tools/Strings.xba +++ b/wizards/source/tools/Strings.xba @@ -455,7 +455,7 @@ End Function Function CheckDouble(DoubleString as String) On Local Error Goto WRONGDATATYPE - CheckDouble() = CDbl(DoubleString) + CheckDouble() = CDbl(DoubleString) WRONGDATATYPE: If Err <> 0 Then CheckDouble() = 0 |