LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/text - txtparae.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1102 1855 59.4 %
Date: 2013-07-09 Functions: 67 82 81.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
      21             : #include <tools/debug.hxx>
      22             : #include <rtl/ustrbuf.hxx>
      23             : #include <sal/types.h>
      24             : 
      25             : #include <vector>
      26             : #include <list>
      27             : #include <boost/unordered_map.hpp>
      28             : 
      29             : #include <com/sun/star/lang/XServiceInfo.hpp>
      30             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      31             : #include <com/sun/star/container/XEnumeration.hpp>
      32             : #include <com/sun/star/container/XIndexReplace.hpp>
      33             : #include <com/sun/star/beans/XPropertySet.hpp>
      34             : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      35             : #include <com/sun/star/beans/XPropertyState.hpp>
      36             : #include <com/sun/star/text/XTextDocument.hpp>
      37             : #include <com/sun/star/text/XTextSectionsSupplier.hpp>
      38             : #include <com/sun/star/text/XTextTablesSupplier.hpp>
      39             : #include <com/sun/star/text/XNumberingRulesSupplier.hpp>
      40             : #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
      41             : #include <com/sun/star/text/XTextTable.hpp>
      42             : #include <com/sun/star/text/XText.hpp>
      43             : #include <com/sun/star/text/XTextContent.hpp>
      44             : #include <com/sun/star/text/XTextRange.hpp>
      45             : #include <com/sun/star/text/XTextField.hpp>
      46             : #include <com/sun/star/text/XFootnote.hpp>
      47             : #include <com/sun/star/container/XNamed.hpp>
      48             : #include <com/sun/star/container/XContentEnumerationAccess.hpp>
      49             : #include <com/sun/star/text/XTextFrame.hpp>
      50             : #include <com/sun/star/container/XNameAccess.hpp>
      51             : #include <com/sun/star/text/SizeType.hpp>
      52             : #include <com/sun/star/text/HoriOrientation.hpp>
      53             : #include <com/sun/star/text/VertOrientation.hpp>
      54             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      55             : #include <com/sun/star/text/XTextFramesSupplier.hpp>
      56             : #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
      57             : #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
      58             : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      59             : #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
      60             : #include <com/sun/star/document/XEventsSupplier.hpp>
      61             : #include <com/sun/star/document/XRedlinesSupplier.hpp>
      62             : 
      63             : #include <com/sun/star/text/XBookmarksSupplier.hpp>
      64             : #include <com/sun/star/text/XFormField.hpp>
      65             : 
      66             : #include <com/sun/star/text/XTextSection.hpp>
      67             : #include <com/sun/star/text/SectionFileLink.hpp>
      68             : #include <com/sun/star/drawing/XShape.hpp>
      69             : #include <com/sun/star/text/XTextShapesSupplier.hpp>
      70             : 
      71             : #include <com/sun/star/style/XAutoStylesSupplier.hpp>
      72             : #include <com/sun/star/style/XAutoStyleFamily.hpp>
      73             : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
      74             : #include <com/sun/star/text/XFootnotesSupplier.hpp>
      75             : #include <com/sun/star/text/XEndnotesSupplier.hpp>
      76             : #include <com/sun/star/drawing/XControlShape.hpp>
      77             : #include <com/sun/star/util/DateTime.hpp>
      78             : 
      79             : #include <sax/tools/converter.hxx>
      80             : 
      81             : #include "xmloff/xmlnmspe.hxx"
      82             : #include <xmloff/xmlaustp.hxx>
      83             : #include <xmloff/families.hxx>
      84             : #include "txtexppr.hxx"
      85             : #include <xmloff/xmlnumfe.hxx>
      86             : #include <xmloff/xmlnume.hxx>
      87             : #include <xmloff/xmluconv.hxx>
      88             : #include "XMLAnchorTypePropHdl.hxx"
      89             : #include "xexptran.hxx"
      90             : #include <xmloff/ProgressBarHelper.hxx>
      91             : #include <xmloff/nmspmap.hxx>
      92             : #include <xmloff/xmlexp.hxx>
      93             : #include "txtflde.hxx"
      94             : #include <xmloff/txtprmap.hxx>
      95             : #include "XMLImageMapExport.hxx"
      96             : #include "XMLTextNumRuleInfo.hxx"
      97             : #include "xmloff/XMLTextListAutoStylePool.hxx"
      98             : #include <xmloff/txtparae.hxx>
      99             : #include "XMLSectionExport.hxx"
     100             : #include "XMLIndexMarkExport.hxx"
     101             : #include <xmloff/XMLEventExport.hxx>
     102             : #include "XMLRedlineExport.hxx"
     103             : #include "MultiPropertySetHelper.hxx"
     104             : #include <xmloff/formlayerexport.hxx>
     105             : #include "XMLTextCharStyleNamesElementExport.hxx"
     106             : #include <comphelper/stlunosequence.hxx>
     107             : 
     108             : #include <xmloff/odffields.hxx>
     109             : #include <com/sun/star/embed/ElementModes.hpp>
     110             : #include <com/sun/star/embed/XTransactedObject.hpp>
     111             : #include <com/sun/star/document/XStorageBasedDocument.hpp>
     112             : #include <txtlists.hxx>
     113             : #include <com/sun/star/rdf/XMetadatable.hpp>
     114             : 
     115             : 
     116             : using namespace ::std;
     117             : using namespace ::com::sun::star;
     118             : using namespace ::com::sun::star::uno;
     119             : using namespace ::com::sun::star::lang;
     120             : using namespace ::com::sun::star::beans;
     121             : using namespace ::com::sun::star::container;
     122             : using namespace ::com::sun::star::text;
     123             : using namespace ::com::sun::star::style;
     124             : using namespace ::com::sun::star::util;
     125             : using namespace ::com::sun::star::drawing;
     126             : using namespace ::com::sun::star::document;
     127             : using namespace ::com::sun::star::frame;
     128             : using namespace ::xmloff;
     129             : using namespace ::xmloff::token;
     130             : 
     131             : namespace
     132             : {
     133         960 :     class TextContentSet
     134             :     {
     135             :         public:
     136             :             typedef Reference<XTextContent> text_content_ref_t;
     137             :             typedef list<text_content_ref_t> contents_t;
     138             :             typedef back_insert_iterator<contents_t> inserter_t;
     139             :             typedef contents_t::const_iterator const_iterator_t;
     140             : 
     141           0 :             inserter_t getInserter()
     142           0 :                 { return back_insert_iterator<contents_t>(m_vTextContents); };
     143          64 :             const_iterator_t getBegin() const
     144          64 :                 { return m_vTextContents.begin(); };
     145          64 :             const_iterator_t getEnd() const
     146          64 :                 { return m_vTextContents.end(); };
     147             : 
     148             :         private:
     149             :             contents_t m_vTextContents;
     150             :     };
     151             : 
     152             :     struct FrameRefHash
     153             :         : public unary_function<Reference<XTextFrame>, size_t>
     154             :     {
     155           8 :         size_t operator()(const Reference<XTextFrame> xFrame) const
     156           8 :             { return sal::static_int_cast<size_t>(reinterpret_cast<sal_uIntPtr>(xFrame.get())); }
     157             :     };
     158             : 
     159           0 :     static bool lcl_TextContentsUnfiltered(const Reference<XTextContent>&)
     160           0 :         { return true; };
     161             : 
     162           0 :     static bool lcl_ShapeFilter(const Reference<XTextContent>& xTxtContent)
     163             :     {
     164           0 :         static const OUString sTextFrameService("com.sun.star.text.TextFrame");
     165           0 :         static const OUString sTextGraphicService("com.sun.star.text.TextGraphicObject");
     166           0 :         static const OUString sTextEmbeddedService("com.sun.star.text.TextEmbeddedObject");
     167           0 :         Reference<XShape> xShape(xTxtContent, UNO_QUERY);
     168           0 :         if(!xShape.is())
     169           0 :             return false;
     170           0 :         Reference<XServiceInfo> xServiceInfo(xTxtContent, UNO_QUERY);
     171           0 :         if(xServiceInfo->supportsService(sTextFrameService) ||
     172           0 :             xServiceInfo->supportsService(sTextGraphicService) ||
     173           0 :             xServiceInfo->supportsService(sTextEmbeddedService) )
     174           0 :             return false;
     175           0 :         return true;
     176             :     };
     177             : 
     178         480 :     class BoundFrames
     179             :     {
     180             :         public:
     181             :             typedef bool (*filter_t)(const Reference<XTextContent>&);
     182         128 :             BoundFrames(
     183             :                 const Reference<XEnumerationAccess> xEnumAccess,
     184             :                 const filter_t& rFilter)
     185         128 :                 : m_xEnumAccess(xEnumAccess)
     186             :             {
     187         128 :                 Fill(rFilter);
     188         128 :             };
     189         352 :             BoundFrames()
     190         352 :                 {};
     191          64 :             const TextContentSet* GetPageBoundContents() const
     192          64 :                 { return &m_vPageBounds; };
     193           8 :             const TextContentSet* GetFrameBoundContents(const Reference<XTextFrame>& rParentFrame) const
     194             :             {
     195           8 :                 framebound_map_t::const_iterator it = m_vFrameBoundsOf.find(rParentFrame);
     196           8 :                 if(it == m_vFrameBoundsOf.end())
     197           8 :                     return NULL;
     198           0 :                 return &(it->second);
     199             :             };
     200          80 :             Reference<XEnumeration> createEnumeration() const
     201             :             {
     202          80 :                 if(!m_xEnumAccess.is())
     203           0 :                     return Reference<XEnumeration>();
     204          80 :                 return m_xEnumAccess->createEnumeration();
     205             :             };
     206             : 
     207             :         private:
     208             :             typedef boost::unordered_map<
     209             :                 Reference<XTextFrame>,
     210             :                 TextContentSet,
     211             :                 FrameRefHash> framebound_map_t;
     212             :             TextContentSet m_vPageBounds;
     213             :             framebound_map_t m_vFrameBoundsOf;
     214             :             const Reference<XEnumerationAccess> m_xEnumAccess;
     215             :             void Fill(const filter_t& rFilter);
     216             :     };
     217             : 
     218           0 :     class FieldParamExporter
     219             :     {
     220             :         public:
     221           0 :             FieldParamExporter(SvXMLExport* const pExport, Reference<XNameContainer> xFieldParams)
     222             :                 : m_pExport(pExport)
     223           0 :                 , m_xFieldParams(xFieldParams)
     224           0 :                 { };
     225             :             void Export();
     226             : 
     227             :         private:
     228             :             SvXMLExport* const m_pExport;
     229             :             const Reference<XNameContainer> m_xFieldParams;
     230             : 
     231             :             void ExportParameter(const OUString& sKey, const OUString& sValue);
     232             :     };
     233             : }
     234             : 
     235             : namespace xmloff
     236             : {
     237          88 :     class BoundFrameSets
     238             :     {
     239             :         public:
     240             :             BoundFrameSets(const Reference<XInterface> xModel);
     241          34 :             const BoundFrames* GetTexts() const
     242          34 :                 { return m_pTexts.get(); };
     243          34 :             const BoundFrames* GetGraphics() const
     244          34 :                 { return m_pGraphics.get(); };
     245          34 :             const BoundFrames* GetEmbeddeds() const
     246          34 :                 { return m_pEmbeddeds.get(); };
     247          50 :             const BoundFrames* GetShapes() const
     248          50 :                 { return m_pShapes.get(); };
     249             :         private:
     250             :             SAL_WNODEPRECATED_DECLARATIONS_PUSH
     251             :             auto_ptr<BoundFrames> m_pTexts;
     252             :             auto_ptr<BoundFrames> m_pGraphics;
     253             :             auto_ptr<BoundFrames> m_pEmbeddeds;
     254             :             auto_ptr<BoundFrames> m_pShapes;
     255             :             SAL_WNODEPRECATED_DECLARATIONS_POP
     256             :     };
     257             : }
     258             : 
     259             : #ifdef DBG_UTIL
     260             : static int txtparae_bContainsIllegalCharacters = sal_False;
     261             : #endif
     262             : 
     263             : // The following map shows which property values are required:
     264             : //
     265             : // property                     auto style pass     export
     266             : // --------------------------------------------------------
     267             : // ParaStyleName                if style exists     always
     268             : // ParaConditionalStyleName     if style exists     always
     269             : // NumberingRules               if style exists     always
     270             : // TextSection                  always              always
     271             : // ParaChapterNumberingLevel    never               always
     272             : // NumberingIsNumber            never               always
     273             : 
     274             : // The conclusion is that for auto styles the first three properties
     275             : // should be queried using a multi property set if, and only if, an
     276             : // auto style needs to be exported. TextSection should be queried by
     277             : // an individual call to getPropertyvalue, because this seems to be
     278             : // less expensive than querying the first three properties if they aren't
     279             : // required.
     280             : 
     281             : // For the export pass all properties can be queried using a multi property
     282             : // set.
     283             : 
     284             : static const sal_Char* aParagraphPropertyNamesAuto[] =
     285             : {
     286             :     "NumberingRules",
     287             :     "ParaConditionalStyleName",
     288             :     "ParaStyleName",
     289             :     NULL
     290             : };
     291             : 
     292             : enum eParagraphPropertyNamesEnumAuto
     293             : {
     294             :     NUMBERING_RULES_AUTO = 0,
     295             :     PARA_CONDITIONAL_STYLE_NAME_AUTO = 1,
     296             :     PARA_STYLE_NAME_AUTO = 2
     297             : };
     298             : 
     299             : static const sal_Char* aParagraphPropertyNames[] =
     300             : {
     301             :     "NumberingIsNumber",
     302             :     "NumberingStyleName",
     303             :     "OutlineLevel",
     304             :     "ParaConditionalStyleName",
     305             :     "ParaStyleName",
     306             :     "TextSection",
     307             :     NULL
     308             : };
     309             : 
     310             : enum eParagraphPropertyNamesEnum
     311             : {
     312             :     NUMBERING_IS_NUMBER = 0,
     313             :     PARA_NUMBERING_STYLENAME = 1,
     314             :     PARA_OUTLINE_LEVEL=2,
     315             :     PARA_CONDITIONAL_STYLE_NAME = 3,
     316             :     PARA_STYLE_NAME = 4,
     317             :     TEXT_SECTION = 5
     318             : };
     319             : 
     320         128 : void BoundFrames::Fill(const filter_t& rFilter)
     321             : {
     322         128 :     if(!m_xEnumAccess.is())
     323           0 :         return;
     324         128 :     const Reference< XEnumeration > xEnum = m_xEnumAccess->createEnumeration();
     325         128 :     if(!xEnum.is())
     326           0 :         return;
     327         256 :     const OUString our_sAnchorType("AnchorType");
     328         256 :     const OUString our_sAnchorFrame("AnchorFrame");
     329         296 :     while(xEnum->hasMoreElements())
     330             :     {
     331          40 :         Reference<XPropertySet> xPropSet(xEnum->nextElement(), UNO_QUERY);
     332          40 :         Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY);
     333          40 :         if(!xPropSet.is() || !xTextContent.is())
     334           0 :             continue;
     335             :         TextContentAnchorType eAnchor;
     336          40 :         xPropSet->getPropertyValue(our_sAnchorType) >>= eAnchor;
     337          40 :         if(TextContentAnchorType_AT_PAGE != eAnchor && TextContentAnchorType_AT_FRAME != eAnchor)
     338          40 :             continue;
     339           0 :         if(!rFilter(xTextContent))
     340           0 :             continue;
     341             : 
     342           0 :         TextContentSet::inserter_t pInserter = m_vPageBounds.getInserter();
     343           0 :         if(TextContentAnchorType_AT_FRAME == eAnchor)
     344             :         {
     345             :             Reference<XTextFrame> xAnchorTxtFrame(
     346           0 :                 xPropSet->getPropertyValue(our_sAnchorFrame),
     347           0 :                 uno::UNO_QUERY);
     348           0 :             pInserter = m_vFrameBoundsOf[xAnchorTxtFrame].getInserter();
     349             :         }
     350           0 :         *pInserter++ = xTextContent;
     351         128 :     }
     352             : }
     353             : 
     354          88 : BoundFrameSets::BoundFrameSets(const Reference<XInterface> xModel)
     355           0 :     : m_pTexts(new BoundFrames())
     356           0 :     , m_pGraphics(new BoundFrames())
     357           0 :     , m_pEmbeddeds(new BoundFrames())
     358          88 :     , m_pShapes(new BoundFrames())
     359             : {
     360          88 :     const Reference<XTextFramesSupplier> xTFS(xModel, UNO_QUERY);
     361         176 :     const Reference<XTextGraphicObjectsSupplier> xGOS(xModel, UNO_QUERY);
     362         176 :     const Reference<XTextEmbeddedObjectsSupplier> xEOS(xModel, UNO_QUERY);
     363         176 :     const Reference<XDrawPageSupplier> xDPS(xModel, UNO_QUERY);
     364          88 :     if(xTFS.is())
     365          96 :         m_pTexts = auto_ptr<BoundFrames>(new BoundFrames(
     366          32 :             Reference<XEnumerationAccess>(xTFS->getTextFrames(), UNO_QUERY),
     367          64 :             &lcl_TextContentsUnfiltered));
     368          88 :     if(xGOS.is())
     369          96 :         m_pGraphics = auto_ptr<BoundFrames>(new BoundFrames(
     370          32 :             Reference<XEnumerationAccess>(xGOS->getGraphicObjects(), UNO_QUERY),
     371          64 :             &lcl_TextContentsUnfiltered));
     372          88 :     if(xEOS.is())
     373          96 :         m_pEmbeddeds = auto_ptr<BoundFrames>(new BoundFrames(
     374          32 :             Reference<XEnumerationAccess>(xEOS->getEmbeddedObjects(), UNO_QUERY),
     375          64 :             &lcl_TextContentsUnfiltered));
     376          88 :     if(xDPS.is())
     377          96 :         m_pShapes = auto_ptr<BoundFrames>(new BoundFrames(
     378          32 :             Reference<XEnumerationAccess>(xDPS->getDrawPage(), UNO_QUERY),
     379         152 :             &lcl_ShapeFilter));
     380          88 : };
     381             : 
     382           0 : void FieldParamExporter::Export()
     383             : {
     384           0 :     const Type aStringType = ::getCppuType((OUString*)0);
     385           0 :     const Type aBoolType = ::getCppuType((sal_Bool*)0);
     386           0 :     const Type aSeqType = ::getCppuType((Sequence<OUString>*)0);
     387           0 :     const Type aIntType = ::getCppuType((sal_Int32*)0);
     388           0 :     Sequence<OUString> vParameters(m_xFieldParams->getElementNames());
     389           0 :     for(const OUString* pCurrent=::comphelper::stl_begin(vParameters); pCurrent!=::comphelper::stl_end(vParameters); ++pCurrent)
     390             :     {
     391           0 :         const Any aValue = m_xFieldParams->getByName(*pCurrent);
     392           0 :         const Type aValueType = aValue.getValueType();
     393           0 :         if(aValueType == aStringType)
     394             :         {
     395           0 :             OUString sValue;
     396           0 :             aValue >>= sValue;
     397           0 :             ExportParameter(*pCurrent,sValue);
     398             : 
     399           0 :             if ( pCurrent->equalsAscii( ODF_OLE_PARAM ) )
     400             :             {
     401             :                 // Save the OLE object
     402           0 :                 Reference< embed::XStorage > xTargetStg = m_pExport->GetTargetStorage();
     403           0 :                 Reference< embed::XStorage > xDstStg = xTargetStg->openStorageElement(
     404           0 :                         OUString("OLELinks"), embed::ElementModes::WRITE );
     405             : 
     406           0 :                 if ( !xDstStg->hasByName( sValue ) ) {
     407             :                     Reference< XStorageBasedDocument > xStgDoc (
     408           0 :                             m_pExport->GetModel( ), UNO_QUERY );
     409           0 :                     Reference< embed::XStorage > xDocStg = xStgDoc->getDocumentStorage();
     410           0 :                     Reference< embed::XStorage > xOleStg = xDocStg->openStorageElement(
     411           0 :                             OUString("OLELinks"), embed::ElementModes::READ );
     412             : 
     413           0 :                     xOleStg->copyElementTo( sValue, xDstStg, sValue );
     414           0 :                     Reference< embed::XTransactedObject > xTransact( xDstStg, UNO_QUERY );
     415           0 :                     if ( xTransact.is( ) )
     416           0 :                         xTransact->commit( );
     417           0 :                 }
     418           0 :             }
     419             :         }
     420           0 :         else if(aValueType == aBoolType)
     421             :         {
     422           0 :             sal_Bool bValue = false;
     423           0 :             aValue >>= bValue;
     424           0 :             ExportParameter(*pCurrent, (bValue ? OUString("true" ) : OUString("false")) );
     425             :         }
     426           0 :         else if(aValueType == aSeqType)
     427             :         {
     428           0 :             Sequence<OUString> vValue;
     429           0 :             aValue >>= vValue;
     430           0 :             for(OUString* pSeqCurrent = ::comphelper::stl_begin(vValue); pSeqCurrent != ::comphelper::stl_end(vValue); ++pSeqCurrent)
     431             :             {
     432           0 :                 ExportParameter(*pCurrent, *pSeqCurrent);
     433           0 :             }
     434             :         }
     435           0 :         else if(aValueType == aIntType)
     436             :         {
     437           0 :             sal_Int32 nValue = 0;
     438           0 :             aValue >>= nValue;
     439           0 :             ExportParameter(*pCurrent, OUStringBuffer().append(nValue).makeStringAndClear());
     440             :         }
     441           0 :     }
     442           0 : }
     443             : 
     444           0 : void FieldParamExporter::ExportParameter(const OUString& sKey, const OUString& sValue)
     445             : {
     446           0 :     m_pExport->AddAttribute(XML_NAMESPACE_FIELD, XML_NAME, sKey);
     447           0 :     m_pExport->AddAttribute(XML_NAMESPACE_FIELD, XML_VALUE, sValue);
     448           0 :     m_pExport->StartElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
     449           0 :     m_pExport->EndElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
     450           0 : }
     451             : 
     452         368 : void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
     453             :                                   const Reference < XPropertySet > & rPropSet,
     454             :                                   const XMLPropertyState** ppAddStates, bool bDontSeek )
     455             : {
     456         368 :     UniReference < SvXMLExportPropertyMapper > xPropMapper;
     457         368 :     switch( nFamily )
     458             :     {
     459             :     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     460          10 :         xPropMapper = GetParaPropMapper();
     461          10 :         break;
     462             :     case XML_STYLE_FAMILY_TEXT_TEXT:
     463         329 :         xPropMapper = GetTextPropMapper();
     464         329 :         break;
     465             :     case XML_STYLE_FAMILY_TEXT_FRAME:
     466          10 :         xPropMapper = GetAutoFramePropMapper();
     467          10 :         break;
     468             :     case XML_STYLE_FAMILY_TEXT_SECTION:
     469          18 :         xPropMapper = GetSectionPropMapper();
     470          18 :         break;
     471             :     case XML_STYLE_FAMILY_TEXT_RUBY:
     472           1 :         xPropMapper = GetRubyPropMapper();
     473           1 :         break;
     474             :     }
     475             :     DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
     476             : 
     477             :     vector< XMLPropertyState > xPropStates =
     478         368 :             xPropMapper->Filter( rPropSet );
     479             : 
     480         368 :     if( ppAddStates )
     481             :     {
     482          42 :         while( *ppAddStates )
     483             :         {
     484          26 :             xPropStates.push_back( **ppAddStates );
     485          26 :             ppAddStates++;
     486             :         }
     487             :     }
     488             : 
     489         368 :     if( !xPropStates.empty() )
     490             :     {
     491          40 :         Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo());
     492          80 :         OUString sParent, sCondParent;
     493          40 :         sal_uInt16 nIgnoreProps = 0;
     494          40 :         switch( nFamily )
     495             :         {
     496             :         case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     497          10 :             if( xPropSetInfo->hasPropertyByName( sParaStyleName ) )
     498             :             {
     499          10 :                 rPropSet->getPropertyValue( sParaStyleName ) >>= sParent;
     500             :             }
     501          10 :             if( xPropSetInfo->hasPropertyByName( sParaConditionalStyleName ) )
     502             :             {
     503          10 :                 rPropSet->getPropertyValue( sParaConditionalStyleName ) >>= sCondParent;
     504             :             }
     505          10 :             if( xPropSetInfo->hasPropertyByName( sNumberingRules ) )
     506             :             {
     507           0 :                 Reference < XIndexReplace > xNumRule(rPropSet->getPropertyValue( sNumberingRules ), uno::UNO_QUERY);
     508           0 :                 if( xNumRule.is() && xNumRule->getCount() )
     509             :                 {
     510           0 :                     Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
     511           0 :                     OUString sName;
     512           0 :                     if( xNamed.is() )
     513           0 :                         sName = xNamed->getName();
     514           0 :                     sal_Bool bAdd = sName.isEmpty();
     515           0 :                     if( !bAdd )
     516             :                     {
     517             :                         Reference < XPropertySet > xNumPropSet( xNumRule,
     518           0 :                                                                 UNO_QUERY );
     519           0 :                         const OUString sIsAutomatic( "IsAutomatic"  );
     520           0 :                         if( xNumPropSet.is() &&
     521           0 :                             xNumPropSet->getPropertySetInfo()
     522           0 :                                        ->hasPropertyByName( sIsAutomatic ) )
     523             :                         {
     524           0 :                             bAdd = *(sal_Bool *)xNumPropSet->getPropertyValue( sIsAutomatic ).getValue();
     525             :                             // Check on outline style (#i73361#)
     526           0 :                             const OUString sNumberingIsOutline( "NumberingIsOutline"  );
     527           0 :                             if ( bAdd &&
     528           0 :                                  xNumPropSet->getPropertySetInfo()
     529           0 :                                            ->hasPropertyByName( sNumberingIsOutline ) )
     530             :                             {
     531           0 :                                 bAdd = !(*(sal_Bool *)xNumPropSet->getPropertyValue( sNumberingIsOutline ).getValue());
     532           0 :                             }
     533             :                         }
     534             :                         else
     535             :                         {
     536           0 :                             bAdd = sal_True;
     537           0 :                         }
     538             :                     }
     539           0 :                     if( bAdd )
     540           0 :                         pListAutoPool->Add( xNumRule );
     541           0 :                 }
     542             :             }
     543          10 :             break;
     544             :         case XML_STYLE_FAMILY_TEXT_TEXT:
     545             :             {
     546             :                 // Get parent and remove hyperlinks (they aren't of interest)
     547           1 :                 UniReference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper());
     548           7 :                 for( ::std::vector< XMLPropertyState >::iterator i(xPropStates.begin());
     549           9 :                       nIgnoreProps < 2 && i != xPropStates.end(); )
     550             :                 {
     551           2 :                     if( i->mnIndex == -1 )
     552             :                     {
     553           0 :                         ++i;
     554           0 :                         continue;
     555             :                     }
     556             : 
     557           2 :                     switch( xPM->GetEntryContextId(i->mnIndex) )
     558             :                     {
     559             :                     case CTF_CHAR_STYLE_NAME:
     560             :                     case CTF_HYPERLINK_URL:
     561           0 :                         i->mnIndex = -1;
     562           0 :                         nIgnoreProps++;
     563           0 :                         i = xPropStates.erase( i );
     564           0 :                         break;
     565             :                     default:
     566           2 :                         ++i;
     567           2 :                         break;
     568             :                     }
     569           1 :                 }
     570             :             }
     571           1 :             break;
     572             :         case XML_STYLE_FAMILY_TEXT_FRAME:
     573          10 :             if( xPropSetInfo->hasPropertyByName( sFrameStyleName ) )
     574             :             {
     575          10 :                 rPropSet->getPropertyValue( sFrameStyleName ) >>= sParent;
     576             :             }
     577          10 :             break;
     578             :         case XML_STYLE_FAMILY_TEXT_SECTION:
     579             :         case XML_STYLE_FAMILY_TEXT_RUBY:
     580             :             ; // section styles have no parents
     581          19 :             break;
     582             :         }
     583          40 :         if( (xPropStates.size() - nIgnoreProps) > 0 )
     584             :         {
     585          40 :             GetAutoStylePool().Add( nFamily, sParent, xPropStates, bDontSeek );
     586          40 :             if( !sCondParent.isEmpty() && sParent != sCondParent )
     587           0 :                 GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
     588          40 :         }
     589         368 :     }
     590         368 : }
     591             : 
     592         125 : static bool lcl_validPropState( const XMLPropertyState& rState )
     593             : {
     594         125 :     return rState.mnIndex != -1;
     595             : }
     596             : 
     597          36 : void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
     598             :                                   MultiPropertySetHelper& rPropSetHelper,
     599             :                                   const Reference < XPropertySet > & rPropSet,
     600             :                                   const XMLPropertyState** ppAddStates)
     601             : {
     602          36 :     UniReference < SvXMLExportPropertyMapper > xPropMapper;
     603          36 :     switch( nFamily )
     604             :     {
     605             :     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     606          36 :         xPropMapper = GetParaPropMapper();
     607          36 :         break;
     608             :     }
     609             :     DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
     610             : 
     611          36 :     vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet ));
     612          36 :     if( ppAddStates )
     613             :     {
     614           0 :         while( *ppAddStates )
     615             :         {
     616           0 :             xPropStates.push_back( **ppAddStates );
     617           0 :             ++ppAddStates;
     618             :         }
     619             :     }
     620             : 
     621          36 :     if( rPropSetHelper.hasProperty( NUMBERING_RULES_AUTO ) )
     622             :     {
     623             :         Reference < XIndexReplace > xNumRule(rPropSetHelper.getValue( NUMBERING_RULES_AUTO,
     624          36 :             rPropSet, sal_True ), uno::UNO_QUERY);
     625          36 :         if( xNumRule.is() && xNumRule->getCount() )
     626             :         {
     627          24 :             Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
     628          48 :             OUString sName;
     629          24 :             if( xNamed.is() )
     630           0 :                 sName = xNamed->getName();
     631          24 :             sal_Bool bAdd = sName.isEmpty();
     632          24 :             if( !bAdd )
     633             :             {
     634             :                 Reference < XPropertySet > xNumPropSet( xNumRule,
     635           0 :                                                         UNO_QUERY );
     636           0 :                 const OUString sIsAutomatic( "IsAutomatic"  );
     637           0 :                 if( xNumPropSet.is() &&
     638           0 :                     xNumPropSet->getPropertySetInfo()
     639           0 :                                ->hasPropertyByName( sIsAutomatic ) )
     640             :                 {
     641           0 :                     bAdd = *(sal_Bool *)xNumPropSet->getPropertyValue( sIsAutomatic ).getValue();
     642             :                     // Check on outline style (#i73361#)
     643           0 :                     const OUString sNumberingIsOutline( "NumberingIsOutline"  );
     644           0 :                     if ( bAdd &&
     645           0 :                          xNumPropSet->getPropertySetInfo()
     646           0 :                                    ->hasPropertyByName( sNumberingIsOutline ) )
     647             :                     {
     648           0 :                         bAdd = !(*(sal_Bool *)xNumPropSet->getPropertyValue( sNumberingIsOutline ).getValue());
     649           0 :                     }
     650             :                 }
     651             :                 else
     652             :                 {
     653           0 :                     bAdd = sal_True;
     654           0 :                 }
     655             :             }
     656          24 :             if( bAdd )
     657          48 :                 pListAutoPool->Add( xNumRule );
     658          36 :         }
     659             :     }
     660             : 
     661          36 :     if( !xPropStates.empty() )
     662             :     {
     663          44 :         OUString sParent, sCondParent;
     664          22 :         switch( nFamily )
     665             :         {
     666             :         case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     667          22 :             if( rPropSetHelper.hasProperty( PARA_STYLE_NAME_AUTO ) )
     668             :             {
     669             :                 rPropSetHelper.getValue( PARA_STYLE_NAME_AUTO, rPropSet,
     670           0 :                                                 sal_True ) >>= sParent;
     671             :             }
     672          22 :             if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO ) )
     673             :             {
     674             :                 rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO,
     675           0 :                                                  rPropSet, sal_True ) >>= sCondParent;
     676             :             }
     677             : 
     678          22 :             break;
     679             :         }
     680             : 
     681          22 :         if( find_if( xPropStates.begin(), xPropStates.end(), lcl_validPropState ) != xPropStates.end() )
     682             :         {
     683          22 :             GetAutoStylePool().Add( nFamily, sParent, xPropStates );
     684          22 :             if( !sCondParent.isEmpty() && sParent != sCondParent )
     685           0 :                 GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
     686          22 :         }
     687          36 :     }
     688          36 : }
     689             : 
     690         185 : OUString XMLTextParagraphExport::Find(
     691             :         sal_uInt16 nFamily,
     692             :            const Reference < XPropertySet > & rPropSet,
     693             :         const OUString& rParent,
     694             :         const XMLPropertyState** ppAddStates) const
     695             : {
     696         185 :     OUString sName( rParent );
     697         370 :     UniReference < SvXMLExportPropertyMapper > xPropMapper;
     698         185 :     switch( nFamily )
     699             :     {
     700             :     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     701         151 :         xPropMapper = GetParaPropMapper();
     702         151 :         break;
     703             :     case XML_STYLE_FAMILY_TEXT_FRAME:
     704          10 :         xPropMapper = GetAutoFramePropMapper();
     705          10 :         break;
     706             :     case XML_STYLE_FAMILY_TEXT_SECTION:
     707          18 :         xPropMapper = GetSectionPropMapper();
     708          18 :         break;
     709             :     case XML_STYLE_FAMILY_TEXT_RUBY:
     710           6 :         xPropMapper = GetRubyPropMapper();
     711           6 :         break;
     712             :     }
     713             :     DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
     714         185 :     if( !xPropMapper.is() )
     715           0 :         return sName;
     716         185 :     vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet ));
     717         185 :     if( ppAddStates )
     718             :     {
     719          42 :         while( *ppAddStates )
     720             :         {
     721          26 :             xPropStates.push_back( **ppAddStates );
     722          26 :             ++ppAddStates;
     723             :         }
     724             :     }
     725         185 :     if( find_if( xPropStates.begin(), xPropStates.end(), lcl_validPropState ) != xPropStates.end() )
     726         102 :         sName = GetAutoStylePool().Find( nFamily, sName, xPropStates );
     727             : 
     728         185 :     return sName;
     729             : }
     730             : 
     731        2096 : OUString XMLTextParagraphExport::FindTextStyleAndHyperlink(
     732             :            const Reference < XPropertySet > & rPropSet,
     733             :         sal_Bool& rbHyperlink,
     734             :         sal_Bool& rbHasCharStyle,
     735             :         sal_Bool& rbHasAutoStyle,
     736             :         const XMLPropertyState** ppAddStates ) const
     737             : {
     738        2096 :     UniReference < SvXMLExportPropertyMapper > xPropMapper(GetTextPropMapper());
     739        4192 :     vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet ));
     740             : 
     741             :     // Get parent and remove hyperlinks (they aren't of interest)
     742        2096 :     OUString sName;
     743        2096 :     rbHyperlink = rbHasCharStyle = rbHasAutoStyle = sal_False;
     744        2096 :     sal_uInt16 nIgnoreProps = 0;
     745        4192 :     UniReference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper());
     746        2096 :     ::std::vector< XMLPropertyState >::iterator aFirstDel = xPropStates.end();
     747        2096 :     ::std::vector< XMLPropertyState >::iterator aSecondDel = xPropStates.end();
     748             : 
     749        6312 :     for( ::std::vector< XMLPropertyState >::iterator
     750        2096 :             i = xPropStates.begin();
     751        6312 :          nIgnoreProps < 2 && i != xPropStates.end();
     752             :          ++i )
     753             :     {
     754           8 :         if( i->mnIndex == -1 )
     755           0 :             continue;
     756             : 
     757           8 :         switch( xPM->GetEntryContextId(i->mnIndex) )
     758             :         {
     759             :         case CTF_CHAR_STYLE_NAME:
     760           0 :             i->maValue >>= sName;
     761           0 :             i->mnIndex = -1;
     762           0 :             rbHasCharStyle = !sName.isEmpty();
     763           0 :             if( nIgnoreProps )
     764           0 :                 aSecondDel = i;
     765             :             else
     766           0 :                 aFirstDel = i;
     767           0 :             nIgnoreProps++;
     768           0 :             break;
     769             :         case CTF_HYPERLINK_URL:
     770           0 :             rbHyperlink = sal_True;
     771           0 :             i->mnIndex = -1;
     772           0 :             if( nIgnoreProps )
     773           0 :                 aSecondDel = i;
     774             :             else
     775           0 :                 aFirstDel = i;
     776           0 :             nIgnoreProps++;
     777           0 :             break;
     778             :         }
     779             :     }
     780        2096 :     if( ppAddStates )
     781             :     {
     782           0 :         while( *ppAddStates )
     783             :         {
     784           0 :             xPropStates.push_back( **ppAddStates );
     785           0 :             ppAddStates++;
     786             :         }
     787             :     }
     788        2096 :     if( (xPropStates.size() - nIgnoreProps) > 0L )
     789             :     {
     790             :         // erase the character style, otherwise the autostyle cannot be found!
     791             :         // erase the hyperlink, otherwise the autostyle cannot be found!
     792           4 :         if ( nIgnoreProps )
     793             :         {
     794             :             // If two elements of a vector have to be deleted,
     795             :             // we should delete the second one first.
     796           0 :             if( --nIgnoreProps )
     797           0 :                 xPropStates.erase( aSecondDel );
     798           0 :             xPropStates.erase( aFirstDel );
     799             :         }
     800           4 :         OUString sParent; // AutoStyles should not have parents!
     801           4 :         sName = GetAutoStylePool().Find( XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates );
     802             :         DBG_ASSERT( !sName.isEmpty(), "AutoStyle could not be found" );
     803           4 :         rbHasAutoStyle = sal_True;
     804             :     }
     805             : 
     806        4192 :     return sName;
     807             : }
     808             : 
     809             : // adjustments to support lists independent from list style
     810         308 : void XMLTextParagraphExport::exportListChange(
     811             :         const XMLTextNumRuleInfo& rPrevInfo,
     812             :         const XMLTextNumRuleInfo& rNextInfo )
     813             : {
     814             :     // end a list
     815         308 :     if ( rPrevInfo.GetLevel() > 0 )
     816             :     {
     817           2 :         sal_Int16 nListLevelsToBeClosed = 0;
     818           4 :         if ( !rNextInfo.BelongsToSameList( rPrevInfo ) ||
     819           2 :              rNextInfo.GetLevel() <= 0 )
     820             :         {
     821             :             // close complete previous list
     822           2 :             nListLevelsToBeClosed = rPrevInfo.GetLevel();
     823             :         }
     824           0 :         else if ( rPrevInfo.GetLevel() > rNextInfo.GetLevel() )
     825             :         {
     826             :             // close corresponding sub lists
     827             :             DBG_ASSERT( rNextInfo.GetLevel() > 0,
     828             :                         "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
     829           0 :             nListLevelsToBeClosed = rPrevInfo.GetLevel() - rNextInfo.GetLevel();
     830             :         }
     831             : 
     832           4 :         if ( nListLevelsToBeClosed > 0 &&
     833           4 :              pListElements &&
     834           2 :              pListElements->size() >= sal::static_int_cast< sal_uInt32 >( 2 * nListLevelsToBeClosed ) )
     835             :         {
     836           2 :             do {
     837           6 :                 for(size_t j = 0; j < 2; ++j)
     838             :                 {
     839           4 :                     OUString aElem(pListElements->back());
     840           4 :                     pListElements->pop_back();
     841           4 :                     GetExport().EndElement(aElem, sal_True);
     842           4 :                 }
     843             : 
     844             :                 // remove closed list from list stack
     845           2 :                 mpTextListsHelper->PopListFromStack();
     846             : 
     847           2 :                 --nListLevelsToBeClosed;
     848             :             } while ( nListLevelsToBeClosed > 0 );
     849             :         }
     850             :     }
     851             : 
     852             :     const bool bExportODF =
     853         308 :                 ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0;
     854             :     const SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion =
     855         308 :                                     GetExport().getDefaultVersion();
     856             : 
     857             :     // start a new list
     858         308 :     if ( rNextInfo.GetLevel() > 0 )
     859             :     {
     860           2 :         bool bRootListToBeStarted = false;
     861           2 :         sal_Int16 nListLevelsToBeOpened = 0;
     862           4 :         if ( !rPrevInfo.BelongsToSameList( rNextInfo ) ||
     863           2 :              rPrevInfo.GetLevel() <= 0 )
     864             :         {
     865             :             // new root list
     866           2 :             bRootListToBeStarted = true;
     867           2 :             nListLevelsToBeOpened = rNextInfo.GetLevel();
     868             :         }
     869           0 :         else if ( rNextInfo.GetLevel() > rPrevInfo.GetLevel() )
     870             :         {
     871             :             // open corresponding sub lists
     872             :             DBG_ASSERT( rPrevInfo.GetLevel() > 0,
     873             :                         "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
     874           0 :             nListLevelsToBeOpened = rNextInfo.GetLevel() - rPrevInfo.GetLevel();
     875             :         }
     876             : 
     877           2 :         if ( nListLevelsToBeOpened > 0 )
     878             :         {
     879           2 :             const OUString sListStyleName( rNextInfo.GetNumRulesName() );
     880             :             // Currently only the text documents support <ListId>.
     881             :             // Thus, for other document types <sListId> is empty.
     882           4 :             const OUString sListId( rNextInfo.GetListId() );
     883           2 :             bool bExportListStyle( true );
     884           2 :             bool bRestartNumberingAtContinuedList( false );
     885           2 :             sal_Int32 nRestartValueForContinuedList( -1 );
     886           2 :             bool bContinueingPreviousSubList = !bRootListToBeStarted &&
     887           2 :                                                rNextInfo.IsContinueingPreviousSubTree();
     888           2 :             do {
     889           2 :                 GetExport().CheckAttrList();
     890             : 
     891           2 :                 if ( bRootListToBeStarted )
     892             :                 {
     893           2 :                     if ( !mpTextListsHelper->IsListProcessed( sListId ) )
     894             :                     {
     895           4 :                         if ( bExportODF &&
     896           4 :                              eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 &&
     897           2 :                              !sListId.isEmpty() )
     898             :                         {
     899             :                             /* Property text:id at element <text:list> has to be
     900             :                                replaced by property xml:id (#i92221#)
     901             :                             */
     902           0 :                             GetExport().AddAttribute( XML_NAMESPACE_XML,
     903             :                                                       XML_ID,
     904           0 :                                                       sListId );
     905             :                         }
     906             :                         mpTextListsHelper->KeepListAsProcessed( sListId,
     907             :                                                                 sListStyleName,
     908           2 :                                                                 OUString() );
     909             :                     }
     910             :                     else
     911             :                     {
     912             :                         const OUString sNewListId(
     913           0 :                                         mpTextListsHelper->GenerateNewListId() );
     914           0 :                         if ( bExportODF &&
     915           0 :                              eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 &&
     916           0 :                              !sListId.isEmpty() )
     917             :                         {
     918             :                             /* Property text:id at element <text:list> has to be
     919             :                                replaced by property xml:id (#i92221#)
     920             :                             */
     921           0 :                             GetExport().AddAttribute( XML_NAMESPACE_XML,
     922             :                                                       XML_ID,
     923           0 :                                                       sNewListId );
     924             :                         }
     925             : 
     926             :                         const OUString sContinueListId =
     927           0 :                             mpTextListsHelper->GetLastContinuingListId( sListId );
     928             :                         // store that list with list id <sNewListId> is last list,
     929             :                         // which has continued list with list id <sListId>
     930             :                         mpTextListsHelper->StoreLastContinuingList( sListId,
     931           0 :                                                                     sNewListId );
     932           0 :                         if ( sListStyleName ==
     933           0 :                                 mpTextListsHelper->GetListStyleOfLastProcessedList() &&
     934             :                              // Inconsistent behavior regarding lists (#i92811#)
     935           0 :                              sContinueListId ==
     936           0 :                                 mpTextListsHelper->GetLastProcessedListId() &&
     937           0 :                              !rNextInfo.IsRestart() )
     938             :                         {
     939           0 :                             GetExport().AddAttribute( XML_NAMESPACE_TEXT,
     940             :                                                       XML_CONTINUE_NUMBERING,
     941           0 :                                                       XML_TRUE );
     942             :                         }
     943             :                         else
     944             :                         {
     945           0 :                             if ( bExportODF &&
     946           0 :                                  eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 &&
     947           0 :                                  !sListId.isEmpty() )
     948             :                             {
     949           0 :                                 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
     950             :                                                           XML_CONTINUE_LIST,
     951           0 :                                                           sContinueListId );
     952             :                             }
     953             : 
     954           0 :                             if ( rNextInfo.IsRestart() &&
     955           0 :                                  ( nListLevelsToBeOpened != 1 ||
     956           0 :                                    !rNextInfo.HasStartValue() ) )
     957             :                             {
     958           0 :                                 bRestartNumberingAtContinuedList = true;
     959             :                                 nRestartValueForContinuedList =
     960           0 :                                             rNextInfo.GetListLevelStartValue();
     961             :                             }
     962             :                         }
     963             : 
     964             :                         mpTextListsHelper->KeepListAsProcessed( sNewListId,
     965             :                                                                 sListStyleName,
     966           0 :                                                                 sContinueListId );
     967             :                     }
     968             : 
     969           2 :                     GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
     970           4 :                             GetExport().EncodeStyleName( sListStyleName ) );
     971           2 :                     bExportListStyle = false;
     972             : 
     973           2 :                     bRootListToBeStarted = false;
     974             :                 }
     975           0 :                 else if ( bExportListStyle &&
     976           0 :                           !mpTextListsHelper->EqualsToTopListStyleOnStack( sListStyleName ) )
     977             :                 {
     978           0 :                     GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
     979           0 :                             GetExport().EncodeStyleName( sListStyleName ) );
     980           0 :                     bExportListStyle = false;
     981             : 
     982             : 
     983             :                 }
     984             :                 else
     985             :                 {
     986             :                     // rhbz#746174: also export list restart for non root list
     987           0 :                     if (rNextInfo.IsRestart() && !rNextInfo.HasStartValue())
     988             :                     {
     989           0 :                         bRestartNumberingAtContinuedList = true;
     990             :                         nRestartValueForContinuedList =
     991           0 :                                         rNextInfo.GetListLevelStartValue();
     992             :                     }
     993             :                 }
     994             : 
     995           2 :                 if ( bContinueingPreviousSubList )
     996             :                 {
     997           0 :                     GetExport().AddAttribute( XML_NAMESPACE_TEXT,
     998           0 :                                               XML_CONTINUE_NUMBERING, XML_TRUE );
     999           0 :                     bContinueingPreviousSubList = false;
    1000             :                 }
    1001             : 
    1002           2 :                 enum XMLTokenEnum eLName = XML_LIST;
    1003             : 
    1004           2 :                 OUString aElem(GetExport().GetNamespaceMap().GetQNameByKey(
    1005             :                                             XML_NAMESPACE_TEXT,
    1006           4 :                                             GetXMLToken(eLName) ) );
    1007           2 :                 GetExport().IgnorableWhitespace();
    1008           2 :                 GetExport().StartElement(aElem, sal_False);
    1009             : 
    1010           2 :                 if(!pListElements)
    1011           2 :                     pListElements = new std::vector<OUString>;
    1012           2 :                 pListElements->push_back(aElem);
    1013             : 
    1014             :                 mpTextListsHelper->PushListOnStack( sListId,
    1015           2 :                                                     sListStyleName );
    1016             : 
    1017             :                 // <text:list-header> or <text:list-item>
    1018           2 :                 GetExport().CheckAttrList();
    1019             : 
    1020             :                 /* Export start value at correct list item (#i97309#) */
    1021           2 :                 if ( nListLevelsToBeOpened == 1 )
    1022             :                 {
    1023           2 :                     if ( rNextInfo.HasStartValue() )
    1024             :                     {
    1025           0 :                         OUStringBuffer aBuffer;
    1026           0 :                         aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
    1027           0 :                         GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
    1028           0 :                                       aBuffer.makeStringAndClear() );
    1029             :                     }
    1030           2 :                     else if (bRestartNumberingAtContinuedList)
    1031             :                     {
    1032           0 :                         OUStringBuffer aBuffer;
    1033           0 :                         aBuffer.append( nRestartValueForContinuedList );
    1034           0 :                         GetExport().AddAttribute( XML_NAMESPACE_TEXT,
    1035             :                                                   XML_START_VALUE,
    1036           0 :                                                   aBuffer.makeStringAndClear() );
    1037           0 :                         bRestartNumberingAtContinuedList = false;
    1038             :                     }
    1039             :                 }
    1040             : 
    1041           2 :                 eLName = ( rNextInfo.IsNumbered() || nListLevelsToBeOpened > 1 )
    1042             :                          ? XML_LIST_ITEM
    1043           4 :                          : XML_LIST_HEADER;
    1044           4 :                 aElem = OUString( GetExport().GetNamespaceMap().GetQNameByKey(
    1045             :                                             XML_NAMESPACE_TEXT,
    1046           4 :                                             GetXMLToken(eLName) ) );
    1047           2 :                 GetExport().IgnorableWhitespace();
    1048           2 :                 GetExport().StartElement(aElem, sal_False);
    1049           2 :                 pListElements->push_back(aElem);
    1050             : 
    1051             :                 // export of <text:number> element for last opened <text:list-item>, if requested
    1052           4 :                 if ( GetExport().exportTextNumberElement() &&
    1053           2 :                      eLName == XML_LIST_ITEM && nListLevelsToBeOpened == 1 && // last iteration --> last opened <text:list-item>
    1054           0 :                      !rNextInfo.ListLabelString().isEmpty() )
    1055             :                 {
    1056             :                     const OUString aTextNumberElem =
    1057           0 :                             OUString( GetExport().GetNamespaceMap().GetQNameByKey(
    1058             :                                       XML_NAMESPACE_TEXT,
    1059           0 :                                       GetXMLToken(XML_NUMBER) ) );
    1060           0 :                     GetExport().IgnorableWhitespace();
    1061           0 :                     GetExport().StartElement( aTextNumberElem, sal_False );
    1062           0 :                     GetExport().Characters( rNextInfo.ListLabelString() );
    1063           0 :                     GetExport().EndElement( aTextNumberElem, sal_True );
    1064             :                 }
    1065           2 :                 --nListLevelsToBeOpened;
    1066           2 :             } while ( nListLevelsToBeOpened > 0 );
    1067             :         }
    1068             :     }
    1069             : 
    1070         618 :     if ( rNextInfo.GetLevel() > 0 &&
    1071           4 :          rNextInfo.IsNumbered() &&
    1072         312 :          rPrevInfo.BelongsToSameList( rNextInfo ) &&
    1073           2 :          rPrevInfo.GetLevel() >= rNextInfo.GetLevel() )
    1074             :     {
    1075             :         // close previous list-item
    1076             :         DBG_ASSERT( pListElements && pListElements->size() >= 2,
    1077             :                 "SwXMLExport::ExportListChange: list elements missing" );
    1078             : 
    1079           0 :         GetExport().EndElement(pListElements->back(), sal_True );
    1080           0 :         pListElements->pop_back();
    1081             : 
    1082             :         // Only for sub lists (#i103745#)
    1083           0 :         if ( rNextInfo.IsRestart() && !rNextInfo.HasStartValue() &&
    1084           0 :              rNextInfo.GetLevel() != 1 )
    1085             :         {
    1086             :             // start new sub list respectively list on same list level
    1087           0 :             GetExport().EndElement(pListElements->back(), sal_True );
    1088           0 :             GetExport().IgnorableWhitespace();
    1089           0 :             GetExport().StartElement(pListElements->back(), sal_False);
    1090             :         }
    1091             : 
    1092             :         // open new list-item
    1093           0 :         GetExport().CheckAttrList();
    1094           0 :         if( rNextInfo.HasStartValue() )
    1095             :         {
    1096           0 :             OUStringBuffer aBuffer;
    1097           0 :             aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
    1098           0 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
    1099           0 :                                       aBuffer.makeStringAndClear() );
    1100             :         }
    1101             :         // Handle restart without start value on list level 1 (#i103745#)
    1102           0 :         else if ( rNextInfo.IsRestart() && /*!rNextInfo.HasStartValue() &&*/
    1103           0 :                   rNextInfo.GetLevel() == 1 )
    1104             :         {
    1105           0 :             OUStringBuffer aBuffer;
    1106           0 :             aBuffer.append( (sal_Int32)rNextInfo.GetListLevelStartValue() );
    1107           0 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
    1108           0 :                                       aBuffer.makeStringAndClear() );
    1109             :         }
    1110           0 :         if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0 &&
    1111           0 :              GetExport().getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
    1112             :         {
    1113           0 :             const OUString sListStyleName( rNextInfo.GetNumRulesName() );
    1114           0 :             if ( !mpTextListsHelper->EqualsToTopListStyleOnStack( sListStyleName ) )
    1115             :             {
    1116           0 :                 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
    1117             :                                           XML_STYLE_OVERRIDE,
    1118           0 :                                           GetExport().EncodeStyleName( sListStyleName ) );
    1119           0 :             }
    1120             :         }
    1121           0 :         OUString aElem( GetExport().GetNamespaceMap().GetQNameByKey(
    1122             :                                 XML_NAMESPACE_TEXT,
    1123           0 :                                 GetXMLToken(XML_LIST_ITEM) ) );
    1124           0 :         GetExport().IgnorableWhitespace();
    1125           0 :         GetExport().StartElement(aElem, sal_False );
    1126           0 :         pListElements->push_back(aElem);
    1127             : 
    1128             :         // export of <text:number> element for <text:list-item>, if requested
    1129           0 :         if ( GetExport().exportTextNumberElement() &&
    1130           0 :              !rNextInfo.ListLabelString().isEmpty() )
    1131             :         {
    1132             :             const OUString aTextNumberElem =
    1133           0 :                     OUString( GetExport().GetNamespaceMap().GetQNameByKey(
    1134             :                               XML_NAMESPACE_TEXT,
    1135           0 :                               GetXMLToken(XML_NUMBER) ) );
    1136           0 :             GetExport().IgnorableWhitespace();
    1137           0 :             GetExport().StartElement( aTextNumberElem, sal_False );
    1138           0 :             GetExport().Characters( rNextInfo.ListLabelString() );
    1139           0 :             GetExport().EndElement( aTextNumberElem, sal_True );
    1140           0 :         }
    1141             :     }
    1142         308 : }
    1143             : 
    1144          88 : struct XMLTextParagraphExport::Impl
    1145             : {
    1146             :     typedef ::std::map<Reference<XFormField>, sal_Int32> FieldMarkMap_t;
    1147             :     FieldMarkMap_t m_FieldMarkMap;
    1148             : 
    1149          88 :     explicit Impl() {}
    1150           0 :     sal_Int32 AddFieldMarkStart(Reference<XFormField> const& i_xFieldMark)
    1151             :     {
    1152             :         assert(m_FieldMarkMap.find(i_xFieldMark) == m_FieldMarkMap.end());
    1153           0 :         sal_Int32 const ret(m_FieldMarkMap.size());
    1154           0 :         m_FieldMarkMap.insert(::std::make_pair(i_xFieldMark, ret));
    1155           0 :         return ret;
    1156             :     }
    1157           0 :     sal_Int32 GetFieldMarkIndex(Reference<XFormField> const& i_xFieldMark)
    1158             :     {
    1159             :         FieldMarkMap_t::const_iterator const it(
    1160           0 :                 m_FieldMarkMap.find(i_xFieldMark));
    1161             :         // rely on SwXFieldmark::CreateXFieldmark returning the same instance
    1162             :         // because the Reference in m_FieldMarkMap will keep it alive
    1163             :         assert(it != m_FieldMarkMap.end());
    1164           0 :         return it->second;
    1165             :     }
    1166             : };
    1167             : 
    1168          88 : XMLTextParagraphExport::XMLTextParagraphExport(
    1169             :         SvXMLExport& rExp,
    1170             :         SvXMLAutoStylePoolP & rASP
    1171             :         ) :
    1172             :     XMLStyleExport( rExp, OUString(), &rASP ),
    1173          88 :     m_pImpl(new Impl),
    1174             :     rAutoStylePool( rASP ),
    1175         176 :     pBoundFrameSets(new BoundFrameSets(GetExport().GetModel())),
    1176             :     pFieldExport( 0 ),
    1177             :     pListElements( 0 ),
    1178         176 :     pListAutoPool( new XMLTextListAutoStylePool( this->GetExport() ) ),
    1179             :     pSectionExport( NULL ),
    1180             :     pIndexMarkExport( NULL ),
    1181             :     pRedlineExport( NULL ),
    1182             :     pHeadingStyles( NULL ),
    1183             :     bProgress( sal_False ),
    1184             :     bBlock( sal_False ),
    1185             :     bOpenRuby( sal_False ),
    1186             :     mpTextListsHelper( 0 ),
    1187             :     maTextListsHelperStack(),
    1188             :     sActualSize("ActualSize"),
    1189             :     // Implement Title/Description Elements UI (#i73249#)
    1190             :     sTitle("Title"),
    1191             :     sDescription("Description"),
    1192             :     sAnchorCharStyleName("AnchorCharStyleName"),
    1193             :     sAnchorPageNo("AnchorPageNo"),
    1194             :     sAnchorType("AnchorType"),
    1195             :     sBeginNotice("BeginNotice"),
    1196             :     sBookmark("Bookmark"),
    1197             :     sCategory("Category"),
    1198             :     sChainNextName("ChainNextName"),
    1199             :     sCharStyleName("CharStyleName"),
    1200             :     sCharStyleNames("CharStyleNames"),
    1201             :     sContourPolyPolygon("ContourPolyPolygon"),
    1202             :     sDocumentIndex("DocumentIndex"),
    1203             :     sDocumentIndexMark("DocumentIndexMark"),
    1204             :     sEndNotice("EndNotice"),
    1205             :     sFootnote("Footnote"),
    1206             :     sFootnoteCounting("FootnoteCounting"),
    1207             :     sFrame("Frame"),
    1208             :     sFrameHeightAbsolute("FrameHeightAbsolute"),
    1209             :     sFrameHeightPercent("FrameHeightPercent"),
    1210             :     sFrameStyleName("FrameStyleName"),
    1211             :     sFrameWidthAbsolute("FrameWidthAbsolute"),
    1212             :     sFrameWidthPercent("FrameWidthPercent"),
    1213             :     sGraphicFilter("GraphicFilter"),
    1214             :     sGraphicRotation("GraphicRotation"),
    1215             :     sGraphicURL("GraphicURL"),
    1216             :     sReplacementGraphicURL("ReplacementGraphicURL"),
    1217             :     sHeight("Height"),
    1218             :     sHoriOrient("HoriOrient"),
    1219             :     sHoriOrientPosition("HoriOrientPosition"),
    1220             :     sHyperLinkName("HyperLinkName"),
    1221             :     sHyperLinkTarget("HyperLinkTarget"),
    1222             :     sHyperLinkURL("HyperLinkURL"),
    1223             :     sIsAutomaticContour("IsAutomaticContour"),
    1224             :     sIsCollapsed("IsCollapsed"),
    1225             :     sIsPixelContour("IsPixelContour"),
    1226             :     sIsStart("IsStart"),
    1227             :     sIsSyncHeightToWidth("IsSyncHeightToWidth"),
    1228             :     sIsSyncWidthToHeight("IsSyncWidthToHeight"),
    1229             :     sNumberingRules("NumberingRules"),
    1230             :     sNumberingType("NumberingType"),
    1231             :     sPageDescName("PageDescName"),
    1232             :     sPageStyleName("PageStyleName"),
    1233             :     sParaChapterNumberingLevel("ParaChapterNumberingLevel"),
    1234             :     sParaConditionalStyleName("ParaConditionalStyleName"),
    1235             :     sParagraphService("com.sun.star.text.Paragraph"),
    1236             :     sParaStyleName("ParaStyleName"),
    1237             :     sPositionEndOfDoc("PositionEndOfDoc"),
    1238             :     sPrefix("Prefix"),
    1239             :     sRedline("Redline"),
    1240             :     sReferenceId("ReferenceId"),
    1241             :     sReferenceMark("ReferenceMark"),
    1242             :     sRelativeHeight("RelativeHeight"),
    1243             :     sRelativeWidth("RelativeWidth"),
    1244             :     sRuby("Ruby"),
    1245             :     sRubyAdjust("RubyAdjust"),
    1246             :     sRubyCharStyleName("RubyCharStyleName"),
    1247             :     sRubyText("RubyText"),
    1248             :     sServerMap("ServerMap"),
    1249             :     sShapeService("com.sun.star.drawing.Shape"),
    1250             :     sSizeType("SizeType"),
    1251             :     sSoftPageBreak( "SoftPageBreak"  ),
    1252             :     sStartAt("StartAt"),
    1253             :     sSuffix("Suffix"),
    1254             :     sTableService("com.sun.star.text.TextTable"),
    1255             :     sText("Text"),
    1256             :     sTextContentService("com.sun.star.text.TextContent"),
    1257             :     sTextEmbeddedService("com.sun.star.text.TextEmbeddedObject"),
    1258             :     sTextEndnoteService("com.sun.star.text.Endnote"),
    1259             :     sTextField("TextField"),
    1260             :     sTextFieldService("com.sun.star.text.TextField"),
    1261             :     sTextFrameService("com.sun.star.text.TextFrame"),
    1262             :     sTextGraphicService("com.sun.star.text.TextGraphicObject"),
    1263             :     sTextPortionType("TextPortionType"),
    1264             :     sTextSection("TextSection"),
    1265             :     sUnvisitedCharStyleName("UnvisitedCharStyleName"),
    1266             :     sVertOrient("VertOrient"),
    1267             :     sVertOrientPosition("VertOrientPosition"),
    1268             :     sVisitedCharStyleName("VisitedCharStyleName"),
    1269             :     sWidth("Width"),
    1270             :     sWidthType( "WidthType"  ),
    1271             :     sTextFieldStart( "TextFieldStart"  ),
    1272             :     sTextFieldEnd( "TextFieldEnd"  ),
    1273             :     sTextFieldStartEnd( "TextFieldStartEnd"  ),
    1274         528 :     aCharStyleNamesPropInfoCache( sCharStyleNames )
    1275             : {
    1276          88 :     UniReference < XMLPropertySetMapper > xPropMapper(new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA ));
    1277         176 :     xParaPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
    1278         264 :                                                              GetExport() );
    1279             : 
    1280         176 :     OUString sFamily( GetXMLToken(XML_PARAGRAPH) );
    1281         176 :     OUString aPrefix(static_cast<sal_Unicode>('P'));
    1282             :     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH, sFamily,
    1283          88 :                               xParaPropMapper, aPrefix );
    1284             : 
    1285          88 :     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
    1286         176 :     xTextPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
    1287         264 :                                                              GetExport() );
    1288          88 :     sFamily = OUString( GetXMLToken(XML_TEXT) );
    1289          88 :     aPrefix = OUString(static_cast<sal_Unicode>('T'));
    1290             :     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_TEXT, sFamily,
    1291          88 :                               xTextPropMapper, aPrefix );
    1292             : 
    1293          88 :     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_AUTO_FRAME );
    1294         176 :     xAutoFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
    1295         264 :                                                                   GetExport() );
    1296          88 :     sFamily = OUString( XML_STYLE_FAMILY_SD_GRAPHICS_NAME );
    1297          88 :     aPrefix = OUString( "fr"  );
    1298             :     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_FRAME, sFamily,
    1299          88 :                               xAutoFramePropMapper, aPrefix );
    1300             : 
    1301          88 :     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION );
    1302         176 :     xSectionPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
    1303         264 :                                                              GetExport() );
    1304          88 :     sFamily = OUString( GetXMLToken( XML_SECTION ) );
    1305          88 :     aPrefix = OUString( "Sect"  );
    1306             :     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_SECTION, sFamily,
    1307          88 :                               xSectionPropMapper, aPrefix );
    1308             : 
    1309          88 :     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY );
    1310          88 :     xRubyPropMapper = new SvXMLExportPropertyMapper( xPropMapper );
    1311          88 :     sFamily = OUString( GetXMLToken( XML_RUBY ) );
    1312          88 :     aPrefix = OUString( "Ru"  );
    1313             :     rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_RUBY, sFamily,
    1314          88 :                               xRubyPropMapper, aPrefix );
    1315             : 
    1316          88 :     xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
    1317         176 :     xFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
    1318         264 :                                                               GetExport() );
    1319             : 
    1320          88 :     pSectionExport = new XMLSectionExport( rExp, *this );
    1321          88 :     pIndexMarkExport = new XMLIndexMarkExport( rExp );
    1322             : 
    1323         352 :     if( ! IsBlockMode() &&
    1324         352 :         Reference<XRedlinesSupplier>( GetExport().GetModel(), UNO_QUERY ).is())
    1325          32 :         pRedlineExport = new XMLRedlineExport( rExp );
    1326             : 
    1327             :     // The text field helper needs a pre-constructed XMLPropertyState
    1328             :     // to export the combined characters field. We construct that
    1329             :     // here, because we need the text property mapper to do it.
    1330             : 
    1331             :     // construct Any value, then find index
    1332          88 :     sal_Int32 nIndex = xTextPropMapper->getPropertySetMapper()->FindEntryIndex(
    1333             :                                 "", XML_NAMESPACE_STYLE,
    1334         176 :                                 GetXMLToken(XML_TEXT_COMBINE));
    1335          88 :     pFieldExport = new XMLTextFieldExport( rExp, new XMLPropertyState( nIndex, uno::makeAny(sal_True) ) );
    1336         176 :     PushNewTextListsHelper();
    1337          88 : }
    1338             : 
    1339         232 : XMLTextParagraphExport::~XMLTextParagraphExport()
    1340             : {
    1341          88 :     delete pHeadingStyles;
    1342          88 :     delete pRedlineExport;
    1343          88 :     delete pIndexMarkExport;
    1344          88 :     delete pSectionExport;
    1345          88 :     delete pFieldExport;
    1346          88 :     delete pListElements;
    1347          88 :     delete pListAutoPool;
    1348             : #ifdef DBG_UTIL
    1349             :     txtparae_bContainsIllegalCharacters = sal_False;
    1350             : #endif
    1351          88 :     PopTextListsHelper();
    1352             :     DBG_ASSERT( maTextListsHelperStack.empty(),
    1353             :                 "misusage of text lists helper stack - it is not empty. Serious defect - please inform OD" );
    1354         144 : }
    1355             : 
    1356          32 : SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateShapeExtPropMapper(
    1357             :         SvXMLExport& rExport )
    1358             : {
    1359             :     UniReference < XMLPropertySetMapper > xPropMapper =
    1360          32 :         new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE );
    1361          32 :     return new XMLTextExportPropertySetMapper( xPropMapper, rExport );
    1362             : }
    1363             : 
    1364           8 : SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateCharExtPropMapper(
    1365             :         SvXMLExport& rExport)
    1366             : {
    1367             :     XMLPropertySetMapper *pPropMapper =
    1368           8 :         new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
    1369           8 :     return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
    1370             : }
    1371             : 
    1372         181 : SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaExtPropMapper(
    1373             :         SvXMLExport& rExport)
    1374             : {
    1375             :     XMLPropertySetMapper *pPropMapper =
    1376         181 :         new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
    1377         181 :     return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
    1378             : }
    1379             : 
    1380          24 : SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaDefaultExtPropMapper(
    1381             :         SvXMLExport& rExport)
    1382             : {
    1383             :     XMLPropertySetMapper *pPropMapper =
    1384          24 :         new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT_ADDITIONAL_DEFAULTS );
    1385          24 :     return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
    1386             : }
    1387             : 
    1388          16 : void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles,
    1389             :                                                sal_Bool bIsProgress )
    1390             : {
    1391          16 :     const TextContentSet* const pTexts = pBoundFrameSets->GetTexts()->GetPageBoundContents();
    1392          16 :     const TextContentSet* const pGraphics = pBoundFrameSets->GetGraphics()->GetPageBoundContents();
    1393          16 :     const TextContentSet* const pEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetPageBoundContents();
    1394          16 :     const TextContentSet* const pShapes = pBoundFrameSets->GetShapes()->GetPageBoundContents();
    1395          48 :     for(TextContentSet::const_iterator_t it = pTexts->getBegin();
    1396          32 :         it != pTexts->getEnd();
    1397             :         ++it)
    1398           0 :         exportTextFrame(*it, bAutoStyles, bIsProgress, sal_True);
    1399          48 :     for(TextContentSet::const_iterator_t it = pGraphics->getBegin();
    1400          32 :         it != pGraphics->getEnd();
    1401             :         ++it)
    1402           0 :         exportTextGraphic(*it, bAutoStyles);
    1403          48 :     for(TextContentSet::const_iterator_t it = pEmbeddeds->getBegin();
    1404          32 :         it != pEmbeddeds->getEnd();
    1405             :         ++it)
    1406           0 :         exportTextEmbedded(*it, bAutoStyles);
    1407          48 :     for(TextContentSet::const_iterator_t it = pShapes->getBegin();
    1408          32 :         it != pShapes->getEnd();
    1409             :         ++it)
    1410           0 :         exportShape(*it, bAutoStyles);
    1411          16 : }
    1412             : 
    1413           2 : void XMLTextParagraphExport::exportFrameFrames(
    1414             :         sal_Bool bAutoStyles,
    1415             :         sal_Bool bIsProgress,
    1416             :         const Reference < XTextFrame > *pParentTxtFrame )
    1417             : {
    1418           2 :     const TextContentSet* const pTexts = pBoundFrameSets->GetTexts()->GetFrameBoundContents(*pParentTxtFrame);
    1419           2 :     if(pTexts)
    1420           0 :         for(TextContentSet::const_iterator_t it = pTexts->getBegin();
    1421           0 :             it != pTexts->getEnd();
    1422             :             ++it)
    1423           0 :             exportTextFrame(*it, bAutoStyles, bIsProgress, sal_True);
    1424           2 :     const TextContentSet* const pGraphics = pBoundFrameSets->GetGraphics()->GetFrameBoundContents(*pParentTxtFrame);
    1425           2 :     if(pGraphics)
    1426           0 :         for(TextContentSet::const_iterator_t it = pGraphics->getBegin();
    1427           0 :             it != pGraphics->getEnd();
    1428             :             ++it)
    1429           0 :             exportTextGraphic(*it, bAutoStyles);
    1430           2 :     const TextContentSet* const pEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetFrameBoundContents(*pParentTxtFrame);
    1431           2 :     if(pEmbeddeds)
    1432           0 :         for(TextContentSet::const_iterator_t it = pEmbeddeds->getBegin();
    1433           0 :             it != pEmbeddeds->getEnd();
    1434             :             ++it)
    1435           0 :             exportTextEmbedded(*it, bAutoStyles);
    1436           2 :     const TextContentSet* const pShapes = pBoundFrameSets->GetShapes()->GetFrameBoundContents(*pParentTxtFrame);
    1437           2 :     if(pShapes)
    1438           0 :         for(TextContentSet::const_iterator_t it = pShapes->getBegin();
    1439           0 :             it != pShapes->getEnd();
    1440             :             ++it)
    1441           0 :             exportShape(*it, bAutoStyles);
    1442           2 : }
    1443             : 
    1444             : // bookmarks, reference marks (and TOC marks) are the same except for the
    1445             : // element names. We use the same method for export and it an array with
    1446             : // the proper element names
    1447             : static const enum XMLTokenEnum lcl_XmlReferenceElements[] = {
    1448             :     XML_REFERENCE_MARK, XML_REFERENCE_MARK_START, XML_REFERENCE_MARK_END };
    1449             : static const enum XMLTokenEnum lcl_XmlBookmarkElements[] = {
    1450             :     XML_BOOKMARK, XML_BOOKMARK_START, XML_BOOKMARK_END };
    1451             : 
    1452             : // This function replaces the text portion iteration during auto style
    1453             : // collection.
    1454          16 : bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgress )
    1455             : {
    1456          16 :     GetExport().GetShapeExport(); // make sure the graphics styles family is added
    1457             : 
    1458          16 :     const sal_Bool bAutoStyles = sal_True;
    1459          16 :     const sal_Bool bExportContent = sal_False;
    1460             : 
    1461             :     // Export AutoStyles:
    1462          16 :     Reference< XAutoStylesSupplier > xAutoStylesSupp( GetExport().GetModel(), UNO_QUERY );
    1463          16 :     if ( xAutoStylesSupp.is() )
    1464             :     {
    1465          16 :         Reference< XAutoStyles > xAutoStyleFamilies = xAutoStylesSupp->getAutoStyles();
    1466          32 :         OUString sName;
    1467             :         sal_uInt16 nFamily;
    1468             : 
    1469          64 :         for ( int i = 0; i < 3; ++i )
    1470             :         {
    1471          48 :             if ( 0 == i )
    1472             :             {
    1473          16 :                 sName = OUString( "CharacterStyles"  );
    1474          16 :                 nFamily = XML_STYLE_FAMILY_TEXT_TEXT;
    1475             :             }
    1476          32 :             else if ( 1 == i )
    1477             :             {
    1478          16 :                 sName = OUString( "RubyStyles"  );
    1479          16 :                 nFamily = XML_STYLE_FAMILY_TEXT_RUBY;
    1480             :             }
    1481             :             else
    1482             :             {
    1483          16 :                 sName = OUString( "ParagraphStyles"  );
    1484          16 :                 nFamily = XML_STYLE_FAMILY_TEXT_PARAGRAPH;
    1485             :             }
    1486             : 
    1487          48 :             Any aAny = xAutoStyleFamilies->getByName( sName );
    1488          96 :             Reference< XAutoStyleFamily > xAutoStyles = *(Reference<XAutoStyleFamily>*)aAny.getValue();
    1489          96 :             Reference < XEnumeration > xAutoStylesEnum( xAutoStyles->createEnumeration() );
    1490             : 
    1491         108 :             while ( xAutoStylesEnum->hasMoreElements() )
    1492             :             {
    1493          12 :                 aAny = xAutoStylesEnum->nextElement();
    1494          12 :                 Reference< XAutoStyle > xAutoStyle = *(Reference<XAutoStyle>*)aAny.getValue();
    1495          24 :                 Reference < XPropertySet > xPSet( xAutoStyle, uno::UNO_QUERY );
    1496          12 :                 Add( nFamily, xPSet, 0, true );
    1497          12 :             }
    1498          64 :         }
    1499             :     }
    1500             : 
    1501             :     // Export Field AutoStyles:
    1502          32 :     Reference< XTextFieldsSupplier > xTextFieldsSupp( GetExport().GetModel(), UNO_QUERY );
    1503          16 :     if ( xTextFieldsSupp.is() )
    1504             :     {
    1505          16 :         Reference< XEnumerationAccess > xTextFields = xTextFieldsSupp->getTextFields();
    1506          32 :         Reference < XEnumeration > xTextFieldsEnum( xTextFields->createEnumeration() );
    1507             : 
    1508          46 :         while ( xTextFieldsEnum->hasMoreElements() )
    1509             :         {
    1510          14 :             Any aAny = xTextFieldsEnum->nextElement();
    1511          28 :             Reference< XTextField > xTextField = *(Reference<XTextField>*)aAny.getValue();
    1512             :             exportTextField( xTextField, bAutoStyles, bIsProgress,
    1513          14 :                 !xAutoStylesSupp.is() );
    1514             :             try
    1515             :             {
    1516          14 :                 Reference < XPropertySet > xSet( xTextField, UNO_QUERY );
    1517          28 :                 Reference < XText > xText;
    1518          28 :                 Any a = xSet->getPropertyValue("TextRange");
    1519           2 :                 a >>= xText;
    1520           2 :                 if ( xText.is() )
    1521             :                 {
    1522           2 :                     exportText( xText, sal_True, bIsProgress, bExportContent );
    1523           2 :                     GetExport().GetTextParagraphExport()
    1524           2 :                         ->collectTextAutoStyles( xText );
    1525          14 :                 }
    1526             :             }
    1527          12 :             catch (Exception&)
    1528             :             {
    1529             :             }
    1530          30 :         }
    1531             :     }
    1532             : 
    1533             :     // Export text frames:
    1534          32 :     Reference<XEnumeration> xTextFramesEnum = pBoundFrameSets->GetTexts()->createEnumeration();
    1535          16 :     if(xTextFramesEnum.is())
    1536          34 :         while(xTextFramesEnum->hasMoreElements())
    1537             :         {
    1538           2 :             Reference<XTextContent> xTxtCntnt(xTextFramesEnum->nextElement(), UNO_QUERY);
    1539           2 :             if(xTxtCntnt.is())
    1540           2 :                 exportTextFrame(xTxtCntnt, bAutoStyles, bIsProgress, bExportContent, 0);
    1541           2 :         }
    1542             : 
    1543             :     // Export graphic objects:
    1544          32 :     Reference<XEnumeration> xGraphicsEnum = pBoundFrameSets->GetGraphics()->createEnumeration();
    1545          16 :     if(xGraphicsEnum.is())
    1546          32 :         while(xGraphicsEnum->hasMoreElements())
    1547             :         {
    1548           0 :             Reference<XTextContent> xTxtCntnt(xGraphicsEnum->nextElement(), UNO_QUERY);
    1549           0 :             if(xTxtCntnt.is())
    1550           0 :                 exportTextGraphic(xTxtCntnt, true, 0);
    1551           0 :         }
    1552             : 
    1553             :     // Export embedded objects:
    1554          32 :     Reference<XEnumeration> xEmbeddedsEnum = pBoundFrameSets->GetEmbeddeds()->createEnumeration();
    1555          16 :     if(xEmbeddedsEnum.is())
    1556          40 :         while(xEmbeddedsEnum->hasMoreElements())
    1557             :         {
    1558           8 :             Reference<XTextContent> xTxtCntnt(xEmbeddedsEnum->nextElement(), UNO_QUERY);
    1559           8 :             if(xTxtCntnt.is())
    1560           8 :                 exportTextEmbedded(xTxtCntnt, true, 0);
    1561           8 :         }
    1562             : 
    1563             :     // Export shapes:
    1564          32 :     Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration();
    1565          16 :     if(xShapesEnum.is())
    1566          42 :         while(xShapesEnum->hasMoreElements())
    1567             :         {
    1568          10 :             Reference<XTextContent> xTxtCntnt(xShapesEnum->nextElement(), UNO_QUERY);
    1569          10 :             if(xTxtCntnt.is())
    1570             :             {
    1571          10 :                 Reference<XServiceInfo> xServiceInfo(xTxtCntnt, UNO_QUERY);
    1572          10 :                 if( xServiceInfo->supportsService(sShapeService))
    1573           0 :                     exportShape(xTxtCntnt, true, 0);
    1574             :             }
    1575          10 :         }
    1576             : 
    1577             :     sal_Int32 nCount;
    1578             :     // AutoStyles for sections
    1579          32 :     Reference< XTextSectionsSupplier > xSectionsSupp( GetExport().GetModel(), UNO_QUERY );
    1580          16 :     if ( xSectionsSupp.is() )
    1581             :     {
    1582          16 :         Reference< XIndexAccess > xSections( xSectionsSupp->getTextSections(), UNO_QUERY );
    1583          16 :         if ( xSections.is() )
    1584             :         {
    1585          16 :             nCount = xSections->getCount();
    1586          34 :             for( sal_Int32 i = 0; i < nCount; ++i )
    1587             :             {
    1588          18 :                 Any aAny = xSections->getByIndex( i );
    1589          36 :                 Reference< XTextSection > xSection = *(Reference<XTextSection>*)aAny.getValue();
    1590          36 :                 Reference < XPropertySet > xPSet( xSection, uno::UNO_QUERY );
    1591          18 :                 Add( XML_STYLE_FAMILY_TEXT_SECTION, xPSet );
    1592          18 :             }
    1593          16 :         }
    1594             :     }
    1595             : 
    1596             :     // AutoStyles for tables (Note: suppress autostyle collection for paragraphs in exportTable)
    1597          32 :     Reference< XTextTablesSupplier > xTablesSupp( GetExport().GetModel(), UNO_QUERY );
    1598          16 :     if ( xTablesSupp.is() )
    1599             :     {
    1600          16 :         Reference< XIndexAccess > xTables( xTablesSupp->getTextTables(), UNO_QUERY );
    1601          16 :         if ( xTables.is() )
    1602             :         {
    1603          16 :             nCount = xTables->getCount();
    1604          16 :             for( sal_Int32 i = 0; i < nCount; ++i )
    1605             :             {
    1606           0 :                 Any aAny = xTables->getByIndex( i );
    1607           0 :                 Reference< XTextTable > xTable = *(Reference<XTextTable>*)aAny.getValue();
    1608           0 :                 exportTable( xTable, sal_True, sal_True );
    1609           0 :             }
    1610          16 :         }
    1611             :     }
    1612             : 
    1613          32 :     Reference< XNumberingRulesSupplier > xNumberingRulesSupp( GetExport().GetModel(), UNO_QUERY );
    1614          16 :     if ( xNumberingRulesSupp.is() )
    1615             :     {
    1616          16 :         Reference< XIndexAccess > xNumberingRules = xNumberingRulesSupp->getNumberingRules();
    1617          16 :         nCount = xNumberingRules->getCount();
    1618             :         // Custom outline assignment lost after re-importing sxw (#i73361#)
    1619          32 :         const OUString sNumberingIsOutline( "NumberingIsOutline"  );
    1620          68 :         for( sal_Int32 i = 0; i < nCount; ++i )
    1621             :         {
    1622          52 :             Reference< XIndexReplace > xNumRule( xNumberingRules->getByIndex( i ), UNO_QUERY );
    1623          52 :             if( xNumRule.is() && xNumRule->getCount() )
    1624             :             {
    1625          52 :                 Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
    1626         104 :                 OUString sName;
    1627          52 :                 if( xNamed.is() )
    1628          52 :                     sName = xNamed->getName();
    1629          52 :                 sal_Bool bAdd = sName.isEmpty();
    1630          52 :                 if( !bAdd )
    1631             :                 {
    1632             :                     Reference < XPropertySet > xNumPropSet( xNumRule,
    1633          52 :                                                             UNO_QUERY );
    1634         104 :                     const OUString sIsAutomatic( "IsAutomatic"  );
    1635         208 :                     if( xNumPropSet.is() &&
    1636          52 :                         xNumPropSet->getPropertySetInfo()
    1637         208 :                                    ->hasPropertyByName( sIsAutomatic ) )
    1638             :                     {
    1639          52 :                         bAdd = *(sal_Bool *)xNumPropSet->getPropertyValue( sIsAutomatic ).getValue();
    1640             :                         // Check on outline style (#i73361#)
    1641         172 :                         if ( bAdd &&
    1642          16 :                              xNumPropSet->getPropertySetInfo()
    1643         100 :                                        ->hasPropertyByName( sNumberingIsOutline ) )
    1644             :                         {
    1645          16 :                             bAdd = !(*(sal_Bool *)xNumPropSet->getPropertyValue( sNumberingIsOutline ).getValue());
    1646             :                         }
    1647             :                     }
    1648             :                     else
    1649             :                     {
    1650           0 :                         bAdd = sal_True;
    1651          52 :                     }
    1652             :                 }
    1653          52 :                 if( bAdd )
    1654          52 :                     pListAutoPool->Add( xNumRule );
    1655             :             }
    1656          68 :         }
    1657             :     }
    1658             : 
    1659          32 :     return true;
    1660             : }
    1661             : 
    1662         338 : void XMLTextParagraphExport::exportText(
    1663             :         const Reference < XText > & rText,
    1664             :         sal_Bool bAutoStyles,
    1665             :         sal_Bool bIsProgress,
    1666             :         sal_Bool bExportParagraph )
    1667             : {
    1668         338 :     if( bAutoStyles )
    1669         242 :         GetExport().GetShapeExport(); // make sure the graphics styles family
    1670             :                                       // is added
    1671         338 :     Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
    1672         676 :     Reference < XEnumeration > xParaEnum(xEA->createEnumeration());
    1673         676 :     Reference < XPropertySet > xPropertySet( rText, UNO_QUERY );
    1674         676 :     Reference < XTextSection > xBaseSection;
    1675             : 
    1676             :     // #97718# footnotes don't supply paragraph enumerations in some cases
    1677             :     // This is always a bug, but at least we don't want to crash.
    1678             :     DBG_ASSERT( xParaEnum.is(), "We need a paragraph enumeration" );
    1679         338 :     if( ! xParaEnum.is() )
    1680         338 :         return;
    1681             : 
    1682         338 :     sal_Bool bExportLevels = sal_True;
    1683             : 
    1684         338 :     if (xPropertySet.is())
    1685             :     {
    1686          94 :         Reference < XPropertySetInfo > xInfo ( xPropertySet->getPropertySetInfo() );
    1687             : 
    1688          94 :         if( xInfo.is() )
    1689             :         {
    1690          94 :             if (xInfo->hasPropertyByName( sTextSection ))
    1691             :             {
    1692           0 :                 xPropertySet->getPropertyValue(sTextSection) >>= xBaseSection ;
    1693             :             }
    1694             : 
    1695             : /* #i35937#
    1696             :             // for applications that use the outliner we need to check if
    1697             :             // the current text object needs the level information exported
    1698             :             if( !bAutoStyles )
    1699             :             {
    1700             :                 // fixme: move string to class member, couldn't do now because
    1701             :                 //        of no incompatible build
    1702             :                 OUString sHasLevels( "HasLevels" );
    1703             :                 if (xInfo->hasPropertyByName( sHasLevels ) )
    1704             :                 {
    1705             :                     xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels;
    1706             :                 }
    1707             :             }
    1708             : */
    1709          94 :         }
    1710             :     }
    1711             : 
    1712             :     // #96530# Export redlines at start & end of XText before & after
    1713             :     // exporting the text content enumeration
    1714         338 :     if( !bAutoStyles && (pRedlineExport != NULL) )
    1715          32 :         pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True );
    1716             :     exportTextContentEnumeration( xParaEnum, bAutoStyles, xBaseSection,
    1717         338 :                                   bIsProgress, bExportParagraph, 0, bExportLevels );
    1718         338 :     if( !bAutoStyles && (pRedlineExport != NULL) )
    1719         370 :         pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_False );
    1720             : }
    1721             : 
    1722           0 : void XMLTextParagraphExport::exportText(
    1723             :         const Reference < XText > & rText,
    1724             :         const Reference < XTextSection > & rBaseSection,
    1725             :         sal_Bool bAutoStyles,
    1726             :         sal_Bool bIsProgress,
    1727             :         sal_Bool bExportParagraph )
    1728             : {
    1729           0 :     if( bAutoStyles )
    1730           0 :         GetExport().GetShapeExport(); // make sure the graphics styles family
    1731             :                                       // is added
    1732           0 :     Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
    1733           0 :     Reference < XEnumeration > xParaEnum(xEA->createEnumeration());
    1734             : 
    1735             :     // #98165# don't continue without a paragraph enumeration
    1736           0 :     if( ! xParaEnum.is() )
    1737           0 :         return;
    1738             : 
    1739             :     // #96530# Export redlines at start & end of XText before & after
    1740             :     // exporting the text content enumeration
    1741           0 :     Reference<XPropertySet> xPropertySet;
    1742           0 :     if( !bAutoStyles && (pRedlineExport != NULL) )
    1743             :     {
    1744           0 :         xPropertySet.set(rText, uno::UNO_QUERY );
    1745           0 :         pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True );
    1746             :     }
    1747             :     exportTextContentEnumeration( xParaEnum, bAutoStyles, rBaseSection,
    1748           0 :                                   bIsProgress, bExportParagraph );
    1749           0 :     if( !bAutoStyles && (pRedlineExport != NULL) )
    1750           0 :         pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_False );
    1751             : }
    1752             : 
    1753         348 : sal_Bool XMLTextParagraphExport::exportTextContentEnumeration(
    1754             :         const Reference < XEnumeration > & rContEnum,
    1755             :         sal_Bool bAutoStyles,
    1756             :         const Reference < XTextSection > & rBaseSection,
    1757             :         sal_Bool bIsProgress,
    1758             :         sal_Bool bExportParagraph,
    1759             :         const Reference < XPropertySet > *pRangePropSet,
    1760             :         sal_Bool bExportLevels )
    1761             : {
    1762             :     DBG_ASSERT( rContEnum.is(), "No enumeration to export!" );
    1763         348 :     sal_Bool bHasMoreElements = rContEnum->hasMoreElements();
    1764         348 :     if( !bHasMoreElements )
    1765           0 :         return sal_False;
    1766             : 
    1767         348 :     XMLTextNumRuleInfo aPrevNumInfo;
    1768         696 :     XMLTextNumRuleInfo aNextNumInfo;
    1769             : 
    1770         348 :     sal_Bool bHasContent = sal_False;
    1771         696 :     Reference<XTextSection> xCurrentTextSection(rBaseSection);
    1772             : 
    1773             :     MultiPropertySetHelper aPropSetHelper(
    1774             :                                bAutoStyles ? aParagraphPropertyNamesAuto :
    1775         696 :                                           aParagraphPropertyNames );
    1776             : 
    1777         348 :     sal_Bool bHoldElement = sal_False;
    1778         696 :     Reference < XTextContent > xTxtCntnt;
    1779        1139 :     while( bHoldElement || bHasMoreElements )
    1780             :     {
    1781         443 :         if (bHoldElement)
    1782             :         {
    1783           0 :             bHoldElement = sal_False;
    1784             :         }
    1785             :         else
    1786             :         {
    1787         443 :             xTxtCntnt.set(rContEnum->nextElement(), uno::UNO_QUERY);
    1788             : 
    1789         443 :             aPropSetHelper.resetValues();
    1790             : 
    1791             :         }
    1792             : 
    1793         443 :         Reference<XServiceInfo> xServiceInfo( xTxtCntnt, UNO_QUERY );
    1794         443 :         if( xServiceInfo->supportsService( sParagraphService ) )
    1795             :         {
    1796         433 :             if( bExportLevels )
    1797             :             {
    1798         433 :                 if( bAutoStyles )
    1799             :                 {
    1800             :                     exportListAndSectionChange( xCurrentTextSection, xTxtCntnt,
    1801             :                                                 aPrevNumInfo, aNextNumInfo,
    1802         242 :                                                 bAutoStyles );
    1803             :                 }
    1804             :                 else
    1805             :                 {
    1806             :                     /* Pass list auto style pool to <XMLTextNumRuleInfo> instance
    1807             :                        Pass info about request to export <text:number> element
    1808             :                        to <XMLTextNumRuleInfo> instance (#i69627#)
    1809             :                     */
    1810             :                     aNextNumInfo.Set( xTxtCntnt,
    1811         191 :                                       GetExport().writeOutlineStyleAsNormalListStyle(),
    1812         191 :                                       GetListAutoStylePool(),
    1813         382 :                                       GetExport().exportTextNumberElement() );
    1814             : 
    1815             :                     exportListAndSectionChange( xCurrentTextSection, aPropSetHelper,
    1816             :                                                 TEXT_SECTION, xTxtCntnt,
    1817             :                                                 aPrevNumInfo, aNextNumInfo,
    1818         191 :                                                 bAutoStyles );
    1819             :                 }
    1820             :             }
    1821             : 
    1822             :             // if we found a mute section: skip all section content
    1823         433 :             if (pSectionExport->IsMuteSection(xCurrentTextSection))
    1824             :             {
    1825             :                 // Make sure headings are exported anyway.
    1826           0 :                 if( !bAutoStyles )
    1827           0 :                     pSectionExport->ExportMasterDocHeadingDummies();
    1828             : 
    1829           0 :                 while (rContEnum->hasMoreElements() &&
    1830             :                        pSectionExport->IsInSection( xCurrentTextSection,
    1831           0 :                                                     xTxtCntnt, sal_True ))
    1832             :                 {
    1833           0 :                     xTxtCntnt.set(rContEnum->nextElement(), uno::UNO_QUERY);
    1834           0 :                     aPropSetHelper.resetValues();
    1835           0 :                     aNextNumInfo.Reset();
    1836             :                 }
    1837             :                 // the first non-mute element still needs to be processed
    1838             :                 bHoldElement =
    1839             :                     ! pSectionExport->IsInSection( xCurrentTextSection,
    1840           0 :                                                    xTxtCntnt, sal_False );
    1841             :             }
    1842             :             else
    1843             :                 exportParagraph( xTxtCntnt, bAutoStyles, bIsProgress,
    1844         433 :                                  bExportParagraph, aPropSetHelper );
    1845         433 :             bHasContent = sal_True;
    1846             :         }
    1847          10 :         else if( xServiceInfo->supportsService( sTableService ) )
    1848             :         {
    1849           0 :             if( !bAutoStyles )
    1850             :             {
    1851           0 :                 aNextNumInfo.Reset();
    1852             :             }
    1853             : 
    1854             :             exportListAndSectionChange( xCurrentTextSection, xTxtCntnt,
    1855             :                                         aPrevNumInfo, aNextNumInfo,
    1856           0 :                                         bAutoStyles );
    1857             : 
    1858           0 :             if (! pSectionExport->IsMuteSection(xCurrentTextSection))
    1859             :             {
    1860             :                 // export start + end redlines (for wholly redlined tables)
    1861           0 :                 if ((! bAutoStyles) && (NULL != pRedlineExport))
    1862           0 :                     pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_True);
    1863             : 
    1864           0 :                 exportTable( xTxtCntnt, bAutoStyles, bIsProgress  );
    1865             : 
    1866           0 :                 if ((! bAutoStyles) && (NULL != pRedlineExport))
    1867           0 :                     pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_False);
    1868             :             }
    1869           0 :             else if( !bAutoStyles )
    1870             :             {
    1871             :                 // Make sure headings are exported anyway.
    1872           0 :                 pSectionExport->ExportMasterDocHeadingDummies();
    1873             :             }
    1874             : 
    1875           0 :             bHasContent = sal_True;
    1876             :         }
    1877          10 :         else if( xServiceInfo->supportsService( sTextFrameService ) )
    1878             :         {
    1879           2 :             exportTextFrame( xTxtCntnt, bAutoStyles, bIsProgress, sal_True, pRangePropSet );
    1880             :         }
    1881           8 :         else if( xServiceInfo->supportsService( sTextGraphicService ) )
    1882             :         {
    1883           0 :             exportTextGraphic( xTxtCntnt, bAutoStyles, pRangePropSet );
    1884             :         }
    1885           8 :         else if( xServiceInfo->supportsService( sTextEmbeddedService ) )
    1886             :         {
    1887           8 :             exportTextEmbedded( xTxtCntnt, bAutoStyles, pRangePropSet );
    1888             :         }
    1889           0 :         else if( xServiceInfo->supportsService( sShapeService ) )
    1890             :         {
    1891           0 :             exportShape( xTxtCntnt, bAutoStyles, pRangePropSet );
    1892             :         }
    1893             :         else
    1894             :         {
    1895             :             DBG_ASSERT( !xTxtCntnt.is(), "unknown text content" );
    1896             :         }
    1897             : 
    1898         443 :         if( !bAutoStyles )
    1899             :         {
    1900         201 :             aPrevNumInfo = aNextNumInfo;
    1901             :         }
    1902             : 
    1903         443 :         bHasMoreElements = rContEnum->hasMoreElements();
    1904         443 :     }
    1905             : 
    1906         348 :     if( bExportLevels && bHasContent && !bAutoStyles )
    1907             :     {
    1908          96 :         aNextNumInfo.Reset();
    1909             : 
    1910             :         // close open lists and sections; no new styles
    1911             :         exportListAndSectionChange( xCurrentTextSection, rBaseSection,
    1912             :                                     aPrevNumInfo, aNextNumInfo,
    1913          96 :                                     bAutoStyles );
    1914             :     }
    1915             : 
    1916         696 :     return sal_True;
    1917             : }
    1918             : 
    1919         433 : void XMLTextParagraphExport::exportParagraph(
    1920             :         const Reference < XTextContent > & rTextContent,
    1921             :         sal_Bool bAutoStyles, sal_Bool bIsProgress, sal_Bool bExportParagraph,
    1922             :         MultiPropertySetHelper& rPropSetHelper)
    1923             : {
    1924         433 :     sal_Int16 nOutlineLevel = -1;
    1925             : 
    1926         433 :     if( bIsProgress )
    1927             :     {
    1928         139 :         ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
    1929         139 :         pProgress->SetValue( pProgress->GetValue()+1 );
    1930             :     }
    1931             : 
    1932             :     // get property set or multi property set and initialize helper
    1933         433 :     Reference<XMultiPropertySet> xMultiPropSet( rTextContent, UNO_QUERY );
    1934         866 :     Reference<XPropertySet> xPropSet( rTextContent, UNO_QUERY );
    1935             : 
    1936             :     // check for supported properties
    1937         433 :     if( !rPropSetHelper.checkedProperties() )
    1938         242 :         rPropSetHelper.hasProperties( xPropSet->getPropertySetInfo() );
    1939             : 
    1940             : //  if( xMultiPropSet.is() )
    1941             : //      rPropSetHelper.getValues( xMultiPropSet );
    1942             : //  else
    1943             : //      rPropSetHelper.getValues( xPropSet );
    1944             : 
    1945         433 :     if( bExportParagraph )
    1946             :     {
    1947         187 :         if( bAutoStyles )
    1948             :         {
    1949          36 :             Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, rPropSetHelper, xPropSet );
    1950             :         }
    1951             :         else
    1952             :         {
    1953             :             // xml:id for RDF metadata
    1954         151 :             GetExport().AddAttributeXmlId(rTextContent);
    1955         151 :             GetExport().AddAttributesRDFa(rTextContent);
    1956             : 
    1957         151 :             OUString sStyle;
    1958         151 :             if( rPropSetHelper.hasProperty( PARA_STYLE_NAME ) )
    1959             :             {
    1960         125 :                 if( xMultiPropSet.is() )
    1961             :                     rPropSetHelper.getValue( PARA_STYLE_NAME,
    1962         125 :                                                     xMultiPropSet ) >>= sStyle;
    1963             :                 else
    1964             :                     rPropSetHelper.getValue( PARA_STYLE_NAME,
    1965           0 :                                                     xPropSet ) >>= sStyle;
    1966             :             }
    1967             : 
    1968         151 :             if( rTextContent.is() )
    1969             :             {
    1970         151 :                 const OUString& rIdentifier = GetExport().getInterfaceToIdentifierMapper().getIdentifier( rTextContent );
    1971         151 :                 if( !rIdentifier.isEmpty() )
    1972             :                 {
    1973             :                     // FIXME: this is just temporary until EditEngine
    1974             :                     // paragraphs implement XMetadatable.
    1975             :                     // then that must be used and not the mapper, because
    1976             :                     // when both can be used we get two xml:id!
    1977             :                     uno::Reference<rdf::XMetadatable> const xMeta(rTextContent,
    1978           0 :                         uno::UNO_QUERY);
    1979             :                     OSL_ENSURE(!xMeta.is(), "paragraph that implements "
    1980             :                         "XMetadatable used in interfaceToIdentifierMapper?");
    1981           0 :                     GetExport().AddAttributeIdLegacy(XML_NAMESPACE_TEXT,
    1982           0 :                         rIdentifier);
    1983             :                 }
    1984             :             }
    1985             : 
    1986         302 :             OUString sAutoStyle( sStyle );
    1987         151 :             sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle );
    1988         151 :             if( !sAutoStyle.isEmpty() )
    1989         147 :                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
    1990         294 :                               GetExport().EncodeStyleName( sAutoStyle ) );
    1991             : 
    1992         151 :             if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME ) )
    1993             :             {
    1994         125 :                 OUString sCondStyle;
    1995         125 :                 if( xMultiPropSet.is() )
    1996             :                     rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME,
    1997         125 :                                                      xMultiPropSet ) >>= sCondStyle;
    1998             :                 else
    1999             :                     rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME,
    2000           0 :                                                      xPropSet ) >>= sCondStyle;
    2001         125 :                 if( sCondStyle != sStyle )
    2002             :                 {
    2003           0 :                     sCondStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet,
    2004           0 :                                           sCondStyle );
    2005           0 :                     if( !sCondStyle.isEmpty() )
    2006           0 :                         GetExport().AddAttribute( XML_NAMESPACE_TEXT,
    2007             :                                                   XML_COND_STYLE_NAME,
    2008           0 :                               GetExport().EncodeStyleName( sCondStyle ) );
    2009         125 :                 }
    2010             :             }
    2011             : 
    2012         151 :             if( rPropSetHelper.hasProperty( PARA_OUTLINE_LEVEL ) )
    2013             :             {
    2014         125 :                 if( xMultiPropSet.is() )
    2015             :                     rPropSetHelper.getValue( PARA_OUTLINE_LEVEL,
    2016         125 :                                                      xMultiPropSet ) >>= nOutlineLevel;
    2017             :                 else
    2018             :                     rPropSetHelper.getValue( PARA_OUTLINE_LEVEL,
    2019           0 :                                                      xPropSet ) >>= nOutlineLevel;
    2020             : 
    2021         125 :                 if( 0 < nOutlineLevel )
    2022             :                 {
    2023           0 :                     OUStringBuffer sTmp;
    2024           0 :                     sTmp.append( sal_Int32( nOutlineLevel) );
    2025           0 :                     GetExport().AddAttribute( XML_NAMESPACE_TEXT,
    2026             :                                               XML_OUTLINE_LEVEL,
    2027           0 :                                   sTmp.makeStringAndClear() );
    2028             : 
    2029           0 :                     if( rPropSetHelper.hasProperty( NUMBERING_IS_NUMBER ) )
    2030             :                     {
    2031           0 :                         bool bIsNumber = false;
    2032           0 :                         if( xMultiPropSet.is() )
    2033             :                             rPropSetHelper.getValue(
    2034           0 :                                        NUMBERING_IS_NUMBER, xMultiPropSet ) >>= bIsNumber;
    2035             :                         else
    2036             :                             rPropSetHelper.getValue(
    2037           0 :                                        NUMBERING_IS_NUMBER, xPropSet ) >>= bIsNumber;
    2038             : 
    2039           0 :                         OUString sListStyleName;
    2040           0 :                         if( xMultiPropSet.is() )
    2041             :                             rPropSetHelper.getValue(
    2042           0 :                                        PARA_NUMBERING_STYLENAME, xMultiPropSet ) >>= sListStyleName;
    2043             :                         else
    2044             :                             rPropSetHelper.getValue(
    2045           0 :                                        PARA_NUMBERING_STYLENAME, xPropSet ) >>= sListStyleName;
    2046             : 
    2047             : 
    2048             : 
    2049           0 :                         bool bAssignedtoOutlineStyle = false;
    2050             :                         {
    2051           0 :                             Reference< XChapterNumberingSupplier > xCNSupplier( GetExport().GetModel(), UNO_QUERY );
    2052             : 
    2053           0 :                             OUString sOutlineName;
    2054           0 :                             if (xCNSupplier.is())
    2055             :                             {
    2056           0 :                                 Reference< XIndexReplace > xNumRule ( xCNSupplier->getChapterNumberingRules() );
    2057             :                                 DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" );
    2058             : 
    2059           0 :                                 if (xNumRule.is())
    2060             :                                 {
    2061           0 :                                     Reference< XPropertySet > xNumRulePropSet( xNumRule, UNO_QUERY );
    2062           0 :                                     xNumRulePropSet->getPropertyValue(
    2063           0 :                                         OUString("Name") ) >>= sOutlineName;
    2064           0 :                                     bAssignedtoOutlineStyle = ( sListStyleName == sOutlineName );
    2065           0 :                                 }
    2066           0 :                             }
    2067             :                         }
    2068             : 
    2069           0 :                         if( ! bIsNumber && bAssignedtoOutlineStyle )
    2070           0 :                             GetExport().AddAttribute( XML_NAMESPACE_TEXT,
    2071             :                                                       XML_IS_LIST_HEADER,
    2072           0 :                                                       XML_TRUE );
    2073             :                     }
    2074             : 
    2075             :                     {
    2076           0 :                         OUString sParaIsNumberingRestart("ParaIsNumberingRestart");
    2077           0 :                         bool bIsRestartNumbering = false;
    2078             : 
    2079             :                         Reference< XPropertySetInfo >
    2080           0 :                         xPropSetInfo(xMultiPropSet.is() ?
    2081           0 :                                      xMultiPropSet->getPropertySetInfo():
    2082           0 :                                      xPropSet->getPropertySetInfo());
    2083             : 
    2084           0 :                         if (xPropSetInfo->
    2085           0 :                             hasPropertyByName(sParaIsNumberingRestart))
    2086             :                         {
    2087           0 :                             xPropSet->getPropertyValue(sParaIsNumberingRestart)
    2088           0 :                                 >>= bIsRestartNumbering;
    2089             :                         }
    2090             : 
    2091           0 :                         if (bIsRestartNumbering)
    2092             :                         {
    2093           0 :                             GetExport().AddAttribute(XML_NAMESPACE_TEXT,
    2094             :                                                      XML_RESTART_NUMBERING,
    2095           0 :                                                      XML_TRUE);
    2096             : 
    2097           0 :                             OUString sNumberingStartValue("NumberingStartValue");
    2098             : 
    2099             : 
    2100           0 :                             if (xPropSetInfo->
    2101           0 :                                 hasPropertyByName(sNumberingStartValue))
    2102             :                             {
    2103           0 :                                 sal_Int32 nStartValue = 0;
    2104             : 
    2105           0 :                                 xPropSet->getPropertyValue(sNumberingStartValue)
    2106           0 :                                     >>= nStartValue;
    2107             : 
    2108           0 :                                 OUStringBuffer sTmpStartValue;
    2109             : 
    2110           0 :                                 sTmpStartValue.append(nStartValue);
    2111             : 
    2112           0 :                                 GetExport().
    2113             :                                     AddAttribute(XML_NAMESPACE_TEXT,
    2114             :                                                  XML_START_VALUE,
    2115             :                                                  sTmpStartValue.
    2116           0 :                                                  makeStringAndClear());
    2117           0 :                             }
    2118           0 :                         }
    2119           0 :                     }
    2120             :                 }
    2121         151 :             }
    2122             :         }
    2123             :     }
    2124             : 
    2125         866 :     Reference < XEnumerationAccess > xEA( rTextContent, UNO_QUERY );
    2126         866 :     Reference < XEnumeration > xTextEnum;
    2127         433 :     xTextEnum = xEA->createEnumeration();
    2128         433 :     const sal_Bool bHasPortions = xTextEnum.is();
    2129             : 
    2130         866 :     Reference < XEnumeration> xContentEnum;
    2131         866 :     Reference < XContentEnumerationAccess > xCEA( rTextContent, UNO_QUERY );
    2132         433 :     if( xCEA.is() )
    2133         137 :         xContentEnum.set(xCEA->createContentEnumeration( sTextContentService ));
    2134         570 :     const sal_Bool bHasContentEnum = xContentEnum.is() &&
    2135         570 :                                         xContentEnum->hasMoreElements();
    2136             : 
    2137         866 :     Reference < XTextSection > xSection;
    2138         433 :     if( bHasContentEnum )
    2139             :     {
    2140             :         // For the auto styles, the multi property set helper is only used
    2141             :         // if hard attributes are existing. Therfor, it seems to be a better
    2142             :         // strategy to have the TextSection property separate, because otherwise
    2143             :         // we always retrieve the style names even if they are not required.
    2144           0 :         if( bAutoStyles )
    2145             :         {
    2146           0 :             if( xPropSet->getPropertySetInfo()->hasPropertyByName( sTextSection ) )
    2147             :             {
    2148           0 :                 xSection.set(xPropSet->getPropertyValue( sTextSection ), uno::UNO_QUERY);
    2149             :             }
    2150             :         }
    2151             :         else
    2152             :         {
    2153           0 :             if( rPropSetHelper.hasProperty( TEXT_SECTION ) )
    2154             :             {
    2155           0 :                 xSection.set(rPropSetHelper.getValue( TEXT_SECTION ), uno::UNO_QUERY);
    2156             :             }
    2157             :         }
    2158             :     }
    2159             : 
    2160         433 :     if( bAutoStyles )
    2161             :     {
    2162         242 :         if( bHasContentEnum )
    2163             :             exportTextContentEnumeration(
    2164             :                                     xContentEnum, bAutoStyles, xSection,
    2165           0 :                                     bIsProgress, sal_True, 0, sal_True );
    2166         242 :         if ( bHasPortions )
    2167         242 :             exportTextRangeEnumeration( xTextEnum, bAutoStyles, bIsProgress );
    2168             :     }
    2169             :     else
    2170             :     {
    2171         191 :         sal_Bool bPrevCharIsSpace = sal_True;
    2172             :         enum XMLTokenEnum eElem =
    2173         191 :             0 < nOutlineLevel ? XML_H : XML_P;
    2174         191 :         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, eElem,
    2175         191 :                                   sal_True, sal_False );
    2176         191 :         if( bHasContentEnum )
    2177             :             bPrevCharIsSpace = !exportTextContentEnumeration(
    2178             :                                     xContentEnum, bAutoStyles, xSection,
    2179           0 :                                     bIsProgress );
    2180             :         exportTextRangeEnumeration( xTextEnum, bAutoStyles, bIsProgress,
    2181         191 :                                      bPrevCharIsSpace );
    2182         433 :     }
    2183         433 : }
    2184             : 
    2185         452 : void XMLTextParagraphExport::exportTextRangeEnumeration(
    2186             :         const Reference < XEnumeration > & rTextEnum,
    2187             :         sal_Bool bAutoStyles, sal_Bool bIsProgress,
    2188             :         sal_Bool bPrvChrIsSpc )
    2189             : {
    2190         452 :     static const OUString sMeta("InContentMetadata");
    2191         452 :     static const OUString sFieldMarkName("__FieldMark_");
    2192         452 :     bool bPrevCharIsSpace = bPrvChrIsSpc;
    2193             : 
    2194             :     /* This is  used for exporting to strict OpenDocument 1.2, in which case traditional
    2195             :      * bookmarks are used instead of fieldmarks. */
    2196         452 :     FieldmarkType openFieldMark = NONE;
    2197             : 
    2198        5243 :     while( rTextEnum->hasMoreElements() )
    2199             :     {
    2200        4339 :         Reference<XPropertySet> xPropSet(rTextEnum->nextElement(), UNO_QUERY);
    2201        8674 :         Reference < XTextRange > xTxtRange(xPropSet, uno::UNO_QUERY);
    2202        8674 :         Reference<XPropertySetInfo> xPropInfo(xPropSet->getPropertySetInfo());
    2203             : 
    2204        4339 :         if (xPropInfo->hasPropertyByName(sTextPortionType))
    2205             :         {
    2206        4339 :             OUString sType;
    2207        4339 :             xPropSet->getPropertyValue(sTextPortionType) >>= sType;
    2208             : 
    2209        4339 :             if( sType.equals(sText))
    2210             :             {
    2211             :                 exportTextRange( xTxtRange, bAutoStyles,
    2212        2216 :                                  bPrevCharIsSpace, openFieldMark);
    2213             :             }
    2214        2123 :             else if( sType.equals(sTextField))
    2215             :             {
    2216         186 :                 Reference< ::com::sun::star::text::XFormField > xFormField;
    2217             :                 try
    2218             :                 {
    2219         186 :                     xFormField.set(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
    2220             :                 }
    2221         172 :                 catch( const uno::Exception& )
    2222             :                 {
    2223             :                     SAL_WARN("xmloff", "unexpected bookmark exception");
    2224             :                 }
    2225             : 
    2226         186 :                 if (!xFormField.is() || xFormField->getFieldType() != ODF_COMMENTRANGE)
    2227             :                 {
    2228         184 :                     exportTextField( xTxtRange, bAutoStyles, bIsProgress );
    2229         184 :                     bPrevCharIsSpace = false;
    2230         186 :                 }
    2231             :             }
    2232        1937 :             else if( sType.equals( sFrame ) )
    2233             :             {
    2234          10 :                 Reference < XEnumeration> xContentEnum;
    2235             :                 Reference < XContentEnumerationAccess > xCEA( xTxtRange,
    2236          20 :                                                               UNO_QUERY );
    2237          10 :                 if( xCEA.is() )
    2238          10 :                     xContentEnum.set(xCEA->createContentEnumeration(
    2239          10 :                                                     sTextContentService ));
    2240             :                 // frames are never in sections
    2241          20 :                 Reference<XTextSection> xSection;
    2242          10 :                 if( xContentEnum.is() )
    2243             :                     exportTextContentEnumeration( xContentEnum,
    2244             :                                                     bAutoStyles,
    2245             :                                                     xSection, bIsProgress, sal_True,
    2246          10 :                                                      &xPropSet  );
    2247             : 
    2248          20 :                 bPrevCharIsSpace = false;
    2249             :             }
    2250        1927 :             else if (sType.equals(sFootnote))
    2251             :             {
    2252             :                 exportTextFootnote(xPropSet,
    2253           0 :                                    xTxtRange->getString(),
    2254           0 :                                    bAutoStyles, bIsProgress );
    2255           0 :                 bPrevCharIsSpace = false;
    2256             :             }
    2257        1927 :             else if (sType.equals(sBookmark))
    2258             :             {
    2259             :                 exportTextMark(xPropSet,
    2260             :                                sBookmark,
    2261             :                                lcl_XmlBookmarkElements,
    2262        1896 :                                bAutoStyles);
    2263             :             }
    2264          31 :             else if (sType.equals(sReferenceMark))
    2265             :             {
    2266             :                 exportTextMark(xPropSet,
    2267             :                                sReferenceMark,
    2268             :                                lcl_XmlReferenceElements,
    2269           0 :                                bAutoStyles);
    2270             :             }
    2271          31 :             else if (sType.equals(sDocumentIndexMark))
    2272             :             {
    2273           0 :                 pIndexMarkExport->ExportIndexMark(xPropSet, bAutoStyles);
    2274             :             }
    2275          31 :             else if (sType.equals(sRedline))
    2276             :             {
    2277           0 :                 if (NULL != pRedlineExport)
    2278           0 :                     pRedlineExport->ExportChange(xPropSet, bAutoStyles);
    2279             :             }
    2280          31 :             else if (sType.equals(sRuby))
    2281             :             {
    2282          12 :                 exportRuby(xPropSet, bAutoStyles);
    2283             :             }
    2284          19 :             else if (sType.equals(sMeta))
    2285             :             {
    2286           9 :                 exportMeta(xPropSet, bAutoStyles, bIsProgress);
    2287             :             }
    2288          10 :             else if (sType.equals(sTextFieldStart))
    2289             :             {
    2290           2 :                 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
    2291           2 :                 if (xFormField.is() && xFormField->getFieldType() == ODF_COMMENTRANGE)
    2292             :                 {
    2293           2 :                     exportTextField( xTxtRange, bAutoStyles, bIsProgress );
    2294           2 :                     continue;
    2295             :                 }
    2296             : 
    2297             :                 /* As of now, textmarks are a proposed extension to the OpenDocument standard. */
    2298           0 :                 if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
    2299             :                 {
    2300           0 :                     Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
    2301           0 :                     if (xBookmark.is())
    2302             :                     {
    2303           0 :                         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
    2304             :                     }
    2305           0 :                     if (xFormField.is())
    2306             :                     {
    2307           0 :                         GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
    2308             :                     }
    2309           0 :                     GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
    2310           0 :                     if (xFormField.is())
    2311             :                     {
    2312           0 :                         FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
    2313             :                     }
    2314           0 :                     GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
    2315             :                 }
    2316             :                 /* The OpenDocument standard does not include support for TextMarks for now, so use bookmarks instead. */
    2317             :                 else
    2318             :                 {
    2319           0 :                     if (xFormField.is())
    2320             :                     {
    2321           0 :                         OUString sName;
    2322           0 :                         Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
    2323           0 :                         if (xParameters.is() && xParameters->hasByName("Name"))
    2324             :                         {
    2325           0 :                             const Any aValue = xParameters->getByName("Name");
    2326           0 :                             aValue >>= sName;
    2327             :                         }
    2328           0 :                         if (sName.isEmpty())
    2329             :                         {   // name attribute is mandatory, so have to pull a
    2330             :                             // rabbit out of the hat here
    2331           0 :                             sName = sFieldMarkName + OUString::valueOf(
    2332           0 :                                     m_pImpl->AddFieldMarkStart(xFormField));
    2333             :                         }
    2334           0 :                         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
    2335           0 :                                 sName);
    2336           0 :                         SvXMLElementExport aElem( GetExport(), !bAutoStyles,
    2337             :                             XML_NAMESPACE_TEXT, XML_BOOKMARK_START,
    2338           0 :                             sal_False, sal_False );
    2339           0 :                         const OUString sFieldType = xFormField->getFieldType();
    2340           0 :                         if (sFieldType ==  ODF_FORMTEXT)
    2341             :                         {
    2342           0 :                             openFieldMark = TEXT;
    2343             :                         }
    2344           0 :                         else if (sFieldType == ODF_FORMCHECKBOX)
    2345             :                         {
    2346           0 :                             openFieldMark = CHECK;
    2347             :                         }
    2348             :                         else
    2349             :                         {
    2350           0 :                             openFieldMark = NONE;
    2351           0 :                         }
    2352             :                     }
    2353           0 :                 }
    2354             :             }
    2355           8 :             else if (sType.equals(sTextFieldEnd))
    2356             :             {
    2357           2 :                 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
    2358           2 :                 if (xFormField.is() && xFormField->getFieldType() == ODF_COMMENTRANGE)
    2359             :                 {
    2360           2 :                     Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
    2361           4 :                     const OUString& rName = xBookmark->getName();
    2362           2 :                     if (!rName.isEmpty())
    2363           2 :                         GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, rName);
    2364           2 :                     SvXMLElementExport aElem( GetExport(), !bAutoStyles,
    2365             :                         XML_NAMESPACE_OFFICE, XML_ANNOTATION_END,
    2366           6 :                         sal_False, sal_False );
    2367           4 :                     continue;
    2368             :                 }
    2369             : 
    2370           0 :                 if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
    2371             :                 {
    2372           0 :                     SvXMLElementExport aElem( GetExport(), !bAutoStyles,
    2373             :                         XML_NAMESPACE_FIELD, XML_FIELDMARK_END,
    2374           0 :                         sal_False, sal_False );
    2375             :                 }
    2376             :                 else
    2377             :                 {
    2378           0 :                     if (xFormField.is())
    2379             :                     {
    2380           0 :                         OUString sName;
    2381           0 :                         Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
    2382           0 :                         if (xParameters.is() && xParameters->hasByName("Name"))
    2383             :                         {
    2384           0 :                             const Any aValue = xParameters->getByName("Name");
    2385           0 :                             aValue >>= sName;
    2386             :                         }
    2387           0 :                         if (sName.isEmpty())
    2388             :                         {   // name attribute is mandatory, so have to pull a
    2389             :                             // rabbit out of the hat here
    2390           0 :                             sName = sFieldMarkName + OUString::valueOf(
    2391           0 :                                 m_pImpl->GetFieldMarkIndex(xFormField));
    2392             :                         }
    2393           0 :                         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
    2394           0 :                                 sName);
    2395           0 :                         SvXMLElementExport aElem( GetExport(), !bAutoStyles,
    2396             :                             XML_NAMESPACE_TEXT, XML_BOOKMARK_END,
    2397           0 :                             sal_False, sal_False );
    2398             :                     }
    2399           0 :                 }
    2400             :             }
    2401           6 :             else if (sType.equals(sTextFieldStartEnd))
    2402             :             {
    2403           0 :                 if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
    2404             :                 {
    2405           0 :                     Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
    2406           0 :                     if (xBookmark.is())
    2407             :                     {
    2408           0 :                         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
    2409             :                     }
    2410           0 :                     Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
    2411           0 :                     if (xFormField.is())
    2412             :                     {
    2413           0 :                         GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
    2414             :                     }
    2415           0 :                     GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);
    2416           0 :                     if (xFormField.is())
    2417             :                     {
    2418           0 :                         FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
    2419             :                     }
    2420           0 :                     GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);
    2421             :                 }
    2422             :                 else
    2423             :                 {
    2424           0 :                     Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
    2425           0 :                     if (xBookmark.is())
    2426             :                     {
    2427           0 :                         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
    2428           0 :                         SvXMLElementExport aElem( GetExport(), !bAutoStyles,
    2429             :                             XML_NAMESPACE_TEXT, XML_BOOKMARK,
    2430           0 :                             sal_False, sal_False );
    2431           0 :                     }
    2432             :                 }
    2433             :             }
    2434           6 :             else if (sType.equals(sSoftPageBreak))
    2435             :             {
    2436           6 :                 exportSoftPageBreak(xPropSet,   bAutoStyles);
    2437             :             }
    2438             :             else {
    2439             :                 OSL_FAIL("unknown text portion type");
    2440        4335 :             }
    2441             :         }
    2442             :         else
    2443             :         {
    2444           0 :             Reference<XServiceInfo> xServiceInfo( xTxtRange, UNO_QUERY );
    2445           0 :             if( xServiceInfo->supportsService( sTextFieldService ) )
    2446             :             {
    2447           0 :                 exportTextField( xTxtRange, bAutoStyles, bIsProgress );
    2448           0 :                 bPrevCharIsSpace = false;
    2449             :             }
    2450             :             else
    2451             :             {
    2452             :                 // no TextPortionType property -> non-Writer app -> text
    2453           0 :                 exportTextRange( xTxtRange, bAutoStyles, bPrevCharIsSpace, openFieldMark );
    2454           0 :             }
    2455             :         }
    2456        4335 :     }
    2457             : 
    2458             : // now that there are nested enumerations for meta(-field), this may be valid!
    2459             : //  DBG_ASSERT( !bOpenRuby, "Red Alert: Ruby still open!" );
    2460         452 : }
    2461             : 
    2462           0 : void XMLTextParagraphExport::exportTable(
    2463             :         const Reference < XTextContent > &,
    2464             :         sal_Bool /*bAutoStyles*/, sal_Bool /*bIsProgress*/ )
    2465             : {
    2466           0 : }
    2467             : 
    2468         186 : void XMLTextParagraphExport::exportTextField(
    2469             :         const Reference < XTextRange > & rTextRange,
    2470             :         sal_Bool bAutoStyles, sal_Bool bIsProgress )
    2471             : {
    2472         186 :     Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY );
    2473             :     // non-Writer apps need not support Property TextField, so test first
    2474         186 :     if (xPropSet->getPropertySetInfo()->hasPropertyByName( sTextField ))
    2475             :     {
    2476         186 :         Reference < XTextField > xTxtFld(xPropSet->getPropertyValue( sTextField ), uno::UNO_QUERY);
    2477             :         DBG_ASSERT( xTxtFld.is(), "text field missing" );
    2478         186 :         if( xTxtFld.is() )
    2479             :         {
    2480         186 :             exportTextField(xTxtFld, bAutoStyles, bIsProgress, sal_True);
    2481             :         }
    2482             :         else
    2483             :         {
    2484             :             // write only characters
    2485           0 :             GetExport().Characters(rTextRange->getString());
    2486         186 :         }
    2487         186 :     }
    2488         186 : }
    2489             : 
    2490         200 : void XMLTextParagraphExport::exportTextField(
    2491             :         const Reference < XTextField > & xTextField,
    2492             :         const sal_Bool bAutoStyles, const sal_Bool bIsProgress,
    2493             :         const sal_Bool bRecursive )
    2494             : {
    2495         200 :     if ( bAutoStyles )
    2496             :     {
    2497             :         pFieldExport->ExportFieldAutoStyle( xTextField, bIsProgress,
    2498         100 :                 bRecursive );
    2499             :     }
    2500             :     else
    2501             :     {
    2502         100 :         pFieldExport->ExportField( xTextField, bIsProgress );
    2503             :     }
    2504         200 : }
    2505             : 
    2506           6 : void XMLTextParagraphExport::exportSoftPageBreak(
    2507             :     const Reference<XPropertySet> & ,
    2508             :     sal_Bool )
    2509             : {
    2510           6 :     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
    2511             :                               XML_SOFT_PAGE_BREAK, sal_False,
    2512           6 :                               sal_False );
    2513           6 : }
    2514             : 
    2515        1896 : void XMLTextParagraphExport::exportTextMark(
    2516             :     const Reference<XPropertySet> & rPropSet,
    2517             :     const OUString& rProperty,
    2518             :     const enum XMLTokenEnum pElements[],
    2519             :     sal_Bool bAutoStyles)
    2520             : {
    2521             :     // mib said: "Hau wech!"
    2522             :     //
    2523             :     // (Originally, I'd export a span element in case the (book|reference)mark
    2524             :     //  was formatted. This actually makes a difference in case some pervert
    2525             :     //  sets a point reference mark in the document and, say, formats it bold.
    2526             :     //  This basically meaningless formatting will now been thrown away
    2527             :     //  (aka cleaned up), since mib said: ...                   dvo
    2528             : 
    2529        1896 :      if (!bAutoStyles)
    2530             :     {
    2531             :         // name element
    2532        1896 :         Reference<XNamed> xName(rPropSet->getPropertyValue(rProperty), UNO_QUERY);
    2533        1896 :         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
    2534        3792 :                                  xName->getName());
    2535             : 
    2536             :         // start, end, or point-reference?
    2537             :         sal_Int8 nElement;
    2538        1896 :         if( *(sal_Bool *)rPropSet->getPropertyValue(sIsCollapsed).getValue() )
    2539             :         {
    2540           2 :             nElement = 0;
    2541             :         }
    2542             :         else
    2543             :         {
    2544        1894 :             nElement = *(sal_Bool *)rPropSet->getPropertyValue(sIsStart).getValue() ? 1 : 2;
    2545             :         }
    2546             : 
    2547             :         // bookmark, bookmark-start: xml:id and RDFa for RDF metadata
    2548        1896 :         if( nElement < 2 ) {
    2549         949 :             GetExport().AddAttributeXmlId(xName);
    2550             :             const uno::Reference<text::XTextContent> xTextContent(
    2551         949 :                     xName, uno::UNO_QUERY_THROW);
    2552         949 :             GetExport().AddAttributesRDFa(xTextContent);
    2553             :         }
    2554             : 
    2555             :         // export element
    2556             :         DBG_ASSERT(pElements != NULL, "illegal element array");
    2557             :         DBG_ASSERT(nElement >= 0, "illegal element number");
    2558             :         DBG_ASSERT(nElement <= 2, "illegal element number");
    2559        1896 :         SvXMLElementExport aElem(GetExport(),
    2560        1896 :                                  XML_NAMESPACE_TEXT, pElements[nElement],
    2561        3792 :                                  sal_False, sal_False);
    2562             :     }
    2563             :     // else: no styles. (see above)
    2564        1896 : }
    2565             : 
    2566          10 : static sal_Bool lcl_txtpara_isBoundAsChar(
    2567             :         const Reference < XPropertySet > & rPropSet,
    2568             :         const Reference < XPropertySetInfo > & rPropSetInfo )
    2569             : {
    2570          10 :     sal_Bool bIsBoundAsChar = sal_False;
    2571          10 :     OUString sAnchorType( "AnchorType"  );
    2572          10 :     if( rPropSetInfo->hasPropertyByName( sAnchorType ) )
    2573             :     {
    2574             :         TextContentAnchorType eAnchor;
    2575          10 :         rPropSet->getPropertyValue( sAnchorType ) >>= eAnchor;
    2576          10 :         bIsBoundAsChar = TextContentAnchorType_AS_CHARACTER == eAnchor;
    2577             :     }
    2578             : 
    2579          10 :     return bIsBoundAsChar;
    2580             : }
    2581             : 
    2582          10 : sal_Int32 XMLTextParagraphExport::addTextFrameAttributes(
    2583             :     const Reference < XPropertySet >& rPropSet,
    2584             :     sal_Bool bShape,
    2585             :     OUString *pMinHeightValue,
    2586             :     OUString *pMinWidthValue)
    2587             : {
    2588          10 :     sal_Int32 nShapeFeatures = SEF_DEFAULT;
    2589             : 
    2590             :     // draw:name (#97662#: not for shapes, since those names will be
    2591             :     // treated in the shape export)
    2592          10 :     if( !bShape )
    2593             :     {
    2594          10 :         Reference < XNamed > xNamed( rPropSet, UNO_QUERY );
    2595          10 :         if( xNamed.is() )
    2596             :         {
    2597          10 :             OUString sName( xNamed->getName() );
    2598          10 :             if( !sName.isEmpty() )
    2599           6 :                 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_NAME,
    2600          12 :                                           xNamed->getName() );
    2601          10 :         }
    2602             :     }
    2603             : 
    2604          10 :     OUStringBuffer sValue;
    2605             : 
    2606             :     // text:anchor-type
    2607          10 :     TextContentAnchorType eAnchor = TextContentAnchorType_AT_PARAGRAPH;
    2608          10 :     rPropSet->getPropertyValue( sAnchorType ) >>= eAnchor;
    2609             :     {
    2610          10 :         XMLAnchorTypePropHdl aAnchorTypeHdl;
    2611          20 :         OUString sTmp;
    2612             :         aAnchorTypeHdl.exportXML( sTmp, uno::makeAny(eAnchor),
    2613          10 :                                   GetExport().GetMM100UnitConverter() );
    2614          20 :         GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, sTmp );
    2615             :     }
    2616             : 
    2617             :     // text:anchor-page-number
    2618          10 :     if( TextContentAnchorType_AT_PAGE == eAnchor )
    2619             :     {
    2620           0 :         sal_Int16 nPage = 0;
    2621           0 :         rPropSet->getPropertyValue( sAnchorPageNo ) >>= nPage;
    2622             :         SAL_WARN_IF(nPage <= 0, "xmloff",
    2623             :                 "ERROR: writing invalid anchor-page-number 0");
    2624           0 :         ::sax::Converter::convertNumber( sValue, (sal_Int32)nPage );
    2625           0 :         GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_PAGE_NUMBER,
    2626           0 :                                   sValue.makeStringAndClear() );
    2627             :     }
    2628             :     else
    2629             :     {
    2630             :         // #92210#
    2631          10 :         nShapeFeatures |= SEF_EXPORT_NO_WS;
    2632             :     }
    2633             : 
    2634             :     // OD 2004-06-01 #i27691# - correction: no export of svg:x, if object
    2635             :     // is anchored as-character.
    2636          20 :     if ( !bShape &&
    2637          10 :          eAnchor != TextContentAnchorType_AS_CHARACTER )
    2638             :     {
    2639             :         // svg:x
    2640           2 :         sal_Int16 nHoriOrient =  HoriOrientation::NONE;
    2641           2 :         rPropSet->getPropertyValue( sHoriOrient ) >>= nHoriOrient;
    2642           2 :         if( HoriOrientation::NONE == nHoriOrient )
    2643             :         {
    2644           2 :             sal_Int32 nPos = 0;
    2645           2 :             rPropSet->getPropertyValue( sHoriOrientPosition ) >>= nPos;
    2646           2 :             GetExport().GetMM100UnitConverter().convertMeasureToXML(
    2647           4 :                     sValue, nPos );
    2648           2 :             GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_X,
    2649           4 :                                       sValue.makeStringAndClear() );
    2650           2 :         }
    2651             :     }
    2652           8 :     else if( TextContentAnchorType_AS_CHARACTER == eAnchor )
    2653           8 :         nShapeFeatures = (nShapeFeatures & ~SEF_EXPORT_X);
    2654             : 
    2655          10 :     if( !bShape || TextContentAnchorType_AS_CHARACTER == eAnchor  )
    2656             :     {
    2657             :         // svg:y
    2658          10 :         sal_Int16 nVertOrient =  VertOrientation::NONE;
    2659          10 :         rPropSet->getPropertyValue( sVertOrient ) >>= nVertOrient;
    2660          10 :         if( VertOrientation::NONE == nVertOrient )
    2661             :         {
    2662           2 :             sal_Int32 nPos = 0;
    2663           2 :             rPropSet->getPropertyValue( sVertOrientPosition ) >>= nPos;
    2664           2 :             GetExport().GetMM100UnitConverter().convertMeasureToXML(
    2665           4 :                     sValue, nPos );
    2666           2 :             GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_Y,
    2667           4 :                                       sValue.makeStringAndClear() );
    2668             :         }
    2669          10 :         if( bShape )
    2670           0 :             nShapeFeatures = (nShapeFeatures & ~SEF_EXPORT_Y);
    2671             :     }
    2672             : 
    2673             : 
    2674          20 :     Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo());
    2675             : 
    2676             :     // svg:width
    2677          10 :     sal_Int16 nWidthType = SizeType::FIX;
    2678          10 :     if( xPropSetInfo->hasPropertyByName( sWidthType ) )
    2679             :     {
    2680           2 :         rPropSet->getPropertyValue( sWidthType ) >>= nWidthType;
    2681             :     }
    2682          10 :     if( xPropSetInfo->hasPropertyByName( sWidth ) )
    2683             :     {
    2684          10 :         sal_Int32 nWidth =  0;
    2685             :         // VAR size will be written as zero min-size
    2686          10 :         if( SizeType::VARIABLE != nWidthType )
    2687             :         {
    2688          10 :             rPropSet->getPropertyValue( sWidth ) >>= nWidth;
    2689             :         }
    2690          10 :         GetExport().GetMM100UnitConverter().convertMeasureToXML(sValue, nWidth);
    2691          10 :         if( SizeType::FIX != nWidthType )
    2692             :         {
    2693             :             assert(pMinWidthValue);
    2694           0 :             if (pMinWidthValue)
    2695             :             {
    2696           0 :                 *pMinWidthValue = sValue.makeStringAndClear();
    2697             :             }
    2698             :         }
    2699             :         else
    2700          10 :             GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH,
    2701          20 :                                       sValue.makeStringAndClear() );
    2702             :     }
    2703          10 :     sal_Bool bSyncWidth = sal_False;
    2704          10 :     if( xPropSetInfo->hasPropertyByName( sIsSyncWidthToHeight ) )
    2705             :     {
    2706          10 :         bSyncWidth = *(sal_Bool *)rPropSet->getPropertyValue( sIsSyncWidthToHeight ).getValue();
    2707          10 :         if( bSyncWidth )
    2708           0 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH,
    2709           0 :                                       XML_SCALE );
    2710             :     }
    2711          10 :     if( !bSyncWidth && xPropSetInfo->hasPropertyByName( sRelativeWidth ) )
    2712             :     {
    2713          10 :         sal_Int16 nRelWidth =  0;
    2714          10 :         rPropSet->getPropertyValue( sRelativeWidth ) >>= nRelWidth;
    2715             :         DBG_ASSERT( nRelWidth >= 0 && nRelWidth <= 254,
    2716             :                     "Got illegal relative width from API" );
    2717          10 :         if( nRelWidth > 0 )
    2718             :         {
    2719           0 :             ::sax::Converter::convertPercent( sValue, nRelWidth );
    2720           0 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH,
    2721           0 :                                       sValue.makeStringAndClear() );
    2722             :         }
    2723             :     }
    2724             : 
    2725             :     // svg:height, fo:min-height or style:rel-height
    2726          10 :     sal_Int16 nSizeType = SizeType::FIX;
    2727          10 :     if( xPropSetInfo->hasPropertyByName( sSizeType ) )
    2728             :     {
    2729           2 :         rPropSet->getPropertyValue( sSizeType ) >>= nSizeType;
    2730             :     }
    2731          10 :     sal_Bool bSyncHeight = sal_False;
    2732          10 :     if( xPropSetInfo->hasPropertyByName( sIsSyncHeightToWidth ) )
    2733             :     {
    2734          10 :         bSyncHeight = *(sal_Bool *)rPropSet->getPropertyValue( sIsSyncHeightToWidth ).getValue();
    2735             :     }
    2736          10 :     sal_Int16 nRelHeight =  0;
    2737          10 :     if( !bSyncHeight && xPropSetInfo->hasPropertyByName( sRelativeHeight ) )
    2738             :     {
    2739          10 :         rPropSet->getPropertyValue( sRelativeHeight ) >>= nRelHeight;
    2740             :     }
    2741          10 :     if( xPropSetInfo->hasPropertyByName( sHeight ) )
    2742             :     {
    2743          10 :         sal_Int32 nHeight =  0;
    2744          10 :         if( SizeType::VARIABLE != nSizeType )
    2745             :         {
    2746          10 :             rPropSet->getPropertyValue( sHeight ) >>= nHeight;
    2747             :         }
    2748          10 :         GetExport().GetMM100UnitConverter().convertMeasureToXML( sValue,
    2749          20 :                                                             nHeight );
    2750          10 :         if( SizeType::FIX != nSizeType && 0==nRelHeight && !bSyncHeight &&
    2751             :              pMinHeightValue )
    2752           0 :             *pMinHeightValue = sValue.makeStringAndClear();
    2753             :         else
    2754          10 :             GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT,
    2755          20 :                                       sValue.makeStringAndClear() );
    2756             :     }
    2757          10 :     if( bSyncHeight )
    2758             :     {
    2759           0 :         GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_HEIGHT,
    2760           0 :                 SizeType::MIN == nSizeType ? XML_SCALE_MIN : XML_SCALE );
    2761             : 
    2762             :     }
    2763          10 :     else if( nRelHeight > 0 )
    2764             :     {
    2765           0 :         ::sax::Converter::convertPercent( sValue, nRelHeight );
    2766           0 :         if( SizeType::MIN == nSizeType )
    2767             :         {
    2768             :             assert(pMinHeightValue);
    2769           0 :             if (pMinHeightValue)
    2770             :             {
    2771           0 :                 *pMinHeightValue = sValue.makeStringAndClear();
    2772             :             }
    2773             :         }
    2774             :         else
    2775           0 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_HEIGHT,
    2776           0 :                                       sValue.makeStringAndClear() );
    2777             :     }
    2778             : 
    2779          20 :     OUString sZOrder( "ZOrder"  );
    2780          10 :     if( xPropSetInfo->hasPropertyByName( sZOrder ) )
    2781             :     {
    2782          10 :         sal_Int32 nZIndex = 0;
    2783          10 :         rPropSet->getPropertyValue( sZOrder ) >>= nZIndex;
    2784          10 :         if( -1 != nZIndex )
    2785             :         {
    2786          10 :             ::sax::Converter::convertNumber( sValue, nZIndex );
    2787          10 :             GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_ZINDEX,
    2788          20 :                                       sValue.makeStringAndClear() );
    2789             :         }
    2790             :     }
    2791             : 
    2792          20 :     return nShapeFeatures;
    2793             : }
    2794             : 
    2795          20 : void XMLTextParagraphExport::exportAnyTextFrame(
    2796             :         const Reference < XTextContent > & rTxtCntnt,
    2797             :         FrameType eType,
    2798             :         sal_Bool bAutoStyles,
    2799             :         sal_Bool bIsProgress,
    2800             :         sal_Bool bExportContent,
    2801             :         const Reference < XPropertySet > *pRangePropSet)
    2802             : {
    2803          20 :     Reference < XPropertySet > xPropSet( rTxtCntnt, UNO_QUERY );
    2804             : 
    2805          20 :     if( bAutoStyles )
    2806             :     {
    2807          10 :         if( FT_EMBEDDED == eType )
    2808           8 :             _collectTextEmbeddedAutoStyles( xPropSet );
    2809             :         // No text frame style for shapes (#i28745#)
    2810           2 :         else if ( FT_SHAPE != eType )
    2811           2 :             Add( XML_STYLE_FAMILY_TEXT_FRAME, xPropSet );
    2812             : 
    2813          30 :         if( pRangePropSet && lcl_txtpara_isBoundAsChar( xPropSet,
    2814          10 :                                             xPropSet->getPropertySetInfo() ) )
    2815           0 :             Add( XML_STYLE_FAMILY_TEXT_TEXT, *pRangePropSet );
    2816             : 
    2817          10 :         switch( eType )
    2818             :         {
    2819             :         case FT_TEXT:
    2820             :             {
    2821             :                 // frame bound frames
    2822           2 :                 if ( bExportContent )
    2823             :                 {
    2824           0 :                     Reference < XTextFrame > xTxtFrame( rTxtCntnt, UNO_QUERY );
    2825           0 :                     Reference < XText > xTxt(xTxtFrame->getText());
    2826           0 :                     exportFrameFrames( sal_True, bIsProgress, &xTxtFrame );
    2827           0 :                     exportText( xTxt, bAutoStyles, bIsProgress, sal_True );
    2828             :                 }
    2829             :             }
    2830           2 :             break;
    2831             :         case FT_SHAPE:
    2832             :             {
    2833           0 :                 Reference < XShape > xShape( rTxtCntnt, UNO_QUERY );
    2834           0 :                 GetExport().GetShapeExport()->collectShapeAutoStyles( xShape );
    2835             :             }
    2836           0 :             break;
    2837             :         default:
    2838           8 :             break;
    2839             :         }
    2840             :     }
    2841             :     else
    2842             :     {
    2843          10 :         Reference< XPropertySetInfo > xPropSetInfo(xPropSet->getPropertySetInfo());
    2844          20 :         Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY );
    2845             :         {
    2846          20 :             sal_Bool bAddCharStyles = pRangePropSet &&
    2847          20 :                 lcl_txtpara_isBoundAsChar( xPropSet, xPropSetInfo );
    2848             : 
    2849             :             sal_Bool bIsUICharStyle;
    2850          10 :             sal_Bool bHasAutoStyle = sal_False;
    2851             :             sal_Bool bDummy;
    2852             : 
    2853          10 :             OUString sStyle;
    2854             : 
    2855          10 :             if( bAddCharStyles )
    2856           8 :                    sStyle = FindTextStyleAndHyperlink( *pRangePropSet, bDummy, bIsUICharStyle, bHasAutoStyle );
    2857             :             else
    2858           2 :                 bIsUICharStyle = sal_False;
    2859             : 
    2860             :             XMLTextCharStyleNamesElementExport aCharStylesExport(
    2861          20 :                 GetExport(), bIsUICharStyle &&
    2862             :                              aCharStyleNamesPropInfoCache.hasProperty(
    2863           0 :                                             *pRangePropSet ), bHasAutoStyle,
    2864          40 :                 *pRangePropSet, sCharStyleNames );
    2865             : 
    2866          10 :             if( !sStyle.isEmpty() )
    2867           0 :                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
    2868           0 :                                   GetExport().EncodeStyleName( sStyle ) );
    2869             :             {
    2870          20 :                 SvXMLElementExport aElem( GetExport(), !sStyle.isEmpty(),
    2871          20 :                     XML_NAMESPACE_TEXT, XML_SPAN, sal_False, sal_False );
    2872             :                 {
    2873          10 :                     SvXMLElementExport aElement( GetExport(),
    2874          20 :                         FT_SHAPE != eType &&
    2875             :                         addHyperlinkAttributes( xPropSet,
    2876          10 :                                                 xPropState,xPropSetInfo ),
    2877          20 :                         XML_NAMESPACE_DRAW, XML_A, sal_False, sal_False );
    2878          10 :                     switch( eType )
    2879             :                     {
    2880             :                     case FT_TEXT:
    2881           2 :                         _exportTextFrame( xPropSet, xPropSetInfo, bIsProgress );
    2882           2 :                         break;
    2883             :                     case FT_GRAPHIC:
    2884           0 :                         _exportTextGraphic( xPropSet, xPropSetInfo );
    2885           0 :                         break;
    2886             :                     case FT_EMBEDDED:
    2887           8 :                         _exportTextEmbedded( xPropSet, xPropSetInfo );
    2888           8 :                         break;
    2889             :                     case FT_SHAPE:
    2890             :                         {
    2891           0 :                             Reference < XShape > xShape( rTxtCntnt, UNO_QUERY );
    2892             :                             sal_Int32 nFeatures =
    2893           0 :                                 addTextFrameAttributes( xPropSet, sal_True );
    2894           0 :                             GetExport().GetShapeExport()
    2895           0 :                                 ->exportShape( xShape, nFeatures );
    2896             :                         }
    2897           0 :                         break;
    2898          10 :                     }
    2899          10 :                 }
    2900          10 :             }
    2901          10 :         }
    2902          20 :     }
    2903          20 : }
    2904             : 
    2905           2 : void XMLTextParagraphExport::_exportTextFrame(
    2906             :         const Reference < XPropertySet > & rPropSet,
    2907             :         const Reference < XPropertySetInfo > & rPropSetInfo,
    2908             :         sal_Bool bIsProgress )
    2909             : {
    2910           2 :     Reference < XTextFrame > xTxtFrame( rPropSet, UNO_QUERY );
    2911           4 :     Reference < XText > xTxt(xTxtFrame->getText());
    2912             : 
    2913           4 :     OUString sStyle;
    2914           2 :     if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
    2915             :     {
    2916           2 :         rPropSet->getPropertyValue( sFrameStyleName ) >>= sStyle;
    2917             :     }
    2918             : 
    2919           4 :     OUString sAutoStyle( sStyle );
    2920           4 :     OUString aMinHeightValue;
    2921           4 :     OUString sMinWidthValue;
    2922           2 :     sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle );
    2923           2 :     if( !sAutoStyle.isEmpty() )
    2924           2 :         GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME,
    2925           4 :                               GetExport().EncodeStyleName( sAutoStyle ) );
    2926           2 :     addTextFrameAttributes(rPropSet, false, &aMinHeightValue, &sMinWidthValue);
    2927             : 
    2928           2 :     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
    2929           4 :                               XML_FRAME, sal_False, sal_True );
    2930             : 
    2931           2 :     if( !aMinHeightValue.isEmpty() )
    2932           0 :         GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_HEIGHT,
    2933           0 :                                   aMinHeightValue );
    2934             : 
    2935           2 :     if (!sMinWidthValue.isEmpty())
    2936             :     {
    2937           0 :         GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_WIDTH,
    2938           0 :                                   sMinWidthValue );
    2939             :     }
    2940             : 
    2941             :     // draw:chain-next-name
    2942           2 :     if( rPropSetInfo->hasPropertyByName( sChainNextName ) )
    2943             :     {
    2944           2 :         OUString sNext;
    2945           2 :         if( (rPropSet->getPropertyValue( sChainNextName ) >>= sNext) && !sNext.isEmpty() )
    2946           0 :             GetExport().AddAttribute( XML_NAMESPACE_DRAW,
    2947             :                                       XML_CHAIN_NEXT_NAME,
    2948           0 :                                       sNext );
    2949             :     }
    2950             : 
    2951             :     {
    2952           2 :         SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_DRAW,
    2953           2 :                                   XML_TEXT_BOX, sal_True, sal_True );
    2954             : 
    2955             :         // frame bound frames
    2956           2 :         exportFramesBoundToFrame( xTxtFrame, bIsProgress );
    2957             : 
    2958           2 :         exportText( xTxt, sal_False, bIsProgress, sal_True );
    2959             :     }
    2960             : 
    2961             :     // script:events
    2962           4 :     Reference<XEventsSupplier> xEventsSupp( xTxtFrame, UNO_QUERY );
    2963           2 :     GetExport().GetEventExport().Export(xEventsSupp);
    2964             : 
    2965             :     // image map
    2966           2 :     GetExport().GetImageMapExport().Export( rPropSet );
    2967             : 
    2968             :     // svg:title and svg:desc (#i73249#)
    2969           4 :     exportTitleAndDescription( rPropSet, rPropSetInfo );
    2970           2 : }
    2971             : 
    2972           8 : void XMLTextParagraphExport::exportContour(
    2973             :         const Reference < XPropertySet > & rPropSet,
    2974             :         const Reference < XPropertySetInfo > & rPropSetInfo )
    2975             : {
    2976           8 :     if( !rPropSetInfo->hasPropertyByName( sContourPolyPolygon ) )
    2977           8 :         return;
    2978             : 
    2979           8 :     PointSequenceSequence aSourcePolyPolygon;
    2980           8 :     rPropSet->getPropertyValue( sContourPolyPolygon ) >>= aSourcePolyPolygon;
    2981             : 
    2982           8 :     if( !aSourcePolyPolygon.getLength() )
    2983           8 :         return;
    2984             : 
    2985           0 :     awt::Point aPoint( 0, 0 );
    2986           0 :     awt::Size aSize( 0, 0 );
    2987           0 :     sal_Int32 nPolygons = aSourcePolyPolygon.getLength();
    2988           0 :     const PointSequence *pPolygons = aSourcePolyPolygon.getConstArray();
    2989           0 :     while( nPolygons-- )
    2990             :     {
    2991           0 :         sal_Int32 nPoints = pPolygons->getLength();
    2992           0 :         const awt::Point *pPoints = pPolygons->getConstArray();
    2993           0 :         while( nPoints-- )
    2994             :         {
    2995           0 :             if( aSize.Width < pPoints->X )
    2996           0 :                 aSize.Width = pPoints->X;
    2997           0 :             if( aSize.Height < pPoints->Y )
    2998           0 :                 aSize.Height = pPoints->Y;
    2999           0 :             pPoints++;
    3000             :         }
    3001           0 :         pPolygons++;
    3002             :     }
    3003             : 
    3004           0 :     sal_Bool bPixel = sal_False;
    3005           0 :     if( rPropSetInfo->hasPropertyByName( sIsPixelContour ) )
    3006             :     {
    3007           0 :         bPixel = *(sal_Bool *)rPropSet->getPropertyValue( sIsPixelContour ).getValue();
    3008             :     }
    3009             : 
    3010             :     // svg: width
    3011           0 :     OUStringBuffer aStringBuffer( 10 );
    3012           0 :     if( bPixel )
    3013             :     {
    3014           0 :         ::sax::Converter::convertMeasurePx(aStringBuffer, aSize.Width);
    3015             :     }
    3016             :     else
    3017             :     {
    3018           0 :         GetExport().GetMM100UnitConverter().convertMeasureToXML(
    3019           0 :                 aStringBuffer, aSize.Width);
    3020             :     }
    3021           0 :     GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH,
    3022           0 :                               aStringBuffer.makeStringAndClear() );
    3023             : 
    3024             :     // svg: height
    3025           0 :     if( bPixel )
    3026             :     {
    3027           0 :         ::sax::Converter::convertMeasurePx(aStringBuffer, aSize.Height);
    3028             :     }
    3029             :     else
    3030             :     {
    3031           0 :         GetExport().GetMM100UnitConverter().convertMeasureToXML(
    3032           0 :                 aStringBuffer, aSize.Height);
    3033             :     }
    3034           0 :     GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT,
    3035           0 :                               aStringBuffer.makeStringAndClear() );
    3036             : 
    3037             :     // svg:viewbox
    3038           0 :     SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height);
    3039           0 :     GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX,
    3040           0 :                 aViewBox.GetExportString());
    3041             : 
    3042           0 :     sal_Int32 nOuterCnt( aSourcePolyPolygon.getLength() );
    3043             : 
    3044           0 :     enum XMLTokenEnum eElem = XML_TOKEN_INVALID;
    3045           0 :     if( 1L == nOuterCnt )
    3046             :     {
    3047             :         // simple polygon shape, can be written as svg:points sequence
    3048             :         /*const*/ PointSequence* pSequence =
    3049           0 :                             (PointSequence*)aSourcePolyPolygon.getConstArray();
    3050             : 
    3051           0 :         SdXMLImExPointsElement aPoints( pSequence, aViewBox, aPoint, aSize );
    3052             : 
    3053             :         // write point array
    3054           0 :         GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_POINTS,
    3055           0 :                                       aPoints.GetExportString());
    3056           0 :         eElem = XML_CONTOUR_POLYGON;
    3057             :     }
    3058             :     else
    3059             :     {
    3060             :         // polypolygon, needs to be written as a svg:path sequence
    3061             :         /*const*/ PointSequence* pOuterSequence =
    3062           0 :                         (PointSequence*)aSourcePolyPolygon.getConstArray();
    3063           0 :         if(pOuterSequence)
    3064             :         {
    3065             :             // prepare svx:d element export
    3066           0 :             SdXMLImExSvgDElement aSvgDElement( aViewBox, GetExport() );
    3067             : 
    3068           0 :             for(sal_Int32 a(0L); a < nOuterCnt; a++)
    3069             :             {
    3070           0 :                 /*const*/ PointSequence* pSequence = pOuterSequence++;
    3071           0 :                 if(pSequence)
    3072             :                 {
    3073             :                     aSvgDElement.AddPolygon(pSequence, 0L, aPoint,
    3074           0 :                         aSize, sal_True );
    3075             :                 }
    3076             :             }
    3077             : 
    3078             :             // write point array
    3079           0 :             GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_D,
    3080           0 :                                       aSvgDElement.GetExportString());
    3081           0 :             eElem = XML_CONTOUR_PATH;
    3082             :         }
    3083             :     }
    3084             : 
    3085           0 :     if( rPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
    3086             :     {
    3087           0 :         sal_Bool bTmp = *(sal_Bool *)rPropSet->getPropertyValue(
    3088           0 :                                             sIsAutomaticContour ).getValue();
    3089           0 :         GetExport().AddAttribute( XML_NAMESPACE_DRAW,
    3090           0 :                       XML_RECREATE_ON_EDIT, bTmp ? XML_TRUE : XML_FALSE );
    3091             :     }
    3092             : 
    3093             :     // write object now
    3094           0 :     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, eElem,
    3095           0 :                               sal_True, sal_True );
    3096             : }
    3097             : 
    3098           0 : void XMLTextParagraphExport::_exportTextGraphic(
    3099             :         const Reference < XPropertySet > & rPropSet,
    3100             :         const Reference < XPropertySetInfo > & rPropSetInfo )
    3101             : {
    3102           0 :     OUString sStyle;
    3103           0 :     if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
    3104             :     {
    3105           0 :         rPropSet->getPropertyValue( sFrameStyleName ) >>= sStyle;
    3106             :     }
    3107             : 
    3108           0 :     OUString sAutoStyle( sStyle );
    3109           0 :     sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle );
    3110           0 :     if( !sAutoStyle.isEmpty() )
    3111           0 :         GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME,
    3112           0 :                                   GetExport().EncodeStyleName( sAutoStyle ) );
    3113           0 :     addTextFrameAttributes( rPropSet, sal_False );
    3114             : 
    3115             :     // svg:transform
    3116           0 :     sal_Int16 nVal = 0;
    3117           0 :     rPropSet->getPropertyValue( sGraphicRotation ) >>= nVal;
    3118           0 :     if( nVal != 0 )
    3119             :     {
    3120           0 :         OUStringBuffer sRet( GetXMLToken(XML_ROTATE).getLength()+4 );
    3121           0 :         sRet.append( GetXMLToken(XML_ROTATE));
    3122           0 :         sRet.append( (sal_Unicode)'(' );
    3123           0 :         ::sax::Converter::convertNumber( sRet, (sal_Int32)nVal );
    3124           0 :         sRet.append( (sal_Unicode)')' );
    3125           0 :         GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_TRANSFORM,
    3126           0 :                                   sRet.makeStringAndClear() );
    3127             :     }
    3128             : 
    3129             :     // original content
    3130           0 :     SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_DRAW, XML_FRAME, sal_False, sal_True);
    3131             : 
    3132             :     // replacement graphic for backwards compatibility, but
    3133             :     // only for SVG currently
    3134           0 :     OUString sReplacementOrigURL;
    3135           0 :     rPropSet->getPropertyValue( sReplacementGraphicURL ) >>= sReplacementOrigURL;
    3136             : 
    3137           0 :     if(sReplacementOrigURL.getLength())
    3138             :     {
    3139           0 :         const OUString sReplacementURL(GetExport().AddEmbeddedGraphicObject( sReplacementOrigURL ));
    3140             : 
    3141             :         // If there is no url, then then graphic is empty
    3142           0 :         if(sReplacementURL.getLength())
    3143             :         {
    3144           0 :             GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sReplacementURL);
    3145           0 :             GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
    3146           0 :             GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED);
    3147           0 :             GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD);
    3148             : 
    3149             :             // xlink:href for replacement, only written for Svg content
    3150           0 :             SvXMLElementExport aElement(GetExport(), XML_NAMESPACE_DRAW, XML_IMAGE, sal_False, sal_True);
    3151             : 
    3152             :             // optional office:binary-data
    3153           0 :             GetExport().AddEmbeddedGraphicObjectAsBase64(sReplacementURL);
    3154           0 :         }
    3155             :     }
    3156             : 
    3157             :     // xlink:href
    3158           0 :     OUString sOrigURL;
    3159           0 :     rPropSet->getPropertyValue( sGraphicURL ) >>= sOrigURL;
    3160           0 :     OUString sURL(GetExport().AddEmbeddedGraphicObject( sOrigURL ));
    3161           0 :     setTextEmbeddedGraphicURL( rPropSet, sURL );
    3162             : 
    3163             :     // If there still is no url, then then graphic is empty
    3164           0 :     if( !sURL.isEmpty() )
    3165             :     {
    3166           0 :         GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
    3167           0 :         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
    3168           0 :         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
    3169           0 :         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE,
    3170           0 :                                                        XML_ONLOAD );
    3171             :     }
    3172             : 
    3173             :     // draw:filter-name
    3174           0 :     OUString sGrfFilter;
    3175           0 :     rPropSet->getPropertyValue( sGraphicFilter ) >>= sGrfFilter;
    3176           0 :     if( !sGrfFilter.isEmpty() )
    3177           0 :         GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_FILTER_NAME,
    3178           0 :                                   sGrfFilter );
    3179             : 
    3180             :     {
    3181           0 :         SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_DRAW,
    3182           0 :                                   XML_IMAGE, sal_False, sal_True );
    3183             : 
    3184             :         // optional office:binary-data
    3185           0 :         GetExport().AddEmbeddedGraphicObjectAsBase64( sOrigURL );
    3186             :     }
    3187             : 
    3188             :     // script:events
    3189           0 :     Reference<XEventsSupplier> xEventsSupp( rPropSet, UNO_QUERY );
    3190           0 :     GetExport().GetEventExport().Export(xEventsSupp);
    3191             : 
    3192             :     // image map
    3193           0 :     GetExport().GetImageMapExport().Export( rPropSet );
    3194             : 
    3195             :     // svg:title and svg:desc (#i73249#)
    3196           0 :     exportTitleAndDescription( rPropSet, rPropSetInfo );
    3197             : 
    3198             :     // draw:contour
    3199           0 :     exportContour( rPropSet, rPropSetInfo );
    3200           0 : }
    3201             : 
    3202           0 : void XMLTextParagraphExport::_collectTextEmbeddedAutoStyles(const Reference < XPropertySet > & )
    3203             : {
    3204             :     DBG_ASSERT( !this, "no API implementation avialable" );
    3205           0 : }
    3206             : 
    3207           0 : void XMLTextParagraphExport::_exportTextEmbedded(
    3208             :         const Reference < XPropertySet > &,
    3209             :         const Reference < XPropertySetInfo > & )
    3210             : {
    3211             :     DBG_ASSERT( !this, "no API implementation avialable" );
    3212           0 : }
    3213             : 
    3214           8 : void XMLTextParagraphExport::exportEvents( const Reference < XPropertySet > & rPropSet )
    3215             : {
    3216             :     // script:events
    3217           8 :     Reference<XEventsSupplier> xEventsSupp( rPropSet, UNO_QUERY );
    3218           8 :     GetExport().GetEventExport().Export(xEventsSupp);
    3219             : 
    3220             :     // image map
    3221          16 :     OUString sImageMap("ImageMap");
    3222           8 :     if (rPropSet->getPropertySetInfo()->hasPropertyByName(sImageMap))
    3223          16 :         GetExport().GetImageMapExport().Export( rPropSet );
    3224           8 : }
    3225             : 
    3226             : // Implement Title/Description Elements UI (#i73249#)
    3227          10 : void XMLTextParagraphExport::exportTitleAndDescription(
    3228             :         const Reference < XPropertySet > & rPropSet,
    3229             :         const Reference < XPropertySetInfo > & rPropSetInfo )
    3230             : {
    3231             :     // svg:title
    3232          10 :     if( rPropSetInfo->hasPropertyByName( sTitle ) )
    3233             :     {
    3234          10 :         OUString sObjTitle;
    3235          10 :         rPropSet->getPropertyValue( sTitle ) >>= sObjTitle;
    3236          10 :         if( !sObjTitle.isEmpty() )
    3237             :         {
    3238           0 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG,
    3239           0 :                                       XML_TITLE, sal_True, sal_False );
    3240           0 :             GetExport().Characters( sObjTitle );
    3241          10 :         }
    3242             :     }
    3243             : 
    3244             :     // svg:description
    3245          10 :     if( rPropSetInfo->hasPropertyByName( sDescription ) )
    3246             :     {
    3247          10 :         OUString sObjDesc;
    3248          10 :         rPropSet->getPropertyValue( sDescription ) >>= sObjDesc;
    3249          10 :         if( !sObjDesc.isEmpty() )
    3250             :         {
    3251           0 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG,
    3252           0 :                                       XML_DESC, sal_True, sal_False );
    3253           0 :             GetExport().Characters( sObjDesc );
    3254          10 :         }
    3255             :     }
    3256          10 : }
    3257             : 
    3258           0 : void XMLTextParagraphExport::setTextEmbeddedGraphicURL(
    3259             :     const Reference < XPropertySet >&,
    3260             :     OUString& /*rStreamName*/ ) const
    3261             : {
    3262           0 : }
    3263             : 
    3264          10 : sal_Bool XMLTextParagraphExport::addHyperlinkAttributes(
    3265             :         const Reference < XPropertySet > & rPropSet,
    3266             :         const Reference < XPropertyState > & rPropState,
    3267             :         const Reference < XPropertySetInfo > & rPropSetInfo )
    3268             : {
    3269          10 :     sal_Bool bExport = sal_False;
    3270          20 :     OUString sHRef, sName, sTargetFrame, sUStyleName, sVStyleName;
    3271          10 :     sal_Bool bServerMap = sal_False;
    3272             : 
    3273          20 :     if( rPropSetInfo->hasPropertyByName( sHyperLinkURL ) &&
    3274          20 :         ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
    3275          10 :                     rPropState->getPropertyState( sHyperLinkURL ) ) )
    3276             :     {
    3277           0 :         rPropSet->getPropertyValue( sHyperLinkURL ) >>= sHRef;
    3278             : 
    3279           0 :         if( !sHRef.isEmpty() )
    3280           0 :             bExport = sal_True;
    3281             :     }
    3282             : 
    3283          20 :     if( rPropSetInfo->hasPropertyByName( sHyperLinkName ) &&
    3284          20 :         ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
    3285          10 :                     rPropState->getPropertyState( sHyperLinkName ) ) )
    3286             :     {
    3287           0 :         rPropSet->getPropertyValue( sHyperLinkName ) >>= sName;
    3288           0 :         if( !sName.isEmpty() )
    3289           0 :             bExport = sal_True;
    3290             :     }
    3291             : 
    3292          20 :     if( rPropSetInfo->hasPropertyByName( sHyperLinkTarget ) &&
    3293          20 :         ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
    3294          10 :                     rPropState->getPropertyState( sHyperLinkTarget ) ) )
    3295             :     {
    3296           0 :         rPropSet->getPropertyValue( sHyperLinkTarget ) >>= sTargetFrame;
    3297           0 :         if( !sTargetFrame.isEmpty() )
    3298           0 :             bExport = sal_True;
    3299             :     }
    3300             : 
    3301          20 :     if( rPropSetInfo->hasPropertyByName( sServerMap ) &&
    3302          20 :         ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
    3303          10 :                     rPropState->getPropertyState( sServerMap ) ) )
    3304             :     {
    3305           0 :         bServerMap = *(sal_Bool *)rPropSet->getPropertyValue( sServerMap ).getValue();
    3306           0 :         if( bServerMap  )
    3307           0 :             bExport = sal_True;
    3308             :     }
    3309             : 
    3310          10 :     if( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) &&
    3311           0 :         ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
    3312           0 :             rPropState->getPropertyState( sUnvisitedCharStyleName ) ) )
    3313             :     {
    3314           0 :         rPropSet->getPropertyValue( sUnvisitedCharStyleName ) >>= sUStyleName;
    3315           0 :         if( !sUStyleName.isEmpty() )
    3316           0 :             bExport = sal_True;
    3317             :     }
    3318             : 
    3319          10 :     if( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) &&
    3320           0 :         ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
    3321           0 :             rPropState->getPropertyState( sVisitedCharStyleName ) ) )
    3322             :     {
    3323           0 :         rPropSet->getPropertyValue( sVisitedCharStyleName ) >>= sVStyleName;
    3324           0 :         if( !sVStyleName.isEmpty() )
    3325           0 :             bExport = sal_True;
    3326             :     }
    3327             : 
    3328          10 :     if( bExport )
    3329             :     {
    3330           0 :         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
    3331           0 :         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference( sHRef ) );
    3332             : 
    3333           0 :         if( !sName.isEmpty() )
    3334           0 :             GetExport().AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME, sName );
    3335             : 
    3336           0 :         if( !sTargetFrame.isEmpty() )
    3337             :         {
    3338           0 :             GetExport().AddAttribute( XML_NAMESPACE_OFFICE,
    3339           0 :                                       XML_TARGET_FRAME_NAME, sTargetFrame );
    3340             :             enum XMLTokenEnum eTok =
    3341           0 :                 sTargetFrame.equalsAsciiL( "_blank", sizeof("_blank")-1 )
    3342           0 :                     ? XML_NEW : XML_REPLACE;
    3343           0 :             GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, eTok );
    3344             :         }
    3345             : 
    3346           0 :         if( bServerMap  )
    3347           0 :             GetExport().AddAttribute( XML_NAMESPACE_OFFICE,
    3348           0 :                                       XML_SERVER_MAP, XML_TRUE );
    3349             : 
    3350           0 :         if( !sUStyleName.isEmpty() )
    3351           0 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT,
    3352           0 :               XML_STYLE_NAME, GetExport().EncodeStyleName( sUStyleName ) );
    3353             : 
    3354           0 :         if( !sVStyleName.isEmpty() )
    3355           0 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT,
    3356           0 :               XML_VISITED_STYLE_NAME, GetExport().EncodeStyleName( sVStyleName ) );
    3357             :     }
    3358             : 
    3359          20 :     return bExport;
    3360             : }
    3361             : 
    3362        2216 : void XMLTextParagraphExport::exportTextRange(
    3363             :         const Reference < XTextRange > & rTextRange,
    3364             :         sal_Bool bAutoStyles,
    3365             :         bool& rPrevCharIsSpace,
    3366             :         FieldmarkType& openFieldMark )
    3367             : {
    3368        2216 :     Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY );
    3369        2216 :     if( bAutoStyles )
    3370             :     {
    3371         228 :         Add( XML_STYLE_FAMILY_TEXT_TEXT, xPropSet );
    3372             :     }
    3373             :     else
    3374             :     {
    3375        1988 :         sal_Bool bHyperlink = sal_False;
    3376        1988 :         sal_Bool bIsUICharStyle = sal_False;
    3377        1988 :         sal_Bool bHasAutoStyle = sal_False;
    3378             : 
    3379             :         OUString sStyle(FindTextStyleAndHyperlink( xPropSet, bHyperlink,
    3380        1988 :                                                         bIsUICharStyle, bHasAutoStyle ));
    3381             : 
    3382        3976 :         Reference < XPropertySetInfo > xPropSetInfo;
    3383        1988 :         if( bHyperlink )
    3384             :         {
    3385           0 :             Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY );
    3386           0 :             xPropSetInfo.set(xPropSet->getPropertySetInfo());
    3387           0 :             bHyperlink = addHyperlinkAttributes( xPropSet, xPropState, xPropSetInfo );
    3388             :         }
    3389        1988 :         SvXMLElementExport aElem( GetExport(), bHyperlink, XML_NAMESPACE_TEXT,
    3390        5964 :                                   XML_A, sal_False, sal_False );
    3391        1988 :         if( bHyperlink )
    3392             :         {
    3393             :             // export events (if supported)
    3394             :             OUString sHyperLinkEvents(
    3395           0 :                 "HyperLinkEvents");
    3396           0 :             if (xPropSetInfo->hasPropertyByName(sHyperLinkEvents))
    3397             :             {
    3398           0 :                 Reference<XNameReplace> xName(xPropSet->getPropertyValue(sHyperLinkEvents), uno::UNO_QUERY);
    3399           0 :                 GetExport().GetEventExport().Export(xName, sal_False);
    3400           0 :             }
    3401             :         }
    3402             : 
    3403             :         {
    3404             :             XMLTextCharStyleNamesElementExport aCharStylesExport(
    3405        3976 :                 GetExport(), bIsUICharStyle &&
    3406             :                              aCharStyleNamesPropInfoCache.hasProperty(
    3407           0 :                                                     xPropSet, xPropSetInfo ), bHasAutoStyle,
    3408        5964 :                 xPropSet, sCharStyleNames );
    3409             : 
    3410        3976 :             OUString aText(rTextRange->getString());
    3411        1988 :             if( !sStyle.isEmpty() )
    3412           4 :                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
    3413           8 :                           GetExport().EncodeStyleName( sStyle ) );
    3414             :             {
    3415             :                 // in a block to make sure it is destroyed before the text:a element
    3416        3976 :                 SvXMLElementExport aElement( GetExport(), !sStyle.isEmpty(),
    3417             :                                           XML_NAMESPACE_TEXT, XML_SPAN, sal_False,
    3418        3976 :                                           sal_False );
    3419             : 
    3420        1988 :                 SvXMLElementExport aElem2( GetExport(), TEXT == openFieldMark,
    3421             :                     XML_NAMESPACE_TEXT, XML_TEXT_INPUT,
    3422        5964 :                     sal_False, sal_False );
    3423        1988 :                 exportText( aText, rPrevCharIsSpace );
    3424        3976 :                 openFieldMark = NONE;
    3425        1988 :             }
    3426        1988 :         }
    3427        2216 :     }
    3428        2216 : }
    3429             : 
    3430        2198 : void XMLTextParagraphExport::exportText( const OUString& rText,
    3431             :                                            bool& rPrevCharIsSpace )
    3432             : {
    3433        2198 :     sal_Int32 nExpStartPos = 0;
    3434        2198 :     sal_Int32 nEndPos = rText.getLength();
    3435        2198 :     sal_Int32 nSpaceChars = 0;
    3436       20574 :     for( sal_Int32 nPos = 0; nPos < nEndPos; nPos++ )
    3437             :     {
    3438       18376 :         sal_Unicode cChar = rText[nPos];
    3439       18376 :         sal_Bool bExpCharAsText = sal_True;
    3440       18376 :         sal_Bool bExpCharAsElement = sal_False;
    3441       18376 :         sal_Bool bCurrCharIsSpace = sal_False;
    3442       18376 :         switch( cChar )
    3443             :         {
    3444             :         case 0x0009:    // Tab
    3445             :         case 0x000A:    // LF
    3446             :             // These characters are exported as text.
    3447           0 :             bExpCharAsElement = sal_True;
    3448           0 :             bExpCharAsText = sal_False;
    3449           0 :             break;
    3450             :         case 0x000D:
    3451           0 :             break;  // legal character
    3452             :         case 0x0020:    // Blank
    3453         967 :             if( rPrevCharIsSpace )
    3454             :             {
    3455             :                 // If the previous character is a space character,
    3456             :                 // too, export a special space element.
    3457           9 :                 bExpCharAsText = sal_False;
    3458             :             }
    3459         967 :             bCurrCharIsSpace = sal_True;
    3460         967 :             break;
    3461             :         default:
    3462       17409 :             if( cChar < 0x0020 )
    3463             :             {
    3464             : #ifdef DBG_UTIL
    3465             :                 OSL_ENSURE( txtparae_bContainsIllegalCharacters ||
    3466             :                             cChar >= 0x0020,
    3467             :                             "illegal character in text content" );
    3468             :                 txtparae_bContainsIllegalCharacters = sal_True;
    3469             : #endif
    3470           0 :                 bExpCharAsText = sal_False;
    3471             :             }
    3472       17409 :             break;
    3473             :         }
    3474             : 
    3475             :         // If the current character is not exported as text
    3476             :            // the text that has not been exported by now has to be exported now.
    3477       18376 :         if( nPos > nExpStartPos && !bExpCharAsText )
    3478             :         {
    3479             :             DBG_ASSERT( 0==nSpaceChars, "pending spaces" );
    3480           1 :             OUString sExp( rText.copy( nExpStartPos, nPos - nExpStartPos ) );
    3481           1 :             GetExport().Characters( sExp );
    3482           1 :             nExpStartPos = nPos;
    3483             :         }
    3484             : 
    3485             :         // If there are spaces left that have not been exported and the
    3486             :         // current chracter is not a space , the pending spaces have to be
    3487             :         // exported now.
    3488       18376 :         if( nSpaceChars > 0 && !bCurrCharIsSpace )
    3489             :         {
    3490             :             DBG_ASSERT( nExpStartPos == nPos, " pending characters" );
    3491             : 
    3492           0 :             if( nSpaceChars > 1 )
    3493             :             {
    3494           0 :                 OUStringBuffer sTmp;
    3495           0 :                 sTmp.append( (sal_Int32)nSpaceChars );
    3496           0 :                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C,
    3497           0 :                               sTmp.makeStringAndClear() );
    3498             :             }
    3499             : 
    3500           0 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
    3501           0 :                                       XML_S, sal_False, sal_False );
    3502             : 
    3503           0 :             nSpaceChars = 0;
    3504             :         }
    3505             : 
    3506             :         // If the current character has to be exported as a special
    3507             :         // element, the elemnt will be exported now.
    3508       18376 :         if( bExpCharAsElement )
    3509             :         {
    3510           0 :             switch( cChar )
    3511             :             {
    3512             :             case 0x0009:    // Tab
    3513             :                 {
    3514           0 :                     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
    3515             :                                               XML_TAB, sal_False,
    3516           0 :                                               sal_False );
    3517             :                 }
    3518           0 :                 break;
    3519             :             case 0x000A:    // LF
    3520             :                 {
    3521           0 :                     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
    3522             :                                               XML_LINE_BREAK, sal_False,
    3523           0 :                                               sal_False );
    3524             :                 }
    3525           0 :                 break;
    3526             :             }
    3527             :         }
    3528             : 
    3529             :         // If the current character is a space, and the previous one
    3530             :         // is a space, too, the number of pending spaces is incremented
    3531             :         // only.
    3532       18376 :         if( bCurrCharIsSpace && rPrevCharIsSpace )
    3533           9 :             nSpaceChars++;
    3534       18376 :         rPrevCharIsSpace = bCurrCharIsSpace;
    3535             : 
    3536             :         // If the currect character is not exported as text, the start
    3537             :         // position for text is the position behind the current position.
    3538       18376 :         if( !bExpCharAsText )
    3539             :         {
    3540             :             DBG_ASSERT( nExpStartPos == nPos, "wrong export start pos" );
    3541           9 :             nExpStartPos = nPos+1;
    3542             :         }
    3543             :     }
    3544             : 
    3545        2198 :     if( nExpStartPos < nEndPos )
    3546             :     {
    3547             :         DBG_ASSERT( 0==nSpaceChars, " pending spaces " );
    3548        2161 :         OUString sExp( rText.copy( nExpStartPos, nEndPos - nExpStartPos ) );
    3549        2161 :         GetExport().Characters( sExp );
    3550             :     }
    3551             : 
    3552             :     // If there are some spaces left, they have to be exported now.
    3553        2198 :     if( nSpaceChars > 0 )
    3554             :     {
    3555           9 :         if( nSpaceChars > 1 )
    3556             :         {
    3557           0 :             OUStringBuffer sTmp;
    3558           0 :             sTmp.append( (sal_Int32)nSpaceChars );
    3559           0 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C,
    3560           0 :                           sTmp.makeStringAndClear() );
    3561             :         }
    3562             : 
    3563           9 :         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_S,
    3564           9 :                                   sal_False, sal_False );
    3565             :     }
    3566        2198 : }
    3567             : 
    3568          16 : void XMLTextParagraphExport::exportTextDeclarations()
    3569             : {
    3570          16 :     pFieldExport->ExportFieldDeclarations();
    3571             : 
    3572             :     // get XPropertySet from the document and ask for AutoMarkFileURL.
    3573             :     // If it exists, export the auto-mark-file element.
    3574          16 :     Reference<XPropertySet> xPropertySet( GetExport().GetModel(), UNO_QUERY );
    3575          16 :     if (xPropertySet.is())
    3576             :     {
    3577          16 :         OUString sUrl;
    3578             :         OUString sIndexAutoMarkFileURL(
    3579          32 :             "IndexAutoMarkFileURL");
    3580          32 :         if (xPropertySet->getPropertySetInfo()->hasPropertyByName(
    3581          16 :             sIndexAutoMarkFileURL))
    3582             :         {
    3583          16 :             xPropertySet->getPropertyValue(sIndexAutoMarkFileURL) >>= sUrl;
    3584          16 :             if (!sUrl.isEmpty())
    3585             :             {
    3586           0 :                 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF,
    3587           0 :                                           GetExport().GetRelativeReference(sUrl) );
    3588             :                 SvXMLElementExport aAutoMarkElement(
    3589           0 :                     GetExport(), XML_NAMESPACE_TEXT,
    3590             :                     XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE,
    3591           0 :                     sal_True, sal_True );
    3592             :             }
    3593          16 :         }
    3594          16 :     }
    3595          16 : }
    3596             : 
    3597          52 : void XMLTextParagraphExport::exportTextDeclarations(
    3598             :     const Reference<XText> & rText )
    3599             : {
    3600          52 :     pFieldExport->ExportFieldDeclarations(rText);
    3601          52 : }
    3602             : 
    3603          16 : void XMLTextParagraphExport::exportUsedDeclarations( sal_Bool bOnlyUsed )
    3604             : {
    3605          16 :     pFieldExport->SetExportOnlyUsedFieldDeclarations( bOnlyUsed );
    3606          16 : }
    3607             : 
    3608             : 
    3609          32 : void XMLTextParagraphExport::exportTrackedChanges(sal_Bool bAutoStyles)
    3610             : {
    3611          32 :     if (NULL != pRedlineExport)
    3612          32 :         pRedlineExport->ExportChangesList( bAutoStyles );
    3613          32 : }
    3614             : 
    3615          24 : void XMLTextParagraphExport::exportTrackedChanges(
    3616             :     const Reference<XText> & rText,
    3617             :     sal_Bool bAutoStyle)
    3618             : {
    3619          24 :     if (NULL != pRedlineExport)
    3620          24 :         pRedlineExport->ExportChangesList(rText, bAutoStyle);
    3621          24 : }
    3622             : 
    3623          24 : void XMLTextParagraphExport::recordTrackedChangesForXText(
    3624             :     const Reference<XText> & rText )
    3625             : {
    3626          24 :     if (NULL != pRedlineExport)
    3627          24 :         pRedlineExport->SetCurrentXText(rText);
    3628          24 : }
    3629             : 
    3630          24 : void XMLTextParagraphExport::recordTrackedChangesNoXText()
    3631             : {
    3632          24 :     if (NULL != pRedlineExport)
    3633          24 :         pRedlineExport->SetCurrentXText();
    3634          24 : }
    3635             : 
    3636             : 
    3637          63 : void XMLTextParagraphExport::exportTextAutoStyles()
    3638             : {
    3639          63 :     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
    3640          63 :                                    GetExport().GetDocHandler(),
    3641          63 :                                    GetExport().GetMM100UnitConverter(),
    3642         126 :                                    GetExport().GetNamespaceMap() );
    3643             : 
    3644          63 :     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_TEXT,
    3645          63 :                                    GetExport().GetDocHandler(),
    3646          63 :                                    GetExport().GetMM100UnitConverter(),
    3647         126 :                                    GetExport().GetNamespaceMap() );
    3648             : 
    3649          63 :     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_FRAME,
    3650          63 :                                    GetExport().GetDocHandler(),
    3651          63 :                                    GetExport().GetMM100UnitConverter(),
    3652         126 :                                    GetExport().GetNamespaceMap() );
    3653             : 
    3654          63 :     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_SECTION,
    3655          63 :                                   GetExport().GetDocHandler(),
    3656          63 :                                   GetExport().GetMM100UnitConverter(),
    3657         126 :                                   GetExport().GetNamespaceMap() );
    3658             : 
    3659          63 :     GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_RUBY,
    3660          63 :                                   GetExport().GetDocHandler(),
    3661          63 :                                   GetExport().GetMM100UnitConverter(),
    3662         126 :                                   GetExport().GetNamespaceMap() );
    3663             : 
    3664          63 :     pListAutoPool->exportXML();
    3665          63 : }
    3666             : 
    3667          12 : void XMLTextParagraphExport::exportRuby(
    3668             :     const Reference<XPropertySet> & rPropSet,
    3669             :     sal_Bool bAutoStyles )
    3670             : {
    3671             :     // early out: a collapsed ruby makes no sense
    3672          12 :     if (*(sal_Bool*)rPropSet->getPropertyValue(sIsCollapsed).getValue())
    3673           0 :         return;
    3674             : 
    3675             :     // start value ?
    3676          12 :     sal_Bool bStart = (*(sal_Bool*)rPropSet->getPropertyValue(sIsStart).getValue());
    3677             : 
    3678          12 :     if (bAutoStyles)
    3679             :     {
    3680             :         // ruby auto styles
    3681           0 :         if (bStart)
    3682           0 :             Add( XML_STYLE_FAMILY_TEXT_RUBY, rPropSet );
    3683             :     }
    3684             :     else
    3685             :     {
    3686          12 :         if (bStart)
    3687             :         {
    3688             :             // ruby start
    3689             : 
    3690             :             // we can only start a ruby if none is open
    3691             :             DBG_ASSERT(! bOpenRuby, "Can't open a ruby inside of ruby!");
    3692           6 :             if( bOpenRuby )
    3693           0 :                 return;
    3694             : 
    3695             :             // save ruby text + ruby char style
    3696           6 :             rPropSet->getPropertyValue(sRubyText) >>= sOpenRubyText;
    3697           6 :             rPropSet->getPropertyValue(sRubyCharStyleName) >>= sOpenRubyCharStyle;
    3698             : 
    3699             :             // ruby style
    3700           6 :             GetExport().CheckAttrList();
    3701           6 :             OUString sEmpty;
    3702             :             OUString sStyleName(Find( XML_STYLE_FAMILY_TEXT_RUBY, rPropSet,
    3703          12 :                                         sEmpty ));
    3704             :             DBG_ASSERT(!sStyleName.isEmpty(), "I can't find the style!");
    3705           6 :             GetExport().AddAttribute(XML_NAMESPACE_TEXT,
    3706           6 :                                      XML_STYLE_NAME, sStyleName);
    3707             : 
    3708             :             // export <text:ruby> and <text:ruby-base> start elements
    3709           6 :             GetExport().StartElement( XML_NAMESPACE_TEXT, XML_RUBY, sal_False);
    3710           6 :             GetExport().ClearAttrList();
    3711           6 :             GetExport().StartElement( XML_NAMESPACE_TEXT, XML_RUBY_BASE,
    3712           6 :                                       sal_False );
    3713          12 :             bOpenRuby = sal_True;
    3714             :         }
    3715             :         else
    3716             :         {
    3717             :             // ruby end
    3718             : 
    3719             :             // check for an open ruby
    3720             :             DBG_ASSERT(bOpenRuby, "Can't close a ruby if none is open!");
    3721           6 :             if( !bOpenRuby )
    3722           0 :                 return;
    3723             : 
    3724             :             // close <text:ruby-base>
    3725           6 :             GetExport().EndElement(XML_NAMESPACE_TEXT, XML_RUBY_BASE,
    3726           6 :                                    sal_False);
    3727             : 
    3728             :             // write the ruby text (with char style)
    3729             :             {
    3730           6 :                 if (!sOpenRubyCharStyle.isEmpty())
    3731           0 :                     GetExport().AddAttribute(
    3732             :                         XML_NAMESPACE_TEXT, XML_STYLE_NAME,
    3733           0 :                         GetExport().EncodeStyleName( sOpenRubyCharStyle) );
    3734             : 
    3735             :                 SvXMLElementExport aRubyElement(
    3736           6 :                     GetExport(), XML_NAMESPACE_TEXT, XML_RUBY_TEXT,
    3737           6 :                     sal_False, sal_False);
    3738             : 
    3739           6 :                 GetExport().Characters(sOpenRubyText);
    3740             :             }
    3741             : 
    3742             :             // and finally, close the ruby
    3743           6 :             GetExport().EndElement(XML_NAMESPACE_TEXT, XML_RUBY, sal_False);
    3744           6 :             bOpenRuby = sal_False;
    3745             :         }
    3746             :     }
    3747             : }
    3748             : 
    3749           9 : void XMLTextParagraphExport::exportMeta(
    3750             :     const Reference<XPropertySet> & i_xPortion,
    3751             :     sal_Bool i_bAutoStyles, sal_Bool i_isProgress)
    3752             : {
    3753           9 :     static OUString sMeta("InContentMetadata");
    3754             : 
    3755           9 :     bool doExport(!i_bAutoStyles); // do not export element if autostyles
    3756             :     // check version >= 1.2
    3757           9 :     switch (GetExport().getDefaultVersion()) {
    3758             :         case SvtSaveOptions::ODFVER_011: // fall thru
    3759           0 :         case SvtSaveOptions::ODFVER_010: doExport = false; break;
    3760           9 :         default: break;
    3761             :     }
    3762             : 
    3763             :     const Reference< XTextContent > xTextContent(
    3764           9 :             i_xPortion->getPropertyValue(sMeta), UNO_QUERY_THROW);
    3765          18 :     const Reference< XEnumerationAccess > xEA( xTextContent, UNO_QUERY_THROW );
    3766          18 :     const Reference< XEnumeration > xTextEnum( xEA->createEnumeration() );
    3767             : 
    3768           9 :     if (doExport)
    3769             :     {
    3770           9 :         const Reference<rdf::XMetadatable> xMeta(xTextContent, UNO_QUERY_THROW);
    3771             : 
    3772             :         // text:meta with neither xml:id nor RDFa is invalid
    3773           9 :         xMeta->ensureMetadataReference();
    3774             : 
    3775             :         // xml:id and RDFa for RDF metadata
    3776           9 :         GetExport().AddAttributeXmlId(xMeta);
    3777           9 :         GetExport().AddAttributesRDFa(xTextContent);
    3778             :     }
    3779             : 
    3780           9 :     SvXMLElementExport aElem( GetExport(), doExport,
    3781          27 :         XML_NAMESPACE_TEXT, XML_META, sal_False, sal_False );
    3782             : 
    3783             :     // recurse to export content
    3784          18 :     exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_isProgress );
    3785           9 : }
    3786             : 
    3787             : 
    3788          16 : void XMLTextParagraphExport::PreventExportOfControlsInMuteSections(
    3789             :     const Reference<XIndexAccess> & rShapes,
    3790             :     UniReference<xmloff::OFormLayerXMLExport> xFormExport   )
    3791             : {
    3792             :     // check parameters ad pre-conditions
    3793          16 :     if( ( ! rShapes.is() ) || ( ! xFormExport.is() ) )
    3794             :     {
    3795             :         // if we don't have shapes or a form export, there's nothing to do
    3796           0 :         return;
    3797             :     }
    3798             :     DBG_ASSERT( pSectionExport != NULL, "We need the section export." );
    3799             : 
    3800          16 :     Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration();
    3801          16 :     if(!xShapesEnum.is())
    3802           0 :         return;
    3803          42 :     while( xShapesEnum->hasMoreElements() )
    3804             :     {
    3805             :         // now we need to check
    3806             :         // 1) if this is a control shape, and
    3807             :         // 2) if it's in a mute section
    3808             :         // if both answers are 'yes', notify the form layer export
    3809             : 
    3810             :         // we join accessing the shape and testing for control
    3811          10 :         Reference<XControlShape> xControlShape(xShapesEnum->nextElement(), UNO_QUERY);
    3812          10 :         if( xControlShape.is() )
    3813             :         {
    3814             :             //            Reference<XPropertySet> xPropSet( xControlShape, UNO_QUERY );
    3815             :             //            Reference<XTextContent> xTextContent;
    3816             :             //            xPropSet->getPropertyValue("TextRange") >>= xTextContent;
    3817             : 
    3818           0 :             Reference<XTextContent> xTextContent( xControlShape, UNO_QUERY );
    3819           0 :             if( xTextContent.is() )
    3820             :             {
    3821           0 :                 if( pSectionExport->IsMuteSection( xTextContent, sal_False ) )
    3822             :                 {
    3823             :                     // Ah, we've found a shape that
    3824             :                     // 1) is a control shape
    3825             :                     // 2) is anchored in a mute section
    3826             :                     // so: don't export it!
    3827             :                     xFormExport->excludeFromExport(
    3828           0 :                         xControlShape->getControl() );
    3829             :                 }
    3830             :                 // else: not in mute section -> should be exported -> nothing
    3831             :                 // to do
    3832           0 :             }
    3833             :             // else: no anchor -> ignore
    3834             :         }
    3835             :         // else: no control shape -> nothing to do
    3836          26 :     }
    3837             : }
    3838             : 
    3839         140 : void XMLTextParagraphExport::PushNewTextListsHelper()
    3840             : {
    3841         140 :     mpTextListsHelper = new XMLTextListsHelper();
    3842         140 :     maTextListsHelperStack.push_back( mpTextListsHelper );
    3843         140 : }
    3844             : 
    3845         140 : void XMLTextParagraphExport::PopTextListsHelper()
    3846             : {
    3847         140 :     delete mpTextListsHelper;
    3848         140 :     mpTextListsHelper = 0;
    3849         140 :     maTextListsHelperStack.pop_back();
    3850         140 :     if ( !maTextListsHelperStack.empty() )
    3851             :     {
    3852          52 :         mpTextListsHelper = maTextListsHelperStack.back();
    3853             :     }
    3854         140 : }
    3855             : 
    3856             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10