diff options
-rw-r--r-- | wizards/source/gimmicks/AutoText.xba | 104 | ||||
-rw-r--r-- | wizards/source/gimmicks/GetTexts.xba | 91 | ||||
-rw-r--r-- | wizards/source/gimmicks/ReadDir.xba | 30 |
3 files changed, 115 insertions, 110 deletions
diff --git a/wizards/source/gimmicks/AutoText.xba b/wizards/source/gimmicks/AutoText.xba index 56e9f4ee047f..6950b830eb79 100644 --- a/wizards/source/gimmicks/AutoText.xba +++ b/wizards/source/gimmicks/AutoText.xba @@ -23,66 +23,68 @@ Dim n, m, iAutoCount as Integer sDocumentTitle = "Installed AutoTexts" ' Open a new empty document - oDocument = StarDesktop.LoadComponentFromURL("private:factory/swriter","_blank",0,NoArgs) - oDocument.DocumentInfo.Title = sDocumentTitle - oDocuText = oDocument.Text + oDocument = CreateNewDocument("swriter") + If Not IsNull(oDocument) Then + oDocument.DocumentInfo.Title = sDocumentTitle + oDocuText = oDocument.Text - ' Create The Character-templates - oCharStyles = oDocument.StyleFamilies.GetByName("CharacterStyles") + ' Create The Character-templates + oCharStyles = oDocument.StyleFamilies.GetByName("CharacterStyles") - ' The Characterstyle for the Header that describes the Title of Autotextgroups - oGroupTitleStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") - oCharStyles.InsertbyName("AutoTextGroupTitle", oGroupTitleStyle) + ' The Characterstyle for the Header that describes the Title of Autotextgroups + oGroupTitleStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("AutoTextGroupTitle", oGroupTitleStyle) - oGroupTitleStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD - oGroupTitleStyle.CharHeight = 14 + oGroupTitleStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD + oGroupTitleStyle.CharHeight = 14 - ' The Characterstyle for the Header that describes the Title of Autotextgroups - oHeaderStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") - oCharStyles.InsertbyName("AutoTextHeading", oHeaderStyle) - oHeaderStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD + ' The Characterstyle for the Header that describes the Title of Autotextgroups + oHeaderStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("AutoTextHeading", oHeaderStyle) + oHeaderStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD - ' "Ordinary" Table Content - oContentStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") - oCharStyles.InsertbyName("TableContent", oContentStyle) + ' "Ordinary" Table Content + oContentStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("TableContent", oContentStyle) - oAutoTextContainer = CreateUnoService("com.sun.star.text.AutoTextContainer") - - oAutoTextCursor = oDocuText.CreateTextCursor() + oAutoTextContainer = CreateUnoService("com.sun.star.text.AutoTextContainer") + + oAutoTextCursor = oDocuText.CreateTextCursor() - oAutoTextCursor.CharStyleName = "AutoTextGroupTitle" - ' Link the Title with the following table - oAutoTextCursor.ParaKeepTogether = True + oAutoTextCursor.CharStyleName = "AutoTextGroupTitle" + ' Link the Title with the following table + oAutoTextCursor.ParaKeepTogether = True - For n = 0 To oAutoTextContainer.Count - 1 - oAutoGroup = oAutoTextContainer.GetByIndex(n) + For n = 0 To oAutoTextContainer.Count - 1 + oAutoGroup = oAutoTextContainer.GetByIndex(n) - oAutoTextCursor.SetString(oAutoGroup.Title) - oAutoTextCursor.CollapseToEnd() - oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) - oTable = oDocument.CreateInstance("com.sun.star.text.TextTable") - ' Divide the table if necessary - oTable.Split = True -' oTable.KeepTogether = False - oTable.RepeatHeadLine = True - oAutoTextCursor.Text.InsertTextContent(oAutoTextCursor,oTable,False) - InsertStringToCell("AutoText Name",oTable.GetCellbyPosition(0,0), "AutoTextHeading") - InsertStringToCell("AutoText Shortcut",oTable.GetCellbyPosition(1,0), "AutoTextHeading") - ' Insert one row at the bottom of the table - oRows = oTable.Rows - iAutoCount = oAutoGroup.Count - For m = 0 To iAutoCount-1 - ' Insert the name and the title of all Autotexts - oAutoText = oAutoGroup.GetByIndex(m) - InsertStringToCell(oAutoGroup.Titles(m), oTable.GetCellbyPosition(0, m + 1), "TableContent") - InsertStringToCell(oAutoGroup.ElementNames(m), oTable.GetCellbyPosition(1, m + 1), "TableContent") - If m < iAutoCount-1 Then - oRows.InsertbyIndex(m + 2,1) - End If - Next m - oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) - oAutoTextCursor.CollapseToEnd() - Next n + oAutoTextCursor.SetString(oAutoGroup.Title) + oAutoTextCursor.CollapseToEnd() + oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) + oTable = oDocument.CreateInstance("com.sun.star.text.TextTable") + ' Divide the table if necessary + oTable.Split = True +' oTable.KeepTogether = False + oTable.RepeatHeadLine = True + oAutoTextCursor.Text.InsertTextContent(oAutoTextCursor,oTable,False) + InsertStringToCell("AutoText Name",oTable.GetCellbyPosition(0,0), "AutoTextHeading") + InsertStringToCell("AutoText Shortcut",oTable.GetCellbyPosition(1,0), "AutoTextHeading") + ' Insert one row at the bottom of the table + oRows = oTable.Rows + iAutoCount = oAutoGroup.Count + For m = 0 To iAutoCount-1 + ' Insert the name and the title of all Autotexts + oAutoText = oAutoGroup.GetByIndex(m) + InsertStringToCell(oAutoGroup.Titles(m), oTable.GetCellbyPosition(0, m + 1), "TableContent") + InsertStringToCell(oAutoGroup.ElementNames(m), oTable.GetCellbyPosition(1, m + 1), "TableContent") + If m < iAutoCount-1 Then + oRows.InsertbyIndex(m + 2,1) + End If + Next m + oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) + oAutoTextCursor.CollapseToEnd() + Next n + End If End Sub diff --git a/wizards/source/gimmicks/GetTexts.xba b/wizards/source/gimmicks/GetTexts.xba index 5d266adf17ef..ed921a5e3948 100644 --- a/wizards/source/gimmicks/GetTexts.xba +++ b/wizards/source/gimmicks/GetTexts.xba @@ -31,52 +31,53 @@ Dim oCharStyles as Object On Local Error Goto 0 ' Open a new document where all the texts are inserted - oLogDocument = StarDesktop.LoadComponentFromURL( "private:factory/swriter","_blank",0,NoArgs()) - oLogText = oLogDocument.Text - - ' create and define the character styles of the Log-document - oCharStyles = oLogDocument.StyleFamilies.GetByName("CharacterStyles") - oLogHeaderStyle = oLogDocument.createInstance("com.sun.star.style.CharacterStyle") - oCharStyles.InsertbyName("Log Header", oLogHeaderStyle) - - oLogHeaderStyle.charWeight = com.sun.star.awt.FontWeight.BOLD - oLogBodyTextStyle = oLogDocument.createInstance("com.sun.star.style.CharacterStyle") - oCharStyles.InsertbyName("Log Body", oLogBodyTextStyle) - - ' Insert the title of the activated document as a hyperlink - oHyperCursor = oLogText.createTextCursor() - oHyperCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD - oHyperCursor.gotoStart(False) - oHyperCursor.HyperLinkURL = oDocument.URL - oHyperCursor.HyperLinkTarget = oDocument.URL - If oDocument.DocumentInfo.Title <> "" Then - oHyperCursor.HyperlinkName = oDocument.DocumentInfo.Title + oLogDocument = CreateNewDocument("swriter") + If Not IsNull(oLogDocument) Then + oLogText = oLogDocument.Text + + ' create and define the character styles of the Log-document + oCharStyles = oLogDocument.StyleFamilies.GetByName("CharacterStyles") + oLogHeaderStyle = oLogDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("Log Header", oLogHeaderStyle) + + oLogHeaderStyle.charWeight = com.sun.star.awt.FontWeight.BOLD + oLogBodyTextStyle = oLogDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("Log Body", oLogBodyTextStyle) + + ' Insert the title of the activated document as a hyperlink + oHyperCursor = oLogText.createTextCursor() + oHyperCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD + oHyperCursor.gotoStart(False) + oHyperCursor.HyperLinkURL = oDocument.URL + oHyperCursor.HyperLinkTarget = oDocument.URL + If oDocument.DocumentInfo.Title <> "" Then + oHyperCursor.HyperlinkName = oDocument.DocumentInfo.Title + End If + oLogText.insertString(oHyperCursor, oDocument.DocumentInfo.Title, False) + oLogText.insertControlCharacter(oHyperCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) + + oLogCursor = oLogText.createTextCursor() + oLogCursor.GotoEnd(False) + ' "Switch off" the Hyperlink - Properties + oLogCursor.SetPropertyToDefault("HyperLinkURL") + oLogCursor.SetPropertyToDefault("HyperLinkTarget") + oLogCursor.SetPropertyToDefault("HyperLinkName") + LogIndex = 0 + + ' Get the Properties of the document Info + GetDocumentInfo() + + Select Case sDocType + Case "swriter" + GetWriterStrings() + Case "scalc" + GetCalcStrings() + Case "sdraw" + GetDrawStrings() + Case Else + Msgbox("This macro only works with a Writer, Calc or Draw/Impress document.", 16, GetProductName()) + End Select End If - oLogText.insertString(oHyperCursor, oDocument.DocumentInfo.Title, False) - oLogText.insertControlCharacter(oHyperCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) - - oLogCursor = oLogText.createTextCursor() - oLogCursor.GotoEnd(False) - ' "Switch off" the Hyperlink - Properties - oLogCursor.SetPropertyToDefault("HyperLinkURL") - oLogCursor.SetPropertyToDefault("HyperLinkTarget") - oLogCursor.SetPropertyToDefault("HyperLinkName") - LogIndex = 0 - - ' Get the Properties of the document Info - GetDocumentInfo() - - Select Case sDocType - Case "swriter" - GetWriterStrings() - Case "scalc" - GetCalcStrings() - Case "sdraw" - GetDrawStrings() - Case Else - Msgbox("This macro only works with a Writer, Calc or Draw/Impress document.", 16, GetProductName()) - End Select - End Sub diff --git a/wizards/source/gimmicks/ReadDir.xba b/wizards/source/gimmicks/ReadDir.xba index c7dd1f7f44a2..370f8cbc1915 100644 --- a/wizards/source/gimmicks/ReadDir.xba +++ b/wizards/source/gimmicks/ReadDir.xba @@ -39,20 +39,22 @@ Dim oPage As Object Sub Main() Dim oStandardTemplate as Object BasicLibraries.LoadLibrary("Tools") - oDocument = StarDesktop.LoadComponentFromURL("private:factory/sdraw","_blank",0, NoArgs()) - oPage = oDocument.DrawPages(0) - oStandardTemplate = oDocument.StyleFamilies.GetByName("graphics").GetByName("standard") - oStandardTemplate.CharHeight = 10 - oStandardTemplate.TextLeftDistance = 100 - oStandardTemplate.TextRightDistance = 100 - oStandardTemplate.TextUpperDistance = 50 - oStandardTemplate.TextLowerDistance = 50 - DlgReadDir = LoadDialog("Gimmicks","ReadFolderDlg") - oProgressBar = DlgReadDir.Model.ProgressBar1 - DlgReadDir.Model.TextField1.Text = ConvertFromUrl(GetPathSettings("Work")) - DlgReadDir.Model.cmdGoOn.DefaultButton = True - DlgReadDir.GetControl("TextField1").SetFocus() - DlgReadDir.Execute + oDocument = CreateNewDocument("sdraw") + If Not IsNull(oDocument) Then + oPage = oDocument.DrawPages(0) + oStandardTemplate = oDocument.StyleFamilies.GetByName("graphics").GetByName("standard") + oStandardTemplate.CharHeight = 10 + oStandardTemplate.TextLeftDistance = 100 + oStandardTemplate.TextRightDistance = 100 + oStandardTemplate.TextUpperDistance = 50 + oStandardTemplate.TextLowerDistance = 50 + DlgReadDir = LoadDialog("Gimmicks","ReadFolderDlg") + oProgressBar = DlgReadDir.Model.ProgressBar1 + DlgReadDir.Model.TextField1.Text = ConvertFromUrl(GetPathSettings("Work")) + DlgReadDir.Model.cmdGoOn.DefaultButton = True + DlgReadDir.GetControl("TextField1").SetFocus() + DlgReadDir.Execute + End If End Sub |