From ee79b9875ce4914c950c349c61f39e6dfdd0cc6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sun, 21 May 2017 18:52:57 +0100 Subject: [PATCH] Resolves: tdf#107964 partially revert "unused basic dialog" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 062e7063a94673d016a91a16a30e86b82c70a03d. see ScModule::Execute case SID_CHOOSE_DESIGN: ... Template.Samples.ShowStyles for the caller of this Change-Id: I95fb4e2999d8898f9425ea6a523187be3c3842af Reviewed-on: https://gerrit.libreoffice.org/37882 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- wizards/Package_template.mk | 2 + wizards/source/template/DialogStyles.xdl | 32 ++++ wizards/source/template/Samples.xba | 170 +++++++++++++++++++ wizards/source/template/script.xlb | 1 + wizards/source/template/template.src | 203 +++++++++++++++++++++++ 5 files changed, 408 insertions(+) create mode 100644 wizards/source/template/DialogStyles.xdl create mode 100644 wizards/source/template/Samples.xba diff --git a/wizards/Package_template.mk b/wizards/Package_template.mk index e117ccc1c1a8..13728c7160a5 100644 --- a/wizards/Package_template.mk +++ b/wizards/Package_template.mk @@ -23,7 +23,9 @@ $(eval $(call gb_Package_add_files,wizards_basicsrvtemplate,$(LIBO_SHARE_FOLDER) Autotext.xba \ Correspondence.xba \ dialog.xlb \ + DialogStyles.xdl \ ModuleAgenda.xba \ + Samples.xba \ script.xlb \ TemplateDialog.xdl \ )) diff --git a/wizards/source/template/DialogStyles.xdl b/wizards/source/template/DialogStyles.xdl new file mode 100644 index 000000000000..ec5f71423593 --- /dev/null +++ b/wizards/source/template/DialogStyles.xdl @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wizards/source/template/Samples.xba b/wizards/source/template/Samples.xba new file mode 100644 index 000000000000..13fe11a09dd9 --- /dev/null +++ b/wizards/source/template/Samples.xba @@ -0,0 +1,170 @@ + + + +Option Explicit + +Const STYLES = 1100 +Const STYLENAME_DEF = 1120 +Const STYLENAME = 1150 +Const NumStyles = 18 +Const aTempFileName = "Berend_Ilko_Tom_Stella_Volker.stc" +Dim oUcbObject as Object +Public StylesDir as String +Public StylesDialog as Object +Public PathSeparator as String +Public oFamilies as Object +Public aOptions(0) as New com.sun.star.beans.PropertyValue +Public sQueryPath as String +Public NoArgs()as New com.sun.star.beans.PropertyValue +Public aTempURL as String + +Public Files(100) as String + + +'-------------------------------------------------------------------------------------- +'Calc Style Section starts here + +Sub ShowStyles +'This sub displays the style selection dialog if the current document is a calc document. +Dim TemplateDir, ActFileTitle, DisplayDummy as String +Dim sFilterName(0) as String +Dim StyleNames() as String +Dim LocalizedStyleNames(NumStyles,2) As String +Dim LocalizedStyleName As String +Dim t as Integer +Dim MaxIndex as Integer + BasicLibraries.LoadLibrary("Tools") + If InitResources("'Template'", "tpl") then + oDocument = ThisComponent + If oDocument.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then + ToggleWindow(False) + oUcbObject = createUnoService("com.sun.star.ucb.SimpleFileAccess") + oFamilies = oDocument.StyleFamilies + SaveCurrentStyles(oDocument) + StylesDialog = LoadDialog("Template", "DialogStyles") + DialogModel = StylesDialog.Model + TemplateDir = GetPathSettings("Template", False, 0) + StylesDir = GetOfficeSubPath("Template", "wizard/styles/") + sQueryPath = GetOfficeSubPath("Template", "../wizard/bitmap/") + DialogModel.Title = GetResText(STYLES) + DialogModel.cmdCancel.Label = GetResText(STYLES+2) + DialogModel.cmdOk.Label = GetResText(STYLES+3) + For t = 0 to NumStyles - 1 + LocalizedStyleNames(t,0) = GetResText(STYLENAME_DEF+t) + LocalizedStyleNames(t,1) = GetResText(STYLENAME+t) + Next t + Stylenames() = ReadDirectories(StylesDir, False, False, True,) + MaxIndex = Ubound(Stylenames()) + For t = 0 to MaxIndex + LocalizedStyleName = StringInMultiArray(LocalizedStyleNames(), StyleNames(t,1), 0, 1) + If LocalizedStyleName <> "" Then + StyleNames(t,1) = LocalizedStyleName + End If + Next t + BubbleSortList(Stylenames(),True) + Dim cStyles(MaxIndex) + For t = 0 to MaxIndex + Files(t) = StyleNames(t,0) + cStyles(t) = StyleNames(t,1) + Next t + On Local Error Resume Next + DialogModel.lbStyles.StringItemList() = cStyles() + ToggleWindow(True) + StylesDialog.Execute + End If + End If +End Sub + + +Sub SelectStyle +'This sub loads the specific styles from a style document and loads them into the +'current document. +Dim StylePath as String +Dim NewStyle as String +Dim Position as Integer + Position = DialogModel.lbStyles.SelectedItems(0) + If Position > -1 Then + ToggleWindow(False) + StylePath = Files(Position) + aOptions(0).Name = "OverwriteStyles" + aOptions(0).Value = true + oFamilies.loadStylesFromURL(StylePath, aOptions()) + ToggleWindow(True) + End If +End Sub + + +Sub SaveCurrentStyles(oDocument as Object) +'This sub stores the current document in the user work directory + On Error Goto ErrorOcurred + aTempURL = GetPathSettings("Work", False) + Dim aRightMost as String + aRightMost = Right(aTempURL, 1) + if aRightMost = "/" Then + aTempURL = aTempURL & aTempFileName + Else + aTempURL = aTempURL & "/" & aTempFileName + End If + + While FileExists(aTempURL) + aTempURL=Left(aTempURL,(Len(aTempURL)-4)) & "_1.stc" + Wend + oDocument.storeToURL(aTempURL, NoArgs()) + Exit Sub + +ErrorOcurred: + MsgBox(GetResText( STYLES+1 ), 16, GetResText( STYLES )) + On Local Error Goto 0 +End Sub + + +Sub RestoreCurrentStyles +'This sub retrieves the styles from the temporarily save document + ToggleWindow(False) + On Local Error Goto NoFile + If FileExists(aTempURL) Then + aOptions(0).Name = "OverwriteStyles" + aOptions(0).Value = true + oFamilies.LoadStylesFromURL(aTempURL, aOptions()) + KillTempFile() + End If + StylesDialog.EndExecute + ToggleWindow(True) +NOFILE: + If Err <> 0 Then + Msgbox("Cannot load Document from " & aTempUrl, 64, GetProductname()) + End If + On Local Error Goto 0 +End Sub + + +Sub CloseStyleDialog + KillTempFile() + DialogExited = True + StylesDialog.Endexecute +End Sub + + +Sub KillTempFile() + If oUcbObject.Exists(aTempUrl) Then + oUcbObject.Kill(aTempUrl) + End If +End Sub + + diff --git a/wizards/source/template/script.xlb b/wizards/source/template/script.xlb index 80e5074d5570..c89cc3788875 100644 --- a/wizards/source/template/script.xlb +++ b/wizards/source/template/script.xlb @@ -3,5 +3,6 @@ + diff --git a/wizards/source/template/template.src b/wizards/source/template/template.src index b749cb7fcdcc..9afa43b00a12 100644 --- a/wizards/source/template/template.src +++ b/wizards/source/template/template.src @@ -16,6 +16,9 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#define STYLES 1100 +#define STYLENAME_DEF 1120 +#define STYLENAME 1150 #define AgendaDlgName 1200 #define AgendaDlgNoCancel 1201 #define AgendaDlgFrame 1202 @@ -27,6 +30,206 @@ #define CorrespondenceFields 1350 #define TextField 1400 +String STYLES +{ + Text [ en-US ] = "Theme Selection"; +}; + +String STYLES + 1 +{ + Text [ en-US ] = "Error while saving the document to the clipboard! The following action cannot be undone."; +}; + +String STYLES + 2 +{ + Text [ en-US ] = "~Cancel"; +}; + +String STYLES + 3 +{ + Text [ en-US ] = "~OK"; +}; + +String STYLENAME_DEF +{ + Text = "(Standard)"; +}; + +String STYLENAME_DEF + 1 +{ + Text = "Autumn Leaves"; +}; + +String STYLENAME_DEF + 2 +{ + Text = "Be"; +}; + +String STYLENAME_DEF + 3 +{ + Text = "Black and White"; +}; + +String STYLENAME_DEF + 4 +{ + Text = "Blackberry Bush"; +}; + +String STYLENAME_DEF + 5 +{ + Text = "Blue Jeans"; +}; + +String STYLENAME_DEF + 6 +{ + Text = "Fifties Diner"; +}; + +String STYLENAME_DEF + 7 +{ + Text = "Glacier"; +}; + +String STYLENAME_DEF + 8 +{ + Text = "Green Grapes"; +}; + +String STYLENAME_DEF + 9 +{ + Text = "Marine"; +}; + +String STYLENAME_DEF + 10 +{ + Text = "Millennium"; +}; + +String STYLENAME_DEF + 11 +{ + Text = "Nature"; +}; + +String STYLENAME_DEF + 12 +{ + Text = "Neon"; +}; + +String STYLENAME_DEF + 13 +{ + Text = "Night"; +}; + +String STYLENAME_DEF + 14 +{ + Text = "PC Nostalgia"; +}; + +String STYLENAME_DEF + 15 +{ + Text = "Pastel"; +}; + +String STYLENAME_DEF + 16 +{ + Text = "Pool Party"; +}; + +String STYLENAME_DEF + 17 +{ + Text = "Pumpkin"; +}; + +String STYLENAME +{ + Text [ en-US ] = "(Standard)"; +}; + +String STYLENAME + 1 +{ + Text [ en-US ] = "Autumn Leaves"; +}; + +String STYLENAME + 2 +{ + Text [ en-US ] = "Be"; +}; + +String STYLENAME + 3 +{ + Text [ en-US ] = "Black and White"; +}; + +String STYLENAME + 4 +{ + Text [ en-US ] = "Blackberry Bush"; +}; + +String STYLENAME + 5 +{ + Text [ en-US ] = "Blue Jeans"; +}; + +String STYLENAME + 6 +{ + Text [ en-US ] = "Fifties Diner"; +}; + +String STYLENAME + 7 +{ + Text [ en-US ] = "Glacier"; +}; + +String STYLENAME + 8 +{ + Text [ en-US ] = "Green Grapes"; +}; + +String STYLENAME + 9 +{ + Text [ en-US ] = "Marine"; +}; + +String STYLENAME + 10 +{ + Text [ en-US ] = "Millennium"; +}; + +String STYLENAME + 11 +{ + Text [ en-US ] = "Nature"; +}; + +String STYLENAME + 12 +{ + Text [ en-US ] = "Neon"; +}; + +String STYLENAME + 13 +{ + Text [ en-US ] = "Night"; +}; + +String STYLENAME + 14 +{ + Text [ en-US ] = "PC Nostalgia"; +}; + +String STYLENAME + 15 +{ + Text [ en-US ] = "Pastel"; +}; + +String STYLENAME + 16 +{ + Text [ en-US ] = "Pool Party"; +}; + +String STYLENAME + 17 +{ + Text [ en-US ] = "Pumpkin"; +}; + String AgendaDlgName { Text [ en-US ] = "Minutes Template";