diff options
author | Behrend Cornelius <bc@openoffice.org> | 2001-09-12 11:30:01 +0000 |
---|---|---|
committer | Behrend Cornelius <bc@openoffice.org> | 2001-09-12 11:30:01 +0000 |
commit | 78471c863b62114593277e656c3e3b524e46d10d (patch) | |
tree | b27c26f3befc83160da5c6c20bcb14f4882f6a27 /wizards/source/euro/ConvertRun.xba | |
parent | 8423d3eb5b1622a1b4b1a81b34e24ab1465c9784 (diff) |
#91710# several modifications
Diffstat (limited to 'wizards/source/euro/ConvertRun.xba')
-rw-r--r-- | wizards/source/euro/ConvertRun.xba | 152 |
1 files changed, 87 insertions, 65 deletions
diff --git a/wizards/source/euro/ConvertRun.xba b/wizards/source/euro/ConvertRun.xba index 9d9548509..a617b923a 100644 --- a/wizards/source/euro/ConvertRun.xba +++ b/wizards/source/euro/ConvertRun.xba @@ -1,18 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> <script:module xmlns:script="http://openoffice.org/2000/script" script:name="ConvertRun" script:language="StarBasic">Option Explicit + +Public oPreSelRange as Object + ' Todo Den Bug mit der Statuszeilengeschichte überprüfen ' Todo Vorselektion der Listbox ' Mauspointer umschalten: ' Todo: Sinnigkeit von 'DocDisposed' noch einmal überprüfen +' Todo: In der Hilfe sollte ein Hinweis erscheinen, dass immer zwei Nachkommastellen angezeigt werden +' und die resultierende Betrag ebenfalls bis auf zwei Stellen nach dem Komma gerundet wird Sub Main() BasicLibraries.LoadLibrary("Tools") If InitResources("Euro Converter", "eur") Then bDoUnProtect = False bPreSelected = True - DocDisposed = False +' DocDisposed = False oDocument = StarDesktop.CurrentFrame.Controller.Model RetrieveDocumentObjects() ' Statusline, SheetsCollection etc. InitializeConverter(oDocument.CharLocale, 1) @@ -112,31 +117,35 @@ End Sub Sub EnableStep1DialogControls(bCurrEnabled as Boolean, bFrameEnabled as Boolean, bButtonsEnabled as Boolean) -Dim bNoComboSelection as Boolean -Dim bNoLBSelection as Boolean - ' Controls around the Currency-Listbox +Dim bCurrIsSelected as Boolean +Dim bObjectIsSelected as Boolean +Dim bConvertWholeDoc as Boolean +Dim bDoEnableFrame as Boolean + bConvertWholeDoc = DialogModel.chkComplete.State = 1 + bDoEnableFrame = bFrameEnabled And (NOT bConvertWholeDoc) + + ' Controls around the Selection Listbox With DialogModel .lblCurrencies.Enabled = bCurrEnabled - .lstCurrencies.Enabled = bCurrEnabled - - .lstSelection.Enabled = bFrameEnabled - .lblSelection.Enabled = bFrameEnabled - .hlnSelection.Enabled = bFrameEnabled - .optCellTemplates.Enabled = bFrameEnabled - .optSheetRanges.Enabled = bFrameEnabled - .optDocRanges.Enabled = bFrameEnabled - .optSelRange.Enabled = bFrameEnabled + .lstCurrencies.Enabled = bCurrEnabled + .lstSelection.Enabled = bDoEnableFrame + .lblSelection.Enabled = bDoEnableFrame + .hlnSelection.Enabled = bDoEnableFrame + .optCellTemplates.Enabled = bDoEnableFrame + .optSheetRanges.Enabled = bDoEnableFrame + .optDocRanges.Enabled = bDoEnableFrame + .optSelRange.Enabled = bDoEnableFrame End With ' The CheckBox has the Value 'True' when the Controls in the Frame are disabled If bButtonsEnabled Then - bNoComboSelection = Ubound(DialogModel.lstCurrencies.SelectedItems()) = -1 + bCurrIsSelected = Ubound(DialogModel.lstCurrencies.SelectedItems()) <> -1 ' Enable GoOnButton only when Currency is selected - DialogModel.cmdGoOn.Enabled = Not bNoComboSelection - DialogModel.chkComplete.Enabled = Not bNoComboSelection - If bFrameEnabled AND Not DialogModel.chkComplete.State = 1 AND DialogModel.cmdGoOn.Enabled Then + DialogModel.cmdGoOn.Enabled = bCurrIsSelected + DialogModel.chkComplete.Enabled = bCurrIsSelected + If bDoEnableFrame AND DialogModel.cmdGoOn.Enabled Then ' If FrameControls are enabled, check if Listbox is Empty - bNoLBSelection = Ubound(DialogModel.lstSelection.SelectedItems()) = -1 - DialogModel.cmdGoOn.Enabled = NOT bNoLBSelection + bObjectIsSelected = Ubound(DialogModel.lstSelection.SelectedItems()) <> -1 + DialogModel.cmdGoOn.Enabled = bObjectIsSelected End If Else DialogModel.cmdGoOn.Enabled = False @@ -149,6 +158,7 @@ Sub ConvertRangesOrStylesOfDocument() Dim i as Integer Dim ItemName as String Dim SelList() as String +Dim oSheetRanges as Object bDocHasProtectedSheets = CheckSheetProtection(oSheets) If bDocHasProtectedSheets Then @@ -166,6 +176,13 @@ Dim SelList() as String ' Option 'Soft' Formatation is selected AssignRangestoStyle(DialogModel.lstSelection.StringItemList(), SelList()) ConverttheSoftWay(SelList(), True) + ElseIf DialogModel.optSelRange.State = 1 Then + oSheetRanges = oPreSelRange.CellFormatRanges.createEnumeration + While oSheetRanges.hasMoreElements + oRange = oSheetRanges.NextElement + ConvertCellCurrencies(oRange) + SwitchNumberFormat(oRange, oFormats, sEuroSign) + Wend Else ConverttheHardWay(SelList(), False, True) End If @@ -208,82 +225,87 @@ Dim EmptySelRangeList() as String End Sub -Sub AddSelectedRangeToSelRangesEnum() +Function AddSelectedRangeToSelRangesEnum() as Object +Dim oLocRange as Object osheet = oDocument.CurrentController.GetActiveSheet -' oAddressRanges = oDocument.createInstance("com.sun.star.sheet.SheetCellRanges") oSelRanges = oDocument.createInstance("com.sun.star.sheet.SheetCellRanges") ' Check if a Currency-Range has been selected - oRange = oDocument.CurrentController.Selection - oSelRanges.InsertbyName("",oRange) -End Sub + oLocRange = oDocument.CurrentController.Selection + oSelRanges.InsertbyName("",oLocRange) + AddSelectedRangeToSelRangesEnum() = oLocRange +End Function Sub GetPreSelectedRange() Dim i as Integer Dim OldCurrSymbolList(2) as String Dim OldCurrIndex as Integer -Dim OldCurExtension(1) as String - AddSelectedRangeToSelRangesEnum() - bPreSelected = CheckIfRangeisCurrency(oRange) - If bPreSelected Then -' Todo: Array als ganzes übergeben! - OldCurrSymbolList() = CurrSymbolList() - OldCurExtension() = CurExtension() - OldCurrIndex = CurrIndex - For i = 0 To 11 - CurrIndex = i - CurExtension(0) = LangIDValue(CurrIndex,0,2) - CurExtension(1) = LangIDValue(CurrIndex,1,2) - InitializeCurrencyValues(CurrIndex) - bPreSelected = CheckFormatType(oRange) - If bPreSelected Then - Exit For - End If - Next i - If Not bPreSelected Then - CurrIndex = OldCurrIndex - CurrSymbolList() = OldCurrSymbolList() - CurExtension() = OldCurExtension() - End If - End If - - If CurrIndex > -1 Then +Dim OldCurExtension(2) as String + oPreSelRange = AddSelectedRangeToSelRangesEnum() + bPreSelected = True + +' bPreSelected = CheckIfRangeisCurrency(oRange) +' If bPreSelected Then +' OldCurrSymbolList() = CurrSymbolList() +' OldCurExtension() = CurExtension() +' OldCurrIndex = CurrIndex +' For i = 0 To 11 +' CurrIndex = i +' CurExtension(0) = LangIDValue(CurrIndex,0,2) +' CurExtension(1) = LangIDValue(CurrIndex,1,2) +' CurExtension(2) = LangIDValue(CurrIndex,2,2) +' InitializeCurrencyValues(CurrIndex) +' bPreSelected = CheckFormatType(oRange) +' If bPreSelected Then +' Exit For +' End If +' Next i +' If Not bPreSelected Then +' CurrIndex = OldCurrIndex +' CurrSymbolList() = OldCurrSymbolList() +' CurExtension() = OldCurExtension() +' End If +' End If + +' If CurrIndex > -1 Then If bPreSelected Then DialogModel.optSelRange.State = 1 - AddRangeToListbox() + AddRangeToListbox(oPreSelRange) Else DialogModel.optCellTemplates.State = 1 CreateStyleEnumeration() End If - End If +' End If EnableStep1DialogControls(True, bPreSelected, True) ' Todo: auf Integer umstellen - If bPreselected Then - DialogModel.chkComplete.State = 0 - Else - DialogModel.chkComplete.State = 1 - End If +' If bPreselected Then + DialogModel.chkComplete.State = Not(Abs(bPreSelected)) '0 +' Else +' DialogModel.chkComplete.State = 1 +' End If DialogModel.optSelRange.Enabled = bPreSelected End Sub -Sub AddRangeToListbox() +Sub AddRangeToListbox(oLocRange as Object) EmptyListBox(DialogModel.lstSelection) ' Den Namen der Range ermitteln und in ein Array packen - PreName = RetrieveRangeNamefromAddress(oRange) + PreName = RetrieveRangeNamefromAddress(oLocRange) AddSingleItemToListbox(DialogModel.lstSelection, Prename)', 0) SelectListboxItem(DialogModel.lstCurrencies, CurrIndex) - TotCellCount = CountRangeCells(oRange) + TotCellCount = CountRangeCells(oLocRange) End Sub Sub CheckRangeSelection(Optional oEvent) ' Todo: Beim Startup werden die folgenden zwei Zeilen doppelt ausgeführt - AddSelectedRangeToSelRangesEnum() - bPreSelected = CheckFormatType(oRange) - If bPreSelected Then - AddRangeToListbox() - End If +' oPreSelRange = AddSelectedRangeToSelRangesEnum() +' bPreSelected = CheckFormatType(oRange) + ' If bPreSelected Then +' + EmptySelection() + AddRangeToListbox(oPreSelRange) +' End If End Sub |