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