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