Kaydet (Commit) f13b1b61 authored tarafından Behrend Cornelius's avatar Behrend Cornelius

#104114# creation of new document modified

üst 005ffe4c
...@@ -23,66 +23,68 @@ Dim n, m, iAutoCount as Integer ...@@ -23,66 +23,68 @@ Dim n, m, iAutoCount as Integer
sDocumentTitle = "Installed AutoTexts" sDocumentTitle = "Installed AutoTexts"
' Open a new empty document ' Open a new empty document
oDocument = StarDesktop.LoadComponentFromURL("private:factory/swriter","_blank",0,NoArgs) oDocument = CreateNewDocument("swriter")
oDocument.DocumentInfo.Title = sDocumentTitle If Not IsNull(oDocument) Then
oDocuText = oDocument.Text oDocument.DocumentInfo.Title = sDocumentTitle
oDocuText = oDocument.Text
' Create The Character-templates ' Create The Character-templates
oCharStyles = oDocument.StyleFamilies.GetByName("CharacterStyles") oCharStyles = oDocument.StyleFamilies.GetByName("CharacterStyles")
' The Characterstyle for the Header that describes the Title of Autotextgroups ' The Characterstyle for the Header that describes the Title of Autotextgroups
oGroupTitleStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") oGroupTitleStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle")
oCharStyles.InsertbyName("AutoTextGroupTitle", oGroupTitleStyle) oCharStyles.InsertbyName("AutoTextGroupTitle", oGroupTitleStyle)
oGroupTitleStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD oGroupTitleStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD
oGroupTitleStyle.CharHeight = 14 oGroupTitleStyle.CharHeight = 14
' The Characterstyle for the Header that describes the Title of Autotextgroups ' The Characterstyle for the Header that describes the Title of Autotextgroups
oHeaderStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") oHeaderStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle")
oCharStyles.InsertbyName("AutoTextHeading", oHeaderStyle) oCharStyles.InsertbyName("AutoTextHeading", oHeaderStyle)
oHeaderStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD oHeaderStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD
' "Ordinary" Table Content ' "Ordinary" Table Content
oContentStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") oContentStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle")
oCharStyles.InsertbyName("TableContent", oContentStyle) oCharStyles.InsertbyName("TableContent", oContentStyle)
oAutoTextContainer = CreateUnoService("com.sun.star.text.AutoTextContainer") oAutoTextContainer = CreateUnoService("com.sun.star.text.AutoTextContainer")
oAutoTextCursor = oDocuText.CreateTextCursor() oAutoTextCursor = oDocuText.CreateTextCursor()
oAutoTextCursor.CharStyleName = "AutoTextGroupTitle" oAutoTextCursor.CharStyleName = "AutoTextGroupTitle"
' Link the Title with the following table ' Link the Title with the following table
oAutoTextCursor.ParaKeepTogether = True oAutoTextCursor.ParaKeepTogether = True
For n = 0 To oAutoTextContainer.Count - 1 For n = 0 To oAutoTextContainer.Count - 1
oAutoGroup = oAutoTextContainer.GetByIndex(n) oAutoGroup = oAutoTextContainer.GetByIndex(n)
oAutoTextCursor.SetString(oAutoGroup.Title) oAutoTextCursor.SetString(oAutoGroup.Title)
oAutoTextCursor.CollapseToEnd() oAutoTextCursor.CollapseToEnd()
oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oTable = oDocument.CreateInstance("com.sun.star.text.TextTable") oTable = oDocument.CreateInstance("com.sun.star.text.TextTable")
' Divide the table if necessary ' Divide the table if necessary
oTable.Split = True oTable.Split = True
' oTable.KeepTogether = False ' oTable.KeepTogether = False
oTable.RepeatHeadLine = True oTable.RepeatHeadLine = True
oAutoTextCursor.Text.InsertTextContent(oAutoTextCursor,oTable,False) oAutoTextCursor.Text.InsertTextContent(oAutoTextCursor,oTable,False)
InsertStringToCell("AutoText Name",oTable.GetCellbyPosition(0,0), "AutoTextHeading") InsertStringToCell("AutoText Name",oTable.GetCellbyPosition(0,0), "AutoTextHeading")
InsertStringToCell("AutoText Shortcut",oTable.GetCellbyPosition(1,0), "AutoTextHeading") InsertStringToCell("AutoText Shortcut",oTable.GetCellbyPosition(1,0), "AutoTextHeading")
' Insert one row at the bottom of the table ' Insert one row at the bottom of the table
oRows = oTable.Rows oRows = oTable.Rows
iAutoCount = oAutoGroup.Count iAutoCount = oAutoGroup.Count
For m = 0 To iAutoCount-1 For m = 0 To iAutoCount-1
' Insert the name and the title of all Autotexts ' Insert the name and the title of all Autotexts
oAutoText = oAutoGroup.GetByIndex(m) oAutoText = oAutoGroup.GetByIndex(m)
InsertStringToCell(oAutoGroup.Titles(m), oTable.GetCellbyPosition(0, m + 1), "TableContent") InsertStringToCell(oAutoGroup.Titles(m), oTable.GetCellbyPosition(0, m + 1), "TableContent")
InsertStringToCell(oAutoGroup.ElementNames(m), oTable.GetCellbyPosition(1, m + 1), "TableContent") InsertStringToCell(oAutoGroup.ElementNames(m), oTable.GetCellbyPosition(1, m + 1), "TableContent")
If m < iAutoCount-1 Then If m < iAutoCount-1 Then
oRows.InsertbyIndex(m + 2,1) oRows.InsertbyIndex(m + 2,1)
End If End If
Next m Next m
oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oAutoTextCursor.CollapseToEnd() oAutoTextCursor.CollapseToEnd()
Next n Next n
End If
End Sub End Sub
......
...@@ -31,52 +31,53 @@ Dim oCharStyles as Object ...@@ -31,52 +31,53 @@ Dim oCharStyles as Object
On Local Error Goto 0 On Local Error Goto 0
' Open a new document where all the texts are inserted ' Open a new document where all the texts are inserted
oLogDocument = StarDesktop.LoadComponentFromURL( "private:factory/swriter","_blank",0,NoArgs()) oLogDocument = CreateNewDocument("swriter")
oLogText = oLogDocument.Text If Not IsNull(oLogDocument) Then
oLogText = oLogDocument.Text
' create and define the character styles of the Log-document
oCharStyles = oLogDocument.StyleFamilies.GetByName("CharacterStyles") ' create and define the character styles of the Log-document
oLogHeaderStyle = oLogDocument.createInstance("com.sun.star.style.CharacterStyle") oCharStyles = oLogDocument.StyleFamilies.GetByName("CharacterStyles")
oCharStyles.InsertbyName("Log Header", oLogHeaderStyle) 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") oLogHeaderStyle.charWeight = com.sun.star.awt.FontWeight.BOLD
oCharStyles.InsertbyName("Log Body", oLogBodyTextStyle) 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() ' Insert the title of the activated document as a hyperlink
oHyperCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD oHyperCursor = oLogText.createTextCursor()
oHyperCursor.gotoStart(False) oHyperCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD
oHyperCursor.HyperLinkURL = oDocument.URL oHyperCursor.gotoStart(False)
oHyperCursor.HyperLinkTarget = oDocument.URL oHyperCursor.HyperLinkURL = oDocument.URL
If oDocument.DocumentInfo.Title <> "" Then oHyperCursor.HyperLinkTarget = oDocument.URL
oHyperCursor.HyperlinkName = oDocument.DocumentInfo.Title 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 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 End Sub
......
...@@ -39,20 +39,22 @@ Dim oPage As Object ...@@ -39,20 +39,22 @@ Dim oPage As Object
Sub Main() Sub Main()
Dim oStandardTemplate as Object Dim oStandardTemplate as Object
BasicLibraries.LoadLibrary("Tools") BasicLibraries.LoadLibrary("Tools")
oDocument = StarDesktop.LoadComponentFromURL("private:factory/sdraw","_blank",0, NoArgs()) oDocument = CreateNewDocument("sdraw")
oPage = oDocument.DrawPages(0) If Not IsNull(oDocument) Then
oStandardTemplate = oDocument.StyleFamilies.GetByName("graphics").GetByName("standard") oPage = oDocument.DrawPages(0)
oStandardTemplate.CharHeight = 10 oStandardTemplate = oDocument.StyleFamilies.GetByName("graphics").GetByName("standard")
oStandardTemplate.TextLeftDistance = 100 oStandardTemplate.CharHeight = 10
oStandardTemplate.TextRightDistance = 100 oStandardTemplate.TextLeftDistance = 100
oStandardTemplate.TextUpperDistance = 50 oStandardTemplate.TextRightDistance = 100
oStandardTemplate.TextLowerDistance = 50 oStandardTemplate.TextUpperDistance = 50
DlgReadDir = LoadDialog("Gimmicks","ReadFolderDlg") oStandardTemplate.TextLowerDistance = 50
oProgressBar = DlgReadDir.Model.ProgressBar1 DlgReadDir = LoadDialog("Gimmicks","ReadFolderDlg")
DlgReadDir.Model.TextField1.Text = ConvertFromUrl(GetPathSettings("Work")) oProgressBar = DlgReadDir.Model.ProgressBar1
DlgReadDir.Model.cmdGoOn.DefaultButton = True DlgReadDir.Model.TextField1.Text = ConvertFromUrl(GetPathSettings("Work"))
DlgReadDir.GetControl("TextField1").SetFocus() DlgReadDir.Model.cmdGoOn.DefaultButton = True
DlgReadDir.Execute DlgReadDir.GetControl("TextField1").SetFocus()
DlgReadDir.Execute
End If
End Sub End Sub
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment