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