Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "XMLSectionExport.hxx"
30 : : #include <rtl/ustring.hxx>
31 : : #include <rtl/ustrbuf.hxx>
32 : :
33 : : #include <vector>
34 : :
35 : :
36 : : #include <com/sun/star/lang/XServiceInfo.hpp>
37 : : #include <com/sun/star/lang/Locale.hpp>
38 : : #include <com/sun/star/container/XIndexReplace.hpp>
39 : : #include <com/sun/star/beans/XPropertySet.hpp>
40 : : #include <com/sun/star/beans/PropertyValue.hpp>
41 : : #include <com/sun/star/beans/PropertyValues.hpp>
42 : : #include <com/sun/star/beans/PropertyState.hpp>
43 : : #include <com/sun/star/text/XText.hpp>
44 : : #include <com/sun/star/text/XTextSection.hpp>
45 : : #include <com/sun/star/text/SectionFileLink.hpp>
46 : : #include <com/sun/star/container/XNamed.hpp>
47 : : #include <com/sun/star/container/XNameAccess.hpp>
48 : : #include <com/sun/star/text/XDocumentIndex.hpp>
49 : : #include <com/sun/star/uno/XInterface.hpp>
50 : : #include <com/sun/star/text/BibliographyDataField.hpp>
51 : : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
52 : : #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
53 : : #include <com/sun/star/text/ChapterFormat.hpp> //i90246
54 : :
55 : : #include <sax/tools/converter.hxx>
56 : :
57 : : #include <xmloff/xmltoken.hxx>
58 : : #include "xmloff/xmlnmspe.hxx"
59 : : #include <xmloff/families.hxx>
60 : : #include <xmloff/xmluconv.hxx>
61 : : #include <xmloff/nmspmap.hxx>
62 : : #include <xmloff/xmlexp.hxx>
63 : : #include <xmloff/xmltkmap.hxx>
64 : : #include "txtflde.hxx"
65 : :
66 : :
67 : :
68 : : using namespace ::com::sun::star;
69 : : using namespace ::com::sun::star::text;
70 : : using namespace ::com::sun::star::uno;
71 : : using namespace ::std;
72 : : using namespace ::xmloff::token;
73 : :
74 : : using ::rtl::OUString;
75 : : using ::rtl::OUStringBuffer;
76 : : using ::com::sun::star::beans::XPropertySet;
77 : : using ::com::sun::star::beans::PropertyValue;
78 : : using ::com::sun::star::beans::PropertyValues;
79 : : using ::com::sun::star::beans::PropertyState;
80 : : using ::com::sun::star::container::XIndexReplace;
81 : : using ::com::sun::star::container::XNameAccess;
82 : : using ::com::sun::star::container::XNamed;
83 : : using ::com::sun::star::lang::XServiceInfo;
84 : : using ::com::sun::star::lang::Locale;
85 : : using ::com::sun::star::uno::XInterface;
86 : :
87 : :
88 : 77 : XMLSectionExport::XMLSectionExport(
89 : : SvXMLExport& rExp,
90 : : XMLTextParagraphExport& rParaExp)
91 : : : sCondition(RTL_CONSTASCII_USTRINGPARAM("Condition"))
92 : : , sCreateFromChapter(RTL_CONSTASCII_USTRINGPARAM("CreateFromChapter"))
93 : : , sCreateFromEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM("CreateFromEmbeddedObjects"))
94 : : , sCreateFromGraphicObjects(RTL_CONSTASCII_USTRINGPARAM("CreateFromGraphicObjects"))
95 : : , sCreateFromLabels(RTL_CONSTASCII_USTRINGPARAM("CreateFromLabels"))
96 : : , sCreateFromMarks(RTL_CONSTASCII_USTRINGPARAM("CreateFromMarks"))
97 : : , sCreateFromOtherEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM("CreateFromOtherEmbeddedObjects"))
98 : : , sCreateFromOutline(RTL_CONSTASCII_USTRINGPARAM("CreateFromOutline"))
99 : : , sCreateFromStarCalc(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarCalc"))
100 : : , sCreateFromStarChart(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarChart"))
101 : : , sCreateFromStarDraw(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarDraw"))
102 : : , sCreateFromStarImage(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarImage"))
103 : : , sCreateFromStarMath(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarMath"))
104 : : , sCreateFromTables(RTL_CONSTASCII_USTRINGPARAM("CreateFromTables"))
105 : : , sCreateFromTextFrames(RTL_CONSTASCII_USTRINGPARAM("CreateFromTextFrames"))
106 : : , sDdeCommandElement(RTL_CONSTASCII_USTRINGPARAM("DDECommandElement"))
107 : : , sDdeCommandFile(RTL_CONSTASCII_USTRINGPARAM("DDECommandFile"))
108 : : , sDdeCommandType(RTL_CONSTASCII_USTRINGPARAM("DDECommandType"))
109 : : , sFileLink(RTL_CONSTASCII_USTRINGPARAM("FileLink"))
110 : : , sIsCaseSensitive(RTL_CONSTASCII_USTRINGPARAM("IsCaseSensitive"))
111 : : , sIsProtected(RTL_CONSTASCII_USTRINGPARAM("IsProtected"))
112 : : , sIsVisible(RTL_CONSTASCII_USTRINGPARAM("IsVisible"))
113 : : , sLabelCategory(RTL_CONSTASCII_USTRINGPARAM("LabelCategory"))
114 : : , sLabelDisplayType(RTL_CONSTASCII_USTRINGPARAM("LabelDisplayType"))
115 : : , sLevel(RTL_CONSTASCII_USTRINGPARAM("Level"))
116 : : , sLevelFormat(RTL_CONSTASCII_USTRINGPARAM("LevelFormat"))
117 : : , sLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM("LevelParagraphStyles"))
118 : : , sLinkRegion(RTL_CONSTASCII_USTRINGPARAM("LinkRegion"))
119 : : , sMainEntryCharacterStyleName(RTL_CONSTASCII_USTRINGPARAM("MainEntryCharacterStyleName"))
120 : : , sParaStyleHeading(RTL_CONSTASCII_USTRINGPARAM("ParaStyleHeading"))
121 : : , sParaStyleLevel(RTL_CONSTASCII_USTRINGPARAM("ParaStyleLevel"))
122 : : , sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
123 : : , sName(RTL_CONSTASCII_USTRINGPARAM("Name"))
124 : : , sUseAlphabeticalSeparators(RTL_CONSTASCII_USTRINGPARAM("UseAlphabeticalSeparators"))
125 : : , sUseCombinedEntries(RTL_CONSTASCII_USTRINGPARAM("UseCombinedEntries"))
126 : : , sUseDash(RTL_CONSTASCII_USTRINGPARAM("UseDash"))
127 : : , sUseKeyAsEntry(RTL_CONSTASCII_USTRINGPARAM("UseKeyAsEntry"))
128 : : , sUseLevelFromSource(RTL_CONSTASCII_USTRINGPARAM("UseLevelFromSource"))
129 : : , sUsePP(RTL_CONSTASCII_USTRINGPARAM("UsePP"))
130 : : , sUseUpperCase(RTL_CONSTASCII_USTRINGPARAM("UseUpperCase"))
131 : : , sIsCommaSeparated(RTL_CONSTASCII_USTRINGPARAM("IsCommaSeparated"))
132 : : , sIsAutomaticUpdate(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticUpdate"))
133 : : , sIsRelativeTabstops(RTL_CONSTASCII_USTRINGPARAM("IsRelativeTabstops"))
134 : : , sCreateFromLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM("CreateFromLevelParagraphStyles"))
135 : : , sDocumentIndex(RTL_CONSTASCII_USTRINGPARAM("DocumentIndex"))
136 : : , sContentSection(RTL_CONSTASCII_USTRINGPARAM("ContentSection"))
137 : : , sHeaderSection(RTL_CONSTASCII_USTRINGPARAM("HeaderSection"))
138 : :
139 : : , sTextSection(RTL_CONSTASCII_USTRINGPARAM("TextSection"))
140 : : , sIsGlobalDocumentSection(RTL_CONSTASCII_USTRINGPARAM("IsGlobalDocumentSection"))
141 : : , sProtectionKey(RTL_CONSTASCII_USTRINGPARAM("ProtectionKey"))
142 : : , sSortAlgorithm(RTL_CONSTASCII_USTRINGPARAM("SortAlgorithm"))
143 : : , sLocale(RTL_CONSTASCII_USTRINGPARAM("Locale"))
144 : : , sUserIndexName(RTL_CONSTASCII_USTRINGPARAM("UserIndexName"))
145 : :
146 : : , sIsCurrentlyVisible(RTL_CONSTASCII_USTRINGPARAM("IsCurrentlyVisible"))
147 : : , sHeadingStyleName(RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName"))
148 : :
149 : : , rExport(rExp)
150 : : , rParaExport(rParaExp)
151 [ + - ][ + - ]: 77 : , bHeadingDummiesExported( sal_False )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
152 : : {
153 : 77 : }
154 : :
155 : :
156 : 32 : void XMLSectionExport::ExportSectionStart(
157 : : const Reference<XTextSection> & rSection,
158 : : sal_Bool bAutoStyles)
159 : : {
160 [ + - ]: 32 : Reference<XPropertySet> xPropertySet(rSection, UNO_QUERY);
161 : :
162 : : // always export section (auto) style
163 [ - + ]: 32 : if (bAutoStyles)
164 : : {
165 : : // get PropertySet and add section style
166 [ # # ]: 0 : GetParaExport().Add( XML_STYLE_FAMILY_TEXT_SECTION, xPropertySet );
167 : : }
168 : : else
169 : : {
170 : : // always export section style
171 : 32 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME,
172 : 32 : GetParaExport().Find(
173 : : XML_STYLE_FAMILY_TEXT_SECTION,
174 [ + - + - ]: 64 : xPropertySet, sEmpty ) );
175 : :
176 : : // xml:id for RDF metadata
177 [ + - ]: 32 : GetExport().AddAttributeXmlId(rSection);
178 : :
179 : : // export index or regular section
180 : 32 : Reference<XDocumentIndex> xIndex;
181 [ + + ][ + - ]: 32 : if (GetIndex(rSection, xIndex))
182 : : {
183 [ + + ]: 28 : if (xIndex.is())
184 : : {
185 : : // we are an index
186 [ + - ]: 14 : ExportIndexStart(xIndex);
187 : : }
188 : : else
189 : : {
190 : : // we are an index header
191 [ + - ]: 14 : ExportIndexHeaderStart(rSection);
192 : : }
193 : : }
194 : : else
195 : : {
196 : : // we are not an index
197 [ + - ]: 4 : ExportRegularSectionStart(rSection);
198 : 32 : }
199 : 32 : }
200 : 32 : }
201 : :
202 : 64 : sal_Bool XMLSectionExport::GetIndex(
203 : : const Reference<XTextSection> & rSection,
204 : : Reference<XDocumentIndex> & rIndex) const
205 : : {
206 : : // first, reset result
207 : 64 : sal_Bool bRet = sal_False;
208 [ + - ]: 64 : rIndex = NULL;
209 : :
210 : : // get section Properties
211 [ + - ]: 64 : Reference<XPropertySet> xSectionPropSet(rSection, UNO_QUERY);
212 : :
213 : : // then check if this section happens to be inside an index
214 [ + - ][ + - ]: 128 : if (xSectionPropSet->getPropertySetInfo()->
[ + - ][ + - ]
215 [ + - ]: 64 : hasPropertyByName(sDocumentIndex))
216 : : {
217 [ + - ][ + - ]: 64 : Any aAny = xSectionPropSet->getPropertyValue(sDocumentIndex);
218 : 64 : Reference<XDocumentIndex> xDocumentIndex;
219 [ + - ]: 64 : aAny >>= xDocumentIndex;
220 : :
221 : : // OK, are we inside of an index
222 [ + + ]: 64 : if (xDocumentIndex.is())
223 : : {
224 : : // is the enclosing index identical with "our" section?
225 [ + - ]: 56 : Reference<XPropertySet> xIndexPropSet(xDocumentIndex, UNO_QUERY);
226 [ + - ][ + - ]: 56 : aAny = xIndexPropSet->getPropertyValue(sContentSection);
227 : 56 : Reference<XTextSection> xEnclosingSection;
228 [ + - ]: 56 : aAny >>= xEnclosingSection;
229 : :
230 : : // if the enclosing section is "our" section, then we are an index!
231 [ + - ][ + + ]: 56 : if (rSection == xEnclosingSection)
232 : : {
233 [ + - ]: 28 : rIndex = xDocumentIndex;
234 : 28 : bRet = sal_True;
235 : : }
236 : : // else: index header or regular section
237 : :
238 : : // is the enclosing index identical with the header section?
239 [ + - ][ + - ]: 56 : aAny = xIndexPropSet->getPropertyValue(sHeaderSection);
240 : : // now mis-named: contains header section
241 [ + - ]: 56 : aAny >>= xEnclosingSection;
242 : :
243 : : // if the enclosing section is "our" section, then we are an index!
244 [ + - ][ + + ]: 56 : if (rSection == xEnclosingSection)
245 : : {
246 : 28 : bRet = sal_True;
247 : 56 : }
248 : : // else: regular section
249 : 64 : }
250 : : // else: we aren't even inside of an index
251 : : }
252 : : // else: we don't even know what an index is.
253 : :
254 : 64 : return bRet;
255 : : }
256 : :
257 : :
258 : 32 : void XMLSectionExport::ExportSectionEnd(
259 : : const Reference<XTextSection> & rSection,
260 : : sal_Bool bAutoStyles)
261 : : {
262 : : // no end section for styles
263 [ + - ]: 32 : if (!bAutoStyles)
264 : : {
265 : 32 : enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
266 : :
267 : : // export index or regular section end
268 : 32 : Reference<XDocumentIndex> xIndex;
269 [ + + ][ + - ]: 32 : if (GetIndex(rSection, xIndex))
270 : : {
271 [ + + ]: 28 : if (xIndex.is())
272 : : {
273 : : // index end: close index body element
274 : 14 : GetExport().EndElement( XML_NAMESPACE_TEXT, XML_INDEX_BODY,
275 [ + - ]: 14 : sal_True );
276 [ + - ]: 14 : GetExport().IgnorableWhitespace();
277 : :
278 [ + - ][ + - ]: 14 : switch (MapSectionType(xIndex->getServiceName()))
[ + - ][ + +
+ + + + +
- ]
279 : : {
280 : : case TEXT_SECTION_TYPE_TOC:
281 : 2 : eElement = XML_TABLE_OF_CONTENT;
282 : 2 : break;
283 : :
284 : : case TEXT_SECTION_TYPE_ILLUSTRATION:
285 : 2 : eElement = XML_ILLUSTRATION_INDEX;
286 : 2 : break;
287 : :
288 : : case TEXT_SECTION_TYPE_ALPHABETICAL:
289 : 2 : eElement = XML_ALPHABETICAL_INDEX;
290 : 2 : break;
291 : :
292 : : case TEXT_SECTION_TYPE_TABLE:
293 : 2 : eElement = XML_TABLE_INDEX;
294 : 2 : break;
295 : :
296 : : case TEXT_SECTION_TYPE_OBJECT:
297 : 2 : eElement = XML_OBJECT_INDEX;
298 : 2 : break;
299 : :
300 : : case TEXT_SECTION_TYPE_USER:
301 : 2 : eElement = XML_USER_INDEX;
302 : 2 : break;
303 : :
304 : : case TEXT_SECTION_TYPE_BIBLIOGRAPHY:
305 : 2 : eElement = XML_BIBLIOGRAPHY;
306 : 2 : break;
307 : :
308 : : default:
309 : : OSL_FAIL("unknown index type");
310 : : // default: skip index!
311 : 14 : break;
312 : : }
313 : : }
314 : : else
315 : : {
316 : 14 : eElement = XML_INDEX_TITLE;
317 : : }
318 : : }
319 : : else
320 : : {
321 : 4 : eElement = XML_SECTION;
322 : : }
323 : :
324 [ + - ]: 32 : if (XML_TOKEN_INVALID != eElement)
325 : : {
326 : : // any old attributes?
327 : 32 : GetExport().CheckAttrList();
328 : :
329 : : // element surrounded by whitespace
330 [ + - ]: 32 : GetExport().EndElement( XML_NAMESPACE_TEXT, eElement, sal_True);
331 [ + - ]: 32 : GetExport().IgnorableWhitespace();
332 : : }
333 : : else
334 : : {
335 : : OSL_FAIL("Need element name!");
336 : 32 : }
337 : : }
338 : : // else: autostyles -> ignore
339 : 32 : }
340 : :
341 : 14 : void XMLSectionExport::ExportIndexStart(
342 : : const Reference<XDocumentIndex> & rIndex)
343 : : {
344 : : // get PropertySet
345 [ + - ]: 14 : Reference<XPropertySet> xPropertySet(rIndex, UNO_QUERY);
346 : :
347 [ + - ][ + - ]: 14 : switch (MapSectionType(rIndex->getServiceName()))
[ + - ][ + +
+ + + + +
- ]
348 : : {
349 : : case TEXT_SECTION_TYPE_TOC:
350 [ + - ]: 2 : ExportTableOfContentStart(xPropertySet);
351 : 2 : break;
352 : :
353 : : case TEXT_SECTION_TYPE_ILLUSTRATION:
354 [ + - ]: 2 : ExportIllustrationIndexStart(xPropertySet);
355 : 2 : break;
356 : :
357 : : case TEXT_SECTION_TYPE_ALPHABETICAL:
358 [ + - ]: 2 : ExportAlphabeticalIndexStart(xPropertySet);
359 : 2 : break;
360 : :
361 : : case TEXT_SECTION_TYPE_TABLE:
362 [ + - ]: 2 : ExportTableIndexStart(xPropertySet);
363 : 2 : break;
364 : :
365 : : case TEXT_SECTION_TYPE_OBJECT:
366 [ + - ]: 2 : ExportObjectIndexStart(xPropertySet);
367 : 2 : break;
368 : :
369 : : case TEXT_SECTION_TYPE_USER:
370 [ + - ]: 2 : ExportUserIndexStart(xPropertySet);
371 : 2 : break;
372 : :
373 : : case TEXT_SECTION_TYPE_BIBLIOGRAPHY:
374 [ + - ]: 2 : ExportBibliographyStart(xPropertySet);
375 : 2 : break;
376 : :
377 : : default:
378 : : // skip index
379 : : OSL_FAIL("unknown index type");
380 : 0 : break;
381 : 14 : }
382 : 14 : }
383 : :
384 : 14 : void XMLSectionExport::ExportIndexHeaderStart(
385 : : const Reference<XTextSection> & rSection)
386 : : {
387 : : // export name, dammit!
388 [ + - ]: 14 : Reference<XNamed> xName(rSection, UNO_QUERY);
389 [ + - ][ + - ]: 14 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xName->getName());
[ + - ]
390 : :
391 : : // format already handled -> export only start element
392 [ + - ]: 14 : GetExport().StartElement( XML_NAMESPACE_TEXT, XML_INDEX_TITLE, sal_True );
393 [ + - ]: 14 : GetExport().IgnorableWhitespace();
394 : 14 : }
395 : :
396 : :
397 : : SvXMLEnumStringMapEntry const aIndexTypeMap[] =
398 : : {
399 : : ENUM_STRING_MAP_ENTRY( "com.sun.star.text.ContentIndex", TEXT_SECTION_TYPE_TOC ),
400 : : ENUM_STRING_MAP_ENTRY( "com.sun.star.text.DocumentIndex", TEXT_SECTION_TYPE_ALPHABETICAL ),
401 : : ENUM_STRING_MAP_ENTRY( "com.sun.star.text.TableIndex", TEXT_SECTION_TYPE_TABLE ),
402 : : ENUM_STRING_MAP_ENTRY( "com.sun.star.text.ObjectIndex", TEXT_SECTION_TYPE_OBJECT ),
403 : : ENUM_STRING_MAP_ENTRY( "com.sun.star.text.Bibliography", TEXT_SECTION_TYPE_BIBLIOGRAPHY ),
404 : : ENUM_STRING_MAP_ENTRY( "com.sun.star.text.UserIndex", TEXT_SECTION_TYPE_USER ),
405 : : ENUM_STRING_MAP_ENTRY( "com.sun.star.text.IllustrationsIndex", TEXT_SECTION_TYPE_ILLUSTRATION ),
406 : : ENUM_STRING_MAP_END()
407 : : };
408 : :
409 : 28 : enum SectionTypeEnum XMLSectionExport::MapSectionType(
410 : : const OUString& rServiceName)
411 : : {
412 : 28 : enum SectionTypeEnum eType = TEXT_SECTION_TYPE_UNKNOWN;
413 : :
414 : : sal_uInt16 nTmp;
415 [ + - ][ + - ]: 28 : if (SvXMLUnitConverter::convertEnum(nTmp, rServiceName, aIndexTypeMap))
416 : : {
417 : 28 : eType = (enum SectionTypeEnum)nTmp;
418 : : }
419 : :
420 : : // TODO: index header section types, etc.
421 : :
422 : 28 : return eType;
423 : : }
424 : :
425 : 4 : void XMLSectionExport::ExportRegularSectionStart(
426 : : const Reference<XTextSection> & rSection)
427 : : {
428 : : // style name already handled in ExportSectionStart(...)
429 : :
430 [ + - ]: 4 : Reference<XNamed> xName(rSection, UNO_QUERY);
431 [ + - ][ + - ]: 4 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xName->getName());
[ + - ]
432 : :
433 : : // get XPropertySet for other values
434 [ + - ]: 4 : Reference<XPropertySet> xPropSet(rSection, UNO_QUERY);
435 : 4 : Any aAny;
436 : :
437 : : // condition and display
438 [ + - ][ + - ]: 4 : aAny = xPropSet->getPropertyValue(sCondition);
439 : 4 : OUString sCond;
440 : 4 : aAny >>= sCond;
441 : 4 : enum XMLTokenEnum eDisplay = XML_TOKEN_INVALID;
442 [ - + ]: 4 : if (!sCond.isEmpty())
443 : : {
444 : : OUString sQValue =
445 : 0 : GetExport().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOOW,
446 [ # # ]: 0 : sCond, sal_False );
447 [ # # ]: 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_CONDITION, sQValue);
448 : 0 : eDisplay = XML_CONDITION;
449 : :
450 : : // #97450# store hidden-status (of conditional sections only)
451 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(sIsCurrentlyVisible);
452 [ # # ]: 0 : if (! *(sal_Bool*)aAny.getValue())
453 : : {
454 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_IS_HIDDEN,
455 [ # # ]: 0 : XML_TRUE);
456 : 0 : }
457 : : }
458 : : else
459 : : {
460 : 4 : eDisplay = XML_NONE;
461 : : }
462 [ + - ][ + - ]: 4 : aAny = xPropSet->getPropertyValue(sIsVisible);
463 [ - + ]: 4 : if (! *(sal_Bool*)aAny.getValue())
464 : : {
465 [ # # ]: 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_DISPLAY, eDisplay);
466 : : }
467 : :
468 : : // protect + protection key
469 [ + - ][ + - ]: 4 : aAny = xPropSet->getPropertyValue(sIsProtected);
470 [ + + ]: 4 : if (*(sal_Bool*)aAny.getValue())
471 : : {
472 [ + - ]: 2 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTED, XML_TRUE);
473 : : }
474 [ + - ]: 4 : Sequence<sal_Int8> aPassword;
475 [ + - ][ + - ]: 4 : xPropSet->getPropertyValue(sProtectionKey) >>= aPassword;
[ + - ]
476 [ + + ]: 4 : if (aPassword.getLength() > 0)
477 : : {
478 : 2 : OUStringBuffer aBuffer;
479 [ + - ]: 2 : ::sax::Converter::encodeBase64(aBuffer, aPassword);
480 : 2 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTION_KEY,
481 [ + - + - ]: 4 : aBuffer.makeStringAndClear());
482 : : }
483 : :
484 : : // export element
485 [ + - ]: 4 : GetExport().IgnorableWhitespace();
486 [ + - ]: 4 : GetExport().StartElement( XML_NAMESPACE_TEXT, XML_SECTION, sal_True );
487 : :
488 : : // data source
489 : : // unfortunately, we have to test all relevant strings for non-zero length
490 [ + - ][ + - ]: 4 : aAny = xPropSet->getPropertyValue(sFileLink);
491 : 4 : SectionFileLink aFileLink;
492 [ + - ]: 4 : aAny >>= aFileLink;
493 : :
494 [ + - ][ + - ]: 4 : aAny = xPropSet->getPropertyValue(sLinkRegion);
495 : 4 : OUString sRegionName;
496 : 4 : aAny >>= sRegionName;
497 : :
498 [ - + ][ + - : 12 : if ( !aFileLink.FileURL.isEmpty() ||
+ - - + ]
499 : 4 : !aFileLink.FilterName.isEmpty() ||
500 : 4 : !sRegionName.isEmpty())
501 : : {
502 [ # # ]: 0 : if (!aFileLink.FileURL.isEmpty())
503 : : {
504 : 0 : GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF,
505 [ # # # # ]: 0 : GetExport().GetRelativeReference( aFileLink.FileURL) );
506 : : }
507 : :
508 [ # # ]: 0 : if (!aFileLink.FilterName.isEmpty())
509 : : {
510 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_FILTER_NAME,
511 [ # # ]: 0 : aFileLink.FilterName);
512 : : }
513 : :
514 [ # # ]: 0 : if (!sRegionName.isEmpty())
515 : : {
516 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_SECTION_NAME,
517 [ # # ]: 0 : sRegionName);
518 : : }
519 : :
520 : 0 : SvXMLElementExport aElem(GetExport(),
521 : : XML_NAMESPACE_TEXT, XML_SECTION_SOURCE,
522 [ # # ][ # # ]: 0 : sal_True, sal_True);
523 : : }
524 : : else
525 : : {
526 : : // check for DDE first
527 [ + - ][ + - ]: 4 : if (xPropSet->getPropertySetInfo()->hasPropertyByName(sDdeCommandFile))
[ + - ][ + - ]
[ + - ]
528 : : {
529 : : // data source DDE
530 : : // unfortunately, we have to test all relevant strings for
531 : : // non-zero length
532 [ + - ][ + - ]: 4 : aAny = xPropSet->getPropertyValue(sDdeCommandFile);
533 : 4 : OUString sApplication;
534 : 4 : aAny >>= sApplication;
535 [ + - ][ + - ]: 4 : aAny = xPropSet->getPropertyValue(sDdeCommandType);
536 : 4 : OUString sTopic;
537 : 4 : aAny >>= sTopic;
538 [ + - ][ + - ]: 4 : aAny = xPropSet->getPropertyValue(sDdeCommandElement);
539 : 4 : OUString sItem;
540 : 4 : aAny >>= sItem;
541 : :
542 [ - + ][ + - : 12 : if ( !sApplication.isEmpty() ||
+ - - + ]
543 : 4 : !sTopic.isEmpty() ||
544 : 4 : !sItem.isEmpty())
545 : : {
546 : 0 : GetExport().AddAttribute(XML_NAMESPACE_OFFICE,
547 [ # # ]: 0 : XML_DDE_APPLICATION, sApplication);
548 : 0 : GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_DDE_TOPIC,
549 [ # # ]: 0 : sTopic);
550 : 0 : GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_DDE_ITEM,
551 [ # # ]: 0 : sItem);
552 : :
553 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue(sIsAutomaticUpdate);
554 [ # # ]: 0 : if (*(sal_Bool*)aAny.getValue())
555 : : {
556 : 0 : GetExport().AddAttribute(XML_NAMESPACE_OFFICE,
557 [ # # ]: 0 : XML_AUTOMATIC_UPDATE, XML_TRUE);
558 : : }
559 : :
560 : 0 : SvXMLElementExport aElem(GetExport(),
561 : : XML_NAMESPACE_OFFICE,
562 [ # # ][ # # ]: 0 : XML_DDE_SOURCE, sal_True, sal_True);
563 : 4 : }
564 : : // else: no DDE data source
565 : : }
566 : : // else: no DDE on this system
567 [ + - ]: 4 : }
568 : 4 : }
569 : :
570 : 2 : void XMLSectionExport::ExportTableOfContentStart(
571 : : const Reference<XPropertySet> & rPropertySet)
572 : : {
573 : : // export TOC element start
574 : 2 : ExportBaseIndexStart(XML_TABLE_OF_CONTENT, rPropertySet);
575 : :
576 : : // scope for table-of-content-source element
577 : : {
578 : :
579 : 2 : Any aAny;
580 : :
581 : : // TOC specific index source attributes:
582 : :
583 : : // outline-level: 1..10
584 : 2 : sal_Int16 nLevel = sal_Int16();
585 [ + - ][ + - ]: 2 : if( rPropertySet->getPropertyValue(sLevel) >>= nLevel )
[ + - ]
586 : : {
587 : 2 : OUStringBuffer sBuffer;
588 [ + - ]: 2 : ::sax::Converter::convertNumber(sBuffer, (sal_Int32)nLevel);
589 : 2 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
590 : : XML_OUTLINE_LEVEL,
591 [ + - + - ]: 4 : sBuffer.makeStringAndClear());
592 : : }
593 : :
594 : : // use outline level
595 : : ExportBoolean(rPropertySet, sCreateFromOutline,
596 [ + - ]: 2 : XML_USE_OUTLINE_LEVEL, sal_True);
597 : :
598 : : // use index marks
599 : : ExportBoolean(rPropertySet, sCreateFromMarks,
600 [ + - ]: 2 : XML_USE_INDEX_MARKS, sal_True);
601 : :
602 : : // use level styles
603 : : ExportBoolean(rPropertySet, sCreateFromLevelParagraphStyles,
604 [ + - ]: 2 : XML_USE_INDEX_SOURCE_STYLES, sal_False);
605 : :
606 [ + - ]: 2 : ExportBaseIndexSource(TEXT_SECTION_TYPE_TOC, rPropertySet);
607 : : }
608 : :
609 : 2 : ExportBaseIndexBody(TEXT_SECTION_TYPE_TOC, rPropertySet);
610 : 2 : }
611 : :
612 : 2 : void XMLSectionExport::ExportObjectIndexStart(
613 : : const Reference<XPropertySet> & rPropertySet)
614 : : {
615 : : // export index start
616 : 2 : ExportBaseIndexStart(XML_OBJECT_INDEX, rPropertySet);
617 : :
618 : : // scope for index source element
619 : : {
620 : : ExportBoolean(rPropertySet, sCreateFromOtherEmbeddedObjects,
621 : 2 : XML_USE_OTHER_OBJECTS, sal_False);
622 : : ExportBoolean(rPropertySet, sCreateFromStarCalc,
623 : 2 : XML_USE_SPREADSHEET_OBJECTS, sal_False);
624 : : ExportBoolean(rPropertySet, sCreateFromStarChart,
625 : 2 : XML_USE_CHART_OBJECTS, sal_False);
626 : : ExportBoolean(rPropertySet, sCreateFromStarDraw,
627 : 2 : XML_USE_DRAW_OBJECTS, sal_False);
628 : : ExportBoolean(rPropertySet, sCreateFromStarMath,
629 : 2 : XML_USE_MATH_OBJECTS, sal_False);
630 : :
631 : 2 : ExportBaseIndexSource(TEXT_SECTION_TYPE_OBJECT, rPropertySet);
632 : : }
633 : :
634 : 2 : ExportBaseIndexBody(TEXT_SECTION_TYPE_OBJECT, rPropertySet);
635 : 2 : }
636 : :
637 : 2 : void XMLSectionExport::ExportIllustrationIndexStart(
638 : : const Reference<XPropertySet> & rPropertySet)
639 : : {
640 : : // export index start
641 : 2 : ExportBaseIndexStart(XML_ILLUSTRATION_INDEX, rPropertySet);
642 : :
643 : : // scope for index source element
644 : : {
645 : : // export common attributes for illustration and table indices
646 : 2 : ExportTableAndIllustrationIndexSourceAttributes(rPropertySet);
647 : :
648 : 2 : ExportBaseIndexSource(TEXT_SECTION_TYPE_ILLUSTRATION, rPropertySet);
649 : : }
650 : :
651 : 2 : ExportBaseIndexBody(TEXT_SECTION_TYPE_ILLUSTRATION, rPropertySet);
652 : 2 : }
653 : :
654 : 2 : void XMLSectionExport::ExportTableIndexStart(
655 : : const Reference<XPropertySet> & rPropertySet)
656 : : {
657 : : // export index start
658 : 2 : ExportBaseIndexStart(XML_TABLE_INDEX, rPropertySet);
659 : :
660 : : // scope for index source element
661 : : {
662 : : // export common attributes for illustration and table indices
663 : 2 : ExportTableAndIllustrationIndexSourceAttributes(rPropertySet);
664 : :
665 : 2 : ExportBaseIndexSource(TEXT_SECTION_TYPE_TABLE, rPropertySet);
666 : : }
667 : :
668 : 2 : ExportBaseIndexBody(TEXT_SECTION_TYPE_TABLE, rPropertySet);
669 : 2 : }
670 : :
671 : 2 : void XMLSectionExport::ExportAlphabeticalIndexStart(
672 : : const Reference<XPropertySet> & rPropertySet)
673 : : {
674 : : // export TOC element start
675 : 2 : ExportBaseIndexStart(XML_ALPHABETICAL_INDEX, rPropertySet);
676 : :
677 : : // scope for table-of-content-source element
678 : : {
679 : :
680 : : // style name (if present)
681 : 2 : Any aAny;
682 [ + - ][ + - ]: 2 : aAny = rPropertySet->getPropertyValue(sMainEntryCharacterStyleName);
683 : 2 : OUString sStyleName;
684 : 2 : aAny >>= sStyleName;
685 [ - + ]: 2 : if (!sStyleName.isEmpty())
686 : : {
687 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
688 : : XML_MAIN_ENTRY_STYLE_NAME,
689 [ # # # # ]: 0 : GetExport().EncodeStyleName( sStyleName ));
690 : : }
691 : :
692 : : // other (boolean) attributes
693 : : ExportBoolean(rPropertySet, sIsCaseSensitive, XML_IGNORE_CASE,
694 [ + - ]: 2 : sal_False, sal_True);
695 : : ExportBoolean(rPropertySet, sUseAlphabeticalSeparators,
696 [ + - ]: 2 : XML_ALPHABETICAL_SEPARATORS, sal_False);
697 : : ExportBoolean(rPropertySet, sUseCombinedEntries, XML_COMBINE_ENTRIES,
698 [ + - ]: 2 : sal_True);
699 : : ExportBoolean(rPropertySet, sUseDash, XML_COMBINE_ENTRIES_WITH_DASH,
700 [ + - ]: 2 : sal_False);
701 : : ExportBoolean(rPropertySet, sUseKeyAsEntry, XML_USE_KEYS_AS_ENTRIES,
702 [ + - ]: 2 : sal_False);
703 : : ExportBoolean(rPropertySet, sUsePP, XML_COMBINE_ENTRIES_WITH_PP,
704 [ + - ]: 2 : sal_True);
705 : : ExportBoolean(rPropertySet, sUseUpperCase, XML_CAPITALIZE_ENTRIES,
706 [ + - ]: 2 : sal_False);
707 : : ExportBoolean(rPropertySet, sIsCommaSeparated, XML_COMMA_SEPARATED,
708 [ + - ]: 2 : sal_False);
709 : :
710 : : // sort algorithm
711 [ + - ][ + - ]: 2 : aAny = rPropertySet->getPropertyValue(sSortAlgorithm);
712 : 2 : OUString sAlgorithm;
713 : 2 : aAny >>= sAlgorithm;
714 [ + - ]: 2 : if (!sAlgorithm.isEmpty())
715 : : {
716 : 2 : GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_SORT_ALGORITHM,
717 [ + - ]: 2 : sAlgorithm );
718 : : }
719 : :
720 : : // locale
721 [ + - ][ + - ]: 2 : aAny = rPropertySet->getPropertyValue(sLocale);
722 : 2 : Locale aLocale;
723 [ + - ]: 2 : aAny >>= aLocale;
724 : 2 : GetExport().AddAttribute(XML_NAMESPACE_FO, XML_LANGUAGE,
725 [ + - ]: 2 : aLocale.Language);
726 : 2 : GetExport().AddAttribute(XML_NAMESPACE_FO, XML_COUNTRY,
727 [ + - ]: 2 : aLocale.Country);
728 : :
729 [ + - ]: 2 : ExportBaseIndexSource(TEXT_SECTION_TYPE_ALPHABETICAL, rPropertySet);
730 : : }
731 : :
732 : 2 : ExportBaseIndexBody(TEXT_SECTION_TYPE_ALPHABETICAL, rPropertySet);
733 : 2 : }
734 : :
735 : 2 : void XMLSectionExport::ExportUserIndexStart(
736 : : const Reference<XPropertySet> & rPropertySet)
737 : : {
738 : : // export TOC element start
739 : 2 : ExportBaseIndexStart(XML_USER_INDEX, rPropertySet);
740 : :
741 : : // scope for table-of-content-source element
742 : : {
743 : : // bool attributes
744 : : ExportBoolean(rPropertySet, sCreateFromEmbeddedObjects,
745 [ + - ]: 2 : XML_USE_OBJECTS, sal_False);
746 : : ExportBoolean(rPropertySet, sCreateFromGraphicObjects,
747 [ + - ]: 2 : XML_USE_GRAPHICS, sal_False);
748 : : ExportBoolean(rPropertySet, sCreateFromMarks,
749 [ + - ]: 2 : XML_USE_INDEX_MARKS, sal_False);
750 : : ExportBoolean(rPropertySet, sCreateFromTables,
751 [ + - ]: 2 : XML_USE_TABLES, sal_False);
752 : : ExportBoolean(rPropertySet, sCreateFromTextFrames,
753 [ + - ]: 2 : XML_USE_FLOATING_FRAMES, sal_False);
754 : : ExportBoolean(rPropertySet, sUseLevelFromSource,
755 [ + - ]: 2 : XML_COPY_OUTLINE_LEVELS, sal_False);
756 : : ExportBoolean(rPropertySet, sCreateFromLevelParagraphStyles,
757 [ + - ]: 2 : XML_USE_INDEX_SOURCE_STYLES, sal_False);
758 : :
759 [ + - ][ + - ]: 2 : Any aAny = rPropertySet->getPropertyValue( sUserIndexName );
760 : 2 : OUString sIndexName;
761 : 2 : aAny >>= sIndexName;
762 : 2 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_INDEX_NAME,
763 [ + - ]: 2 : sIndexName);
764 : :
765 [ + - ]: 2 : ExportBaseIndexSource(TEXT_SECTION_TYPE_USER, rPropertySet);
766 : : }
767 : :
768 : 2 : ExportBaseIndexBody(TEXT_SECTION_TYPE_USER, rPropertySet);
769 : 2 : }
770 : :
771 : 2 : void XMLSectionExport::ExportBibliographyStart(
772 : : const Reference<XPropertySet> & rPropertySet)
773 : : {
774 : : // export TOC element start
775 : 2 : ExportBaseIndexStart(XML_BIBLIOGRAPHY, rPropertySet);
776 : :
777 : : // scope for table-of-content-source element
778 : : {
779 : : // No attributes. Fine.
780 : :
781 : 2 : ExportBaseIndexSource(TEXT_SECTION_TYPE_BIBLIOGRAPHY, rPropertySet);
782 : : }
783 : :
784 : 2 : ExportBaseIndexBody(TEXT_SECTION_TYPE_BIBLIOGRAPHY, rPropertySet);
785 : 2 : }
786 : :
787 : :
788 : 14 : void XMLSectionExport::ExportBaseIndexStart(
789 : : XMLTokenEnum eElement,
790 : : const Reference<XPropertySet> & rPropertySet)
791 : : {
792 : : // protect + protection key
793 [ + - ][ + - ]: 14 : Any aAny = rPropertySet->getPropertyValue(sIsProtected);
794 [ + - ]: 14 : if (*(sal_Bool*)aAny.getValue())
795 : : {
796 [ + - ]: 14 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTED, XML_TRUE);
797 : : }
798 : :
799 : : // index name
800 : 14 : OUString sIndexName;
801 [ + - ][ + - ]: 14 : rPropertySet->getPropertyValue(sName) >>= sIndexName;
802 [ + - ]: 14 : if ( !sIndexName.isEmpty() )
803 : : {
804 [ + - ]: 14 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, sIndexName);
805 : : }
806 : :
807 : : // index Element start
808 [ + - ]: 14 : GetExport().IgnorableWhitespace();
809 [ + - ]: 14 : GetExport().StartElement( XML_NAMESPACE_TEXT, eElement, sal_False );
810 : 14 : }
811 : :
812 : : static const XMLTokenEnum aTypeSourceElementNameMap[] =
813 : : {
814 : : XML_TABLE_OF_CONTENT_SOURCE, // TOC
815 : : XML_TABLE_INDEX_SOURCE, // table index
816 : : XML_ILLUSTRATION_INDEX_SOURCE, // illustration index
817 : : XML_OBJECT_INDEX_SOURCE, // object index
818 : : XML_USER_INDEX_SOURCE, // user index
819 : : XML_ALPHABETICAL_INDEX_SOURCE, // alphabetical index
820 : : XML_BIBLIOGRAPHY_SOURCE // bibliography
821 : : };
822 : :
823 : 14 : void XMLSectionExport::ExportBaseIndexSource(
824 : : SectionTypeEnum eType,
825 : : const Reference<XPropertySet> & rPropertySet)
826 : : {
827 : : // check type
828 : : OSL_ENSURE(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type");
829 : : OSL_ENSURE(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type");
830 : :
831 : 14 : Any aAny;
832 : :
833 : : // common attributes; not supported by bibliography
834 [ + + ]: 14 : if (eType != TEXT_SECTION_TYPE_BIBLIOGRAPHY)
835 : : {
836 : : // document or chapter index?
837 [ + - ][ + - ]: 12 : aAny = rPropertySet->getPropertyValue(sCreateFromChapter);
838 [ - + ]: 12 : if (*(sal_Bool*)aAny.getValue())
839 : : {
840 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
841 [ # # ]: 0 : XML_INDEX_SCOPE, XML_CHAPTER);
842 : : }
843 : :
844 : : // tab-stops relative to margin?
845 [ + - ][ + - ]: 12 : aAny = rPropertySet->getPropertyValue(sIsRelativeTabstops);
846 [ - + ]: 12 : if (! *(sal_Bool*)aAny.getValue())
847 : : {
848 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
849 : : XML_RELATIVE_TAB_STOP_POSITION,
850 [ # # ]: 0 : XML_FALSE);
851 : : }
852 : : }
853 : :
854 : : // the index source element (all indices)
855 : 14 : SvXMLElementExport aElem(GetExport(),
856 : : XML_NAMESPACE_TEXT,
857 : : GetXMLToken(
858 : : aTypeSourceElementNameMap[
859 [ + - ]: 14 : eType - TEXT_SECTION_TYPE_TOC]),
860 [ + - ]: 14 : sal_True, sal_True);
861 : :
862 : : // scope for title template (all indices)
863 : : {
864 : : // header style name
865 [ + - ][ + - ]: 14 : aAny = rPropertySet->getPropertyValue(sParaStyleHeading);
866 : 14 : OUString sStyleName;
867 : 14 : aAny >>= sStyleName;
868 : 14 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
869 : : XML_STYLE_NAME,
870 [ + - + - ]: 28 : GetExport().EncodeStyleName( sStyleName ));
871 : :
872 : : // title template
873 : 14 : SvXMLElementExport aHeaderTemplate(GetExport(),
874 : : XML_NAMESPACE_TEXT,
875 : : XML_INDEX_TITLE_TEMPLATE,
876 [ + - ]: 14 : sal_True, sal_False);
877 : :
878 : : // title as element content
879 [ + - ][ + - ]: 14 : aAny = rPropertySet->getPropertyValue(sTitle);
880 : 14 : OUString sTitleString;
881 : 14 : aAny >>= sTitleString;
882 [ + - ][ + - ]: 14 : GetExport().Characters(sTitleString);
883 : : }
884 : :
885 : : // export level templates (all indices)
886 [ + - ][ + - ]: 14 : aAny = rPropertySet->getPropertyValue(sLevelFormat);
887 : 14 : Reference<XIndexReplace> xLevelTemplates;
888 [ + - ]: 14 : aAny >>= xLevelTemplates;
889 : :
890 : : // iterate over level formats;
891 : : // skip element 0 (empty template for title)
892 [ + - ][ + - ]: 14 : sal_Int32 nLevelCount = xLevelTemplates->getCount();
893 [ + + ]: 112 : for(sal_Int32 i = 1; i<nLevelCount; i++)
894 : : {
895 : : // get sequence
896 [ + - ]: 98 : Sequence<PropertyValues> aTemplateSequence;
897 [ + - ][ + - ]: 98 : aAny = xLevelTemplates->getByIndex(i);
898 [ + - ]: 98 : aAny >>= aTemplateSequence;
899 : :
900 : : // export the sequence (abort export if an error occurred; #91214#)
901 : : sal_Bool bResult =
902 [ + - ]: 98 : ExportIndexTemplate(eType, i, rPropertySet, aTemplateSequence);
903 [ - + ]: 98 : if ( !bResult )
904 : : break;
905 [ + - ][ + - ]: 98 : }
906 : :
907 : : // only TOC and user index:
908 : : // styles from which to build the index (LevelParagraphStyles)
909 [ + + ][ + + ]: 14 : if ( (TEXT_SECTION_TYPE_TOC == eType) ||
910 : : (TEXT_SECTION_TYPE_USER == eType) )
911 : : {
912 [ + - ][ + - ]: 4 : aAny = rPropertySet->getPropertyValue(sLevelParagraphStyles);
913 : 4 : Reference<XIndexReplace> xLevelParagraphStyles;
914 [ + - ]: 4 : aAny >>= xLevelParagraphStyles;
915 [ + - ]: 4 : ExportLevelParagraphStyles(xLevelParagraphStyles);
916 [ + - ]: 14 : }
917 : 14 : }
918 : :
919 : :
920 : 14 : void XMLSectionExport::ExportBaseIndexBody(
921 : : SectionTypeEnum
922 : : #if OSL_DEBUG_LEVEL > 0
923 : : eType
924 : : #endif
925 : : ,
926 : : const Reference<XPropertySet> &)
927 : : {
928 : : // type not used; checked anyway.
929 : : OSL_ENSURE(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type");
930 : : OSL_ENSURE(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type");
931 : :
932 : : // export start only
933 : :
934 : : // any old attributes?
935 : 14 : GetExport().CheckAttrList();
936 : :
937 : : // start surrounded by whitespace
938 : 14 : GetExport().IgnorableWhitespace();
939 : 14 : GetExport().StartElement( XML_NAMESPACE_TEXT, XML_INDEX_BODY, sal_True );
940 : 14 : }
941 : :
942 : 4 : void XMLSectionExport::ExportTableAndIllustrationIndexSourceAttributes(
943 : : const Reference<XPropertySet> & rPropertySet)
944 : : {
945 : : // use caption
946 [ + - ][ + - ]: 4 : Any aAny = rPropertySet->getPropertyValue(sCreateFromLabels);
947 [ - + ]: 4 : if (! *(sal_Bool*)aAny.getValue())
948 : : {
949 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
950 [ # # ]: 0 : XML_USE_CAPTION, XML_FALSE);
951 : : }
952 : :
953 : : // sequence name
954 [ + - ][ + - ]: 4 : aAny = rPropertySet->getPropertyValue(sLabelCategory);
955 : 4 : OUString sSequenceName;
956 : 4 : aAny >>= sSequenceName;
957 : 4 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
958 : : XML_CAPTION_SEQUENCE_NAME,
959 [ + - ]: 4 : sSequenceName);
960 : :
961 : : // caption format
962 [ + - ][ + - ]: 4 : aAny = rPropertySet->getPropertyValue(sLabelDisplayType);
963 : 4 : sal_Int16 nType = 0;
964 : 4 : aAny >>= nType;
965 : 4 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
966 : : XML_CAPTION_SEQUENCE_FORMAT,
967 [ + - + - ]: 8 : XMLTextFieldExport::MapReferenceType(nType));
968 : 4 : }
969 : :
970 : :
971 : : // map index of LevelFormats to attribute value;
972 : : // level 0 is always the header
973 : : static const XMLTokenEnum aLevelNameTOCMap[] =
974 : : { XML_TOKEN_INVALID, XML_1, XML_2, XML_3, XML_4, XML_5, XML_6, XML_7,
975 : : XML_8, XML_9, XML_10, XML_TOKEN_INVALID };
976 : : static const XMLTokenEnum aLevelNameTableMap[] =
977 : : { XML_TOKEN_INVALID, XML__EMPTY, XML_TOKEN_INVALID };
978 : : static const XMLTokenEnum aLevelNameAlphaMap[] =
979 : : { XML_TOKEN_INVALID, XML_SEPARATOR, XML_1, XML_2, XML_3, XML_TOKEN_INVALID };
980 : : static const XMLTokenEnum aLevelNameBibliographyMap[] =
981 : : { XML_TOKEN_INVALID, XML_ARTICLE, XML_BOOK, XML_BOOKLET, XML_CONFERENCE,
982 : : XML_CUSTOM1, XML_CUSTOM2, XML_CUSTOM3, XML_CUSTOM4,
983 : : XML_CUSTOM5, XML_EMAIL, XML_INBOOK, XML_INCOLLECTION,
984 : : XML_INPROCEEDINGS, XML_JOURNAL,
985 : : XML_MANUAL, XML_MASTERSTHESIS, XML_MISC, XML_PHDTHESIS,
986 : : XML_PROCEEDINGS, XML_TECHREPORT, XML_UNPUBLISHED, XML_WWW,
987 : : XML_TOKEN_INVALID };
988 : :
989 : : static const XMLTokenEnum* aTypeLevelNameMap[] =
990 : : {
991 : : aLevelNameTOCMap, // TOC
992 : : aLevelNameTableMap, // table index
993 : : aLevelNameTableMap, // illustration index
994 : : aLevelNameTableMap, // object index
995 : : aLevelNameTOCMap, // user index
996 : : aLevelNameAlphaMap, // alphabetical index
997 : : aLevelNameBibliographyMap // bibliography
998 : : };
999 : :
1000 : : static const sal_Char* aLevelStylePropNameTOCMap[] =
1001 : : { NULL, "ParaStyleLevel1", "ParaStyleLevel2", "ParaStyleLevel3",
1002 : : "ParaStyleLevel4", "ParaStyleLevel5", "ParaStyleLevel6",
1003 : : "ParaStyleLevel7", "ParaStyleLevel8", "ParaStyleLevel9",
1004 : : "ParaStyleLevel10", NULL };
1005 : : static const sal_Char* aLevelStylePropNameTableMap[] =
1006 : : { NULL, "ParaStyleLevel1", NULL };
1007 : : static const sal_Char* aLevelStylePropNameAlphaMap[] =
1008 : : { NULL, "ParaStyleSeparator", "ParaStyleLevel1", "ParaStyleLevel2",
1009 : : "ParaStyleLevel3", NULL };
1010 : : static const sal_Char* aLevelStylePropNameBibliographyMap[] =
1011 : : // TODO: replace with real property names, when available
1012 : : { NULL, "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1013 : : "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1014 : : "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1015 : : "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1016 : : "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1017 : : "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1018 : : "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1019 : : "ParaStyleLevel1",
1020 : : NULL };
1021 : :
1022 : : static const sal_Char** aTypeLevelStylePropNameMap[] =
1023 : : {
1024 : : aLevelStylePropNameTOCMap, // TOC
1025 : : aLevelStylePropNameTableMap, // table index
1026 : : aLevelStylePropNameTableMap, // illustration index
1027 : : aLevelStylePropNameTableMap, // object index
1028 : : aLevelStylePropNameTOCMap, // user index
1029 : : aLevelStylePropNameAlphaMap, // alphabetical index
1030 : : aLevelStylePropNameBibliographyMap // bibliography
1031 : : };
1032 : :
1033 : : static const XMLTokenEnum aTypeLevelAttrMap[] =
1034 : : {
1035 : : XML_OUTLINE_LEVEL, // TOC
1036 : : XML_TOKEN_INVALID, // table index
1037 : : XML_TOKEN_INVALID, // illustration index
1038 : : XML_TOKEN_INVALID, // object index
1039 : : XML_OUTLINE_LEVEL, // user index
1040 : : XML_OUTLINE_LEVEL, // alphabetical index
1041 : : XML_BIBLIOGRAPHY_TYPE // bibliography
1042 : : };
1043 : :
1044 : : static const XMLTokenEnum aTypeElementNameMap[] =
1045 : : {
1046 : : XML_TABLE_OF_CONTENT_ENTRY_TEMPLATE, // TOC
1047 : : XML_TABLE_INDEX_ENTRY_TEMPLATE, // table index
1048 : : XML_ILLUSTRATION_INDEX_ENTRY_TEMPLATE, // illustration index
1049 : : XML_OBJECT_INDEX_ENTRY_TEMPLATE, // object index
1050 : : XML_USER_INDEX_ENTRY_TEMPLATE, // user index
1051 : : XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE, // alphabetical index
1052 : : XML_BIBLIOGRAPHY_ENTRY_TEMPLATE // bibliography
1053 : : };
1054 : :
1055 : :
1056 : 98 : sal_Bool XMLSectionExport::ExportIndexTemplate(
1057 : : SectionTypeEnum eType,
1058 : : sal_Int32 nOutlineLevel,
1059 : : const Reference<XPropertySet> & rPropertySet,
1060 : : Sequence<Sequence<PropertyValue> > & rValues)
1061 : : {
1062 : : OSL_ENSURE(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type");
1063 : : OSL_ENSURE(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type");
1064 : : OSL_ENSURE(nOutlineLevel >= 0, "illegal outline level");
1065 : :
1066 [ + - ][ + - ]: 98 : if ( (eType >= TEXT_SECTION_TYPE_TOC) &&
[ + - ]
1067 : : (eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY) &&
1068 : : (nOutlineLevel >= 0) )
1069 : : {
1070 : : // get level name and level attribute name from aLevelNameMap;
1071 : : const XMLTokenEnum eLevelAttrName(
1072 : 98 : aTypeLevelAttrMap[eType-TEXT_SECTION_TYPE_TOC]);
1073 : : const XMLTokenEnum eLevelName(
1074 : 98 : aTypeLevelNameMap[eType-TEXT_SECTION_TYPE_TOC][nOutlineLevel]);
1075 : :
1076 : : // #92124#: some old documents may be broken, then they have
1077 : : // too many template levels; we need to recognize this and
1078 : : // export only as many as is legal for the respective index
1079 : : // type. To do this, we simply return an error flag, which
1080 : : // will then abort further template level exports.
1081 : : OSL_ENSURE(XML_TOKEN_INVALID != eLevelName, "can't find level name");
1082 [ - + ]: 98 : if ( XML_TOKEN_INVALID == eLevelName )
1083 : : {
1084 : : // output level not found? Then end of templates! #91214#
1085 : 0 : return sal_False;
1086 : : }
1087 : :
1088 : : // output level name
1089 [ + - ][ + + ]: 98 : if ((XML_TOKEN_INVALID != eLevelName) && (XML_TOKEN_INVALID != eLevelAttrName))
1090 : : {
1091 : 92 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1092 [ + - ]: 92 : GetXMLToken(eLevelAttrName),
1093 [ + - + - ]: 184 : GetXMLToken(eLevelName));
1094 : : }
1095 : :
1096 : : // paragraph level style name
1097 : : const sal_Char* pPropName(
1098 : 98 : aTypeLevelStylePropNameMap[eType-TEXT_SECTION_TYPE_TOC][nOutlineLevel]);
1099 : : OSL_ENSURE(NULL != pPropName, "can't find property name");
1100 [ + - ]: 98 : if (NULL != pPropName)
1101 : : {
1102 [ + - ]: 98 : Any aAny = rPropertySet->getPropertyValue(
1103 [ + - ]: 98 : OUString::createFromAscii(pPropName));
1104 : 98 : OUString sParaStyleName;
1105 : 98 : aAny >>= sParaStyleName;
1106 : 98 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1107 : : XML_STYLE_NAME,
1108 [ + - + - ]: 196 : GetExport().EncodeStyleName( sParaStyleName ));
1109 : : }
1110 : :
1111 : : // template element
1112 : : const XMLTokenEnum eElementName(
1113 : 98 : aTypeElementNameMap[eType - TEXT_SECTION_TYPE_TOC]);
1114 : 98 : SvXMLElementExport aLevelTemplate(GetExport(),
1115 : : XML_NAMESPACE_TEXT,
1116 [ + - ]: 98 : GetXMLToken(eElementName),
1117 [ + - ]: 98 : sal_True, sal_True);
1118 : :
1119 : : // export sequence
1120 : 98 : sal_Int32 nTemplateCount = rValues.getLength();
1121 [ + + ]: 588 : for(sal_Int32 nTemplateNo = 0;
1122 : : nTemplateNo < nTemplateCount;
1123 : : nTemplateNo++)
1124 : : {
1125 : : ExportIndexTemplateElement(
1126 : : eType, //i90246
1127 [ + - ][ + - ]: 490 : rValues[nTemplateNo]);
1128 [ + - ]: 98 : }
1129 : : }
1130 : :
1131 : 98 : return sal_True;
1132 : : }
1133 : :
1134 : :
1135 : : enum TemplateTypeEnum
1136 : : {
1137 : : TOK_TTYPE_ENTRY_NUMBER,
1138 : : TOK_TTYPE_ENTRY_TEXT,
1139 : : TOK_TTYPE_TAB_STOP,
1140 : : TOK_TTYPE_TEXT,
1141 : : TOK_TTYPE_PAGE_NUMBER,
1142 : : TOK_TTYPE_CHAPTER_INFO,
1143 : : TOK_TTYPE_HYPERLINK_START,
1144 : : TOK_TTYPE_HYPERLINK_END,
1145 : : TOK_TTYPE_BIBLIOGRAPHY,
1146 : : TOK_TTYPE_INVALID
1147 : : };
1148 : :
1149 : : enum TemplateParamEnum
1150 : : {
1151 : : TOK_TPARAM_TOKEN_TYPE,
1152 : : TOK_TPARAM_CHAR_STYLE,
1153 : : TOK_TPARAM_TAB_RIGHT_ALIGNED,
1154 : : TOK_TPARAM_TAB_POSITION,
1155 : : TOK_TPARAM_TAB_WITH_TAB, // #i21237#
1156 : : TOK_TPARAM_TAB_FILL_CHAR,
1157 : : TOK_TPARAM_TEXT,
1158 : : TOK_TPARAM_CHAPTER_FORMAT,
1159 : : TOK_TPARAM_CHAPTER_LEVEL,//i53420
1160 : : TOK_TPARAM_BIBLIOGRAPHY_DATA
1161 : : };
1162 : :
1163 : : SvXMLEnumStringMapEntry const aTemplateTypeMap[] =
1164 : : {
1165 : : ENUM_STRING_MAP_ENTRY( "TokenEntryNumber", TOK_TTYPE_ENTRY_NUMBER ),
1166 : : ENUM_STRING_MAP_ENTRY( "TokenEntryText", TOK_TTYPE_ENTRY_TEXT ),
1167 : : ENUM_STRING_MAP_ENTRY( "TokenTabStop", TOK_TTYPE_TAB_STOP ),
1168 : : ENUM_STRING_MAP_ENTRY( "TokenText", TOK_TTYPE_TEXT ),
1169 : : ENUM_STRING_MAP_ENTRY( "TokenPageNumber", TOK_TTYPE_PAGE_NUMBER ),
1170 : : ENUM_STRING_MAP_ENTRY( "TokenChapterInfo", TOK_TTYPE_CHAPTER_INFO ),
1171 : : ENUM_STRING_MAP_ENTRY( "TokenHyperlinkStart", TOK_TTYPE_HYPERLINK_START ),
1172 : : ENUM_STRING_MAP_ENTRY( "TokenHyperlinkEnd", TOK_TTYPE_HYPERLINK_END ),
1173 : : ENUM_STRING_MAP_ENTRY( "TokenBibliographyDataField", TOK_TTYPE_BIBLIOGRAPHY ),
1174 : : ENUM_STRING_MAP_END()
1175 : : };
1176 : :
1177 : : SvXMLEnumStringMapEntry const aTemplateParamMap[] =
1178 : : {
1179 : : ENUM_STRING_MAP_ENTRY( "TokenType", TOK_TPARAM_TOKEN_TYPE ),
1180 : : ENUM_STRING_MAP_ENTRY( "CharacterStyleName", TOK_TPARAM_CHAR_STYLE ),
1181 : : ENUM_STRING_MAP_ENTRY( "TabStopRightAligned", TOK_TPARAM_TAB_RIGHT_ALIGNED ),
1182 : : ENUM_STRING_MAP_ENTRY( "TabStopPosition", TOK_TPARAM_TAB_POSITION ),
1183 : : ENUM_STRING_MAP_ENTRY( "TabStopFillCharacter", TOK_TPARAM_TAB_FILL_CHAR ),
1184 : : // #i21237#
1185 : : ENUM_STRING_MAP_ENTRY( "WithTab", TOK_TPARAM_TAB_WITH_TAB ),
1186 : : ENUM_STRING_MAP_ENTRY( "Text", TOK_TPARAM_TEXT ),
1187 : : ENUM_STRING_MAP_ENTRY( "ChapterFormat", TOK_TPARAM_CHAPTER_FORMAT ),
1188 : : ENUM_STRING_MAP_ENTRY( "ChapterLevel", TOK_TPARAM_CHAPTER_LEVEL ),//i53420
1189 : : ENUM_STRING_MAP_ENTRY( "BibliographyDataField", TOK_TPARAM_BIBLIOGRAPHY_DATA ),
1190 : : ENUM_STRING_MAP_END()
1191 : : };
1192 : :
1193 : : SvXMLEnumMapEntry const aBibliographyDataFieldMap[] =
1194 : : {
1195 : : { XML_ADDRESS, BibliographyDataField::ADDRESS },
1196 : : { XML_ANNOTE, BibliographyDataField::ANNOTE },
1197 : : { XML_AUTHOR, BibliographyDataField::AUTHOR },
1198 : : { XML_BIBLIOGRAPHY_TYPE, BibliographyDataField::BIBILIOGRAPHIC_TYPE },
1199 : : { XML_BOOKTITLE, BibliographyDataField::BOOKTITLE },
1200 : : { XML_CHAPTER, BibliographyDataField::CHAPTER },
1201 : : { XML_CUSTOM1, BibliographyDataField::CUSTOM1 },
1202 : : { XML_CUSTOM2, BibliographyDataField::CUSTOM2 },
1203 : : { XML_CUSTOM3, BibliographyDataField::CUSTOM3 },
1204 : : { XML_CUSTOM4, BibliographyDataField::CUSTOM4 },
1205 : : { XML_CUSTOM5, BibliographyDataField::CUSTOM5 },
1206 : : { XML_EDITION, BibliographyDataField::EDITION },
1207 : : { XML_EDITOR, BibliographyDataField::EDITOR },
1208 : : { XML_HOWPUBLISHED, BibliographyDataField::HOWPUBLISHED },
1209 : : { XML_IDENTIFIER, BibliographyDataField::IDENTIFIER },
1210 : : { XML_INSTITUTION, BibliographyDataField::INSTITUTION },
1211 : : { XML_ISBN, BibliographyDataField::ISBN },
1212 : : { XML_JOURNAL, BibliographyDataField::JOURNAL },
1213 : : { XML_MONTH, BibliographyDataField::MONTH },
1214 : : { XML_NOTE, BibliographyDataField::NOTE },
1215 : : { XML_NUMBER, BibliographyDataField::NUMBER },
1216 : : { XML_ORGANIZATIONS, BibliographyDataField::ORGANIZATIONS },
1217 : : { XML_PAGES, BibliographyDataField::PAGES },
1218 : : { XML_PUBLISHER, BibliographyDataField::PUBLISHER },
1219 : : { XML_REPORT_TYPE, BibliographyDataField::REPORT_TYPE },
1220 : : { XML_SCHOOL, BibliographyDataField::SCHOOL },
1221 : : { XML_SERIES, BibliographyDataField::SERIES },
1222 : : { XML_TITLE, BibliographyDataField::TITLE },
1223 : : { XML_URL, BibliographyDataField::URL },
1224 : : { XML_VOLUME, BibliographyDataField::VOLUME },
1225 : : { XML_YEAR, BibliographyDataField::YEAR },
1226 : : { XML_TOKEN_INVALID, 0 }
1227 : : };
1228 : :
1229 : 490 : void XMLSectionExport::ExportIndexTemplateElement(
1230 : : SectionTypeEnum eType, //i90246
1231 : : Sequence<PropertyValue> & rValues)
1232 : : {
1233 : : // variables for template values
1234 : :
1235 : : // char style
1236 : 490 : OUString sCharStyle;
1237 : 490 : sal_Bool bCharStyleOK = sal_False;
1238 : :
1239 : : // text
1240 : 490 : OUString sText;
1241 : 490 : sal_Bool bTextOK = sal_False;
1242 : :
1243 : : // tab position
1244 : 490 : sal_Bool bRightAligned = sal_False;
1245 : :
1246 : : // tab position
1247 : 490 : sal_Int32 nTabPosition = 0;
1248 : 490 : sal_Bool bTabPositionOK = sal_False;
1249 : :
1250 : : // fill character
1251 : 490 : OUString sFillChar;
1252 : 490 : sal_Bool bFillCharOK = sal_False;
1253 : :
1254 : : // chapter format
1255 : 490 : sal_Int16 nChapterFormat = 0;
1256 : 490 : sal_Bool bChapterFormatOK = sal_False;
1257 : :
1258 : : // outline max level
1259 : 490 : sal_Int16 nLevel = 0;
1260 : 490 : sal_Bool bLevelOK = sal_False;
1261 : :
1262 : : // Bibliography Data
1263 : 490 : sal_Int16 nBibliographyData = 0;
1264 : 490 : sal_Bool bBibliographyDataOK = sal_False;
1265 : :
1266 : : // With Tab Stop #i21237#
1267 : 490 : sal_Bool bWithTabStop = sal_False;
1268 : 490 : sal_Bool bWithTabStopOK = sal_False;
1269 : :
1270 : : //i90246, the ODF version being written to is:
1271 [ + - ]: 490 : const SvtSaveOptions::ODFDefaultVersion aODFVersion = rExport.getDefaultVersion();
1272 : : //the above version cannot be used for old OOo (OOo 1.0) formats!
1273 : :
1274 : : // token type
1275 : 490 : enum TemplateTypeEnum nTokenType = TOK_TTYPE_INVALID;
1276 : :
1277 : 490 : sal_Int32 nCount = rValues.getLength();
1278 [ + + ]: 1938 : for(sal_Int32 i = 0; i<nCount; i++)
1279 : : {
1280 : : sal_uInt16 nToken;
1281 [ + - ][ + - ]: 2896 : if ( SvXMLUnitConverter::convertEnum( nToken, rValues[i].Name,
1282 [ + - ]: 1448 : aTemplateParamMap ) )
1283 : : {
1284 : : // Only use direct and default values.
1285 : : // Wrong. no property states, so ignore.
1286 : : // if ( (beans::PropertyState_DIRECT_VALUE == rValues[i].State) ||
1287 : : // (beans::PropertyState_DEFAULT_VALUE == rValues[i].State) )
1288 : :
1289 [ + + + + : 1448 : switch (nToken)
- + + - -
+ - ]
1290 : : {
1291 : : case TOK_TPARAM_TOKEN_TYPE:
1292 : : {
1293 : : sal_uInt16 nTmp;
1294 : 490 : OUString sVal;
1295 [ + - ]: 490 : rValues[i].Value >>= sVal;
1296 [ + - ]: 490 : if (SvXMLUnitConverter::convertEnum( nTmp, sVal,
1297 [ + - ]: 490 : aTemplateTypeMap))
1298 : : {
1299 : 490 : nTokenType = (enum TemplateTypeEnum)nTmp;
1300 : : }
1301 : 490 : break;
1302 : : }
1303 : :
1304 : : case TOK_TPARAM_CHAR_STYLE:
1305 : : // only valid, if not empty
1306 [ + - ]: 490 : rValues[i].Value >>= sCharStyle;
1307 : 490 : bCharStyleOK = !sCharStyle.isEmpty();
1308 : 490 : break;
1309 : :
1310 : : case TOK_TPARAM_TEXT:
1311 [ + - ]: 134 : rValues[i].Value >>= sText;
1312 : 134 : bTextOK = sal_True;
1313 : 134 : break;
1314 : :
1315 : : case TOK_TPARAM_TAB_RIGHT_ALIGNED:
1316 : : bRightAligned =
1317 [ + - ]: 52 : *(sal_Bool *)rValues[i].Value.getValue();
1318 : 52 : break;
1319 : :
1320 : : case TOK_TPARAM_TAB_POSITION:
1321 [ # # ]: 0 : rValues[i].Value >>= nTabPosition;
1322 : 0 : bTabPositionOK = sal_True;
1323 : 0 : break;
1324 : :
1325 : : // #i21237#
1326 : : case TOK_TPARAM_TAB_WITH_TAB:
1327 [ + - ]: 52 : bWithTabStop = *(sal_Bool *)rValues[i].Value.getValue();
1328 : 52 : bWithTabStopOK = sal_True;
1329 : 52 : break;
1330 : :
1331 : : case TOK_TPARAM_TAB_FILL_CHAR:
1332 [ + - ]: 52 : rValues[i].Value >>= sFillChar;
1333 : 52 : bFillCharOK = sal_True;
1334 : 52 : break;
1335 : :
1336 : : case TOK_TPARAM_CHAPTER_FORMAT:
1337 [ # # ]: 0 : rValues[i].Value >>= nChapterFormat;
1338 : 0 : bChapterFormatOK = sal_True;
1339 : 0 : break;
1340 : : //---> i53420
1341 : : case TOK_TPARAM_CHAPTER_LEVEL:
1342 [ # # ]: 0 : rValues[i].Value >>= nLevel;
1343 : 0 : bLevelOK = sal_True;
1344 : 0 : break;
1345 : : case TOK_TPARAM_BIBLIOGRAPHY_DATA:
1346 [ + - ]: 178 : rValues[i].Value >>= nBibliographyData;
1347 : 178 : bBibliographyDataOK = sal_True;
1348 : 1448 : break;
1349 : : }
1350 : : }
1351 : : }
1352 : :
1353 : : // convert type to token (and check validity) ...
1354 : 490 : XMLTokenEnum eElement(XML_TOKEN_INVALID);
1355 [ + + + + : 490 : switch(nTokenType)
- + - - +
- ]
1356 : : {
1357 : : case TOK_TTYPE_ENTRY_TEXT:
1358 : 54 : eElement = XML_INDEX_ENTRY_TEXT;
1359 : 54 : break;
1360 : : case TOK_TTYPE_TAB_STOP:
1361 : : // test validity
1362 [ - + ][ # # ]: 52 : if ( bRightAligned || bTabPositionOK || bFillCharOK )
[ # # ]
1363 : : {
1364 : 52 : eElement = XML_INDEX_ENTRY_TAB_STOP;
1365 : : }
1366 : 52 : break;
1367 : : case TOK_TTYPE_TEXT:
1368 : : // test validity
1369 [ + - ]: 134 : if (bTextOK)
1370 : : {
1371 : 134 : eElement = XML_INDEX_ENTRY_SPAN;
1372 : : }
1373 : 134 : break;
1374 : : case TOK_TTYPE_PAGE_NUMBER:
1375 : 52 : eElement = XML_INDEX_ENTRY_PAGE_NUMBER;
1376 : 52 : break;
1377 : : case TOK_TTYPE_CHAPTER_INFO: // keyword index
1378 : 0 : eElement = XML_INDEX_ENTRY_CHAPTER;
1379 : 0 : break;
1380 : : case TOK_TTYPE_ENTRY_NUMBER: // table of content
1381 : 20 : eElement = XML_INDEX_ENTRY_CHAPTER;
1382 : 20 : break;
1383 : : case TOK_TTYPE_HYPERLINK_START:
1384 : 0 : eElement = XML_INDEX_ENTRY_LINK_START;
1385 : 0 : break;
1386 : : case TOK_TTYPE_HYPERLINK_END:
1387 : 0 : eElement = XML_INDEX_ENTRY_LINK_END;
1388 : 0 : break;
1389 : : case TOK_TTYPE_BIBLIOGRAPHY:
1390 [ + - ]: 178 : if (bBibliographyDataOK)
1391 : : {
1392 : 178 : eElement = XML_INDEX_ENTRY_BIBLIOGRAPHY;
1393 : : }
1394 : 178 : break;
1395 : : default:
1396 : : ; // unknown/unimplemented template
1397 : 0 : break;
1398 : : }
1399 : :
1400 : : //--->i90246
1401 : : //check the ODF version being exported
1402 [ + - ][ - + ]: 490 : if( aODFVersion == SvtSaveOptions::ODFVER_011
1403 : : || aODFVersion == SvtSaveOptions::ODFVER_010)
1404 : : {
1405 : 0 : bLevelOK = sal_False;
1406 [ # # ]: 0 : if (TOK_TTYPE_CHAPTER_INFO == nTokenType)
1407 : : {
1408 : : //if we are emitting for ODF 1.1 or 1.0, this information can be used for alphabetical index only
1409 : : //it's not permitted in other indexes
1410 [ # # ]: 0 : if (eType != TEXT_SECTION_TYPE_ALPHABETICAL)
1411 : : {
1412 : 0 : eElement = XML_TOKEN_INVALID; //not permitted, invalidate the element
1413 : : }
1414 : : else //maps format for 1.1 & 1.0
1415 : : {
1416 : : // a few word here: OOo up to 2.4 uses the field chapter info in Alphabetical index
1417 : : // in a way different from the ODF 1.1/1.0 specification:
1418 : : //
1419 : : // ODF1.1/1.0 OOo display in chapter info ODF1.2
1420 : : // (used in alphabetical index only
1421 : : //
1422 : : // number chapter number without pre/postfix plain-number
1423 : : // number-and-name chapter number without pre/postfix plus title plain-number-and-name
1424 : : //
1425 : : // with issue i89791 the reading of ODF 1.1 and 1.0 was corrected
1426 : : // this one corrects the writing back from ODF 1.2 to ODF 1.1/1.0
1427 : : // unfortunately if there is another application which interprets correctly ODF1.1/1.0,
1428 : : // the resulting alphabetical index will be rendered wrong by OOo 2.4 version
1429 : : //
1430 [ # # # ]: 0 : switch( nChapterFormat )
1431 : : {
1432 : : case ChapterFormat::DIGIT:
1433 : 0 : nChapterFormat = ChapterFormat::NUMBER;
1434 : 0 : break;
1435 : : case ChapterFormat::NO_PREFIX_SUFFIX:
1436 : 0 : nChapterFormat = ChapterFormat::NAME_NUMBER;
1437 : 0 : break;
1438 : : }
1439 : : }
1440 : : }
1441 [ # # ]: 0 : else if (TOK_TTYPE_ENTRY_NUMBER == nTokenType)
1442 : : {
1443 : : //in case of ODF 1.1 or 1.0 the only allowed number format is "number"
1444 : : //so, force it...
1445 : : // The only expected 'foreign' nChapterFormat is
1446 : : // ' ChapterFormat::DIGIT', forced to 'none, since the
1447 : : // 'value allowed in ODF 1.1 and 1.0 is 'number' the default
1448 : : // this can be obtained by simply disabling the chapter format
1449 : 0 : bChapterFormatOK = sal_False;
1450 : : }
1451 : : }
1452 : :
1453 : : // ... and write Element
1454 [ + - ]: 490 : if (eElement != XML_TOKEN_INVALID)
1455 : : {
1456 : : // character style (for most templates)
1457 [ - + ]: 490 : if (bCharStyleOK)
1458 : : {
1459 [ # # ]: 0 : switch (nTokenType)
1460 : : {
1461 : : case TOK_TTYPE_ENTRY_TEXT:
1462 : : case TOK_TTYPE_TEXT:
1463 : : case TOK_TTYPE_PAGE_NUMBER:
1464 : : case TOK_TTYPE_ENTRY_NUMBER:
1465 : : case TOK_TTYPE_HYPERLINK_START:
1466 : : case TOK_TTYPE_HYPERLINK_END:
1467 : : case TOK_TTYPE_BIBLIOGRAPHY:
1468 : : case TOK_TTYPE_CHAPTER_INFO:
1469 : : case TOK_TTYPE_TAB_STOP:
1470 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1471 : : XML_STYLE_NAME,
1472 [ # # # # ]: 0 : GetExport().EncodeStyleName( sCharStyle) );
1473 : 0 : break;
1474 : : default:
1475 : : ; // nothing: no character style
1476 : 0 : break;
1477 : : }
1478 : : }
1479 : :
1480 : : // tab properties
1481 [ + + ]: 490 : if (TOK_TTYPE_TAB_STOP == nTokenType)
1482 : : {
1483 : : // tab type
1484 : 52 : GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_TYPE,
1485 [ + - ][ + - ]: 104 : bRightAligned ? XML_RIGHT : XML_LEFT);
1486 : :
1487 [ - + ][ # # ]: 52 : if (bTabPositionOK && (! bRightAligned))
1488 : : {
1489 : : // position for left tabs (convert to measure)
1490 : 0 : OUStringBuffer sBuf;
1491 : 0 : GetExport().GetMM100UnitConverter().convertMeasureToXML(sBuf,
1492 [ # # ]: 0 : nTabPosition);
1493 : 0 : GetExport().AddAttribute(XML_NAMESPACE_STYLE,
1494 : : XML_POSITION,
1495 [ # # # # ]: 0 : sBuf.makeStringAndClear());
1496 : : }
1497 : :
1498 : : // fill char ("leader char")
1499 [ + - ][ + - ]: 52 : if (bFillCharOK && !sFillChar.isEmpty())
[ + - ]
1500 : : {
1501 : 52 : GetExport().AddAttribute(XML_NAMESPACE_STYLE,
1502 [ + - ]: 52 : XML_LEADER_CHAR, sFillChar);
1503 : : }
1504 : :
1505 : : // #i21237#
1506 [ + - ][ - + ]: 52 : if (bWithTabStopOK && ! bWithTabStop)
1507 : : {
1508 : 0 : GetExport().AddAttribute(XML_NAMESPACE_STYLE,
1509 : : XML_WITH_TAB,
1510 [ # # ]: 0 : XML_FALSE);
1511 : : }
1512 : : }
1513 : :
1514 : : // bibliography data
1515 [ + + ]: 490 : if (TOK_TTYPE_BIBLIOGRAPHY == nTokenType)
1516 : : {
1517 : : OSL_ENSURE(bBibliographyDataOK, "need bibl data");
1518 : 178 : OUStringBuffer sBuf;
1519 [ + - ]: 178 : if (SvXMLUnitConverter::convertEnum( sBuf, nBibliographyData,
1520 [ + - ]: 178 : aBibliographyDataFieldMap ) )
1521 : : {
1522 : 178 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1523 : : XML_BIBLIOGRAPHY_DATA_FIELD,
1524 [ + - + - ]: 356 : sBuf.makeStringAndClear());
1525 : 178 : }
1526 : : }
1527 : :
1528 : : // chapter info
1529 [ - + ]: 490 : if (TOK_TTYPE_CHAPTER_INFO == nTokenType)
1530 : : {
1531 : : OSL_ENSURE(bChapterFormatOK, "need chapter info");
1532 : 0 : GetExport().AddAttribute(
1533 : : XML_NAMESPACE_TEXT, XML_DISPLAY,
1534 [ # # # # ]: 0 : XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat));
1535 : : //---> i53420
1536 [ # # ]: 0 : if (bLevelOK)
1537 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,
1538 [ # # ]: 0 : OUString::valueOf((sal_Int32)nLevel));
1539 : : }
1540 : :
1541 : : //--->i53420
1542 [ + + ]: 490 : if (TOK_TTYPE_ENTRY_NUMBER == nTokenType)
1543 : : {
1544 [ - + ]: 20 : if (bChapterFormatOK)
1545 : 0 : GetExport().AddAttribute(
1546 : : XML_NAMESPACE_TEXT, XML_DISPLAY,
1547 [ # # # # ]: 0 : XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat));
1548 : :
1549 [ - + ]: 20 : if (bLevelOK)
1550 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,
1551 [ # # ]: 0 : OUString::valueOf((sal_Int32)nLevel));
1552 : : }
1553 : : // export template
1554 : 490 : SvXMLElementExport aTemplateElement(GetExport(), XML_NAMESPACE_TEXT,
1555 [ + - ]: 490 : GetXMLToken(eElement),
1556 [ + - ]: 490 : sal_True, sal_False)
1557 : : ;
1558 : :
1559 : : // entry text or span element: write text
1560 [ + + ]: 490 : if (TOK_TTYPE_TEXT == nTokenType)
1561 : : {
1562 [ + - ]: 134 : GetExport().Characters(sText);
1563 [ + - ]: 490 : }
1564 : 490 : }
1565 : 490 : }
1566 : :
1567 : 4 : void XMLSectionExport::ExportLevelParagraphStyles(
1568 : : Reference<XIndexReplace> & xLevelParagraphStyles)
1569 : : {
1570 : : // iterate over levels
1571 : 4 : sal_Int32 nPLevelCount = xLevelParagraphStyles->getCount();
1572 [ + + ]: 44 : for(sal_Int32 nLevel = 0; nLevel < nPLevelCount; nLevel++)
1573 : : {
1574 [ + - ][ + - ]: 40 : Any aAny = xLevelParagraphStyles->getByIndex(nLevel);
1575 [ + - ]: 40 : Sequence<OUString> aStyleNames;
1576 [ + - ]: 40 : aAny >>= aStyleNames;
1577 : :
1578 : : // export only if at least one style is contained
1579 : 40 : sal_Int32 nNamesCount = aStyleNames.getLength();
1580 [ - + ]: 40 : if (nNamesCount > 0)
1581 : : {
1582 : : // level attribute; we count 1..10; API 0..9
1583 : 0 : OUStringBuffer sBuf;
1584 : 0 : sal_Int32 nLevelPlusOne = nLevel + 1;
1585 [ # # ]: 0 : ::sax::Converter::convertNumber(sBuf, nLevelPlusOne);
1586 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1587 : : XML_OUTLINE_LEVEL,
1588 [ # # # # ]: 0 : sBuf.makeStringAndClear());
1589 : :
1590 : : // source styles element
1591 : 0 : SvXMLElementExport aParaStyles(GetExport(),
1592 : : XML_NAMESPACE_TEXT,
1593 : : XML_INDEX_SOURCE_STYLES,
1594 [ # # ]: 0 : sal_True, sal_True);
1595 : :
1596 : : // iterate over styles in this level
1597 [ # # ]: 0 : for(sal_Int32 nName = 0; nName < nNamesCount; nName++)
1598 : : {
1599 : : // stylename attribute
1600 : 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1601 : : XML_STYLE_NAME,
1602 [ # # ]: 0 : GetExport().EncodeStyleName( aStyleNames[nName]) );
[ # # # # ]
1603 : :
1604 : : // element
1605 : 0 : SvXMLElementExport aParaStyle(GetExport(),
1606 : : XML_NAMESPACE_TEXT,
1607 : : XML_INDEX_SOURCE_STYLE,
1608 [ # # ]: 0 : sal_True, sal_False);
1609 [ # # ][ # # ]: 0 : }
1610 : : }
1611 [ + - ]: 40 : }
1612 : 4 : }
1613 : :
1614 : 46 : void XMLSectionExport::ExportBoolean(
1615 : : const Reference<XPropertySet> & rPropSet,
1616 : : const OUString& sPropertyName,
1617 : : enum XMLTokenEnum eAttributeName,
1618 : : sal_Bool bDefault,
1619 : : sal_Bool bInvert)
1620 : : {
1621 : : OSL_ENSURE(eAttributeName != XML_TOKEN_INVALID, "Need attribute name");
1622 : :
1623 [ + - ][ + - ]: 46 : Any aAny = rPropSet->getPropertyValue(sPropertyName);
1624 : 46 : sal_Bool bTmp = *(sal_Bool*)aAny.getValue();
1625 : :
1626 : : // value = value ^ bInvert
1627 : : // omit if value == default
1628 : : // negate forces sal_Bool to 0/1, making them comparable
1629 [ + + ]: 46 : if ((!(bTmp ^ bInvert)) != (!bDefault))
1630 : : {
1631 : : // export non-default value (since default is omitted)
1632 : 10 : GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1633 : : eAttributeName,
1634 [ - + ][ + - ]: 20 : bDefault ? XML_FALSE : XML_TRUE);
1635 : 46 : }
1636 : 46 : }
1637 : :
1638 : : const sal_Char sAPI_FieldMaster_Bibliography[] =
1639 : : "com.sun.star.text.FieldMaster.Bibliography";
1640 : : const sal_Char sAPI_SortKey[] = "SortKey";
1641 : : const sal_Char sAPI_IsSortAscending[] = "IsSortAscending";
1642 : :
1643 : 19 : void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport)
1644 : : {
1645 : : // first: get field master (via text field supplier)
1646 : 19 : Reference<XTextFieldsSupplier> xTextFieldsSupp( rExport.GetModel(),
1647 [ + - ]: 19 : UNO_QUERY );
1648 [ + - ]: 19 : if ( xTextFieldsSupp.is() )
1649 : : {
1650 : : const OUString sFieldMaster_Bibliography(
1651 [ + - ]: 19 : RTL_CONSTASCII_USTRINGPARAM(sAPI_FieldMaster_Bibliography));
1652 : :
1653 : : // get bibliography field master
1654 : : Reference<XNameAccess> xMasters =
1655 [ + - ][ + - ]: 19 : xTextFieldsSupp->getTextFieldMasters();
1656 [ + - ][ + - ]: 19 : if ( xMasters->hasByName(sFieldMaster_Bibliography) )
[ + + ]
1657 : : {
1658 : : Any aAny =
1659 [ + - ][ + - ]: 2 : xMasters->getByName(sFieldMaster_Bibliography);
1660 : 2 : Reference<XPropertySet> xPropSet;
1661 [ + - ]: 2 : aAny >>= xPropSet;
1662 : :
1663 : : OSL_ENSURE( xPropSet.is(), "field master must have XPropSet" );
1664 : :
1665 : : const OUString sBracketBefore(
1666 [ + - ]: 2 : RTL_CONSTASCII_USTRINGPARAM("BracketBefore"));
1667 : : const OUString sBracketAfter(
1668 [ + - ]: 2 : RTL_CONSTASCII_USTRINGPARAM("BracketAfter"));
1669 : : const OUString sIsNumberEntries(
1670 [ + - ]: 2 : RTL_CONSTASCII_USTRINGPARAM("IsNumberEntries"));
1671 : : const OUString sIsSortByPosition(
1672 [ + - ]: 2 : RTL_CONSTASCII_USTRINGPARAM("IsSortByPosition"));
1673 : : const OUString sSortKeys(
1674 [ + - ]: 2 : RTL_CONSTASCII_USTRINGPARAM("SortKeys"));
1675 : : const OUString sSortAlgorithm(
1676 [ + - ]: 2 : RTL_CONSTASCII_USTRINGPARAM("SortAlgorithm"));
1677 : : const OUString sLocale(
1678 [ + - ]: 2 : RTL_CONSTASCII_USTRINGPARAM("Locale"));
1679 : :
1680 : 2 : OUString sTmp;
1681 : :
1682 [ + - ][ + - ]: 2 : aAny = xPropSet->getPropertyValue(sBracketBefore);
1683 : 2 : aAny >>= sTmp;
1684 [ + - ]: 2 : rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_PREFIX, sTmp);
1685 : :
1686 [ + - ][ + - ]: 2 : aAny = xPropSet->getPropertyValue(sBracketAfter);
1687 : 2 : aAny >>= sTmp;
1688 [ + - ]: 2 : rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SUFFIX, sTmp);
1689 : :
1690 [ + - ][ + - ]: 2 : aAny = xPropSet->getPropertyValue(sIsNumberEntries);
1691 [ - + ]: 2 : if (*(sal_Bool*)aAny.getValue())
1692 : : {
1693 : : rExport.AddAttribute(XML_NAMESPACE_TEXT,
1694 [ # # ]: 0 : XML_NUMBERED_ENTRIES, XML_TRUE);
1695 : : }
1696 : :
1697 [ + - ][ + - ]: 2 : aAny = xPropSet->getPropertyValue(sIsSortByPosition);
1698 [ - + ]: 2 : if (! *(sal_Bool*)aAny.getValue())
1699 : : {
1700 : : rExport.AddAttribute(XML_NAMESPACE_TEXT,
1701 [ # # ]: 0 : XML_SORT_BY_POSITION, XML_FALSE);
1702 : : }
1703 : :
1704 : : // sort algorithm
1705 [ + - ][ + - ]: 2 : aAny = xPropSet->getPropertyValue(sSortAlgorithm);
1706 : 2 : OUString sAlgorithm;
1707 : 2 : aAny >>= sAlgorithm;
1708 [ + - ]: 2 : if( !sAlgorithm.isEmpty() )
1709 : : {
1710 : : rExport.AddAttribute( XML_NAMESPACE_TEXT,
1711 [ + - ]: 2 : XML_SORT_ALGORITHM, sAlgorithm );
1712 : : }
1713 : :
1714 : : // locale
1715 [ + - ][ + - ]: 2 : aAny = xPropSet->getPropertyValue(sLocale);
1716 : 2 : Locale aLocale;
1717 [ + - ]: 2 : aAny >>= aLocale;
1718 : : rExport.AddAttribute(XML_NAMESPACE_FO, XML_LANGUAGE,
1719 [ + - ]: 2 : aLocale.Language);
1720 : : rExport.AddAttribute(XML_NAMESPACE_FO, XML_COUNTRY,
1721 [ + - ]: 2 : aLocale.Country);
1722 : :
1723 : : // configuration element
1724 : : SvXMLElementExport aElement(rExport, XML_NAMESPACE_TEXT,
1725 : : XML_BIBLIOGRAPHY_CONFIGURATION,
1726 [ + - ]: 2 : sal_True, sal_True);
1727 : :
1728 : : // sort keys
1729 [ + - ][ + - ]: 2 : aAny = xPropSet->getPropertyValue(sSortKeys);
1730 [ + - ]: 2 : Sequence<Sequence<PropertyValue> > aKeys;
1731 [ + - ]: 2 : aAny >>= aKeys;
1732 : 2 : sal_Int32 nKeysCount = aKeys.getLength();
1733 [ - + ]: 2 : for(sal_Int32 nKeys = 0; nKeys < nKeysCount; nKeys++)
1734 : : {
1735 [ # # ]: 0 : Sequence<PropertyValue> & rKey = aKeys[nKeys];
1736 : :
1737 : 0 : sal_Int32 nKeyCount = rKey.getLength();
1738 [ # # ]: 0 : for(sal_Int32 nPropertyKey = 0; nPropertyKey < nKeyCount; nPropertyKey++)
1739 : : {
1740 [ # # ]: 0 : PropertyValue& rValue = rKey[nPropertyKey];
1741 : :
1742 [ # # ]: 0 : if (rValue.Name.equalsAsciiL(sAPI_SortKey,
1743 : 0 : sizeof(sAPI_SortKey)-1))
1744 : : {
1745 : 0 : sal_Int16 nKey = 0;
1746 : 0 : rValue.Value >>= nKey;
1747 : 0 : OUStringBuffer sBuf;
1748 [ # # ]: 0 : if (SvXMLUnitConverter::convertEnum( sBuf, nKey,
1749 [ # # ]: 0 : aBibliographyDataFieldMap ) )
1750 : : {
1751 : : rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_KEY,
1752 [ # # ][ # # ]: 0 : sBuf.makeStringAndClear());
1753 : 0 : }
1754 : : }
1755 [ # # ]: 0 : else if (rValue.Name.equalsAsciiL(sAPI_IsSortAscending,
1756 : 0 : sizeof(sAPI_IsSortAscending)-1))
1757 : : {
1758 : 0 : sal_Bool bTmp = *(sal_Bool*)rValue.Value.getValue();
1759 : : rExport.AddAttribute(XML_NAMESPACE_TEXT,
1760 : : XML_SORT_ASCENDING,
1761 [ # # ][ # # ]: 0 : bTmp ? XML_TRUE : XML_FALSE);
1762 : : }
1763 : : }
1764 : :
1765 : : SvXMLElementExport aKeyElem(rExport,
1766 : : XML_NAMESPACE_TEXT, XML_SORT_KEY,
1767 [ # # ]: 0 : sal_True, sal_True);
1768 [ # # ][ + - ]: 2 : }
[ + - ]
1769 : 19 : }
1770 : 19 : }
1771 : 19 : }
1772 : :
1773 : :
1774 : 454 : sal_Bool XMLSectionExport::IsMuteSection(
1775 : : const Reference<XTextSection> & rSection) const
1776 : : {
1777 : 454 : sal_Bool bRet = sal_False;
1778 : :
1779 : : // a section is mute if
1780 : : // 1) it exists
1781 : : // 2) the SaveLinkedSections flag (at the export) is false
1782 : : // 3) the IsGlobalDocumentSection property is true
1783 : : // 4) it is not an Index
1784 : :
1785 [ - + ][ # # ]: 454 : if ( (!rExport.IsSaveLinkedSections()) && rSection.is() )
[ - + ]
1786 : : {
1787 : : // walk the section chain and set bRet if any is linked
1788 [ # # # # ]: 0 : for(Reference<XTextSection> aSection(rSection);
1789 : 0 : aSection.is();
1790 [ # # ][ # # ]: 0 : aSection = aSection->getParentSection())
1791 : : {
1792 : : // check if it is a global document section (linked or index)
1793 [ # # ]: 0 : Reference<XPropertySet> xPropSet(aSection, UNO_QUERY);
1794 [ # # ]: 0 : if (xPropSet.is())
1795 : : {
1796 [ # # ][ # # ]: 0 : Any aAny = xPropSet->getPropertyValue(sIsGlobalDocumentSection);
1797 : :
1798 [ # # ]: 0 : if ( *(sal_Bool*)aAny.getValue() )
1799 : : {
1800 : 0 : Reference<XDocumentIndex> xIndex;
1801 [ # # ][ # # ]: 0 : if (! GetIndex(rSection, xIndex))
1802 : : {
1803 : 0 : bRet = sal_True;
1804 : :
1805 : : // early out if result is known
1806 : : break;
1807 [ # # ]: 0 : }
1808 [ # # ]: 0 : }
1809 : : }
1810 : : // section has no properties: ignore
1811 [ # # ]: 0 : }
1812 : : }
1813 : : // else: no section, or always save sections: default (false)
1814 : :
1815 : 454 : return bRet;
1816 : : }
1817 : :
1818 : 0 : sal_Bool XMLSectionExport::IsMuteSection(
1819 : : const Reference<XTextContent> & rSection,
1820 : : sal_Bool bDefault) const
1821 : : {
1822 : : // default: like default argument
1823 : 0 : sal_Bool bRet = bDefault;
1824 : :
1825 [ # # ][ # # ]: 0 : Reference<XPropertySet> xPropSet(rSection->getAnchor(), UNO_QUERY);
[ # # ]
1826 [ # # ]: 0 : if (xPropSet.is())
1827 : : {
1828 [ # # ][ # # ]: 0 : if (xPropSet->getPropertySetInfo()->hasPropertyByName(sTextSection))
[ # # ][ # # ]
[ # # ]
1829 : : {
1830 [ # # ][ # # ]: 0 : Any aAny = xPropSet->getPropertyValue(sTextSection);
1831 : 0 : Reference<XTextSection> xSection;
1832 [ # # ]: 0 : aAny >>= xSection;
1833 : :
1834 [ # # ]: 0 : bRet = IsMuteSection(xSection);
1835 : : }
1836 : : // else: return default
1837 : : }
1838 : : // else: return default
1839 : :
1840 : 0 : return bRet;
1841 : : }
1842 : :
1843 : 0 : sal_Bool XMLSectionExport::IsInSection(
1844 : : const Reference<XTextSection> & rEnclosingSection,
1845 : : const Reference<XTextContent> & rContent,
1846 : : sal_Bool bDefault)
1847 : : {
1848 : : // default: like default argument
1849 : 0 : sal_Bool bRet = bDefault;
1850 : : OSL_ENSURE(rEnclosingSection.is(), "enclosing section expected");
1851 : :
1852 [ # # ]: 0 : Reference<XPropertySet> xPropSet(rContent, UNO_QUERY);
1853 [ # # ]: 0 : if (xPropSet.is())
1854 : : {
1855 [ # # ][ # # ]: 0 : if (xPropSet->getPropertySetInfo()->hasPropertyByName(sTextSection))
[ # # ][ # # ]
[ # # ]
1856 : : {
1857 [ # # ][ # # ]: 0 : Any aAny = xPropSet->getPropertyValue(sTextSection);
1858 : 0 : Reference<XTextSection> xSection;
1859 [ # # ]: 0 : aAny >>= xSection;
1860 : :
1861 : : // now walk chain of text sections (if we have one)
1862 [ # # ]: 0 : if (xSection.is())
1863 : : {
1864 [ # # ]: 0 : do
[ # # # # ]
1865 : : {
1866 [ # # ]: 0 : bRet = (rEnclosingSection == xSection);
1867 [ # # ][ # # ]: 0 : xSection = xSection->getParentSection();
[ # # ]
1868 : : }
1869 : 0 : while (!bRet && xSection.is());
1870 : : }
1871 : : else
1872 : 0 : bRet = sal_False; // no section -> can't be inside
1873 : : }
1874 : : // else: no TextSection property -> return default
1875 : : }
1876 : : // else: no XPropertySet -> return default
1877 : :
1878 : 0 : return bRet;
1879 : : }
1880 : :
1881 : :
1882 : 0 : void XMLSectionExport::ExportMasterDocHeadingDummies()
1883 : : {
1884 [ # # ]: 0 : if( bHeadingDummiesExported )
1885 : : return;
1886 : :
1887 : 0 : Reference< XChapterNumberingSupplier > xCNSupplier( rExport.GetModel(),
1888 [ # # ]: 0 : UNO_QUERY );
1889 : :
1890 : 0 : Reference< XIndexReplace > xChapterNumbering;
1891 [ # # ]: 0 : if( xCNSupplier.is() )
1892 [ # # ][ # # ]: 0 : xChapterNumbering = xCNSupplier->getChapterNumberingRules();
[ # # ]
1893 : :
1894 [ # # ]: 0 : if( !xChapterNumbering.is() )
1895 : : return;
1896 : :
1897 [ # # ][ # # ]: 0 : sal_Int32 nCount = xChapterNumbering->getCount();
1898 [ # # ]: 0 : for( sal_Int32 nLevel = 0; nLevel < nCount; nLevel++ )
1899 : : {
1900 : 0 : OUString sStyle;
1901 [ # # ]: 0 : Sequence<PropertyValue> aProperties;
1902 [ # # ][ # # ]: 0 : xChapterNumbering->getByIndex( nLevel ) >>= aProperties;
[ # # ]
1903 [ # # ]: 0 : for( sal_Int32 i = 0; i < aProperties.getLength(); i++ )
1904 : : {
1905 [ # # ][ # # ]: 0 : if( aProperties[i].Name == sHeadingStyleName )
1906 : : {
1907 [ # # ]: 0 : aProperties[i].Value >>= sStyle;
1908 : 0 : break;
1909 : : }
1910 : : }
1911 [ # # ]: 0 : if( !sStyle.isEmpty() )
1912 : : {
1913 : 0 : GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
1914 [ # # # # ]: 0 : GetExport().EncodeStyleName( sStyle ) );
1915 : :
1916 : 0 : OUStringBuffer sTmp;
1917 [ # # ]: 0 : sTmp.append( nLevel + 1 );
1918 : 0 : GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LEVEL,
1919 [ # # # # ]: 0 : sTmp.makeStringAndClear() );
1920 : 0 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_H,
1921 [ # # ][ # # ]: 0 : sal_True, sal_False );
1922 : : }
1923 [ # # ]: 0 : }
1924 : :
1925 [ # # ][ # # ]: 0 : bHeadingDummiesExported = sal_True;
1926 : : }
1927 : :
1928 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|