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