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