bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / text / txtparae.cxx
blob46a19e8a700f9a62fa04d54cc8edb740589561ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
21 #include <tools/debug.hxx>
22 #include <rtl/ustrbuf.hxx>
23 #include <sal/types.h>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/container/XEnumerationAccess.hpp>
26 #include <com/sun/star/container/XEnumeration.hpp>
27 #include <com/sun/star/container/XIndexReplace.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/beans/XMultiPropertySet.hpp>
30 #include <com/sun/star/beans/XPropertyState.hpp>
31 #include <com/sun/star/text/XTextDocument.hpp>
32 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
33 #include <com/sun/star/text/XTextTablesSupplier.hpp>
34 #include <com/sun/star/text/XNumberingRulesSupplier.hpp>
35 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
36 #include <com/sun/star/text/XTextTable.hpp>
37 #include <com/sun/star/text/XText.hpp>
38 #include <com/sun/star/text/XTextContent.hpp>
39 #include <com/sun/star/text/XTextRange.hpp>
40 #include <com/sun/star/text/XTextField.hpp>
41 #include <com/sun/star/text/XFootnote.hpp>
42 #include <com/sun/star/container/XNamed.hpp>
43 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
44 #include <com/sun/star/text/XTextFrame.hpp>
45 #include <com/sun/star/container/XNameAccess.hpp>
46 #include <com/sun/star/text/SizeType.hpp>
47 #include <com/sun/star/text/HoriOrientation.hpp>
48 #include <com/sun/star/text/VertOrientation.hpp>
49 #include <com/sun/star/text/TextContentAnchorType.hpp>
50 #include <com/sun/star/text/XTextFramesSupplier.hpp>
51 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
52 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
53 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
54 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
55 #include <com/sun/star/document/XEventsSupplier.hpp>
56 #include <com/sun/star/document/XRedlinesSupplier.hpp>
57 #include <com/sun/star/text/XBookmarksSupplier.hpp>
58 #include <com/sun/star/text/XFormField.hpp>
59 #include <com/sun/star/text/XTextSection.hpp>
60 #include <com/sun/star/text/SectionFileLink.hpp>
61 #include <com/sun/star/drawing/XShape.hpp>
62 #include <com/sun/star/text/XTextShapesSupplier.hpp>
63 #include <com/sun/star/style/XAutoStylesSupplier.hpp>
64 #include <com/sun/star/style/XAutoStyleFamily.hpp>
65 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
66 #include <com/sun/star/text/XFootnotesSupplier.hpp>
67 #include <com/sun/star/text/XEndnotesSupplier.hpp>
68 #include <com/sun/star/drawing/XControlShape.hpp>
69 #include <com/sun/star/util/DateTime.hpp>
71 #include <sax/tools/converter.hxx>
73 #include <xmloff/xmlnmspe.hxx>
74 #include <xmloff/xmlaustp.hxx>
75 #include <xmloff/families.hxx>
76 #include "txtexppr.hxx"
77 #include <xmloff/xmlnumfe.hxx>
78 #include <xmloff/xmlnume.hxx>
79 #include <xmloff/xmluconv.hxx>
80 #include "XMLAnchorTypePropHdl.hxx"
81 #include "xexptran.hxx"
82 #include <xmloff/ProgressBarHelper.hxx>
83 #include <xmloff/nmspmap.hxx>
84 #include <xmloff/xmlexp.hxx>
85 #include "txtflde.hxx"
86 #include <xmloff/txtprmap.hxx>
87 #include "XMLImageMapExport.hxx"
88 #include "XMLTextNumRuleInfo.hxx"
89 #include <xmloff/XMLTextListAutoStylePool.hxx>
90 #include <xmloff/txtparae.hxx>
91 #include "XMLSectionExport.hxx"
92 #include "XMLIndexMarkExport.hxx"
93 #include <xmloff/XMLEventExport.hxx>
94 #include "XMLRedlineExport.hxx"
95 #include "MultiPropertySetHelper.hxx"
96 #include <xmloff/formlayerexport.hxx>
97 #include "XMLTextCharStyleNamesElementExport.hxx"
98 #include <xmloff/odffields.hxx>
99 #include <xmloff/maptype.hxx>
100 #include <basegfx/polygon/b2dpolypolygon.hxx>
101 #include <basegfx/polygon/b2dpolypolygontools.hxx>
102 #include <basegfx/polygon/b2dpolygontools.hxx>
103 #include <com/sun/star/embed/ElementModes.hpp>
104 #include <com/sun/star/embed/XTransactedObject.hpp>
105 #include <com/sun/star/document/XStorageBasedDocument.hpp>
106 #include <txtlists.hxx>
107 #include <com/sun/star/rdf/XMetadatable.hpp>
108 #include <list>
109 #include <unordered_map>
110 #include <vector>
111 #include <algorithm>
113 using namespace ::std;
114 using namespace ::com::sun::star;
115 using namespace ::com::sun::star::uno;
116 using namespace ::com::sun::star::lang;
117 using namespace ::com::sun::star::beans;
118 using namespace ::com::sun::star::container;
119 using namespace ::com::sun::star::text;
120 using namespace ::com::sun::star::style;
121 using namespace ::com::sun::star::util;
122 using namespace ::com::sun::star::drawing;
123 using namespace ::com::sun::star::document;
124 using namespace ::com::sun::star::frame;
125 using namespace ::xmloff;
126 using namespace ::xmloff::token;
128 namespace
130 class TextContentSet
132 public:
133 typedef Reference<XTextContent> text_content_ref_t;
134 typedef list<text_content_ref_t> contents_t;
135 typedef back_insert_iterator<contents_t> inserter_t;
136 typedef contents_t::const_iterator const_iterator_t;
138 inserter_t getInserter()
139 { return back_insert_iterator<contents_t>(m_vTextContents); };
140 const_iterator_t getBegin() const
141 { return m_vTextContents.begin(); };
142 const_iterator_t getEnd() const
143 { return m_vTextContents.end(); };
145 private:
146 contents_t m_vTextContents;
149 struct FrameRefHash
150 : public unary_function<Reference<XTextFrame>, size_t>
152 size_t operator()(const Reference<XTextFrame>& rFrame) const
153 { return sal::static_int_cast<size_t>(reinterpret_cast<sal_uIntPtr>(rFrame.get())); }
156 static bool lcl_TextContentsUnfiltered(const Reference<XTextContent>&)
157 { return true; };
159 static bool lcl_ShapeFilter(const Reference<XTextContent>& xTxtContent)
161 Reference<XShape> xShape(xTxtContent, UNO_QUERY);
162 if(!xShape.is())
163 return false;
164 Reference<XServiceInfo> xServiceInfo(xTxtContent, UNO_QUERY);
165 if(xServiceInfo->supportsService("com.sun.star.text.TextFrame") ||
166 xServiceInfo->supportsService("com.sun.star.text.TextGraphicObject") ||
167 xServiceInfo->supportsService("com.sun.star.text.TextEmbeddedObject") )
168 return false;
169 return true;
172 class BoundFrames
174 public:
175 typedef bool (*filter_t)(const Reference<XTextContent>&);
176 BoundFrames(
177 const Reference<XEnumerationAccess>& rEnumAccess,
178 const filter_t& rFilter)
179 : m_xEnumAccess(rEnumAccess)
181 Fill(rFilter);
183 BoundFrames()
185 const TextContentSet& GetPageBoundContents() const
186 { return m_vPageBounds; };
187 const TextContentSet* GetFrameBoundContents(const Reference<XTextFrame>& rParentFrame) const
189 framebound_map_t::const_iterator it = m_vFrameBoundsOf.find(rParentFrame);
190 if(it == m_vFrameBoundsOf.end())
191 return NULL;
192 return &(it->second);
194 Reference<XEnumeration> createEnumeration() const
196 if(!m_xEnumAccess.is())
197 return Reference<XEnumeration>();
198 return m_xEnumAccess->createEnumeration();
201 private:
202 typedef std::unordered_map<
203 Reference<XTextFrame>,
204 TextContentSet,
205 FrameRefHash> framebound_map_t;
206 TextContentSet m_vPageBounds;
207 framebound_map_t m_vFrameBoundsOf;
208 const Reference<XEnumerationAccess> m_xEnumAccess;
209 void Fill(const filter_t& rFilter);
212 class FieldParamExporter
214 public:
215 FieldParamExporter(SvXMLExport* const pExport, Reference<XNameContainer> xFieldParams)
216 : m_pExport(pExport)
217 , m_xFieldParams(xFieldParams)
218 { };
219 void Export();
221 private:
222 SvXMLExport* const m_pExport;
223 const Reference<XNameContainer> m_xFieldParams;
225 void ExportParameter(const OUString& sKey, const OUString& sValue);
229 namespace xmloff
231 class BoundFrameSets
233 public:
234 BoundFrameSets(const Reference<XInterface>& rModel);
235 const BoundFrames* GetTexts() const
236 { return m_pTexts.get(); };
237 const BoundFrames* GetGraphics() const
238 { return m_pGraphics.get(); };
239 const BoundFrames* GetEmbeddeds() const
240 { return m_pEmbeddeds.get(); };
241 const BoundFrames* GetShapes() const
242 { return m_pShapes.get(); };
243 private:
244 unique_ptr<BoundFrames> m_pTexts;
245 unique_ptr<BoundFrames> m_pGraphics;
246 unique_ptr<BoundFrames> m_pEmbeddeds;
247 unique_ptr<BoundFrames> m_pShapes;
251 #ifdef DBG_UTIL
252 static bool txtparae_bContainsIllegalCharacters = false;
253 #endif
255 // The following map shows which property values are required:
257 // property auto style pass export
259 // ParaStyleName if style exists always
260 // ParaConditionalStyleName if style exists always
261 // NumberingRules if style exists always
262 // TextSection always always
263 // ParaChapterNumberingLevel never always
264 // NumberingIsNumber never always
266 // The conclusion is that for auto styles the first three properties
267 // should be queried using a multi property set if, and only if, an
268 // auto style needs to be exported. TextSection should be queried by
269 // an individual call to getPropertyvalue, because this seems to be
270 // less expensive than querying the first three properties if they aren't
271 // required.
273 // For the export pass all properties can be queried using a multi property
274 // set.
276 static const sal_Char* aParagraphPropertyNamesAuto[] =
278 "NumberingRules",
279 "ParaConditionalStyleName",
280 "ParaStyleName",
281 NULL
284 enum eParagraphPropertyNamesEnumAuto
286 NUMBERING_RULES_AUTO = 0,
287 PARA_CONDITIONAL_STYLE_NAME_AUTO = 1,
288 PARA_STYLE_NAME_AUTO = 2
291 static const sal_Char* aParagraphPropertyNames[] =
293 "NumberingIsNumber",
294 "NumberingStyleName",
295 "OutlineLevel",
296 "ParaConditionalStyleName",
297 "ParaStyleName",
298 "TextSection",
299 NULL
302 enum eParagraphPropertyNamesEnum
304 NUMBERING_IS_NUMBER = 0,
305 PARA_NUMBERING_STYLENAME = 1,
306 PARA_OUTLINE_LEVEL=2,
307 PARA_CONDITIONAL_STYLE_NAME = 3,
308 PARA_STYLE_NAME = 4,
309 TEXT_SECTION = 5
312 void BoundFrames::Fill(const filter_t& rFilter)
314 if(!m_xEnumAccess.is())
315 return;
316 const Reference< XEnumeration > xEnum = m_xEnumAccess->createEnumeration();
317 if(!xEnum.is())
318 return;
319 const OUString our_sAnchorType("AnchorType");
320 const OUString our_sAnchorFrame("AnchorFrame");
321 while(xEnum->hasMoreElements())
323 Reference<XPropertySet> xPropSet(xEnum->nextElement(), UNO_QUERY);
324 Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY);
325 if(!xPropSet.is() || !xTextContent.is())
326 continue;
327 TextContentAnchorType eAnchor;
328 xPropSet->getPropertyValue(our_sAnchorType) >>= eAnchor;
329 if(TextContentAnchorType_AT_PAGE != eAnchor && TextContentAnchorType_AT_FRAME != eAnchor)
330 continue;
331 if(!rFilter(xTextContent))
332 continue;
334 TextContentSet::inserter_t pInserter = m_vPageBounds.getInserter();
335 if(TextContentAnchorType_AT_FRAME == eAnchor)
337 Reference<XTextFrame> xAnchorTxtFrame(
338 xPropSet->getPropertyValue(our_sAnchorFrame),
339 uno::UNO_QUERY);
340 pInserter = m_vFrameBoundsOf[xAnchorTxtFrame].getInserter();
342 *pInserter++ = xTextContent;
346 BoundFrameSets::BoundFrameSets(const Reference<XInterface>& rModel)
347 : m_pTexts(new BoundFrames())
348 , m_pGraphics(new BoundFrames())
349 , m_pEmbeddeds(new BoundFrames())
350 , m_pShapes(new BoundFrames())
352 const Reference<XTextFramesSupplier> xTFS(rModel, UNO_QUERY);
353 const Reference<XTextGraphicObjectsSupplier> xGOS(rModel, UNO_QUERY);
354 const Reference<XTextEmbeddedObjectsSupplier> xEOS(rModel, UNO_QUERY);
355 const Reference<XDrawPageSupplier> xDPS(rModel, UNO_QUERY);
356 if(xTFS.is())
357 m_pTexts.reset(new BoundFrames(
358 Reference<XEnumerationAccess>(xTFS->getTextFrames(), UNO_QUERY),
359 &lcl_TextContentsUnfiltered));
360 if(xGOS.is())
361 m_pGraphics.reset(new BoundFrames(
362 Reference<XEnumerationAccess>(xGOS->getGraphicObjects(), UNO_QUERY),
363 &lcl_TextContentsUnfiltered));
364 if(xEOS.is())
365 m_pEmbeddeds.reset(new BoundFrames(
366 Reference<XEnumerationAccess>(xEOS->getEmbeddedObjects(), UNO_QUERY),
367 &lcl_TextContentsUnfiltered));
368 if(xDPS.is())
369 m_pShapes.reset(new BoundFrames(
370 Reference<XEnumerationAccess>(xDPS->getDrawPage(), UNO_QUERY),
371 &lcl_ShapeFilter));
374 void FieldParamExporter::Export()
376 const Type aStringType = ::cppu::UnoType<OUString>::get();
377 const Type aBoolType = cppu::UnoType<sal_Bool>::get();
378 const Type aSeqType = cppu::UnoType<Sequence<OUString>>::get();
379 const Type aIntType = ::cppu::UnoType<sal_Int32>::get();
380 Sequence<OUString> vParameters(m_xFieldParams->getElementNames());
381 for(const OUString* pCurrent = vParameters.begin(); pCurrent != vParameters.end(); ++pCurrent)
383 const Any aValue = m_xFieldParams->getByName(*pCurrent);
384 const Type aValueType = aValue.getValueType();
385 if(aValueType == aStringType)
387 OUString sValue;
388 aValue >>= sValue;
389 ExportParameter(*pCurrent,sValue);
391 if ( *pCurrent == ODF_OLE_PARAM )
393 // Save the OLE object
394 Reference< embed::XStorage > xTargetStg = m_pExport->GetTargetStorage();
395 Reference< embed::XStorage > xDstStg = xTargetStg->openStorageElement(
396 "OLELinks", embed::ElementModes::WRITE );
398 if ( !xDstStg->hasByName( sValue ) ) {
399 Reference< XStorageBasedDocument > xStgDoc (
400 m_pExport->GetModel( ), UNO_QUERY );
401 Reference< embed::XStorage > xDocStg = xStgDoc->getDocumentStorage();
402 Reference< embed::XStorage > xOleStg = xDocStg->openStorageElement(
403 "OLELinks", embed::ElementModes::READ );
405 xOleStg->copyElementTo( sValue, xDstStg, sValue );
406 Reference< embed::XTransactedObject > xTransact( xDstStg, UNO_QUERY );
407 if ( xTransact.is( ) )
408 xTransact->commit( );
412 else if(aValueType == aBoolType)
414 bool bValue = false;
415 aValue >>= bValue;
416 ExportParameter(*pCurrent, OUString::boolean(bValue) );
418 else if(aValueType == aSeqType)
420 Sequence<OUString> vValue;
421 aValue >>= vValue;
422 for(OUString* pSeqCurrent = vValue.begin(); pSeqCurrent != vValue.end(); ++pSeqCurrent)
424 ExportParameter(*pCurrent, *pSeqCurrent);
427 else if(aValueType == aIntType)
429 sal_Int32 nValue = 0;
430 aValue >>= nValue;
431 ExportParameter(*pCurrent, OUStringBuffer().append(nValue).makeStringAndClear());
436 void FieldParamExporter::ExportParameter(const OUString& sKey, const OUString& sValue)
438 m_pExport->AddAttribute(XML_NAMESPACE_FIELD, XML_NAME, sKey);
439 m_pExport->AddAttribute(XML_NAMESPACE_FIELD, XML_VALUE, sValue);
440 m_pExport->StartElement(XML_NAMESPACE_FIELD, XML_PARAM, false);
441 m_pExport->EndElement(XML_NAMESPACE_FIELD, XML_PARAM, false);
444 void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
445 const Reference < XPropertySet > & rPropSet,
446 const XMLPropertyState** ppAddStates, bool bDontSeek )
448 rtl::Reference < SvXMLExportPropertyMapper > xPropMapper;
449 switch( nFamily )
451 case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
452 xPropMapper = GetParaPropMapper();
453 break;
454 case XML_STYLE_FAMILY_TEXT_TEXT:
455 xPropMapper = GetTextPropMapper();
456 break;
457 case XML_STYLE_FAMILY_TEXT_FRAME:
458 xPropMapper = GetAutoFramePropMapper();
459 break;
460 case XML_STYLE_FAMILY_TEXT_SECTION:
461 xPropMapper = GetSectionPropMapper();
462 break;
463 case XML_STYLE_FAMILY_TEXT_RUBY:
464 xPropMapper = GetRubyPropMapper();
465 break;
467 DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
469 vector< XMLPropertyState > xPropStates =
470 xPropMapper->Filter( rPropSet );
472 if( ppAddStates )
474 while( *ppAddStates )
476 xPropStates.push_back( **ppAddStates );
477 ppAddStates++;
481 if( !xPropStates.empty() )
483 Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo());
484 OUString sParent, sCondParent;
485 sal_uInt16 nIgnoreProps = 0;
486 switch( nFamily )
488 case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
489 if( xPropSetInfo->hasPropertyByName( sParaStyleName ) )
491 rPropSet->getPropertyValue( sParaStyleName ) >>= sParent;
493 if( xPropSetInfo->hasPropertyByName( sParaConditionalStyleName ) )
495 rPropSet->getPropertyValue( sParaConditionalStyleName ) >>= sCondParent;
497 if( xPropSetInfo->hasPropertyByName( sNumberingRules ) )
499 Reference < XIndexReplace > xNumRule(rPropSet->getPropertyValue( sNumberingRules ), uno::UNO_QUERY);
500 if( xNumRule.is() && xNumRule->getCount() )
502 Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
503 OUString sName;
504 if( xNamed.is() )
505 sName = xNamed->getName();
506 bool bAdd = sName.isEmpty();
507 if( !bAdd )
509 Reference < XPropertySet > xNumPropSet( xNumRule,
510 UNO_QUERY );
511 if( xNumPropSet.is() &&
512 xNumPropSet->getPropertySetInfo()
513 ->hasPropertyByName( "IsAutomatic" ) )
515 bAdd = *static_cast<sal_Bool const *>(xNumPropSet->getPropertyValue( "IsAutomatic" ).getValue());
516 // Check on outline style (#i73361#)
517 if ( bAdd &&
518 xNumPropSet->getPropertySetInfo()
519 ->hasPropertyByName( "NumberingIsOutline" ) )
521 bAdd = !(*static_cast<sal_Bool const *>(xNumPropSet->getPropertyValue( "NumberingIsOutline" ).getValue()));
524 else
526 bAdd = true;
529 if( bAdd )
530 pListAutoPool->Add( xNumRule );
533 break;
534 case XML_STYLE_FAMILY_TEXT_TEXT:
536 // Get parent and remove hyperlinks (they aren't of interest)
537 rtl::Reference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper());
538 for( ::std::vector< XMLPropertyState >::iterator i(xPropStates.begin());
539 nIgnoreProps < 2 && i != xPropStates.end(); )
541 if( i->mnIndex == -1 )
543 ++i;
544 continue;
547 switch( xPM->GetEntryContextId(i->mnIndex) )
549 case CTF_CHAR_STYLE_NAME:
550 case CTF_HYPERLINK_URL:
551 i->mnIndex = -1;
552 nIgnoreProps++;
553 i = xPropStates.erase( i );
554 break;
555 default:
556 ++i;
557 break;
561 break;
562 case XML_STYLE_FAMILY_TEXT_FRAME:
563 if( xPropSetInfo->hasPropertyByName( sFrameStyleName ) )
565 rPropSet->getPropertyValue( sFrameStyleName ) >>= sParent;
567 break;
568 case XML_STYLE_FAMILY_TEXT_SECTION:
569 case XML_STYLE_FAMILY_TEXT_RUBY:
570 ; // section styles have no parents
571 break;
573 if( (xPropStates.size() - nIgnoreProps) > 0 )
575 GetAutoStylePool().Add( nFamily, sParent, xPropStates, bDontSeek );
576 if( !sCondParent.isEmpty() && sParent != sCondParent )
577 GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
582 static bool lcl_validPropState( const XMLPropertyState& rState )
584 return rState.mnIndex != -1;
587 void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
588 MultiPropertySetHelper& rPropSetHelper,
589 const Reference < XPropertySet > & rPropSet,
590 const XMLPropertyState** ppAddStates)
592 rtl::Reference < SvXMLExportPropertyMapper > xPropMapper;
593 switch( nFamily )
595 case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
596 xPropMapper = GetParaPropMapper();
597 break;
599 DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
601 vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet ));
602 if( ppAddStates )
604 while( *ppAddStates )
606 xPropStates.push_back( **ppAddStates );
607 ++ppAddStates;
611 if( rPropSetHelper.hasProperty( NUMBERING_RULES_AUTO ) )
613 Reference < XIndexReplace > xNumRule(rPropSetHelper.getValue( NUMBERING_RULES_AUTO,
614 rPropSet, true ), uno::UNO_QUERY);
615 if( xNumRule.is() && xNumRule->getCount() )
617 Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
618 OUString sName;
619 if( xNamed.is() )
620 sName = xNamed->getName();
621 bool bAdd = sName.isEmpty();
622 if( !bAdd )
624 Reference < XPropertySet > xNumPropSet( xNumRule,
625 UNO_QUERY );
626 if( xNumPropSet.is() &&
627 xNumPropSet->getPropertySetInfo()
628 ->hasPropertyByName( "IsAutomatic" ) )
630 bAdd = *static_cast<sal_Bool const *>(xNumPropSet->getPropertyValue( "IsAutomatic" ).getValue());
631 // Check on outline style (#i73361#)
632 if ( bAdd &&
633 xNumPropSet->getPropertySetInfo()
634 ->hasPropertyByName( "NumberingIsOutline" ) )
636 bAdd = !(*static_cast<sal_Bool const *>(xNumPropSet->getPropertyValue( "NumberingIsOutline" ).getValue()));
639 else
641 bAdd = true;
644 if( bAdd )
645 pListAutoPool->Add( xNumRule );
649 if( !xPropStates.empty() )
651 OUString sParent, sCondParent;
652 switch( nFamily )
654 case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
655 if( rPropSetHelper.hasProperty( PARA_STYLE_NAME_AUTO ) )
657 rPropSetHelper.getValue( PARA_STYLE_NAME_AUTO, rPropSet,
658 true ) >>= sParent;
660 if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO ) )
662 rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO,
663 rPropSet, true ) >>= sCondParent;
666 break;
669 if( std::any_of( xPropStates.begin(), xPropStates.end(), lcl_validPropState ) )
671 GetAutoStylePool().Add( nFamily, sParent, xPropStates );
672 if( !sCondParent.isEmpty() && sParent != sCondParent )
673 GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
678 OUString XMLTextParagraphExport::Find(
679 sal_uInt16 nFamily,
680 const Reference < XPropertySet > & rPropSet,
681 const OUString& rParent,
682 const XMLPropertyState** ppAddStates) const
684 OUString sName( rParent );
685 rtl::Reference < SvXMLExportPropertyMapper > xPropMapper;
686 switch( nFamily )
688 case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
689 xPropMapper = GetParaPropMapper();
690 break;
691 case XML_STYLE_FAMILY_TEXT_FRAME:
692 xPropMapper = GetAutoFramePropMapper();
693 break;
694 case XML_STYLE_FAMILY_TEXT_SECTION:
695 xPropMapper = GetSectionPropMapper();
696 break;
697 case XML_STYLE_FAMILY_TEXT_RUBY:
698 xPropMapper = GetRubyPropMapper();
699 break;
701 DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
702 if( !xPropMapper.is() )
703 return sName;
704 vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet ));
705 if( ppAddStates )
707 while( *ppAddStates )
709 xPropStates.push_back( **ppAddStates );
710 ++ppAddStates;
713 if( std::any_of( xPropStates.begin(), xPropStates.end(), lcl_validPropState ) )
714 sName = GetAutoStylePool().Find( nFamily, sName, xPropStates );
716 return sName;
719 OUString XMLTextParagraphExport::FindTextStyleAndHyperlink(
720 const Reference < XPropertySet > & rPropSet,
721 bool& rbHyperlink,
722 bool& rbHasCharStyle,
723 bool& rbHasAutoStyle,
724 const XMLPropertyState** ppAddStates ) const
726 rtl::Reference < SvXMLExportPropertyMapper > xPropMapper(GetTextPropMapper());
727 vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet ));
729 // Get parent and remove hyperlinks (they aren't of interest)
730 OUString sName;
731 rbHyperlink = rbHasCharStyle = rbHasAutoStyle = false;
732 sal_uInt16 nIgnoreProps = 0;
733 rtl::Reference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper());
734 ::std::vector< XMLPropertyState >::iterator aFirstDel = xPropStates.end();
735 ::std::vector< XMLPropertyState >::iterator aSecondDel = xPropStates.end();
737 for( ::std::vector< XMLPropertyState >::iterator
738 i = xPropStates.begin();
739 nIgnoreProps < 2 && i != xPropStates.end();
740 ++i )
742 if( i->mnIndex == -1 )
743 continue;
745 switch( xPM->GetEntryContextId(i->mnIndex) )
747 case CTF_CHAR_STYLE_NAME:
748 i->maValue >>= sName;
749 i->mnIndex = -1;
750 rbHasCharStyle = !sName.isEmpty();
751 if( nIgnoreProps )
752 aSecondDel = i;
753 else
754 aFirstDel = i;
755 nIgnoreProps++;
756 break;
757 case CTF_HYPERLINK_URL:
758 rbHyperlink = true;
759 i->mnIndex = -1;
760 if( nIgnoreProps )
761 aSecondDel = i;
762 else
763 aFirstDel = i;
764 nIgnoreProps++;
765 break;
768 if( ppAddStates )
770 while( *ppAddStates )
772 xPropStates.push_back( **ppAddStates );
773 ppAddStates++;
776 if( (xPropStates.size() - nIgnoreProps) > 0L )
778 // erase the character style, otherwise the autostyle cannot be found!
779 // erase the hyperlink, otherwise the autostyle cannot be found!
780 if ( nIgnoreProps )
782 // If two elements of a vector have to be deleted,
783 // we should delete the second one first.
784 if( --nIgnoreProps )
785 xPropStates.erase( aSecondDel );
786 xPropStates.erase( aFirstDel );
788 OUString sParent; // AutoStyles should not have parents!
789 sName = GetAutoStylePool().Find( XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates );
790 rbHasAutoStyle = true;
793 return sName;
796 // adjustments to support lists independent from list style
797 void XMLTextParagraphExport::exportListChange(
798 const XMLTextNumRuleInfo& rPrevInfo,
799 const XMLTextNumRuleInfo& rNextInfo )
801 // end a list
802 if ( rPrevInfo.GetLevel() > 0 )
804 sal_Int16 nListLevelsToBeClosed = 0;
805 if ( !rNextInfo.BelongsToSameList( rPrevInfo ) ||
806 rNextInfo.GetLevel() <= 0 )
808 // close complete previous list
809 nListLevelsToBeClosed = rPrevInfo.GetLevel();
811 else if ( rPrevInfo.GetLevel() > rNextInfo.GetLevel() )
813 // close corresponding sub lists
814 DBG_ASSERT( rNextInfo.GetLevel() > 0,
815 "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
816 nListLevelsToBeClosed = rPrevInfo.GetLevel() - rNextInfo.GetLevel();
819 if ( nListLevelsToBeClosed > 0 &&
820 pListElements &&
821 pListElements->size() >= sal::static_int_cast< sal_uInt32 >( 2 * nListLevelsToBeClosed ) )
823 do {
824 for(size_t j = 0; j < 2; ++j)
826 OUString aElem(pListElements->back());
827 pListElements->pop_back();
828 GetExport().EndElement(aElem, true);
831 // remove closed list from list stack
832 mpTextListsHelper->PopListFromStack();
834 --nListLevelsToBeClosed;
835 } while ( nListLevelsToBeClosed > 0 );
839 const bool bExportODF =
840 bool( GetExport().getExportFlags() & SvXMLExportFlags::OASIS );
841 const SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion =
842 GetExport().getDefaultVersion();
844 // start a new list
845 if ( rNextInfo.GetLevel() > 0 )
847 bool bRootListToBeStarted = false;
848 sal_Int16 nListLevelsToBeOpened = 0;
849 if ( !rPrevInfo.BelongsToSameList( rNextInfo ) ||
850 rPrevInfo.GetLevel() <= 0 )
852 // new root list
853 bRootListToBeStarted = true;
854 nListLevelsToBeOpened = rNextInfo.GetLevel();
856 else if ( rNextInfo.GetLevel() > rPrevInfo.GetLevel() )
858 // open corresponding sub lists
859 DBG_ASSERT( rPrevInfo.GetLevel() > 0,
860 "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
861 nListLevelsToBeOpened = rNextInfo.GetLevel() - rPrevInfo.GetLevel();
864 if ( nListLevelsToBeOpened > 0 )
866 const OUString sListStyleName( rNextInfo.GetNumRulesName() );
867 // Currently only the text documents support <ListId>.
868 // Thus, for other document types <sListId> is empty.
869 const OUString sListId( rNextInfo.GetListId() );
870 bool bExportListStyle( true );
871 bool bRestartNumberingAtContinuedList( false );
872 sal_Int32 nRestartValueForContinuedList( -1 );
873 bool bContinueingPreviousSubList = !bRootListToBeStarted &&
874 rNextInfo.IsContinueingPreviousSubTree();
875 do {
876 GetExport().CheckAttrList();
878 if ( bRootListToBeStarted )
880 if ( !mpTextListsHelper->IsListProcessed( sListId ) )
882 if ( bExportODF &&
883 eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 &&
884 !sListId.isEmpty() )
886 /* Property text:id at element <text:list> has to be
887 replaced by property xml:id (#i92221#)
889 GetExport().AddAttribute( XML_NAMESPACE_XML,
890 XML_ID,
891 sListId );
893 mpTextListsHelper->KeepListAsProcessed( sListId,
894 sListStyleName,
895 OUString() );
897 else
899 const OUString sNewListId(
900 mpTextListsHelper->GenerateNewListId() );
901 if ( bExportODF &&
902 eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 &&
903 !sListId.isEmpty() )
905 /* Property text:id at element <text:list> has to be
906 replaced by property xml:id (#i92221#)
908 GetExport().AddAttribute( XML_NAMESPACE_XML,
909 XML_ID,
910 sNewListId );
913 const OUString sContinueListId =
914 mpTextListsHelper->GetLastContinuingListId( sListId );
915 // store that list with list id <sNewListId> is last list,
916 // which has continued list with list id <sListId>
917 mpTextListsHelper->StoreLastContinuingList( sListId,
918 sNewListId );
919 if ( sListStyleName ==
920 mpTextListsHelper->GetListStyleOfLastProcessedList() &&
921 // Inconsistent behavior regarding lists (#i92811#)
922 sContinueListId ==
923 mpTextListsHelper->GetLastProcessedListId() &&
924 !rNextInfo.IsRestart() )
926 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
927 XML_CONTINUE_NUMBERING,
928 XML_TRUE );
930 else
932 if ( bExportODF &&
933 eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 &&
934 !sListId.isEmpty() )
936 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
937 XML_CONTINUE_LIST,
938 sContinueListId );
941 if ( rNextInfo.IsRestart() &&
942 ( nListLevelsToBeOpened != 1 ||
943 !rNextInfo.HasStartValue() ) )
945 bRestartNumberingAtContinuedList = true;
946 nRestartValueForContinuedList =
947 rNextInfo.GetListLevelStartValue();
951 mpTextListsHelper->KeepListAsProcessed( sNewListId,
952 sListStyleName,
953 sContinueListId );
956 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
957 GetExport().EncodeStyleName( sListStyleName ) );
958 bExportListStyle = false;
960 bRootListToBeStarted = false;
962 else if ( bExportListStyle &&
963 !mpTextListsHelper->EqualsToTopListStyleOnStack( sListStyleName ) )
965 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
966 GetExport().EncodeStyleName( sListStyleName ) );
967 bExportListStyle = false;
970 else
972 // rhbz#746174: also export list restart for non root list
973 if (rNextInfo.IsRestart() && !rNextInfo.HasStartValue())
975 bRestartNumberingAtContinuedList = true;
976 nRestartValueForContinuedList =
977 rNextInfo.GetListLevelStartValue();
981 if ( bContinueingPreviousSubList )
983 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
984 XML_CONTINUE_NUMBERING, XML_TRUE );
985 bContinueingPreviousSubList = false;
988 enum XMLTokenEnum eLName = XML_LIST;
990 OUString aElem(GetExport().GetNamespaceMap().GetQNameByKey(
991 XML_NAMESPACE_TEXT,
992 GetXMLToken(eLName) ) );
993 GetExport().IgnorableWhitespace();
994 GetExport().StartElement(aElem, false);
996 if(!pListElements)
997 pListElements = new std::vector<OUString>;
998 pListElements->push_back(aElem);
1000 mpTextListsHelper->PushListOnStack( sListId,
1001 sListStyleName );
1003 // <text:list-header> or <text:list-item>
1004 GetExport().CheckAttrList();
1006 /* Export start value at correct list item (#i97309#) */
1007 if ( nListLevelsToBeOpened == 1 )
1009 if ( rNextInfo.HasStartValue() )
1011 OUStringBuffer aBuffer;
1012 aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
1013 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
1014 aBuffer.makeStringAndClear() );
1016 else if (bRestartNumberingAtContinuedList)
1018 OUStringBuffer aBuffer;
1019 aBuffer.append( nRestartValueForContinuedList );
1020 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
1021 XML_START_VALUE,
1022 aBuffer.makeStringAndClear() );
1023 bRestartNumberingAtContinuedList = false;
1027 eLName = ( rNextInfo.IsNumbered() || nListLevelsToBeOpened > 1 )
1028 ? XML_LIST_ITEM
1029 : XML_LIST_HEADER;
1030 aElem = OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1031 XML_NAMESPACE_TEXT,
1032 GetXMLToken(eLName) ) );
1033 GetExport().IgnorableWhitespace();
1034 GetExport().StartElement(aElem, false);
1035 pListElements->push_back(aElem);
1037 // export of <text:number> element for last opened <text:list-item>, if requested
1038 if ( GetExport().exportTextNumberElement() &&
1039 eLName == XML_LIST_ITEM && nListLevelsToBeOpened == 1 && // last iteration --> last opened <text:list-item>
1040 !rNextInfo.ListLabelString().isEmpty() )
1042 const OUString aTextNumberElem =
1043 OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1044 XML_NAMESPACE_TEXT,
1045 GetXMLToken(XML_NUMBER) ) );
1046 GetExport().IgnorableWhitespace();
1047 GetExport().StartElement( aTextNumberElem, false );
1048 GetExport().Characters( rNextInfo.ListLabelString() );
1049 GetExport().EndElement( aTextNumberElem, true );
1051 --nListLevelsToBeOpened;
1052 } while ( nListLevelsToBeOpened > 0 );
1056 bool bEndElement = false;
1058 if ( rNextInfo.GetLevel() > 0 &&
1059 rNextInfo.IsNumbered() &&
1060 rPrevInfo.BelongsToSameList( rNextInfo ) &&
1061 rPrevInfo.GetLevel() >= rNextInfo.GetLevel() )
1063 assert(pListElements && pListElements->size() >= 2 && "list elements missing");
1064 bEndElement = pListElements && pListElements->size() >= 2;
1067 if (bEndElement)
1069 // close previous list-item
1070 GetExport().EndElement(pListElements->back(), true );
1071 pListElements->pop_back();
1073 // Only for sub lists (#i103745#)
1074 if ( rNextInfo.IsRestart() && !rNextInfo.HasStartValue() &&
1075 rNextInfo.GetLevel() != 1 )
1077 // start new sub list respectively list on same list level
1078 GetExport().EndElement(pListElements->back(), true );
1079 GetExport().IgnorableWhitespace();
1080 GetExport().StartElement(pListElements->back(), false);
1083 // open new list-item
1084 GetExport().CheckAttrList();
1085 if( rNextInfo.HasStartValue() )
1087 OUStringBuffer aBuffer;
1088 aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
1089 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
1090 aBuffer.makeStringAndClear() );
1092 // Handle restart without start value on list level 1 (#i103745#)
1093 else if ( rNextInfo.IsRestart() && /*!rNextInfo.HasStartValue() &&*/
1094 rNextInfo.GetLevel() == 1 )
1096 OUStringBuffer aBuffer;
1097 aBuffer.append( (sal_Int32)rNextInfo.GetListLevelStartValue() );
1098 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
1099 aBuffer.makeStringAndClear() );
1101 if ( ( GetExport().getExportFlags() & SvXMLExportFlags::OASIS ) &&
1102 GetExport().getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
1104 const OUString sListStyleName( rNextInfo.GetNumRulesName() );
1105 if ( !mpTextListsHelper->EqualsToTopListStyleOnStack( sListStyleName ) )
1107 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
1108 XML_STYLE_OVERRIDE,
1109 GetExport().EncodeStyleName( sListStyleName ) );
1112 OUString aElem( GetExport().GetNamespaceMap().GetQNameByKey(
1113 XML_NAMESPACE_TEXT,
1114 GetXMLToken(XML_LIST_ITEM) ) );
1115 GetExport().IgnorableWhitespace();
1116 GetExport().StartElement(aElem, false );
1117 pListElements->push_back(aElem);
1119 // export of <text:number> element for <text:list-item>, if requested
1120 if ( GetExport().exportTextNumberElement() &&
1121 !rNextInfo.ListLabelString().isEmpty() )
1123 const OUString aTextNumberElem =
1124 OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1125 XML_NAMESPACE_TEXT,
1126 GetXMLToken(XML_NUMBER) ) );
1127 GetExport().IgnorableWhitespace();
1128 GetExport().StartElement( aTextNumberElem, false );
1129 GetExport().Characters( rNextInfo.ListLabelString() );
1130 GetExport().EndElement( aTextNumberElem, true );
1135 struct XMLTextParagraphExport::Impl
1137 typedef ::std::map<Reference<XFormField>, sal_Int32> FieldMarkMap_t;
1138 FieldMarkMap_t m_FieldMarkMap;
1140 explicit Impl() {}
1141 sal_Int32 AddFieldMarkStart(Reference<XFormField> const& i_xFieldMark)
1143 assert(m_FieldMarkMap.find(i_xFieldMark) == m_FieldMarkMap.end());
1144 sal_Int32 const ret(m_FieldMarkMap.size());
1145 m_FieldMarkMap.insert(::std::make_pair(i_xFieldMark, ret));
1146 return ret;
1148 sal_Int32 GetFieldMarkIndex(Reference<XFormField> const& i_xFieldMark)
1150 FieldMarkMap_t::const_iterator const it(
1151 m_FieldMarkMap.find(i_xFieldMark));
1152 // rely on SwXFieldmark::CreateXFieldmark returning the same instance
1153 // because the Reference in m_FieldMarkMap will keep it alive
1154 assert(it != m_FieldMarkMap.end());
1155 return it->second;
1159 XMLTextParagraphExport::XMLTextParagraphExport(
1160 SvXMLExport& rExp,
1161 SvXMLAutoStylePoolP & rASP
1163 XMLStyleExport( rExp, OUString(), &rASP ),
1164 m_xImpl(new Impl),
1165 rAutoStylePool( rASP ),
1166 pBoundFrameSets(new BoundFrameSets(GetExport().GetModel())),
1167 pFieldExport( 0 ),
1168 pListElements( 0 ),
1169 pListAutoPool( new XMLTextListAutoStylePool( this->GetExport() ) ),
1170 pSectionExport( NULL ),
1171 pIndexMarkExport( NULL ),
1172 pRedlineExport( NULL ),
1173 pHeadingStyles( NULL ),
1174 bProgress( false ),
1175 bBlock( false ),
1176 bOpenRuby( false ),
1177 mpTextListsHelper( 0 ),
1178 maTextListsHelperStack(),
1179 sActualSize("ActualSize"),
1180 // Implement Title/Description Elements UI (#i73249#)
1181 sTitle("Title"),
1182 sDescription("Description"),
1183 sAnchorCharStyleName("AnchorCharStyleName"),
1184 sAnchorPageNo("AnchorPageNo"),
1185 sAnchorType("AnchorType"),
1186 sBeginNotice("BeginNotice"),
1187 sBookmark("Bookmark"),
1188 sCategory("Category"),
1189 sChainNextName("ChainNextName"),
1190 sCharStyleName("CharStyleName"),
1191 sCharStyleNames("CharStyleNames"),
1192 sContourPolyPolygon("ContourPolyPolygon"),
1193 sDocumentIndex("DocumentIndex"),
1194 sDocumentIndexMark("DocumentIndexMark"),
1195 sEndNotice("EndNotice"),
1196 sFootnote("Footnote"),
1197 sFootnoteCounting("FootnoteCounting"),
1198 sFrame("Frame"),
1199 sFrameHeightAbsolute("FrameHeightAbsolute"),
1200 sFrameHeightPercent("FrameHeightPercent"),
1201 sFrameStyleName("FrameStyleName"),
1202 sFrameWidthAbsolute("FrameWidthAbsolute"),
1203 sFrameWidthPercent("FrameWidthPercent"),
1204 sGraphicFilter("GraphicFilter"),
1205 sGraphicRotation("GraphicRotation"),
1206 sGraphicURL("GraphicURL"),
1207 sReplacementGraphicURL("ReplacementGraphicURL"),
1208 sHeight("Height"),
1209 sHoriOrient("HoriOrient"),
1210 sHoriOrientPosition("HoriOrientPosition"),
1211 sHyperLinkName("HyperLinkName"),
1212 sHyperLinkTarget("HyperLinkTarget"),
1213 sHyperLinkURL("HyperLinkURL"),
1214 sIsAutomaticContour("IsAutomaticContour"),
1215 sIsCollapsed("IsCollapsed"),
1216 sIsPixelContour("IsPixelContour"),
1217 sIsStart("IsStart"),
1218 sIsSyncHeightToWidth("IsSyncHeightToWidth"),
1219 sIsSyncWidthToHeight("IsSyncWidthToHeight"),
1220 sNumberingRules("NumberingRules"),
1221 sNumberingType("NumberingType"),
1222 sPageDescName("PageDescName"),
1223 sPageStyleName("PageStyleName"),
1224 sParaChapterNumberingLevel("ParaChapterNumberingLevel"),
1225 sParaConditionalStyleName("ParaConditionalStyleName"),
1226 sParagraphService("com.sun.star.text.Paragraph"),
1227 sParaStyleName("ParaStyleName"),
1228 sPositionEndOfDoc("PositionEndOfDoc"),
1229 sPrefix("Prefix"),
1230 sRedline("Redline"),
1231 sReferenceId("ReferenceId"),
1232 sReferenceMark("ReferenceMark"),
1233 sRelativeHeight("RelativeHeight"),
1234 sRelativeWidth("RelativeWidth"),
1235 sRuby("Ruby"),
1236 sRubyAdjust("RubyAdjust"),
1237 sRubyCharStyleName("RubyCharStyleName"),
1238 sRubyText("RubyText"),
1239 sServerMap("ServerMap"),
1240 sShapeService("com.sun.star.drawing.Shape"),
1241 sSizeType("SizeType"),
1242 sSoftPageBreak( "SoftPageBreak" ),
1243 sStartAt("StartAt"),
1244 sSuffix("Suffix"),
1245 sTableService("com.sun.star.text.TextTable"),
1246 sText("Text"),
1247 sTextContentService("com.sun.star.text.TextContent"),
1248 sTextEmbeddedService("com.sun.star.text.TextEmbeddedObject"),
1249 sTextEndnoteService("com.sun.star.text.Endnote"),
1250 sTextField("TextField"),
1251 sTextFieldService("com.sun.star.text.TextField"),
1252 sTextFrameService("com.sun.star.text.TextFrame"),
1253 sTextGraphicService("com.sun.star.text.TextGraphicObject"),
1254 sTextPortionType("TextPortionType"),
1255 sTextSection("TextSection"),
1256 sUnvisitedCharStyleName("UnvisitedCharStyleName"),
1257 sVertOrient("VertOrient"),
1258 sVertOrientPosition("VertOrientPosition"),
1259 sVisitedCharStyleName("VisitedCharStyleName"),
1260 sWidth("Width"),
1261 sWidthType( "WidthType" ),
1262 sTextFieldStart( "TextFieldStart" ),
1263 sTextFieldEnd( "TextFieldEnd" ),
1264 sTextFieldStartEnd( "TextFieldStartEnd" ),
1265 aCharStyleNamesPropInfoCache( sCharStyleNames )
1267 rtl::Reference < XMLPropertySetMapper > xPropMapper(new XMLTextPropertySetMapper( TextPropMap::PARA, true ));
1268 xParaPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1269 GetExport() );
1271 OUString sFamily( GetXMLToken(XML_PARAGRAPH) );
1272 OUString aPrefix(static_cast<sal_Unicode>('P'));
1273 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH, sFamily,
1274 xParaPropMapper, aPrefix );
1276 xPropMapper = new XMLTextPropertySetMapper( TextPropMap::TEXT, true );
1277 xTextPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1278 GetExport() );
1279 sFamily = GetXMLToken(XML_TEXT);
1280 aPrefix = "T";
1281 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_TEXT, sFamily,
1282 xTextPropMapper, aPrefix );
1284 xPropMapper = new XMLTextPropertySetMapper( TextPropMap::AUTO_FRAME, true );
1285 xAutoFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1286 GetExport() );
1287 sFamily = XML_STYLE_FAMILY_SD_GRAPHICS_NAME;
1288 aPrefix = "fr";
1289 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_FRAME, sFamily,
1290 xAutoFramePropMapper, aPrefix );
1292 xPropMapper = new XMLTextPropertySetMapper( TextPropMap::SECTION, true );
1293 xSectionPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1294 GetExport() );
1295 sFamily = GetXMLToken( XML_SECTION );
1296 aPrefix = "Sect" ;
1297 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_SECTION, sFamily,
1298 xSectionPropMapper, aPrefix );
1300 xPropMapper = new XMLTextPropertySetMapper( TextPropMap::RUBY, true );
1301 xRubyPropMapper = new SvXMLExportPropertyMapper( xPropMapper );
1302 sFamily = GetXMLToken( XML_RUBY );
1303 aPrefix = "Ru";
1304 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_RUBY, sFamily,
1305 xRubyPropMapper, aPrefix );
1307 xPropMapper = new XMLTextPropertySetMapper( TextPropMap::FRAME, true );
1308 xFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
1309 GetExport() );
1311 pSectionExport = new XMLSectionExport( rExp, *this );
1312 pIndexMarkExport = new XMLIndexMarkExport( rExp );
1314 if( ! IsBlockMode() &&
1315 Reference<XRedlinesSupplier>( GetExport().GetModel(), UNO_QUERY ).is())
1316 pRedlineExport = new XMLRedlineExport( rExp );
1318 // The text field helper needs a pre-constructed XMLPropertyState
1319 // to export the combined characters field. We construct that
1320 // here, because we need the text property mapper to do it.
1322 // construct Any value, then find index
1323 sal_Int32 nIndex = xTextPropMapper->getPropertySetMapper()->FindEntryIndex(
1324 "", XML_NAMESPACE_STYLE,
1325 GetXMLToken(XML_TEXT_COMBINE));
1326 pFieldExport = new XMLTextFieldExport( rExp, new XMLPropertyState( nIndex, uno::makeAny(sal_True) ) );
1327 PushNewTextListsHelper();
1330 XMLTextParagraphExport::~XMLTextParagraphExport()
1332 delete pHeadingStyles;
1333 delete pRedlineExport;
1334 delete pIndexMarkExport;
1335 delete pSectionExport;
1336 delete pFieldExport;
1337 delete pListElements;
1338 delete pListAutoPool;
1339 #ifdef DBG_UTIL
1340 txtparae_bContainsIllegalCharacters = false;
1341 #endif
1342 PopTextListsHelper();
1343 DBG_ASSERT( maTextListsHelperStack.empty(),
1344 "misusage of text lists helper stack - it is not empty. Serious defect - please inform OD" );
1347 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateShapeExtPropMapper(
1348 SvXMLExport& rExport )
1350 rtl::Reference < XMLPropertySetMapper > xPropMapper =
1351 new XMLTextPropertySetMapper( TextPropMap::SHAPE, true );
1352 return new XMLTextExportPropertySetMapper( xPropMapper, rExport );
1355 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateCharExtPropMapper(
1356 SvXMLExport& rExport)
1358 XMLPropertySetMapper *pPropMapper =
1359 new XMLTextPropertySetMapper( TextPropMap::TEXT, true );
1360 return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
1363 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaExtPropMapper(
1364 SvXMLExport& rExport)
1366 XMLPropertySetMapper *pPropMapper =
1367 new XMLTextPropertySetMapper( TextPropMap::SHAPE_PARA, true );
1368 return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
1371 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaDefaultExtPropMapper(
1372 SvXMLExport& rExport)
1374 XMLPropertySetMapper *pPropMapper =
1375 new XMLTextPropertySetMapper( TextPropMap::TEXT_ADDITIONAL_DEFAULTS, true );
1376 return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
1379 void XMLTextParagraphExport::exportPageFrames( bool bAutoStyles,
1380 bool bIsProgress )
1382 const TextContentSet& rTexts = pBoundFrameSets->GetTexts()->GetPageBoundContents();
1383 const TextContentSet& rGraphics = pBoundFrameSets->GetGraphics()->GetPageBoundContents();
1384 const TextContentSet& rEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetPageBoundContents();
1385 const TextContentSet& rShapes = pBoundFrameSets->GetShapes()->GetPageBoundContents();
1386 for(TextContentSet::const_iterator_t it = rTexts.getBegin();
1387 it != rTexts.getEnd();
1388 ++it)
1389 exportTextFrame(*it, bAutoStyles, bIsProgress, true);
1390 for(TextContentSet::const_iterator_t it = rGraphics.getBegin();
1391 it != rGraphics.getEnd();
1392 ++it)
1393 exportTextGraphic(*it, bAutoStyles);
1394 for(TextContentSet::const_iterator_t it = rEmbeddeds.getBegin();
1395 it != rEmbeddeds.getEnd();
1396 ++it)
1397 exportTextEmbedded(*it, bAutoStyles);
1398 for(TextContentSet::const_iterator_t it = rShapes.getBegin();
1399 it != rShapes.getEnd();
1400 ++it)
1401 exportShape(*it, bAutoStyles);
1404 void XMLTextParagraphExport::exportFrameFrames(
1405 bool bAutoStyles,
1406 bool bIsProgress,
1407 const Reference < XTextFrame > *pParentTxtFrame )
1409 const TextContentSet* const pTexts = pBoundFrameSets->GetTexts()->GetFrameBoundContents(*pParentTxtFrame);
1410 if(pTexts)
1411 for(TextContentSet::const_iterator_t it = pTexts->getBegin();
1412 it != pTexts->getEnd();
1413 ++it)
1414 exportTextFrame(*it, bAutoStyles, bIsProgress, true);
1415 const TextContentSet* const pGraphics = pBoundFrameSets->GetGraphics()->GetFrameBoundContents(*pParentTxtFrame);
1416 if(pGraphics)
1417 for(TextContentSet::const_iterator_t it = pGraphics->getBegin();
1418 it != pGraphics->getEnd();
1419 ++it)
1420 exportTextGraphic(*it, bAutoStyles);
1421 const TextContentSet* const pEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetFrameBoundContents(*pParentTxtFrame);
1422 if(pEmbeddeds)
1423 for(TextContentSet::const_iterator_t it = pEmbeddeds->getBegin();
1424 it != pEmbeddeds->getEnd();
1425 ++it)
1426 exportTextEmbedded(*it, bAutoStyles);
1427 const TextContentSet* const pShapes = pBoundFrameSets->GetShapes()->GetFrameBoundContents(*pParentTxtFrame);
1428 if(pShapes)
1429 for(TextContentSet::const_iterator_t it = pShapes->getBegin();
1430 it != pShapes->getEnd();
1431 ++it)
1432 exportShape(*it, bAutoStyles);
1435 // bookmarks, reference marks (and TOC marks) are the same except for the
1436 // element names. We use the same method for export and it an array with
1437 // the proper element names
1438 static const enum XMLTokenEnum lcl_XmlReferenceElements[] = {
1439 XML_REFERENCE_MARK, XML_REFERENCE_MARK_START, XML_REFERENCE_MARK_END };
1440 static const enum XMLTokenEnum lcl_XmlBookmarkElements[] = {
1441 XML_BOOKMARK, XML_BOOKMARK_START, XML_BOOKMARK_END };
1443 // This function replaces the text portion iteration during auto style
1444 // collection.
1445 bool XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress )
1447 GetExport().GetShapeExport(); // make sure the graphics styles family is added
1449 const bool bAutoStyles = true;
1450 const bool bExportContent = false;
1452 // Export AutoStyles:
1453 Reference< XAutoStylesSupplier > xAutoStylesSupp( GetExport().GetModel(), UNO_QUERY );
1454 if ( xAutoStylesSupp.is() )
1456 Reference< XAutoStyles > xAutoStyleFamilies = xAutoStylesSupp->getAutoStyles();
1457 OUString sName;
1458 sal_uInt16 nFamily;
1460 for ( int i = 0; i < 3; ++i )
1462 if ( 0 == i )
1464 sName = "CharacterStyles" ;
1465 nFamily = XML_STYLE_FAMILY_TEXT_TEXT;
1467 else if ( 1 == i )
1469 sName = "RubyStyles" ;
1470 nFamily = XML_STYLE_FAMILY_TEXT_RUBY;
1472 else
1474 sName = "ParagraphStyles" ;
1475 nFamily = XML_STYLE_FAMILY_TEXT_PARAGRAPH;
1478 Any aAny = xAutoStyleFamilies->getByName( sName );
1479 Reference< XAutoStyleFamily > xAutoStyles = *static_cast<Reference<XAutoStyleFamily> const *>(aAny.getValue());
1480 Reference < XEnumeration > xAutoStylesEnum( xAutoStyles->createEnumeration() );
1482 while ( xAutoStylesEnum->hasMoreElements() )
1484 aAny = xAutoStylesEnum->nextElement();
1485 Reference< XAutoStyle > xAutoStyle = *static_cast<Reference<XAutoStyle> const *>(aAny.getValue());
1486 Reference < XPropertySet > xPSet( xAutoStyle, uno::UNO_QUERY );
1487 Add( nFamily, xPSet, 0, true );
1492 // Export Field AutoStyles:
1493 Reference< XTextFieldsSupplier > xTextFieldsSupp( GetExport().GetModel(), UNO_QUERY );
1494 if ( xTextFieldsSupp.is() )
1496 Reference< XEnumerationAccess > xTextFields = xTextFieldsSupp->getTextFields();
1497 Reference < XEnumeration > xTextFieldsEnum( xTextFields->createEnumeration() );
1499 while ( xTextFieldsEnum->hasMoreElements() )
1501 Any aAny = xTextFieldsEnum->nextElement();
1502 Reference< XTextField > xTextField = *static_cast<Reference<XTextField> const *>(aAny.getValue());
1503 exportTextField( xTextField, bAutoStyles, bIsProgress,
1504 !xAutoStylesSupp.is() );
1507 Reference < XPropertySet > xSet( xTextField, UNO_QUERY );
1508 Reference < XText > xText;
1509 Any a = xSet->getPropertyValue("TextRange");
1510 a >>= xText;
1511 if ( xText.is() )
1513 exportText( xText, true, bIsProgress, bExportContent );
1514 GetExport().GetTextParagraphExport()
1515 ->collectTextAutoStyles( xText );
1518 catch (Exception&)
1524 // Export text frames:
1525 Reference<XEnumeration> xTextFramesEnum = pBoundFrameSets->GetTexts()->createEnumeration();
1526 if(xTextFramesEnum.is())
1527 while(xTextFramesEnum->hasMoreElements())
1529 Reference<XTextContent> xTxtCntnt(xTextFramesEnum->nextElement(), UNO_QUERY);
1530 if(xTxtCntnt.is())
1531 exportTextFrame(xTxtCntnt, bAutoStyles, bIsProgress, bExportContent, 0);
1534 // Export graphic objects:
1535 Reference<XEnumeration> xGraphicsEnum = pBoundFrameSets->GetGraphics()->createEnumeration();
1536 if(xGraphicsEnum.is())
1537 while(xGraphicsEnum->hasMoreElements())
1539 Reference<XTextContent> xTxtCntnt(xGraphicsEnum->nextElement(), UNO_QUERY);
1540 if(xTxtCntnt.is())
1541 exportTextGraphic(xTxtCntnt, true, 0);
1544 // Export embedded objects:
1545 Reference<XEnumeration> xEmbeddedsEnum = pBoundFrameSets->GetEmbeddeds()->createEnumeration();
1546 if(xEmbeddedsEnum.is())
1547 while(xEmbeddedsEnum->hasMoreElements())
1549 Reference<XTextContent> xTxtCntnt(xEmbeddedsEnum->nextElement(), UNO_QUERY);
1550 if(xTxtCntnt.is())
1551 exportTextEmbedded(xTxtCntnt, true, 0);
1554 // Export shapes:
1555 Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration();
1556 if(xShapesEnum.is())
1557 while(xShapesEnum->hasMoreElements())
1559 Reference<XTextContent> xTxtCntnt(xShapesEnum->nextElement(), UNO_QUERY);
1560 if(xTxtCntnt.is())
1562 Reference<XServiceInfo> xServiceInfo(xTxtCntnt, UNO_QUERY);
1563 if( xServiceInfo->supportsService(sShapeService))
1564 exportShape(xTxtCntnt, true, 0);
1568 sal_Int32 nCount;
1569 // AutoStyles for sections
1570 Reference< XTextSectionsSupplier > xSectionsSupp( GetExport().GetModel(), UNO_QUERY );
1571 if ( xSectionsSupp.is() )
1573 Reference< XIndexAccess > xSections( xSectionsSupp->getTextSections(), UNO_QUERY );
1574 if ( xSections.is() )
1576 nCount = xSections->getCount();
1577 for( sal_Int32 i = 0; i < nCount; ++i )
1579 Any aAny = xSections->getByIndex( i );
1580 Reference< XTextSection > xSection = *static_cast<Reference<XTextSection> const *>(aAny.getValue());
1581 Reference < XPropertySet > xPSet( xSection, uno::UNO_QUERY );
1582 Add( XML_STYLE_FAMILY_TEXT_SECTION, xPSet );
1587 // AutoStyles for tables (Note: suppress autostyle collection for paragraphs in exportTable)
1588 Reference< XTextTablesSupplier > xTablesSupp( GetExport().GetModel(), UNO_QUERY );
1589 if ( xTablesSupp.is() )
1591 Reference< XIndexAccess > xTables( xTablesSupp->getTextTables(), UNO_QUERY );
1592 if ( xTables.is() )
1594 nCount = xTables->getCount();
1595 for( sal_Int32 i = 0; i < nCount; ++i )
1597 Any aAny = xTables->getByIndex( i );
1598 Reference< XTextTable > xTable = *static_cast<Reference<XTextTable> const *>(aAny.getValue());
1599 exportTable( xTable, true, true );
1604 Reference< XNumberingRulesSupplier > xNumberingRulesSupp( GetExport().GetModel(), UNO_QUERY );
1605 if ( xNumberingRulesSupp.is() )
1607 Reference< XIndexAccess > xNumberingRules = xNumberingRulesSupp->getNumberingRules();
1608 nCount = xNumberingRules->getCount();
1609 // Custom outline assignment lost after re-importing sxw (#i73361#)
1610 for( sal_Int32 i = 0; i < nCount; ++i )
1612 Reference< XIndexReplace > xNumRule( xNumberingRules->getByIndex( i ), UNO_QUERY );
1613 if( xNumRule.is() && xNumRule->getCount() )
1615 Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
1616 OUString sName;
1617 if( xNamed.is() )
1618 sName = xNamed->getName();
1619 bool bAdd = sName.isEmpty();
1620 if( !bAdd )
1622 Reference < XPropertySet > xNumPropSet( xNumRule,
1623 UNO_QUERY );
1624 if( xNumPropSet.is() &&
1625 xNumPropSet->getPropertySetInfo()
1626 ->hasPropertyByName( "IsAutomatic" ) )
1628 bAdd = *static_cast<sal_Bool const *>(xNumPropSet->getPropertyValue( "IsAutomatic" ).getValue());
1629 // Check on outline style (#i73361#)
1630 if ( bAdd &&
1631 xNumPropSet->getPropertySetInfo()
1632 ->hasPropertyByName( "NumberingIsOutline" ) )
1634 bAdd = !(*static_cast<sal_Bool const *>(xNumPropSet->getPropertyValue( "NumberingIsOutline" ).getValue()));
1637 else
1639 bAdd = true;
1642 if( bAdd )
1643 pListAutoPool->Add( xNumRule );
1648 return true;
1651 void XMLTextParagraphExport::exportText(
1652 const Reference < XText > & rText,
1653 bool bAutoStyles,
1654 bool bIsProgress,
1655 bool bExportParagraph,
1656 TextPNS eExtensionNS)
1658 if( bAutoStyles )
1659 GetExport().GetShapeExport(); // make sure the graphics styles family
1660 // is added
1661 Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
1662 Reference < XEnumeration > xParaEnum(xEA->createEnumeration());
1663 Reference < XPropertySet > xPropertySet( rText, UNO_QUERY );
1664 Reference < XTextSection > xBaseSection;
1666 // #97718# footnotes don't supply paragraph enumerations in some cases
1667 // This is always a bug, but at least we don't want to crash.
1668 DBG_ASSERT( xParaEnum.is(), "We need a paragraph enumeration" );
1669 if( ! xParaEnum.is() )
1670 return;
1672 bool bExportLevels = true;
1674 if (xPropertySet.is())
1676 Reference < XPropertySetInfo > xInfo ( xPropertySet->getPropertySetInfo() );
1678 if( xInfo.is() )
1680 if (xInfo->hasPropertyByName( sTextSection ))
1682 xPropertySet->getPropertyValue(sTextSection) >>= xBaseSection ;
1685 /* #i35937#
1686 // for applications that use the outliner we need to check if
1687 // the current text object needs the level information exported
1688 if( !bAutoStyles )
1690 // fixme: move string to class member, couldn't do now because
1691 // of no incompatible build
1692 OUString sHasLevels( "HasLevels" );
1693 if (xInfo->hasPropertyByName( sHasLevels ) )
1695 xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels;
1702 // #96530# Export redlines at start & end of XText before & after
1703 // exporting the text content enumeration
1704 if( !bAutoStyles && (pRedlineExport != NULL) )
1705 pRedlineExport->ExportStartOrEndRedline( xPropertySet, true );
1706 exportTextContentEnumeration( xParaEnum, bAutoStyles, xBaseSection,
1707 bIsProgress, bExportParagraph, 0, bExportLevels, eExtensionNS );
1708 if( !bAutoStyles && (pRedlineExport != NULL) )
1709 pRedlineExport->ExportStartOrEndRedline( xPropertySet, false );
1712 void XMLTextParagraphExport::exportText(
1713 const Reference < XText > & rText,
1714 const Reference < XTextSection > & rBaseSection,
1715 bool bAutoStyles,
1716 bool bIsProgress,
1717 bool bExportParagraph,
1718 TextPNS /*eExtensionNS*/)
1720 if( bAutoStyles )
1721 GetExport().GetShapeExport(); // make sure the graphics styles family
1722 // is added
1723 Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
1724 Reference < XEnumeration > xParaEnum(xEA->createEnumeration());
1726 // #98165# don't continue without a paragraph enumeration
1727 if( ! xParaEnum.is() )
1728 return;
1730 // #96530# Export redlines at start & end of XText before & after
1731 // exporting the text content enumeration
1732 Reference<XPropertySet> xPropertySet;
1733 if( !bAutoStyles && (pRedlineExport != NULL) )
1735 xPropertySet.set(rText, uno::UNO_QUERY );
1736 pRedlineExport->ExportStartOrEndRedline( xPropertySet, true );
1738 exportTextContentEnumeration( xParaEnum, bAutoStyles, rBaseSection,
1739 bIsProgress, bExportParagraph );
1740 if( !bAutoStyles && (pRedlineExport != NULL) )
1741 pRedlineExport->ExportStartOrEndRedline( xPropertySet, false );
1744 bool XMLTextParagraphExport::exportTextContentEnumeration(
1745 const Reference < XEnumeration > & rContEnum,
1746 bool bAutoStyles,
1747 const Reference < XTextSection > & rBaseSection,
1748 bool bIsProgress,
1749 bool bExportParagraph,
1750 const Reference < XPropertySet > *pRangePropSet,
1751 bool bExportLevels, TextPNS eExtensionNS )
1753 DBG_ASSERT( rContEnum.is(), "No enumeration to export!" );
1754 bool bHasMoreElements = rContEnum->hasMoreElements();
1755 if( !bHasMoreElements )
1756 return false;
1758 XMLTextNumRuleInfo aPrevNumInfo;
1759 XMLTextNumRuleInfo aNextNumInfo;
1761 bool bHasContent = false;
1762 Reference<XTextSection> xCurrentTextSection(rBaseSection);
1764 MultiPropertySetHelper aPropSetHelper(
1765 bAutoStyles ? aParagraphPropertyNamesAuto :
1766 aParagraphPropertyNames );
1768 bool bHoldElement = false;
1769 Reference < XTextContent > xTxtCntnt;
1770 while( bHoldElement || bHasMoreElements )
1772 if (bHoldElement)
1774 bHoldElement = false;
1776 else
1778 xTxtCntnt.set(rContEnum->nextElement(), uno::UNO_QUERY);
1780 aPropSetHelper.resetValues();
1784 Reference<XServiceInfo> xServiceInfo( xTxtCntnt, UNO_QUERY );
1785 if( xServiceInfo->supportsService( sParagraphService ) )
1787 if( bExportLevels )
1789 if( bAutoStyles )
1791 exportListAndSectionChange( xCurrentTextSection, xTxtCntnt,
1792 aPrevNumInfo, aNextNumInfo,
1793 bAutoStyles );
1795 else
1797 /* Pass list auto style pool to <XMLTextNumRuleInfo> instance
1798 Pass info about request to export <text:number> element
1799 to <XMLTextNumRuleInfo> instance (#i69627#)
1801 aNextNumInfo.Set( xTxtCntnt,
1802 GetExport().writeOutlineStyleAsNormalListStyle(),
1803 GetListAutoStylePool(),
1804 GetExport().exportTextNumberElement() );
1806 exportListAndSectionChange( xCurrentTextSection, aPropSetHelper,
1807 TEXT_SECTION, xTxtCntnt,
1808 aPrevNumInfo, aNextNumInfo,
1809 bAutoStyles );
1813 // if we found a mute section: skip all section content
1814 if (pSectionExport->IsMuteSection(xCurrentTextSection))
1816 // Make sure headings are exported anyway.
1817 if( !bAutoStyles )
1818 pSectionExport->ExportMasterDocHeadingDummies();
1820 while (rContEnum->hasMoreElements() &&
1821 pSectionExport->IsInSection( xCurrentTextSection,
1822 xTxtCntnt, true ))
1824 xTxtCntnt.set(rContEnum->nextElement(), uno::UNO_QUERY);
1825 aPropSetHelper.resetValues();
1826 aNextNumInfo.Reset();
1828 // the first non-mute element still needs to be processed
1829 bHoldElement =
1830 ! pSectionExport->IsInSection( xCurrentTextSection,
1831 xTxtCntnt, false );
1833 else
1834 exportParagraph( xTxtCntnt, bAutoStyles, bIsProgress,
1835 bExportParagraph, aPropSetHelper, eExtensionNS );
1836 bHasContent = true;
1838 else if( xServiceInfo->supportsService( sTableService ) )
1840 if( !bAutoStyles )
1842 aNextNumInfo.Reset();
1845 exportListAndSectionChange( xCurrentTextSection, xTxtCntnt,
1846 aPrevNumInfo, aNextNumInfo,
1847 bAutoStyles );
1849 if (! pSectionExport->IsMuteSection(xCurrentTextSection))
1851 // export start + end redlines (for wholly redlined tables)
1852 if ((! bAutoStyles) && (NULL != pRedlineExport))
1853 pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, true);
1855 exportTable( xTxtCntnt, bAutoStyles, bIsProgress );
1857 if ((! bAutoStyles) && (NULL != pRedlineExport))
1858 pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, false);
1860 else if( !bAutoStyles )
1862 // Make sure headings are exported anyway.
1863 pSectionExport->ExportMasterDocHeadingDummies();
1866 bHasContent = true;
1868 else if( xServiceInfo->supportsService( sTextFrameService ) )
1870 exportTextFrame( xTxtCntnt, bAutoStyles, bIsProgress, true, pRangePropSet );
1872 else if( xServiceInfo->supportsService( sTextGraphicService ) )
1874 exportTextGraphic( xTxtCntnt, bAutoStyles, pRangePropSet );
1876 else if( xServiceInfo->supportsService( sTextEmbeddedService ) )
1878 exportTextEmbedded( xTxtCntnt, bAutoStyles, pRangePropSet );
1880 else if( xServiceInfo->supportsService( sShapeService ) )
1882 exportShape( xTxtCntnt, bAutoStyles, pRangePropSet );
1884 else
1886 DBG_ASSERT( !xTxtCntnt.is(), "unknown text content" );
1889 if( !bAutoStyles )
1891 aPrevNumInfo = aNextNumInfo;
1894 bHasMoreElements = rContEnum->hasMoreElements();
1897 if( bExportLevels && bHasContent && !bAutoStyles )
1899 aNextNumInfo.Reset();
1901 // close open lists and sections; no new styles
1902 exportListAndSectionChange( xCurrentTextSection, rBaseSection,
1903 aPrevNumInfo, aNextNumInfo,
1904 bAutoStyles );
1907 return true;
1910 void XMLTextParagraphExport::exportParagraph(
1911 const Reference < XTextContent > & rTextContent,
1912 bool bAutoStyles, bool bIsProgress, bool bExportParagraph,
1913 MultiPropertySetHelper& rPropSetHelper, TextPNS eExtensionNS)
1915 sal_Int16 nOutlineLevel = -1;
1917 if( bIsProgress )
1919 ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
1920 pProgress->SetValue( pProgress->GetValue()+1 );
1923 // get property set or multi property set and initialize helper
1924 Reference<XMultiPropertySet> xMultiPropSet( rTextContent, UNO_QUERY );
1925 Reference<XPropertySet> xPropSet( rTextContent, UNO_QUERY );
1927 // check for supported properties
1928 if( !rPropSetHelper.checkedProperties() )
1929 rPropSetHelper.hasProperties( xPropSet->getPropertySetInfo() );
1931 // if( xMultiPropSet.is() )
1932 // rPropSetHelper.getValues( xMultiPropSet );
1933 // else
1934 // rPropSetHelper.getValues( xPropSet );
1936 if( bExportParagraph )
1938 if( bAutoStyles )
1940 Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, rPropSetHelper, xPropSet );
1942 else
1944 // xml:id for RDF metadata
1945 GetExport().AddAttributeXmlId(rTextContent);
1946 GetExport().AddAttributesRDFa(rTextContent);
1948 OUString sStyle;
1949 if( rPropSetHelper.hasProperty( PARA_STYLE_NAME ) )
1951 if( xMultiPropSet.is() )
1952 rPropSetHelper.getValue( PARA_STYLE_NAME,
1953 xMultiPropSet ) >>= sStyle;
1954 else
1955 rPropSetHelper.getValue( PARA_STYLE_NAME,
1956 xPropSet ) >>= sStyle;
1959 if( rTextContent.is() )
1961 const OUString& rIdentifier = GetExport().getInterfaceToIdentifierMapper().getIdentifier( rTextContent );
1962 if( !rIdentifier.isEmpty() )
1964 // FIXME: this is just temporary until EditEngine
1965 // paragraphs implement XMetadatable.
1966 // then that must be used and not the mapper, because
1967 // when both can be used we get two xml:id!
1968 uno::Reference<rdf::XMetadatable> const xMeta(rTextContent,
1969 uno::UNO_QUERY);
1970 OSL_ENSURE(!xMeta.is(), "paragraph that implements "
1971 "XMetadatable used in interfaceToIdentifierMapper?");
1972 GetExport().AddAttributeIdLegacy(XML_NAMESPACE_TEXT,
1973 rIdentifier);
1977 OUString sAutoStyle( sStyle );
1978 sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle );
1979 if( !sAutoStyle.isEmpty() )
1980 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
1981 GetExport().EncodeStyleName( sAutoStyle ) );
1983 if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME ) )
1985 OUString sCondStyle;
1986 if( xMultiPropSet.is() )
1987 rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME,
1988 xMultiPropSet ) >>= sCondStyle;
1989 else
1990 rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME,
1991 xPropSet ) >>= sCondStyle;
1992 if( sCondStyle != sStyle )
1994 sCondStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet,
1995 sCondStyle );
1996 if( !sCondStyle.isEmpty() )
1997 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
1998 XML_COND_STYLE_NAME,
1999 GetExport().EncodeStyleName( sCondStyle ) );
2003 if( rPropSetHelper.hasProperty( PARA_OUTLINE_LEVEL ) )
2005 if( xMultiPropSet.is() )
2006 rPropSetHelper.getValue( PARA_OUTLINE_LEVEL,
2007 xMultiPropSet ) >>= nOutlineLevel;
2008 else
2009 rPropSetHelper.getValue( PARA_OUTLINE_LEVEL,
2010 xPropSet ) >>= nOutlineLevel;
2012 if( 0 < nOutlineLevel )
2014 OUStringBuffer sTmp;
2015 sTmp.append( sal_Int32( nOutlineLevel) );
2016 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
2017 XML_OUTLINE_LEVEL,
2018 sTmp.makeStringAndClear() );
2020 if( rPropSetHelper.hasProperty( NUMBERING_IS_NUMBER ) )
2022 bool bIsNumber = false;
2023 if( xMultiPropSet.is() )
2024 rPropSetHelper.getValue(
2025 NUMBERING_IS_NUMBER, xMultiPropSet ) >>= bIsNumber;
2026 else
2027 rPropSetHelper.getValue(
2028 NUMBERING_IS_NUMBER, xPropSet ) >>= bIsNumber;
2030 OUString sListStyleName;
2031 if( xMultiPropSet.is() )
2032 rPropSetHelper.getValue(
2033 PARA_NUMBERING_STYLENAME, xMultiPropSet ) >>= sListStyleName;
2034 else
2035 rPropSetHelper.getValue(
2036 PARA_NUMBERING_STYLENAME, xPropSet ) >>= sListStyleName;
2038 bool bAssignedtoOutlineStyle = false;
2040 Reference< XChapterNumberingSupplier > xCNSupplier( GetExport().GetModel(), UNO_QUERY );
2042 OUString sOutlineName;
2043 if (xCNSupplier.is())
2045 Reference< XIndexReplace > xNumRule ( xCNSupplier->getChapterNumberingRules() );
2046 DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" );
2048 if (xNumRule.is())
2050 Reference< XPropertySet > xNumRulePropSet( xNumRule, UNO_QUERY );
2051 xNumRulePropSet->getPropertyValue(
2052 "Name" ) >>= sOutlineName;
2053 bAssignedtoOutlineStyle = ( sListStyleName == sOutlineName );
2058 if( ! bIsNumber && bAssignedtoOutlineStyle )
2059 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
2060 XML_IS_LIST_HEADER,
2061 XML_TRUE );
2065 bool bIsRestartNumbering = false;
2067 Reference< XPropertySetInfo >
2068 xPropSetInfo(xMultiPropSet.is() ?
2069 xMultiPropSet->getPropertySetInfo():
2070 xPropSet->getPropertySetInfo());
2072 if (xPropSetInfo->
2073 hasPropertyByName("ParaIsNumberingRestart"))
2075 xPropSet->getPropertyValue("ParaIsNumberingRestart")
2076 >>= bIsRestartNumbering;
2079 if (bIsRestartNumbering)
2081 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
2082 XML_RESTART_NUMBERING,
2083 XML_TRUE);
2085 if (xPropSetInfo->
2086 hasPropertyByName("NumberingStartValue"))
2088 sal_Int32 nStartValue = 0;
2090 xPropSet->getPropertyValue("NumberingStartValue")
2091 >>= nStartValue;
2093 OUStringBuffer sTmpStartValue;
2095 sTmpStartValue.append(nStartValue);
2097 GetExport().
2098 AddAttribute(XML_NAMESPACE_TEXT,
2099 XML_START_VALUE,
2100 sTmpStartValue.
2101 makeStringAndClear());
2110 Reference < XEnumerationAccess > xEA( rTextContent, UNO_QUERY );
2111 Reference < XEnumeration > xTextEnum;
2112 xTextEnum = xEA->createEnumeration();
2113 const bool bHasPortions = xTextEnum.is();
2115 Reference < XEnumeration> xContentEnum;
2116 Reference < XContentEnumerationAccess > xCEA( rTextContent, UNO_QUERY );
2117 if( xCEA.is() )
2118 xContentEnum.set(xCEA->createContentEnumeration( sTextContentService ));
2119 const bool bHasContentEnum = xContentEnum.is() &&
2120 xContentEnum->hasMoreElements();
2122 Reference < XTextSection > xSection;
2123 if( bHasContentEnum )
2125 // For the auto styles, the multi property set helper is only used
2126 // if hard attributes are existing. Therefore, it seems to be a better
2127 // strategy to have the TextSection property separate, because otherwise
2128 // we always retrieve the style names even if they are not required.
2129 if( bAutoStyles )
2131 if( xPropSet->getPropertySetInfo()->hasPropertyByName( sTextSection ) )
2133 xSection.set(xPropSet->getPropertyValue( sTextSection ), uno::UNO_QUERY);
2136 else
2138 if( rPropSetHelper.hasProperty( TEXT_SECTION ) )
2140 xSection.set(rPropSetHelper.getValue( TEXT_SECTION ), uno::UNO_QUERY);
2145 if( bAutoStyles )
2147 if( bHasContentEnum )
2148 exportTextContentEnumeration(
2149 xContentEnum, bAutoStyles, xSection,
2150 bIsProgress, true, 0, true );
2151 if ( bHasPortions )
2152 exportTextRangeEnumeration( xTextEnum, bAutoStyles, bIsProgress );
2154 else
2156 bool bPrevCharIsSpace = true;
2157 enum XMLTokenEnum eElem =
2158 0 < nOutlineLevel ? XML_H : XML_P;
2159 SvXMLElementExport aElem( GetExport(), eExtensionNS == TextPNS::EXTENSION ? XML_NAMESPACE_LO_EXT : XML_NAMESPACE_TEXT, eElem,
2160 true, false );
2161 if( bHasContentEnum )
2162 bPrevCharIsSpace = !exportTextContentEnumeration(
2163 xContentEnum, bAutoStyles, xSection,
2164 bIsProgress );
2165 exportTextRangeEnumeration( xTextEnum, bAutoStyles, bIsProgress,
2166 bPrevCharIsSpace );
2170 void XMLTextParagraphExport::exportTextRangeEnumeration(
2171 const Reference < XEnumeration > & rTextEnum,
2172 bool bAutoStyles, bool bIsProgress,
2173 bool bPrvChrIsSpc )
2175 static const char sMeta[] = "InContentMetadata";
2176 static const char sFieldMarkName[] = "__FieldMark_";
2177 static const char sAnnotation[] = "Annotation";
2178 static const char sAnnotationEnd[] = "AnnotationEnd";
2180 bool bPrevCharIsSpace = bPrvChrIsSpc;
2182 /* This is used for exporting to strict OpenDocument 1.2, in which case traditional
2183 * bookmarks are used instead of fieldmarks. */
2184 FieldmarkType openFieldMark = NONE;
2186 while( rTextEnum->hasMoreElements() )
2188 Reference<XPropertySet> xPropSet(rTextEnum->nextElement(), UNO_QUERY);
2189 Reference < XTextRange > xTxtRange(xPropSet, uno::UNO_QUERY);
2190 Reference<XPropertySetInfo> xPropInfo(xPropSet->getPropertySetInfo());
2192 if (xPropInfo->hasPropertyByName(sTextPortionType))
2194 OUString sType;
2195 xPropSet->getPropertyValue(sTextPortionType) >>= sType;
2197 if( sType.equals(sText))
2199 exportTextRange( xTxtRange, bAutoStyles,
2200 bPrevCharIsSpace, openFieldMark);
2202 else if( sType.equals(sTextField))
2204 exportTextField( xTxtRange, bAutoStyles, bIsProgress );
2205 bPrevCharIsSpace = false;
2207 else if ( sType == sAnnotation )
2209 exportTextField( xTxtRange, bAutoStyles, bIsProgress );
2210 bPrevCharIsSpace = false;
2212 else if ( sType == sAnnotationEnd )
2214 if (!bAutoStyles)
2216 Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2217 const OUString& rName = xBookmark->getName();
2218 if (!rName.isEmpty())
2220 GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, rName);
2222 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_OFFICE, XML_ANNOTATION_END, false, false );
2225 else if( sType.equals( sFrame ) )
2227 Reference < XEnumeration> xContentEnum;
2228 Reference < XContentEnumerationAccess > xCEA( xTxtRange,
2229 UNO_QUERY );
2230 if( xCEA.is() )
2231 xContentEnum.set(xCEA->createContentEnumeration(
2232 sTextContentService ));
2233 // frames are never in sections
2234 Reference<XTextSection> xSection;
2235 if( xContentEnum.is() )
2236 exportTextContentEnumeration( xContentEnum,
2237 bAutoStyles,
2238 xSection, bIsProgress, true,
2239 &xPropSet );
2241 bPrevCharIsSpace = false;
2243 else if (sType.equals(sFootnote))
2245 exportTextFootnote(xPropSet,
2246 xTxtRange->getString(),
2247 bAutoStyles, bIsProgress );
2248 bPrevCharIsSpace = false;
2250 else if (sType.equals(sBookmark))
2252 exportTextMark(xPropSet,
2253 sBookmark,
2254 lcl_XmlBookmarkElements,
2255 bAutoStyles);
2257 else if (sType.equals(sReferenceMark))
2259 exportTextMark(xPropSet,
2260 sReferenceMark,
2261 lcl_XmlReferenceElements,
2262 bAutoStyles);
2264 else if (sType.equals(sDocumentIndexMark))
2266 pIndexMarkExport->ExportIndexMark(xPropSet, bAutoStyles);
2268 else if (sType.equals(sRedline))
2270 if (NULL != pRedlineExport)
2271 pRedlineExport->ExportChange(xPropSet, bAutoStyles);
2273 else if (sType.equals(sRuby))
2275 exportRuby(xPropSet, bAutoStyles);
2277 else if (sType == sMeta)
2279 exportMeta(xPropSet, bAutoStyles, bIsProgress);
2281 else if (sType.equals(sTextFieldStart))
2283 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2285 /* As of now, textmarks are a proposed extension to the OpenDocument standard. */
2286 if (!bAutoStyles)
2288 if (GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012)
2290 Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2291 if (xBookmark.is())
2293 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
2296 if (xFormField.is())
2298 GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
2301 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, false);
2302 if (xFormField.is())
2304 FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
2306 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, false);
2308 /* The OpenDocument standard does not include support for TextMarks for now, so use bookmarks instead. */
2309 else
2311 if (xFormField.is())
2313 OUString sName;
2314 Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
2315 if (xParameters.is() && xParameters->hasByName("Name"))
2317 const Any aValue = xParameters->getByName("Name");
2318 aValue >>= sName;
2320 if (sName.isEmpty())
2321 { // name attribute is mandatory, so have to pull a
2322 // rabbit out of the hat here
2323 sName = sFieldMarkName + OUString::number(
2324 m_xImpl->AddFieldMarkStart(xFormField));
2326 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
2327 sName);
2328 SvXMLElementExport aElem( GetExport(), !bAutoStyles,
2329 XML_NAMESPACE_TEXT, XML_BOOKMARK_START,
2330 false, false );
2331 const OUString sFieldType = xFormField->getFieldType();
2332 if (sFieldType == ODF_FORMTEXT)
2334 openFieldMark = TEXT;
2336 else if (sFieldType == ODF_FORMCHECKBOX)
2338 openFieldMark = CHECK;
2340 else
2342 openFieldMark = NONE;
2348 else if (sType.equals(sTextFieldEnd))
2350 if (!bAutoStyles)
2352 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2354 if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
2356 SvXMLElementExport aElem( GetExport(), !bAutoStyles,
2357 XML_NAMESPACE_FIELD, XML_FIELDMARK_END,
2358 false, false );
2360 else
2362 if (xFormField.is())
2364 OUString sName;
2365 Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
2366 if (xParameters.is() && xParameters->hasByName("Name"))
2368 const Any aValue = xParameters->getByName("Name");
2369 aValue >>= sName;
2371 if (sName.isEmpty())
2372 { // name attribute is mandatory, so have to pull a
2373 // rabbit out of the hat here
2374 sName = sFieldMarkName + OUString::number(
2375 m_xImpl->GetFieldMarkIndex(xFormField));
2377 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
2378 sName);
2379 SvXMLElementExport aElem( GetExport(), !bAutoStyles,
2380 XML_NAMESPACE_TEXT, XML_BOOKMARK_END,
2381 false, false );
2386 else if (sType.equals(sTextFieldStartEnd))
2388 if (!bAutoStyles)
2390 if (GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012)
2392 Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2393 if (xBookmark.is())
2395 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
2397 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2398 if (xFormField.is())
2400 GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
2402 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, false);
2403 if (xFormField.is())
2405 FieldParamExporter(&GetExport(), xFormField->getParameters()).Export();
2407 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, false);
2409 else
2411 Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2412 if (xBookmark.is())
2414 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
2415 SvXMLElementExport aElem( GetExport(), !bAutoStyles,
2416 XML_NAMESPACE_TEXT, XML_BOOKMARK,
2417 false, false );
2422 else if (sType.equals(sSoftPageBreak))
2424 exportSoftPageBreak(xPropSet, bAutoStyles);
2426 else {
2427 OSL_FAIL("unknown text portion type");
2430 else
2432 Reference<XServiceInfo> xServiceInfo( xTxtRange, UNO_QUERY );
2433 if( xServiceInfo->supportsService( sTextFieldService ) )
2435 exportTextField( xTxtRange, bAutoStyles, bIsProgress );
2436 bPrevCharIsSpace = false;
2438 else
2440 // no TextPortionType property -> non-Writer app -> text
2441 exportTextRange( xTxtRange, bAutoStyles, bPrevCharIsSpace, openFieldMark );
2446 // now that there are nested enumerations for meta(-field), this may be valid!
2447 // DBG_ASSERT( !bOpenRuby, "Red Alert: Ruby still open!" );
2450 void XMLTextParagraphExport::exportTable(
2451 const Reference < XTextContent > &,
2452 bool /*bAutoStyles*/, bool /*bIsProgress*/ )
2456 void XMLTextParagraphExport::exportTextField(
2457 const Reference < XTextRange > & rTextRange,
2458 bool bAutoStyles, bool bIsProgress )
2460 Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY );
2461 // non-Writer apps need not support Property TextField, so test first
2462 if (xPropSet->getPropertySetInfo()->hasPropertyByName( sTextField ))
2464 Reference < XTextField > xTxtFld(xPropSet->getPropertyValue( sTextField ), uno::UNO_QUERY);
2465 DBG_ASSERT( xTxtFld.is(), "text field missing" );
2466 if( xTxtFld.is() )
2468 exportTextField(xTxtFld, bAutoStyles, bIsProgress, true);
2470 else
2472 // write only characters
2473 GetExport().Characters(rTextRange->getString());
2478 void XMLTextParagraphExport::exportTextField(
2479 const Reference < XTextField > & xTextField,
2480 const bool bAutoStyles, const bool bIsProgress,
2481 const bool bRecursive )
2483 if ( bAutoStyles )
2485 pFieldExport->ExportFieldAutoStyle( xTextField, bIsProgress,
2486 bRecursive );
2488 else
2490 pFieldExport->ExportField( xTextField, bIsProgress );
2494 void XMLTextParagraphExport::exportSoftPageBreak(
2495 const Reference<XPropertySet> & ,
2496 bool )
2498 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2499 XML_SOFT_PAGE_BREAK, false,
2500 false );
2503 void XMLTextParagraphExport::exportTextMark(
2504 const Reference<XPropertySet> & rPropSet,
2505 const OUString& rProperty,
2506 const enum XMLTokenEnum pElements[],
2507 bool bAutoStyles)
2509 // mib said: "Hau wech!"
2511 // (Originally, I'd export a span element in case the (book|reference)mark
2512 // was formatted. This actually makes a difference in case some pervert
2513 // sets a point reference mark in the document and, say, formats it bold.
2514 // This basically meaningless formatting will now been thrown away
2515 // (aka cleaned up), since mib said: ... dvo
2517 if (!bAutoStyles)
2519 // name element
2520 Reference<XNamed> xName(rPropSet->getPropertyValue(rProperty), UNO_QUERY);
2521 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
2522 xName->getName());
2524 // start, end, or point-reference?
2525 sal_Int8 nElement;
2526 if( *static_cast<sal_Bool const *>(rPropSet->getPropertyValue(sIsCollapsed).getValue()) )
2528 nElement = 0;
2530 else
2532 nElement = *static_cast<sal_Bool const *>(rPropSet->getPropertyValue(sIsStart).getValue()) ? 1 : 2;
2535 // bookmark, bookmark-start: xml:id and RDFa for RDF metadata
2536 if( nElement < 2 ) {
2537 GetExport().AddAttributeXmlId(xName);
2538 const uno::Reference<text::XTextContent> xTextContent(
2539 xName, uno::UNO_QUERY_THROW);
2540 GetExport().AddAttributesRDFa(xTextContent);
2543 // export element
2544 DBG_ASSERT(pElements != NULL, "illegal element array");
2545 DBG_ASSERT(nElement >= 0, "illegal element number");
2546 DBG_ASSERT(nElement <= 2, "illegal element number");
2547 SvXMLElementExport aElem(GetExport(),
2548 XML_NAMESPACE_TEXT, pElements[nElement],
2549 false, false);
2551 // else: no styles. (see above)
2554 static bool lcl_txtpara_isBoundAsChar(
2555 const Reference < XPropertySet > & rPropSet,
2556 const Reference < XPropertySetInfo > & rPropSetInfo )
2558 bool bIsBoundAsChar = false;
2559 OUString sAnchorType( "AnchorType" );
2560 if( rPropSetInfo->hasPropertyByName( sAnchorType ) )
2562 TextContentAnchorType eAnchor;
2563 rPropSet->getPropertyValue( sAnchorType ) >>= eAnchor;
2564 bIsBoundAsChar = TextContentAnchorType_AS_CHARACTER == eAnchor;
2567 return bIsBoundAsChar;
2570 XMLShapeExportFlags XMLTextParagraphExport::addTextFrameAttributes(
2571 const Reference < XPropertySet >& rPropSet,
2572 bool bShape,
2573 OUString *pMinHeightValue,
2574 OUString *pMinWidthValue)
2576 XMLShapeExportFlags nShapeFeatures = SEF_DEFAULT;
2578 // draw:name (#97662#: not for shapes, since those names will be
2579 // treated in the shape export)
2580 if( !bShape )
2582 Reference < XNamed > xNamed( rPropSet, UNO_QUERY );
2583 if( xNamed.is() )
2585 OUString sName( xNamed->getName() );
2586 if( !sName.isEmpty() )
2587 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_NAME,
2588 xNamed->getName() );
2592 OUStringBuffer sValue;
2594 // text:anchor-type
2595 TextContentAnchorType eAnchor = TextContentAnchorType_AT_PARAGRAPH;
2596 rPropSet->getPropertyValue( sAnchorType ) >>= eAnchor;
2598 XMLAnchorTypePropHdl aAnchorTypeHdl;
2599 OUString sTmp;
2600 aAnchorTypeHdl.exportXML( sTmp, uno::makeAny(eAnchor),
2601 GetExport().GetMM100UnitConverter() );
2602 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, sTmp );
2605 // text:anchor-page-number
2606 if( TextContentAnchorType_AT_PAGE == eAnchor )
2608 sal_Int16 nPage = 0;
2609 rPropSet->getPropertyValue( sAnchorPageNo ) >>= nPage;
2610 SAL_WARN_IF(nPage <= 0, "xmloff",
2611 "ERROR: writing invalid anchor-page-number 0");
2612 ::sax::Converter::convertNumber( sValue, (sal_Int32)nPage );
2613 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_PAGE_NUMBER,
2614 sValue.makeStringAndClear() );
2616 else
2618 // #92210#
2619 nShapeFeatures |= XMLShapeExportFlags::NO_WS;
2622 // OD 2004-06-01 #i27691# - correction: no export of svg:x, if object
2623 // is anchored as-character.
2624 if ( !bShape &&
2625 eAnchor != TextContentAnchorType_AS_CHARACTER )
2627 // svg:x
2628 sal_Int16 nHoriOrient = HoriOrientation::NONE;
2629 rPropSet->getPropertyValue( sHoriOrient ) >>= nHoriOrient;
2630 if( HoriOrientation::NONE == nHoriOrient )
2632 sal_Int32 nPos = 0;
2633 rPropSet->getPropertyValue( sHoriOrientPosition ) >>= nPos;
2634 GetExport().GetMM100UnitConverter().convertMeasureToXML(
2635 sValue, nPos );
2636 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_X,
2637 sValue.makeStringAndClear() );
2640 else if( TextContentAnchorType_AS_CHARACTER == eAnchor )
2641 nShapeFeatures = (nShapeFeatures & ~XMLShapeExportFlags::X);
2643 if( !bShape || TextContentAnchorType_AS_CHARACTER == eAnchor )
2645 // svg:y
2646 sal_Int16 nVertOrient = VertOrientation::NONE;
2647 rPropSet->getPropertyValue( sVertOrient ) >>= nVertOrient;
2648 if( VertOrientation::NONE == nVertOrient )
2650 sal_Int32 nPos = 0;
2651 rPropSet->getPropertyValue( sVertOrientPosition ) >>= nPos;
2652 GetExport().GetMM100UnitConverter().convertMeasureToXML(
2653 sValue, nPos );
2654 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_Y,
2655 sValue.makeStringAndClear() );
2657 if( bShape )
2658 nShapeFeatures = (nShapeFeatures & ~XMLShapeExportFlags::Y);
2661 Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo());
2663 // svg:width
2664 sal_Int16 nWidthType = SizeType::FIX;
2665 if( xPropSetInfo->hasPropertyByName( sWidthType ) )
2667 rPropSet->getPropertyValue( sWidthType ) >>= nWidthType;
2669 if( xPropSetInfo->hasPropertyByName( sWidth ) )
2671 sal_Int32 nWidth = 0;
2672 // VAR size will be written as zero min-size
2673 if( SizeType::VARIABLE != nWidthType )
2675 rPropSet->getPropertyValue( sWidth ) >>= nWidth;
2677 GetExport().GetMM100UnitConverter().convertMeasureToXML(sValue, nWidth);
2678 if( SizeType::FIX != nWidthType )
2680 assert(pMinWidthValue);
2681 if (pMinWidthValue)
2683 *pMinWidthValue = sValue.makeStringAndClear();
2686 else
2687 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH,
2688 sValue.makeStringAndClear() );
2690 bool bSyncWidth = false;
2691 if( xPropSetInfo->hasPropertyByName( sIsSyncWidthToHeight ) )
2693 bSyncWidth = *static_cast<sal_Bool const *>(rPropSet->getPropertyValue( sIsSyncWidthToHeight ).getValue());
2694 if( bSyncWidth )
2695 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH,
2696 XML_SCALE );
2698 if( !bSyncWidth && xPropSetInfo->hasPropertyByName( sRelativeWidth ) )
2700 sal_Int16 nRelWidth = 0;
2701 rPropSet->getPropertyValue( sRelativeWidth ) >>= nRelWidth;
2702 DBG_ASSERT( nRelWidth >= 0 && nRelWidth <= 254,
2703 "Got illegal relative width from API" );
2704 if( nRelWidth > 0 )
2706 ::sax::Converter::convertPercent( sValue, nRelWidth );
2707 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH,
2708 sValue.makeStringAndClear() );
2712 // svg:height, fo:min-height or style:rel-height
2713 sal_Int16 nSizeType = SizeType::FIX;
2714 if( xPropSetInfo->hasPropertyByName( sSizeType ) )
2716 rPropSet->getPropertyValue( sSizeType ) >>= nSizeType;
2718 bool bSyncHeight = false;
2719 if( xPropSetInfo->hasPropertyByName( sIsSyncHeightToWidth ) )
2721 bSyncHeight = *static_cast<sal_Bool const *>(rPropSet->getPropertyValue( sIsSyncHeightToWidth ).getValue());
2723 sal_Int16 nRelHeight = 0;
2724 if( !bSyncHeight && xPropSetInfo->hasPropertyByName( sRelativeHeight ) )
2726 rPropSet->getPropertyValue( sRelativeHeight ) >>= nRelHeight;
2728 if( xPropSetInfo->hasPropertyByName( sHeight ) )
2730 sal_Int32 nHeight = 0;
2731 if( SizeType::VARIABLE != nSizeType )
2733 rPropSet->getPropertyValue( sHeight ) >>= nHeight;
2735 GetExport().GetMM100UnitConverter().convertMeasureToXML( sValue,
2736 nHeight );
2737 if( SizeType::FIX != nSizeType && 0==nRelHeight && !bSyncHeight &&
2738 pMinHeightValue )
2739 *pMinHeightValue = sValue.makeStringAndClear();
2740 else
2741 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT,
2742 sValue.makeStringAndClear() );
2744 if( bSyncHeight )
2746 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_HEIGHT,
2747 SizeType::MIN == nSizeType ? XML_SCALE_MIN : XML_SCALE );
2750 else if( nRelHeight > 0 )
2752 ::sax::Converter::convertPercent( sValue, nRelHeight );
2753 if( SizeType::MIN == nSizeType )
2755 assert(pMinHeightValue);
2756 if (pMinHeightValue)
2758 *pMinHeightValue = sValue.makeStringAndClear();
2761 else
2762 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_HEIGHT,
2763 sValue.makeStringAndClear() );
2766 OUString sZOrder( "ZOrder" );
2767 if( xPropSetInfo->hasPropertyByName( sZOrder ) )
2769 sal_Int32 nZIndex = 0;
2770 rPropSet->getPropertyValue( sZOrder ) >>= nZIndex;
2771 if( -1 != nZIndex )
2773 ::sax::Converter::convertNumber( sValue, nZIndex );
2774 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_ZINDEX,
2775 sValue.makeStringAndClear() );
2779 return nShapeFeatures;
2782 void XMLTextParagraphExport::exportAnyTextFrame(
2783 const Reference < XTextContent > & rTxtCntnt,
2784 FrameType eType,
2785 bool bAutoStyles,
2786 bool bIsProgress,
2787 bool bExportContent,
2788 const Reference < XPropertySet > *pRangePropSet)
2790 Reference < XPropertySet > xPropSet( rTxtCntnt, UNO_QUERY );
2792 if( bAutoStyles )
2794 if( FT_EMBEDDED == eType )
2795 _collectTextEmbeddedAutoStyles( xPropSet );
2796 // No text frame style for shapes (#i28745#)
2797 else if ( FT_SHAPE != eType )
2798 Add( XML_STYLE_FAMILY_TEXT_FRAME, xPropSet );
2800 if( pRangePropSet && lcl_txtpara_isBoundAsChar( xPropSet,
2801 xPropSet->getPropertySetInfo() ) )
2802 Add( XML_STYLE_FAMILY_TEXT_TEXT, *pRangePropSet );
2804 switch( eType )
2806 case FT_TEXT:
2808 // frame bound frames
2809 if ( bExportContent )
2811 Reference < XTextFrame > xTxtFrame( rTxtCntnt, UNO_QUERY );
2812 Reference < XText > xTxt(xTxtFrame->getText());
2813 exportFrameFrames( true, bIsProgress, &xTxtFrame );
2814 exportText( xTxt, bAutoStyles, bIsProgress, true );
2817 break;
2818 case FT_SHAPE:
2820 Reference < XShape > xShape( rTxtCntnt, UNO_QUERY );
2821 GetExport().GetShapeExport()->collectShapeAutoStyles( xShape );
2823 break;
2824 default:
2825 break;
2828 else
2830 Reference< XPropertySetInfo > xPropSetInfo(xPropSet->getPropertySetInfo());
2831 Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY );
2833 bool bAddCharStyles = pRangePropSet &&
2834 lcl_txtpara_isBoundAsChar( xPropSet, xPropSetInfo );
2836 bool bIsUICharStyle;
2837 bool bHasAutoStyle = false;
2839 OUString sStyle;
2841 if( bAddCharStyles )
2843 bool bDummy;
2844 sStyle = FindTextStyleAndHyperlink( *pRangePropSet, bDummy, bIsUICharStyle, bHasAutoStyle );
2846 else
2847 bIsUICharStyle = false;
2849 bool bDoSomething = bIsUICharStyle
2850 && aCharStyleNamesPropInfoCache.hasProperty( *pRangePropSet );
2851 XMLTextCharStyleNamesElementExport aCharStylesExport(
2852 GetExport(), bDoSomething, bHasAutoStyle,
2853 bDoSomething ? *pRangePropSet : Reference<XPropertySet>(),
2854 sCharStyleNames );
2856 if( !sStyle.isEmpty() )
2857 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
2858 GetExport().EncodeStyleName( sStyle ) );
2860 SvXMLElementExport aElem( GetExport(), !sStyle.isEmpty(),
2861 XML_NAMESPACE_TEXT, XML_SPAN, false, false );
2863 SvXMLElementExport aElement( GetExport(),
2864 FT_SHAPE != eType &&
2865 addHyperlinkAttributes( xPropSet,
2866 xPropState,xPropSetInfo ),
2867 XML_NAMESPACE_DRAW, XML_A, false, false );
2868 switch( eType )
2870 case FT_TEXT:
2871 _exportTextFrame( xPropSet, xPropSetInfo, bIsProgress );
2872 break;
2873 case FT_GRAPHIC:
2874 _exportTextGraphic( xPropSet, xPropSetInfo );
2875 break;
2876 case FT_EMBEDDED:
2877 _exportTextEmbedded( xPropSet, xPropSetInfo );
2878 break;
2879 case FT_SHAPE:
2881 Reference < XShape > xShape( rTxtCntnt, UNO_QUERY );
2882 XMLShapeExportFlags nFeatures =
2883 addTextFrameAttributes( xPropSet, true );
2884 GetExport().GetShapeExport()
2885 ->exportShape( xShape, nFeatures );
2887 break;
2895 void XMLTextParagraphExport::_exportTextFrame(
2896 const Reference < XPropertySet > & rPropSet,
2897 const Reference < XPropertySetInfo > & rPropSetInfo,
2898 bool bIsProgress )
2900 Reference < XTextFrame > xTxtFrame( rPropSet, UNO_QUERY );
2901 Reference < XText > xTxt(xTxtFrame->getText());
2903 OUString sStyle;
2904 if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
2906 rPropSet->getPropertyValue( sFrameStyleName ) >>= sStyle;
2909 OUString sAutoStyle( sStyle );
2910 OUString aMinHeightValue;
2911 OUString sMinWidthValue;
2912 sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle );
2913 if( !sAutoStyle.isEmpty() )
2914 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME,
2915 GetExport().EncodeStyleName( sAutoStyle ) );
2916 addTextFrameAttributes(rPropSet, false, &aMinHeightValue, &sMinWidthValue);
2918 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
2919 XML_FRAME, false, true );
2921 if( !aMinHeightValue.isEmpty() )
2922 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_HEIGHT,
2923 aMinHeightValue );
2925 if (!sMinWidthValue.isEmpty())
2927 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_WIDTH,
2928 sMinWidthValue );
2931 // draw:chain-next-name
2932 if( rPropSetInfo->hasPropertyByName( sChainNextName ) )
2934 OUString sNext;
2935 if( (rPropSet->getPropertyValue( sChainNextName ) >>= sNext) && !sNext.isEmpty() )
2936 GetExport().AddAttribute( XML_NAMESPACE_DRAW,
2937 XML_CHAIN_NEXT_NAME,
2938 sNext );
2942 SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_DRAW,
2943 XML_TEXT_BOX, true, true );
2945 // frame bound frames
2946 exportFramesBoundToFrame( xTxtFrame, bIsProgress );
2948 exportText( xTxt, false, bIsProgress, true );
2951 // script:events
2952 Reference<XEventsSupplier> xEventsSupp( xTxtFrame, UNO_QUERY );
2953 GetExport().GetEventExport().Export(xEventsSupp);
2955 // image map
2956 GetExport().GetImageMapExport().Export( rPropSet );
2958 // svg:title and svg:desc (#i73249#)
2959 exportTitleAndDescription( rPropSet, rPropSetInfo );
2962 void XMLTextParagraphExport::exportContour(
2963 const Reference < XPropertySet > & rPropSet,
2964 const Reference < XPropertySetInfo > & rPropSetInfo )
2966 if( !rPropSetInfo->hasPropertyByName( sContourPolyPolygon ) )
2968 return;
2971 PointSequenceSequence aSourcePolyPolygon;
2972 rPropSet->getPropertyValue( sContourPolyPolygon ) >>= aSourcePolyPolygon;
2973 const basegfx::B2DPolyPolygon aPolyPolygon(
2974 basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(
2975 aSourcePolyPolygon));
2976 const sal_uInt32 nPolygonCount(aPolyPolygon.count());
2978 if(!nPolygonCount)
2980 return;
2983 const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange());
2984 bool bPixel(false);
2986 if( rPropSetInfo->hasPropertyByName( sIsPixelContour ) )
2988 bPixel = *static_cast<sal_Bool const *>(rPropSet->getPropertyValue( sIsPixelContour ).getValue());
2991 // svg: width
2992 OUStringBuffer aStringBuffer( 10 );
2994 if(bPixel)
2996 ::sax::Converter::convertMeasurePx(aStringBuffer, basegfx::fround(aPolyPolygonRange.getWidth()));
2998 else
3000 GetExport().GetMM100UnitConverter().convertMeasureToXML(aStringBuffer, basegfx::fround(aPolyPolygonRange.getWidth()));
3003 GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStringBuffer.makeStringAndClear());
3005 // svg: height
3006 if(bPixel)
3008 ::sax::Converter::convertMeasurePx(aStringBuffer, basegfx::fround(aPolyPolygonRange.getHeight()));
3010 else
3012 GetExport().GetMM100UnitConverter().convertMeasureToXML(aStringBuffer, basegfx::fround(aPolyPolygonRange.getHeight()));
3015 GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStringBuffer.makeStringAndClear());
3017 // svg:viewbox
3018 SdXMLImExViewBox aViewBox(0.0, 0.0, aPolyPolygonRange.getWidth(), aPolyPolygonRange.getHeight());
3019 GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString());
3020 enum XMLTokenEnum eElem = XML_TOKEN_INVALID;
3022 if(1 == nPolygonCount )
3024 // simple polygon shape, can be written as svg:points sequence
3025 const OUString aPointString(
3026 basegfx::tools::exportToSvgPoints(
3027 aPolyPolygon.getB2DPolygon(0)));
3029 // write point array
3030 GetExport().AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPointString);
3031 eElem = XML_CONTOUR_POLYGON;
3033 else
3035 // polypolygon, needs to be written as a svg:path sequence
3036 const OUString aPolygonString(
3037 basegfx::tools::exportToSvgD(
3038 aPolyPolygon,
3039 true, // bUseRelativeCoordinates
3040 false, // bDetectQuadraticBeziers: not used in old, but maybe activated now
3041 true)); // bHandleRelativeNextPointCompatible
3043 // write point array
3044 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_D, aPolygonString);
3045 eElem = XML_CONTOUR_PATH;
3048 if( rPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
3050 bool bTmp = *static_cast<sal_Bool const *>(rPropSet->getPropertyValue(
3051 sIsAutomaticContour ).getValue());
3052 GetExport().AddAttribute( XML_NAMESPACE_DRAW,
3053 XML_RECREATE_ON_EDIT, bTmp ? XML_TRUE : XML_FALSE );
3056 // write object now
3057 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, eElem,
3058 true, true );
3061 void XMLTextParagraphExport::_exportTextGraphic(
3062 const Reference < XPropertySet > & rPropSet,
3063 const Reference < XPropertySetInfo > & rPropSetInfo )
3065 OUString sStyle;
3066 if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
3068 rPropSet->getPropertyValue( sFrameStyleName ) >>= sStyle;
3071 OUString sAutoStyle( sStyle );
3072 sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle );
3073 if( !sAutoStyle.isEmpty() )
3074 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME,
3075 GetExport().EncodeStyleName( sAutoStyle ) );
3076 addTextFrameAttributes( rPropSet, false );
3078 // svg:transform
3079 sal_Int16 nVal = 0;
3080 rPropSet->getPropertyValue( sGraphicRotation ) >>= nVal;
3081 if( nVal != 0 )
3083 OUStringBuffer sRet( GetXMLToken(XML_ROTATE).getLength()+4 );
3084 sRet.append( GetXMLToken(XML_ROTATE));
3085 sRet.append( '(' );
3086 ::sax::Converter::convertNumber( sRet, (sal_Int32)nVal );
3087 sRet.append( ')' );
3088 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_TRANSFORM,
3089 sRet.makeStringAndClear() );
3092 // original content
3093 SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_DRAW, XML_FRAME, false, true);
3095 // replacement graphic for backwards compatibility, but
3096 // only for SVG currently
3097 OUString sReplacementOrigURL;
3098 rPropSet->getPropertyValue( sReplacementGraphicURL ) >>= sReplacementOrigURL;
3100 // xlink:href
3101 OUString sOrigURL;
3102 rPropSet->getPropertyValue( sGraphicURL ) >>= sOrigURL;
3103 OUString sURL(GetExport().AddEmbeddedGraphicObject( sOrigURL ));
3105 // If there still is no url, then then graphic is empty
3106 if( !sURL.isEmpty() )
3108 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
3109 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3110 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
3111 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE,
3112 XML_ONLOAD );
3115 // draw:filter-name
3116 OUString sGrfFilter;
3117 rPropSet->getPropertyValue( sGraphicFilter ) >>= sGrfFilter;
3118 if( !sGrfFilter.isEmpty() )
3119 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_FILTER_NAME,
3120 sGrfFilter );
3123 SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_DRAW,
3124 XML_IMAGE, false, true );
3126 // optional office:binary-data
3127 GetExport().AddEmbeddedGraphicObjectAsBase64( sOrigURL );
3130 //Resolves: fdo#62461 put preferred image first above, followed by
3131 //fallback here
3132 if (!sReplacementOrigURL.isEmpty())
3134 const OUString sReplacementURL(GetExport().AddEmbeddedGraphicObject( sReplacementOrigURL ));
3136 // If there is no url, then then graphic is empty
3137 if(sReplacementURL.getLength())
3139 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sReplacementURL);
3140 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
3141 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED);
3142 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD);
3144 // xlink:href for replacement, only written for Svg content
3145 SvXMLElementExport aElement(GetExport(), XML_NAMESPACE_DRAW, XML_IMAGE, false, true);
3147 // optional office:binary-data
3148 GetExport().AddEmbeddedGraphicObjectAsBase64(sReplacementURL);
3154 // script:events
3155 Reference<XEventsSupplier> xEventsSupp( rPropSet, UNO_QUERY );
3156 GetExport().GetEventExport().Export(xEventsSupp);
3158 // image map
3159 GetExport().GetImageMapExport().Export( rPropSet );
3161 // svg:title and svg:desc (#i73249#)
3162 exportTitleAndDescription( rPropSet, rPropSetInfo );
3164 // draw:contour
3165 exportContour( rPropSet, rPropSetInfo );
3168 void XMLTextParagraphExport::_collectTextEmbeddedAutoStyles(const Reference < XPropertySet > & )
3170 DBG_ASSERT( false, "no API implementation avialable" );
3173 void XMLTextParagraphExport::_exportTextEmbedded(
3174 const Reference < XPropertySet > &,
3175 const Reference < XPropertySetInfo > & )
3177 DBG_ASSERT( false, "no API implementation avialable" );
3180 void XMLTextParagraphExport::exportEvents( const Reference < XPropertySet > & rPropSet )
3182 // script:events
3183 Reference<XEventsSupplier> xEventsSupp( rPropSet, UNO_QUERY );
3184 GetExport().GetEventExport().Export(xEventsSupp);
3186 // image map
3187 OUString sImageMap("ImageMap");
3188 if (rPropSet->getPropertySetInfo()->hasPropertyByName(sImageMap))
3189 GetExport().GetImageMapExport().Export( rPropSet );
3192 // Implement Title/Description Elements UI (#i73249#)
3193 void XMLTextParagraphExport::exportTitleAndDescription(
3194 const Reference < XPropertySet > & rPropSet,
3195 const Reference < XPropertySetInfo > & rPropSetInfo )
3197 // svg:title
3198 if( rPropSetInfo->hasPropertyByName( sTitle ) )
3200 OUString sObjTitle;
3201 rPropSet->getPropertyValue( sTitle ) >>= sObjTitle;
3202 if( !sObjTitle.isEmpty() )
3204 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG,
3205 XML_TITLE, true, false );
3206 GetExport().Characters( sObjTitle );
3210 // svg:description
3211 if( rPropSetInfo->hasPropertyByName( sDescription ) )
3213 OUString sObjDesc;
3214 rPropSet->getPropertyValue( sDescription ) >>= sObjDesc;
3215 if( !sObjDesc.isEmpty() )
3217 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG,
3218 XML_DESC, true, false );
3219 GetExport().Characters( sObjDesc );
3224 bool XMLTextParagraphExport::addHyperlinkAttributes(
3225 const Reference< XPropertySet > & rPropSet,
3226 const Reference< XPropertyState > & rPropState,
3227 const Reference< XPropertySetInfo > & rPropSetInfo )
3229 bool bExport = false;
3230 OUString sHRef, sName, sTargetFrame, sUStyleName, sVStyleName;
3231 bool bServerMap = false;
3233 if( rPropSetInfo->hasPropertyByName( sHyperLinkURL ) &&
3234 ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
3235 rPropState->getPropertyState( sHyperLinkURL ) ) )
3237 rPropSet->getPropertyValue( sHyperLinkURL ) >>= sHRef;
3239 if( !sHRef.isEmpty() )
3240 bExport = true;
3243 if ( sHRef.isEmpty() )
3245 // hyperlink without an URL does not make sense
3246 OSL_ENSURE( false, "hyperlink without an URL --> no export to ODF" );
3247 return false;
3250 if ( rPropSetInfo->hasPropertyByName( sHyperLinkName )
3251 && ( !rPropState.is()
3252 || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sHyperLinkName ) ) )
3254 rPropSet->getPropertyValue( sHyperLinkName ) >>= sName;
3255 if( !sName.isEmpty() )
3256 bExport = true;
3259 if ( rPropSetInfo->hasPropertyByName( sHyperLinkTarget )
3260 && ( !rPropState.is()
3261 || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sHyperLinkTarget ) ) )
3263 rPropSet->getPropertyValue( sHyperLinkTarget ) >>= sTargetFrame;
3264 if( !sTargetFrame.isEmpty() )
3265 bExport = true;
3268 if ( rPropSetInfo->hasPropertyByName( sServerMap )
3269 && ( !rPropState.is()
3270 || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sServerMap ) ) )
3272 bServerMap = *static_cast<sal_Bool const *>(rPropSet->getPropertyValue( sServerMap ).getValue());
3273 if ( bServerMap )
3274 bExport = true;
3277 if ( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName )
3278 && ( !rPropState.is()
3279 || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sUnvisitedCharStyleName ) ) )
3281 rPropSet->getPropertyValue( sUnvisitedCharStyleName ) >>= sUStyleName;
3282 if( !sUStyleName.isEmpty() )
3283 bExport = true;
3286 if ( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName )
3287 && ( !rPropState.is()
3288 || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sVisitedCharStyleName ) ) )
3290 rPropSet->getPropertyValue( sVisitedCharStyleName ) >>= sVStyleName;
3291 if( !sVStyleName.isEmpty() )
3292 bExport = true;
3295 if ( bExport )
3297 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3298 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference( sHRef ) );
3300 if( !sName.isEmpty() )
3301 GetExport().AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME, sName );
3303 if( !sTargetFrame.isEmpty() )
3305 GetExport().AddAttribute( XML_NAMESPACE_OFFICE,
3306 XML_TARGET_FRAME_NAME, sTargetFrame );
3307 enum XMLTokenEnum eTok = sTargetFrame == "_blank" ? XML_NEW : XML_REPLACE;
3308 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, eTok );
3311 if( bServerMap )
3312 GetExport().AddAttribute( XML_NAMESPACE_OFFICE,
3313 XML_SERVER_MAP, XML_TRUE );
3315 if( !sUStyleName.isEmpty() )
3316 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
3317 XML_STYLE_NAME, GetExport().EncodeStyleName( sUStyleName ) );
3319 if( !sVStyleName.isEmpty() )
3320 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
3321 XML_VISITED_STYLE_NAME, GetExport().EncodeStyleName( sVStyleName ) );
3324 return bExport;
3327 void XMLTextParagraphExport::exportTextRangeSpan(
3328 const com::sun::star::uno::Reference< com::sun::star::text::XTextRange > & rTextRange,
3329 Reference< XPropertySet > & xPropSet,
3330 Reference < XPropertySetInfo > & xPropSetInfo,
3331 const bool bIsUICharStyle,
3332 const bool bHasAutoStyle,
3333 const OUString& sStyle,
3334 bool& rPrevCharIsSpace,
3335 FieldmarkType& openFieldMark )
3337 XMLTextCharStyleNamesElementExport aCharStylesExport(
3338 GetExport(),
3339 bIsUICharStyle && aCharStyleNamesPropInfoCache.hasProperty( xPropSet, xPropSetInfo ),
3340 bHasAutoStyle,
3341 xPropSet,
3342 sCharStyleNames );
3344 if ( !sStyle.isEmpty() )
3346 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( sStyle ) );
3349 SvXMLElementExport aElement( GetExport(), !sStyle.isEmpty(), XML_NAMESPACE_TEXT, XML_SPAN, false, false );
3350 const OUString aText( rTextRange->getString() );
3351 SvXMLElementExport aElem2( GetExport(), TEXT == openFieldMark,
3352 XML_NAMESPACE_TEXT, XML_TEXT_INPUT,
3353 false, false );
3354 exportText( aText, rPrevCharIsSpace );
3355 openFieldMark = NONE;
3359 void XMLTextParagraphExport::exportTextRange(
3360 const Reference< XTextRange > & rTextRange,
3361 bool bAutoStyles,
3362 bool& rPrevCharIsSpace,
3363 FieldmarkType& openFieldMark )
3365 Reference< XPropertySet > xPropSet( rTextRange, UNO_QUERY );
3366 if ( bAutoStyles )
3368 Add( XML_STYLE_FAMILY_TEXT_TEXT, xPropSet );
3370 else
3372 bool bHyperlink = false;
3373 bool bIsUICharStyle = false;
3374 bool bHasAutoStyle = false;
3375 const OUString sStyle(
3376 FindTextStyleAndHyperlink( xPropSet, bHyperlink, bIsUICharStyle, bHasAutoStyle ) );
3378 Reference < XPropertySetInfo > xPropSetInfo;
3379 bool bHyperlinkAttrsAdded = false;
3380 if ( bHyperlink )
3382 Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY );
3383 xPropSetInfo.set( xPropSet->getPropertySetInfo() );
3384 bHyperlinkAttrsAdded = addHyperlinkAttributes( xPropSet, xPropState, xPropSetInfo );
3387 if ( bHyperlink && bHyperlinkAttrsAdded )
3389 SvXMLElementExport aElem( GetExport(), true, XML_NAMESPACE_TEXT, XML_A, false, false );
3391 // export events (if supported)
3392 OUString sHyperLinkEvents(
3393 "HyperLinkEvents");
3394 if (xPropSetInfo->hasPropertyByName(sHyperLinkEvents))
3396 Reference< XNameReplace > xName( xPropSet->getPropertyValue( sHyperLinkEvents ), uno::UNO_QUERY );
3397 GetExport().GetEventExport().Export( xName, false );
3400 exportTextRangeSpan( rTextRange, xPropSet, xPropSetInfo, bIsUICharStyle, bHasAutoStyle, sStyle, rPrevCharIsSpace, openFieldMark );
3402 else
3404 exportTextRangeSpan( rTextRange, xPropSet, xPropSetInfo, bIsUICharStyle, bHasAutoStyle, sStyle, rPrevCharIsSpace, openFieldMark );
3409 void XMLTextParagraphExport::exportText( const OUString& rText,
3410 bool& rPrevCharIsSpace, TextPNS /*eExtensionNS*/ )
3412 sal_Int32 nExpStartPos = 0;
3413 sal_Int32 nEndPos = rText.getLength();
3414 sal_Int32 nSpaceChars = 0;
3415 for( sal_Int32 nPos = 0; nPos < nEndPos; nPos++ )
3417 sal_Unicode cChar = rText[nPos];
3418 bool bExpCharAsText = true;
3419 bool bExpCharAsElement = false;
3420 bool bCurrCharIsSpace = false;
3421 switch( cChar )
3423 case 0x0009: // Tab
3424 case 0x000A: // LF
3425 // These characters are exported as text.
3426 bExpCharAsElement = true;
3427 bExpCharAsText = false;
3428 break;
3429 case 0x000D:
3430 break; // legal character
3431 case 0x0020: // Blank
3432 if( rPrevCharIsSpace )
3434 // If the previous character is a space character,
3435 // too, export a special space element.
3436 bExpCharAsText = false;
3438 bCurrCharIsSpace = true;
3439 break;
3440 default:
3441 if( cChar < 0x0020 )
3443 #ifdef DBG_UTIL
3444 OSL_ENSURE( txtparae_bContainsIllegalCharacters ||
3445 cChar >= 0x0020,
3446 "illegal character in text content" );
3447 txtparae_bContainsIllegalCharacters = true;
3448 #endif
3449 bExpCharAsText = false;
3451 break;
3454 // If the current character is not exported as text
3455 // the text that has not been exported by now has to be exported now.
3456 if( nPos > nExpStartPos && !bExpCharAsText )
3458 DBG_ASSERT( 0==nSpaceChars, "pending spaces" );
3459 OUString sExp( rText.copy( nExpStartPos, nPos - nExpStartPos ) );
3460 GetExport().Characters( sExp );
3461 nExpStartPos = nPos;
3464 // If there are spaces left that have not been exported and the
3465 // current character is not a space , the pending spaces have to be
3466 // exported now.
3467 if( nSpaceChars > 0 && !bCurrCharIsSpace )
3469 DBG_ASSERT( nExpStartPos == nPos, " pending characters" );
3471 if( nSpaceChars > 1 )
3473 OUStringBuffer sTmp;
3474 sTmp.append( (sal_Int32)nSpaceChars );
3475 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C,
3476 sTmp.makeStringAndClear() );
3479 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
3480 XML_S, false, false );
3482 nSpaceChars = 0;
3485 // If the current character has to be exported as a special
3486 // element, the elemnt will be exported now.
3487 if( bExpCharAsElement )
3489 switch( cChar )
3491 case 0x0009: // Tab
3493 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
3494 XML_TAB, false,
3495 false );
3497 break;
3498 case 0x000A: // LF
3500 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
3501 XML_LINE_BREAK, false,
3502 false );
3504 break;
3508 // If the current character is a space, and the previous one
3509 // is a space, too, the number of pending spaces is incremented
3510 // only.
3511 if( bCurrCharIsSpace && rPrevCharIsSpace )
3512 nSpaceChars++;
3513 rPrevCharIsSpace = bCurrCharIsSpace;
3515 // If the current character is not exported as text, the start
3516 // position for text is the position behind the current position.
3517 if( !bExpCharAsText )
3519 DBG_ASSERT( nExpStartPos == nPos, "wrong export start pos" );
3520 nExpStartPos = nPos+1;
3524 if( nExpStartPos < nEndPos )
3526 DBG_ASSERT( 0==nSpaceChars, " pending spaces " );
3527 OUString sExp( rText.copy( nExpStartPos, nEndPos - nExpStartPos ) );
3528 GetExport().Characters( sExp );
3531 // If there are some spaces left, they have to be exported now.
3532 if( nSpaceChars > 0 )
3534 if( nSpaceChars > 1 )
3536 OUStringBuffer sTmp;
3537 sTmp.append( (sal_Int32)nSpaceChars );
3538 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C,
3539 sTmp.makeStringAndClear() );
3542 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_S,
3543 false, false );
3547 void XMLTextParagraphExport::exportTextDeclarations()
3549 pFieldExport->ExportFieldDeclarations();
3551 // get XPropertySet from the document and ask for AutoMarkFileURL.
3552 // If it exists, export the auto-mark-file element.
3553 Reference<XPropertySet> xPropertySet( GetExport().GetModel(), UNO_QUERY );
3554 if (xPropertySet.is())
3556 OUString sUrl;
3557 OUString sIndexAutoMarkFileURL(
3558 "IndexAutoMarkFileURL");
3559 if (xPropertySet->getPropertySetInfo()->hasPropertyByName(
3560 sIndexAutoMarkFileURL))
3562 xPropertySet->getPropertyValue(sIndexAutoMarkFileURL) >>= sUrl;
3563 if (!sUrl.isEmpty())
3565 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF,
3566 GetExport().GetRelativeReference(sUrl) );
3567 SvXMLElementExport aAutoMarkElement(
3568 GetExport(), XML_NAMESPACE_TEXT,
3569 XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE,
3570 true, true );
3576 void XMLTextParagraphExport::exportTextDeclarations(
3577 const Reference<XText> & rText )
3579 pFieldExport->ExportFieldDeclarations(rText);
3582 void XMLTextParagraphExport::exportUsedDeclarations( bool bOnlyUsed )
3584 pFieldExport->SetExportOnlyUsedFieldDeclarations( bOnlyUsed );
3587 void XMLTextParagraphExport::exportTrackedChanges(bool bAutoStyles)
3589 if (NULL != pRedlineExport)
3590 pRedlineExport->ExportChangesList( bAutoStyles );
3593 void XMLTextParagraphExport::exportTrackedChanges(
3594 const Reference<XText> & rText,
3595 bool bAutoStyle)
3597 if (NULL != pRedlineExport)
3598 pRedlineExport->ExportChangesList(rText, bAutoStyle);
3601 void XMLTextParagraphExport::recordTrackedChangesForXText(
3602 const Reference<XText> & rText )
3604 if (NULL != pRedlineExport)
3605 pRedlineExport->SetCurrentXText(rText);
3608 void XMLTextParagraphExport::recordTrackedChangesNoXText()
3610 if (NULL != pRedlineExport)
3611 pRedlineExport->SetCurrentXText();
3614 void XMLTextParagraphExport::exportTextAutoStyles()
3616 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
3617 GetExport().GetDocHandler(),
3618 GetExport().GetMM100UnitConverter(),
3619 GetExport().GetNamespaceMap() );
3621 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_TEXT,
3622 GetExport().GetDocHandler(),
3623 GetExport().GetMM100UnitConverter(),
3624 GetExport().GetNamespaceMap() );
3626 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_FRAME,
3627 GetExport().GetDocHandler(),
3628 GetExport().GetMM100UnitConverter(),
3629 GetExport().GetNamespaceMap() );
3631 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_SECTION,
3632 GetExport().GetDocHandler(),
3633 GetExport().GetMM100UnitConverter(),
3634 GetExport().GetNamespaceMap() );
3636 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_RUBY,
3637 GetExport().GetDocHandler(),
3638 GetExport().GetMM100UnitConverter(),
3639 GetExport().GetNamespaceMap() );
3641 pListAutoPool->exportXML();
3644 void XMLTextParagraphExport::exportRuby(
3645 const Reference<XPropertySet> & rPropSet,
3646 bool bAutoStyles )
3648 // early out: a collapsed ruby makes no sense
3649 if (*static_cast<sal_Bool const *>(rPropSet->getPropertyValue(sIsCollapsed).getValue()))
3650 return;
3652 // start value ?
3653 bool bStart = *static_cast<sal_Bool const *>(rPropSet->getPropertyValue(sIsStart).getValue());
3655 if (bAutoStyles)
3657 // ruby auto styles
3658 if (bStart)
3659 Add( XML_STYLE_FAMILY_TEXT_RUBY, rPropSet );
3661 else
3663 if (bStart)
3665 // ruby start
3667 // we can only start a ruby if none is open
3668 DBG_ASSERT(! bOpenRuby, "Can't open a ruby inside of ruby!");
3669 if( bOpenRuby )
3670 return;
3672 // save ruby text + ruby char style
3673 rPropSet->getPropertyValue(sRubyText) >>= sOpenRubyText;
3674 rPropSet->getPropertyValue(sRubyCharStyleName) >>= sOpenRubyCharStyle;
3676 // ruby style
3677 GetExport().CheckAttrList();
3678 OUString sEmpty;
3679 OUString sStyleName(Find( XML_STYLE_FAMILY_TEXT_RUBY, rPropSet,
3680 sEmpty ));
3681 DBG_ASSERT(!sStyleName.isEmpty(), "I can't find the style!");
3682 GetExport().AddAttribute(XML_NAMESPACE_TEXT,
3683 XML_STYLE_NAME, sStyleName);
3685 // export <text:ruby> and <text:ruby-base> start elements
3686 GetExport().StartElement( XML_NAMESPACE_TEXT, XML_RUBY, false);
3687 GetExport().ClearAttrList();
3688 GetExport().StartElement( XML_NAMESPACE_TEXT, XML_RUBY_BASE,
3689 false );
3690 bOpenRuby = true;
3692 else
3694 // ruby end
3696 // check for an open ruby
3697 DBG_ASSERT(bOpenRuby, "Can't close a ruby if none is open!");
3698 if( !bOpenRuby )
3699 return;
3701 // close <text:ruby-base>
3702 GetExport().EndElement(XML_NAMESPACE_TEXT, XML_RUBY_BASE,
3703 false);
3705 // write the ruby text (with char style)
3707 if (!sOpenRubyCharStyle.isEmpty())
3708 GetExport().AddAttribute(
3709 XML_NAMESPACE_TEXT, XML_STYLE_NAME,
3710 GetExport().EncodeStyleName( sOpenRubyCharStyle) );
3712 SvXMLElementExport aRubyElement(
3713 GetExport(), XML_NAMESPACE_TEXT, XML_RUBY_TEXT,
3714 false, false);
3716 GetExport().Characters(sOpenRubyText);
3719 // and finally, close the ruby
3720 GetExport().EndElement(XML_NAMESPACE_TEXT, XML_RUBY, false);
3721 bOpenRuby = false;
3726 void XMLTextParagraphExport::exportMeta(
3727 const Reference<XPropertySet> & i_xPortion,
3728 bool i_bAutoStyles, bool i_isProgress)
3730 static const char sMeta[] = "InContentMetadata";
3732 bool doExport(!i_bAutoStyles); // do not export element if autostyles
3733 // check version >= 1.2
3734 switch (GetExport().getDefaultVersion()) {
3735 case SvtSaveOptions::ODFVER_011: // fall through
3736 case SvtSaveOptions::ODFVER_010: doExport = false; break;
3737 default: break;
3740 const Reference< XTextContent > xTextContent(
3741 i_xPortion->getPropertyValue(sMeta), UNO_QUERY_THROW);
3742 const Reference< XEnumerationAccess > xEA( xTextContent, UNO_QUERY_THROW );
3743 const Reference< XEnumeration > xTextEnum( xEA->createEnumeration() );
3745 if (doExport)
3747 const Reference<rdf::XMetadatable> xMeta(xTextContent, UNO_QUERY_THROW);
3749 // text:meta with neither xml:id nor RDFa is invalid
3750 xMeta->ensureMetadataReference();
3752 // xml:id and RDFa for RDF metadata
3753 GetExport().AddAttributeXmlId(xMeta);
3754 GetExport().AddAttributesRDFa(xTextContent);
3757 SvXMLElementExport aElem( GetExport(), doExport,
3758 XML_NAMESPACE_TEXT, XML_META, false, false );
3760 // recurse to export content
3761 exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_isProgress );
3764 void XMLTextParagraphExport::PreventExportOfControlsInMuteSections(
3765 const Reference<XIndexAccess> & rShapes,
3766 rtl::Reference<xmloff::OFormLayerXMLExport> xFormExport )
3768 // check parameters ad pre-conditions
3769 if( ( ! rShapes.is() ) || ( ! xFormExport.is() ) )
3771 // if we don't have shapes or a form export, there's nothing to do
3772 return;
3774 DBG_ASSERT( pSectionExport != NULL, "We need the section export." );
3776 Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration();
3777 if(!xShapesEnum.is())
3778 return;
3779 while( xShapesEnum->hasMoreElements() )
3781 // now we need to check
3782 // 1) if this is a control shape, and
3783 // 2) if it's in a mute section
3784 // if both answers are 'yes', notify the form layer export
3786 // we join accessing the shape and testing for control
3787 Reference<XControlShape> xControlShape(xShapesEnum->nextElement(), UNO_QUERY);
3788 if( xControlShape.is() )
3790 // Reference<XPropertySet> xPropSet( xControlShape, UNO_QUERY );
3791 // Reference<XTextContent> xTextContent;
3792 // xPropSet->getPropertyValue("TextRange") >>= xTextContent;
3794 Reference<XTextContent> xTextContent( xControlShape, UNO_QUERY );
3795 if( xTextContent.is() )
3797 if( pSectionExport->IsMuteSection( xTextContent, false ) )
3799 // Ah, we've found a shape that
3800 // 1) is a control shape
3801 // 2) is anchored in a mute section
3802 // so: don't export it!
3803 xFormExport->excludeFromExport(
3804 xControlShape->getControl() );
3806 // else: not in mute section -> should be exported -> nothing
3807 // to do
3809 // else: no anchor -> ignore
3811 // else: no control shape -> nothing to do
3815 void XMLTextParagraphExport::PushNewTextListsHelper()
3817 mpTextListsHelper = new XMLTextListsHelper();
3818 maTextListsHelperStack.push_back( mpTextListsHelper );
3821 void XMLTextParagraphExport::PopTextListsHelper()
3823 delete mpTextListsHelper;
3824 mpTextListsHelper = 0;
3825 maTextListsHelperStack.pop_back();
3826 if ( !maTextListsHelperStack.empty() )
3828 mpTextListsHelper = maTextListsHelperStack.back();
3832 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */