1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLSectionExport.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "XMLSectionExport.hxx"
34 #include <tools/debug.hxx>
35 #include <rtl/ustring.hxx>
36 #include <rtl/ustrbuf.hxx>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/lang/Locale.hpp>
43 #include <com/sun/star/container/XIndexReplace.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/beans/PropertyValue.hpp>
46 #include <com/sun/star/beans/PropertyValues.hpp>
47 #include <com/sun/star/beans/PropertyState.hpp>
48 #include <com/sun/star/text/XText.hpp>
49 #include <com/sun/star/text/XTextSection.hpp>
50 #include <com/sun/star/text/SectionFileLink.hpp>
51 #include <com/sun/star/container/XNamed.hpp>
52 #include <com/sun/star/container/XNameAccess.hpp>
53 #include <com/sun/star/text/XDocumentIndex.hpp>
54 #include <com/sun/star/uno/XInterface.hpp>
55 #include <com/sun/star/text/BibliographyDataField.hpp>
56 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
57 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
58 #include <com/sun/star/text/ChapterFormat.hpp> //i90246
59 #include "xmlkywd.hxx"
60 #include <xmloff/xmltoken.hxx>
61 #include "xmlnmspe.hxx"
62 #include <xmloff/families.hxx>
63 #include <xmloff/xmluconv.hxx>
64 #include <xmloff/nmspmap.hxx>
65 #include <xmloff/xmlexp.hxx>
66 #include <xmloff/xmltkmap.hxx>
67 #include "txtflde.hxx"
71 using namespace ::com::sun::star
;
72 using namespace ::com::sun::star::text
;
73 using namespace ::com::sun::star::uno
;
74 using namespace ::std
;
75 using namespace ::xmloff::token
;
77 using ::rtl::OUString
;
78 using ::rtl::OUStringBuffer
;
79 using ::com::sun::star::beans::XPropertySet
;
80 using ::com::sun::star::beans::PropertyValue
;
81 using ::com::sun::star::beans::PropertyValues
;
82 using ::com::sun::star::beans::PropertyState
;
83 using ::com::sun::star::container::XIndexReplace
;
84 using ::com::sun::star::container::XNameAccess
;
85 using ::com::sun::star::container::XNamed
;
86 using ::com::sun::star::lang::XServiceInfo
;
87 using ::com::sun::star::lang::Locale
;
88 using ::com::sun::star::uno::XInterface
;
91 XMLSectionExport::XMLSectionExport(
93 XMLTextParagraphExport
& rParaExp
)
94 : sCondition(RTL_CONSTASCII_USTRINGPARAM("Condition"))
95 , sCreateFromChapter(RTL_CONSTASCII_USTRINGPARAM("CreateFromChapter"))
96 , sCreateFromEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM("CreateFromEmbeddedObjects"))
97 , sCreateFromGraphicObjects(RTL_CONSTASCII_USTRINGPARAM("CreateFromGraphicObjects"))
98 , sCreateFromLabels(RTL_CONSTASCII_USTRINGPARAM("CreateFromLabels"))
99 , sCreateFromMarks(RTL_CONSTASCII_USTRINGPARAM("CreateFromMarks"))
100 , sCreateFromOtherEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM("CreateFromOtherEmbeddedObjects"))
101 , sCreateFromOutline(RTL_CONSTASCII_USTRINGPARAM("CreateFromOutline"))
102 , sCreateFromStarCalc(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarCalc"))
103 , sCreateFromStarChart(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarChart"))
104 , sCreateFromStarDraw(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarDraw"))
105 , sCreateFromStarImage(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarImage"))
106 , sCreateFromStarMath(RTL_CONSTASCII_USTRINGPARAM("CreateFromStarMath"))
107 , sCreateFromTables(RTL_CONSTASCII_USTRINGPARAM("CreateFromTables"))
108 , sCreateFromTextFrames(RTL_CONSTASCII_USTRINGPARAM("CreateFromTextFrames"))
109 , sDdeCommandElement(RTL_CONSTASCII_USTRINGPARAM("DDECommandElement"))
110 , sDdeCommandFile(RTL_CONSTASCII_USTRINGPARAM("DDECommandFile"))
111 , sDdeCommandType(RTL_CONSTASCII_USTRINGPARAM("DDECommandType"))
112 , sFileLink(RTL_CONSTASCII_USTRINGPARAM("FileLink"))
113 , sIsCaseSensitive(RTL_CONSTASCII_USTRINGPARAM("IsCaseSensitive"))
114 , sIsProtected(RTL_CONSTASCII_USTRINGPARAM("IsProtected"))
115 , sIsVisible(RTL_CONSTASCII_USTRINGPARAM("IsVisible"))
116 , sLabelCategory(RTL_CONSTASCII_USTRINGPARAM("LabelCategory"))
117 , sLabelDisplayType(RTL_CONSTASCII_USTRINGPARAM("LabelDisplayType"))
118 , sLevel(RTL_CONSTASCII_USTRINGPARAM("Level"))
119 , sLevelFormat(RTL_CONSTASCII_USTRINGPARAM("LevelFormat"))
120 , sLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM("LevelParagraphStyles"))
121 , sLinkRegion(RTL_CONSTASCII_USTRINGPARAM("LinkRegion"))
122 , sMainEntryCharacterStyleName(RTL_CONSTASCII_USTRINGPARAM("MainEntryCharacterStyleName"))
123 , sParaStyleHeading(RTL_CONSTASCII_USTRINGPARAM("ParaStyleHeading"))
124 , sParaStyleLevel(RTL_CONSTASCII_USTRINGPARAM("ParaStyleLevel"))
125 , sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
126 , sName(RTL_CONSTASCII_USTRINGPARAM("Name"))
127 , sUseAlphabeticalSeparators(RTL_CONSTASCII_USTRINGPARAM("UseAlphabeticalSeparators"))
128 , sUseCombinedEntries(RTL_CONSTASCII_USTRINGPARAM("UseCombinedEntries"))
129 , sUseDash(RTL_CONSTASCII_USTRINGPARAM("UseDash"))
130 , sUseKeyAsEntry(RTL_CONSTASCII_USTRINGPARAM("UseKeyAsEntry"))
131 , sUseLevelFromSource(RTL_CONSTASCII_USTRINGPARAM("UseLevelFromSource"))
132 , sUsePP(RTL_CONSTASCII_USTRINGPARAM("UsePP"))
133 , sUseUpperCase(RTL_CONSTASCII_USTRINGPARAM("UseUpperCase"))
134 , sIsCommaSeparated(RTL_CONSTASCII_USTRINGPARAM("IsCommaSeparated"))
135 , sIsAutomaticUpdate(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticUpdate"))
136 , sIsRelativeTabstops(RTL_CONSTASCII_USTRINGPARAM("IsRelativeTabstops"))
137 , sCreateFromLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM("CreateFromLevelParagraphStyles"))
138 , sDocumentIndex(RTL_CONSTASCII_USTRINGPARAM("DocumentIndex"))
139 , sContentSection(RTL_CONSTASCII_USTRINGPARAM("ContentSection"))
140 , sHeaderSection(RTL_CONSTASCII_USTRINGPARAM("HeaderSection"))
142 , sTextSection(RTL_CONSTASCII_USTRINGPARAM("TextSection"))
143 , sIsGlobalDocumentSection(RTL_CONSTASCII_USTRINGPARAM("IsGlobalDocumentSection"))
144 , sProtectionKey(RTL_CONSTASCII_USTRINGPARAM("ProtectionKey"))
145 , sSortAlgorithm(RTL_CONSTASCII_USTRINGPARAM("SortAlgorithm"))
146 , sLocale(RTL_CONSTASCII_USTRINGPARAM("Locale"))
147 , sUserIndexName(RTL_CONSTASCII_USTRINGPARAM("UserIndexName"))
149 , sIsCurrentlyVisible(RTL_CONSTASCII_USTRINGPARAM("IsCurrentlyVisible"))
150 , sHeadingStyleName(RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName"))
153 , rParaExport(rParaExp
)
154 , bHeadingDummiesExported( sal_False
)
159 void XMLSectionExport::ExportSectionStart(
160 const Reference
<XTextSection
> & rSection
,
161 sal_Bool bAutoStyles
)
163 Reference
<XPropertySet
> xPropertySet(rSection
, UNO_QUERY
);
165 // always export section (auto) style
168 // get PropertySet and add section style
169 GetParaExport().Add( XML_STYLE_FAMILY_TEXT_SECTION
, xPropertySet
);
173 // always export section style
174 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
175 GetParaExport().Find(
176 XML_STYLE_FAMILY_TEXT_SECTION
,
177 xPropertySet
, sEmpty
) );
179 // xml:id for RDF metadata
180 GetExport().AddAttributeXmlId(rSection
);
182 // export index or regular section
183 Reference
<XDocumentIndex
> xIndex
;
184 if (GetIndex(rSection
, xIndex
))
189 ExportIndexStart(xIndex
);
193 // we are an index header
194 ExportIndexHeaderStart(rSection
);
199 // we are not an index
200 ExportRegularSectionStart(rSection
);
205 sal_Bool
XMLSectionExport::GetIndex(
206 const Reference
<XTextSection
> & rSection
,
207 Reference
<XDocumentIndex
> & rIndex
) const
209 // first, reset result
210 sal_Bool bRet
= sal_False
;
213 // get section Properties
214 Reference
<XPropertySet
> xSectionPropSet(rSection
, UNO_QUERY
);
216 // then check if this section happens to be inside an index
217 if (xSectionPropSet
->getPropertySetInfo()->
218 hasPropertyByName(sDocumentIndex
))
220 Any aAny
= xSectionPropSet
->getPropertyValue(sDocumentIndex
);
221 Reference
<XDocumentIndex
> xDocumentIndex
;
222 aAny
>>= xDocumentIndex
;
224 // OK, are we inside of an index
225 if (xDocumentIndex
.is())
227 // is the enclosing index identical with "our" section?
228 Reference
<XPropertySet
> xIndexPropSet(xDocumentIndex
, UNO_QUERY
);
229 aAny
= xIndexPropSet
->getPropertyValue(sContentSection
);
230 Reference
<XTextSection
> xEnclosingSection
;
231 aAny
>>= xEnclosingSection
;
233 // if the enclosing section is "our" section, then we are an index!
234 if (rSection
== xEnclosingSection
)
236 rIndex
= xDocumentIndex
;
239 // else: index header or regular section
241 // is the enclosing index identical with the header section?
242 aAny
= xIndexPropSet
->getPropertyValue(sHeaderSection
);
243 // now mis-named: contains header section
244 aAny
>>= xEnclosingSection
;
246 // if the enclosing section is "our" section, then we are an index!
247 if (rSection
== xEnclosingSection
)
251 // else: regular section
253 // else: we aren't even inside of an index
255 // else: we don't even know what an index is.
261 void XMLSectionExport::ExportSectionEnd(
262 const Reference
<XTextSection
> & rSection
,
263 sal_Bool bAutoStyles
)
265 // no end section for styles
268 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
270 // export index or regular section end
271 Reference
<XDocumentIndex
> xIndex
;
272 if (GetIndex(rSection
, xIndex
))
276 // index end: close index body element
277 GetExport().EndElement( XML_NAMESPACE_TEXT
, XML_INDEX_BODY
,
279 GetExport().IgnorableWhitespace();
281 switch (MapSectionType(xIndex
->getServiceName()))
283 case TEXT_SECTION_TYPE_TOC
:
284 eElement
= XML_TABLE_OF_CONTENT
;
287 case TEXT_SECTION_TYPE_ILLUSTRATION
:
288 eElement
= XML_ILLUSTRATION_INDEX
;
291 case TEXT_SECTION_TYPE_ALPHABETICAL
:
292 eElement
= XML_ALPHABETICAL_INDEX
;
295 case TEXT_SECTION_TYPE_TABLE
:
296 eElement
= XML_TABLE_INDEX
;
299 case TEXT_SECTION_TYPE_OBJECT
:
300 eElement
= XML_OBJECT_INDEX
;
303 case TEXT_SECTION_TYPE_USER
:
304 eElement
= XML_USER_INDEX
;
307 case TEXT_SECTION_TYPE_BIBLIOGRAPHY
:
308 eElement
= XML_BIBLIOGRAPHY
;
312 DBG_ERROR("unknown index type");
313 // default: skip index!
319 eElement
= XML_INDEX_TITLE
;
324 eElement
= XML_SECTION
;
327 if (XML_TOKEN_INVALID
!= eElement
)
329 // any old attributes?
330 GetExport().CheckAttrList();
332 // element surrounded by whitespace
333 GetExport().EndElement( XML_NAMESPACE_TEXT
, eElement
, sal_True
);
334 GetExport().IgnorableWhitespace();
338 DBG_ERROR("Need element name!");
341 // else: autostyles -> ignore
344 void XMLSectionExport::ExportIndexStart(
345 const Reference
<XDocumentIndex
> & rIndex
)
348 Reference
<XPropertySet
> xPropertySet(rIndex
, UNO_QUERY
);
350 switch (MapSectionType(rIndex
->getServiceName()))
352 case TEXT_SECTION_TYPE_TOC
:
353 ExportTableOfContentStart(xPropertySet
);
356 case TEXT_SECTION_TYPE_ILLUSTRATION
:
357 ExportIllustrationIndexStart(xPropertySet
);
360 case TEXT_SECTION_TYPE_ALPHABETICAL
:
361 ExportAlphabeticalIndexStart(xPropertySet
);
364 case TEXT_SECTION_TYPE_TABLE
:
365 ExportTableIndexStart(xPropertySet
);
368 case TEXT_SECTION_TYPE_OBJECT
:
369 ExportObjectIndexStart(xPropertySet
);
372 case TEXT_SECTION_TYPE_USER
:
373 ExportUserIndexStart(xPropertySet
);
376 case TEXT_SECTION_TYPE_BIBLIOGRAPHY
:
377 ExportBibliographyStart(xPropertySet
);
382 DBG_ERROR("unknown index type");
387 void XMLSectionExport::ExportIndexHeaderStart(
388 const Reference
<XTextSection
> & rSection
)
390 // export name, dammit!
391 Reference
<XNamed
> xName(rSection
, UNO_QUERY
);
392 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, xName
->getName());
394 // format already handled -> export only start element
395 GetExport().StartElement( XML_NAMESPACE_TEXT
, XML_INDEX_TITLE
, sal_True
);
396 GetExport().IgnorableWhitespace();
400 SvXMLEnumStringMapEntry __READONLY_DATA aIndexTypeMap
[] =
402 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.ContentIndex", TEXT_SECTION_TYPE_TOC
),
403 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.DocumentIndex", TEXT_SECTION_TYPE_ALPHABETICAL
),
404 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.TableIndex", TEXT_SECTION_TYPE_TABLE
),
405 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.ObjectIndex", TEXT_SECTION_TYPE_OBJECT
),
406 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.Bibliography", TEXT_SECTION_TYPE_BIBLIOGRAPHY
),
407 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.UserIndex", TEXT_SECTION_TYPE_USER
),
408 ENUM_STRING_MAP_ENTRY( "com.sun.star.text.IllustrationsIndex", TEXT_SECTION_TYPE_ILLUSTRATION
),
409 ENUM_STRING_MAP_END()
412 enum SectionTypeEnum
XMLSectionExport::MapSectionType(
413 const OUString
& rServiceName
)
415 enum SectionTypeEnum eType
= TEXT_SECTION_TYPE_UNKNOWN
;
418 if (SvXMLUnitConverter::convertEnum(nTmp
, rServiceName
, aIndexTypeMap
))
420 eType
= (enum SectionTypeEnum
)nTmp
;
423 // TODO: index header section types, etc.
428 void XMLSectionExport::ExportRegularSectionStart(
429 const Reference
<XTextSection
> & rSection
)
431 // style name already handled in ExportSectionStart(...)
433 Reference
<XNamed
> xName(rSection
, UNO_QUERY
);
434 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, xName
->getName());
436 // get XPropertySet for other values
437 Reference
<XPropertySet
> xPropSet(rSection
, UNO_QUERY
);
440 // condition and display
441 aAny
= xPropSet
->getPropertyValue(sCondition
);
444 enum XMLTokenEnum eDisplay
= XML_TOKEN_INVALID
;
445 if (sCond
.getLength() > 0)
448 GetExport().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOOW
,
450 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_CONDITION
, sQValue
);
451 eDisplay
= XML_CONDITION
;
453 // #97450# store hidden-status (of conditional sections only)
454 aAny
= xPropSet
->getPropertyValue(sIsCurrentlyVisible
);
455 if (! *(sal_Bool
*)aAny
.getValue())
457 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_IS_HIDDEN
,
465 aAny
= xPropSet
->getPropertyValue(sIsVisible
);
466 if (! *(sal_Bool
*)aAny
.getValue())
468 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_DISPLAY
, eDisplay
);
471 // protect + protection key
472 aAny
= xPropSet
->getPropertyValue(sIsProtected
);
473 if (*(sal_Bool
*)aAny
.getValue())
475 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_PROTECTED
, XML_TRUE
);
477 Sequence
<sal_Int8
> aPassword
;
478 xPropSet
->getPropertyValue(sProtectionKey
) >>= aPassword
;
479 if (aPassword
.getLength() > 0)
481 OUStringBuffer aBuffer
;
482 SvXMLUnitConverter::encodeBase64(aBuffer
, aPassword
);
483 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_PROTECTION_KEY
,
484 aBuffer
.makeStringAndClear());
488 GetExport().IgnorableWhitespace();
489 GetExport().StartElement( XML_NAMESPACE_TEXT
, XML_SECTION
, sal_True
);
492 // unfortunately, we have to test all relevant strings for non-zero length
493 aAny
= xPropSet
->getPropertyValue(sFileLink
);
494 SectionFileLink aFileLink
;
497 aAny
= xPropSet
->getPropertyValue(sLinkRegion
);
498 OUString sRegionName
;
499 aAny
>>= sRegionName
;
501 if ( (aFileLink
.FileURL
.getLength() > 0) ||
502 (aFileLink
.FilterName
.getLength() > 0) ||
503 (sRegionName
.getLength() > 0) )
505 if (aFileLink
.FileURL
.getLength() > 0)
507 GetExport().AddAttribute(XML_NAMESPACE_XLINK
, XML_HREF
,
508 GetExport().GetRelativeReference( aFileLink
.FileURL
) );
511 if (aFileLink
.FilterName
.getLength() > 0)
513 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_FILTER_NAME
,
514 aFileLink
.FilterName
);
517 if (sRegionName
.getLength() > 0)
519 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_SECTION_NAME
,
523 SvXMLElementExport
aElem(GetExport(),
524 XML_NAMESPACE_TEXT
, XML_SECTION_SOURCE
,
529 // check for DDE first
530 if (xPropSet
->getPropertySetInfo()->hasPropertyByName(sDdeCommandFile
))
533 // unfortunately, we have to test all relevant strings for
535 aAny
= xPropSet
->getPropertyValue(sDdeCommandFile
);
536 OUString sApplication
;
537 aAny
>>= sApplication
;
538 aAny
= xPropSet
->getPropertyValue(sDdeCommandType
);
541 aAny
= xPropSet
->getPropertyValue(sDdeCommandElement
);
545 if ( (sApplication
.getLength() > 0) ||
546 (sTopic
.getLength() > 0) ||
547 (sItem
.getLength() > 0 ) )
549 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
,
550 XML_DDE_APPLICATION
, sApplication
);
551 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
, XML_DDE_TOPIC
,
553 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
, XML_DDE_ITEM
,
556 aAny
= xPropSet
->getPropertyValue(sIsAutomaticUpdate
);
557 if (*(sal_Bool
*)aAny
.getValue())
559 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
,
560 XML_AUTOMATIC_UPDATE
, XML_TRUE
);
563 SvXMLElementExport
aElem(GetExport(),
564 XML_NAMESPACE_OFFICE
,
565 XML_DDE_SOURCE
, sal_True
, sal_True
);
567 // else: no DDE data source
569 // else: no DDE on this system
573 void XMLSectionExport::ExportTableOfContentStart(
574 const Reference
<XPropertySet
> & rPropertySet
)
576 // export TOC element start
577 ExportBaseIndexStart(XML_TABLE_OF_CONTENT
, rPropertySet
);
579 // scope for table-of-content-source element
584 // TOC specific index source attributes:
586 // outline-level: 1..10
587 sal_Int16 nLevel
= sal_Int16();
588 if( rPropertySet
->getPropertyValue(sLevel
) >>= nLevel
)
590 OUStringBuffer sBuffer
;
591 SvXMLUnitConverter::convertNumber(sBuffer
, (sal_Int32
)nLevel
);
592 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
594 sBuffer
.makeStringAndClear());
598 ExportBoolean(rPropertySet
, sCreateFromOutline
,
599 XML_USE_OUTLINE_LEVEL
, sal_True
);
602 ExportBoolean(rPropertySet
, sCreateFromMarks
,
603 XML_USE_INDEX_MARKS
, sal_True
);
606 ExportBoolean(rPropertySet
, sCreateFromLevelParagraphStyles
,
607 XML_USE_INDEX_SOURCE_STYLES
, sal_False
);
609 ExportBaseIndexSource(TEXT_SECTION_TYPE_TOC
, rPropertySet
);
612 ExportBaseIndexBody(TEXT_SECTION_TYPE_TOC
, rPropertySet
);
615 void XMLSectionExport::ExportObjectIndexStart(
616 const Reference
<XPropertySet
> & rPropertySet
)
618 // export index start
619 ExportBaseIndexStart(XML_OBJECT_INDEX
, rPropertySet
);
621 // scope for index source element
623 ExportBoolean(rPropertySet
, sCreateFromOtherEmbeddedObjects
,
624 XML_USE_OTHER_OBJECTS
, sal_False
);
625 ExportBoolean(rPropertySet
, sCreateFromStarCalc
,
626 XML_USE_SPREADSHEET_OBJECTS
, sal_False
);
627 ExportBoolean(rPropertySet
, sCreateFromStarChart
,
628 XML_USE_CHART_OBJECTS
, sal_False
);
629 ExportBoolean(rPropertySet
, sCreateFromStarDraw
,
630 XML_USE_DRAW_OBJECTS
, sal_False
);
631 ExportBoolean(rPropertySet
, sCreateFromStarMath
,
632 XML_USE_MATH_OBJECTS
, sal_False
);
634 ExportBaseIndexSource(TEXT_SECTION_TYPE_OBJECT
, rPropertySet
);
637 ExportBaseIndexBody(TEXT_SECTION_TYPE_OBJECT
, rPropertySet
);
640 void XMLSectionExport::ExportIllustrationIndexStart(
641 const Reference
<XPropertySet
> & rPropertySet
)
643 // export index start
644 ExportBaseIndexStart(XML_ILLUSTRATION_INDEX
, rPropertySet
);
646 // scope for index source element
648 // export common attributes for illustration and table indices
649 ExportTableAndIllustrationIndexSourceAttributes(rPropertySet
);
651 ExportBaseIndexSource(TEXT_SECTION_TYPE_ILLUSTRATION
, rPropertySet
);
654 ExportBaseIndexBody(TEXT_SECTION_TYPE_ILLUSTRATION
, rPropertySet
);
657 void XMLSectionExport::ExportTableIndexStart(
658 const Reference
<XPropertySet
> & rPropertySet
)
660 // export index start
661 ExportBaseIndexStart(XML_TABLE_INDEX
, rPropertySet
);
663 // scope for index source element
665 // export common attributes for illustration and table indices
666 ExportTableAndIllustrationIndexSourceAttributes(rPropertySet
);
668 ExportBaseIndexSource(TEXT_SECTION_TYPE_TABLE
, rPropertySet
);
671 ExportBaseIndexBody(TEXT_SECTION_TYPE_TABLE
, rPropertySet
);
674 void XMLSectionExport::ExportAlphabeticalIndexStart(
675 const Reference
<XPropertySet
> & rPropertySet
)
677 // export TOC element start
678 ExportBaseIndexStart(XML_ALPHABETICAL_INDEX
, rPropertySet
);
680 // scope for table-of-content-source element
683 // style name (if present)
685 aAny
= rPropertySet
->getPropertyValue(sMainEntryCharacterStyleName
);
688 if (sStyleName
.getLength())
690 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
691 XML_MAIN_ENTRY_STYLE_NAME
,
692 GetExport().EncodeStyleName( sStyleName
));
695 // other (boolean) attributes
696 ExportBoolean(rPropertySet
, sIsCaseSensitive
, XML_IGNORE_CASE
,
697 sal_False
, sal_True
);
698 ExportBoolean(rPropertySet
, sUseAlphabeticalSeparators
,
699 XML_ALPHABETICAL_SEPARATORS
, sal_False
);
700 ExportBoolean(rPropertySet
, sUseCombinedEntries
, XML_COMBINE_ENTRIES
,
702 ExportBoolean(rPropertySet
, sUseDash
, XML_COMBINE_ENTRIES_WITH_DASH
,
704 ExportBoolean(rPropertySet
, sUseKeyAsEntry
, XML_USE_KEYS_AS_ENTRIES
,
706 ExportBoolean(rPropertySet
, sUsePP
, XML_COMBINE_ENTRIES_WITH_PP
,
708 ExportBoolean(rPropertySet
, sUseUpperCase
, XML_CAPITALIZE_ENTRIES
,
710 ExportBoolean(rPropertySet
, sIsCommaSeparated
, XML_COMMA_SEPARATED
,
714 aAny
= rPropertySet
->getPropertyValue(sSortAlgorithm
);
717 if (sAlgorithm
.getLength() > 0)
719 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_SORT_ALGORITHM
,
724 aAny
= rPropertySet
->getPropertyValue(sLocale
);
727 GetExport().AddAttribute(XML_NAMESPACE_FO
, XML_LANGUAGE
,
729 GetExport().AddAttribute(XML_NAMESPACE_FO
, XML_COUNTRY
,
732 ExportBaseIndexSource(TEXT_SECTION_TYPE_ALPHABETICAL
, rPropertySet
);
735 ExportBaseIndexBody(TEXT_SECTION_TYPE_ALPHABETICAL
, rPropertySet
);
738 void XMLSectionExport::ExportUserIndexStart(
739 const Reference
<XPropertySet
> & rPropertySet
)
741 // export TOC element start
742 ExportBaseIndexStart(XML_USER_INDEX
, rPropertySet
);
744 // scope for table-of-content-source element
747 ExportBoolean(rPropertySet
, sCreateFromEmbeddedObjects
,
748 XML_USE_OBJECTS
, sal_False
);
749 ExportBoolean(rPropertySet
, sCreateFromGraphicObjects
,
750 XML_USE_GRAPHICS
, sal_False
);
751 ExportBoolean(rPropertySet
, sCreateFromMarks
,
752 XML_USE_INDEX_MARKS
, sal_False
);
753 ExportBoolean(rPropertySet
, sCreateFromTables
,
754 XML_USE_TABLES
, sal_False
);
755 ExportBoolean(rPropertySet
, sCreateFromTextFrames
,
756 XML_USE_FLOATING_FRAMES
, sal_False
);
757 ExportBoolean(rPropertySet
, sUseLevelFromSource
,
758 XML_COPY_OUTLINE_LEVELS
, sal_False
);
759 ExportBoolean(rPropertySet
, sCreateFromLevelParagraphStyles
,
760 XML_USE_INDEX_SOURCE_STYLES
, sal_False
);
762 Any aAny
= rPropertySet
->getPropertyValue( sUserIndexName
);
765 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_INDEX_NAME
,
768 ExportBaseIndexSource(TEXT_SECTION_TYPE_USER
, rPropertySet
);
771 ExportBaseIndexBody(TEXT_SECTION_TYPE_USER
, rPropertySet
);
774 void XMLSectionExport::ExportBibliographyStart(
775 const Reference
<XPropertySet
> & rPropertySet
)
777 // export TOC element start
778 ExportBaseIndexStart(XML_BIBLIOGRAPHY
, rPropertySet
);
780 // scope for table-of-content-source element
782 // No attributes. Fine.
784 ExportBaseIndexSource(TEXT_SECTION_TYPE_BIBLIOGRAPHY
, rPropertySet
);
787 ExportBaseIndexBody(TEXT_SECTION_TYPE_BIBLIOGRAPHY
, rPropertySet
);
791 void XMLSectionExport::ExportBaseIndexStart(
792 XMLTokenEnum eElement
,
793 const Reference
<XPropertySet
> & rPropertySet
)
795 // protect + protection key
796 Any aAny
= rPropertySet
->getPropertyValue(sIsProtected
);
797 if (*(sal_Bool
*)aAny
.getValue())
799 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_PROTECTED
, XML_TRUE
);
804 rPropertySet
->getPropertyValue(sName
) >>= sIndexName
;
805 if ( sIndexName
.getLength() > 0 )
807 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, sIndexName
);
810 // index Element start
811 GetExport().IgnorableWhitespace();
812 GetExport().StartElement( XML_NAMESPACE_TEXT
, eElement
, sal_False
);
815 static const sal_Char
* aTypeSourceElementNameMap
[] =
817 sXML_table_of_content_source
, // TOC
818 sXML_table_index_source
, // table index
819 sXML_illustration_index_source
, // illustration index
820 sXML_object_index_source
, // object index
821 sXML_user_index_source
, // user index
822 sXML_alphabetical_index_source
, // alphabetical index
823 sXML_bibliography_source
// bibliography
826 void XMLSectionExport::ExportBaseIndexSource(
827 SectionTypeEnum eType
,
828 const Reference
<XPropertySet
> & rPropertySet
)
831 DBG_ASSERT(eType
>= TEXT_SECTION_TYPE_TOC
, "illegal index type");
832 DBG_ASSERT(eType
<= TEXT_SECTION_TYPE_BIBLIOGRAPHY
, "illegal index type");
836 // common attributes; not supported by bibliography
837 if (eType
!= TEXT_SECTION_TYPE_BIBLIOGRAPHY
)
839 // document or chapter index?
840 aAny
= rPropertySet
->getPropertyValue(sCreateFromChapter
);
841 if (*(sal_Bool
*)aAny
.getValue())
843 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
844 XML_INDEX_SCOPE
, XML_CHAPTER
);
847 // tab-stops relative to margin?
848 aAny
= rPropertySet
->getPropertyValue(sIsRelativeTabstops
);
849 if (! *(sal_Bool
*)aAny
.getValue())
851 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
852 XML_RELATIVE_TAB_STOP_POSITION
,
857 // the index source element (all indices)
858 SvXMLElementExport
aElem(GetExport(),
860 aTypeSourceElementNameMap
[
861 eType
- TEXT_SECTION_TYPE_TOC
],
864 // scope for title template (all indices)
867 aAny
= rPropertySet
->getPropertyValue(sParaStyleHeading
);
870 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
872 GetExport().EncodeStyleName( sStyleName
));
875 SvXMLElementExport
aHeaderTemplate(GetExport(),
877 XML_INDEX_TITLE_TEMPLATE
,
878 sal_True
, sal_False
);
880 // title as element content
881 aAny
= rPropertySet
->getPropertyValue(sTitle
);
882 OUString sTitleString
;
883 aAny
>>= sTitleString
;
884 GetExport().Characters(sTitleString
);
887 // export level templates (all indices)
888 aAny
= rPropertySet
->getPropertyValue(sLevelFormat
);
889 Reference
<XIndexReplace
> xLevelTemplates
;
890 aAny
>>= xLevelTemplates
;
892 // iterate over level formats;
893 // skip element 0 (empty template for title)
894 sal_Int32 nLevelCount
= xLevelTemplates
->getCount();
895 for(sal_Int32 i
= 1; i
<nLevelCount
; i
++)
898 Sequence
<PropertyValues
> aTemplateSequence
;
899 aAny
= xLevelTemplates
->getByIndex(i
);
900 aAny
>>= aTemplateSequence
;
902 // export the sequence (abort export if an error occured; #91214#)
904 ExportIndexTemplate(eType
, i
, rPropertySet
, aTemplateSequence
);
909 // only TOC and user index:
910 // styles from which to build the index (LevelParagraphStyles)
911 if ( (TEXT_SECTION_TYPE_TOC
== eType
) ||
912 (TEXT_SECTION_TYPE_USER
== eType
) )
914 aAny
= rPropertySet
->getPropertyValue(sLevelParagraphStyles
);
915 Reference
<XIndexReplace
> xLevelParagraphStyles
;
916 aAny
>>= xLevelParagraphStyles
;
917 ExportLevelParagraphStyles(xLevelParagraphStyles
);
922 void XMLSectionExport::ExportBaseIndexBody(
928 const Reference
<XPropertySet
> &)
930 // type not used; checked anyway.
931 DBG_ASSERT(eType
>= TEXT_SECTION_TYPE_TOC
, "illegal index type");
932 DBG_ASSERT(eType
<= TEXT_SECTION_TYPE_BIBLIOGRAPHY
, "illegal index type");
936 // any old attributes?
937 GetExport().CheckAttrList();
939 // start surrounded by whitespace
940 GetExport().IgnorableWhitespace();
941 GetExport().StartElement( XML_NAMESPACE_TEXT
, XML_INDEX_BODY
, sal_True
);
944 void XMLSectionExport::ExportTableAndIllustrationIndexSourceAttributes(
945 const Reference
<XPropertySet
> & rPropertySet
)
948 Any aAny
= rPropertySet
->getPropertyValue(sCreateFromLabels
);
949 if (! *(sal_Bool
*)aAny
.getValue())
951 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
952 XML_USE_CAPTION
, XML_FALSE
);
956 aAny
= rPropertySet
->getPropertyValue(sLabelCategory
);
957 OUString sSequenceName
;
958 aAny
>>= sSequenceName
;
959 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
960 XML_CAPTION_SEQUENCE_NAME
,
964 aAny
= rPropertySet
->getPropertyValue(sLabelDisplayType
);
967 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
968 XML_CAPTION_SEQUENCE_FORMAT
,
969 XMLTextFieldExport::MapReferenceType(nType
));
973 // map index of LevelFormats to attribute value;
974 // level 0 is always the header
975 static const sal_Char
* aLevelNameTOCMap
[] =
976 { NULL
, sXML_1
, sXML_2
, sXML_3
, sXML_4
, sXML_5
, sXML_6
, sXML_7
,
977 sXML_8
, sXML_9
, sXML_10
, NULL
};
978 static const sal_Char
* aLevelNameTableMap
[] =
980 static const sal_Char
* aLevelNameAlphaMap
[] =
981 { NULL
, sXML_separator
, sXML_1
, sXML_2
, sXML_3
, NULL
};
982 static const sal_Char
* aLevelNameBibliographyMap
[] =
983 { NULL
, sXML_article
, sXML_book
, sXML_booklet
, sXML_conference
,
984 sXML_custom1
, sXML_custom2
, sXML_custom3
, sXML_custom4
,
985 sXML_custom5
, sXML_email
, sXML_inbook
, sXML_incollection
,
986 sXML_inproceedings
, sXML_journal
,
987 sXML_manual
, sXML_mastersthesis
, sXML_misc
, sXML_phdthesis
,
988 sXML_proceedings
, sXML_techreport
, sXML_unpublished
, sXML_www
,
991 static const sal_Char
** aTypeLevelNameMap
[] =
993 aLevelNameTOCMap
, // TOC
994 aLevelNameTableMap
, // table index
995 aLevelNameTableMap
, // illustration index
996 aLevelNameTableMap
, // object index
997 aLevelNameTOCMap
, // user index
998 aLevelNameAlphaMap
, // alphabetical index
999 aLevelNameBibliographyMap
// bibliography
1002 static const sal_Char
* aLevelStylePropNameTOCMap
[] =
1003 { NULL
, "ParaStyleLevel1", "ParaStyleLevel2", "ParaStyleLevel3",
1004 "ParaStyleLevel4", "ParaStyleLevel5", "ParaStyleLevel6",
1005 "ParaStyleLevel7", "ParaStyleLevel8", "ParaStyleLevel9",
1006 "ParaStyleLevel10", NULL
};
1007 static const sal_Char
* aLevelStylePropNameTableMap
[] =
1008 { NULL
, "ParaStyleLevel1", NULL
};
1009 static const sal_Char
* aLevelStylePropNameAlphaMap
[] =
1010 { NULL
, "ParaStyleSeparator", "ParaStyleLevel1", "ParaStyleLevel2",
1011 "ParaStyleLevel3", NULL
};
1012 static const sal_Char
* aLevelStylePropNameBibliographyMap
[] =
1013 // TODO: replace with real property names, when available
1014 { NULL
, "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1015 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1016 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1017 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1018 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1019 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1020 "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
1024 static const sal_Char
** aTypeLevelStylePropNameMap
[] =
1026 aLevelStylePropNameTOCMap
, // TOC
1027 aLevelStylePropNameTableMap
, // table index
1028 aLevelStylePropNameTableMap
, // illustration index
1029 aLevelStylePropNameTableMap
, // object index
1030 aLevelStylePropNameTOCMap
, // user index
1031 aLevelStylePropNameAlphaMap
, // alphabetical index
1032 aLevelStylePropNameBibliographyMap
// bibliography
1035 static const sal_Char
* aTypeLevelAttrMap
[] =
1037 sXML_outline_level
, // TOC
1038 NULL
, // table index
1039 NULL
, // illustration index
1040 NULL
, // object index
1041 sXML_outline_level
, // user index
1042 sXML_outline_level
, // alphabetical index
1043 sXML_bibliography_type
// bibliography
1046 static const sal_Char
* aTypeElementNameMap
[] =
1048 sXML_table_of_content_entry_template
, // TOC
1049 sXML_table_index_entry_template
, // table index
1050 sXML_illustration_index_entry_template
, // illustration index
1051 sXML_object_index_entry_template
, // object index
1052 sXML_user_index_entry_template
, // user index
1053 sXML_alphabetical_index_entry_template
, // alphabetical index
1054 sXML_bibliography_entry_template
// bibliography
1058 sal_Bool
XMLSectionExport::ExportIndexTemplate(
1059 SectionTypeEnum eType
,
1060 sal_Int32 nOutlineLevel
,
1061 const Reference
<XPropertySet
> & rPropertySet
,
1062 Sequence
<Sequence
<PropertyValue
> > & rValues
)
1064 DBG_ASSERT(eType
>= TEXT_SECTION_TYPE_TOC
, "illegal index type");
1065 DBG_ASSERT(eType
<= TEXT_SECTION_TYPE_BIBLIOGRAPHY
, "illegal index type");
1066 DBG_ASSERT(nOutlineLevel
>= 0, "illegal outline level");
1068 if ( (eType
>= TEXT_SECTION_TYPE_TOC
) &&
1069 (eType
<= TEXT_SECTION_TYPE_BIBLIOGRAPHY
) &&
1070 (nOutlineLevel
>= 0) )
1072 // get level name and level attribute name from aLevelNameMap;
1073 const sal_Char
* pLevelAttrName
=
1074 aTypeLevelAttrMap
[eType
-TEXT_SECTION_TYPE_TOC
];
1075 const sal_Char
* pLevelName
=
1076 aTypeLevelNameMap
[eType
-TEXT_SECTION_TYPE_TOC
][nOutlineLevel
];
1078 // #92124#: some old documents may be broken, then they have
1079 // too many template levels; we need to recognize this and
1080 // export only as many as is legal for the respective index
1081 // type. To do this, we simply return an error flag, which
1082 // will then abort further template level exports.
1083 DBG_ASSERT(NULL
!= pLevelName
, "can't find level name");
1084 if ( NULL
== pLevelName
)
1086 // output level not found? Then end of templates! #91214#
1090 // output level name
1091 if ((NULL
!= pLevelName
) && (NULL
!= pLevelAttrName
))
1093 GetExport().AddAttributeASCII(XML_NAMESPACE_TEXT
,
1098 // paragraph level style name
1099 const sal_Char
* pPropName
=
1100 aTypeLevelStylePropNameMap
[eType
-TEXT_SECTION_TYPE_TOC
][nOutlineLevel
];
1101 DBG_ASSERT(NULL
!= pPropName
, "can't find property name");
1102 if (NULL
!= pPropName
)
1104 Any aAny
= rPropertySet
->getPropertyValue(
1105 OUString::createFromAscii(pPropName
));
1106 OUString sParaStyleName
;
1107 aAny
>>= sParaStyleName
;
1108 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
1110 GetExport().EncodeStyleName( sParaStyleName
));
1114 const sal_Char
* pElementName
=
1115 aTypeElementNameMap
[eType
- TEXT_SECTION_TYPE_TOC
];
1116 SvXMLElementExport
aLevelTemplate(GetExport(),
1119 sal_True
, sal_True
);
1122 sal_Int32 nTemplateCount
= rValues
.getLength();
1123 for(sal_Int32 nTemplateNo
= 0;
1124 nTemplateNo
< nTemplateCount
;
1127 ExportIndexTemplateElement(
1129 rValues
[nTemplateNo
]);
1137 enum TemplateTypeEnum
1139 TOK_TTYPE_ENTRY_NUMBER
,
1140 TOK_TTYPE_ENTRY_TEXT
,
1143 TOK_TTYPE_PAGE_NUMBER
,
1144 TOK_TTYPE_CHAPTER_INFO
,
1145 TOK_TTYPE_HYPERLINK_START
,
1146 TOK_TTYPE_HYPERLINK_END
,
1147 TOK_TTYPE_BIBLIOGRAPHY
,
1151 enum TemplateParamEnum
1153 TOK_TPARAM_TOKEN_TYPE
,
1154 TOK_TPARAM_CHAR_STYLE
,
1155 TOK_TPARAM_TAB_RIGHT_ALIGNED
,
1156 TOK_TPARAM_TAB_POSITION
,
1157 TOK_TPARAM_TAB_WITH_TAB
, // #i21237#
1158 TOK_TPARAM_TAB_FILL_CHAR
,
1160 TOK_TPARAM_CHAPTER_FORMAT
,
1161 TOK_TPARAM_CHAPTER_LEVEL
,//i53420
1162 TOK_TPARAM_BIBLIOGRAPHY_DATA
1165 SvXMLEnumStringMapEntry __READONLY_DATA aTemplateTypeMap
[] =
1167 ENUM_STRING_MAP_ENTRY( "TokenEntryNumber", TOK_TTYPE_ENTRY_NUMBER
),
1168 ENUM_STRING_MAP_ENTRY( "TokenEntryText", TOK_TTYPE_ENTRY_TEXT
),
1169 ENUM_STRING_MAP_ENTRY( "TokenTabStop", TOK_TTYPE_TAB_STOP
),
1170 ENUM_STRING_MAP_ENTRY( "TokenText", TOK_TTYPE_TEXT
),
1171 ENUM_STRING_MAP_ENTRY( "TokenPageNumber", TOK_TTYPE_PAGE_NUMBER
),
1172 ENUM_STRING_MAP_ENTRY( "TokenChapterInfo", TOK_TTYPE_CHAPTER_INFO
),
1173 ENUM_STRING_MAP_ENTRY( "TokenHyperlinkStart", TOK_TTYPE_HYPERLINK_START
),
1174 ENUM_STRING_MAP_ENTRY( "TokenHyperlinkEnd", TOK_TTYPE_HYPERLINK_END
),
1175 ENUM_STRING_MAP_ENTRY( "TokenBibliographyDataField", TOK_TTYPE_BIBLIOGRAPHY
),
1176 ENUM_STRING_MAP_END()
1179 SvXMLEnumStringMapEntry __READONLY_DATA aTemplateParamMap
[] =
1181 ENUM_STRING_MAP_ENTRY( "TokenType", TOK_TPARAM_TOKEN_TYPE
),
1182 ENUM_STRING_MAP_ENTRY( "CharacterStyleName", TOK_TPARAM_CHAR_STYLE
),
1183 ENUM_STRING_MAP_ENTRY( "TabStopRightAligned", TOK_TPARAM_TAB_RIGHT_ALIGNED
),
1184 ENUM_STRING_MAP_ENTRY( "TabStopPosition", TOK_TPARAM_TAB_POSITION
),
1185 ENUM_STRING_MAP_ENTRY( "TabStopFillCharacter", TOK_TPARAM_TAB_FILL_CHAR
),
1187 ENUM_STRING_MAP_ENTRY( "WithTab", TOK_TPARAM_TAB_WITH_TAB
),
1188 ENUM_STRING_MAP_ENTRY( "Text", TOK_TPARAM_TEXT
),
1189 ENUM_STRING_MAP_ENTRY( "ChapterFormat", TOK_TPARAM_CHAPTER_FORMAT
),
1190 ENUM_STRING_MAP_ENTRY( "ChapterLevel", TOK_TPARAM_CHAPTER_LEVEL
),//i53420
1191 ENUM_STRING_MAP_ENTRY( "BibliographyDataField", TOK_TPARAM_BIBLIOGRAPHY_DATA
),
1192 ENUM_STRING_MAP_END()
1195 SvXMLEnumMapEntry __READONLY_DATA aBibliographyDataFieldMap
[] =
1197 { XML_ADDRESS
, BibliographyDataField::ADDRESS
},
1198 { XML_ANNOTE
, BibliographyDataField::ANNOTE
},
1199 { XML_AUTHOR
, BibliographyDataField::AUTHOR
},
1200 { XML_BIBLIOGRAPHY_TYPE
, BibliographyDataField::BIBILIOGRAPHIC_TYPE
},
1201 { XML_BOOKTITLE
, BibliographyDataField::BOOKTITLE
},
1202 { XML_CHAPTER
, BibliographyDataField::CHAPTER
},
1203 { XML_CUSTOM1
, BibliographyDataField::CUSTOM1
},
1204 { XML_CUSTOM2
, BibliographyDataField::CUSTOM2
},
1205 { XML_CUSTOM3
, BibliographyDataField::CUSTOM3
},
1206 { XML_CUSTOM4
, BibliographyDataField::CUSTOM4
},
1207 { XML_CUSTOM5
, BibliographyDataField::CUSTOM5
},
1208 { XML_EDITION
, BibliographyDataField::EDITION
},
1209 { XML_EDITOR
, BibliographyDataField::EDITOR
},
1210 { XML_HOWPUBLISHED
, BibliographyDataField::HOWPUBLISHED
},
1211 { XML_IDENTIFIER
, BibliographyDataField::IDENTIFIER
},
1212 { XML_INSTITUTION
, BibliographyDataField::INSTITUTION
},
1213 { XML_ISBN
, BibliographyDataField::ISBN
},
1214 { XML_JOURNAL
, BibliographyDataField::JOURNAL
},
1215 { XML_MONTH
, BibliographyDataField::MONTH
},
1216 { XML_NOTE
, BibliographyDataField::NOTE
},
1217 { XML_NUMBER
, BibliographyDataField::NUMBER
},
1218 { XML_ORGANIZATIONS
, BibliographyDataField::ORGANIZATIONS
},
1219 { XML_PAGES
, BibliographyDataField::PAGES
},
1220 { XML_PUBLISHER
, BibliographyDataField::PUBLISHER
},
1221 { XML_REPORT_TYPE
, BibliographyDataField::REPORT_TYPE
},
1222 { XML_SCHOOL
, BibliographyDataField::SCHOOL
},
1223 { XML_SERIES
, BibliographyDataField::SERIES
},
1224 { XML_TITLE
, BibliographyDataField::TITLE
},
1225 { XML_URL
, BibliographyDataField::URL
},
1226 { XML_VOLUME
, BibliographyDataField::VOLUME
},
1227 { XML_YEAR
, BibliographyDataField::YEAR
},
1228 { XML_TOKEN_INVALID
, 0 }
1231 void XMLSectionExport::ExportIndexTemplateElement(
1232 SectionTypeEnum eType
, //i90246
1233 Sequence
<PropertyValue
> & rValues
)
1235 // variables for template values
1238 OUString sCharStyle
;
1239 sal_Bool bCharStyleOK
= sal_False
;
1243 sal_Bool bTextOK
= sal_False
;
1246 sal_Bool bRightAligned
= sal_False
;
1247 sal_Bool bRightAlignedOK
= sal_False
;
1250 sal_Int32 nTabPosition
= 0;
1251 sal_Bool bTabPositionOK
= sal_False
;
1255 sal_Bool bFillCharOK
= sal_False
;
1258 sal_Int16 nChapterFormat
= 0;
1259 sal_Bool bChapterFormatOK
= sal_False
;
1261 // outline max level
1262 sal_Int16 nLevel
= 0;
1263 sal_Bool bLevelOK
= sal_False
;
1265 // Bibliography Data
1266 sal_Int16 nBibliographyData
= 0;
1267 sal_Bool bBibliographyDataOK
= sal_False
;
1269 // With Tab Stop #i21237#
1270 sal_Bool bWithTabStop
= sal_False
;
1271 sal_Bool bWithTabStopOK
= sal_False
;
1273 //i90246, the ODF version being written to is:
1274 const SvtSaveOptions::ODFDefaultVersion aODFVersion
= rExport
.getDefaultVersion();
1275 //the above version cannot be used for old OOo (OOo 1.0) formats!
1278 enum TemplateTypeEnum nTokenType
= TOK_TTYPE_INVALID
;
1280 sal_Int32 nCount
= rValues
.getLength();
1281 for(sal_Int32 i
= 0; i
<nCount
; i
++)
1284 if ( SvXMLUnitConverter::convertEnum( nToken
, rValues
[i
].Name
,
1285 aTemplateParamMap
) )
1287 // Only use direct and default values.
1288 // Wrong. no property states, so ignore.
1289 // if ( (beans::PropertyState_DIRECT_VALUE == rValues[i].State) ||
1290 // (beans::PropertyState_DEFAULT_VALUE == rValues[i].State) )
1294 case TOK_TPARAM_TOKEN_TYPE
:
1298 rValues
[i
].Value
>>= sVal
;
1299 if (SvXMLUnitConverter::convertEnum( nTmp
, sVal
,
1302 nTokenType
= (enum TemplateTypeEnum
)nTmp
;
1307 case TOK_TPARAM_CHAR_STYLE
:
1308 // only valid, if not empty
1309 rValues
[i
].Value
>>= sCharStyle
;
1310 bCharStyleOK
= sCharStyle
.getLength() > 0;
1313 case TOK_TPARAM_TEXT
:
1314 rValues
[i
].Value
>>= sText
;
1318 case TOK_TPARAM_TAB_RIGHT_ALIGNED
:
1320 *(sal_Bool
*)rValues
[i
].Value
.getValue();
1321 bRightAlignedOK
= sal_True
;
1324 case TOK_TPARAM_TAB_POSITION
:
1325 rValues
[i
].Value
>>= nTabPosition
;
1326 bTabPositionOK
= sal_True
;
1330 case TOK_TPARAM_TAB_WITH_TAB
:
1331 bWithTabStop
= *(sal_Bool
*)rValues
[i
].Value
.getValue();
1332 bWithTabStopOK
= sal_True
;
1335 case TOK_TPARAM_TAB_FILL_CHAR
:
1336 rValues
[i
].Value
>>= sFillChar
;
1337 bFillCharOK
= sal_True
;
1340 case TOK_TPARAM_CHAPTER_FORMAT
:
1341 rValues
[i
].Value
>>= nChapterFormat
;
1342 bChapterFormatOK
= sal_True
;
1345 case TOK_TPARAM_CHAPTER_LEVEL
:
1346 rValues
[i
].Value
>>= nLevel
;
1347 bLevelOK
= sal_True
;
1350 case TOK_TPARAM_BIBLIOGRAPHY_DATA
:
1351 rValues
[i
].Value
>>= nBibliographyData
;
1352 bBibliographyDataOK
= sal_True
;
1358 // convert type to token (and check validity) ...
1359 sal_Char
* pElement
= NULL
;
1362 case TOK_TTYPE_ENTRY_TEXT
:
1363 pElement
= sXML_index_entry_text
;
1365 case TOK_TTYPE_TAB_STOP
:
1367 pElement
= ( bRightAligned
|| bTabPositionOK
|| bFillCharOK
)
1368 ? sXML_index_entry_tab_stop
: NULL
;
1370 case TOK_TTYPE_TEXT
:
1372 pElement
= bTextOK
? sXML_index_entry_span
: NULL
;
1374 case TOK_TTYPE_PAGE_NUMBER
:
1375 pElement
= sXML_index_entry_page_number
;
1377 case TOK_TTYPE_CHAPTER_INFO
: // keyword index
1378 pElement
= sXML_index_entry_chapter
;
1380 case TOK_TTYPE_ENTRY_NUMBER
: // table of content
1381 pElement
= sXML_index_entry_chapter
;
1383 case TOK_TTYPE_HYPERLINK_START
:
1384 pElement
= sXML_index_entry_link_start
;
1386 case TOK_TTYPE_HYPERLINK_END
:
1387 pElement
= sXML_index_entry_link_end
;
1389 case TOK_TTYPE_BIBLIOGRAPHY
:
1390 pElement
= bBibliographyDataOK
1391 ? sXML_index_entry_bibliography
: NULL
;
1394 ; // unknown/unimplemented template
1399 //check the ODF version being exported
1400 if( aODFVersion
== SvtSaveOptions::ODFVER_011
1401 || aODFVersion
== SvtSaveOptions::ODFVER_010
)
1403 bLevelOK
= sal_False
;
1404 if (TOK_TTYPE_CHAPTER_INFO
== nTokenType
)
1406 //if we are emitting for ODF 1.1 or 1.0, this information can be used for alphabetical index only
1407 //it's not permitted in other indexes
1408 if (eType
!= TEXT_SECTION_TYPE_ALPHABETICAL
)
1410 pElement
= NULL
; //not permitted, null the element
1412 else //maps format for 1.1 & 1.0
1414 // a few word here: OOo up to 2.4 uses the field chapter info in Alphabetical index
1415 // in a way different from the ODF 1.1/1.0 specification:
1417 // ODF1.1/1.0 OOo display in chapter info ODF1.2
1418 // (used in alphabetical index only
1420 // number chapter number without pre/postfix plain-number
1421 // number-and-name chapter number without pre/postfix plus title plain-number-and-name
1423 // with issue i89791 the reading of ODF 1.1 and 1.0 was corrected
1424 // this one corrects the writing back from ODF 1.2 to ODF 1.1/1.0
1425 // unfortunately if there is another application which interprets correctly ODF1.1/1.0,
1426 // the resulting alphabetical index will be rendered wrong by OOo 2.4 version
1428 switch( nChapterFormat
)
1430 case ChapterFormat::DIGIT
:
1431 nChapterFormat
= ChapterFormat::NUMBER
;
1433 case ChapterFormat::NO_PREFIX_SUFFIX
:
1434 nChapterFormat
= ChapterFormat::NAME_NUMBER
;
1439 else if (TOK_TTYPE_ENTRY_NUMBER
== nTokenType
)
1441 //in case of ODF 1.1 or 1.0 the only allowed number format is "number"
1443 // The only expected 'foreign' nChapterFormat is
1444 // ' ChapterFormat::DIGIT', forced to 'none, since the
1445 // 'value allowed in ODF 1.1 and 1.0 is 'number' the default
1446 // this can be obtained by simply disabling the chapter format
1447 bChapterFormatOK
= sal_False
;
1452 // ... and write Element
1453 if (pElement
!= NULL
)
1455 // character style (for most templates)
1460 case TOK_TTYPE_ENTRY_TEXT
:
1461 case TOK_TTYPE_TEXT
:
1462 case TOK_TTYPE_PAGE_NUMBER
:
1463 case TOK_TTYPE_ENTRY_NUMBER
:
1464 case TOK_TTYPE_HYPERLINK_START
:
1465 case TOK_TTYPE_HYPERLINK_END
:
1466 case TOK_TTYPE_BIBLIOGRAPHY
:
1467 case TOK_TTYPE_CHAPTER_INFO
:
1468 case TOK_TTYPE_TAB_STOP
:
1469 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
1471 GetExport().EncodeStyleName( sCharStyle
) );
1474 ; // nothing: no character style
1480 if (TOK_TTYPE_TAB_STOP
== nTokenType
)
1483 GetExport().AddAttribute(XML_NAMESPACE_STYLE
, XML_TYPE
,
1484 bRightAligned
? XML_RIGHT
: XML_LEFT
);
1486 if (bTabPositionOK
&& (! bRightAligned
))
1488 // position for left tabs (convert to measure)
1489 OUStringBuffer sBuf
;
1490 GetExport().GetMM100UnitConverter().convertMeasure(sBuf
,
1492 GetExport().AddAttribute(XML_NAMESPACE_STYLE
,
1494 sBuf
.makeStringAndClear());
1497 // fill char ("leader char")
1498 if (bFillCharOK
&& (sFillChar
.getLength() > 0))
1500 GetExport().AddAttribute(XML_NAMESPACE_STYLE
,
1501 XML_LEADER_CHAR
, sFillChar
);
1505 if (bWithTabStopOK
&& ! bWithTabStop
)
1507 GetExport().AddAttribute(XML_NAMESPACE_STYLE
,
1513 // bibliography data
1514 if (TOK_TTYPE_BIBLIOGRAPHY
== nTokenType
)
1516 DBG_ASSERT(bBibliographyDataOK
, "need bibl data");
1517 OUStringBuffer sBuf
;
1518 if (SvXMLUnitConverter::convertEnum( sBuf
, nBibliographyData
,
1519 aBibliographyDataFieldMap
) )
1521 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
1522 XML_BIBLIOGRAPHY_DATA_FIELD
,
1523 sBuf
.makeStringAndClear());
1528 if (TOK_TTYPE_CHAPTER_INFO
== nTokenType
)
1530 DBG_ASSERT(bChapterFormatOK
, "need chapter info");
1531 GetExport().AddAttribute(
1532 XML_NAMESPACE_TEXT
, XML_DISPLAY
,
1533 XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat
));
1536 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_OUTLINE_LEVEL
,
1537 OUString::valueOf((sal_Int32
)nLevel
));
1542 if (TOK_TTYPE_ENTRY_NUMBER
== nTokenType
)
1544 if (bChapterFormatOK
)
1545 GetExport().AddAttribute(
1546 XML_NAMESPACE_TEXT
, XML_DISPLAY
,
1547 XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat
));
1550 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_OUTLINE_LEVEL
,
1551 OUString::valueOf((sal_Int32
)nLevel
));
1555 SvXMLElementExport
aTemplateElement(GetExport(), XML_NAMESPACE_TEXT
,
1556 pElement
, sal_True
, sal_False
);
1558 // entry text or span element: write text
1559 if (TOK_TTYPE_TEXT
== nTokenType
)
1561 GetExport().Characters(sText
);
1566 void XMLSectionExport::ExportLevelParagraphStyles(
1567 Reference
<XIndexReplace
> & xLevelParagraphStyles
)
1569 // iterate over levels
1570 sal_Int32 nPLevelCount
= xLevelParagraphStyles
->getCount();
1571 for(sal_Int32 nLevel
= 0; nLevel
< nPLevelCount
; nLevel
++)
1573 Any aAny
= xLevelParagraphStyles
->getByIndex(nLevel
);
1574 Sequence
<OUString
> aStyleNames
;
1575 aAny
>>= aStyleNames
;
1577 // export only if at least one style is contained
1578 sal_Int32 nNamesCount
= aStyleNames
.getLength();
1579 if (nNamesCount
> 0)
1581 // level attribute; we count 1..10; API 0..9
1582 OUStringBuffer sBuf
;
1583 sal_Int32 nLevelPlusOne
= nLevel
+ 1;
1584 SvXMLUnitConverter::convertNumber(sBuf
, nLevelPlusOne
);
1585 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
1587 sBuf
.makeStringAndClear());
1589 // source styles element
1590 SvXMLElementExport
aParaStyles(GetExport(),
1592 XML_INDEX_SOURCE_STYLES
,
1593 sal_True
, sal_True
);
1595 // iterate over styles in this level
1596 for(sal_Int32 nName
= 0; nName
< nNamesCount
; nName
++)
1598 // stylename attribute
1599 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
1601 GetExport().EncodeStyleName( aStyleNames
[nName
]) );
1604 SvXMLElementExport
aParaStyle(GetExport(),
1606 XML_INDEX_SOURCE_STYLE
,
1607 sal_True
, sal_False
);
1613 void XMLSectionExport::ExportBoolean(
1614 const Reference
<XPropertySet
> & rPropSet
,
1615 const OUString
& sPropertyName
,
1616 enum XMLTokenEnum eAttributeName
,
1620 DBG_ASSERT(eAttributeName
!= XML_TOKEN_INVALID
, "Need attribute name");
1622 Any aAny
= rPropSet
->getPropertyValue(sPropertyName
);
1623 sal_Bool bTmp
= *(sal_Bool
*)aAny
.getValue();
1625 // value = value ^ bInvert
1626 // omit if value == default
1627 // negate forces sal_Bool to 0/1, making them comparable
1628 if ((!(bTmp
^ bInvert
)) != (!bDefault
))
1630 // export non-default value (since default is omitted)
1631 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
1633 bDefault
? XML_FALSE
: XML_TRUE
);
1637 const sal_Char sAPI_FieldMaster_Bibliography
[] =
1638 "com.sun.star.text.FieldMaster.Bibliography";
1639 const sal_Char sAPI_SortKey
[] = "SortKey";
1640 const sal_Char sAPI_IsSortAscending
[] = "IsSortAscending";
1642 void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport
& rExport
)
1644 // first: get field master (via text field supplier)
1645 Reference
<XTextFieldsSupplier
> xTextFieldsSupp( rExport
.GetModel(),
1647 if ( xTextFieldsSupp
.is() )
1649 const OUString
sFieldMaster_Bibliography(
1650 RTL_CONSTASCII_USTRINGPARAM(sAPI_FieldMaster_Bibliography
));
1652 // get bibliography field master
1653 Reference
<XNameAccess
> xMasters
=
1654 xTextFieldsSupp
->getTextFieldMasters();
1655 if ( xMasters
->hasByName(sFieldMaster_Bibliography
) )
1658 xMasters
->getByName(sFieldMaster_Bibliography
);
1659 Reference
<XPropertySet
> xPropSet
;
1662 DBG_ASSERT( xPropSet
.is(), "field master must have XPropSet" );
1664 const OUString
sBracketBefore(
1665 RTL_CONSTASCII_USTRINGPARAM("BracketBefore"));
1666 const OUString
sBracketAfter(
1667 RTL_CONSTASCII_USTRINGPARAM("BracketAfter"));
1668 const OUString
sIsNumberEntries(
1669 RTL_CONSTASCII_USTRINGPARAM("IsNumberEntries"));
1670 const OUString
sIsSortByPosition(
1671 RTL_CONSTASCII_USTRINGPARAM("IsSortByPosition"));
1672 const OUString
sSortKeys(
1673 RTL_CONSTASCII_USTRINGPARAM("SortKeys"));
1674 const OUString
sSortAlgorithm(
1675 RTL_CONSTASCII_USTRINGPARAM("SortAlgorithm"));
1676 const OUString
sLocale(
1677 RTL_CONSTASCII_USTRINGPARAM("Locale"));
1681 aAny
= xPropSet
->getPropertyValue(sBracketBefore
);
1683 rExport
.AddAttribute(XML_NAMESPACE_TEXT
, XML_PREFIX
, sTmp
);
1685 aAny
= xPropSet
->getPropertyValue(sBracketAfter
);
1687 rExport
.AddAttribute(XML_NAMESPACE_TEXT
, XML_SUFFIX
, sTmp
);
1689 aAny
= xPropSet
->getPropertyValue(sIsNumberEntries
);
1690 if (*(sal_Bool
*)aAny
.getValue())
1692 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
1693 XML_NUMBERED_ENTRIES
, XML_TRUE
);
1696 aAny
= xPropSet
->getPropertyValue(sIsSortByPosition
);
1697 if (! *(sal_Bool
*)aAny
.getValue())
1699 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
1700 XML_SORT_BY_POSITION
, XML_FALSE
);
1704 aAny
= xPropSet
->getPropertyValue(sSortAlgorithm
);
1705 OUString sAlgorithm
;
1706 aAny
>>= sAlgorithm
;
1707 if( sAlgorithm
.getLength() > 0 )
1709 rExport
.AddAttribute( XML_NAMESPACE_TEXT
,
1710 XML_SORT_ALGORITHM
, sAlgorithm
);
1714 aAny
= xPropSet
->getPropertyValue(sLocale
);
1717 rExport
.AddAttribute(XML_NAMESPACE_FO
, XML_LANGUAGE
,
1719 rExport
.AddAttribute(XML_NAMESPACE_FO
, XML_COUNTRY
,
1722 // configuration element
1723 SvXMLElementExport
aElement(rExport
, XML_NAMESPACE_TEXT
,
1724 XML_BIBLIOGRAPHY_CONFIGURATION
,
1725 sal_True
, sal_True
);
1728 aAny
= xPropSet
->getPropertyValue(sSortKeys
);
1729 Sequence
<Sequence
<PropertyValue
> > aKeys
;
1731 sal_Int32 nKeysCount
= aKeys
.getLength();
1732 for(sal_Int32 nKeys
= 0; nKeys
< nKeysCount
; nKeys
++)
1734 Sequence
<PropertyValue
> & rKey
= aKeys
[nKeys
];
1736 sal_Int32 nKeyCount
= rKey
.getLength();
1737 for(sal_Int32 nPropertyKey
= 0; nPropertyKey
< nKeyCount
; nPropertyKey
++)
1739 PropertyValue
& rValue
= rKey
[nPropertyKey
];
1741 if (rValue
.Name
.equalsAsciiL(sAPI_SortKey
,
1742 sizeof(sAPI_SortKey
)-1))
1745 rValue
.Value
>>= nKey
;
1746 OUStringBuffer sBuf
;
1747 if (SvXMLUnitConverter::convertEnum( sBuf
, nKey
,
1748 aBibliographyDataFieldMap
) )
1750 rExport
.AddAttribute(XML_NAMESPACE_TEXT
, XML_KEY
,
1751 sBuf
.makeStringAndClear());
1754 else if (rValue
.Name
.equalsAsciiL(sAPI_IsSortAscending
,
1755 sizeof(sAPI_IsSortAscending
)-1))
1757 sal_Bool bTmp
= *(sal_Bool
*)rValue
.Value
.getValue();
1758 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
1760 bTmp
? XML_TRUE
: XML_FALSE
);
1764 SvXMLElementExport
aKeyElem(rExport
,
1765 XML_NAMESPACE_TEXT
, XML_SORT_KEY
,
1766 sal_True
, sal_True
);
1773 sal_Bool
XMLSectionExport::IsMuteSection(
1774 const Reference
<XTextSection
> & rSection
) const
1776 sal_Bool bRet
= sal_False
;
1778 // a section is mute if
1780 // 2) the SaveLinkedSections flag (at the export) is false
1781 // 3) the IsGlobalDocumentSection property is true
1782 // 4) it is not an Index
1784 if ( (!rExport
.IsSaveLinkedSections()) && rSection
.is() )
1786 // walk the section chain and set bRet if any is linked
1787 for(Reference
<XTextSection
> aSection(rSection
);
1789 aSection
= aSection
->getParentSection())
1791 // check if it is a global document section (linked or index)
1792 Reference
<XPropertySet
> xPropSet(aSection
, UNO_QUERY
);
1795 Any aAny
= xPropSet
->getPropertyValue(sIsGlobalDocumentSection
);
1797 if ( *(sal_Bool
*)aAny
.getValue() )
1799 Reference
<XDocumentIndex
> xIndex
;
1800 if (! GetIndex(rSection
, xIndex
))
1804 // early out if result is known
1809 // section has no properties: ignore
1812 // else: no section, or always save sections: default (false)
1817 sal_Bool
XMLSectionExport::IsMuteSection(
1818 const Reference
<XTextContent
> & rSection
,
1819 sal_Bool bDefault
) const
1821 // default: like default argument
1822 sal_Bool bRet
= bDefault
;
1824 Reference
<XPropertySet
> xPropSet(rSection
->getAnchor(), UNO_QUERY
);
1827 if (xPropSet
->getPropertySetInfo()->hasPropertyByName(sTextSection
))
1829 Any aAny
= xPropSet
->getPropertyValue(sTextSection
);
1830 Reference
<XTextSection
> xSection
;
1833 bRet
= IsMuteSection(xSection
);
1835 // else: return default
1837 // else: return default
1842 sal_Bool
XMLSectionExport::IsInSection(
1843 const Reference
<XTextSection
> & rEnclosingSection
,
1844 const Reference
<XTextContent
> & rContent
,
1847 // default: like default argument
1848 sal_Bool bRet
= bDefault
;
1849 DBG_ASSERT(rEnclosingSection
.is(), "enclosing section expected");
1851 Reference
<XPropertySet
> xPropSet(rContent
, UNO_QUERY
);
1854 if (xPropSet
->getPropertySetInfo()->hasPropertyByName(sTextSection
))
1856 Any aAny
= xPropSet
->getPropertyValue(sTextSection
);
1857 Reference
<XTextSection
> xSection
;
1860 // now walk chain of text sections (if we have one)
1865 bRet
= (rEnclosingSection
== xSection
);
1866 xSection
= xSection
->getParentSection();
1868 while (!bRet
&& xSection
.is());
1871 bRet
= sal_False
; // no section -> can't be inside
1873 // else: no TextSection property -> return default
1875 // else: no XPropertySet -> return default
1881 void XMLSectionExport::ExportMasterDocHeadingDummies()
1883 if( bHeadingDummiesExported
)
1886 Reference
< XChapterNumberingSupplier
> xCNSupplier( rExport
.GetModel(),
1889 Reference
< XIndexReplace
> xChapterNumbering
;
1890 if( xCNSupplier
.is() )
1891 xChapterNumbering
= xCNSupplier
->getChapterNumberingRules();
1893 if( !xChapterNumbering
.is() )
1896 sal_Int32 nCount
= xChapterNumbering
->getCount();
1897 for( sal_Int32 nLevel
= 0; nLevel
< nCount
; nLevel
++ )
1900 Sequence
<PropertyValue
> aProperties
;
1901 xChapterNumbering
->getByIndex( nLevel
) >>= aProperties
;
1902 for( sal_Int32 i
= 0; i
< aProperties
.getLength(); i
++ )
1904 if( aProperties
[i
].Name
== sHeadingStyleName
)
1906 aProperties
[i
].Value
>>= sStyle
;
1910 if( sStyle
.getLength() > 0 )
1912 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
1913 GetExport().EncodeStyleName( sStyle
) );
1915 OUStringBuffer sTmp
;
1916 sTmp
.append( nLevel
+ 1 );
1917 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_LEVEL
,
1918 sTmp
.makeStringAndClear() );
1919 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, XML_H
,
1920 sal_True
, sal_False
);
1924 bHeadingDummiesExported
= sal_True
;