1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
27 #include <boost/unordered_map.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/container/XEnumerationAccess.hpp>
31 #include <com/sun/star/container/XEnumeration.hpp>
32 #include <com/sun/star/container/XIndexReplace.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/beans/XMultiPropertySet.hpp>
35 #include <com/sun/star/beans/XPropertyState.hpp>
36 #include <com/sun/star/text/XTextDocument.hpp>
37 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
38 #include <com/sun/star/text/XTextTablesSupplier.hpp>
39 #include <com/sun/star/text/XNumberingRulesSupplier.hpp>
40 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
41 #include <com/sun/star/text/XTextTable.hpp>
42 #include <com/sun/star/text/XText.hpp>
43 #include <com/sun/star/text/XTextContent.hpp>
44 #include <com/sun/star/text/XTextRange.hpp>
45 #include <com/sun/star/text/XTextField.hpp>
46 #include <com/sun/star/text/XFootnote.hpp>
47 #include <com/sun/star/container/XNamed.hpp>
48 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
49 #include <com/sun/star/text/XTextFrame.hpp>
50 #include <com/sun/star/container/XNameAccess.hpp>
51 #include <com/sun/star/text/SizeType.hpp>
52 #include <com/sun/star/text/HoriOrientation.hpp>
53 #include <com/sun/star/text/VertOrientation.hpp>
54 #include <com/sun/star/text/TextContentAnchorType.hpp>
55 #include <com/sun/star/text/XTextFramesSupplier.hpp>
56 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
57 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
58 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
59 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
60 #include <com/sun/star/document/XEventsSupplier.hpp>
61 #include <com/sun/star/document/XRedlinesSupplier.hpp>
63 #include <com/sun/star/text/XBookmarksSupplier.hpp>
64 #include <com/sun/star/text/XFormField.hpp>
66 #include <com/sun/star/text/XTextSection.hpp>
67 #include <com/sun/star/text/SectionFileLink.hpp>
68 #include <com/sun/star/drawing/XShape.hpp>
69 #include <com/sun/star/text/XTextShapesSupplier.hpp>
71 #include <com/sun/star/style/XAutoStylesSupplier.hpp>
72 #include <com/sun/star/style/XAutoStyleFamily.hpp>
73 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
74 #include <com/sun/star/text/XFootnotesSupplier.hpp>
75 #include <com/sun/star/text/XEndnotesSupplier.hpp>
76 #include <com/sun/star/drawing/XControlShape.hpp>
77 #include <com/sun/star/util/DateTime.hpp>
79 #include <sax/tools/converter.hxx>
81 #include "xmloff/xmlnmspe.hxx"
82 #include <xmloff/xmlaustp.hxx>
83 #include <xmloff/families.hxx>
84 #include "txtexppr.hxx"
85 #include <xmloff/xmlnumfe.hxx>
86 #include <xmloff/xmlnume.hxx>
87 #include <xmloff/xmluconv.hxx>
88 #include "XMLAnchorTypePropHdl.hxx"
89 #include "xexptran.hxx"
90 #include <xmloff/ProgressBarHelper.hxx>
91 #include <xmloff/nmspmap.hxx>
92 #include <xmloff/xmlexp.hxx>
93 #include "txtflde.hxx"
94 #include <xmloff/txtprmap.hxx>
95 #include "XMLImageMapExport.hxx"
96 #include "XMLTextNumRuleInfo.hxx"
97 #include "xmloff/XMLTextListAutoStylePool.hxx"
98 #include <xmloff/txtparae.hxx>
99 #include "XMLSectionExport.hxx"
100 #include "XMLIndexMarkExport.hxx"
101 #include <xmloff/XMLEventExport.hxx>
102 #include "XMLRedlineExport.hxx"
103 #include "MultiPropertySetHelper.hxx"
104 #include <xmloff/formlayerexport.hxx>
105 #include "XMLTextCharStyleNamesElementExport.hxx"
106 #include <comphelper/stlunosequence.hxx>
108 #include <xmloff/odffields.hxx>
109 #include <com/sun/star/embed/ElementModes.hpp>
110 #include <com/sun/star/embed/XTransactedObject.hpp>
111 #include <com/sun/star/document/XStorageBasedDocument.hpp>
112 #include <txtlists.hxx>
113 #include <com/sun/star/rdf/XMetadatable.hpp>
116 using namespace ::std
;
117 using namespace ::com::sun::star
;
118 using namespace ::com::sun::star::uno
;
119 using namespace ::com::sun::star::lang
;
120 using namespace ::com::sun::star::beans
;
121 using namespace ::com::sun::star::container
;
122 using namespace ::com::sun::star::text
;
123 using namespace ::com::sun::star::style
;
124 using namespace ::com::sun::star::util
;
125 using namespace ::com::sun::star::drawing
;
126 using namespace ::com::sun::star::document
;
127 using namespace ::com::sun::star::frame
;
128 using namespace ::xmloff
;
129 using namespace ::xmloff::token
;
136 typedef Reference
<XTextContent
> text_content_ref_t
;
137 typedef list
<text_content_ref_t
> contents_t
;
138 typedef back_insert_iterator
<contents_t
> inserter_t
;
139 typedef contents_t::const_iterator const_iterator_t
;
141 inserter_t
getInserter()
142 { return back_insert_iterator
<contents_t
>(m_vTextContents
); };
143 const_iterator_t
getBegin() const
144 { return m_vTextContents
.begin(); };
145 const_iterator_t
getEnd() const
146 { return m_vTextContents
.end(); };
149 contents_t m_vTextContents
;
153 : public unary_function
<Reference
<XTextFrame
>, size_t>
155 size_t operator()(const Reference
<XTextFrame
> xFrame
) const
156 { return sal::static_int_cast
<size_t>(reinterpret_cast<sal_uIntPtr
>(xFrame
.get())); }
159 static bool lcl_TextContentsUnfiltered(const Reference
<XTextContent
>&)
162 static bool lcl_ShapeFilter(const Reference
<XTextContent
>& xTxtContent
)
164 static const OUString
sTextFrameService("com.sun.star.text.TextFrame");
165 static const OUString
sTextGraphicService("com.sun.star.text.TextGraphicObject");
166 static const OUString
sTextEmbeddedService("com.sun.star.text.TextEmbeddedObject");
167 Reference
<XShape
> xShape(xTxtContent
, UNO_QUERY
);
170 Reference
<XServiceInfo
> xServiceInfo(xTxtContent
, UNO_QUERY
);
171 if(xServiceInfo
->supportsService(sTextFrameService
) ||
172 xServiceInfo
->supportsService(sTextGraphicService
) ||
173 xServiceInfo
->supportsService(sTextEmbeddedService
) )
181 typedef bool (*filter_t
)(const Reference
<XTextContent
>&);
183 const Reference
<XEnumerationAccess
> xEnumAccess
,
184 const filter_t
& rFilter
)
185 : m_xEnumAccess(xEnumAccess
)
191 const TextContentSet
* GetPageBoundContents() const
192 { return &m_vPageBounds
; };
193 const TextContentSet
* GetFrameBoundContents(const Reference
<XTextFrame
>& rParentFrame
) const
195 framebound_map_t::const_iterator it
= m_vFrameBoundsOf
.find(rParentFrame
);
196 if(it
== m_vFrameBoundsOf
.end())
198 return &(it
->second
);
200 Reference
<XEnumeration
> createEnumeration() const
202 if(!m_xEnumAccess
.is())
203 return Reference
<XEnumeration
>();
204 return m_xEnumAccess
->createEnumeration();
208 typedef boost::unordered_map
<
209 Reference
<XTextFrame
>,
211 FrameRefHash
> framebound_map_t
;
212 TextContentSet m_vPageBounds
;
213 framebound_map_t m_vFrameBoundsOf
;
214 const Reference
<XEnumerationAccess
> m_xEnumAccess
;
215 void Fill(const filter_t
& rFilter
);
218 class FieldParamExporter
221 FieldParamExporter(SvXMLExport
* const pExport
, Reference
<XNameContainer
> xFieldParams
)
223 , m_xFieldParams(xFieldParams
)
228 SvXMLExport
* const m_pExport
;
229 const Reference
<XNameContainer
> m_xFieldParams
;
231 void ExportParameter(const OUString
& sKey
, const OUString
& sValue
);
240 BoundFrameSets(const Reference
<XInterface
> xModel
);
241 const BoundFrames
* GetTexts() const
242 { return m_pTexts
.get(); };
243 const BoundFrames
* GetGraphics() const
244 { return m_pGraphics
.get(); };
245 const BoundFrames
* GetEmbeddeds() const
246 { return m_pEmbeddeds
.get(); };
247 const BoundFrames
* GetShapes() const
248 { return m_pShapes
.get(); };
250 SAL_WNODEPRECATED_DECLARATIONS_PUSH
251 auto_ptr
<BoundFrames
> m_pTexts
;
252 auto_ptr
<BoundFrames
> m_pGraphics
;
253 auto_ptr
<BoundFrames
> m_pEmbeddeds
;
254 auto_ptr
<BoundFrames
> m_pShapes
;
255 SAL_WNODEPRECATED_DECLARATIONS_POP
260 static int txtparae_bContainsIllegalCharacters
= sal_False
;
263 // The following map shows which property values are required:
265 // property auto style pass export
266 // --------------------------------------------------------
267 // ParaStyleName if style exists always
268 // ParaConditionalStyleName if style exists always
269 // NumberingRules if style exists always
270 // TextSection always always
271 // ParaChapterNumberingLevel never always
272 // NumberingIsNumber never always
274 // The conclusion is that for auto styles the first three properties
275 // should be queried using a multi property set if, and only if, an
276 // auto style needs to be exported. TextSection should be queried by
277 // an individual call to getPropertyvalue, because this seems to be
278 // less expensive than querying the first three properties if they aren't
281 // For the export pass all properties can be queried using a multi property
284 static const sal_Char
* aParagraphPropertyNamesAuto
[] =
287 "ParaConditionalStyleName",
292 enum eParagraphPropertyNamesEnumAuto
294 NUMBERING_RULES_AUTO
= 0,
295 PARA_CONDITIONAL_STYLE_NAME_AUTO
= 1,
296 PARA_STYLE_NAME_AUTO
= 2
299 static const sal_Char
* aParagraphPropertyNames
[] =
302 "NumberingStyleName",
304 "ParaConditionalStyleName",
310 enum eParagraphPropertyNamesEnum
312 NUMBERING_IS_NUMBER
= 0,
313 PARA_NUMBERING_STYLENAME
= 1,
314 PARA_OUTLINE_LEVEL
=2,
315 PARA_CONDITIONAL_STYLE_NAME
= 3,
320 void BoundFrames::Fill(const filter_t
& rFilter
)
322 if(!m_xEnumAccess
.is())
324 const Reference
< XEnumeration
> xEnum
= m_xEnumAccess
->createEnumeration();
327 const OUString
our_sAnchorType("AnchorType");
328 const OUString
our_sAnchorFrame("AnchorFrame");
329 while(xEnum
->hasMoreElements())
331 Reference
<XPropertySet
> xPropSet(xEnum
->nextElement(), UNO_QUERY
);
332 Reference
<XTextContent
> xTextContent(xPropSet
, UNO_QUERY
);
333 if(!xPropSet
.is() || !xTextContent
.is())
335 TextContentAnchorType eAnchor
;
336 xPropSet
->getPropertyValue(our_sAnchorType
) >>= eAnchor
;
337 if(TextContentAnchorType_AT_PAGE
!= eAnchor
&& TextContentAnchorType_AT_FRAME
!= eAnchor
)
339 if(!rFilter(xTextContent
))
342 TextContentSet::inserter_t pInserter
= m_vPageBounds
.getInserter();
343 if(TextContentAnchorType_AT_FRAME
== eAnchor
)
345 Reference
<XTextFrame
> xAnchorTxtFrame(
346 xPropSet
->getPropertyValue(our_sAnchorFrame
),
348 pInserter
= m_vFrameBoundsOf
[xAnchorTxtFrame
].getInserter();
350 *pInserter
++ = xTextContent
;
354 BoundFrameSets::BoundFrameSets(const Reference
<XInterface
> xModel
)
355 : m_pTexts(new BoundFrames())
356 , m_pGraphics(new BoundFrames())
357 , m_pEmbeddeds(new BoundFrames())
358 , m_pShapes(new BoundFrames())
360 const Reference
<XTextFramesSupplier
> xTFS(xModel
, UNO_QUERY
);
361 const Reference
<XTextGraphicObjectsSupplier
> xGOS(xModel
, UNO_QUERY
);
362 const Reference
<XTextEmbeddedObjectsSupplier
> xEOS(xModel
, UNO_QUERY
);
363 const Reference
<XDrawPageSupplier
> xDPS(xModel
, UNO_QUERY
);
365 m_pTexts
= auto_ptr
<BoundFrames
>(new BoundFrames(
366 Reference
<XEnumerationAccess
>(xTFS
->getTextFrames(), UNO_QUERY
),
367 &lcl_TextContentsUnfiltered
));
369 m_pGraphics
= auto_ptr
<BoundFrames
>(new BoundFrames(
370 Reference
<XEnumerationAccess
>(xGOS
->getGraphicObjects(), UNO_QUERY
),
371 &lcl_TextContentsUnfiltered
));
373 m_pEmbeddeds
= auto_ptr
<BoundFrames
>(new BoundFrames(
374 Reference
<XEnumerationAccess
>(xEOS
->getEmbeddedObjects(), UNO_QUERY
),
375 &lcl_TextContentsUnfiltered
));
377 m_pShapes
= auto_ptr
<BoundFrames
>(new BoundFrames(
378 Reference
<XEnumerationAccess
>(xDPS
->getDrawPage(), UNO_QUERY
),
382 void FieldParamExporter::Export()
384 const Type aStringType
= ::getCppuType((OUString
*)0);
385 const Type aBoolType
= ::getCppuType((sal_Bool
*)0);
386 const Type aSeqType
= ::getCppuType((Sequence
<OUString
>*)0);
387 const Type aIntType
= ::getCppuType((sal_Int32
*)0);
388 Sequence
<OUString
> vParameters(m_xFieldParams
->getElementNames());
389 for(const OUString
* pCurrent
=::comphelper::stl_begin(vParameters
); pCurrent
!=::comphelper::stl_end(vParameters
); ++pCurrent
)
391 const Any aValue
= m_xFieldParams
->getByName(*pCurrent
);
392 const Type aValueType
= aValue
.getValueType();
393 if(aValueType
== aStringType
)
397 ExportParameter(*pCurrent
,sValue
);
399 if ( pCurrent
->equalsAscii( ODF_OLE_PARAM
) )
401 // Save the OLE object
402 Reference
< embed::XStorage
> xTargetStg
= m_pExport
->GetTargetStorage();
403 Reference
< embed::XStorage
> xDstStg
= xTargetStg
->openStorageElement(
404 OUString("OLELinks"), embed::ElementModes::WRITE
);
406 if ( !xDstStg
->hasByName( sValue
) ) {
407 Reference
< XStorageBasedDocument
> xStgDoc (
408 m_pExport
->GetModel( ), UNO_QUERY
);
409 Reference
< embed::XStorage
> xDocStg
= xStgDoc
->getDocumentStorage();
410 Reference
< embed::XStorage
> xOleStg
= xDocStg
->openStorageElement(
411 OUString("OLELinks"), embed::ElementModes::READ
);
413 xOleStg
->copyElementTo( sValue
, xDstStg
, sValue
);
414 Reference
< embed::XTransactedObject
> xTransact( xDstStg
, UNO_QUERY
);
415 if ( xTransact
.is( ) )
416 xTransact
->commit( );
420 else if(aValueType
== aBoolType
)
422 sal_Bool bValue
= false;
424 ExportParameter(*pCurrent
, (bValue
? OUString("true" ) : OUString("false")) );
426 else if(aValueType
== aSeqType
)
428 Sequence
<OUString
> vValue
;
430 for(OUString
* pSeqCurrent
= ::comphelper::stl_begin(vValue
); pSeqCurrent
!= ::comphelper::stl_end(vValue
); ++pSeqCurrent
)
432 ExportParameter(*pCurrent
, *pSeqCurrent
);
435 else if(aValueType
== aIntType
)
437 sal_Int32 nValue
= 0;
439 ExportParameter(*pCurrent
, OUStringBuffer().append(nValue
).makeStringAndClear());
444 void FieldParamExporter::ExportParameter(const OUString
& sKey
, const OUString
& sValue
)
446 m_pExport
->AddAttribute(XML_NAMESPACE_FIELD
, XML_NAME
, sKey
);
447 m_pExport
->AddAttribute(XML_NAMESPACE_FIELD
, XML_VALUE
, sValue
);
448 m_pExport
->StartElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
449 m_pExport
->EndElement(XML_NAMESPACE_FIELD
, XML_PARAM
, sal_False
);
452 void XMLTextParagraphExport::Add( sal_uInt16 nFamily
,
453 const Reference
< XPropertySet
> & rPropSet
,
454 const XMLPropertyState
** ppAddStates
, bool bDontSeek
)
456 UniReference
< SvXMLExportPropertyMapper
> xPropMapper
;
459 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
460 xPropMapper
= GetParaPropMapper();
462 case XML_STYLE_FAMILY_TEXT_TEXT
:
463 xPropMapper
= GetTextPropMapper();
465 case XML_STYLE_FAMILY_TEXT_FRAME
:
466 xPropMapper
= GetAutoFramePropMapper();
468 case XML_STYLE_FAMILY_TEXT_SECTION
:
469 xPropMapper
= GetSectionPropMapper();
471 case XML_STYLE_FAMILY_TEXT_RUBY
:
472 xPropMapper
= GetRubyPropMapper();
475 DBG_ASSERT( xPropMapper
.is(), "There is the property mapper?" );
477 vector
< XMLPropertyState
> xPropStates
=
478 xPropMapper
->Filter( rPropSet
);
482 while( *ppAddStates
)
484 xPropStates
.push_back( **ppAddStates
);
489 if( !xPropStates
.empty() )
491 Reference
< XPropertySetInfo
> xPropSetInfo(rPropSet
->getPropertySetInfo());
492 OUString sParent
, sCondParent
;
493 sal_uInt16 nIgnoreProps
= 0;
496 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
497 if( xPropSetInfo
->hasPropertyByName( sParaStyleName
) )
499 rPropSet
->getPropertyValue( sParaStyleName
) >>= sParent
;
501 if( xPropSetInfo
->hasPropertyByName( sParaConditionalStyleName
) )
503 rPropSet
->getPropertyValue( sParaConditionalStyleName
) >>= sCondParent
;
505 if( xPropSetInfo
->hasPropertyByName( sNumberingRules
) )
507 Reference
< XIndexReplace
> xNumRule(rPropSet
->getPropertyValue( sNumberingRules
), uno::UNO_QUERY
);
508 if( xNumRule
.is() && xNumRule
->getCount() )
510 Reference
< XNamed
> xNamed( xNumRule
, UNO_QUERY
);
513 sName
= xNamed
->getName();
514 sal_Bool bAdd
= sName
.isEmpty();
517 Reference
< XPropertySet
> xNumPropSet( xNumRule
,
519 const OUString
sIsAutomatic( "IsAutomatic" );
520 if( xNumPropSet
.is() &&
521 xNumPropSet
->getPropertySetInfo()
522 ->hasPropertyByName( sIsAutomatic
) )
524 bAdd
= *(sal_Bool
*)xNumPropSet
->getPropertyValue( sIsAutomatic
).getValue();
525 // Check on outline style (#i73361#)
526 const OUString
sNumberingIsOutline( "NumberingIsOutline" );
528 xNumPropSet
->getPropertySetInfo()
529 ->hasPropertyByName( sNumberingIsOutline
) )
531 bAdd
= !(*(sal_Bool
*)xNumPropSet
->getPropertyValue( sNumberingIsOutline
).getValue());
540 pListAutoPool
->Add( xNumRule
);
544 case XML_STYLE_FAMILY_TEXT_TEXT
:
546 // Get parent and remove hyperlinks (they aren't of interest)
547 UniReference
< XMLPropertySetMapper
> xPM(xPropMapper
->getPropertySetMapper());
548 for( ::std::vector
< XMLPropertyState
>::iterator
i(xPropStates
.begin());
549 nIgnoreProps
< 2 && i
!= xPropStates
.end(); )
551 if( i
->mnIndex
== -1 )
557 switch( xPM
->GetEntryContextId(i
->mnIndex
) )
559 case CTF_CHAR_STYLE_NAME
:
560 case CTF_HYPERLINK_URL
:
563 i
= xPropStates
.erase( i
);
572 case XML_STYLE_FAMILY_TEXT_FRAME
:
573 if( xPropSetInfo
->hasPropertyByName( sFrameStyleName
) )
575 rPropSet
->getPropertyValue( sFrameStyleName
) >>= sParent
;
578 case XML_STYLE_FAMILY_TEXT_SECTION
:
579 case XML_STYLE_FAMILY_TEXT_RUBY
:
580 ; // section styles have no parents
583 if( (xPropStates
.size() - nIgnoreProps
) > 0 )
585 GetAutoStylePool().Add( nFamily
, sParent
, xPropStates
, bDontSeek
);
586 if( !sCondParent
.isEmpty() && sParent
!= sCondParent
)
587 GetAutoStylePool().Add( nFamily
, sCondParent
, xPropStates
);
592 static bool lcl_validPropState( const XMLPropertyState
& rState
)
594 return rState
.mnIndex
!= -1;
597 void XMLTextParagraphExport::Add( sal_uInt16 nFamily
,
598 MultiPropertySetHelper
& rPropSetHelper
,
599 const Reference
< XPropertySet
> & rPropSet
,
600 const XMLPropertyState
** ppAddStates
)
602 UniReference
< SvXMLExportPropertyMapper
> xPropMapper
;
605 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
606 xPropMapper
= GetParaPropMapper();
609 DBG_ASSERT( xPropMapper
.is(), "There is the property mapper?" );
611 vector
< XMLPropertyState
> xPropStates(xPropMapper
->Filter( rPropSet
));
614 while( *ppAddStates
)
616 xPropStates
.push_back( **ppAddStates
);
621 if( rPropSetHelper
.hasProperty( NUMBERING_RULES_AUTO
) )
623 Reference
< XIndexReplace
> xNumRule(rPropSetHelper
.getValue( NUMBERING_RULES_AUTO
,
624 rPropSet
, sal_True
), uno::UNO_QUERY
);
625 if( xNumRule
.is() && xNumRule
->getCount() )
627 Reference
< XNamed
> xNamed( xNumRule
, UNO_QUERY
);
630 sName
= xNamed
->getName();
631 sal_Bool bAdd
= sName
.isEmpty();
634 Reference
< XPropertySet
> xNumPropSet( xNumRule
,
636 const OUString
sIsAutomatic( "IsAutomatic" );
637 if( xNumPropSet
.is() &&
638 xNumPropSet
->getPropertySetInfo()
639 ->hasPropertyByName( sIsAutomatic
) )
641 bAdd
= *(sal_Bool
*)xNumPropSet
->getPropertyValue( sIsAutomatic
).getValue();
642 // Check on outline style (#i73361#)
643 const OUString
sNumberingIsOutline( "NumberingIsOutline" );
645 xNumPropSet
->getPropertySetInfo()
646 ->hasPropertyByName( sNumberingIsOutline
) )
648 bAdd
= !(*(sal_Bool
*)xNumPropSet
->getPropertyValue( sNumberingIsOutline
).getValue());
657 pListAutoPool
->Add( xNumRule
);
661 if( !xPropStates
.empty() )
663 OUString sParent
, sCondParent
;
666 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
667 if( rPropSetHelper
.hasProperty( PARA_STYLE_NAME_AUTO
) )
669 rPropSetHelper
.getValue( PARA_STYLE_NAME_AUTO
, rPropSet
,
670 sal_True
) >>= sParent
;
672 if( rPropSetHelper
.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO
) )
674 rPropSetHelper
.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO
,
675 rPropSet
, sal_True
) >>= sCondParent
;
681 if( find_if( xPropStates
.begin(), xPropStates
.end(), lcl_validPropState
) != xPropStates
.end() )
683 GetAutoStylePool().Add( nFamily
, sParent
, xPropStates
);
684 if( !sCondParent
.isEmpty() && sParent
!= sCondParent
)
685 GetAutoStylePool().Add( nFamily
, sCondParent
, xPropStates
);
690 OUString
XMLTextParagraphExport::Find(
692 const Reference
< XPropertySet
> & rPropSet
,
693 const OUString
& rParent
,
694 const XMLPropertyState
** ppAddStates
) const
696 OUString
sName( rParent
);
697 UniReference
< SvXMLExportPropertyMapper
> xPropMapper
;
700 case XML_STYLE_FAMILY_TEXT_PARAGRAPH
:
701 xPropMapper
= GetParaPropMapper();
703 case XML_STYLE_FAMILY_TEXT_FRAME
:
704 xPropMapper
= GetAutoFramePropMapper();
706 case XML_STYLE_FAMILY_TEXT_SECTION
:
707 xPropMapper
= GetSectionPropMapper();
709 case XML_STYLE_FAMILY_TEXT_RUBY
:
710 xPropMapper
= GetRubyPropMapper();
713 DBG_ASSERT( xPropMapper
.is(), "There is the property mapper?" );
714 if( !xPropMapper
.is() )
716 vector
< XMLPropertyState
> xPropStates(xPropMapper
->Filter( rPropSet
));
719 while( *ppAddStates
)
721 xPropStates
.push_back( **ppAddStates
);
725 if( find_if( xPropStates
.begin(), xPropStates
.end(), lcl_validPropState
) != xPropStates
.end() )
726 sName
= GetAutoStylePool().Find( nFamily
, sName
, xPropStates
);
731 OUString
XMLTextParagraphExport::FindTextStyleAndHyperlink(
732 const Reference
< XPropertySet
> & rPropSet
,
733 sal_Bool
& rbHyperlink
,
734 sal_Bool
& rbHasCharStyle
,
735 sal_Bool
& rbHasAutoStyle
,
736 const XMLPropertyState
** ppAddStates
) const
738 UniReference
< SvXMLExportPropertyMapper
> xPropMapper(GetTextPropMapper());
739 vector
< XMLPropertyState
> xPropStates(xPropMapper
->Filter( rPropSet
));
741 // Get parent and remove hyperlinks (they aren't of interest)
743 rbHyperlink
= rbHasCharStyle
= rbHasAutoStyle
= sal_False
;
744 sal_uInt16 nIgnoreProps
= 0;
745 UniReference
< XMLPropertySetMapper
> xPM(xPropMapper
->getPropertySetMapper());
746 ::std::vector
< XMLPropertyState
>::iterator aFirstDel
= xPropStates
.end();
747 ::std::vector
< XMLPropertyState
>::iterator aSecondDel
= xPropStates
.end();
749 for( ::std::vector
< XMLPropertyState
>::iterator
750 i
= xPropStates
.begin();
751 nIgnoreProps
< 2 && i
!= xPropStates
.end();
754 if( i
->mnIndex
== -1 )
757 switch( xPM
->GetEntryContextId(i
->mnIndex
) )
759 case CTF_CHAR_STYLE_NAME
:
760 i
->maValue
>>= sName
;
762 rbHasCharStyle
= !sName
.isEmpty();
769 case CTF_HYPERLINK_URL
:
770 rbHyperlink
= sal_True
;
782 while( *ppAddStates
)
784 xPropStates
.push_back( **ppAddStates
);
788 if( (xPropStates
.size() - nIgnoreProps
) > 0L )
790 // erase the character style, otherwise the autostyle cannot be found!
791 // erase the hyperlink, otherwise the autostyle cannot be found!
794 // If two elements of a vector have to be deleted,
795 // we should delete the second one first.
797 xPropStates
.erase( aSecondDel
);
798 xPropStates
.erase( aFirstDel
);
800 OUString sParent
; // AutoStyles should not have parents!
801 sName
= GetAutoStylePool().Find( XML_STYLE_FAMILY_TEXT_TEXT
, sParent
, xPropStates
);
802 DBG_ASSERT( !sName
.isEmpty(), "AutoStyle could not be found" );
803 rbHasAutoStyle
= sal_True
;
809 // adjustments to support lists independent from list style
810 void XMLTextParagraphExport::exportListChange(
811 const XMLTextNumRuleInfo
& rPrevInfo
,
812 const XMLTextNumRuleInfo
& rNextInfo
)
815 if ( rPrevInfo
.GetLevel() > 0 )
817 sal_Int16 nListLevelsToBeClosed
= 0;
818 if ( !rNextInfo
.BelongsToSameList( rPrevInfo
) ||
819 rNextInfo
.GetLevel() <= 0 )
821 // close complete previous list
822 nListLevelsToBeClosed
= rPrevInfo
.GetLevel();
824 else if ( rPrevInfo
.GetLevel() > rNextInfo
.GetLevel() )
826 // close corresponding sub lists
827 DBG_ASSERT( rNextInfo
.GetLevel() > 0,
828 "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
829 nListLevelsToBeClosed
= rPrevInfo
.GetLevel() - rNextInfo
.GetLevel();
832 if ( nListLevelsToBeClosed
> 0 &&
834 pListElements
->size() >= sal::static_int_cast
< sal_uInt32
>( 2 * nListLevelsToBeClosed
) )
837 for(size_t j
= 0; j
< 2; ++j
)
839 OUString
aElem(pListElements
->back());
840 pListElements
->pop_back();
841 GetExport().EndElement(aElem
, sal_True
);
844 // remove closed list from list stack
845 mpTextListsHelper
->PopListFromStack();
847 --nListLevelsToBeClosed
;
848 } while ( nListLevelsToBeClosed
> 0 );
852 const bool bExportODF
=
853 ( GetExport().getExportFlags() & EXPORT_OASIS
) != 0;
854 const SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion
=
855 GetExport().getDefaultVersion();
858 if ( rNextInfo
.GetLevel() > 0 )
860 bool bRootListToBeStarted
= false;
861 sal_Int16 nListLevelsToBeOpened
= 0;
862 if ( !rPrevInfo
.BelongsToSameList( rNextInfo
) ||
863 rPrevInfo
.GetLevel() <= 0 )
866 bRootListToBeStarted
= true;
867 nListLevelsToBeOpened
= rNextInfo
.GetLevel();
869 else if ( rNextInfo
.GetLevel() > rPrevInfo
.GetLevel() )
871 // open corresponding sub lists
872 DBG_ASSERT( rPrevInfo
.GetLevel() > 0,
873 "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." );
874 nListLevelsToBeOpened
= rNextInfo
.GetLevel() - rPrevInfo
.GetLevel();
877 if ( nListLevelsToBeOpened
> 0 )
879 const OUString
sListStyleName( rNextInfo
.GetNumRulesName() );
880 // Currently only the text documents support <ListId>.
881 // Thus, for other document types <sListId> is empty.
882 const OUString
sListId( rNextInfo
.GetListId() );
883 bool bExportListStyle( true );
884 bool bRestartNumberingAtContinuedList( false );
885 sal_Int32
nRestartValueForContinuedList( -1 );
886 bool bContinueingPreviousSubList
= !bRootListToBeStarted
&&
887 rNextInfo
.IsContinueingPreviousSubTree();
889 GetExport().CheckAttrList();
891 if ( bRootListToBeStarted
)
893 if ( !mpTextListsHelper
->IsListProcessed( sListId
) )
896 eODFDefaultVersion
>= SvtSaveOptions::ODFVER_012
&&
899 /* Property text:id at element <text:list> has to be
900 replaced by property xml:id (#i92221#)
902 GetExport().AddAttribute( XML_NAMESPACE_XML
,
906 mpTextListsHelper
->KeepListAsProcessed( sListId
,
912 const OUString
sNewListId(
913 mpTextListsHelper
->GenerateNewListId() );
915 eODFDefaultVersion
>= SvtSaveOptions::ODFVER_012
&&
918 /* Property text:id at element <text:list> has to be
919 replaced by property xml:id (#i92221#)
921 GetExport().AddAttribute( XML_NAMESPACE_XML
,
926 const OUString sContinueListId
=
927 mpTextListsHelper
->GetLastContinuingListId( sListId
);
928 // store that list with list id <sNewListId> is last list,
929 // which has continued list with list id <sListId>
930 mpTextListsHelper
->StoreLastContinuingList( sListId
,
932 if ( sListStyleName
==
933 mpTextListsHelper
->GetListStyleOfLastProcessedList() &&
934 // Inconsistent behavior regarding lists (#i92811#)
936 mpTextListsHelper
->GetLastProcessedListId() &&
937 !rNextInfo
.IsRestart() )
939 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
940 XML_CONTINUE_NUMBERING
,
946 eODFDefaultVersion
>= SvtSaveOptions::ODFVER_012
&&
949 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
954 if ( rNextInfo
.IsRestart() &&
955 ( nListLevelsToBeOpened
!= 1 ||
956 !rNextInfo
.HasStartValue() ) )
958 bRestartNumberingAtContinuedList
= true;
959 nRestartValueForContinuedList
=
960 rNextInfo
.GetListLevelStartValue();
964 mpTextListsHelper
->KeepListAsProcessed( sNewListId
,
969 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
970 GetExport().EncodeStyleName( sListStyleName
) );
971 bExportListStyle
= false;
973 bRootListToBeStarted
= false;
975 else if ( bExportListStyle
&&
976 !mpTextListsHelper
->EqualsToTopListStyleOnStack( sListStyleName
) )
978 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
979 GetExport().EncodeStyleName( sListStyleName
) );
980 bExportListStyle
= false;
986 // rhbz#746174: also export list restart for non root list
987 if (rNextInfo
.IsRestart() && !rNextInfo
.HasStartValue())
989 bRestartNumberingAtContinuedList
= true;
990 nRestartValueForContinuedList
=
991 rNextInfo
.GetListLevelStartValue();
995 if ( bContinueingPreviousSubList
)
997 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
998 XML_CONTINUE_NUMBERING
, XML_TRUE
);
999 bContinueingPreviousSubList
= false;
1002 enum XMLTokenEnum eLName
= XML_LIST
;
1004 OUString
aElem(GetExport().GetNamespaceMap().GetQNameByKey(
1006 GetXMLToken(eLName
) ) );
1007 GetExport().IgnorableWhitespace();
1008 GetExport().StartElement(aElem
, sal_False
);
1011 pListElements
= new std::vector
<OUString
>;
1012 pListElements
->push_back(aElem
);
1014 mpTextListsHelper
->PushListOnStack( sListId
,
1017 // <text:list-header> or <text:list-item>
1018 GetExport().CheckAttrList();
1020 /* Export start value at correct list item (#i97309#) */
1021 if ( nListLevelsToBeOpened
== 1 )
1023 if ( rNextInfo
.HasStartValue() )
1025 OUStringBuffer aBuffer
;
1026 aBuffer
.append( (sal_Int32
)rNextInfo
.GetStartValue() );
1027 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_START_VALUE
,
1028 aBuffer
.makeStringAndClear() );
1030 else if (bRestartNumberingAtContinuedList
)
1032 OUStringBuffer aBuffer
;
1033 aBuffer
.append( nRestartValueForContinuedList
);
1034 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
1036 aBuffer
.makeStringAndClear() );
1037 bRestartNumberingAtContinuedList
= false;
1041 eLName
= ( rNextInfo
.IsNumbered() || nListLevelsToBeOpened
> 1 )
1044 aElem
= OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1046 GetXMLToken(eLName
) ) );
1047 GetExport().IgnorableWhitespace();
1048 GetExport().StartElement(aElem
, sal_False
);
1049 pListElements
->push_back(aElem
);
1051 // export of <text:number> element for last opened <text:list-item>, if requested
1052 if ( GetExport().exportTextNumberElement() &&
1053 eLName
== XML_LIST_ITEM
&& nListLevelsToBeOpened
== 1 && // last iteration --> last opened <text:list-item>
1054 !rNextInfo
.ListLabelString().isEmpty() )
1056 const OUString aTextNumberElem
=
1057 OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1059 GetXMLToken(XML_NUMBER
) ) );
1060 GetExport().IgnorableWhitespace();
1061 GetExport().StartElement( aTextNumberElem
, sal_False
);
1062 GetExport().Characters( rNextInfo
.ListLabelString() );
1063 GetExport().EndElement( aTextNumberElem
, sal_True
);
1065 --nListLevelsToBeOpened
;
1066 } while ( nListLevelsToBeOpened
> 0 );
1070 if ( rNextInfo
.GetLevel() > 0 &&
1071 rNextInfo
.IsNumbered() &&
1072 rPrevInfo
.BelongsToSameList( rNextInfo
) &&
1073 rPrevInfo
.GetLevel() >= rNextInfo
.GetLevel() )
1075 // close previous list-item
1076 DBG_ASSERT( pListElements
&& pListElements
->size() >= 2,
1077 "SwXMLExport::ExportListChange: list elements missing" );
1079 GetExport().EndElement(pListElements
->back(), sal_True
);
1080 pListElements
->pop_back();
1082 // Only for sub lists (#i103745#)
1083 if ( rNextInfo
.IsRestart() && !rNextInfo
.HasStartValue() &&
1084 rNextInfo
.GetLevel() != 1 )
1086 // start new sub list respectively list on same list level
1087 GetExport().EndElement(pListElements
->back(), sal_True
);
1088 GetExport().IgnorableWhitespace();
1089 GetExport().StartElement(pListElements
->back(), sal_False
);
1092 // open new list-item
1093 GetExport().CheckAttrList();
1094 if( rNextInfo
.HasStartValue() )
1096 OUStringBuffer aBuffer
;
1097 aBuffer
.append( (sal_Int32
)rNextInfo
.GetStartValue() );
1098 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_START_VALUE
,
1099 aBuffer
.makeStringAndClear() );
1101 // Handle restart without start value on list level 1 (#i103745#)
1102 else if ( rNextInfo
.IsRestart() && /*!rNextInfo.HasStartValue() &&*/
1103 rNextInfo
.GetLevel() == 1 )
1105 OUStringBuffer aBuffer
;
1106 aBuffer
.append( (sal_Int32
)rNextInfo
.GetListLevelStartValue() );
1107 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_START_VALUE
,
1108 aBuffer
.makeStringAndClear() );
1110 if ( ( GetExport().getExportFlags() & EXPORT_OASIS
) != 0 &&
1111 GetExport().getDefaultVersion() >= SvtSaveOptions::ODFVER_012
)
1113 const OUString
sListStyleName( rNextInfo
.GetNumRulesName() );
1114 if ( !mpTextListsHelper
->EqualsToTopListStyleOnStack( sListStyleName
) )
1116 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
1118 GetExport().EncodeStyleName( sListStyleName
) );
1121 OUString
aElem( GetExport().GetNamespaceMap().GetQNameByKey(
1123 GetXMLToken(XML_LIST_ITEM
) ) );
1124 GetExport().IgnorableWhitespace();
1125 GetExport().StartElement(aElem
, sal_False
);
1126 pListElements
->push_back(aElem
);
1128 // export of <text:number> element for <text:list-item>, if requested
1129 if ( GetExport().exportTextNumberElement() &&
1130 !rNextInfo
.ListLabelString().isEmpty() )
1132 const OUString aTextNumberElem
=
1133 OUString( GetExport().GetNamespaceMap().GetQNameByKey(
1135 GetXMLToken(XML_NUMBER
) ) );
1136 GetExport().IgnorableWhitespace();
1137 GetExport().StartElement( aTextNumberElem
, sal_False
);
1138 GetExport().Characters( rNextInfo
.ListLabelString() );
1139 GetExport().EndElement( aTextNumberElem
, sal_True
);
1144 struct XMLTextParagraphExport::Impl
1146 typedef ::std::map
<Reference
<XFormField
>, sal_Int32
> FieldMarkMap_t
;
1147 FieldMarkMap_t m_FieldMarkMap
;
1150 sal_Int32
AddFieldMarkStart(Reference
<XFormField
> const& i_xFieldMark
)
1152 assert(m_FieldMarkMap
.find(i_xFieldMark
) == m_FieldMarkMap
.end());
1153 sal_Int32
const ret(m_FieldMarkMap
.size());
1154 m_FieldMarkMap
.insert(::std::make_pair(i_xFieldMark
, ret
));
1157 sal_Int32
GetFieldMarkIndex(Reference
<XFormField
> const& i_xFieldMark
)
1159 FieldMarkMap_t::const_iterator
const it(
1160 m_FieldMarkMap
.find(i_xFieldMark
));
1161 // rely on SwXFieldmark::CreateXFieldmark returning the same instance
1162 // because the Reference in m_FieldMarkMap will keep it alive
1163 assert(it
!= m_FieldMarkMap
.end());
1168 XMLTextParagraphExport::XMLTextParagraphExport(
1170 SvXMLAutoStylePoolP
& rASP
1172 XMLStyleExport( rExp
, OUString(), &rASP
),
1174 rAutoStylePool( rASP
),
1175 pBoundFrameSets(new BoundFrameSets(GetExport().GetModel())),
1178 pListAutoPool( new XMLTextListAutoStylePool( this->GetExport() ) ),
1179 pSectionExport( NULL
),
1180 pIndexMarkExport( NULL
),
1181 pRedlineExport( NULL
),
1182 pHeadingStyles( NULL
),
1183 bProgress( sal_False
),
1184 bBlock( sal_False
),
1185 bOpenRuby( sal_False
),
1186 mpTextListsHelper( 0 ),
1187 maTextListsHelperStack(),
1188 sActualSize("ActualSize"),
1189 // Implement Title/Description Elements UI (#i73249#)
1191 sDescription("Description"),
1192 sAnchorCharStyleName("AnchorCharStyleName"),
1193 sAnchorPageNo("AnchorPageNo"),
1194 sAnchorType("AnchorType"),
1195 sBeginNotice("BeginNotice"),
1196 sBookmark("Bookmark"),
1197 sCategory("Category"),
1198 sChainNextName("ChainNextName"),
1199 sCharStyleName("CharStyleName"),
1200 sCharStyleNames("CharStyleNames"),
1201 sContourPolyPolygon("ContourPolyPolygon"),
1202 sDocumentIndex("DocumentIndex"),
1203 sDocumentIndexMark("DocumentIndexMark"),
1204 sEndNotice("EndNotice"),
1205 sFootnote("Footnote"),
1206 sFootnoteCounting("FootnoteCounting"),
1208 sFrameHeightAbsolute("FrameHeightAbsolute"),
1209 sFrameHeightPercent("FrameHeightPercent"),
1210 sFrameStyleName("FrameStyleName"),
1211 sFrameWidthAbsolute("FrameWidthAbsolute"),
1212 sFrameWidthPercent("FrameWidthPercent"),
1213 sGraphicFilter("GraphicFilter"),
1214 sGraphicRotation("GraphicRotation"),
1215 sGraphicURL("GraphicURL"),
1216 sReplacementGraphicURL("ReplacementGraphicURL"),
1218 sHoriOrient("HoriOrient"),
1219 sHoriOrientPosition("HoriOrientPosition"),
1220 sHyperLinkName("HyperLinkName"),
1221 sHyperLinkTarget("HyperLinkTarget"),
1222 sHyperLinkURL("HyperLinkURL"),
1223 sIsAutomaticContour("IsAutomaticContour"),
1224 sIsCollapsed("IsCollapsed"),
1225 sIsPixelContour("IsPixelContour"),
1226 sIsStart("IsStart"),
1227 sIsSyncHeightToWidth("IsSyncHeightToWidth"),
1228 sIsSyncWidthToHeight("IsSyncWidthToHeight"),
1229 sNumberingRules("NumberingRules"),
1230 sNumberingType("NumberingType"),
1231 sPageDescName("PageDescName"),
1232 sPageStyleName("PageStyleName"),
1233 sParaChapterNumberingLevel("ParaChapterNumberingLevel"),
1234 sParaConditionalStyleName("ParaConditionalStyleName"),
1235 sParagraphService("com.sun.star.text.Paragraph"),
1236 sParaStyleName("ParaStyleName"),
1237 sPositionEndOfDoc("PositionEndOfDoc"),
1239 sRedline("Redline"),
1240 sReferenceId("ReferenceId"),
1241 sReferenceMark("ReferenceMark"),
1242 sRelativeHeight("RelativeHeight"),
1243 sRelativeWidth("RelativeWidth"),
1245 sRubyAdjust("RubyAdjust"),
1246 sRubyCharStyleName("RubyCharStyleName"),
1247 sRubyText("RubyText"),
1248 sServerMap("ServerMap"),
1249 sShapeService("com.sun.star.drawing.Shape"),
1250 sSizeType("SizeType"),
1251 sSoftPageBreak( "SoftPageBreak" ),
1252 sStartAt("StartAt"),
1254 sTableService("com.sun.star.text.TextTable"),
1256 sTextContentService("com.sun.star.text.TextContent"),
1257 sTextEmbeddedService("com.sun.star.text.TextEmbeddedObject"),
1258 sTextEndnoteService("com.sun.star.text.Endnote"),
1259 sTextField("TextField"),
1260 sTextFieldService("com.sun.star.text.TextField"),
1261 sTextFrameService("com.sun.star.text.TextFrame"),
1262 sTextGraphicService("com.sun.star.text.TextGraphicObject"),
1263 sTextPortionType("TextPortionType"),
1264 sTextSection("TextSection"),
1265 sUnvisitedCharStyleName("UnvisitedCharStyleName"),
1266 sVertOrient("VertOrient"),
1267 sVertOrientPosition("VertOrientPosition"),
1268 sVisitedCharStyleName("VisitedCharStyleName"),
1270 sWidthType( "WidthType" ),
1271 sTextFieldStart( "TextFieldStart" ),
1272 sTextFieldEnd( "TextFieldEnd" ),
1273 sTextFieldStartEnd( "TextFieldStartEnd" ),
1274 aCharStyleNamesPropInfoCache( sCharStyleNames
)
1276 UniReference
< XMLPropertySetMapper
> xPropMapper(new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA
, true ));
1277 xParaPropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1280 OUString
sFamily( GetXMLToken(XML_PARAGRAPH
) );
1281 OUString
aPrefix(static_cast<sal_Unicode
>('P'));
1282 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, sFamily
,
1283 xParaPropMapper
, aPrefix
);
1285 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT
, true );
1286 xTextPropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1288 sFamily
= OUString( GetXMLToken(XML_TEXT
) );
1289 aPrefix
= OUString(static_cast<sal_Unicode
>('T'));
1290 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_TEXT
, sFamily
,
1291 xTextPropMapper
, aPrefix
);
1293 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_AUTO_FRAME
, true );
1294 xAutoFramePropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1296 sFamily
= OUString( XML_STYLE_FAMILY_SD_GRAPHICS_NAME
);
1297 aPrefix
= OUString( "fr" );
1298 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_FRAME
, sFamily
,
1299 xAutoFramePropMapper
, aPrefix
);
1301 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION
, true );
1302 xSectionPropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1304 sFamily
= OUString( GetXMLToken( XML_SECTION
) );
1305 aPrefix
= OUString( "Sect" );
1306 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_SECTION
, sFamily
,
1307 xSectionPropMapper
, aPrefix
);
1309 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY
, true );
1310 xRubyPropMapper
= new SvXMLExportPropertyMapper( xPropMapper
);
1311 sFamily
= OUString( GetXMLToken( XML_RUBY
) );
1312 aPrefix
= OUString( "Ru" );
1313 rAutoStylePool
.AddFamily( XML_STYLE_FAMILY_TEXT_RUBY
, sFamily
,
1314 xRubyPropMapper
, aPrefix
);
1316 xPropMapper
= new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME
, true );
1317 xFramePropMapper
= new XMLTextExportPropertySetMapper( xPropMapper
,
1320 pSectionExport
= new XMLSectionExport( rExp
, *this );
1321 pIndexMarkExport
= new XMLIndexMarkExport( rExp
);
1323 if( ! IsBlockMode() &&
1324 Reference
<XRedlinesSupplier
>( GetExport().GetModel(), UNO_QUERY
).is())
1325 pRedlineExport
= new XMLRedlineExport( rExp
);
1327 // The text field helper needs a pre-constructed XMLPropertyState
1328 // to export the combined characters field. We construct that
1329 // here, because we need the text property mapper to do it.
1331 // construct Any value, then find index
1332 sal_Int32 nIndex
= xTextPropMapper
->getPropertySetMapper()->FindEntryIndex(
1333 "", XML_NAMESPACE_STYLE
,
1334 GetXMLToken(XML_TEXT_COMBINE
));
1335 pFieldExport
= new XMLTextFieldExport( rExp
, new XMLPropertyState( nIndex
, uno::makeAny(sal_True
) ) );
1336 PushNewTextListsHelper();
1339 XMLTextParagraphExport::~XMLTextParagraphExport()
1341 delete pHeadingStyles
;
1342 delete pRedlineExport
;
1343 delete pIndexMarkExport
;
1344 delete pSectionExport
;
1345 delete pFieldExport
;
1346 delete pListElements
;
1347 delete pListAutoPool
;
1349 txtparae_bContainsIllegalCharacters
= sal_False
;
1351 PopTextListsHelper();
1352 DBG_ASSERT( maTextListsHelperStack
.empty(),
1353 "misusage of text lists helper stack - it is not empty. Serious defect - please inform OD" );
1356 SvXMLExportPropertyMapper
*XMLTextParagraphExport::CreateShapeExtPropMapper(
1357 SvXMLExport
& rExport
)
1359 UniReference
< XMLPropertySetMapper
> xPropMapper
=
1360 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE
, true );
1361 return new XMLTextExportPropertySetMapper( xPropMapper
, rExport
);
1364 SvXMLExportPropertyMapper
*XMLTextParagraphExport::CreateCharExtPropMapper(
1365 SvXMLExport
& rExport
)
1367 XMLPropertySetMapper
*pPropMapper
=
1368 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT
, true );
1369 return new XMLTextExportPropertySetMapper( pPropMapper
, rExport
);
1372 SvXMLExportPropertyMapper
*XMLTextParagraphExport::CreateParaExtPropMapper(
1373 SvXMLExport
& rExport
)
1375 XMLPropertySetMapper
*pPropMapper
=
1376 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA
, true );
1377 return new XMLTextExportPropertySetMapper( pPropMapper
, rExport
);
1380 SvXMLExportPropertyMapper
*XMLTextParagraphExport::CreateParaDefaultExtPropMapper(
1381 SvXMLExport
& rExport
)
1383 XMLPropertySetMapper
*pPropMapper
=
1384 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT_ADDITIONAL_DEFAULTS
, true );
1385 return new XMLTextExportPropertySetMapper( pPropMapper
, rExport
);
1388 void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles
,
1389 sal_Bool bIsProgress
)
1391 const TextContentSet
* const pTexts
= pBoundFrameSets
->GetTexts()->GetPageBoundContents();
1392 const TextContentSet
* const pGraphics
= pBoundFrameSets
->GetGraphics()->GetPageBoundContents();
1393 const TextContentSet
* const pEmbeddeds
= pBoundFrameSets
->GetEmbeddeds()->GetPageBoundContents();
1394 const TextContentSet
* const pShapes
= pBoundFrameSets
->GetShapes()->GetPageBoundContents();
1395 for(TextContentSet::const_iterator_t it
= pTexts
->getBegin();
1396 it
!= pTexts
->getEnd();
1398 exportTextFrame(*it
, bAutoStyles
, bIsProgress
, sal_True
);
1399 for(TextContentSet::const_iterator_t it
= pGraphics
->getBegin();
1400 it
!= pGraphics
->getEnd();
1402 exportTextGraphic(*it
, bAutoStyles
);
1403 for(TextContentSet::const_iterator_t it
= pEmbeddeds
->getBegin();
1404 it
!= pEmbeddeds
->getEnd();
1406 exportTextEmbedded(*it
, bAutoStyles
);
1407 for(TextContentSet::const_iterator_t it
= pShapes
->getBegin();
1408 it
!= pShapes
->getEnd();
1410 exportShape(*it
, bAutoStyles
);
1413 void XMLTextParagraphExport::exportFrameFrames(
1414 sal_Bool bAutoStyles
,
1415 sal_Bool bIsProgress
,
1416 const Reference
< XTextFrame
> *pParentTxtFrame
)
1418 const TextContentSet
* const pTexts
= pBoundFrameSets
->GetTexts()->GetFrameBoundContents(*pParentTxtFrame
);
1420 for(TextContentSet::const_iterator_t it
= pTexts
->getBegin();
1421 it
!= pTexts
->getEnd();
1423 exportTextFrame(*it
, bAutoStyles
, bIsProgress
, sal_True
);
1424 const TextContentSet
* const pGraphics
= pBoundFrameSets
->GetGraphics()->GetFrameBoundContents(*pParentTxtFrame
);
1426 for(TextContentSet::const_iterator_t it
= pGraphics
->getBegin();
1427 it
!= pGraphics
->getEnd();
1429 exportTextGraphic(*it
, bAutoStyles
);
1430 const TextContentSet
* const pEmbeddeds
= pBoundFrameSets
->GetEmbeddeds()->GetFrameBoundContents(*pParentTxtFrame
);
1432 for(TextContentSet::const_iterator_t it
= pEmbeddeds
->getBegin();
1433 it
!= pEmbeddeds
->getEnd();
1435 exportTextEmbedded(*it
, bAutoStyles
);
1436 const TextContentSet
* const pShapes
= pBoundFrameSets
->GetShapes()->GetFrameBoundContents(*pParentTxtFrame
);
1438 for(TextContentSet::const_iterator_t it
= pShapes
->getBegin();
1439 it
!= pShapes
->getEnd();
1441 exportShape(*it
, bAutoStyles
);
1444 // bookmarks, reference marks (and TOC marks) are the same except for the
1445 // element names. We use the same method for export and it an array with
1446 // the proper element names
1447 static const enum XMLTokenEnum lcl_XmlReferenceElements
[] = {
1448 XML_REFERENCE_MARK
, XML_REFERENCE_MARK_START
, XML_REFERENCE_MARK_END
};
1449 static const enum XMLTokenEnum lcl_XmlBookmarkElements
[] = {
1450 XML_BOOKMARK
, XML_BOOKMARK_START
, XML_BOOKMARK_END
};
1452 // This function replaces the text portion iteration during auto style
1454 bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgress
)
1456 GetExport().GetShapeExport(); // make sure the graphics styles family is added
1458 const sal_Bool bAutoStyles
= sal_True
;
1459 const sal_Bool bExportContent
= sal_False
;
1461 // Export AutoStyles:
1462 Reference
< XAutoStylesSupplier
> xAutoStylesSupp( GetExport().GetModel(), UNO_QUERY
);
1463 if ( xAutoStylesSupp
.is() )
1465 Reference
< XAutoStyles
> xAutoStyleFamilies
= xAutoStylesSupp
->getAutoStyles();
1469 for ( int i
= 0; i
< 3; ++i
)
1473 sName
= OUString( "CharacterStyles" );
1474 nFamily
= XML_STYLE_FAMILY_TEXT_TEXT
;
1478 sName
= OUString( "RubyStyles" );
1479 nFamily
= XML_STYLE_FAMILY_TEXT_RUBY
;
1483 sName
= OUString( "ParagraphStyles" );
1484 nFamily
= XML_STYLE_FAMILY_TEXT_PARAGRAPH
;
1487 Any aAny
= xAutoStyleFamilies
->getByName( sName
);
1488 Reference
< XAutoStyleFamily
> xAutoStyles
= *(Reference
<XAutoStyleFamily
>*)aAny
.getValue();
1489 Reference
< XEnumeration
> xAutoStylesEnum( xAutoStyles
->createEnumeration() );
1491 while ( xAutoStylesEnum
->hasMoreElements() )
1493 aAny
= xAutoStylesEnum
->nextElement();
1494 Reference
< XAutoStyle
> xAutoStyle
= *(Reference
<XAutoStyle
>*)aAny
.getValue();
1495 Reference
< XPropertySet
> xPSet( xAutoStyle
, uno::UNO_QUERY
);
1496 Add( nFamily
, xPSet
, 0, true );
1501 // Export Field AutoStyles:
1502 Reference
< XTextFieldsSupplier
> xTextFieldsSupp( GetExport().GetModel(), UNO_QUERY
);
1503 if ( xTextFieldsSupp
.is() )
1505 Reference
< XEnumerationAccess
> xTextFields
= xTextFieldsSupp
->getTextFields();
1506 Reference
< XEnumeration
> xTextFieldsEnum( xTextFields
->createEnumeration() );
1508 while ( xTextFieldsEnum
->hasMoreElements() )
1510 Any aAny
= xTextFieldsEnum
->nextElement();
1511 Reference
< XTextField
> xTextField
= *(Reference
<XTextField
>*)aAny
.getValue();
1512 exportTextField( xTextField
, bAutoStyles
, bIsProgress
,
1513 !xAutoStylesSupp
.is() );
1516 Reference
< XPropertySet
> xSet( xTextField
, UNO_QUERY
);
1517 Reference
< XText
> xText
;
1518 Any a
= xSet
->getPropertyValue( OUString("TextRange") );
1522 exportText( xText
, sal_True
, bIsProgress
, bExportContent
);
1523 GetExport().GetTextParagraphExport()
1524 ->collectTextAutoStyles( xText
);
1533 // Export text frames:
1534 Reference
<XEnumeration
> xTextFramesEnum
= pBoundFrameSets
->GetTexts()->createEnumeration();
1535 if(xTextFramesEnum
.is())
1536 while(xTextFramesEnum
->hasMoreElements())
1538 Reference
<XTextContent
> xTxtCntnt(xTextFramesEnum
->nextElement(), UNO_QUERY
);
1540 exportTextFrame(xTxtCntnt
, bAutoStyles
, bIsProgress
, bExportContent
, 0);
1543 // Export graphic objects:
1544 Reference
<XEnumeration
> xGraphicsEnum
= pBoundFrameSets
->GetGraphics()->createEnumeration();
1545 if(xGraphicsEnum
.is())
1546 while(xGraphicsEnum
->hasMoreElements())
1548 Reference
<XTextContent
> xTxtCntnt(xGraphicsEnum
->nextElement(), UNO_QUERY
);
1550 exportTextGraphic(xTxtCntnt
, true, 0);
1553 // Export embedded objects:
1554 Reference
<XEnumeration
> xEmbeddedsEnum
= pBoundFrameSets
->GetEmbeddeds()->createEnumeration();
1555 if(xEmbeddedsEnum
.is())
1556 while(xEmbeddedsEnum
->hasMoreElements())
1558 Reference
<XTextContent
> xTxtCntnt(xEmbeddedsEnum
->nextElement(), UNO_QUERY
);
1560 exportTextEmbedded(xTxtCntnt
, true, 0);
1564 Reference
<XEnumeration
> xShapesEnum
= pBoundFrameSets
->GetShapes()->createEnumeration();
1565 if(xShapesEnum
.is())
1566 while(xShapesEnum
->hasMoreElements())
1568 Reference
<XTextContent
> xTxtCntnt(xShapesEnum
->nextElement(), UNO_QUERY
);
1571 Reference
<XServiceInfo
> xServiceInfo(xTxtCntnt
, UNO_QUERY
);
1572 if( xServiceInfo
->supportsService(sShapeService
))
1573 exportShape(xTxtCntnt
, true, 0);
1578 // AutoStyles for sections
1579 Reference
< XTextSectionsSupplier
> xSectionsSupp( GetExport().GetModel(), UNO_QUERY
);
1580 if ( xSectionsSupp
.is() )
1582 Reference
< XIndexAccess
> xSections( xSectionsSupp
->getTextSections(), UNO_QUERY
);
1583 if ( xSections
.is() )
1585 nCount
= xSections
->getCount();
1586 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
1588 Any aAny
= xSections
->getByIndex( i
);
1589 Reference
< XTextSection
> xSection
= *(Reference
<XTextSection
>*)aAny
.getValue();
1590 Reference
< XPropertySet
> xPSet( xSection
, uno::UNO_QUERY
);
1591 Add( XML_STYLE_FAMILY_TEXT_SECTION
, xPSet
);
1596 // AutoStyles for tables (Note: suppress autostyle collection for paragraphs in exportTable)
1597 Reference
< XTextTablesSupplier
> xTablesSupp( GetExport().GetModel(), UNO_QUERY
);
1598 if ( xTablesSupp
.is() )
1600 Reference
< XIndexAccess
> xTables( xTablesSupp
->getTextTables(), UNO_QUERY
);
1603 nCount
= xTables
->getCount();
1604 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
1606 Any aAny
= xTables
->getByIndex( i
);
1607 Reference
< XTextTable
> xTable
= *(Reference
<XTextTable
>*)aAny
.getValue();
1608 Reference
< XTextContent
> xTextContent( xTable
, uno::UNO_QUERY
);
1609 exportTable( xTextContent
, sal_True
, sal_True
);
1614 Reference
< XNumberingRulesSupplier
> xNumberingRulesSupp( GetExport().GetModel(), UNO_QUERY
);
1615 if ( xNumberingRulesSupp
.is() )
1617 Reference
< XIndexAccess
> xNumberingRules
= xNumberingRulesSupp
->getNumberingRules();
1618 nCount
= xNumberingRules
->getCount();
1619 // Custom outline assignment lost after re-importing sxw (#i73361#)
1620 const OUString
sNumberingIsOutline( "NumberingIsOutline" );
1621 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
1623 Reference
< XIndexReplace
> xNumRule( xNumberingRules
->getByIndex( i
), UNO_QUERY
);
1624 if( xNumRule
.is() && xNumRule
->getCount() )
1626 Reference
< XNamed
> xNamed( xNumRule
, UNO_QUERY
);
1629 sName
= xNamed
->getName();
1630 sal_Bool bAdd
= sName
.isEmpty();
1633 Reference
< XPropertySet
> xNumPropSet( xNumRule
,
1635 const OUString
sIsAutomatic( "IsAutomatic" );
1636 if( xNumPropSet
.is() &&
1637 xNumPropSet
->getPropertySetInfo()
1638 ->hasPropertyByName( sIsAutomatic
) )
1640 bAdd
= *(sal_Bool
*)xNumPropSet
->getPropertyValue( sIsAutomatic
).getValue();
1641 // Check on outline style (#i73361#)
1643 xNumPropSet
->getPropertySetInfo()
1644 ->hasPropertyByName( sNumberingIsOutline
) )
1646 bAdd
= !(*(sal_Bool
*)xNumPropSet
->getPropertyValue( sNumberingIsOutline
).getValue());
1655 pListAutoPool
->Add( xNumRule
);
1663 void XMLTextParagraphExport::exportText(
1664 const Reference
< XText
> & rText
,
1665 sal_Bool bAutoStyles
,
1666 sal_Bool bIsProgress
,
1667 sal_Bool bExportParagraph
)
1670 GetExport().GetShapeExport(); // make sure the graphics styles family
1672 Reference
< XEnumerationAccess
> xEA( rText
, UNO_QUERY
);
1673 Reference
< XEnumeration
> xParaEnum(xEA
->createEnumeration());
1674 Reference
< XPropertySet
> xPropertySet( rText
, UNO_QUERY
);
1675 Reference
< XTextSection
> xBaseSection
;
1677 // #97718# footnotes don't supply paragraph enumerations in some cases
1678 // This is always a bug, but at least we don't want to crash.
1679 DBG_ASSERT( xParaEnum
.is(), "We need a paragraph enumeration" );
1680 if( ! xParaEnum
.is() )
1683 sal_Bool bExportLevels
= sal_True
;
1685 if (xPropertySet
.is())
1687 Reference
< XPropertySetInfo
> xInfo ( xPropertySet
->getPropertySetInfo() );
1691 if (xInfo
->hasPropertyByName( sTextSection
))
1693 xPropertySet
->getPropertyValue(sTextSection
) >>= xBaseSection
;
1697 // for applications that use the outliner we need to check if
1698 // the current text object needs the level information exported
1701 // fixme: move string to class member, couldn't do now because
1702 // of no incompatible build
1703 OUString sHasLevels( "HasLevels" );
1704 if (xInfo->hasPropertyByName( sHasLevels ) )
1706 xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels;
1713 // #96530# Export redlines at start & end of XText before & after
1714 // exporting the text content enumeration
1715 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1716 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_True
);
1717 exportTextContentEnumeration( xParaEnum
, bAutoStyles
, xBaseSection
,
1718 bIsProgress
, bExportParagraph
, 0, bExportLevels
);
1719 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1720 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_False
);
1723 void XMLTextParagraphExport::exportText(
1724 const Reference
< XText
> & rText
,
1725 const Reference
< XTextSection
> & rBaseSection
,
1726 sal_Bool bAutoStyles
,
1727 sal_Bool bIsProgress
,
1728 sal_Bool bExportParagraph
)
1731 GetExport().GetShapeExport(); // make sure the graphics styles family
1733 Reference
< XEnumerationAccess
> xEA( rText
, UNO_QUERY
);
1734 Reference
< XEnumeration
> xParaEnum(xEA
->createEnumeration());
1736 // #98165# don't continue without a paragraph enumeration
1737 if( ! xParaEnum
.is() )
1740 // #96530# Export redlines at start & end of XText before & after
1741 // exporting the text content enumeration
1742 Reference
<XPropertySet
> xPropertySet
;
1743 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1745 xPropertySet
.set(rText
, uno::UNO_QUERY
);
1746 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_True
);
1748 exportTextContentEnumeration( xParaEnum
, bAutoStyles
, rBaseSection
,
1749 bIsProgress
, bExportParagraph
);
1750 if( !bAutoStyles
&& (pRedlineExport
!= NULL
) )
1751 pRedlineExport
->ExportStartOrEndRedline( xPropertySet
, sal_False
);
1754 sal_Bool
XMLTextParagraphExport::exportTextContentEnumeration(
1755 const Reference
< XEnumeration
> & rContEnum
,
1756 sal_Bool bAutoStyles
,
1757 const Reference
< XTextSection
> & rBaseSection
,
1758 sal_Bool bIsProgress
,
1759 sal_Bool bExportParagraph
,
1760 const Reference
< XPropertySet
> *pRangePropSet
,
1761 sal_Bool bExportLevels
)
1763 DBG_ASSERT( rContEnum
.is(), "No enumeration to export!" );
1764 sal_Bool bHasMoreElements
= rContEnum
->hasMoreElements();
1765 if( !bHasMoreElements
)
1768 XMLTextNumRuleInfo aPrevNumInfo
;
1769 XMLTextNumRuleInfo aNextNumInfo
;
1771 sal_Bool bHasContent
= sal_False
;
1772 Reference
<XTextSection
> xCurrentTextSection(rBaseSection
);
1774 MultiPropertySetHelper
aPropSetHelper(
1775 bAutoStyles
? aParagraphPropertyNamesAuto
:
1776 aParagraphPropertyNames
);
1778 sal_Bool bHoldElement
= sal_False
;
1779 Reference
< XTextContent
> xTxtCntnt
;
1780 while( bHoldElement
|| bHasMoreElements
)
1784 bHoldElement
= sal_False
;
1788 xTxtCntnt
.set(rContEnum
->nextElement(), uno::UNO_QUERY
);
1790 aPropSetHelper
.resetValues();
1794 Reference
<XServiceInfo
> xServiceInfo( xTxtCntnt
, UNO_QUERY
);
1795 if( xServiceInfo
->supportsService( sParagraphService
) )
1801 exportListAndSectionChange( xCurrentTextSection
, xTxtCntnt
,
1802 aPrevNumInfo
, aNextNumInfo
,
1807 /* Pass list auto style pool to <XMLTextNumRuleInfo> instance
1808 Pass info about request to export <text:number> element
1809 to <XMLTextNumRuleInfo> instance (#i69627#)
1811 aNextNumInfo
.Set( xTxtCntnt
,
1812 GetExport().writeOutlineStyleAsNormalListStyle(),
1813 GetListAutoStylePool(),
1814 GetExport().exportTextNumberElement() );
1816 exportListAndSectionChange( xCurrentTextSection
, aPropSetHelper
,
1817 TEXT_SECTION
, xTxtCntnt
,
1818 aPrevNumInfo
, aNextNumInfo
,
1823 // if we found a mute section: skip all section content
1824 if (pSectionExport
->IsMuteSection(xCurrentTextSection
))
1826 // Make sure headings are exported anyway.
1828 pSectionExport
->ExportMasterDocHeadingDummies();
1830 while (rContEnum
->hasMoreElements() &&
1831 pSectionExport
->IsInSection( xCurrentTextSection
,
1832 xTxtCntnt
, sal_True
))
1834 xTxtCntnt
.set(rContEnum
->nextElement(), uno::UNO_QUERY
);
1835 aPropSetHelper
.resetValues();
1836 aNextNumInfo
.Reset();
1838 // the first non-mute element still needs to be processed
1840 ! pSectionExport
->IsInSection( xCurrentTextSection
,
1841 xTxtCntnt
, sal_False
);
1844 exportParagraph( xTxtCntnt
, bAutoStyles
, bIsProgress
,
1845 bExportParagraph
, aPropSetHelper
);
1846 bHasContent
= sal_True
;
1848 else if( xServiceInfo
->supportsService( sTableService
) )
1852 aNextNumInfo
.Reset();
1855 exportListAndSectionChange( xCurrentTextSection
, xTxtCntnt
,
1856 aPrevNumInfo
, aNextNumInfo
,
1859 if (! pSectionExport
->IsMuteSection(xCurrentTextSection
))
1861 // export start + end redlines (for wholly redlined tables)
1862 if ((! bAutoStyles
) && (NULL
!= pRedlineExport
))
1863 pRedlineExport
->ExportStartOrEndRedline(xTxtCntnt
, sal_True
);
1865 exportTable( xTxtCntnt
, bAutoStyles
, bIsProgress
);
1867 if ((! bAutoStyles
) && (NULL
!= pRedlineExport
))
1868 pRedlineExport
->ExportStartOrEndRedline(xTxtCntnt
, sal_False
);
1870 else if( !bAutoStyles
)
1872 // Make sure headings are exported anyway.
1873 pSectionExport
->ExportMasterDocHeadingDummies();
1876 bHasContent
= sal_True
;
1878 else if( xServiceInfo
->supportsService( sTextFrameService
) )
1880 exportTextFrame( xTxtCntnt
, bAutoStyles
, bIsProgress
, sal_True
, pRangePropSet
);
1882 else if( xServiceInfo
->supportsService( sTextGraphicService
) )
1884 exportTextGraphic( xTxtCntnt
, bAutoStyles
, pRangePropSet
);
1886 else if( xServiceInfo
->supportsService( sTextEmbeddedService
) )
1888 exportTextEmbedded( xTxtCntnt
, bAutoStyles
, pRangePropSet
);
1890 else if( xServiceInfo
->supportsService( sShapeService
) )
1892 exportShape( xTxtCntnt
, bAutoStyles
, pRangePropSet
);
1896 DBG_ASSERT( !xTxtCntnt
.is(), "unknown text content" );
1901 aPrevNumInfo
= aNextNumInfo
;
1904 bHasMoreElements
= rContEnum
->hasMoreElements();
1907 if( bExportLevels
&& bHasContent
&& !bAutoStyles
)
1909 aNextNumInfo
.Reset();
1911 // close open lists and sections; no new styles
1912 exportListAndSectionChange( xCurrentTextSection
, rBaseSection
,
1913 aPrevNumInfo
, aNextNumInfo
,
1920 void XMLTextParagraphExport::exportParagraph(
1921 const Reference
< XTextContent
> & rTextContent
,
1922 sal_Bool bAutoStyles
, sal_Bool bIsProgress
, sal_Bool bExportParagraph
,
1923 MultiPropertySetHelper
& rPropSetHelper
)
1925 sal_Int16 nOutlineLevel
= -1;
1929 ProgressBarHelper
*pProgress
= GetExport().GetProgressBarHelper();
1930 pProgress
->SetValue( pProgress
->GetValue()+1 );
1933 // get property set or multi property set and initialize helper
1934 Reference
<XMultiPropertySet
> xMultiPropSet( rTextContent
, UNO_QUERY
);
1935 Reference
<XPropertySet
> xPropSet( rTextContent
, UNO_QUERY
);
1937 // check for supported properties
1938 if( !rPropSetHelper
.checkedProperties() )
1939 rPropSetHelper
.hasProperties( xPropSet
->getPropertySetInfo() );
1941 // if( xMultiPropSet.is() )
1942 // rPropSetHelper.getValues( xMultiPropSet );
1944 // rPropSetHelper.getValues( xPropSet );
1946 if( bExportParagraph
)
1950 Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, rPropSetHelper
, xPropSet
);
1954 // xml:id for RDF metadata
1955 GetExport().AddAttributeXmlId(rTextContent
);
1956 GetExport().AddAttributesRDFa(rTextContent
);
1959 if( rPropSetHelper
.hasProperty( PARA_STYLE_NAME
) )
1961 if( xMultiPropSet
.is() )
1962 rPropSetHelper
.getValue( PARA_STYLE_NAME
,
1963 xMultiPropSet
) >>= sStyle
;
1965 rPropSetHelper
.getValue( PARA_STYLE_NAME
,
1966 xPropSet
) >>= sStyle
;
1969 Reference
< XInterface
> xRef( rTextContent
, UNO_QUERY
);
1972 const OUString
& rIdentifier
= GetExport().getInterfaceToIdentifierMapper().getIdentifier( xRef
);
1973 if( !rIdentifier
.isEmpty() )
1975 // FIXME: this is just temporary until EditEngine
1976 // paragraphs implement XMetadatable.
1977 // then that must be used and not the mapper, because
1978 // when both can be used we get two xml:id!
1979 uno::Reference
<rdf::XMetadatable
> const xMeta(xRef
,
1981 OSL_ENSURE(!xMeta
.is(), "paragraph that implements "
1982 "XMetadatable used in interfaceToIdentifierMapper?");
1983 GetExport().AddAttributeIdLegacy(XML_NAMESPACE_TEXT
,
1988 OUString
sAutoStyle( sStyle
);
1989 sAutoStyle
= Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, xPropSet
, sStyle
);
1990 if( !sAutoStyle
.isEmpty() )
1991 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
1992 GetExport().EncodeStyleName( sAutoStyle
) );
1994 if( rPropSetHelper
.hasProperty( PARA_CONDITIONAL_STYLE_NAME
) )
1996 OUString sCondStyle
;
1997 if( xMultiPropSet
.is() )
1998 rPropSetHelper
.getValue( PARA_CONDITIONAL_STYLE_NAME
,
1999 xMultiPropSet
) >>= sCondStyle
;
2001 rPropSetHelper
.getValue( PARA_CONDITIONAL_STYLE_NAME
,
2002 xPropSet
) >>= sCondStyle
;
2003 if( sCondStyle
!= sStyle
)
2005 sCondStyle
= Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH
, xPropSet
,
2007 if( !sCondStyle
.isEmpty() )
2008 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
2009 XML_COND_STYLE_NAME
,
2010 GetExport().EncodeStyleName( sCondStyle
) );
2014 if( rPropSetHelper
.hasProperty( PARA_OUTLINE_LEVEL
) )
2016 if( xMultiPropSet
.is() )
2017 rPropSetHelper
.getValue( PARA_OUTLINE_LEVEL
,
2018 xMultiPropSet
) >>= nOutlineLevel
;
2020 rPropSetHelper
.getValue( PARA_OUTLINE_LEVEL
,
2021 xPropSet
) >>= nOutlineLevel
;
2023 if( 0 < nOutlineLevel
)
2025 OUStringBuffer sTmp
;
2026 sTmp
.append( sal_Int32( nOutlineLevel
) );
2027 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
2029 sTmp
.makeStringAndClear() );
2031 if( rPropSetHelper
.hasProperty( NUMBERING_IS_NUMBER
) )
2033 bool bIsNumber
= false;
2034 if( xMultiPropSet
.is() )
2035 rPropSetHelper
.getValue(
2036 NUMBERING_IS_NUMBER
, xMultiPropSet
) >>= bIsNumber
;
2038 rPropSetHelper
.getValue(
2039 NUMBERING_IS_NUMBER
, xPropSet
) >>= bIsNumber
;
2041 OUString sListStyleName
;
2042 if( xMultiPropSet
.is() )
2043 rPropSetHelper
.getValue(
2044 PARA_NUMBERING_STYLENAME
, xMultiPropSet
) >>= sListStyleName
;
2046 rPropSetHelper
.getValue(
2047 PARA_NUMBERING_STYLENAME
, xPropSet
) >>= sListStyleName
;
2051 bool bAssignedtoOutlineStyle
= false;
2053 Reference
< XChapterNumberingSupplier
> xCNSupplier( GetExport().GetModel(), UNO_QUERY
);
2055 OUString sOutlineName
;
2056 if (xCNSupplier
.is())
2058 Reference
< XIndexReplace
> xNumRule ( xCNSupplier
->getChapterNumberingRules() );
2059 DBG_ASSERT( xNumRule
.is(), "no chapter numbering rules" );
2063 Reference
< XPropertySet
> xNumRulePropSet( xNumRule
, UNO_QUERY
);
2064 xNumRulePropSet
->getPropertyValue(
2065 OUString("Name") ) >>= sOutlineName
;
2066 bAssignedtoOutlineStyle
= ( sListStyleName
== sOutlineName
);
2071 if( ! bIsNumber
&& bAssignedtoOutlineStyle
)
2072 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
2078 OUString
sParaIsNumberingRestart("ParaIsNumberingRestart");
2079 bool bIsRestartNumbering
= false;
2081 Reference
< XPropertySetInfo
>
2082 xPropSetInfo(xMultiPropSet
.is() ?
2083 xMultiPropSet
->getPropertySetInfo():
2084 xPropSet
->getPropertySetInfo());
2087 hasPropertyByName(sParaIsNumberingRestart
))
2089 xPropSet
->getPropertyValue(sParaIsNumberingRestart
)
2090 >>= bIsRestartNumbering
;
2093 if (bIsRestartNumbering
)
2095 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
2096 XML_RESTART_NUMBERING
,
2099 OUString
sNumberingStartValue("NumberingStartValue");
2103 hasPropertyByName(sNumberingStartValue
))
2105 sal_Int32 nStartValue
= 0;
2107 xPropSet
->getPropertyValue(sNumberingStartValue
)
2110 OUStringBuffer sTmpStartValue
;
2112 sTmpStartValue
.append(nStartValue
);
2115 AddAttribute(XML_NAMESPACE_TEXT
,
2118 makeStringAndClear());
2127 Reference
< XEnumerationAccess
> xEA( rTextContent
, UNO_QUERY
);
2128 Reference
< XEnumeration
> xTextEnum
;
2129 xTextEnum
= xEA
->createEnumeration();
2130 const sal_Bool bHasPortions
= xTextEnum
.is();
2132 Reference
< XEnumeration
> xContentEnum
;
2133 Reference
< XContentEnumerationAccess
> xCEA( rTextContent
, UNO_QUERY
);
2135 xContentEnum
.set(xCEA
->createContentEnumeration( sTextContentService
));
2136 const sal_Bool bHasContentEnum
= xContentEnum
.is() &&
2137 xContentEnum
->hasMoreElements();
2139 Reference
< XTextSection
> xSection
;
2140 if( bHasContentEnum
)
2142 // For the auto styles, the multi property set helper is only used
2143 // if hard attributes are existing. Therfor, it seems to be a better
2144 // strategy to have the TextSection property separate, because otherwise
2145 // we always retrieve the style names even if they are not required.
2148 if( xPropSet
->getPropertySetInfo()->hasPropertyByName( sTextSection
) )
2150 xSection
.set(xPropSet
->getPropertyValue( sTextSection
), uno::UNO_QUERY
);
2155 if( rPropSetHelper
.hasProperty( TEXT_SECTION
) )
2157 xSection
.set(rPropSetHelper
.getValue( TEXT_SECTION
), uno::UNO_QUERY
);
2164 if( bHasContentEnum
)
2165 exportTextContentEnumeration(
2166 xContentEnum
, bAutoStyles
, xSection
,
2167 bIsProgress
, sal_True
, 0, sal_True
);
2169 exportTextRangeEnumeration( xTextEnum
, bAutoStyles
, bIsProgress
);
2173 sal_Bool bPrevCharIsSpace
= sal_True
;
2174 enum XMLTokenEnum eElem
=
2175 0 < nOutlineLevel
? XML_H
: XML_P
;
2176 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, eElem
,
2177 sal_True
, sal_False
);
2178 if( bHasContentEnum
)
2179 bPrevCharIsSpace
= !exportTextContentEnumeration(
2180 xContentEnum
, bAutoStyles
, xSection
,
2182 exportTextRangeEnumeration( xTextEnum
, bAutoStyles
, bIsProgress
,
2187 void XMLTextParagraphExport::exportTextRangeEnumeration(
2188 const Reference
< XEnumeration
> & rTextEnum
,
2189 sal_Bool bAutoStyles
, sal_Bool bIsProgress
,
2190 sal_Bool bPrvChrIsSpc
)
2192 static const OUString
sMeta("InContentMetadata");
2193 static const OUString
sFieldMarkName("__FieldMark_");
2194 bool bPrevCharIsSpace
= bPrvChrIsSpc
;
2196 /* This is used for exporting to strict OpenDocument 1.2, in which case traditional
2197 * bookmarks are used instead of fieldmarks. */
2198 FieldmarkType openFieldMark
= NONE
;
2200 while( rTextEnum
->hasMoreElements() )
2202 Reference
<XPropertySet
> xPropSet(rTextEnum
->nextElement(), UNO_QUERY
);
2203 Reference
< XTextRange
> xTxtRange(xPropSet
, uno::UNO_QUERY
);
2204 Reference
<XPropertySetInfo
> xPropInfo(xPropSet
->getPropertySetInfo());
2206 if (xPropInfo
->hasPropertyByName(sTextPortionType
))
2209 xPropSet
->getPropertyValue(sTextPortionType
) >>= sType
;
2211 if( sType
.equals(sText
))
2213 exportTextRange( xTxtRange
, bAutoStyles
,
2214 bPrevCharIsSpace
, openFieldMark
);
2216 else if( sType
.equals(sTextField
))
2218 Reference
< ::com::sun::star::text::XFormField
> xFormField
;
2221 xFormField
.set(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2223 catch( const uno::Exception
& )
2225 SAL_WARN("xmloff", "unexpected bookmark exception");
2228 if (!xFormField
.is() || xFormField
->getFieldType() != ODF_COMMENTRANGE
)
2230 exportTextField( xTxtRange
, bAutoStyles
, bIsProgress
);
2231 bPrevCharIsSpace
= false;
2234 else if( sType
.equals( sFrame
) )
2236 Reference
< XEnumeration
> xContentEnum
;
2237 Reference
< XContentEnumerationAccess
> xCEA( xTxtRange
,
2240 xContentEnum
.set(xCEA
->createContentEnumeration(
2241 sTextContentService
));
2242 // frames are never in sections
2243 Reference
<XTextSection
> xSection
;
2244 if( xContentEnum
.is() )
2245 exportTextContentEnumeration( xContentEnum
,
2247 xSection
, bIsProgress
, sal_True
,
2250 bPrevCharIsSpace
= false;
2252 else if (sType
.equals(sFootnote
))
2254 exportTextFootnote(xPropSet
,
2255 xTxtRange
->getString(),
2256 bAutoStyles
, bIsProgress
);
2257 bPrevCharIsSpace
= false;
2259 else if (sType
.equals(sBookmark
))
2261 exportTextMark(xPropSet
,
2263 lcl_XmlBookmarkElements
,
2266 else if (sType
.equals(sReferenceMark
))
2268 exportTextMark(xPropSet
,
2270 lcl_XmlReferenceElements
,
2273 else if (sType
.equals(sDocumentIndexMark
))
2275 pIndexMarkExport
->ExportIndexMark(xPropSet
, bAutoStyles
);
2277 else if (sType
.equals(sRedline
))
2279 if (NULL
!= pRedlineExport
)
2280 pRedlineExport
->ExportChange(xPropSet
, bAutoStyles
);
2282 else if (sType
.equals(sRuby
))
2284 exportRuby(xPropSet
, bAutoStyles
);
2286 else if (sType
.equals(sMeta
))
2288 exportMeta(xPropSet
, bAutoStyles
, bIsProgress
);
2290 else if (sType
.equals(sTextFieldStart
))
2292 Reference
< ::com::sun::star::text::XFormField
> xFormField(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2293 if (xFormField
.is() && xFormField
->getFieldType() == ODF_COMMENTRANGE
)
2295 exportTextField( xTxtRange
, bAutoStyles
, bIsProgress
);
2299 /* As of now, textmarks are a proposed extension to the OpenDocument standard. */
2300 if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012
)
2302 Reference
<XNamed
> xBookmark(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2305 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, xBookmark
->getName());
2307 if (xFormField
.is())
2309 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_TYPE
, xFormField
->getFieldType());
2311 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_START
, sal_False
);
2312 if (xFormField
.is())
2314 FieldParamExporter(&GetExport(), xFormField
->getParameters()).Export();
2316 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK_START
, sal_False
);
2318 /* The OpenDocument standard does not include support for TextMarks for now, so use bookmarks instead. */
2321 if (xFormField
.is())
2324 Reference
< ::com::sun::star::container::XNameAccess
> xParameters(xFormField
->getParameters(), UNO_QUERY
);
2325 if (xParameters
.is() && xParameters
->hasByName("Name"))
2327 const Any aValue
= xParameters
->getByName("Name");
2330 if (sName
.isEmpty())
2331 { // name attribute is mandatory, so have to pull a
2332 // rabbit out of the hat here
2333 sName
= sFieldMarkName
+ OUString::valueOf(
2334 m_pImpl
->AddFieldMarkStart(xFormField
));
2336 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
,
2338 SvXMLElementExport
aElem( GetExport(), !bAutoStyles
,
2339 XML_NAMESPACE_TEXT
, XML_BOOKMARK_START
,
2340 sal_False
, sal_False
);
2341 const OUString sFieldType
= xFormField
->getFieldType();
2342 if (sFieldType
== ODF_FORMTEXT
)
2344 openFieldMark
= TEXT
;
2346 else if (sFieldType
== ODF_FORMCHECKBOX
)
2348 openFieldMark
= CHECK
;
2352 openFieldMark
= NONE
;
2357 else if (sType
.equals(sTextFieldEnd
))
2359 Reference
< ::com::sun::star::text::XFormField
> xFormField(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2360 if (xFormField
.is() && xFormField
->getFieldType() == ODF_COMMENTRANGE
)
2362 Reference
<XNamed
> xBookmark(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2363 const OUString
& rName
= xBookmark
->getName();
2364 if (!rName
.isEmpty())
2365 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
, XML_NAME
, rName
);
2366 SvXMLElementExport
aElem( GetExport(), !bAutoStyles
,
2367 XML_NAMESPACE_OFFICE
, XML_ANNOTATION_END
,
2368 sal_False
, sal_False
);
2372 if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012
)
2374 SvXMLElementExport
aElem( GetExport(), !bAutoStyles
,
2375 XML_NAMESPACE_FIELD
, XML_FIELDMARK_END
,
2376 sal_False
, sal_False
);
2380 if (xFormField
.is())
2383 Reference
< ::com::sun::star::container::XNameAccess
> xParameters(xFormField
->getParameters(), UNO_QUERY
);
2384 if (xParameters
.is() && xParameters
->hasByName("Name"))
2386 const Any aValue
= xParameters
->getByName("Name");
2389 if (sName
.isEmpty())
2390 { // name attribute is mandatory, so have to pull a
2391 // rabbit out of the hat here
2392 sName
= sFieldMarkName
+ OUString::valueOf(
2393 m_pImpl
->GetFieldMarkIndex(xFormField
));
2395 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
,
2397 SvXMLElementExport
aElem( GetExport(), !bAutoStyles
,
2398 XML_NAMESPACE_TEXT
, XML_BOOKMARK_END
,
2399 sal_False
, sal_False
);
2403 else if (sType
.equals(sTextFieldStartEnd
))
2405 if ( GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012
)
2407 Reference
<XNamed
> xBookmark(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2410 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, xBookmark
->getName());
2412 Reference
< ::com::sun::star::text::XFormField
> xFormField(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2413 if (xFormField
.is())
2415 GetExport().AddAttribute(XML_NAMESPACE_FIELD
, XML_TYPE
, xFormField
->getFieldType());
2417 GetExport().StartElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK
, sal_False
);
2418 if (xFormField
.is())
2420 FieldParamExporter(&GetExport(), xFormField
->getParameters()).Export();
2422 GetExport().EndElement(XML_NAMESPACE_FIELD
, XML_FIELDMARK
, sal_False
);
2426 Reference
<XNamed
> xBookmark(xPropSet
->getPropertyValue(sBookmark
), UNO_QUERY
);
2429 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
, xBookmark
->getName());
2430 SvXMLElementExport
aElem( GetExport(), !bAutoStyles
,
2431 XML_NAMESPACE_TEXT
, XML_BOOKMARK
,
2432 sal_False
, sal_False
);
2436 else if (sType
.equals(sSoftPageBreak
))
2438 exportSoftPageBreak(xPropSet
, bAutoStyles
);
2441 OSL_FAIL("unknown text portion type");
2446 Reference
<XServiceInfo
> xServiceInfo( xTxtRange
, UNO_QUERY
);
2447 if( xServiceInfo
->supportsService( sTextFieldService
) )
2449 exportTextField( xTxtRange
, bAutoStyles
, bIsProgress
);
2450 bPrevCharIsSpace
= false;
2454 // no TextPortionType property -> non-Writer app -> text
2455 exportTextRange( xTxtRange
, bAutoStyles
, bPrevCharIsSpace
, openFieldMark
);
2460 // now that there are nested enumerations for meta(-field), this may be valid!
2461 // DBG_ASSERT( !bOpenRuby, "Red Alert: Ruby still open!" );
2464 void XMLTextParagraphExport::exportTable(
2465 const Reference
< XTextContent
> &,
2466 sal_Bool
/*bAutoStyles*/, sal_Bool
/*bIsProgress*/ )
2470 void XMLTextParagraphExport::exportTextField(
2471 const Reference
< XTextRange
> & rTextRange
,
2472 sal_Bool bAutoStyles
, sal_Bool bIsProgress
)
2474 Reference
< XPropertySet
> xPropSet( rTextRange
, UNO_QUERY
);
2475 // non-Writer apps need not support Property TextField, so test first
2476 if (xPropSet
->getPropertySetInfo()->hasPropertyByName( sTextField
))
2478 Reference
< XTextField
> xTxtFld(xPropSet
->getPropertyValue( sTextField
), uno::UNO_QUERY
);
2479 DBG_ASSERT( xTxtFld
.is(), "text field missing" );
2482 exportTextField(xTxtFld
, bAutoStyles
, bIsProgress
, sal_True
);
2486 // write only characters
2487 GetExport().Characters(rTextRange
->getString());
2492 void XMLTextParagraphExport::exportTextField(
2493 const Reference
< XTextField
> & xTextField
,
2494 const sal_Bool bAutoStyles
, const sal_Bool bIsProgress
,
2495 const sal_Bool bRecursive
)
2499 pFieldExport
->ExportFieldAutoStyle( xTextField
, bIsProgress
,
2504 pFieldExport
->ExportField( xTextField
, bIsProgress
);
2508 void XMLTextParagraphExport::exportSoftPageBreak(
2509 const Reference
<XPropertySet
> & ,
2512 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2513 XML_SOFT_PAGE_BREAK
, sal_False
,
2517 void XMLTextParagraphExport::exportTextMark(
2518 const Reference
<XPropertySet
> & rPropSet
,
2519 const OUString
& rProperty
,
2520 const enum XMLTokenEnum pElements
[],
2521 sal_Bool bAutoStyles
)
2523 // mib said: "Hau wech!"
2525 // (Originally, I'd export a span element in case the (book|reference)mark
2526 // was formatted. This actually makes a difference in case some pervert
2527 // sets a point reference mark in the document and, say, formats it bold.
2528 // This basically meaningless formatting will now been thrown away
2529 // (aka cleaned up), since mib said: ... dvo
2534 Reference
<XNamed
> xName(rPropSet
->getPropertyValue(rProperty
), UNO_QUERY
);
2535 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_NAME
,
2538 // start, end, or point-reference?
2540 if( *(sal_Bool
*)rPropSet
->getPropertyValue(sIsCollapsed
).getValue() )
2546 nElement
= *(sal_Bool
*)rPropSet
->getPropertyValue(sIsStart
).getValue() ? 1 : 2;
2549 // bookmark, bookmark-start: xml:id and RDFa for RDF metadata
2550 if( nElement
< 2 ) {
2551 GetExport().AddAttributeXmlId(xName
);
2552 const uno::Reference
<text::XTextContent
> xTextContent(
2553 xName
, uno::UNO_QUERY_THROW
);
2554 GetExport().AddAttributesRDFa(xTextContent
);
2558 DBG_ASSERT(pElements
!= NULL
, "illegal element array");
2559 DBG_ASSERT(nElement
>= 0, "illegal element number");
2560 DBG_ASSERT(nElement
<= 2, "illegal element number");
2561 SvXMLElementExport
aElem(GetExport(),
2562 XML_NAMESPACE_TEXT
, pElements
[nElement
],
2563 sal_False
, sal_False
);
2565 // else: no styles. (see above)
2568 static sal_Bool
lcl_txtpara_isBoundAsChar(
2569 const Reference
< XPropertySet
> & rPropSet
,
2570 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
2572 sal_Bool bIsBoundAsChar
= sal_False
;
2573 OUString
sAnchorType( "AnchorType" );
2574 if( rPropSetInfo
->hasPropertyByName( sAnchorType
) )
2576 TextContentAnchorType eAnchor
;
2577 rPropSet
->getPropertyValue( sAnchorType
) >>= eAnchor
;
2578 bIsBoundAsChar
= TextContentAnchorType_AS_CHARACTER
== eAnchor
;
2581 return bIsBoundAsChar
;
2584 sal_Int32
XMLTextParagraphExport::addTextFrameAttributes(
2585 const Reference
< XPropertySet
>& rPropSet
,
2587 OUString
*pMinHeightValue
,
2588 OUString
*pMinWidthValue
)
2590 sal_Int32 nShapeFeatures
= SEF_DEFAULT
;
2592 // draw:name (#97662#: not for shapes, since those names will be
2593 // treated in the shape export)
2596 Reference
< XNamed
> xNamed( rPropSet
, UNO_QUERY
);
2599 OUString
sName( xNamed
->getName() );
2600 if( !sName
.isEmpty() )
2601 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_NAME
,
2602 xNamed
->getName() );
2606 OUStringBuffer sValue
;
2609 TextContentAnchorType eAnchor
= TextContentAnchorType_AT_PARAGRAPH
;
2610 rPropSet
->getPropertyValue( sAnchorType
) >>= eAnchor
;
2612 XMLAnchorTypePropHdl aAnchorTypeHdl
;
2614 aAnchorTypeHdl
.exportXML( sTmp
, uno::makeAny(eAnchor
),
2615 GetExport().GetMM100UnitConverter() );
2616 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_ANCHOR_TYPE
, sTmp
);
2619 // text:anchor-page-number
2620 if( TextContentAnchorType_AT_PAGE
== eAnchor
)
2622 sal_Int16 nPage
= 0;
2623 rPropSet
->getPropertyValue( sAnchorPageNo
) >>= nPage
;
2624 SAL_WARN_IF(nPage
<= 0, "xmloff",
2625 "ERROR: writing invalid anchor-page-number 0");
2626 ::sax::Converter::convertNumber( sValue
, (sal_Int32
)nPage
);
2627 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_ANCHOR_PAGE_NUMBER
,
2628 sValue
.makeStringAndClear() );
2633 nShapeFeatures
|= SEF_EXPORT_NO_WS
;
2636 // OD 2004-06-01 #i27691# - correction: no export of svg:x, if object
2637 // is anchored as-character.
2639 eAnchor
!= TextContentAnchorType_AS_CHARACTER
)
2642 sal_Int16 nHoriOrient
= HoriOrientation::NONE
;
2643 rPropSet
->getPropertyValue( sHoriOrient
) >>= nHoriOrient
;
2644 if( HoriOrientation::NONE
== nHoriOrient
)
2647 rPropSet
->getPropertyValue( sHoriOrientPosition
) >>= nPos
;
2648 GetExport().GetMM100UnitConverter().convertMeasureToXML(
2650 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_X
,
2651 sValue
.makeStringAndClear() );
2654 else if( TextContentAnchorType_AS_CHARACTER
== eAnchor
)
2655 nShapeFeatures
= (nShapeFeatures
& ~SEF_EXPORT_X
);
2657 if( !bShape
|| TextContentAnchorType_AS_CHARACTER
== eAnchor
)
2660 sal_Int16 nVertOrient
= VertOrientation::NONE
;
2661 rPropSet
->getPropertyValue( sVertOrient
) >>= nVertOrient
;
2662 if( VertOrientation::NONE
== nVertOrient
)
2665 rPropSet
->getPropertyValue( sVertOrientPosition
) >>= nPos
;
2666 GetExport().GetMM100UnitConverter().convertMeasureToXML(
2668 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_Y
,
2669 sValue
.makeStringAndClear() );
2672 nShapeFeatures
= (nShapeFeatures
& ~SEF_EXPORT_Y
);
2676 Reference
< XPropertySetInfo
> xPropSetInfo(rPropSet
->getPropertySetInfo());
2679 sal_Int16 nWidthType
= SizeType::FIX
;
2680 if( xPropSetInfo
->hasPropertyByName( sWidthType
) )
2682 rPropSet
->getPropertyValue( sWidthType
) >>= nWidthType
;
2684 if( xPropSetInfo
->hasPropertyByName( sWidth
) )
2686 sal_Int32 nWidth
= 0;
2687 // VAR size will be written as zero min-size
2688 if( SizeType::VARIABLE
!= nWidthType
)
2690 rPropSet
->getPropertyValue( sWidth
) >>= nWidth
;
2692 GetExport().GetMM100UnitConverter().convertMeasureToXML(sValue
, nWidth
);
2693 if( SizeType::FIX
!= nWidthType
)
2695 assert(pMinWidthValue
);
2698 *pMinWidthValue
= sValue
.makeStringAndClear();
2702 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_WIDTH
,
2703 sValue
.makeStringAndClear() );
2705 sal_Bool bSyncWidth
= sal_False
;
2706 if( xPropSetInfo
->hasPropertyByName( sIsSyncWidthToHeight
) )
2708 bSyncWidth
= *(sal_Bool
*)rPropSet
->getPropertyValue( sIsSyncWidthToHeight
).getValue();
2710 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_WIDTH
,
2713 if( !bSyncWidth
&& xPropSetInfo
->hasPropertyByName( sRelativeWidth
) )
2715 sal_Int16 nRelWidth
= 0;
2716 rPropSet
->getPropertyValue( sRelativeWidth
) >>= nRelWidth
;
2717 DBG_ASSERT( nRelWidth
>= 0 && nRelWidth
<= 254,
2718 "Got illegal relative width from API" );
2721 ::sax::Converter::convertPercent( sValue
, nRelWidth
);
2722 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_WIDTH
,
2723 sValue
.makeStringAndClear() );
2727 // svg:height, fo:min-height or style:rel-height
2728 sal_Int16 nSizeType
= SizeType::FIX
;
2729 if( xPropSetInfo
->hasPropertyByName( sSizeType
) )
2731 rPropSet
->getPropertyValue( sSizeType
) >>= nSizeType
;
2733 sal_Bool bSyncHeight
= sal_False
;
2734 if( xPropSetInfo
->hasPropertyByName( sIsSyncHeightToWidth
) )
2736 bSyncHeight
= *(sal_Bool
*)rPropSet
->getPropertyValue( sIsSyncHeightToWidth
).getValue();
2738 sal_Int16 nRelHeight
= 0;
2739 if( !bSyncHeight
&& xPropSetInfo
->hasPropertyByName( sRelativeHeight
) )
2741 rPropSet
->getPropertyValue( sRelativeHeight
) >>= nRelHeight
;
2743 if( xPropSetInfo
->hasPropertyByName( sHeight
) )
2745 sal_Int32 nHeight
= 0;
2746 if( SizeType::VARIABLE
!= nSizeType
)
2748 rPropSet
->getPropertyValue( sHeight
) >>= nHeight
;
2750 GetExport().GetMM100UnitConverter().convertMeasureToXML( sValue
,
2752 if( SizeType::FIX
!= nSizeType
&& 0==nRelHeight
&& !bSyncHeight
&&
2754 *pMinHeightValue
= sValue
.makeStringAndClear();
2756 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_HEIGHT
,
2757 sValue
.makeStringAndClear() );
2761 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_HEIGHT
,
2762 SizeType::MIN
== nSizeType
? XML_SCALE_MIN
: XML_SCALE
);
2765 else if( nRelHeight
> 0 )
2767 ::sax::Converter::convertPercent( sValue
, nRelHeight
);
2768 if( SizeType::MIN
== nSizeType
)
2770 assert(pMinHeightValue
);
2771 if (pMinHeightValue
)
2773 *pMinHeightValue
= sValue
.makeStringAndClear();
2777 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_HEIGHT
,
2778 sValue
.makeStringAndClear() );
2781 OUString
sZOrder( "ZOrder" );
2782 if( xPropSetInfo
->hasPropertyByName( sZOrder
) )
2784 sal_Int32 nZIndex
= 0;
2785 rPropSet
->getPropertyValue( sZOrder
) >>= nZIndex
;
2788 ::sax::Converter::convertNumber( sValue
, nZIndex
);
2789 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_ZINDEX
,
2790 sValue
.makeStringAndClear() );
2794 return nShapeFeatures
;
2797 void XMLTextParagraphExport::exportAnyTextFrame(
2798 const Reference
< XTextContent
> & rTxtCntnt
,
2800 sal_Bool bAutoStyles
,
2801 sal_Bool bIsProgress
,
2802 sal_Bool bExportContent
,
2803 const Reference
< XPropertySet
> *pRangePropSet
)
2805 Reference
< XPropertySet
> xPropSet( rTxtCntnt
, UNO_QUERY
);
2809 if( FT_EMBEDDED
== eType
)
2810 _collectTextEmbeddedAutoStyles( xPropSet
);
2811 // No text frame style for shapes (#i28745#)
2812 else if ( FT_SHAPE
!= eType
)
2813 Add( XML_STYLE_FAMILY_TEXT_FRAME
, xPropSet
);
2815 if( pRangePropSet
&& lcl_txtpara_isBoundAsChar( xPropSet
,
2816 xPropSet
->getPropertySetInfo() ) )
2817 Add( XML_STYLE_FAMILY_TEXT_TEXT
, *pRangePropSet
);
2823 // frame bound frames
2824 if ( bExportContent
)
2826 Reference
< XTextFrame
> xTxtFrame( rTxtCntnt
, UNO_QUERY
);
2827 Reference
< XText
> xTxt(xTxtFrame
->getText());
2828 exportFrameFrames( sal_True
, bIsProgress
, &xTxtFrame
);
2829 exportText( xTxt
, bAutoStyles
, bIsProgress
, sal_True
);
2835 Reference
< XShape
> xShape( rTxtCntnt
, UNO_QUERY
);
2836 GetExport().GetShapeExport()->collectShapeAutoStyles( xShape
);
2845 Reference
< XPropertySetInfo
> xPropSetInfo(xPropSet
->getPropertySetInfo());
2846 Reference
< XPropertyState
> xPropState( xPropSet
, UNO_QUERY
);
2848 sal_Bool bAddCharStyles
= pRangePropSet
&&
2849 lcl_txtpara_isBoundAsChar( xPropSet
, xPropSetInfo
);
2851 sal_Bool bIsUICharStyle
;
2852 sal_Bool bHasAutoStyle
= sal_False
;
2857 if( bAddCharStyles
)
2858 sStyle
= FindTextStyleAndHyperlink( *pRangePropSet
, bDummy
, bIsUICharStyle
, bHasAutoStyle
);
2860 bIsUICharStyle
= sal_False
;
2862 XMLTextCharStyleNamesElementExport
aCharStylesExport(
2863 GetExport(), bIsUICharStyle
&&
2864 aCharStyleNamesPropInfoCache
.hasProperty(
2865 *pRangePropSet
), bHasAutoStyle
,
2866 *pRangePropSet
, sCharStyleNames
);
2868 if( !sStyle
.isEmpty() )
2869 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
2870 GetExport().EncodeStyleName( sStyle
) );
2872 SvXMLElementExport
aElem( GetExport(), !sStyle
.isEmpty(),
2873 XML_NAMESPACE_TEXT
, XML_SPAN
, sal_False
, sal_False
);
2875 SvXMLElementExport
aElement( GetExport(),
2876 FT_SHAPE
!= eType
&&
2877 addHyperlinkAttributes( xPropSet
,
2878 xPropState
,xPropSetInfo
),
2879 XML_NAMESPACE_DRAW
, XML_A
, sal_False
, sal_False
);
2883 _exportTextFrame( xPropSet
, xPropSetInfo
, bIsProgress
);
2886 _exportTextGraphic( xPropSet
, xPropSetInfo
);
2889 _exportTextEmbedded( xPropSet
, xPropSetInfo
);
2893 Reference
< XShape
> xShape( rTxtCntnt
, UNO_QUERY
);
2894 sal_Int32 nFeatures
=
2895 addTextFrameAttributes( xPropSet
, sal_True
);
2896 GetExport().GetShapeExport()
2897 ->exportShape( xShape
, nFeatures
);
2907 void XMLTextParagraphExport::_exportTextFrame(
2908 const Reference
< XPropertySet
> & rPropSet
,
2909 const Reference
< XPropertySetInfo
> & rPropSetInfo
,
2910 sal_Bool bIsProgress
)
2912 Reference
< XTextFrame
> xTxtFrame( rPropSet
, UNO_QUERY
);
2913 Reference
< XText
> xTxt(xTxtFrame
->getText());
2916 if( rPropSetInfo
->hasPropertyByName( sFrameStyleName
) )
2918 rPropSet
->getPropertyValue( sFrameStyleName
) >>= sStyle
;
2921 OUString
sAutoStyle( sStyle
);
2922 OUString aMinHeightValue
;
2923 OUString sMinWidthValue
;
2924 sAutoStyle
= Find( XML_STYLE_FAMILY_TEXT_FRAME
, rPropSet
, sStyle
);
2925 if( !sAutoStyle
.isEmpty() )
2926 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_STYLE_NAME
,
2927 GetExport().EncodeStyleName( sAutoStyle
) );
2928 addTextFrameAttributes(rPropSet
, false, &aMinHeightValue
, &sMinWidthValue
);
2930 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_DRAW
,
2931 XML_FRAME
, sal_False
, sal_True
);
2933 if( !aMinHeightValue
.isEmpty() )
2934 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_MIN_HEIGHT
,
2937 if (!sMinWidthValue
.isEmpty())
2939 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_MIN_WIDTH
,
2943 // draw:chain-next-name
2944 if( rPropSetInfo
->hasPropertyByName( sChainNextName
) )
2947 if( (rPropSet
->getPropertyValue( sChainNextName
) >>= sNext
) && !sNext
.isEmpty() )
2948 GetExport().AddAttribute( XML_NAMESPACE_DRAW
,
2949 XML_CHAIN_NEXT_NAME
,
2954 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_DRAW
,
2955 XML_TEXT_BOX
, sal_True
, sal_True
);
2957 // frame bound frames
2958 exportFramesBoundToFrame( xTxtFrame
, bIsProgress
);
2960 exportText( xTxt
, sal_False
, bIsProgress
, sal_True
);
2964 Reference
<XEventsSupplier
> xEventsSupp( xTxtFrame
, UNO_QUERY
);
2965 GetExport().GetEventExport().Export(xEventsSupp
);
2968 GetExport().GetImageMapExport().Export( rPropSet
);
2970 // svg:title and svg:desc (#i73249#)
2971 exportTitleAndDescription( rPropSet
, rPropSetInfo
);
2974 void XMLTextParagraphExport::exportContour(
2975 const Reference
< XPropertySet
> & rPropSet
,
2976 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
2978 if( !rPropSetInfo
->hasPropertyByName( sContourPolyPolygon
) )
2981 PointSequenceSequence aSourcePolyPolygon
;
2982 rPropSet
->getPropertyValue( sContourPolyPolygon
) >>= aSourcePolyPolygon
;
2984 if( !aSourcePolyPolygon
.getLength() )
2987 awt::Point
aPoint( 0, 0 );
2988 awt::Size
aSize( 0, 0 );
2989 sal_Int32 nPolygons
= aSourcePolyPolygon
.getLength();
2990 const PointSequence
*pPolygons
= aSourcePolyPolygon
.getConstArray();
2991 while( nPolygons
-- )
2993 sal_Int32 nPoints
= pPolygons
->getLength();
2994 const awt::Point
*pPoints
= pPolygons
->getConstArray();
2997 if( aSize
.Width
< pPoints
->X
)
2998 aSize
.Width
= pPoints
->X
;
2999 if( aSize
.Height
< pPoints
->Y
)
3000 aSize
.Height
= pPoints
->Y
;
3006 sal_Bool bPixel
= sal_False
;
3007 if( rPropSetInfo
->hasPropertyByName( sIsPixelContour
) )
3009 bPixel
= *(sal_Bool
*)rPropSet
->getPropertyValue( sIsPixelContour
).getValue();
3013 OUStringBuffer
aStringBuffer( 10 );
3016 ::sax::Converter::convertMeasurePx(aStringBuffer
, aSize
.Width
);
3020 GetExport().GetMM100UnitConverter().convertMeasureToXML(
3021 aStringBuffer
, aSize
.Width
);
3023 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_WIDTH
,
3024 aStringBuffer
.makeStringAndClear() );
3029 ::sax::Converter::convertMeasurePx(aStringBuffer
, aSize
.Height
);
3033 GetExport().GetMM100UnitConverter().convertMeasureToXML(
3034 aStringBuffer
, aSize
.Height
);
3036 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_HEIGHT
,
3037 aStringBuffer
.makeStringAndClear() );
3040 SdXMLImExViewBox
aViewBox(0, 0, aSize
.Width
, aSize
.Height
);
3041 GetExport().AddAttribute(XML_NAMESPACE_SVG
, XML_VIEWBOX
,
3042 aViewBox
.GetExportString());
3044 sal_Int32
nOuterCnt( aSourcePolyPolygon
.getLength() );
3046 enum XMLTokenEnum eElem
= XML_TOKEN_INVALID
;
3047 if( 1L == nOuterCnt
)
3049 // simple polygon shape, can be written as svg:points sequence
3050 /*const*/ PointSequence
* pSequence
=
3051 (PointSequence
*)aSourcePolyPolygon
.getConstArray();
3053 SdXMLImExPointsElement
aPoints( pSequence
, aViewBox
, aPoint
, aSize
);
3055 // write point array
3056 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_POINTS
,
3057 aPoints
.GetExportString());
3058 eElem
= XML_CONTOUR_POLYGON
;
3062 // polypolygon, needs to be written as a svg:path sequence
3063 /*const*/ PointSequence
* pOuterSequence
=
3064 (PointSequence
*)aSourcePolyPolygon
.getConstArray();
3067 // prepare svx:d element export
3068 SdXMLImExSvgDElement
aSvgDElement( aViewBox
, GetExport() );
3070 for(sal_Int32
a(0L); a
< nOuterCnt
; a
++)
3072 /*const*/ PointSequence
* pSequence
= pOuterSequence
++;
3075 aSvgDElement
.AddPolygon(pSequence
, 0L, aPoint
,
3080 // write point array
3081 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_D
,
3082 aSvgDElement
.GetExportString());
3083 eElem
= XML_CONTOUR_PATH
;
3087 if( rPropSetInfo
->hasPropertyByName( sIsAutomaticContour
) )
3089 sal_Bool bTmp
= *(sal_Bool
*)rPropSet
->getPropertyValue(
3090 sIsAutomaticContour
).getValue();
3091 GetExport().AddAttribute( XML_NAMESPACE_DRAW
,
3092 XML_RECREATE_ON_EDIT
, bTmp
? XML_TRUE
: XML_FALSE
);
3096 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_DRAW
, eElem
,
3097 sal_True
, sal_True
);
3100 void XMLTextParagraphExport::_exportTextGraphic(
3101 const Reference
< XPropertySet
> & rPropSet
,
3102 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
3105 if( rPropSetInfo
->hasPropertyByName( sFrameStyleName
) )
3107 rPropSet
->getPropertyValue( sFrameStyleName
) >>= sStyle
;
3110 OUString
sAutoStyle( sStyle
);
3111 sAutoStyle
= Find( XML_STYLE_FAMILY_TEXT_FRAME
, rPropSet
, sStyle
);
3112 if( !sAutoStyle
.isEmpty() )
3113 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_STYLE_NAME
,
3114 GetExport().EncodeStyleName( sAutoStyle
) );
3115 addTextFrameAttributes( rPropSet
, sal_False
);
3119 rPropSet
->getPropertyValue( sGraphicRotation
) >>= nVal
;
3122 OUStringBuffer
sRet( GetXMLToken(XML_ROTATE
).getLength()+4 );
3123 sRet
.append( GetXMLToken(XML_ROTATE
));
3124 sRet
.append( (sal_Unicode
)'(' );
3125 ::sax::Converter::convertNumber( sRet
, (sal_Int32
)nVal
);
3126 sRet
.append( (sal_Unicode
)')' );
3127 GetExport().AddAttribute( XML_NAMESPACE_SVG
, XML_TRANSFORM
,
3128 sRet
.makeStringAndClear() );
3132 SvXMLElementExport
aElem(GetExport(), XML_NAMESPACE_DRAW
, XML_FRAME
, sal_False
, sal_True
);
3134 // replacement graphic for backwards compatibility, but
3135 // only for SVG currently
3136 OUString sReplacementOrigURL
;
3137 rPropSet
->getPropertyValue( sReplacementGraphicURL
) >>= sReplacementOrigURL
;
3139 if(sReplacementOrigURL
.getLength())
3141 const OUString
sReplacementURL(GetExport().AddEmbeddedGraphicObject( sReplacementOrigURL
));
3143 // If there is no url, then then graphic is empty
3144 if(sReplacementURL
.getLength())
3146 GetExport().AddAttribute(XML_NAMESPACE_XLINK
, XML_HREF
, sReplacementURL
);
3147 GetExport().AddAttribute(XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
3148 GetExport().AddAttribute(XML_NAMESPACE_XLINK
, XML_SHOW
, XML_EMBED
);
3149 GetExport().AddAttribute(XML_NAMESPACE_XLINK
, XML_ACTUATE
, XML_ONLOAD
);
3151 // xlink:href for replacement, only written for Svg content
3152 SvXMLElementExport
aElement(GetExport(), XML_NAMESPACE_DRAW
, XML_IMAGE
, sal_False
, sal_True
);
3154 // optional office:binary-data
3155 GetExport().AddEmbeddedGraphicObjectAsBase64(sReplacementURL
);
3161 rPropSet
->getPropertyValue( sGraphicURL
) >>= sOrigURL
;
3162 OUString
sURL(GetExport().AddEmbeddedGraphicObject( sOrigURL
));
3163 setTextEmbeddedGraphicURL( rPropSet
, sURL
);
3165 // If there still is no url, then then graphic is empty
3166 if( !sURL
.isEmpty() )
3168 GetExport().AddAttribute(XML_NAMESPACE_XLINK
, XML_HREF
, sURL
);
3169 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
3170 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_SHOW
, XML_EMBED
);
3171 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_ACTUATE
,
3176 OUString sGrfFilter
;
3177 rPropSet
->getPropertyValue( sGraphicFilter
) >>= sGrfFilter
;
3178 if( !sGrfFilter
.isEmpty() )
3179 GetExport().AddAttribute( XML_NAMESPACE_DRAW
, XML_FILTER_NAME
,
3183 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_DRAW
,
3184 XML_IMAGE
, sal_False
, sal_True
);
3186 // optional office:binary-data
3187 GetExport().AddEmbeddedGraphicObjectAsBase64( sOrigURL
);
3191 Reference
<XEventsSupplier
> xEventsSupp( rPropSet
, UNO_QUERY
);
3192 GetExport().GetEventExport().Export(xEventsSupp
);
3195 GetExport().GetImageMapExport().Export( rPropSet
);
3197 // svg:title and svg:desc (#i73249#)
3198 exportTitleAndDescription( rPropSet
, rPropSetInfo
);
3201 exportContour( rPropSet
, rPropSetInfo
);
3204 void XMLTextParagraphExport::_collectTextEmbeddedAutoStyles(const Reference
< XPropertySet
> & )
3206 DBG_ASSERT( !this, "no API implementation avialable" );
3209 void XMLTextParagraphExport::_exportTextEmbedded(
3210 const Reference
< XPropertySet
> &,
3211 const Reference
< XPropertySetInfo
> & )
3213 DBG_ASSERT( !this, "no API implementation avialable" );
3216 void XMLTextParagraphExport::exportEvents( const Reference
< XPropertySet
> & rPropSet
)
3219 Reference
<XEventsSupplier
> xEventsSupp( rPropSet
, UNO_QUERY
);
3220 GetExport().GetEventExport().Export(xEventsSupp
);
3223 OUString
sImageMap("ImageMap");
3224 if (rPropSet
->getPropertySetInfo()->hasPropertyByName(sImageMap
))
3225 GetExport().GetImageMapExport().Export( rPropSet
);
3228 // Implement Title/Description Elements UI (#i73249#)
3229 void XMLTextParagraphExport::exportTitleAndDescription(
3230 const Reference
< XPropertySet
> & rPropSet
,
3231 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
3234 if( rPropSetInfo
->hasPropertyByName( sTitle
) )
3237 rPropSet
->getPropertyValue( sTitle
) >>= sObjTitle
;
3238 if( !sObjTitle
.isEmpty() )
3240 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_SVG
,
3241 XML_TITLE
, sal_True
, sal_False
);
3242 GetExport().Characters( sObjTitle
);
3247 if( rPropSetInfo
->hasPropertyByName( sDescription
) )
3250 rPropSet
->getPropertyValue( sDescription
) >>= sObjDesc
;
3251 if( !sObjDesc
.isEmpty() )
3253 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_SVG
,
3254 XML_DESC
, sal_True
, sal_False
);
3255 GetExport().Characters( sObjDesc
);
3260 void XMLTextParagraphExport::setTextEmbeddedGraphicURL(
3261 const Reference
< XPropertySet
>&,
3262 OUString
& /*rStreamName*/ ) const
3266 sal_Bool
XMLTextParagraphExport::addHyperlinkAttributes(
3267 const Reference
< XPropertySet
> & rPropSet
,
3268 const Reference
< XPropertyState
> & rPropState
,
3269 const Reference
< XPropertySetInfo
> & rPropSetInfo
)
3271 sal_Bool bExport
= sal_False
;
3272 OUString sHRef
, sName
, sTargetFrame
, sUStyleName
, sVStyleName
;
3273 sal_Bool bServerMap
= sal_False
;
3275 if( rPropSetInfo
->hasPropertyByName( sHyperLinkURL
) &&
3276 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3277 rPropState
->getPropertyState( sHyperLinkURL
) ) )
3279 rPropSet
->getPropertyValue( sHyperLinkURL
) >>= sHRef
;
3281 if( !sHRef
.isEmpty() )
3285 if( rPropSetInfo
->hasPropertyByName( sHyperLinkName
) &&
3286 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3287 rPropState
->getPropertyState( sHyperLinkName
) ) )
3289 rPropSet
->getPropertyValue( sHyperLinkName
) >>= sName
;
3290 if( !sName
.isEmpty() )
3294 if( rPropSetInfo
->hasPropertyByName( sHyperLinkTarget
) &&
3295 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3296 rPropState
->getPropertyState( sHyperLinkTarget
) ) )
3298 rPropSet
->getPropertyValue( sHyperLinkTarget
) >>= sTargetFrame
;
3299 if( !sTargetFrame
.isEmpty() )
3303 if( rPropSetInfo
->hasPropertyByName( sServerMap
) &&
3304 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3305 rPropState
->getPropertyState( sServerMap
) ) )
3307 bServerMap
= *(sal_Bool
*)rPropSet
->getPropertyValue( sServerMap
).getValue();
3312 if( rPropSetInfo
->hasPropertyByName( sUnvisitedCharStyleName
) &&
3313 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3314 rPropState
->getPropertyState( sUnvisitedCharStyleName
) ) )
3316 rPropSet
->getPropertyValue( sUnvisitedCharStyleName
) >>= sUStyleName
;
3317 if( !sUStyleName
.isEmpty() )
3321 if( rPropSetInfo
->hasPropertyByName( sVisitedCharStyleName
) &&
3322 ( !rPropState
.is() || PropertyState_DIRECT_VALUE
==
3323 rPropState
->getPropertyState( sVisitedCharStyleName
) ) )
3325 rPropSet
->getPropertyValue( sVisitedCharStyleName
) >>= sVStyleName
;
3326 if( !sVStyleName
.isEmpty() )
3332 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
3333 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, GetExport().GetRelativeReference( sHRef
) );
3335 if( !sName
.isEmpty() )
3336 GetExport().AddAttribute( XML_NAMESPACE_OFFICE
, XML_NAME
, sName
);
3338 if( !sTargetFrame
.isEmpty() )
3340 GetExport().AddAttribute( XML_NAMESPACE_OFFICE
,
3341 XML_TARGET_FRAME_NAME
, sTargetFrame
);
3342 enum XMLTokenEnum eTok
=
3343 sTargetFrame
.equalsAsciiL( "_blank", sizeof("_blank")-1 )
3344 ? XML_NEW
: XML_REPLACE
;
3345 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_SHOW
, eTok
);
3349 GetExport().AddAttribute( XML_NAMESPACE_OFFICE
,
3350 XML_SERVER_MAP
, XML_TRUE
);
3352 if( !sUStyleName
.isEmpty() )
3353 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
3354 XML_STYLE_NAME
, GetExport().EncodeStyleName( sUStyleName
) );
3356 if( !sVStyleName
.isEmpty() )
3357 GetExport().AddAttribute( XML_NAMESPACE_TEXT
,
3358 XML_VISITED_STYLE_NAME
, GetExport().EncodeStyleName( sVStyleName
) );
3364 void XMLTextParagraphExport::exportTextRange(
3365 const Reference
< XTextRange
> & rTextRange
,
3366 sal_Bool bAutoStyles
,
3367 bool& rPrevCharIsSpace
,
3368 FieldmarkType
& openFieldMark
)
3370 Reference
< XPropertySet
> xPropSet( rTextRange
, UNO_QUERY
);
3373 Add( XML_STYLE_FAMILY_TEXT_TEXT
, xPropSet
);
3377 sal_Bool bHyperlink
= sal_False
;
3378 sal_Bool bIsUICharStyle
= sal_False
;
3379 sal_Bool bHasAutoStyle
= sal_False
;
3381 OUString
sStyle(FindTextStyleAndHyperlink( xPropSet
, bHyperlink
,
3382 bIsUICharStyle
, bHasAutoStyle
));
3384 Reference
< XPropertySetInfo
> xPropSetInfo
;
3387 Reference
< XPropertyState
> xPropState( xPropSet
, UNO_QUERY
);
3388 xPropSetInfo
.set(xPropSet
->getPropertySetInfo());
3389 bHyperlink
= addHyperlinkAttributes( xPropSet
, xPropState
, xPropSetInfo
);
3391 SvXMLElementExport
aElem( GetExport(), bHyperlink
, XML_NAMESPACE_TEXT
,
3392 XML_A
, sal_False
, sal_False
);
3395 // export events (if supported)
3396 OUString
sHyperLinkEvents(
3398 if (xPropSetInfo
->hasPropertyByName(sHyperLinkEvents
))
3400 Reference
<XNameReplace
> xName(xPropSet
->getPropertyValue(sHyperLinkEvents
), uno::UNO_QUERY
);
3401 GetExport().GetEventExport().Export(xName
, sal_False
);
3406 XMLTextCharStyleNamesElementExport
aCharStylesExport(
3407 GetExport(), bIsUICharStyle
&&
3408 aCharStyleNamesPropInfoCache
.hasProperty(
3409 xPropSet
, xPropSetInfo
), bHasAutoStyle
,
3410 xPropSet
, sCharStyleNames
);
3412 OUString
aText(rTextRange
->getString());
3413 if( !sStyle
.isEmpty() )
3414 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
3415 GetExport().EncodeStyleName( sStyle
) );
3417 // in a block to make sure it is destroyed before the text:a element
3418 SvXMLElementExport
aElement( GetExport(), !sStyle
.isEmpty(),
3419 XML_NAMESPACE_TEXT
, XML_SPAN
, sal_False
,
3422 SvXMLElementExport
aElem2( GetExport(), TEXT
== openFieldMark
,
3423 XML_NAMESPACE_TEXT
, XML_TEXT_INPUT
,
3424 sal_False
, sal_False
);
3425 exportText( aText
, rPrevCharIsSpace
);
3426 openFieldMark
= NONE
;
3432 void XMLTextParagraphExport::exportText( const OUString
& rText
,
3433 bool& rPrevCharIsSpace
)
3435 sal_Int32 nExpStartPos
= 0;
3436 sal_Int32 nEndPos
= rText
.getLength();
3437 sal_Int32 nSpaceChars
= 0;
3438 for( sal_Int32 nPos
= 0; nPos
< nEndPos
; nPos
++ )
3440 sal_Unicode cChar
= rText
[nPos
];
3441 sal_Bool bExpCharAsText
= sal_True
;
3442 sal_Bool bExpCharAsElement
= sal_False
;
3443 sal_Bool bCurrCharIsSpace
= sal_False
;
3448 // These characters are exported as text.
3449 bExpCharAsElement
= sal_True
;
3450 bExpCharAsText
= sal_False
;
3453 break; // legal character
3454 case 0x0020: // Blank
3455 if( rPrevCharIsSpace
)
3457 // If the previous character is a space character,
3458 // too, export a special space element.
3459 bExpCharAsText
= sal_False
;
3461 bCurrCharIsSpace
= sal_True
;
3464 if( cChar
< 0x0020 )
3467 OSL_ENSURE( txtparae_bContainsIllegalCharacters
||
3469 "illegal character in text content" );
3470 txtparae_bContainsIllegalCharacters
= sal_True
;
3472 bExpCharAsText
= sal_False
;
3477 // If the current character is not exported as text
3478 // the text that has not been exported by now has to be exported now.
3479 if( nPos
> nExpStartPos
&& !bExpCharAsText
)
3481 DBG_ASSERT( 0==nSpaceChars
, "pending spaces" );
3482 OUString
sExp( rText
.copy( nExpStartPos
, nPos
- nExpStartPos
) );
3483 GetExport().Characters( sExp
);
3484 nExpStartPos
= nPos
;
3487 // If there are spaces left that have not been exported and the
3488 // current chracter is not a space , the pending spaces have to be
3490 if( nSpaceChars
> 0 && !bCurrCharIsSpace
)
3492 DBG_ASSERT( nExpStartPos
== nPos
, " pending characters" );
3494 if( nSpaceChars
> 1 )
3496 OUStringBuffer sTmp
;
3497 sTmp
.append( (sal_Int32
)nSpaceChars
);
3498 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_C
,
3499 sTmp
.makeStringAndClear() );
3502 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
3503 XML_S
, sal_False
, sal_False
);
3508 // If the current character has to be exported as a special
3509 // element, the elemnt will be exported now.
3510 if( bExpCharAsElement
)
3516 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
3523 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
3524 XML_LINE_BREAK
, sal_False
,
3531 // If the current character is a space, and the previous one
3532 // is a space, too, the number of pending spaces is incremented
3534 if( bCurrCharIsSpace
&& rPrevCharIsSpace
)
3536 rPrevCharIsSpace
= bCurrCharIsSpace
;
3538 // If the currect character is not exported as text, the start
3539 // position for text is the position behind the current position.
3540 if( !bExpCharAsText
)
3542 DBG_ASSERT( nExpStartPos
== nPos
, "wrong export start pos" );
3543 nExpStartPos
= nPos
+1;
3547 if( nExpStartPos
< nEndPos
)
3549 DBG_ASSERT( 0==nSpaceChars
, " pending spaces " );
3550 OUString
sExp( rText
.copy( nExpStartPos
, nEndPos
- nExpStartPos
) );
3551 GetExport().Characters( sExp
);
3554 // If there are some spaces left, they have to be exported now.
3555 if( nSpaceChars
> 0 )
3557 if( nSpaceChars
> 1 )
3559 OUStringBuffer sTmp
;
3560 sTmp
.append( (sal_Int32
)nSpaceChars
);
3561 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_C
,
3562 sTmp
.makeStringAndClear() );
3565 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
, XML_S
,
3566 sal_False
, sal_False
);
3570 void XMLTextParagraphExport::exportTextDeclarations()
3572 pFieldExport
->ExportFieldDeclarations();
3574 // get XPropertySet from the document and ask for AutoMarkFileURL.
3575 // If it exists, export the auto-mark-file element.
3576 Reference
<XPropertySet
> xPropertySet( GetExport().GetModel(), UNO_QUERY
);
3577 if (xPropertySet
.is())
3580 OUString
sIndexAutoMarkFileURL(
3581 "IndexAutoMarkFileURL");
3582 if (xPropertySet
->getPropertySetInfo()->hasPropertyByName(
3583 sIndexAutoMarkFileURL
))
3585 xPropertySet
->getPropertyValue(sIndexAutoMarkFileURL
) >>= sUrl
;
3586 if (!sUrl
.isEmpty())
3588 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
,
3589 GetExport().GetRelativeReference(sUrl
) );
3590 SvXMLElementExport
aAutoMarkElement(
3591 GetExport(), XML_NAMESPACE_TEXT
,
3592 XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE
,
3593 sal_True
, sal_True
);
3599 void XMLTextParagraphExport::exportTextDeclarations(
3600 const Reference
<XText
> & rText
)
3602 pFieldExport
->ExportFieldDeclarations(rText
);
3605 void XMLTextParagraphExport::exportUsedDeclarations( sal_Bool bOnlyUsed
)
3607 pFieldExport
->SetExportOnlyUsedFieldDeclarations( bOnlyUsed
);
3611 void XMLTextParagraphExport::exportTrackedChanges(sal_Bool bAutoStyles
)
3613 if (NULL
!= pRedlineExport
)
3614 pRedlineExport
->ExportChangesList( bAutoStyles
);
3617 void XMLTextParagraphExport::exportTrackedChanges(
3618 const Reference
<XText
> & rText
,
3619 sal_Bool bAutoStyle
)
3621 if (NULL
!= pRedlineExport
)
3622 pRedlineExport
->ExportChangesList(rText
, bAutoStyle
);
3625 void XMLTextParagraphExport::recordTrackedChangesForXText(
3626 const Reference
<XText
> & rText
)
3628 if (NULL
!= pRedlineExport
)
3629 pRedlineExport
->SetCurrentXText(rText
);
3632 void XMLTextParagraphExport::recordTrackedChangesNoXText()
3634 if (NULL
!= pRedlineExport
)
3635 pRedlineExport
->SetCurrentXText();
3639 void XMLTextParagraphExport::exportTextAutoStyles()
3641 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_PARAGRAPH
,
3642 GetExport().GetDocHandler(),
3643 GetExport().GetMM100UnitConverter(),
3644 GetExport().GetNamespaceMap() );
3646 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_TEXT
,
3647 GetExport().GetDocHandler(),
3648 GetExport().GetMM100UnitConverter(),
3649 GetExport().GetNamespaceMap() );
3651 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_FRAME
,
3652 GetExport().GetDocHandler(),
3653 GetExport().GetMM100UnitConverter(),
3654 GetExport().GetNamespaceMap() );
3656 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_SECTION
,
3657 GetExport().GetDocHandler(),
3658 GetExport().GetMM100UnitConverter(),
3659 GetExport().GetNamespaceMap() );
3661 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_RUBY
,
3662 GetExport().GetDocHandler(),
3663 GetExport().GetMM100UnitConverter(),
3664 GetExport().GetNamespaceMap() );
3666 pListAutoPool
->exportXML();
3669 void XMLTextParagraphExport::exportRuby(
3670 const Reference
<XPropertySet
> & rPropSet
,
3671 sal_Bool bAutoStyles
)
3673 // early out: a collapsed ruby makes no sense
3674 if (*(sal_Bool
*)rPropSet
->getPropertyValue(sIsCollapsed
).getValue())
3678 sal_Bool bStart
= (*(sal_Bool
*)rPropSet
->getPropertyValue(sIsStart
).getValue());
3684 Add( XML_STYLE_FAMILY_TEXT_RUBY
, rPropSet
);
3692 // we can only start a ruby if none is open
3693 DBG_ASSERT(! bOpenRuby
, "Can't open a ruby inside of ruby!");
3697 // save ruby text + ruby char style
3698 rPropSet
->getPropertyValue(sRubyText
) >>= sOpenRubyText
;
3699 rPropSet
->getPropertyValue(sRubyCharStyleName
) >>= sOpenRubyCharStyle
;
3702 GetExport().CheckAttrList();
3704 OUString
sStyleName(Find( XML_STYLE_FAMILY_TEXT_RUBY
, rPropSet
,
3706 DBG_ASSERT(!sStyleName
.isEmpty(), "I can't find the style!");
3707 GetExport().AddAttribute(XML_NAMESPACE_TEXT
,
3708 XML_STYLE_NAME
, sStyleName
);
3710 // export <text:ruby> and <text:ruby-base> start elements
3711 GetExport().StartElement( XML_NAMESPACE_TEXT
, XML_RUBY
, sal_False
);
3712 GetExport().ClearAttrList();
3713 GetExport().StartElement( XML_NAMESPACE_TEXT
, XML_RUBY_BASE
,
3715 bOpenRuby
= sal_True
;
3721 // check for an open ruby
3722 DBG_ASSERT(bOpenRuby
, "Can't close a ruby if none is open!");
3726 // close <text:ruby-base>
3727 GetExport().EndElement(XML_NAMESPACE_TEXT
, XML_RUBY_BASE
,
3730 // write the ruby text (with char style)
3732 if (!sOpenRubyCharStyle
.isEmpty())
3733 GetExport().AddAttribute(
3734 XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
3735 GetExport().EncodeStyleName( sOpenRubyCharStyle
) );
3737 SvXMLElementExport
aRubyElement(
3738 GetExport(), XML_NAMESPACE_TEXT
, XML_RUBY_TEXT
,
3739 sal_False
, sal_False
);
3741 GetExport().Characters(sOpenRubyText
);
3744 // and finally, close the ruby
3745 GetExport().EndElement(XML_NAMESPACE_TEXT
, XML_RUBY
, sal_False
);
3746 bOpenRuby
= sal_False
;
3751 void XMLTextParagraphExport::exportMeta(
3752 const Reference
<XPropertySet
> & i_xPortion
,
3753 sal_Bool i_bAutoStyles
, sal_Bool i_isProgress
)
3755 static OUString
sMeta("InContentMetadata");
3757 bool doExport(!i_bAutoStyles
); // do not export element if autostyles
3758 // check version >= 1.2
3759 switch (GetExport().getDefaultVersion()) {
3760 case SvtSaveOptions::ODFVER_011
: // fall thru
3761 case SvtSaveOptions::ODFVER_010
: doExport
= false; break;
3765 const Reference
< XTextContent
> xTextContent(
3766 i_xPortion
->getPropertyValue(sMeta
), UNO_QUERY_THROW
);
3767 const Reference
< XEnumerationAccess
> xEA( xTextContent
, UNO_QUERY_THROW
);
3768 const Reference
< XEnumeration
> xTextEnum( xEA
->createEnumeration() );
3772 const Reference
<rdf::XMetadatable
> xMeta(xTextContent
, UNO_QUERY_THROW
);
3774 // text:meta with neither xml:id nor RDFa is invalid
3775 xMeta
->ensureMetadataReference();
3777 // xml:id and RDFa for RDF metadata
3778 GetExport().AddAttributeXmlId(xMeta
);
3779 GetExport().AddAttributesRDFa(xTextContent
);
3782 SvXMLElementExport
aElem( GetExport(), doExport
,
3783 XML_NAMESPACE_TEXT
, XML_META
, sal_False
, sal_False
);
3785 // recurse to export content
3786 exportTextRangeEnumeration( xTextEnum
, i_bAutoStyles
, i_isProgress
);
3790 void XMLTextParagraphExport::PreventExportOfControlsInMuteSections(
3791 const Reference
<XIndexAccess
> & rShapes
,
3792 UniReference
<xmloff::OFormLayerXMLExport
> xFormExport
)
3794 // check parameters ad pre-conditions
3795 if( ( ! rShapes
.is() ) || ( ! xFormExport
.is() ) )
3797 // if we don't have shapes or a form export, there's nothing to do
3800 DBG_ASSERT( pSectionExport
!= NULL
, "We need the section export." );
3802 Reference
<XEnumeration
> xShapesEnum
= pBoundFrameSets
->GetShapes()->createEnumeration();
3803 if(!xShapesEnum
.is())
3805 while( xShapesEnum
->hasMoreElements() )
3807 // now we need to check
3808 // 1) if this is a control shape, and
3809 // 2) if it's in a mute section
3810 // if both answers are 'yes', notify the form layer export
3812 // we join accessing the shape and testing for control
3813 Reference
<XControlShape
> xControlShape(xShapesEnum
->nextElement(), UNO_QUERY
);
3814 if( xControlShape
.is() )
3816 // Reference<XPropertySet> xPropSet( xControlShape, UNO_QUERY );
3817 // Reference<XTextContent> xTextContent;
3818 // xPropSet->getPropertyValue( OUString( "TextRange" ) ) >>= xTextContent;
3820 Reference
<XTextContent
> xTextContent( xControlShape
, UNO_QUERY
);
3821 if( xTextContent
.is() )
3823 if( pSectionExport
->IsMuteSection( xTextContent
, sal_False
) )
3825 // Ah, we've found a shape that
3826 // 1) is a control shape
3827 // 2) is anchored in a mute section
3828 // so: don't export it!
3829 xFormExport
->excludeFromExport(
3830 xControlShape
->getControl() );
3832 // else: not in mute section -> should be exported -> nothing
3835 // else: no anchor -> ignore
3837 // else: no control shape -> nothing to do
3841 void XMLTextParagraphExport::PushNewTextListsHelper()
3843 mpTextListsHelper
= new XMLTextListsHelper();
3844 maTextListsHelperStack
.push_back( mpTextListsHelper
);
3847 void XMLTextParagraphExport::PopTextListsHelper()
3849 delete mpTextListsHelper
;
3850 mpTextListsHelper
= 0;
3851 maTextListsHelperStack
.pop_back();
3852 if ( !maTextListsHelperStack
.empty() )
3854 mpTextListsHelper
= maTextListsHelperStack
.back();
3858 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */