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