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