1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
33e02b54dSAndrew Rist<!--***********************************************************
43e02b54dSAndrew Rist *
53e02b54dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
63e02b54dSAndrew Rist * or more contributor license agreements.  See the NOTICE file
73e02b54dSAndrew Rist * distributed with this work for additional information
83e02b54dSAndrew Rist * regarding copyright ownership.  The ASF licenses this file
93e02b54dSAndrew Rist * to you under the Apache License, Version 2.0 (the
103e02b54dSAndrew Rist * "License"); you may not use this file except in compliance
113e02b54dSAndrew Rist * with the License.  You may obtain a copy of the License at
123e02b54dSAndrew Rist *
133e02b54dSAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
143e02b54dSAndrew Rist *
153e02b54dSAndrew Rist * Unless required by applicable law or agreed to in writing,
163e02b54dSAndrew Rist * software distributed under the License is distributed on an
173e02b54dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
183e02b54dSAndrew Rist * KIND, either express or implied.  See the License for the
193e02b54dSAndrew Rist * specific language governing permissions and limitations
203e02b54dSAndrew Rist * under the License.
213e02b54dSAndrew Rist *
223e02b54dSAndrew Rist ***********************************************************-->
23cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="GetTexts" script:language="StarBasic">Option Explicit
24*0a50a83bSMatthias Seidel&apos; Description:
25*0a50a83bSMatthias Seidel&apos; This macro extracts the strings out of the currently active document and inserts them into a log document.
26*0a50a83bSMatthias Seidel&apos; The aim of the macro is to provide the programmer an insight into the OpenOffice API.
27*0a50a83bSMatthias Seidel&apos; It focuses on how document objects are accessed.
28*0a50a83bSMatthias Seidel&apos; Therefore not only texts of the document body are retrieved but also texts of general
29*0a50a83bSMatthias Seidel&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
41*0a50a83bSMatthias Seidel	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
47*0a50a83bSMatthias Seidel		Msgbox(&quot;This macro extracts all data from the active Writer, Calc or Draw/Impress 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
58*0a50a83bSMatthias Seidel		&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
104*0a50a83bSMatthias Seidel&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
117*0a50a83bSMatthias Seidel		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
188*0a50a83bSMatthias Seidel&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
205*0a50a83bSMatthias Seidel		&apos; Note: The enumeration ParaEnum lists all tables and paragraphs.
206*0a50a83bSMatthias Seidel		&apos; Therefore 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
228cdf0e10cSrcweirSub GetChartStrings(oSheet as Object, HeaderLine as String)
229cdf0e10cSrcweirDim i as Integer
230cdf0e10cSrcweirDim aChartObject as Object
231cdf0e10cSrcweirDim aChartDiagram as Object
232cdf0e10cSrcweir
233cdf0e10cSrcweir	MakeLogHeadLine(HeaderLine)
234cdf0e10cSrcweir
235cdf0e10cSrcweir	For i = 0 to oSheet.Charts.Count-1
236cdf0e10cSrcweir		aChartObject = oSheet.Charts.GetByIndex(i).EmbeddedObject
237cdf0e10cSrcweir		If aChartObject.HasSubTitle then
238cdf0e10cSrcweir			WriteStringToLogFile(aChartObject.SubTitle.String)
239cdf0e10cSrcweir		End If
240cdf0e10cSrcweir
241cdf0e10cSrcweir		If aChartObject.HasMainTitle then
242cdf0e10cSrcweir			WriteStringToLogFile(aChartObject.Title.String)
243cdf0e10cSrcweir		End If
244cdf0e10cSrcweir
245cdf0e10cSrcweir		aChartDiagram = aChartObject.Diagram
246cdf0e10cSrcweir
247cdf0e10cSrcweir		If aChartDiagram.hasXAxisTitle Then
248cdf0e10cSrcweir			WriteStringToLogFile(aChartDiagram.XAxisTitle)
249cdf0e10cSrcweir		End If
250cdf0e10cSrcweir
251cdf0e10cSrcweir		If aChartDiagram.hasYAxisTitle Then
252cdf0e10cSrcweir			WriteStringToLogFile(aChartDiagram.YAxisTitle)
253cdf0e10cSrcweir		End If
254cdf0e10cSrcweir
255cdf0e10cSrcweir		If aChartDiagram.hasZAxisTitle Then
256cdf0e10cSrcweir			WriteStringToLogFile(aChartDiagram.ZAxisTitle)
257cdf0e10cSrcweir		End If
258cdf0e10cSrcweir	Next i
259cdf0e10cSrcweirEnd Sub
260cdf0e10cSrcweir
261cdf0e10cSrcweir
262cdf0e10cSrcweirSub GetFrameTexts()
263cdf0e10cSrcweirDim i as integer
264cdf0e10cSrcweirDim oTextFrame as object
265cdf0e10cSrcweirDim oFrameEnum as Object
266cdf0e10cSrcweirDim oFramePort as Object
267cdf0e10cSrcweirDim oFrameTextEnum as Object
268cdf0e10cSrcweirDim oFrameTextPort as Object
269cdf0e10cSrcweir
270cdf0e10cSrcweir	MakeLogHeadLine(&quot;Text Frames&quot;)
271cdf0e10cSrcweir	For i = 0 to oDocument.TextFrames.Count-1
272cdf0e10cSrcweir		oTextFrame = oDocument.TextFrames.GetbyIndex(i)
273cdf0e10cSrcweir		WriteStringToLogFile(oTextFrame.Name)
274cdf0e10cSrcweir
275*0a50a83bSMatthias Seidel		&apos; Is the frame bound to the page?
276*0a50a83bSMatthias Seidel		If oTextFrame.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE Then
277cdf0e10cSrcweir			GetParagraphTexts(oTextFrame, &quot;Text Frame Contents&quot;)
278cdf0e10cSrcweir		End If
279cdf0e10cSrcweir
280cdf0e10cSrcweir		oFrameEnum = oTextFrame.CreateEnumeration
281cdf0e10cSrcweir		While oFrameEnum.HasMoreElements
282cdf0e10cSrcweir			oFramePort = oFrameEnum.NextElement
283cdf0e10cSrcweir			If oFramePort.supportsService(&quot;com.sun.star.text.Paragraph&quot;) then
284cdf0e10cSrcweir				oFrameTextEnum = oFramePort.createEnumeration
285cdf0e10cSrcweir				While oFrameTextEnum.HasMoreElements
286cdf0e10cSrcweir					oFrameTextPort = oFrameTextEnum.NextElement
287cdf0e10cSrcweir					If oFrameTextPort.SupportsService(&quot;com.sun.star.text.TextFrame&quot;) Then
288cdf0e10cSrcweir						WriteStringtoLogFile(oFrameTextPort.String)
289cdf0e10cSrcweir					End If
290cdf0e10cSrcweir				Wend
291cdf0e10cSrcweir			Else
292cdf0e10cSrcweir				WriteStringtoLogFile(oFramePort.Name)
293cdf0e10cSrcweir			End if
294cdf0e10cSrcweir		Wend
295cdf0e10cSrcweir	Next
296cdf0e10cSrcweirEnd Sub
297cdf0e10cSrcweir
298cdf0e10cSrcweir
299cdf0e10cSrcweirSub GetTextFieldStrings()
300cdf0e10cSrcweirDim aTextField as Object
301cdf0e10cSrcweirDim i as integer
302cdf0e10cSrcweirDim CurElement as Object
303cdf0e10cSrcweir	MakeLogHeadLine(&quot;Text Fields&quot;)
304cdf0e10cSrcweir	aTextfield = oDocument.getTextfields.CreateEnumeration
305cdf0e10cSrcweir	While aTextField.hasmoreElements
306cdf0e10cSrcweir		CurElement = aTextField.NextElement
307cdf0e10cSrcweir		If CurElement.PropertySetInfo.hasPropertybyName(&quot;Content&quot;) Then
308cdf0e10cSrcweir			WriteStringtoLogFile(CurElement.Content)
309cdf0e10cSrcweir		ElseIf CurElement.PropertySetInfo.hasPropertybyName(&quot;PlaceHolder&quot;) Then
310cdf0e10cSrcweir			WriteStringtoLogFile(CurElement.PlaceHolder)
311cdf0e10cSrcweir			WriteStringtoLogFile(CurElement.Hint)
312cdf0e10cSrcweir		ElseIf Curelement.TextFieldMaster.PropertySetInfo.HasPropertybyName(&quot;Content&quot;) then
313cdf0e10cSrcweir			WriteStringtoLogFile(CurElement.TextFieldMaster.Content)
314cdf0e10cSrcweir		End If
315cdf0e10cSrcweir	Wend
316cdf0e10cSrcweirEnd Sub
317cdf0e10cSrcweir
318cdf0e10cSrcweir
319cdf0e10cSrcweirSub GetLinkedFileNames()
320cdf0e10cSrcweirDim oDocSections as Object
321cdf0e10cSrcweirDim LinkedFileName as String
322cdf0e10cSrcweirDim i as Integer
323cdf0e10cSrcweir	If Right(oDocument.URL,3) = &quot;sgl&quot; Then
324cdf0e10cSrcweir		MakeLogHeadLine(&quot;Sub-documents&quot;)
325cdf0e10cSrcweir		oDocSections = oDocument.TextSections
326cdf0e10cSrcweir		For i = 0 to oDocSections.Count - 1
327cdf0e10cSrcweir			LinkedFileName = oDocSections.GetbyIndex(i).FileLink.FileURL
328cdf0e10cSrcweir			If LinkedFileName &lt;&gt; &quot;&quot; Then
329cdf0e10cSrcweir				WriteStringToLogFile(LinkedFileName)
330cdf0e10cSrcweir			End If
331cdf0e10cSrcweir		Next i
332cdf0e10cSrcweir	End If
333cdf0e10cSrcweirEnd Sub
334cdf0e10cSrcweir
335cdf0e10cSrcweir
336cdf0e10cSrcweirSub GetSectionNames()
337cdf0e10cSrcweirDim i as integer
338cdf0e10cSrcweirDim oDocSections as Object
339cdf0e10cSrcweir	MakeLogHeadLine(&quot;Sections&quot;)
340cdf0e10cSrcweir	oDocSections = oDocument.TextSections
341cdf0e10cSrcweir	For i = 0 to oDocSections.Count-1
342cdf0e10cSrcweir		WriteStringtoLogFile(oDocSections.GetbyIndex(i).Name)
343cdf0e10cSrcweir	Next
344cdf0e10cSrcweirEnd Sub
345cdf0e10cSrcweir
346cdf0e10cSrcweir
347cdf0e10cSrcweirSub GetWriterStrings()
348cdf0e10cSrcweir	GetParagraphTexts(oDocument, &quot;Document Body&quot;)
349cdf0e10cSrcweir	GetGraphicNames()
350cdf0e10cSrcweir	GetStyles()
351cdf0e10cSrcweir	GetControlStrings(oDocument.DrawPage, &quot;Controls&quot;)
352cdf0e10cSrcweir	GetTextFieldStrings()
353cdf0e10cSrcweir	GetSectionNames()
354cdf0e10cSrcweir	GetFrameTexts()
355cdf0e10cSrcweir	GetHyperLinks
356cdf0e10cSrcweir	GetLinkedFileNames()
357cdf0e10cSrcweirEnd Sub
358cdf0e10cSrcweir
359cdf0e10cSrcweir
360*0a50a83bSMatthias Seidel&apos; ***********************************************Draw/Impress documents**************************************************
361cdf0e10cSrcweir
362cdf0e10cSrcweirSub GetDrawPageTitles(LocObject as Object)
363cdf0e10cSrcweirDim n as integer
364cdf0e10cSrcweirDim oPage as Object
365cdf0e10cSrcweir
366cdf0e10cSrcweir	For n = 0 to LocObject.Count - 1
367cdf0e10cSrcweir		oPage = LocObject.GetbyIndex(n)
368cdf0e10cSrcweir		WriteStringtoLogFile(oPage.Name)
369*0a50a83bSMatthias Seidel		&apos; Is the page a DrawPage and not a MasterPage?
370cdf0e10cSrcweir		If oPage.supportsService(&quot;com.sun.star.drawing.DrawPage&quot;)then
371*0a50a83bSMatthias Seidel			&apos; Get the name of the NotesPage (only relevant for Impress documents)
372cdf0e10cSrcweir			If oDocument.supportsService(&quot;com.sun.star.presentation.PresentationDocument&quot;) then
373cdf0e10cSrcweir				WriteStringtoLogFile(oPage.NotesPage.Name)
374cdf0e10cSrcweir			End If
375cdf0e10cSrcweir		End If
376cdf0e10cSrcweir	Next
377cdf0e10cSrcweirEnd Sub
378cdf0e10cSrcweir
379cdf0e10cSrcweir
380cdf0e10cSrcweirSub GetPageStrings(oPages as Object)
381cdf0e10cSrcweirDim m, n, s as Integer
382cdf0e10cSrcweirDim oPage, oPageElement, oShape as Object
383cdf0e10cSrcweir	For n = 0 to oPages.Count-1
384cdf0e10cSrcweir		oPage = oPages.GetbyIndex(n)
385cdf0e10cSrcweir		If oPage.HasElements then
386cdf0e10cSrcweir			For m = 0 to oPage.Count-1
387cdf0e10cSrcweir				oPageElement = oPage.GetByIndex(m)
388cdf0e10cSrcweir				If HasUnoInterfaces(oPageElement,&quot;com.sun.star.container.XIndexAccess&quot;) Then
389cdf0e10cSrcweir					&apos; The Object &quot;oPageElement&quot; a group of Shapes, that can be accessed by their index
390cdf0e10cSrcweir					For s = 0 To oPageElement.Count - 1
391cdf0e10cSrcweir						WriteStringToLogFile(oPageElement.GetByIndex(s).String)
392cdf0e10cSrcweir					Next s
393cdf0e10cSrcweir				ElseIf HasUnoInterfaces(oPageElement, &quot;com.sun.star.text.XText&quot;) Then
394cdf0e10cSrcweir					WriteStringtoLogFile(oPageElement.String)
395cdf0e10cSrcweir				End If
396cdf0e10cSrcweir			Next
397cdf0e10cSrcweir		End If
398cdf0e10cSrcweir	Next
399cdf0e10cSrcweirEnd Sub
400cdf0e10cSrcweir
401cdf0e10cSrcweir
402cdf0e10cSrcweirSub GetDrawStrings()
403cdf0e10cSrcweirDim oDPages, oMPages as Object
404cdf0e10cSrcweir
405cdf0e10cSrcweir	oDPages = oDocument.DrawPages
406cdf0e10cSrcweir	oMPages = oDocument.Masterpages
407cdf0e10cSrcweir
408cdf0e10cSrcweir	MakeLogHeadLine(&quot;Titles&quot;)
409cdf0e10cSrcweir	GetDrawPageTitles(oDPages)
410cdf0e10cSrcweir	GetDrawPageTitles(oMPages)
411cdf0e10cSrcweir
412cdf0e10cSrcweir	MakeLogHeadLine(&quot;Document Body&quot;)
413cdf0e10cSrcweir	GetPageStrings(oDPages)
414cdf0e10cSrcweir	GetPageStrings(oMPages)
415cdf0e10cSrcweirEnd Sub
416cdf0e10cSrcweir
417cdf0e10cSrcweir
418cdf0e10cSrcweir&apos; ***********************************************Misc**************************************************
419cdf0e10cSrcweir
420cdf0e10cSrcweirSub GetDocumentProps()
421cdf0e10cSrcweirDim oDocuProps as Object
422cdf0e10cSrcweir	MakeLogHeadLine(&quot;Document Properties&quot;)
423cdf0e10cSrcweir	oDocuProps = oDocument.DocumentProperties
424cdf0e10cSrcweir	WriteStringToLogFile(oDocuProps.Title)
425cdf0e10cSrcweir	WriteStringToLogFile(oDocuProps.Description)
426cdf0e10cSrcweir	WriteStringToLogFile(oDocuProps.Subject)
427cdf0e10cSrcweir	WriteStringToLogFile(oDocuProps.Author)
428*0a50a83bSMatthias Seidel	&apos; WriteStringToLogFile(oDocuProps.UserDefinedProperties.ReplyTo)
429*0a50a83bSMatthias Seidel	&apos; WriteStringToLogFile(oDocuProps.UserDefinedProperties.Recipient)
430*0a50a83bSMatthias Seidel	&apos; WriteStringToLogFile(oDocuProps.UserDefinedProperties.References)
431*0a50a83bSMatthias Seidel	&apos; WriteStringToLogFile(oDocuProps.Keywords)
432cdf0e10cSrcweirEnd Sub
433cdf0e10cSrcweir
434cdf0e10cSrcweir
435cdf0e10cSrcweirSub GetHyperlinks()
436cdf0e10cSrcweirDim i as integer
437cdf0e10cSrcweirDim oCrsr as Object
438cdf0e10cSrcweirDim oAllHyperLinks as Object
439cdf0e10cSrcweirDim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
440cdf0e10cSrcweirDim oSearchDesc as Object
441cdf0e10cSrcweir
442cdf0e10cSrcweir	MakeLogHeadLine(&quot;Hyperlinks&quot;)
443cdf0e10cSrcweir	&apos; create a Search-Descriptor
444cdf0e10cSrcweir	oSearchDesc = oDocument.CreateSearchDescriptor
445cdf0e10cSrcweir	oSearchDesc.Valuesearch = False
446cdf0e10cSrcweir
447cdf0e10cSrcweir	&apos; define the Search-attributes
448cdf0e10cSrcweir	srchattributes(0).Name = &quot;HyperLinkURL&quot;
449cdf0e10cSrcweir	srchattributes(0).Value = &quot;&quot;
450cdf0e10cSrcweir	oSearchDesc.SetSearchAttributes(SrchAttributes())
451cdf0e10cSrcweir
452cdf0e10cSrcweir	oAllHyperLinks = oDocument.findAll(oSearchDesc())
453cdf0e10cSrcweir
454cdf0e10cSrcweir	For i = 0 to oAllHyperLinks.Count - 1
455cdf0e10cSrcweir		oFound = oAllHyperLinks(i)
456cdf0e10cSrcweir		oCrsr = oFound.Text.createTextCursorByRange(oFound)
457*0a50a83bSMatthias Seidel		WriteStringToLogFile(oCrs.HyperLinkURL) 	&apos;Url
458cdf0e10cSrcweir		WriteStringToLogFile(oCrs.HyperLinkTarget)	&apos;Name
459cdf0e10cSrcweir		WriteStringToLogFile(oCrs.HyperLinkName)	&apos;Frame
460cdf0e10cSrcweir	Next i
461cdf0e10cSrcweirEnd Sub
462cdf0e10cSrcweir
463cdf0e10cSrcweir
464cdf0e10cSrcweirSub GetGraphicNames()
465cdf0e10cSrcweirDim i as integer
466cdf0e10cSrcweirDim oDocGraphics as Object
467cdf0e10cSrcweir	MakeLogHeadLine(&quot;Graphics&quot;)
468cdf0e10cSrcweir	oDocGraphics = oDocument.GraphicObjects
469cdf0e10cSrcweir	For i = 0 to oDocGraphics.count - 1
470cdf0e10cSrcweir		WriteStringtoLogFile(oDocGraphics.GetbyIndex(i).Name)
471cdf0e10cSrcweir	Next
472cdf0e10cSrcweirEnd Sub
473cdf0e10cSrcweir
474cdf0e10cSrcweir
475cdf0e10cSrcweirSub GetStyles()
476cdf0e10cSrcweirDim m,n as integer
477cdf0e10cSrcweir	MakeLogHeadLine(&quot;User-defined Templates&quot;)
478cdf0e10cSrcweir
479cdf0e10cSrcweir	&apos; Check all StyleFamilies(i.e. PageStyles, ParagraphStyles, CharacterStyles, cellStyles)
480cdf0e10cSrcweir	For n = 0 to oDocument.StyleFamilies.Count - 1
481cdf0e10cSrcweir		For m = 0 to oDocument.StyleFamilies.getbyIndex(n).Count-1
482cdf0e10cSrcweir			If oDocument.StyleFamilies.GetbyIndex(n).getbyIndex(m).IsUserDefined then
483cdf0e10cSrcweir				WriteStringtoLogFile(oDocument.StyleFamilies.GetbyIndex(n).getbyIndex(m).Name)
484cdf0e10cSrcweir			End If
485cdf0e10cSrcweir		Next
486cdf0e10cSrcweir	Next
487cdf0e10cSrcweirEnd Sub
488cdf0e10cSrcweir
489cdf0e10cSrcweir
490cdf0e10cSrcweirSub GetControlStrings(oDPage as Object, HeaderLine as String)
491cdf0e10cSrcweirDim aForm as Object
492cdf0e10cSrcweirDim m,n as integer
493cdf0e10cSrcweir	MakeLogHeadLine(HeaderLine)
494cdf0e10cSrcweir	&apos;SearchFor all possible Controls
495cdf0e10cSrcweir	For n = 0 to oDPage.Forms.Count - 1
496cdf0e10cSrcweir		aForm = oDPage.Forms(n)
497cdf0e10cSrcweir		For m = 0 to aForm.Count-1
498cdf0e10cSrcweir			GetControlContent(aForm.GetbyIndex(m))
499cdf0e10cSrcweir		Next
500cdf0e10cSrcweir	Next
501cdf0e10cSrcweirEnd Sub
502cdf0e10cSrcweir
503cdf0e10cSrcweir
504cdf0e10cSrcweirSub GetControlContent(LocControl as Object)
505cdf0e10cSrcweirDim i as integer
506cdf0e10cSrcweir
507cdf0e10cSrcweir	If LocControl.PropertySetInfo.HasPropertybyName(&quot;Label&quot;) then
508cdf0e10cSrcweir		WriteStringtoLogFile(LocControl.Label)
509cdf0e10cSrcweir
510cdf0e10cSrcweir	ElseIf LocControl.SupportsService(&quot;com.sun.star.form.component.ListBox&quot;) then
511cdf0e10cSrcweir		For i = 0 to Ubound(LocControl.StringItemList())
512cdf0e10cSrcweir			WriteStringtoLogFile(LocControl.StringItemList(i))
513cdf0e10cSrcweir		Next
514cdf0e10cSrcweir	End If
515cdf0e10cSrcweir	If LocControl.PropertySetInfo.HasPropertybyName(&quot;HelpText&quot;) then
516cdf0e10cSrcweir		WriteStringtoLogFile(LocControl.Helptext)
517cdf0e10cSrcweir	End If
518cdf0e10cSrcweirEnd Sub
519cdf0e10cSrcweir
520*0a50a83bSMatthias Seidel&apos; ***********************************************Log document**************************************************
521cdf0e10cSrcweir
522cdf0e10cSrcweirSub WriteStringtoLogFile( sString as String)
523cdf0e10cSrcweir	If (Not FieldInArray(LogArray(),LogIndex,sString))AND (NOT ISNULL(sString)) Then
524cdf0e10cSrcweir		LogArray(LogIndex) = sString
525cdf0e10cSrcweir		LogIndex = LogIndex + 1
526cdf0e10cSrcweir		oLogText.insertString(oLogCursor,sString,False)
527*0a50a83bSMatthias Seidel		oLogText.insertControlCharacter(oLogCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
528cdf0e10cSrcweir	End If
529cdf0e10cSrcweirEnd Sub
530cdf0e10cSrcweir
531cdf0e10cSrcweir
532cdf0e10cSrcweirSub MakeLogHeadLine(HeadText as String)
533cdf0e10cSrcweir	oLogCursor.CharStyleName = &quot;Log Header&quot;
534cdf0e10cSrcweir	oLogText.insertControlCharacter(oLogCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
535cdf0e10cSrcweir	oLogText.insertString(oLogCursor,HeadText,False)
536cdf0e10cSrcweir	oLogText.insertControlCharacter(oLogCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
537cdf0e10cSrcweir	oLogCursor.CharStyleName = &quot;Log Body&quot;
538cdf0e10cSrcweirEnd Sub
539cdf0e10cSrcweir</script:module>
540