bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / text / XMLSectionExport.cxx
blob94049faab79543f4544b54f243e147a3bce9d3d6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "XMLSectionExport.hxx"
21 #include <rtl/ustring.hxx>
22 #include <rtl/ustrbuf.hxx>
24 #include <vector>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/lang/Locale.hpp>
29 #include <com/sun/star/container/XIndexReplace.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/beans/PropertyValue.hpp>
32 #include <com/sun/star/beans/PropertyValues.hpp>
33 #include <com/sun/star/beans/PropertyState.hpp>
34 #include <com/sun/star/text/XText.hpp>
35 #include <com/sun/star/text/XTextSection.hpp>
36 #include <com/sun/star/text/SectionFileLink.hpp>
37 #include <com/sun/star/container/XNamed.hpp>
38 #include <com/sun/star/container/XNameAccess.hpp>
39 #include <com/sun/star/text/XDocumentIndex.hpp>
40 #include <com/sun/star/uno/XInterface.hpp>
41 #include <com/sun/star/text/BibliographyDataField.hpp>
42 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
43 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
44 #include <com/sun/star/text/ChapterFormat.hpp>
46 #include <sax/tools/converter.hxx>
48 #include <xmloff/xmltoken.hxx>
49 #include <xmloff/xmlnmspe.hxx>
50 #include <xmloff/families.hxx>
51 #include <xmloff/xmluconv.hxx>
52 #include <xmloff/nmspmap.hxx>
53 #include <xmloff/xmlexp.hxx>
54 #include <xmloff/xmltkmap.hxx>
55 #include "txtflde.hxx"
59 using namespace ::com::sun::star;
60 using namespace ::com::sun::star::text;
61 using namespace ::com::sun::star::uno;
62 using namespace ::std;
63 using namespace ::xmloff::token;
65 using ::com::sun::star::beans::XPropertySet;
66 using ::com::sun::star::beans::PropertyValue;
67 using ::com::sun::star::beans::PropertyValues;
68 using ::com::sun::star::beans::PropertyState;
69 using ::com::sun::star::container::XIndexReplace;
70 using ::com::sun::star::container::XNameAccess;
71 using ::com::sun::star::container::XNamed;
72 using ::com::sun::star::lang::XServiceInfo;
73 using ::com::sun::star::lang::Locale;
74 using ::com::sun::star::uno::XInterface;
77 XMLSectionExport::XMLSectionExport(
78 SvXMLExport& rExp,
79 XMLTextParagraphExport& rParaExp)
80 : sCondition("Condition")
81 , sCreateFromChapter("CreateFromChapter")
82 , sCreateFromEmbeddedObjects("CreateFromEmbeddedObjects")
83 , sCreateFromGraphicObjects("CreateFromGraphicObjects")
84 , sCreateFromLabels("CreateFromLabels")
85 , sCreateFromMarks("CreateFromMarks")
86 , sCreateFromOtherEmbeddedObjects("CreateFromOtherEmbeddedObjects")
87 , sCreateFromOutline("CreateFromOutline")
88 , sCreateFromStarCalc("CreateFromStarCalc")
89 , sCreateFromStarChart("CreateFromStarChart")
90 , sCreateFromStarDraw("CreateFromStarDraw")
91 , sCreateFromStarMath("CreateFromStarMath")
92 , sCreateFromTables("CreateFromTables")
93 , sCreateFromTextFrames("CreateFromTextFrames")
94 , sDdeCommandElement("DDECommandElement")
95 , sDdeCommandFile("DDECommandFile")
96 , sDdeCommandType("DDECommandType")
97 , sFileLink("FileLink")
98 , sIsCaseSensitive("IsCaseSensitive")
99 , sIsProtected("IsProtected")
100 , sIsVisible("IsVisible")
101 , sLabelCategory("LabelCategory")
102 , sLabelDisplayType("LabelDisplayType")
103 , sLevel("Level")
104 , sLevelFormat("LevelFormat")
105 , sLevelParagraphStyles("LevelParagraphStyles")
106 , sLinkRegion("LinkRegion")
107 , sMainEntryCharacterStyleName("MainEntryCharacterStyleName")
108 , sParaStyleHeading("ParaStyleHeading")
109 , sTitle("Title")
110 , sName("Name")
111 , sUseAlphabeticalSeparators("UseAlphabeticalSeparators")
112 , sUseCombinedEntries("UseCombinedEntries")
113 , sUseDash("UseDash")
114 , sUseKeyAsEntry("UseKeyAsEntry")
115 , sUseLevelFromSource("UseLevelFromSource")
116 , sUsePP("UsePP")
117 , sUseUpperCase("UseUpperCase")
118 , sIsCommaSeparated("IsCommaSeparated")
119 , sIsAutomaticUpdate("IsAutomaticUpdate")
120 , sIsRelativeTabstops("IsRelativeTabstops")
121 , sCreateFromLevelParagraphStyles("CreateFromLevelParagraphStyles")
122 , sDocumentIndex("DocumentIndex")
123 , sContentSection("ContentSection")
124 , sHeaderSection("HeaderSection")
126 , sTextSection("TextSection")
127 , sIsGlobalDocumentSection("IsGlobalDocumentSection")
128 , sProtectionKey("ProtectionKey")
129 , sSortAlgorithm("SortAlgorithm")
130 , sLocale("Locale")
131 , sUserIndexName("UserIndexName")
133 , sIsCurrentlyVisible("IsCurrentlyVisible")
134 , sHeadingStyleName("HeadingStyleName")
136 , rExport(rExp)
137 , rParaExport(rParaExp)
138 , bHeadingDummiesExported( false )
143 void XMLSectionExport::ExportSectionStart(
144 const Reference<XTextSection> & rSection,
145 bool bAutoStyles)
147 Reference<XPropertySet> xPropertySet(rSection, UNO_QUERY);
149 // always export section (auto) style
150 if (bAutoStyles)
152 // get PropertySet and add section style
153 GetParaExport().Add( XML_STYLE_FAMILY_TEXT_SECTION, xPropertySet );
155 else
157 // always export section style
158 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME,
159 GetParaExport().Find(
160 XML_STYLE_FAMILY_TEXT_SECTION,
161 xPropertySet, sEmpty ) );
163 // xml:id for RDF metadata
164 GetExport().AddAttributeXmlId(rSection);
166 // export index or regular section
167 Reference<XDocumentIndex> xIndex;
168 if (GetIndex(rSection, xIndex))
170 if (xIndex.is())
172 // we are an index
173 ExportIndexStart(xIndex);
175 else
177 // we are an index header
178 ExportIndexHeaderStart(rSection);
181 else
183 // we are not an index
184 ExportRegularSectionStart(rSection);
189 bool XMLSectionExport::GetIndex(
190 const Reference<XTextSection> & rSection,
191 Reference<XDocumentIndex> & rIndex) const
193 // first, reset result
194 bool bRet = false;
195 rIndex = NULL;
197 // get section Properties
198 Reference<XPropertySet> xSectionPropSet(rSection, UNO_QUERY);
200 // then check if this section happens to be inside an index
201 if (xSectionPropSet->getPropertySetInfo()->
202 hasPropertyByName(sDocumentIndex))
204 Any aAny = xSectionPropSet->getPropertyValue(sDocumentIndex);
205 Reference<XDocumentIndex> xDocumentIndex;
206 aAny >>= xDocumentIndex;
208 // OK, are we inside of an index
209 if (xDocumentIndex.is())
211 // is the enclosing index identical with "our" section?
212 Reference<XPropertySet> xIndexPropSet(xDocumentIndex, UNO_QUERY);
213 aAny = xIndexPropSet->getPropertyValue(sContentSection);
214 Reference<XTextSection> xEnclosingSection;
215 aAny >>= xEnclosingSection;
217 // if the enclosing section is "our" section, then we are an index!
218 if (rSection == xEnclosingSection)
220 rIndex = xDocumentIndex;
221 bRet = true;
223 // else: index header or regular section
225 // is the enclosing index identical with the header section?
226 aAny = xIndexPropSet->getPropertyValue(sHeaderSection);
227 // now mis-named: contains header section
228 aAny >>= xEnclosingSection;
230 // if the enclosing section is "our" section, then we are an index!
231 if (rSection == xEnclosingSection)
233 bRet = true;
235 // else: regular section
237 // else: we aren't even inside of an index
239 // else: we don't even know what an index is.
241 return bRet;
245 void XMLSectionExport::ExportSectionEnd(
246 const Reference<XTextSection> & rSection,
247 bool bAutoStyles)
249 // no end section for styles
250 if (!bAutoStyles)
252 enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
254 // export index or regular section end
255 Reference<XDocumentIndex> xIndex;
256 if (GetIndex(rSection, xIndex))
258 if (xIndex.is())
260 // index end: close index body element
261 GetExport().EndElement( XML_NAMESPACE_TEXT, XML_INDEX_BODY,
262 true );
263 GetExport().IgnorableWhitespace();
265 switch (MapSectionType(xIndex->getServiceName()))
267 case TEXT_SECTION_TYPE_TOC:
268 eElement = XML_TABLE_OF_CONTENT;
269 break;
271 case TEXT_SECTION_TYPE_ILLUSTRATION:
272 eElement = XML_ILLUSTRATION_INDEX;
273 break;
275 case TEXT_SECTION_TYPE_ALPHABETICAL:
276 eElement = XML_ALPHABETICAL_INDEX;
277 break;
279 case TEXT_SECTION_TYPE_TABLE:
280 eElement = XML_TABLE_INDEX;
281 break;
283 case TEXT_SECTION_TYPE_OBJECT:
284 eElement = XML_OBJECT_INDEX;
285 break;
287 case TEXT_SECTION_TYPE_USER:
288 eElement = XML_USER_INDEX;
289 break;
291 case TEXT_SECTION_TYPE_BIBLIOGRAPHY:
292 eElement = XML_BIBLIOGRAPHY;
293 break;
295 default:
296 OSL_FAIL("unknown index type");
297 // default: skip index!
298 break;
301 else
303 eElement = XML_INDEX_TITLE;
306 else
308 eElement = XML_SECTION;
311 if (XML_TOKEN_INVALID != eElement)
313 // any old attributes?
314 GetExport().CheckAttrList();
316 // element surrounded by whitespace
317 GetExport().EndElement( XML_NAMESPACE_TEXT, eElement, true);
318 GetExport().IgnorableWhitespace();
320 else
322 OSL_FAIL("Need element name!");
325 // else: autostyles -> ignore
328 void XMLSectionExport::ExportIndexStart(
329 const Reference<XDocumentIndex> & rIndex)
331 // get PropertySet
332 Reference<XPropertySet> xPropertySet(rIndex, UNO_QUERY);
334 switch (MapSectionType(rIndex->getServiceName()))
336 case TEXT_SECTION_TYPE_TOC:
337 ExportTableOfContentStart(xPropertySet);
338 break;
340 case TEXT_SECTION_TYPE_ILLUSTRATION:
341 ExportIllustrationIndexStart(xPropertySet);
342 break;
344 case TEXT_SECTION_TYPE_ALPHABETICAL:
345 ExportAlphabeticalIndexStart(xPropertySet);
346 break;
348 case TEXT_SECTION_TYPE_TABLE:
349 ExportTableIndexStart(xPropertySet);
350 break;
352 case TEXT_SECTION_TYPE_OBJECT:
353 ExportObjectIndexStart(xPropertySet);
354 break;
356 case TEXT_SECTION_TYPE_USER:
357 ExportUserIndexStart(xPropertySet);
358 break;
360 case TEXT_SECTION_TYPE_BIBLIOGRAPHY:
361 ExportBibliographyStart(xPropertySet);
362 break;
364 default:
365 // skip index
366 OSL_FAIL("unknown index type");
367 break;
371 void XMLSectionExport::ExportIndexHeaderStart(
372 const Reference<XTextSection> & rSection)
374 // export name, dammit!
375 Reference<XNamed> xName(rSection, UNO_QUERY);
376 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xName->getName());
378 // format already handled -> export only start element
379 GetExport().StartElement( XML_NAMESPACE_TEXT, XML_INDEX_TITLE, true );
380 GetExport().IgnorableWhitespace();
384 SvXMLEnumStringMapEntry const aIndexTypeMap[] =
386 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.ContentIndex", TEXT_SECTION_TYPE_TOC ),
387 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.DocumentIndex", TEXT_SECTION_TYPE_ALPHABETICAL ),
388 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.TableIndex", TEXT_SECTION_TYPE_TABLE ),
389 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.ObjectIndex", TEXT_SECTION_TYPE_OBJECT ),
390 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.Bibliography", TEXT_SECTION_TYPE_BIBLIOGRAPHY ),
391 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.UserIndex", TEXT_SECTION_TYPE_USER ),
392 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.IllustrationsIndex", TEXT_SECTION_TYPE_ILLUSTRATION ),
393 ENUM_STRING_MAP_END()
396 enum SectionTypeEnum XMLSectionExport::MapSectionType(
397 const OUString& rServiceName)
399 enum SectionTypeEnum eType = TEXT_SECTION_TYPE_UNKNOWN;
401 sal_uInt16 nTmp;
402 if (SvXMLUnitConverter::convertEnum(nTmp, rServiceName, aIndexTypeMap))
404 eType = (enum SectionTypeEnum)nTmp;
407 // TODO: index header section types, etc.
409 return eType;
412 void XMLSectionExport::ExportRegularSectionStart(
413 const Reference<XTextSection> & rSection)
415 // style name already handled in ExportSectionStart(...)
417 Reference<XNamed> xName(rSection, UNO_QUERY);
418 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xName->getName());
420 // get XPropertySet for other values
421 Reference<XPropertySet> xPropSet(rSection, UNO_QUERY);
422 Any aAny;
424 // condition and display
425 aAny = xPropSet->getPropertyValue(sCondition);
426 OUString sCond;
427 aAny >>= sCond;
428 enum XMLTokenEnum eDisplay = XML_TOKEN_INVALID;
429 if (!sCond.isEmpty())
431 OUString sQValue =
432 GetExport().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOOW,
433 sCond, false );
434 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_CONDITION, sQValue);
435 eDisplay = XML_CONDITION;
437 // #97450# store hidden-status (of conditional sections only)
438 aAny = xPropSet->getPropertyValue(sIsCurrentlyVisible);
439 if (! *static_cast<sal_Bool const *>(aAny.getValue()))
441 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_IS_HIDDEN,
442 XML_TRUE);
445 else
447 eDisplay = XML_NONE;
449 aAny = xPropSet->getPropertyValue(sIsVisible);
450 if (! *static_cast<sal_Bool const *>(aAny.getValue()))
452 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_DISPLAY, eDisplay);
455 // protect + protection key
456 aAny = xPropSet->getPropertyValue(sIsProtected);
457 if (*static_cast<sal_Bool const *>(aAny.getValue()))
459 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTED, XML_TRUE);
461 Sequence<sal_Int8> aPassword;
462 xPropSet->getPropertyValue(sProtectionKey) >>= aPassword;
463 if (aPassword.getLength() > 0)
465 OUStringBuffer aBuffer;
466 ::sax::Converter::encodeBase64(aBuffer, aPassword);
467 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTION_KEY,
468 aBuffer.makeStringAndClear());
471 // export element
472 GetExport().IgnorableWhitespace();
473 GetExport().StartElement( XML_NAMESPACE_TEXT, XML_SECTION, true );
475 // data source
476 // unfortunately, we have to test all relevant strings for non-zero length
477 aAny = xPropSet->getPropertyValue(sFileLink);
478 SectionFileLink aFileLink;
479 aAny >>= aFileLink;
481 aAny = xPropSet->getPropertyValue(sLinkRegion);
482 OUString sRegionName;
483 aAny >>= sRegionName;
485 if ( !aFileLink.FileURL.isEmpty() ||
486 !aFileLink.FilterName.isEmpty() ||
487 !sRegionName.isEmpty())
489 if (!aFileLink.FileURL.isEmpty())
491 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF,
492 GetExport().GetRelativeReference( aFileLink.FileURL) );
495 if (!aFileLink.FilterName.isEmpty())
497 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_FILTER_NAME,
498 aFileLink.FilterName);
501 if (!sRegionName.isEmpty())
503 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_SECTION_NAME,
504 sRegionName);
507 SvXMLElementExport aElem(GetExport(),
508 XML_NAMESPACE_TEXT, XML_SECTION_SOURCE,
509 true, true);
511 else
513 // check for DDE first
514 if (xPropSet->getPropertySetInfo()->hasPropertyByName(sDdeCommandFile))
516 // data source DDE
517 // unfortunately, we have to test all relevant strings for
518 // non-zero length
519 aAny = xPropSet->getPropertyValue(sDdeCommandFile);
520 OUString sApplication;
521 aAny >>= sApplication;
522 aAny = xPropSet->getPropertyValue(sDdeCommandType);
523 OUString sTopic;
524 aAny >>= sTopic;
525 aAny = xPropSet->getPropertyValue(sDdeCommandElement);
526 OUString sItem;
527 aAny >>= sItem;
529 if ( !sApplication.isEmpty() ||
530 !sTopic.isEmpty() ||
531 !sItem.isEmpty())
533 GetExport().AddAttribute(XML_NAMESPACE_OFFICE,
534 XML_DDE_APPLICATION, sApplication);
535 GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_DDE_TOPIC,
536 sTopic);
537 GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_DDE_ITEM,
538 sItem);
540 aAny = xPropSet->getPropertyValue(sIsAutomaticUpdate);
541 if (*static_cast<sal_Bool const *>(aAny.getValue()))
543 GetExport().AddAttribute(XML_NAMESPACE_OFFICE,
544 XML_AUTOMATIC_UPDATE, XML_TRUE);
547 SvXMLElementExport aElem(GetExport(),
548 XML_NAMESPACE_OFFICE,
549 XML_DDE_SOURCE, true, true);
551 // else: no DDE data source
553 // else: no DDE on this system
557 void XMLSectionExport::ExportTableOfContentStart(
558 const Reference<XPropertySet> & rPropertySet)
560 // export TOC element start
561 ExportBaseIndexStart(XML_TABLE_OF_CONTENT, rPropertySet);
563 // scope for table-of-content-source element
565 // TOC specific index source attributes:
567 // outline-level: 1..10
568 sal_Int16 nLevel = sal_Int16();
569 if( rPropertySet->getPropertyValue(sLevel) >>= nLevel )
571 OUStringBuffer sBuffer;
572 ::sax::Converter::convertNumber(sBuffer, (sal_Int32)nLevel);
573 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
574 XML_OUTLINE_LEVEL,
575 sBuffer.makeStringAndClear());
578 // use outline level
579 ExportBoolean(rPropertySet, sCreateFromOutline,
580 XML_USE_OUTLINE_LEVEL, true);
582 // use index marks
583 ExportBoolean(rPropertySet, sCreateFromMarks,
584 XML_USE_INDEX_MARKS, true);
586 // use level styles
587 ExportBoolean(rPropertySet, sCreateFromLevelParagraphStyles,
588 XML_USE_INDEX_SOURCE_STYLES, false);
590 ExportBaseIndexSource(TEXT_SECTION_TYPE_TOC, rPropertySet);
593 ExportBaseIndexBody(TEXT_SECTION_TYPE_TOC, rPropertySet);
596 void XMLSectionExport::ExportObjectIndexStart(
597 const Reference<XPropertySet> & rPropertySet)
599 // export index start
600 ExportBaseIndexStart(XML_OBJECT_INDEX, rPropertySet);
602 // scope for index source element
604 ExportBoolean(rPropertySet, sCreateFromOtherEmbeddedObjects,
605 XML_USE_OTHER_OBJECTS, false);
606 ExportBoolean(rPropertySet, sCreateFromStarCalc,
607 XML_USE_SPREADSHEET_OBJECTS, false);
608 ExportBoolean(rPropertySet, sCreateFromStarChart,
609 XML_USE_CHART_OBJECTS, false);
610 ExportBoolean(rPropertySet, sCreateFromStarDraw,
611 XML_USE_DRAW_OBJECTS, false);
612 ExportBoolean(rPropertySet, sCreateFromStarMath,
613 XML_USE_MATH_OBJECTS, false);
615 ExportBaseIndexSource(TEXT_SECTION_TYPE_OBJECT, rPropertySet);
618 ExportBaseIndexBody(TEXT_SECTION_TYPE_OBJECT, rPropertySet);
621 void XMLSectionExport::ExportIllustrationIndexStart(
622 const Reference<XPropertySet> & rPropertySet)
624 // export index start
625 ExportBaseIndexStart(XML_ILLUSTRATION_INDEX, rPropertySet);
627 // scope for index source element
629 // export common attributes for illustration and table indices
630 ExportTableAndIllustrationIndexSourceAttributes(rPropertySet);
632 ExportBaseIndexSource(TEXT_SECTION_TYPE_ILLUSTRATION, rPropertySet);
635 ExportBaseIndexBody(TEXT_SECTION_TYPE_ILLUSTRATION, rPropertySet);
638 void XMLSectionExport::ExportTableIndexStart(
639 const Reference<XPropertySet> & rPropertySet)
641 // export index start
642 ExportBaseIndexStart(XML_TABLE_INDEX, rPropertySet);
644 // scope for index source element
646 // export common attributes for illustration and table indices
647 ExportTableAndIllustrationIndexSourceAttributes(rPropertySet);
649 ExportBaseIndexSource(TEXT_SECTION_TYPE_TABLE, rPropertySet);
652 ExportBaseIndexBody(TEXT_SECTION_TYPE_TABLE, rPropertySet);
655 void XMLSectionExport::ExportAlphabeticalIndexStart(
656 const Reference<XPropertySet> & rPropertySet)
658 // export TOC element start
659 ExportBaseIndexStart(XML_ALPHABETICAL_INDEX, rPropertySet);
661 // scope for table-of-content-source element
664 // style name (if present)
665 Any aAny;
666 aAny = rPropertySet->getPropertyValue(sMainEntryCharacterStyleName);
667 OUString sStyleName;
668 aAny >>= sStyleName;
669 if (!sStyleName.isEmpty())
671 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
672 XML_MAIN_ENTRY_STYLE_NAME,
673 GetExport().EncodeStyleName( sStyleName ));
676 // other (boolean) attributes
677 ExportBoolean(rPropertySet, sIsCaseSensitive, XML_IGNORE_CASE,
678 false, true);
679 ExportBoolean(rPropertySet, sUseAlphabeticalSeparators,
680 XML_ALPHABETICAL_SEPARATORS, false);
681 ExportBoolean(rPropertySet, sUseCombinedEntries, XML_COMBINE_ENTRIES,
682 true);
683 ExportBoolean(rPropertySet, sUseDash, XML_COMBINE_ENTRIES_WITH_DASH,
684 false);
685 ExportBoolean(rPropertySet, sUseKeyAsEntry, XML_USE_KEYS_AS_ENTRIES,
686 false);
687 ExportBoolean(rPropertySet, sUsePP, XML_COMBINE_ENTRIES_WITH_PP,
688 true);
689 ExportBoolean(rPropertySet, sUseUpperCase, XML_CAPITALIZE_ENTRIES,
690 false);
691 ExportBoolean(rPropertySet, sIsCommaSeparated, XML_COMMA_SEPARATED,
692 false);
694 // sort algorithm
695 aAny = rPropertySet->getPropertyValue(sSortAlgorithm);
696 OUString sAlgorithm;
697 aAny >>= sAlgorithm;
698 if (!sAlgorithm.isEmpty())
700 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_SORT_ALGORITHM,
701 sAlgorithm );
704 // locale
705 aAny = rPropertySet->getPropertyValue(sLocale);
706 Locale aLocale;
707 aAny >>= aLocale;
708 GetExport().AddLanguageTagAttributes( XML_NAMESPACE_FO, XML_NAMESPACE_STYLE, aLocale, true);
710 ExportBaseIndexSource(TEXT_SECTION_TYPE_ALPHABETICAL, rPropertySet);
713 ExportBaseIndexBody(TEXT_SECTION_TYPE_ALPHABETICAL, rPropertySet);
716 void XMLSectionExport::ExportUserIndexStart(
717 const Reference<XPropertySet> & rPropertySet)
719 // export TOC element start
720 ExportBaseIndexStart(XML_USER_INDEX, rPropertySet);
722 // scope for table-of-content-source element
724 // bool attributes
725 ExportBoolean(rPropertySet, sCreateFromEmbeddedObjects,
726 XML_USE_OBJECTS, false);
727 ExportBoolean(rPropertySet, sCreateFromGraphicObjects,
728 XML_USE_GRAPHICS, false);
729 ExportBoolean(rPropertySet, sCreateFromMarks,
730 XML_USE_INDEX_MARKS, false);
731 ExportBoolean(rPropertySet, sCreateFromTables,
732 XML_USE_TABLES, false);
733 ExportBoolean(rPropertySet, sCreateFromTextFrames,
734 XML_USE_FLOATING_FRAMES, false);
735 ExportBoolean(rPropertySet, sUseLevelFromSource,
736 XML_COPY_OUTLINE_LEVELS, false);
737 ExportBoolean(rPropertySet, sCreateFromLevelParagraphStyles,
738 XML_USE_INDEX_SOURCE_STYLES, false);
740 Any aAny = rPropertySet->getPropertyValue( sUserIndexName );
741 OUString sIndexName;
742 aAny >>= sIndexName;
743 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_INDEX_NAME,
744 sIndexName);
746 ExportBaseIndexSource(TEXT_SECTION_TYPE_USER, rPropertySet);
749 ExportBaseIndexBody(TEXT_SECTION_TYPE_USER, rPropertySet);
752 void XMLSectionExport::ExportBibliographyStart(
753 const Reference<XPropertySet> & rPropertySet)
755 // export TOC element start
756 ExportBaseIndexStart(XML_BIBLIOGRAPHY, rPropertySet);
758 // scope for table-of-content-source element
760 // No attributes. Fine.
762 ExportBaseIndexSource(TEXT_SECTION_TYPE_BIBLIOGRAPHY, rPropertySet);
765 ExportBaseIndexBody(TEXT_SECTION_TYPE_BIBLIOGRAPHY, rPropertySet);
769 void XMLSectionExport::ExportBaseIndexStart(
770 XMLTokenEnum eElement,
771 const Reference<XPropertySet> & rPropertySet)
773 // protect + protection key
774 Any aAny = rPropertySet->getPropertyValue(sIsProtected);
775 if (*static_cast<sal_Bool const *>(aAny.getValue()))
777 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTED, XML_TRUE);
780 // index name
781 OUString sIndexName;
782 rPropertySet->getPropertyValue(sName) >>= sIndexName;
783 if ( !sIndexName.isEmpty() )
785 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, sIndexName);
788 // index Element start
789 GetExport().IgnorableWhitespace();
790 GetExport().StartElement( XML_NAMESPACE_TEXT, eElement, false );
793 static const XMLTokenEnum aTypeSourceElementNameMap[] =
795 XML_TABLE_OF_CONTENT_SOURCE, // TOC
796 XML_TABLE_INDEX_SOURCE, // table index
797 XML_ILLUSTRATION_INDEX_SOURCE, // illustration index
798 XML_OBJECT_INDEX_SOURCE, // object index
799 XML_USER_INDEX_SOURCE, // user index
800 XML_ALPHABETICAL_INDEX_SOURCE, // alphabetical index
801 XML_BIBLIOGRAPHY_SOURCE // bibliography
804 void XMLSectionExport::ExportBaseIndexSource(
805 SectionTypeEnum eType,
806 const Reference<XPropertySet> & rPropertySet)
808 // check type
809 OSL_ENSURE(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type");
810 OSL_ENSURE(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type");
812 Any aAny;
814 // common attributes; not supported by bibliography
815 if (eType != TEXT_SECTION_TYPE_BIBLIOGRAPHY)
817 // document or chapter index?
818 aAny = rPropertySet->getPropertyValue(sCreateFromChapter);
819 if (*static_cast<sal_Bool const *>(aAny.getValue()))
821 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
822 XML_INDEX_SCOPE, XML_CHAPTER);
825 // tab-stops relative to margin?
826 aAny = rPropertySet->getPropertyValue(sIsRelativeTabstops);
827 if (! *static_cast<sal_Bool const *>(aAny.getValue()))
829 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
830 XML_RELATIVE_TAB_STOP_POSITION,
831 XML_FALSE);
835 // the index source element (all indices)
836 SvXMLElementExport aElem(GetExport(),
837 XML_NAMESPACE_TEXT,
838 GetXMLToken(
839 aTypeSourceElementNameMap[
840 eType - TEXT_SECTION_TYPE_TOC]),
841 true, true);
843 // scope for title template (all indices)
845 // header style name
846 aAny = rPropertySet->getPropertyValue(sParaStyleHeading);
847 OUString sStyleName;
848 aAny >>= sStyleName;
849 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
850 XML_STYLE_NAME,
851 GetExport().EncodeStyleName( sStyleName ));
853 // title template
854 SvXMLElementExport aHeaderTemplate(GetExport(),
855 XML_NAMESPACE_TEXT,
856 XML_INDEX_TITLE_TEMPLATE,
857 true, false);
859 // title as element content
860 aAny = rPropertySet->getPropertyValue(sTitle);
861 OUString sTitleString;
862 aAny >>= sTitleString;
863 GetExport().Characters(sTitleString);
866 // export level templates (all indices)
867 aAny = rPropertySet->getPropertyValue(sLevelFormat);
868 Reference<XIndexReplace> xLevelTemplates;
869 aAny >>= xLevelTemplates;
871 // iterate over level formats;
872 // skip element 0 (empty template for title)
873 sal_Int32 nLevelCount = xLevelTemplates->getCount();
874 for(sal_Int32 i = 1; i<nLevelCount; i++)
876 // get sequence
877 Sequence<PropertyValues> aTemplateSequence;
878 aAny = xLevelTemplates->getByIndex(i);
879 aAny >>= aTemplateSequence;
881 // export the sequence (abort export if an error occurred; #91214#)
882 bool bResult =
883 ExportIndexTemplate(eType, i, rPropertySet, aTemplateSequence);
884 if ( !bResult )
885 break;
888 // only TOC and user index:
889 // styles from which to build the index (LevelParagraphStyles)
890 if ( (TEXT_SECTION_TYPE_TOC == eType) ||
891 (TEXT_SECTION_TYPE_USER == eType) )
893 aAny = rPropertySet->getPropertyValue(sLevelParagraphStyles);
894 Reference<XIndexReplace> xLevelParagraphStyles;
895 aAny >>= xLevelParagraphStyles;
896 ExportLevelParagraphStyles(xLevelParagraphStyles);
901 void XMLSectionExport::ExportBaseIndexBody(
902 SectionTypeEnum
903 #if OSL_DEBUG_LEVEL > 0
904 eType
905 #endif
907 const Reference<XPropertySet> &)
909 // type not used; checked anyway.
910 OSL_ENSURE(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type");
911 OSL_ENSURE(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type");
913 // export start only
915 // any old attributes?
916 GetExport().CheckAttrList();
918 // start surrounded by whitespace
919 GetExport().IgnorableWhitespace();
920 GetExport().StartElement( XML_NAMESPACE_TEXT, XML_INDEX_BODY, true );
923 void XMLSectionExport::ExportTableAndIllustrationIndexSourceAttributes(
924 const Reference<XPropertySet> & rPropertySet)
926 // use caption
927 Any aAny = rPropertySet->getPropertyValue(sCreateFromLabels);
928 if (! *static_cast<sal_Bool const *>(aAny.getValue()))
930 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
931 XML_USE_CAPTION, XML_FALSE);
934 // sequence name
935 aAny = rPropertySet->getPropertyValue(sLabelCategory);
936 OUString sSequenceName;
937 aAny >>= sSequenceName;
938 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
939 XML_CAPTION_SEQUENCE_NAME,
940 sSequenceName);
942 // caption format
943 aAny = rPropertySet->getPropertyValue(sLabelDisplayType);
944 sal_Int16 nType = 0;
945 aAny >>= nType;
946 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
947 XML_CAPTION_SEQUENCE_FORMAT,
948 XMLTextFieldExport::MapReferenceType(nType));
952 // map index of LevelFormats to attribute value;
953 // level 0 is always the header
954 static const XMLTokenEnum aLevelNameTOCMap[] =
955 { XML_TOKEN_INVALID, XML_1, XML_2, XML_3, XML_4, XML_5, XML_6, XML_7,
956 XML_8, XML_9, XML_10, XML_TOKEN_INVALID };
957 static const XMLTokenEnum aLevelNameTableMap[] =
958 { XML_TOKEN_INVALID, XML__EMPTY, XML_TOKEN_INVALID };
959 static const XMLTokenEnum aLevelNameAlphaMap[] =
960 { XML_TOKEN_INVALID, XML_SEPARATOR, XML_1, XML_2, XML_3, XML_TOKEN_INVALID };
961 static const XMLTokenEnum aLevelNameBibliographyMap[] =
962 { XML_TOKEN_INVALID, XML_ARTICLE, XML_BOOK, XML_BOOKLET, XML_CONFERENCE,
963 XML_CUSTOM1, XML_CUSTOM2, XML_CUSTOM3, XML_CUSTOM4,
964 XML_CUSTOM5, XML_EMAIL, XML_INBOOK, XML_INCOLLECTION,
965 XML_INPROCEEDINGS, XML_JOURNAL,
966 XML_MANUAL, XML_MASTERSTHESIS, XML_MISC, XML_PHDTHESIS,
967 XML_PROCEEDINGS, XML_TECHREPORT, XML_UNPUBLISHED, XML_WWW,
968 XML_TOKEN_INVALID };
970 static const XMLTokenEnum* aTypeLevelNameMap[] =
972 aLevelNameTOCMap, // TOC
973 aLevelNameTableMap, // table index
974 aLevelNameTableMap, // illustration index
975 aLevelNameTableMap, // object index
976 aLevelNameTOCMap, // user index
977 aLevelNameAlphaMap, // alphabetical index
978 aLevelNameBibliographyMap // bibliography
981 static const sal_Char* aLevelStylePropNameTOCMap[] =
982 { NULL, "ParaStyleLevel1", "ParaStyleLevel2", "ParaStyleLevel3",
983 "ParaStyleLevel4", "ParaStyleLevel5", "ParaStyleLevel6",
984 "ParaStyleLevel7", "ParaStyleLevel8", "ParaStyleLevel9",
985 "ParaStyleLevel10", NULL };
986 static const sal_Char* aLevelStylePropNameTableMap[] =
987 { NULL, "ParaStyleLevel1", NULL };
988 static const sal_Char* aLevelStylePropNameAlphaMap[] =
989 { NULL, "ParaStyleSeparator", "ParaStyleLevel1", "ParaStyleLevel2",
990 "ParaStyleLevel3", NULL };
991 static const sal_Char* aLevelStylePropNameBibliographyMap[] =
992 // TODO: replace with real property names, when available
993 { NULL, "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
994 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
995 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
996 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
997 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
998 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
999 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1000 "ParaStyleLevel1",
1001 NULL };
1003 static const sal_Char** aTypeLevelStylePropNameMap[] =
1005 aLevelStylePropNameTOCMap, // TOC
1006 aLevelStylePropNameTableMap, // table index
1007 aLevelStylePropNameTableMap, // illustration index
1008 aLevelStylePropNameTableMap, // object index
1009 aLevelStylePropNameTOCMap, // user index
1010 aLevelStylePropNameAlphaMap, // alphabetical index
1011 aLevelStylePropNameBibliographyMap // bibliography
1014 static const XMLTokenEnum aTypeLevelAttrMap[] =
1016 XML_OUTLINE_LEVEL, // TOC
1017 XML_TOKEN_INVALID, // table index
1018 XML_TOKEN_INVALID, // illustration index
1019 XML_TOKEN_INVALID, // object index
1020 XML_OUTLINE_LEVEL, // user index
1021 XML_OUTLINE_LEVEL, // alphabetical index
1022 XML_BIBLIOGRAPHY_TYPE // bibliography
1025 static const XMLTokenEnum aTypeElementNameMap[] =
1027 XML_TABLE_OF_CONTENT_ENTRY_TEMPLATE, // TOC
1028 XML_TABLE_INDEX_ENTRY_TEMPLATE, // table index
1029 XML_ILLUSTRATION_INDEX_ENTRY_TEMPLATE, // illustration index
1030 XML_OBJECT_INDEX_ENTRY_TEMPLATE, // object index
1031 XML_USER_INDEX_ENTRY_TEMPLATE, // user index
1032 XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE, // alphabetical index
1033 XML_BIBLIOGRAPHY_ENTRY_TEMPLATE // bibliography
1037 bool XMLSectionExport::ExportIndexTemplate(
1038 SectionTypeEnum eType,
1039 sal_Int32 nOutlineLevel,
1040 const Reference<XPropertySet> & rPropertySet,
1041 Sequence<Sequence<PropertyValue> > & rValues)
1043 OSL_ENSURE(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type");
1044 OSL_ENSURE(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type");
1045 OSL_ENSURE(nOutlineLevel >= 0, "illegal outline level");
1047 if ( (eType >= TEXT_SECTION_TYPE_TOC) &&
1048 (eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY) &&
1049 (nOutlineLevel >= 0) )
1051 // get level name and level attribute name from aLevelNameMap;
1052 const XMLTokenEnum eLevelAttrName(
1053 aTypeLevelAttrMap[eType-TEXT_SECTION_TYPE_TOC]);
1054 const XMLTokenEnum eLevelName(
1055 aTypeLevelNameMap[eType-TEXT_SECTION_TYPE_TOC][nOutlineLevel]);
1057 // #92124#: some old documents may be broken, then they have
1058 // too many template levels; we need to recognize this and
1059 // export only as many as is legal for the respective index
1060 // type. To do this, we simply return an error flag, which
1061 // will then abort further template level exports.
1062 OSL_ENSURE(XML_TOKEN_INVALID != eLevelName, "can't find level name");
1063 if ( XML_TOKEN_INVALID == eLevelName )
1065 // output level not found? Then end of templates! #91214#
1066 return false;
1069 // output level name
1070 if ((XML_TOKEN_INVALID != eLevelName) && (XML_TOKEN_INVALID != eLevelAttrName))
1072 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1073 GetXMLToken(eLevelAttrName),
1074 GetXMLToken(eLevelName));
1077 // paragraph level style name
1078 const sal_Char* pPropName(
1079 aTypeLevelStylePropNameMap[eType-TEXT_SECTION_TYPE_TOC][nOutlineLevel]);
1080 OSL_ENSURE(NULL != pPropName, "can't find property name");
1081 if (NULL != pPropName)
1083 Any aAny = rPropertySet->getPropertyValue(
1084 OUString::createFromAscii(pPropName));
1085 OUString sParaStyleName;
1086 aAny >>= sParaStyleName;
1087 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1088 XML_STYLE_NAME,
1089 GetExport().EncodeStyleName( sParaStyleName ));
1092 // template element
1093 const XMLTokenEnum eElementName(
1094 aTypeElementNameMap[eType - TEXT_SECTION_TYPE_TOC]);
1095 SvXMLElementExport aLevelTemplate(GetExport(),
1096 XML_NAMESPACE_TEXT,
1097 GetXMLToken(eElementName),
1098 true, true);
1100 // export sequence
1101 sal_Int32 nTemplateCount = rValues.getLength();
1102 for(sal_Int32 nTemplateNo = 0;
1103 nTemplateNo < nTemplateCount;
1104 nTemplateNo++)
1106 ExportIndexTemplateElement(
1107 eType, //i90246
1108 rValues[nTemplateNo]);
1112 return true;
1116 enum TemplateTypeEnum
1118 TOK_TTYPE_ENTRY_NUMBER,
1119 TOK_TTYPE_ENTRY_TEXT,
1120 TOK_TTYPE_TAB_STOP,
1121 TOK_TTYPE_TEXT,
1122 TOK_TTYPE_PAGE_NUMBER,
1123 TOK_TTYPE_CHAPTER_INFO,
1124 TOK_TTYPE_HYPERLINK_START,
1125 TOK_TTYPE_HYPERLINK_END,
1126 TOK_TTYPE_BIBLIOGRAPHY,
1127 TOK_TTYPE_INVALID
1130 enum TemplateParamEnum
1132 TOK_TPARAM_TOKEN_TYPE,
1133 TOK_TPARAM_CHAR_STYLE,
1134 TOK_TPARAM_TAB_RIGHT_ALIGNED,
1135 TOK_TPARAM_TAB_POSITION,
1136 TOK_TPARAM_TAB_WITH_TAB, // #i21237#
1137 TOK_TPARAM_TAB_FILL_CHAR,
1138 TOK_TPARAM_TEXT,
1139 TOK_TPARAM_CHAPTER_FORMAT,
1140 TOK_TPARAM_CHAPTER_LEVEL,//i53420
1141 TOK_TPARAM_BIBLIOGRAPHY_DATA
1144 SvXMLEnumStringMapEntry const aTemplateTypeMap[] =
1146 ENUM_STRING_MAP_ENTRY( "TokenEntryNumber", TOK_TTYPE_ENTRY_NUMBER ),
1147 ENUM_STRING_MAP_ENTRY( "TokenEntryText", TOK_TTYPE_ENTRY_TEXT ),
1148 ENUM_STRING_MAP_ENTRY( "TokenTabStop", TOK_TTYPE_TAB_STOP ),
1149 ENUM_STRING_MAP_ENTRY( "TokenText", TOK_TTYPE_TEXT ),
1150 ENUM_STRING_MAP_ENTRY( "TokenPageNumber", TOK_TTYPE_PAGE_NUMBER ),
1151 ENUM_STRING_MAP_ENTRY( "TokenChapterInfo", TOK_TTYPE_CHAPTER_INFO ),
1152 ENUM_STRING_MAP_ENTRY( "TokenHyperlinkStart", TOK_TTYPE_HYPERLINK_START ),
1153 ENUM_STRING_MAP_ENTRY( "TokenHyperlinkEnd", TOK_TTYPE_HYPERLINK_END ),
1154 ENUM_STRING_MAP_ENTRY( "TokenBibliographyDataField", TOK_TTYPE_BIBLIOGRAPHY ),
1155 ENUM_STRING_MAP_END()
1158 SvXMLEnumStringMapEntry const aTemplateParamMap[] =
1160 ENUM_STRING_MAP_ENTRY( "TokenType", TOK_TPARAM_TOKEN_TYPE ),
1161 ENUM_STRING_MAP_ENTRY( "CharacterStyleName", TOK_TPARAM_CHAR_STYLE ),
1162 ENUM_STRING_MAP_ENTRY( "TabStopRightAligned", TOK_TPARAM_TAB_RIGHT_ALIGNED ),
1163 ENUM_STRING_MAP_ENTRY( "TabStopPosition", TOK_TPARAM_TAB_POSITION ),
1164 ENUM_STRING_MAP_ENTRY( "TabStopFillCharacter", TOK_TPARAM_TAB_FILL_CHAR ),
1165 // #i21237#
1166 ENUM_STRING_MAP_ENTRY( "WithTab", TOK_TPARAM_TAB_WITH_TAB ),
1167 ENUM_STRING_MAP_ENTRY( "Text", TOK_TPARAM_TEXT ),
1168 ENUM_STRING_MAP_ENTRY( "ChapterFormat", TOK_TPARAM_CHAPTER_FORMAT ),
1169 ENUM_STRING_MAP_ENTRY( "ChapterLevel", TOK_TPARAM_CHAPTER_LEVEL ),//i53420
1170 ENUM_STRING_MAP_ENTRY( "BibliographyDataField", TOK_TPARAM_BIBLIOGRAPHY_DATA ),
1171 ENUM_STRING_MAP_END()
1174 SvXMLEnumMapEntry const aBibliographyDataFieldMap[] =
1176 { XML_ADDRESS, BibliographyDataField::ADDRESS },
1177 { XML_ANNOTE, BibliographyDataField::ANNOTE },
1178 { XML_AUTHOR, BibliographyDataField::AUTHOR },
1179 { XML_BIBLIOGRAPHY_TYPE, BibliographyDataField::BIBILIOGRAPHIC_TYPE },
1180 { XML_BOOKTITLE, BibliographyDataField::BOOKTITLE },
1181 { XML_CHAPTER, BibliographyDataField::CHAPTER },
1182 { XML_CUSTOM1, BibliographyDataField::CUSTOM1 },
1183 { XML_CUSTOM2, BibliographyDataField::CUSTOM2 },
1184 { XML_CUSTOM3, BibliographyDataField::CUSTOM3 },
1185 { XML_CUSTOM4, BibliographyDataField::CUSTOM4 },
1186 { XML_CUSTOM5, BibliographyDataField::CUSTOM5 },
1187 { XML_EDITION, BibliographyDataField::EDITION },
1188 { XML_EDITOR, BibliographyDataField::EDITOR },
1189 { XML_HOWPUBLISHED, BibliographyDataField::HOWPUBLISHED },
1190 { XML_IDENTIFIER, BibliographyDataField::IDENTIFIER },
1191 { XML_INSTITUTION, BibliographyDataField::INSTITUTION },
1192 { XML_ISBN, BibliographyDataField::ISBN },
1193 { XML_JOURNAL, BibliographyDataField::JOURNAL },
1194 { XML_MONTH, BibliographyDataField::MONTH },
1195 { XML_NOTE, BibliographyDataField::NOTE },
1196 { XML_NUMBER, BibliographyDataField::NUMBER },
1197 { XML_ORGANIZATIONS, BibliographyDataField::ORGANIZATIONS },
1198 { XML_PAGES, BibliographyDataField::PAGES },
1199 { XML_PUBLISHER, BibliographyDataField::PUBLISHER },
1200 { XML_REPORT_TYPE, BibliographyDataField::REPORT_TYPE },
1201 { XML_SCHOOL, BibliographyDataField::SCHOOL },
1202 { XML_SERIES, BibliographyDataField::SERIES },
1203 { XML_TITLE, BibliographyDataField::TITLE },
1204 { XML_URL, BibliographyDataField::URL },
1205 { XML_VOLUME, BibliographyDataField::VOLUME },
1206 { XML_YEAR, BibliographyDataField::YEAR },
1207 { XML_TOKEN_INVALID, 0 }
1210 void XMLSectionExport::ExportIndexTemplateElement(
1211 SectionTypeEnum eType, //i90246
1212 Sequence<PropertyValue> & rValues)
1214 // variables for template values
1216 // char style
1217 OUString sCharStyle;
1218 bool bCharStyleOK = false;
1220 // text
1221 OUString sText;
1222 bool bTextOK = false;
1224 // tab position
1225 bool bRightAligned = false;
1227 // tab position
1228 sal_Int32 nTabPosition = 0;
1229 bool bTabPositionOK = false;
1231 // fill character
1232 OUString sFillChar;
1233 bool bFillCharOK = false;
1235 // chapter format
1236 sal_Int16 nChapterFormat = 0;
1237 bool bChapterFormatOK = false;
1239 // outline max level
1240 sal_Int16 nLevel = 0;
1241 bool bLevelOK = false;
1243 // Bibliography Data
1244 sal_Int16 nBibliographyData = 0;
1245 bool bBibliographyDataOK = false;
1247 // With Tab Stop #i21237#
1248 bool bWithTabStop = false;
1249 bool bWithTabStopOK = false;
1251 //i90246, the ODF version being written to is:
1252 const SvtSaveOptions::ODFDefaultVersion aODFVersion = rExport.getDefaultVersion();
1253 //the above version cannot be used for old OOo (OOo 1.0) formats!
1255 // token type
1256 enum TemplateTypeEnum nTokenType = TOK_TTYPE_INVALID;
1258 sal_Int32 nCount = rValues.getLength();
1259 for(sal_Int32 i = 0; i<nCount; i++)
1261 sal_uInt16 nToken;
1262 if ( SvXMLUnitConverter::convertEnum( nToken, rValues[i].Name,
1263 aTemplateParamMap ) )
1265 // Only use direct and default values.
1266 // Wrong. no property states, so ignore.
1267 // if ( (beans::PropertyState_DIRECT_VALUE == rValues[i].State) ||
1268 // (beans::PropertyState_DEFAULT_VALUE == rValues[i].State) )
1270 switch (nToken)
1272 case TOK_TPARAM_TOKEN_TYPE:
1274 sal_uInt16 nTmp;
1275 OUString sVal;
1276 rValues[i].Value >>= sVal;
1277 if (SvXMLUnitConverter::convertEnum( nTmp, sVal,
1278 aTemplateTypeMap))
1280 nTokenType = (enum TemplateTypeEnum)nTmp;
1282 break;
1285 case TOK_TPARAM_CHAR_STYLE:
1286 // only valid, if not empty
1287 rValues[i].Value >>= sCharStyle;
1288 bCharStyleOK = !sCharStyle.isEmpty();
1289 break;
1291 case TOK_TPARAM_TEXT:
1292 rValues[i].Value >>= sText;
1293 bTextOK = true;
1294 break;
1296 case TOK_TPARAM_TAB_RIGHT_ALIGNED:
1297 bRightAligned =
1298 *static_cast<sal_Bool const *>(rValues[i].Value.getValue());
1299 break;
1301 case TOK_TPARAM_TAB_POSITION:
1302 rValues[i].Value >>= nTabPosition;
1303 bTabPositionOK = true;
1304 break;
1306 // #i21237#
1307 case TOK_TPARAM_TAB_WITH_TAB:
1308 bWithTabStop = *static_cast<sal_Bool const *>(rValues[i].Value.getValue());
1309 bWithTabStopOK = true;
1310 break;
1312 case TOK_TPARAM_TAB_FILL_CHAR:
1313 rValues[i].Value >>= sFillChar;
1314 bFillCharOK = true;
1315 break;
1317 case TOK_TPARAM_CHAPTER_FORMAT:
1318 rValues[i].Value >>= nChapterFormat;
1319 bChapterFormatOK = true;
1320 break;
1321 //---> i53420
1322 case TOK_TPARAM_CHAPTER_LEVEL:
1323 rValues[i].Value >>= nLevel;
1324 bLevelOK = true;
1325 break;
1326 case TOK_TPARAM_BIBLIOGRAPHY_DATA:
1327 rValues[i].Value >>= nBibliographyData;
1328 bBibliographyDataOK = true;
1329 break;
1334 // convert type to token (and check validity) ...
1335 XMLTokenEnum eElement(XML_TOKEN_INVALID);
1336 switch(nTokenType)
1338 case TOK_TTYPE_ENTRY_TEXT:
1339 eElement = XML_INDEX_ENTRY_TEXT;
1340 break;
1341 case TOK_TTYPE_TAB_STOP:
1342 // test validity
1343 if ( bRightAligned || bTabPositionOK || bFillCharOK )
1345 eElement = XML_INDEX_ENTRY_TAB_STOP;
1347 break;
1348 case TOK_TTYPE_TEXT:
1349 // test validity
1350 if (bTextOK)
1352 eElement = XML_INDEX_ENTRY_SPAN;
1354 break;
1355 case TOK_TTYPE_PAGE_NUMBER:
1356 eElement = XML_INDEX_ENTRY_PAGE_NUMBER;
1357 break;
1358 case TOK_TTYPE_CHAPTER_INFO: // keyword index
1359 eElement = XML_INDEX_ENTRY_CHAPTER;
1360 break;
1361 case TOK_TTYPE_ENTRY_NUMBER: // table of content
1362 eElement = XML_INDEX_ENTRY_CHAPTER;
1363 break;
1364 case TOK_TTYPE_HYPERLINK_START:
1365 eElement = XML_INDEX_ENTRY_LINK_START;
1366 break;
1367 case TOK_TTYPE_HYPERLINK_END:
1368 eElement = XML_INDEX_ENTRY_LINK_END;
1369 break;
1370 case TOK_TTYPE_BIBLIOGRAPHY:
1371 if (bBibliographyDataOK)
1373 eElement = XML_INDEX_ENTRY_BIBLIOGRAPHY;
1375 break;
1376 default:
1377 ; // unknown/unimplemented template
1378 break;
1381 //--->i90246
1382 //check the ODF version being exported
1383 if( aODFVersion == SvtSaveOptions::ODFVER_011
1384 || aODFVersion == SvtSaveOptions::ODFVER_010)
1386 bLevelOK = false;
1387 if (TOK_TTYPE_CHAPTER_INFO == nTokenType)
1389 //if we are emitting for ODF 1.1 or 1.0, this information can be used for alphabetical index only
1390 //it's not permitted in other indexes
1391 if (eType != TEXT_SECTION_TYPE_ALPHABETICAL)
1393 eElement = XML_TOKEN_INVALID; //not permitted, invalidate the element
1395 else //maps format for 1.1 & 1.0
1397 // a few word here: OOo up to 2.4 uses the field chapter info in Alphabetical index
1398 // in a way different from the ODF 1.1/1.0 specification:
1400 // ODF1.1/1.0 OOo display in chapter info ODF1.2
1401 // (used in alphabetical index only
1403 // number chapter number without pre/postfix plain-number
1404 // number-and-name chapter number without pre/postfix plus title plain-number-and-name
1406 // with issue i89791 the reading of ODF 1.1 and 1.0 was corrected
1407 // this one corrects the writing back from ODF 1.2 to ODF 1.1/1.0
1408 // unfortunately if there is another application which interprets correctly ODF1.1/1.0,
1409 // the resulting alphabetical index will be rendered wrong by OOo 2.4 version
1411 switch( nChapterFormat )
1413 case ChapterFormat::DIGIT:
1414 nChapterFormat = ChapterFormat::NUMBER;
1415 break;
1416 case ChapterFormat::NO_PREFIX_SUFFIX:
1417 nChapterFormat = ChapterFormat::NAME_NUMBER;
1418 break;
1422 else if (TOK_TTYPE_ENTRY_NUMBER == nTokenType)
1424 //in case of ODF 1.1 or 1.0 the only allowed number format is "number"
1425 //so, force it...
1426 // The only expected 'foreign' nChapterFormat is
1427 // ' ChapterFormat::DIGIT', forced to 'none, since the
1428 // 'value allowed in ODF 1.1 and 1.0 is 'number' the default
1429 // this can be obtained by simply disabling the chapter format
1430 bChapterFormatOK = false;
1434 // ... and write Element
1435 if (eElement != XML_TOKEN_INVALID)
1437 // character style (for most templates)
1438 if (bCharStyleOK)
1440 switch (nTokenType)
1442 case TOK_TTYPE_ENTRY_TEXT:
1443 case TOK_TTYPE_TEXT:
1444 case TOK_TTYPE_PAGE_NUMBER:
1445 case TOK_TTYPE_ENTRY_NUMBER:
1446 case TOK_TTYPE_HYPERLINK_START:
1447 case TOK_TTYPE_HYPERLINK_END:
1448 case TOK_TTYPE_BIBLIOGRAPHY:
1449 case TOK_TTYPE_CHAPTER_INFO:
1450 case TOK_TTYPE_TAB_STOP:
1451 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1452 XML_STYLE_NAME,
1453 GetExport().EncodeStyleName( sCharStyle) );
1454 break;
1455 default:
1456 ; // nothing: no character style
1457 break;
1461 // tab properties
1462 if (TOK_TTYPE_TAB_STOP == nTokenType)
1464 // tab type
1465 GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_TYPE,
1466 bRightAligned ? XML_RIGHT : XML_LEFT);
1468 if (bTabPositionOK && (! bRightAligned))
1470 // position for left tabs (convert to measure)
1471 OUStringBuffer sBuf;
1472 GetExport().GetMM100UnitConverter().convertMeasureToXML(sBuf,
1473 nTabPosition);
1474 GetExport().AddAttribute(XML_NAMESPACE_STYLE,
1475 XML_POSITION,
1476 sBuf.makeStringAndClear());
1479 // fill char ("leader char")
1480 if (bFillCharOK && !sFillChar.isEmpty())
1482 GetExport().AddAttribute(XML_NAMESPACE_STYLE,
1483 XML_LEADER_CHAR, sFillChar);
1486 // #i21237#
1487 if (bWithTabStopOK && ! bWithTabStop)
1489 GetExport().AddAttribute(XML_NAMESPACE_STYLE,
1490 XML_WITH_TAB,
1491 XML_FALSE);
1495 // bibliography data
1496 if (TOK_TTYPE_BIBLIOGRAPHY == nTokenType)
1498 OSL_ENSURE(bBibliographyDataOK, "need bibl data");
1499 OUStringBuffer sBuf;
1500 if (SvXMLUnitConverter::convertEnum( sBuf, nBibliographyData,
1501 aBibliographyDataFieldMap ) )
1503 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1504 XML_BIBLIOGRAPHY_DATA_FIELD,
1505 sBuf.makeStringAndClear());
1509 // chapter info
1510 if (TOK_TTYPE_CHAPTER_INFO == nTokenType)
1512 OSL_ENSURE(bChapterFormatOK, "need chapter info");
1513 GetExport().AddAttribute(
1514 XML_NAMESPACE_TEXT, XML_DISPLAY,
1515 XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat));
1516 //---> i53420
1517 if (bLevelOK)
1518 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,
1519 OUString::number(nLevel));
1522 //--->i53420
1523 if (TOK_TTYPE_ENTRY_NUMBER == nTokenType)
1525 if (bChapterFormatOK)
1526 GetExport().AddAttribute(
1527 XML_NAMESPACE_TEXT, XML_DISPLAY,
1528 XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat));
1530 if (bLevelOK)
1531 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,
1532 OUString::number(nLevel));
1534 // export template
1535 SvXMLElementExport aTemplateElement(GetExport(), XML_NAMESPACE_TEXT,
1536 GetXMLToken(eElement),
1537 true, false)
1540 // entry text or span element: write text
1541 if (TOK_TTYPE_TEXT == nTokenType)
1543 GetExport().Characters(sText);
1548 void XMLSectionExport::ExportLevelParagraphStyles(
1549 Reference<XIndexReplace> & xLevelParagraphStyles)
1551 // iterate over levels
1552 sal_Int32 nPLevelCount = xLevelParagraphStyles->getCount();
1553 for(sal_Int32 nLevel = 0; nLevel < nPLevelCount; nLevel++)
1555 Any aAny = xLevelParagraphStyles->getByIndex(nLevel);
1556 Sequence<OUString> aStyleNames;
1557 aAny >>= aStyleNames;
1559 // export only if at least one style is contained
1560 sal_Int32 nNamesCount = aStyleNames.getLength();
1561 if (nNamesCount > 0)
1563 // level attribute; we count 1..10; API 0..9
1564 OUStringBuffer sBuf;
1565 sal_Int32 nLevelPlusOne = nLevel + 1;
1566 ::sax::Converter::convertNumber(sBuf, nLevelPlusOne);
1567 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1568 XML_OUTLINE_LEVEL,
1569 sBuf.makeStringAndClear());
1571 // source styles element
1572 SvXMLElementExport aParaStyles(GetExport(),
1573 XML_NAMESPACE_TEXT,
1574 XML_INDEX_SOURCE_STYLES,
1575 true, true);
1577 // iterate over styles in this level
1578 for(sal_Int32 nName = 0; nName < nNamesCount; nName++)
1580 // stylename attribute
1581 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1582 XML_STYLE_NAME,
1583 GetExport().EncodeStyleName( aStyleNames[nName]) );
1585 // element
1586 SvXMLElementExport aParaStyle(GetExport(),
1587 XML_NAMESPACE_TEXT,
1588 XML_INDEX_SOURCE_STYLE,
1589 true, false);
1595 void XMLSectionExport::ExportBoolean(
1596 const Reference<XPropertySet> & rPropSet,
1597 const OUString& sPropertyName,
1598 enum XMLTokenEnum eAttributeName,
1599 bool bDefault,
1600 bool bInvert)
1602 OSL_ENSURE(eAttributeName != XML_TOKEN_INVALID, "Need attribute name");
1604 Any aAny = rPropSet->getPropertyValue(sPropertyName);
1605 bool bTmp = *static_cast<sal_Bool const *>(aAny.getValue());
1607 // value = value ^ bInvert
1608 // omit if value == default
1609 if ( (bTmp != bInvert) != bDefault )
1611 // export non-default value (since default is omitted)
1612 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
1613 eAttributeName,
1614 bDefault ? XML_FALSE : XML_TRUE);
1618 const sal_Char sAPI_FieldMaster_Bibliography[] =
1619 "com.sun.star.text.FieldMaster.Bibliography";
1621 void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport)
1623 // first: get field master (via text field supplier)
1624 Reference<XTextFieldsSupplier> xTextFieldsSupp( rExport.GetModel(),
1625 UNO_QUERY );
1626 if ( xTextFieldsSupp.is() )
1628 const OUString sFieldMaster_Bibliography(sAPI_FieldMaster_Bibliography);
1630 // get bibliography field master
1631 Reference<XNameAccess> xMasters =
1632 xTextFieldsSupp->getTextFieldMasters();
1633 if ( xMasters->hasByName(sFieldMaster_Bibliography) )
1635 Any aAny =
1636 xMasters->getByName(sFieldMaster_Bibliography);
1637 Reference<XPropertySet> xPropSet;
1638 aAny >>= xPropSet;
1640 OSL_ENSURE( xPropSet.is(), "field master must have XPropSet" );
1642 const OUString sBracketBefore("BracketBefore");
1643 const OUString sBracketAfter("BracketAfter");
1644 const OUString sIsNumberEntries("IsNumberEntries");
1645 const OUString sIsSortByPosition("IsSortByPosition");
1646 const OUString sSortKeys("SortKeys");
1647 const OUString sSortAlgorithm("SortAlgorithm");
1648 const OUString sLocale("Locale");
1650 OUString sTmp;
1652 aAny = xPropSet->getPropertyValue(sBracketBefore);
1653 aAny >>= sTmp;
1654 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_PREFIX, sTmp);
1656 aAny = xPropSet->getPropertyValue(sBracketAfter);
1657 aAny >>= sTmp;
1658 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SUFFIX, sTmp);
1660 aAny = xPropSet->getPropertyValue(sIsNumberEntries);
1661 if (*static_cast<sal_Bool const *>(aAny.getValue()))
1663 rExport.AddAttribute(XML_NAMESPACE_TEXT,
1664 XML_NUMBERED_ENTRIES, XML_TRUE);
1667 aAny = xPropSet->getPropertyValue(sIsSortByPosition);
1668 if (! *static_cast<sal_Bool const *>(aAny.getValue()))
1670 rExport.AddAttribute(XML_NAMESPACE_TEXT,
1671 XML_SORT_BY_POSITION, XML_FALSE);
1674 // sort algorithm
1675 aAny = xPropSet->getPropertyValue(sSortAlgorithm);
1676 OUString sAlgorithm;
1677 aAny >>= sAlgorithm;
1678 if( !sAlgorithm.isEmpty() )
1680 rExport.AddAttribute( XML_NAMESPACE_TEXT,
1681 XML_SORT_ALGORITHM, sAlgorithm );
1684 // locale
1685 aAny = xPropSet->getPropertyValue(sLocale);
1686 Locale aLocale;
1687 aAny >>= aLocale;
1688 rExport.AddLanguageTagAttributes( XML_NAMESPACE_FO, XML_NAMESPACE_STYLE, aLocale, true);
1690 // configuration element
1691 SvXMLElementExport aElement(rExport, XML_NAMESPACE_TEXT,
1692 XML_BIBLIOGRAPHY_CONFIGURATION,
1693 true, true);
1695 // sort keys
1696 aAny = xPropSet->getPropertyValue(sSortKeys);
1697 Sequence<Sequence<PropertyValue> > aKeys;
1698 aAny >>= aKeys;
1699 sal_Int32 nKeysCount = aKeys.getLength();
1700 for(sal_Int32 nKeys = 0; nKeys < nKeysCount; nKeys++)
1702 Sequence<PropertyValue> & rKey = aKeys[nKeys];
1704 sal_Int32 nKeyCount = rKey.getLength();
1705 for(sal_Int32 nPropertyKey = 0; nPropertyKey < nKeyCount; nPropertyKey++)
1707 PropertyValue& rValue = rKey[nPropertyKey];
1709 if (rValue.Name == "SortKey")
1711 sal_Int16 nKey = 0;
1712 rValue.Value >>= nKey;
1713 OUStringBuffer sBuf;
1714 if (SvXMLUnitConverter::convertEnum( sBuf, nKey,
1715 aBibliographyDataFieldMap ) )
1717 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_KEY,
1718 sBuf.makeStringAndClear());
1721 else if (rValue.Name == "IsSortAscending")
1723 bool bTmp = *static_cast<sal_Bool const *>(rValue.Value.getValue());
1724 rExport.AddAttribute(XML_NAMESPACE_TEXT,
1725 XML_SORT_ASCENDING,
1726 bTmp ? XML_TRUE : XML_FALSE);
1730 SvXMLElementExport aKeyElem(rExport,
1731 XML_NAMESPACE_TEXT, XML_SORT_KEY,
1732 true, true);
1739 bool XMLSectionExport::IsMuteSection(
1740 const Reference<XTextSection> & rSection) const
1742 bool bRet = false;
1744 // a section is mute if
1745 // 1) it exists
1746 // 2) the SaveLinkedSections flag (at the export) is false
1747 // 3) the IsGlobalDocumentSection property is true
1748 // 4) it is not an Index
1750 if ( (!rExport.IsSaveLinkedSections()) && rSection.is() )
1752 // walk the section chain and set bRet if any is linked
1753 for(Reference<XTextSection> aSection(rSection);
1754 aSection.is();
1755 aSection = aSection->getParentSection())
1757 // check if it is a global document section (linked or index)
1758 Reference<XPropertySet> xPropSet(aSection, UNO_QUERY);
1759 if (xPropSet.is())
1761 Any aAny = xPropSet->getPropertyValue(sIsGlobalDocumentSection);
1763 if ( *static_cast<sal_Bool const *>(aAny.getValue()) )
1765 Reference<XDocumentIndex> xIndex;
1766 if (! GetIndex(rSection, xIndex))
1768 bRet = true;
1770 // early out if result is known
1771 break;
1775 // section has no properties: ignore
1778 // else: no section, or always save sections: default (false)
1780 return bRet;
1783 bool XMLSectionExport::IsMuteSection(
1784 const Reference<XTextContent> & rSection,
1785 bool bDefault) const
1787 // default: like default argument
1788 bool bRet = bDefault;
1790 Reference<XPropertySet> xPropSet(rSection->getAnchor(), UNO_QUERY);
1791 if (xPropSet.is())
1793 if (xPropSet->getPropertySetInfo()->hasPropertyByName(sTextSection))
1795 Any aAny = xPropSet->getPropertyValue(sTextSection);
1796 Reference<XTextSection> xSection;
1797 aAny >>= xSection;
1799 bRet = IsMuteSection(xSection);
1801 // else: return default
1803 // else: return default
1805 return bRet;
1808 bool XMLSectionExport::IsInSection(
1809 const Reference<XTextSection> & rEnclosingSection,
1810 const Reference<XTextContent> & rContent,
1811 bool bDefault)
1813 // default: like default argument
1814 bool bRet = bDefault;
1815 OSL_ENSURE(rEnclosingSection.is(), "enclosing section expected");
1817 Reference<XPropertySet> xPropSet(rContent, UNO_QUERY);
1818 if (xPropSet.is())
1820 if (xPropSet->getPropertySetInfo()->hasPropertyByName(sTextSection))
1822 Any aAny = xPropSet->getPropertyValue(sTextSection);
1823 Reference<XTextSection> xSection;
1824 aAny >>= xSection;
1826 // now walk chain of text sections (if we have one)
1827 if (xSection.is())
1831 bRet = (rEnclosingSection == xSection);
1832 xSection = xSection->getParentSection();
1834 while (!bRet && xSection.is());
1836 else
1837 bRet = false; // no section -> can't be inside
1839 // else: no TextSection property -> return default
1841 // else: no XPropertySet -> return default
1843 return bRet;
1847 void XMLSectionExport::ExportMasterDocHeadingDummies()
1849 if( bHeadingDummiesExported )
1850 return;
1852 Reference< XChapterNumberingSupplier > xCNSupplier( rExport.GetModel(),
1853 UNO_QUERY );
1855 Reference< XIndexReplace > xChapterNumbering;
1856 if( xCNSupplier.is() )
1857 xChapterNumbering = xCNSupplier->getChapterNumberingRules();
1859 if( !xChapterNumbering.is() )
1860 return;
1862 sal_Int32 nCount = xChapterNumbering->getCount();
1863 for( sal_Int32 nLevel = 0; nLevel < nCount; nLevel++ )
1865 OUString sStyle;
1866 Sequence<PropertyValue> aProperties;
1867 xChapterNumbering->getByIndex( nLevel ) >>= aProperties;
1868 for( sal_Int32 i = 0; i < aProperties.getLength(); i++ )
1870 if( aProperties[i].Name == sHeadingStyleName )
1872 aProperties[i].Value >>= sStyle;
1873 break;
1876 if( !sStyle.isEmpty() )
1878 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
1879 GetExport().EncodeStyleName( sStyle ) );
1881 OUStringBuffer sTmp;
1882 sTmp.append( nLevel + 1 );
1883 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LEVEL,
1884 sTmp.makeStringAndClear() );
1885 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_H,
1886 true, false );
1890 bHeadingDummiesExported = true;
1893 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */