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