1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?> 2*b1cdbd2cSJim Jagielski<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*b1cdbd2cSJim Jagielski<!--*********************************************************** 4*b1cdbd2cSJim Jagielski * 5*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 6*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 7*b1cdbd2cSJim Jagielski * distributed with this work for additional information 8*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 9*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 10*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 11*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 14*b1cdbd2cSJim Jagielski * 15*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 16*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 17*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 19*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 20*b1cdbd2cSJim Jagielski * under the License. 21*b1cdbd2cSJim Jagielski * 22*b1cdbd2cSJim Jagielski ***********************************************************--> 23*b1cdbd2cSJim Jagielski<script:module xmlns:script="http://openoffice.org/2000/script" script:name="GetTexts" script:language="StarBasic">Option Explicit 24*b1cdbd2cSJim Jagielski' Macro-Description: 25*b1cdbd2cSJim Jagielski' This Macro extracts the Strings out of the currently activated document und inserts them into a logdocument 26*b1cdbd2cSJim Jagielski' The aim of the macro is to provide the programmer an insight into the StarOffice API 27*b1cdbd2cSJim Jagielski' It focusses on how document-Objects are accessed. 28*b1cdbd2cSJim Jagielski' Therefor not only texts of the document-body are retrieved but also Texts of general 29*b1cdbd2cSJim Jagielski' document Objects like, Annotations, charts and general Document Information 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim JagielskiPublic oLogDocument, oLogText, oLogCursor, oLogHeaderStyle, oLogBodyTextStyle as Object 32*b1cdbd2cSJim JagielskiPublic oDocument as Object 33*b1cdbd2cSJim JagielskiPublic LogArray(1000) as String 34*b1cdbd2cSJim JagielskiPublic LogIndex as Integer 35*b1cdbd2cSJim JagielskiPublic oLocHeaderStyle as Object 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim JagielskiSub Main 38*b1cdbd2cSJim JagielskiDim sDocType as String 39*b1cdbd2cSJim JagielskiDim oHyperCursor as Object 40*b1cdbd2cSJim JagielskiDim oCharStyles as Object 41*b1cdbd2cSJim Jagielski BasicLibraries.LoadLibrary("Tools") 42*b1cdbd2cSJim Jagielski On Local Error GoTo NODOCUMENT 43*b1cdbd2cSJim Jagielski oDocument = StarDesktop.ActiveFrame.Controller.Model 44*b1cdbd2cSJim Jagielski sDocType = GetDocumentType(oDocument) 45*b1cdbd2cSJim Jagielski NODOCUMENT: 46*b1cdbd2cSJim Jagielski If Err <> 0 Then 47*b1cdbd2cSJim Jagielski Msgbox("This macro extracts all data from the active Writer, Calc or Draw document." & chr(13) &_ 48*b1cdbd2cSJim Jagielski "To start this macro you have to activate a document first." , 16, GetProductName) 49*b1cdbd2cSJim Jagielski Exit Sub 50*b1cdbd2cSJim Jagielski End If 51*b1cdbd2cSJim Jagielski On Local Error Goto 0 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim Jagielski ' Open a new document where all the texts are inserted 54*b1cdbd2cSJim Jagielski oLogDocument = CreateNewDocument("swriter") 55*b1cdbd2cSJim Jagielski If Not IsNull(oLogDocument) Then 56*b1cdbd2cSJim Jagielski oLogText = oLogDocument.Text 57*b1cdbd2cSJim Jagielski 58*b1cdbd2cSJim Jagielski ' create and define the character styles of the Log-document 59*b1cdbd2cSJim Jagielski oCharStyles = oLogDocument.StyleFamilies.GetByName("CharacterStyles") 60*b1cdbd2cSJim Jagielski oLogHeaderStyle = oLogDocument.createInstance("com.sun.star.style.CharacterStyle") 61*b1cdbd2cSJim Jagielski oCharStyles.InsertbyName("Log Header", oLogHeaderStyle) 62*b1cdbd2cSJim Jagielski 63*b1cdbd2cSJim Jagielski oLogHeaderStyle.charWeight = com.sun.star.awt.FontWeight.BOLD 64*b1cdbd2cSJim Jagielski oLogBodyTextStyle = oLogDocument.createInstance("com.sun.star.style.CharacterStyle") 65*b1cdbd2cSJim Jagielski oCharStyles.InsertbyName("Log Body", oLogBodyTextStyle) 66*b1cdbd2cSJim Jagielski 67*b1cdbd2cSJim Jagielski ' Insert the title of the activated document as a hyperlink 68*b1cdbd2cSJim Jagielski oHyperCursor = oLogText.createTextCursor() 69*b1cdbd2cSJim Jagielski oHyperCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD 70*b1cdbd2cSJim Jagielski oHyperCursor.gotoStart(False) 71*b1cdbd2cSJim Jagielski oHyperCursor.HyperLinkURL = oDocument.URL 72*b1cdbd2cSJim Jagielski oHyperCursor.HyperLinkTarget = oDocument.URL 73*b1cdbd2cSJim Jagielski If oDocument.DocumentProperties.Title <> "" Then 74*b1cdbd2cSJim Jagielski oHyperCursor.HyperlinkName = oDocument.DocumentProperties.Title 75*b1cdbd2cSJim Jagielski End If 76*b1cdbd2cSJim Jagielski oLogText.insertString(oHyperCursor, oDocument.DocumentProperties.Title, False) 77*b1cdbd2cSJim Jagielski oLogText.insertControlCharacter(oHyperCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) 78*b1cdbd2cSJim Jagielski 79*b1cdbd2cSJim Jagielski oLogCursor = oLogText.createTextCursor() 80*b1cdbd2cSJim Jagielski oLogCursor.GotoEnd(False) 81*b1cdbd2cSJim Jagielski ' "Switch off" the Hyperlink - Properties 82*b1cdbd2cSJim Jagielski oLogCursor.SetPropertyToDefault("HyperLinkURL") 83*b1cdbd2cSJim Jagielski oLogCursor.SetPropertyToDefault("HyperLinkTarget") 84*b1cdbd2cSJim Jagielski oLogCursor.SetPropertyToDefault("HyperLinkName") 85*b1cdbd2cSJim Jagielski LogIndex = 0 86*b1cdbd2cSJim Jagielski 87*b1cdbd2cSJim Jagielski ' Get the Properties of the document 88*b1cdbd2cSJim Jagielski GetDocumentProps() 89*b1cdbd2cSJim Jagielski 90*b1cdbd2cSJim Jagielski Select Case sDocType 91*b1cdbd2cSJim Jagielski Case "swriter" 92*b1cdbd2cSJim Jagielski GetWriterStrings() 93*b1cdbd2cSJim Jagielski Case "scalc" 94*b1cdbd2cSJim Jagielski GetCalcStrings() 95*b1cdbd2cSJim Jagielski Case "sdraw", "simpress" 96*b1cdbd2cSJim Jagielski GetDrawStrings() 97*b1cdbd2cSJim Jagielski Case Else 98*b1cdbd2cSJim Jagielski Msgbox("This macro only works with a Writer, Calc or Draw/Impress document.", 16, GetProductName()) 99*b1cdbd2cSJim Jagielski End Select 100*b1cdbd2cSJim Jagielski End If 101*b1cdbd2cSJim JagielskiEnd Sub 102*b1cdbd2cSJim Jagielski 103*b1cdbd2cSJim Jagielski 104*b1cdbd2cSJim Jagielski' ***********************************************Calc-Documents************************************************** 105*b1cdbd2cSJim Jagielski 106*b1cdbd2cSJim JagielskiSub GetCalcStrings() 107*b1cdbd2cSJim JagielskiDim i, n as integer 108*b1cdbd2cSJim JagielskiDim oSheet as Object 109*b1cdbd2cSJim JagielskiDim SheetName as String 110*b1cdbd2cSJim JagielskiDim oSheets as Object 111*b1cdbd2cSJim Jagielski ' Create a sequence of all sheets within the document 112*b1cdbd2cSJim Jagielski oSheets = oDocument.Sheets 113*b1cdbd2cSJim Jagielski 114*b1cdbd2cSJim Jagielski For i = 0 to osheets.Count - 1 115*b1cdbd2cSJim Jagielski oSheet = osheets.GetbyIndex(i) 116*b1cdbd2cSJim Jagielski SheetName = oSheet.Name 117*b1cdbd2cSJim Jagielski MakeLogHeadLine("Sheet No. " & i & "(" & SheetName & ")" ) 118*b1cdbd2cSJim Jagielski 119*b1cdbd2cSJim Jagielski ' Check the "body" of the sheet 120*b1cdbd2cSJim Jagielski GetCellTexts(oSheet) 121*b1cdbd2cSJim Jagielski 122*b1cdbd2cSJim Jagielski If oSheet.IsScenario then 123*b1cdbd2cSJim Jagielski MakeLogHeadLine("Scenario Comments from " & SheetName & "'") 124*b1cdbd2cSJim Jagielski WriteStringtoLogFile(osheet.ScenarioComment) 125*b1cdbd2cSJim Jagielski End if 126*b1cdbd2cSJim Jagielski 127*b1cdbd2cSJim Jagielski GetAnnotations(oSheet, "Annotations from '" & SheetName & "'") 128*b1cdbd2cSJim Jagielski 129*b1cdbd2cSJim Jagielski GetChartStrings(oSheet, "Charts from '" & SheetName & "'") 130*b1cdbd2cSJim Jagielski 131*b1cdbd2cSJim Jagielski GetControlStrings(oSheet.DrawPage, "Controls from '" & SheetName & "'") 132*b1cdbd2cSJim Jagielski Next 133*b1cdbd2cSJim Jagielski 134*b1cdbd2cSJim Jagielski ' Pictures 135*b1cdbd2cSJim Jagielski GetCalcGraphicNames() 136*b1cdbd2cSJim Jagielski 137*b1cdbd2cSJim Jagielski GetNamedRanges() 138*b1cdbd2cSJim JagielskiEnd Sub 139*b1cdbd2cSJim Jagielski 140*b1cdbd2cSJim Jagielski 141*b1cdbd2cSJim JagielskiSub GetCellTexts(oSheet as Object) 142*b1cdbd2cSJim JagielskiDim BigRange, BigEnum, oCell as Object 143*b1cdbd2cSJim Jagielski BigRange = oDocument.CreateInstance("com.sun.star.sheet.SheetCellRanges") 144*b1cdbd2cSJim Jagielski BigRange.InsertbyName("",oSheet) 145*b1cdbd2cSJim Jagielski BigEnum = BigRange.GetCells.CreateEnumeration 146*b1cdbd2cSJim Jagielski While BigEnum.hasmoreElements 147*b1cdbd2cSJim Jagielski oCell = BigEnum.NextElement 148*b1cdbd2cSJim Jagielski If oCell.String <> "" And Val(oCell.String) = 0then 149*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oCell.String) 150*b1cdbd2cSJim Jagielski End If 151*b1cdbd2cSJim Jagielski Wend 152*b1cdbd2cSJim JagielskiEnd Sub 153*b1cdbd2cSJim Jagielski 154*b1cdbd2cSJim Jagielski 155*b1cdbd2cSJim JagielskiSub GetAnnotations(oSheet as Object, HeaderLine as String) 156*b1cdbd2cSJim JagielskiDim oNotes as Object 157*b1cdbd2cSJim JagielskiDim n as Integer 158*b1cdbd2cSJim Jagielski oNotes = oSheet.getAnnotations 159*b1cdbd2cSJim Jagielski If oNotes.hasElements() then 160*b1cdbd2cSJim Jagielski MakeLogHeadLine(HeaderLine) 161*b1cdbd2cSJim Jagielski For n = 0 to oNotes.Count-1 162*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oNotes.GetbyIndex(n).String) 163*b1cdbd2cSJim Jagielski Next 164*b1cdbd2cSJim Jagielski End if 165*b1cdbd2cSJim JagielskiEnd Sub 166*b1cdbd2cSJim Jagielski 167*b1cdbd2cSJim Jagielski 168*b1cdbd2cSJim JagielskiSub GetNamedRanges() 169*b1cdbd2cSJim JagielskiDim i as integer 170*b1cdbd2cSJim Jagielski MakeLogHeadLine("Named Ranges") 171*b1cdbd2cSJim Jagielski For i = 0 To oDocument.NamedRanges.Count - 1 172*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oDocument.NamedRanges.GetbyIndex(i).Name) 173*b1cdbd2cSJim Jagielski Next 174*b1cdbd2cSJim JagielskiEnd Sub 175*b1cdbd2cSJim Jagielski 176*b1cdbd2cSJim Jagielski 177*b1cdbd2cSJim JagielskiSub GetCalcGraphicNames() 178*b1cdbd2cSJim JagielskiDim n,m as integer 179*b1cdbd2cSJim Jagielski MakeLogHeadLine("Graphics") 180*b1cdbd2cSJim Jagielski For n = 0 To oDocument.Drawpages.count-1 181*b1cdbd2cSJim Jagielski For m = 0 To oDocument.Drawpages.GetbyIndex(n).Count - 1 182*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oDocument.DrawPages.GetbyIndex(n).GetbyIndex(m).Text.String) 183*b1cdbd2cSJim Jagielski Next m 184*b1cdbd2cSJim Jagielski Next n 185*b1cdbd2cSJim JagielskiEnd Sub 186*b1cdbd2cSJim Jagielski 187*b1cdbd2cSJim Jagielski 188*b1cdbd2cSJim Jagielski' ***********************************************Writer-Documents************************************************** 189*b1cdbd2cSJim Jagielski 190*b1cdbd2cSJim JagielskiSub GetParagraphTexts(oParaObject as Object, HeadLine as String) 191*b1cdbd2cSJim JagielskiDim ParaEnum as Object 192*b1cdbd2cSJim JagielskiDim oPara as Object 193*b1cdbd2cSJim JagielskiDim oTextPortEnum as Object 194*b1cdbd2cSJim JagielskiDim oTextPortion as Object 195*b1cdbd2cSJim JagielskiDim i as integer 196*b1cdbd2cSJim JagielskiDim oCellNames() 197*b1cdbd2cSJim JagielskiDim oCell as Object 198*b1cdbd2cSJim Jagielski 199*b1cdbd2cSJim Jagielski MakeLogHeadLine(HeadLine) 200*b1cdbd2cSJim Jagielski ParaEnum = oParaObject.Text.CreateEnumeration 201*b1cdbd2cSJim Jagielski 202*b1cdbd2cSJim Jagielski While ParaEnum.HasMoreElements 203*b1cdbd2cSJim Jagielski oPara = ParaEnum.NextElement 204*b1cdbd2cSJim Jagielski 205*b1cdbd2cSJim Jagielski ' Note: The Enumeration ParaEnum lists all tables and Paragraphs. 206*b1cdbd2cSJim Jagielski ' Therefor we have to find out what kind of object "oPara" actually is 207*b1cdbd2cSJim Jagielski If oPara.supportsService("com.sun.star.text.Paragraph") Then 208*b1cdbd2cSJim Jagielski ' "oPara" is a Paragraph 209*b1cdbd2cSJim Jagielski oTextPortEnum = oPara.createEnumeration 210*b1cdbd2cSJim Jagielski While oTextPortEnum.hasmoreElements 211*b1cdbd2cSJim Jagielski oTextPortion = oTextPortEnum.nextElement() 212*b1cdbd2cSJim Jagielski WriteStringToLogFile(oTextPortion.String) 213*b1cdbd2cSJim Jagielski Wend 214*b1cdbd2cSJim Jagielski Else 215*b1cdbd2cSJim Jagielski ' "oPara" is a table 216*b1cdbd2cSJim Jagielski oCellNames = oPara.CellNames 217*b1cdbd2cSJim Jagielski For i = 0 To Ubound(oCellNames()) 218*b1cdbd2cSJim Jagielski If oCellNames(i) <> "" Then 219*b1cdbd2cSJim Jagielski oCell = oPara.getCellByName(oCellNames(i)) 220*b1cdbd2cSJim Jagielski WriteStringToLogFile(oCell.String) 221*b1cdbd2cSJim Jagielski End If 222*b1cdbd2cSJim Jagielski Next 223*b1cdbd2cSJim Jagielski End If 224*b1cdbd2cSJim Jagielski Wend 225*b1cdbd2cSJim JagielskiEnd Sub 226*b1cdbd2cSJim Jagielski 227*b1cdbd2cSJim Jagielski 228*b1cdbd2cSJim Jagielski 229*b1cdbd2cSJim JagielskiSub GetChartStrings(oSheet as Object, HeaderLine as String) 230*b1cdbd2cSJim JagielskiDim i as Integer 231*b1cdbd2cSJim JagielskiDim aChartObject as Object 232*b1cdbd2cSJim JagielskiDim aChartDiagram as Object 233*b1cdbd2cSJim Jagielski 234*b1cdbd2cSJim Jagielski MakeLogHeadLine(HeaderLine) 235*b1cdbd2cSJim Jagielski 236*b1cdbd2cSJim Jagielski For i = 0 to oSheet.Charts.Count-1 237*b1cdbd2cSJim Jagielski aChartObject = oSheet.Charts.GetByIndex(i).EmbeddedObject 238*b1cdbd2cSJim Jagielski If aChartObject.HasSubTitle then 239*b1cdbd2cSJim Jagielski WriteStringToLogFile(aChartObject.SubTitle.String) 240*b1cdbd2cSJim Jagielski End If 241*b1cdbd2cSJim Jagielski 242*b1cdbd2cSJim Jagielski If aChartObject.HasMainTitle then 243*b1cdbd2cSJim Jagielski WriteStringToLogFile(aChartObject.Title.String) 244*b1cdbd2cSJim Jagielski End If 245*b1cdbd2cSJim Jagielski 246*b1cdbd2cSJim Jagielski aChartDiagram = aChartObject.Diagram 247*b1cdbd2cSJim Jagielski 248*b1cdbd2cSJim Jagielski If aChartDiagram.hasXAxisTitle Then 249*b1cdbd2cSJim Jagielski WriteStringToLogFile(aChartDiagram.XAxisTitle) 250*b1cdbd2cSJim Jagielski End If 251*b1cdbd2cSJim Jagielski 252*b1cdbd2cSJim Jagielski If aChartDiagram.hasYAxisTitle Then 253*b1cdbd2cSJim Jagielski WriteStringToLogFile(aChartDiagram.YAxisTitle) 254*b1cdbd2cSJim Jagielski End If 255*b1cdbd2cSJim Jagielski 256*b1cdbd2cSJim Jagielski If aChartDiagram.hasZAxisTitle Then 257*b1cdbd2cSJim Jagielski WriteStringToLogFile(aChartDiagram.ZAxisTitle) 258*b1cdbd2cSJim Jagielski End If 259*b1cdbd2cSJim Jagielski Next i 260*b1cdbd2cSJim JagielskiEnd Sub 261*b1cdbd2cSJim Jagielski 262*b1cdbd2cSJim Jagielski 263*b1cdbd2cSJim Jagielski 264*b1cdbd2cSJim JagielskiSub GetFrameTexts() 265*b1cdbd2cSJim JagielskiDim i as integer 266*b1cdbd2cSJim JagielskiDim oTextFrame as object 267*b1cdbd2cSJim JagielskiDim oFrameEnum as Object 268*b1cdbd2cSJim JagielskiDim oFramePort as Object 269*b1cdbd2cSJim JagielskiDim oFrameTextEnum as Object 270*b1cdbd2cSJim JagielskiDim oFrameTextPort as Object 271*b1cdbd2cSJim Jagielski 272*b1cdbd2cSJim Jagielski MakeLogHeadLine("Text Frames") 273*b1cdbd2cSJim Jagielski For i = 0 to oDocument.TextFrames.Count-1 274*b1cdbd2cSJim Jagielski oTextFrame = oDocument.TextFrames.GetbyIndex(i) 275*b1cdbd2cSJim Jagielski WriteStringToLogFile(oTextFrame.Name) 276*b1cdbd2cSJim Jagielski 277*b1cdbd2cSJim Jagielski ' Is the frame bound to the Page 278*b1cdbd2cSJim Jagielski If oTextFrame.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE Then 279*b1cdbd2cSJim Jagielski GetParagraphTexts(oTextFrame, "Text Frame Contents") 280*b1cdbd2cSJim Jagielski End If 281*b1cdbd2cSJim Jagielski 282*b1cdbd2cSJim Jagielski oFrameEnum = oTextFrame.CreateEnumeration 283*b1cdbd2cSJim Jagielski While oFrameEnum.HasMoreElements 284*b1cdbd2cSJim Jagielski oFramePort = oFrameEnum.NextElement 285*b1cdbd2cSJim Jagielski If oFramePort.supportsService("com.sun.star.text.Paragraph") then 286*b1cdbd2cSJim Jagielski oFrameTextEnum = oFramePort.createEnumeration 287*b1cdbd2cSJim Jagielski While oFrameTextEnum.HasMoreElements 288*b1cdbd2cSJim Jagielski oFrameTextPort = oFrameTextEnum.NextElement 289*b1cdbd2cSJim Jagielski If oFrameTextPort.SupportsService("com.sun.star.text.TextFrame") Then 290*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oFrameTextPort.String) 291*b1cdbd2cSJim Jagielski End If 292*b1cdbd2cSJim Jagielski Wend 293*b1cdbd2cSJim Jagielski Else 294*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oFramePort.Name) 295*b1cdbd2cSJim Jagielski End if 296*b1cdbd2cSJim Jagielski Wend 297*b1cdbd2cSJim Jagielski Next 298*b1cdbd2cSJim JagielskiEnd Sub 299*b1cdbd2cSJim Jagielski 300*b1cdbd2cSJim Jagielski 301*b1cdbd2cSJim JagielskiSub GetTextFieldStrings() 302*b1cdbd2cSJim JagielskiDim aTextField as Object 303*b1cdbd2cSJim JagielskiDim i as integer 304*b1cdbd2cSJim JagielskiDim CurElement as Object 305*b1cdbd2cSJim Jagielski MakeLogHeadLine("Text Fields") 306*b1cdbd2cSJim Jagielski aTextfield = oDocument.getTextfields.CreateEnumeration 307*b1cdbd2cSJim Jagielski While aTextField.hasmoreElements 308*b1cdbd2cSJim Jagielski CurElement = aTextField.NextElement 309*b1cdbd2cSJim Jagielski If CurElement.PropertySetInfo.hasPropertybyName("Content") Then 310*b1cdbd2cSJim Jagielski WriteStringtoLogFile(CurElement.Content) 311*b1cdbd2cSJim Jagielski ElseIf CurElement.PropertySetInfo.hasPropertybyName("PlaceHolder") Then 312*b1cdbd2cSJim Jagielski WriteStringtoLogFile(CurElement.PlaceHolder) 313*b1cdbd2cSJim Jagielski WriteStringtoLogFile(CurElement.Hint) 314*b1cdbd2cSJim Jagielski ElseIf Curelement.TextFieldMaster.PropertySetInfo.HasPropertybyName("Content") then 315*b1cdbd2cSJim Jagielski WriteStringtoLogFile(CurElement.TextFieldMaster.Content) 316*b1cdbd2cSJim Jagielski End If 317*b1cdbd2cSJim Jagielski Wend 318*b1cdbd2cSJim JagielskiEnd Sub 319*b1cdbd2cSJim Jagielski 320*b1cdbd2cSJim Jagielski 321*b1cdbd2cSJim Jagielski 322*b1cdbd2cSJim JagielskiSub GetLinkedFileNames() 323*b1cdbd2cSJim JagielskiDim oDocSections as Object 324*b1cdbd2cSJim JagielskiDim LinkedFileName as String 325*b1cdbd2cSJim JagielskiDim i as Integer 326*b1cdbd2cSJim Jagielski If Right(oDocument.URL,3) = "sgl" Then 327*b1cdbd2cSJim Jagielski MakeLogHeadLine("Sub-documents") 328*b1cdbd2cSJim Jagielski oDocSections = oDocument.TextSections 329*b1cdbd2cSJim Jagielski For i = 0 to oDocSections.Count - 1 330*b1cdbd2cSJim Jagielski LinkedFileName = oDocSections.GetbyIndex(i).FileLink.FileURL 331*b1cdbd2cSJim Jagielski If LinkedFileName <> "" Then 332*b1cdbd2cSJim Jagielski WriteStringToLogFile(LinkedFileName) 333*b1cdbd2cSJim Jagielski End If 334*b1cdbd2cSJim Jagielski Next i 335*b1cdbd2cSJim Jagielski End If 336*b1cdbd2cSJim JagielskiEnd Sub 337*b1cdbd2cSJim Jagielski 338*b1cdbd2cSJim Jagielski 339*b1cdbd2cSJim JagielskiSub GetSectionNames() 340*b1cdbd2cSJim JagielskiDim i as integer 341*b1cdbd2cSJim JagielskiDim oDocSections as Object 342*b1cdbd2cSJim Jagielski MakeLogHeadLine("Sections") 343*b1cdbd2cSJim Jagielski oDocSections = oDocument.TextSections 344*b1cdbd2cSJim Jagielski For i = 0 to oDocSections.Count-1 345*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oDocSections.GetbyIndex(i).Name) 346*b1cdbd2cSJim Jagielski Next 347*b1cdbd2cSJim JagielskiEnd Sub 348*b1cdbd2cSJim Jagielski 349*b1cdbd2cSJim Jagielski 350*b1cdbd2cSJim JagielskiSub GetWriterStrings() 351*b1cdbd2cSJim Jagielski GetParagraphTexts(oDocument, "Document Body") 352*b1cdbd2cSJim Jagielski GetGraphicNames() 353*b1cdbd2cSJim Jagielski GetStyles() 354*b1cdbd2cSJim Jagielski GetControlStrings(oDocument.DrawPage, "Controls") 355*b1cdbd2cSJim Jagielski GetTextFieldStrings() 356*b1cdbd2cSJim Jagielski GetSectionNames() 357*b1cdbd2cSJim Jagielski GetFrameTexts() 358*b1cdbd2cSJim Jagielski GetHyperLinks 359*b1cdbd2cSJim Jagielski GetLinkedFileNames() 360*b1cdbd2cSJim JagielskiEnd Sub 361*b1cdbd2cSJim Jagielski 362*b1cdbd2cSJim Jagielski 363*b1cdbd2cSJim Jagielski' ***********************************************Draw-Documents************************************************** 364*b1cdbd2cSJim Jagielski 365*b1cdbd2cSJim JagielskiSub GetDrawPageTitles(LocObject as Object) 366*b1cdbd2cSJim JagielskiDim n as integer 367*b1cdbd2cSJim JagielskiDim oPage as Object 368*b1cdbd2cSJim Jagielski 369*b1cdbd2cSJim Jagielski For n = 0 to LocObject.Count - 1 370*b1cdbd2cSJim Jagielski oPage = LocObject.GetbyIndex(n) 371*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oPage.Name) 372*b1cdbd2cSJim Jagielski ' Is the Page a DrawPage and not a MasterPage? 373*b1cdbd2cSJim Jagielski If oPage.supportsService("com.sun.star.drawing.DrawPage")then 374*b1cdbd2cSJim Jagielski ' Get the Name of the NotesPage (only relevant for Impress-Documents) 375*b1cdbd2cSJim Jagielski If oDocument.supportsService("com.sun.star.presentation.PresentationDocument") then 376*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oPage.NotesPage.Name) 377*b1cdbd2cSJim Jagielski End If 378*b1cdbd2cSJim Jagielski End If 379*b1cdbd2cSJim Jagielski Next 380*b1cdbd2cSJim JagielskiEnd Sub 381*b1cdbd2cSJim Jagielski 382*b1cdbd2cSJim Jagielski 383*b1cdbd2cSJim JagielskiSub GetPageStrings(oPages as Object) 384*b1cdbd2cSJim JagielskiDim m, n, s as Integer 385*b1cdbd2cSJim JagielskiDim oPage, oPageElement, oShape as Object 386*b1cdbd2cSJim Jagielski For n = 0 to oPages.Count-1 387*b1cdbd2cSJim Jagielski oPage = oPages.GetbyIndex(n) 388*b1cdbd2cSJim Jagielski If oPage.HasElements then 389*b1cdbd2cSJim Jagielski For m = 0 to oPage.Count-1 390*b1cdbd2cSJim Jagielski oPageElement = oPage.GetByIndex(m) 391*b1cdbd2cSJim Jagielski If HasUnoInterfaces(oPageElement,"com.sun.star.container.XIndexAccess") Then 392*b1cdbd2cSJim Jagielski ' The Object "oPageElement" a group of Shapes, that can be accessed by their index 393*b1cdbd2cSJim Jagielski For s = 0 To oPageElement.Count - 1 394*b1cdbd2cSJim Jagielski WriteStringToLogFile(oPageElement.GetByIndex(s).String) 395*b1cdbd2cSJim Jagielski Next s 396*b1cdbd2cSJim Jagielski ElseIf HasUnoInterfaces(oPageElement, "com.sun.star.text.XText") Then 397*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oPageElement.String) 398*b1cdbd2cSJim Jagielski End If 399*b1cdbd2cSJim Jagielski Next 400*b1cdbd2cSJim Jagielski End If 401*b1cdbd2cSJim Jagielski Next 402*b1cdbd2cSJim JagielskiEnd Sub 403*b1cdbd2cSJim Jagielski 404*b1cdbd2cSJim Jagielski 405*b1cdbd2cSJim JagielskiSub GetDrawStrings() 406*b1cdbd2cSJim JagielskiDim oDPages, oMPages as Object 407*b1cdbd2cSJim Jagielski 408*b1cdbd2cSJim Jagielski oDPages = oDocument.DrawPages 409*b1cdbd2cSJim Jagielski oMPages = oDocument.Masterpages 410*b1cdbd2cSJim Jagielski 411*b1cdbd2cSJim Jagielski MakeLogHeadLine("Titles") 412*b1cdbd2cSJim Jagielski GetDrawPageTitles(oDPages) 413*b1cdbd2cSJim Jagielski GetDrawPageTitles(oMPages) 414*b1cdbd2cSJim Jagielski 415*b1cdbd2cSJim Jagielski MakeLogHeadLine("Document Body") 416*b1cdbd2cSJim Jagielski GetPageStrings(oDPages) 417*b1cdbd2cSJim Jagielski GetPageStrings(oMPages) 418*b1cdbd2cSJim JagielskiEnd Sub 419*b1cdbd2cSJim Jagielski 420*b1cdbd2cSJim Jagielski 421*b1cdbd2cSJim Jagielski' ***********************************************Misc************************************************** 422*b1cdbd2cSJim Jagielski 423*b1cdbd2cSJim JagielskiSub GetDocumentProps() 424*b1cdbd2cSJim JagielskiDim oDocuProps as Object 425*b1cdbd2cSJim Jagielski MakeLogHeadLine("Document Properties") 426*b1cdbd2cSJim Jagielski oDocuProps = oDocument.DocumentProperties 427*b1cdbd2cSJim Jagielski WriteStringToLogFile(oDocuProps.Title) 428*b1cdbd2cSJim Jagielski WriteStringToLogFile(oDocuProps.Description) 429*b1cdbd2cSJim Jagielski WriteStringToLogFile(oDocuProps.Subject) 430*b1cdbd2cSJim Jagielski WriteStringToLogFile(oDocuProps.Author) 431*b1cdbd2cSJim Jagielski' WriteStringToLogFile(oDocuProps.UserDefinedProperties.ReplyTo) 432*b1cdbd2cSJim Jagielski' WriteStringToLogFile(oDocuProps.UserDefinedProperties.Recipient) 433*b1cdbd2cSJim Jagielski' WriteStringToLogFile(oDocuProps.UserDefinedProperties.References) 434*b1cdbd2cSJim Jagielski' WriteStringToLogFile(oDocuProps.Keywords) 435*b1cdbd2cSJim JagielskiEnd Sub 436*b1cdbd2cSJim Jagielski 437*b1cdbd2cSJim Jagielski 438*b1cdbd2cSJim JagielskiSub GetHyperlinks() 439*b1cdbd2cSJim JagielskiDim i as integer 440*b1cdbd2cSJim JagielskiDim oCrsr as Object 441*b1cdbd2cSJim JagielskiDim oAllHyperLinks as Object 442*b1cdbd2cSJim JagielskiDim SrchAttributes(0) as new com.sun.star.beans.PropertyValue 443*b1cdbd2cSJim JagielskiDim oSearchDesc as Object 444*b1cdbd2cSJim Jagielski 445*b1cdbd2cSJim Jagielski MakeLogHeadLine("Hyperlinks") 446*b1cdbd2cSJim Jagielski ' create a Search-Descriptor 447*b1cdbd2cSJim Jagielski oSearchDesc = oDocument.CreateSearchDescriptor 448*b1cdbd2cSJim Jagielski oSearchDesc.Valuesearch = False 449*b1cdbd2cSJim Jagielski 450*b1cdbd2cSJim Jagielski ' define the Search-attributes 451*b1cdbd2cSJim Jagielski srchattributes(0).Name = "HyperLinkURL" 452*b1cdbd2cSJim Jagielski srchattributes(0).Value = "" 453*b1cdbd2cSJim Jagielski oSearchDesc.SetSearchAttributes(SrchAttributes()) 454*b1cdbd2cSJim Jagielski 455*b1cdbd2cSJim Jagielski oAllHyperLinks = oDocument.findAll(oSearchDesc()) 456*b1cdbd2cSJim Jagielski 457*b1cdbd2cSJim Jagielski For i = 0 to oAllHyperLinks.Count - 1 458*b1cdbd2cSJim Jagielski oFound = oAllHyperLinks(i) 459*b1cdbd2cSJim Jagielski oCrsr = oFound.Text.createTextCursorByRange(oFound) 460*b1cdbd2cSJim Jagielski WriteStringToLogFile(oCrs.HyperLinkURL) 'Url 461*b1cdbd2cSJim Jagielski WriteStringToLogFile(oCrs.HyperLinkTarget) 'Name 462*b1cdbd2cSJim Jagielski WriteStringToLogFile(oCrs.HyperLinkName) 'Frame 463*b1cdbd2cSJim Jagielski Next i 464*b1cdbd2cSJim JagielskiEnd Sub 465*b1cdbd2cSJim Jagielski 466*b1cdbd2cSJim Jagielski 467*b1cdbd2cSJim JagielskiSub GetGraphicNames() 468*b1cdbd2cSJim JagielskiDim i as integer 469*b1cdbd2cSJim JagielskiDim oDocGraphics as Object 470*b1cdbd2cSJim Jagielski MakeLogHeadLine("Graphics") 471*b1cdbd2cSJim Jagielski oDocGraphics = oDocument.GraphicObjects 472*b1cdbd2cSJim Jagielski For i = 0 to oDocGraphics.count - 1 473*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oDocGraphics.GetbyIndex(i).Name) 474*b1cdbd2cSJim Jagielski Next 475*b1cdbd2cSJim JagielskiEnd Sub 476*b1cdbd2cSJim Jagielski 477*b1cdbd2cSJim Jagielski 478*b1cdbd2cSJim JagielskiSub GetStyles() 479*b1cdbd2cSJim JagielskiDim m,n as integer 480*b1cdbd2cSJim Jagielski MakeLogHeadLine("User-defined Templates") 481*b1cdbd2cSJim Jagielski 482*b1cdbd2cSJim Jagielski ' Check all StyleFamilies(i.e. PageStyles, ParagraphStyles, CharacterStyles, cellStyles) 483*b1cdbd2cSJim Jagielski For n = 0 to oDocument.StyleFamilies.Count - 1 484*b1cdbd2cSJim Jagielski For m = 0 to oDocument.StyleFamilies.getbyIndex(n).Count-1 485*b1cdbd2cSJim Jagielski If oDocument.StyleFamilies.GetbyIndex(n).getbyIndex(m).IsUserDefined then 486*b1cdbd2cSJim Jagielski WriteStringtoLogFile(oDocument.StyleFamilies.GetbyIndex(n).getbyIndex(m).Name) 487*b1cdbd2cSJim Jagielski End If 488*b1cdbd2cSJim Jagielski Next 489*b1cdbd2cSJim Jagielski Next 490*b1cdbd2cSJim JagielskiEnd Sub 491*b1cdbd2cSJim Jagielski 492*b1cdbd2cSJim Jagielski 493*b1cdbd2cSJim JagielskiSub GetControlStrings(oDPage as Object, HeaderLine as String) 494*b1cdbd2cSJim JagielskiDim aForm as Object 495*b1cdbd2cSJim JagielskiDim m,n as integer 496*b1cdbd2cSJim Jagielski MakeLogHeadLine(HeaderLine) 497*b1cdbd2cSJim Jagielski 'SearchFor all possible Controls 498*b1cdbd2cSJim Jagielski For n = 0 to oDPage.Forms.Count - 1 499*b1cdbd2cSJim Jagielski aForm = oDPage.Forms(n) 500*b1cdbd2cSJim Jagielski For m = 0 to aForm.Count-1 501*b1cdbd2cSJim Jagielski GetControlContent(aForm.GetbyIndex(m)) 502*b1cdbd2cSJim Jagielski Next 503*b1cdbd2cSJim Jagielski Next 504*b1cdbd2cSJim JagielskiEnd Sub 505*b1cdbd2cSJim Jagielski 506*b1cdbd2cSJim Jagielski 507*b1cdbd2cSJim JagielskiSub GetControlContent(LocControl as Object) 508*b1cdbd2cSJim JagielskiDim i as integer 509*b1cdbd2cSJim Jagielski 510*b1cdbd2cSJim Jagielski If LocControl.PropertySetInfo.HasPropertybyName("Label") then 511*b1cdbd2cSJim Jagielski WriteStringtoLogFile(LocControl.Label) 512*b1cdbd2cSJim Jagielski 513*b1cdbd2cSJim Jagielski ElseIf LocControl.SupportsService("com.sun.star.form.component.ListBox") then 514*b1cdbd2cSJim Jagielski For i = 0 to Ubound(LocControl.StringItemList()) 515*b1cdbd2cSJim Jagielski WriteStringtoLogFile(LocControl.StringItemList(i)) 516*b1cdbd2cSJim Jagielski Next 517*b1cdbd2cSJim Jagielski End If 518*b1cdbd2cSJim Jagielski If LocControl.PropertySetInfo.HasPropertybyName("HelpText") then 519*b1cdbd2cSJim Jagielski WriteStringtoLogFile(LocControl.Helptext) 520*b1cdbd2cSJim Jagielski End If 521*b1cdbd2cSJim JagielskiEnd Sub 522*b1cdbd2cSJim Jagielski 523*b1cdbd2cSJim Jagielski' ***********************************************LogDocument************************************************** 524*b1cdbd2cSJim Jagielski 525*b1cdbd2cSJim JagielskiSub WriteStringtoLogFile( sString as String) 526*b1cdbd2cSJim Jagielski If (Not FieldInArray(LogArray(),LogIndex,sString))AND (NOT ISNULL(sString)) Then 527*b1cdbd2cSJim Jagielski LogArray(LogIndex) = sString 528*b1cdbd2cSJim Jagielski LogIndex = LogIndex + 1 529*b1cdbd2cSJim Jagielski oLogText.insertString(oLogCursor,sString,False) 530*b1cdbd2cSJim Jagielski oLogText.insertControlCharacter(oLogCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) 531*b1cdbd2cSJim Jagielski End If 532*b1cdbd2cSJim JagielskiEnd Sub 533*b1cdbd2cSJim Jagielski 534*b1cdbd2cSJim Jagielski 535*b1cdbd2cSJim JagielskiSub MakeLogHeadLine(HeadText as String) 536*b1cdbd2cSJim Jagielski oLogCursor.CharStyleName = "Log Header" 537*b1cdbd2cSJim Jagielski oLogText.insertControlCharacter(oLogCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) 538*b1cdbd2cSJim Jagielski oLogText.insertString(oLogCursor,HeadText,False) 539*b1cdbd2cSJim Jagielski oLogText.insertControlCharacter(oLogCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) 540*b1cdbd2cSJim Jagielski oLogCursor.CharStyleName = "Log Body" 541*b1cdbd2cSJim JagielskiEnd Sub 542*b1cdbd2cSJim Jagielski</script:module> 543