1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_XMLOFF_TXTPARAE_HXX
21 #define INCLUDED_XMLOFF_TXTPARAE_HXX
23 #include <sal/config.h>
24 #include <rtl/ref.hxx>
25 #include <xmloff/dllapi.h>
26 #include <rtl/ustring.hxx>
27 #include <com/sun/star/uno/Reference.h>
28 #include <xmloff/styleexp.hxx>
29 #include <xmloff/xmltoken.hxx>
30 #include <xmloff/SinglePropertySetInfoCache.hxx>
31 #include <xmloff/XMLTextListAutoStylePool.hxx>
35 class XMLTextListsHelper
;
37 class SvXMLAutoStylePoolP
;
38 class XMLTextFieldExport
;
39 class XMLTextNumRuleInfo
;
40 class XMLSectionExport
;
41 class XMLIndexMarkExport
;
42 class XMLRedlineExport
;
43 struct XMLPropertyState
;
44 class MultiPropertySetHelper
;
45 enum class XMLShapeExportFlags
;
46 class SvXMLExportPropertyMapper
;
48 namespace com::sun::star
50 namespace beans
{ class XPropertySet
; class XPropertyState
;
51 class XPropertySetInfo
; }
52 namespace container
{ class XEnumeration
; class XIndexAccess
; }
53 namespace text
{ class XTextContent
; class XTextRange
; class XText
;
54 class XFootnote
; class XTextFrame
; class XTextSection
;
60 class OFormLayerXMLExport
;
76 class XMLOFF_DLLPUBLIC XMLTextParagraphExport
: public XMLStyleExport
79 std::unique_ptr
<Impl
> m_xImpl
;
81 // SvXMLExport& rExport;
82 SvXMLAutoStylePoolP
& rAutoStylePool
;
83 rtl::Reference
< SvXMLExportPropertyMapper
> xParaPropMapper
;
84 rtl::Reference
< SvXMLExportPropertyMapper
> xTextPropMapper
;
85 rtl::Reference
< SvXMLExportPropertyMapper
> xFramePropMapper
;
86 rtl::Reference
< SvXMLExportPropertyMapper
> xAutoFramePropMapper
;
87 rtl::Reference
< SvXMLExportPropertyMapper
> xSectionPropMapper
;
88 rtl::Reference
< SvXMLExportPropertyMapper
> xRubyPropMapper
;
90 const ::std::unique_ptr
< ::xmloff::BoundFrameSets
> pBoundFrameSets
;
91 std::unique_ptr
<XMLTextFieldExport
> pFieldExport
;
92 std::unique_ptr
<std::vector
<OUString
>> pListElements
;
93 XMLTextListAutoStylePool maListAutoPool
;
94 std::unique_ptr
<XMLSectionExport
> pSectionExport
;
95 std::unique_ptr
<XMLIndexMarkExport
> pIndexMarkExport
;
97 /// may be NULL (if no redlines should be exported; e.g. in block mode)
98 std::unique_ptr
<XMLRedlineExport
> pRedlineExport
;
104 // keep track of open rubies
105 OUString sOpenRubyText
;
106 OUString sOpenRubyCharStyle
;
109 XMLTextListsHelper
* mpTextListsHelper
;
110 ::std::vector
< std::unique_ptr
<XMLTextListsHelper
> > maTextListsHelperStack
;
114 enum class FrameType
{ Text
, Graphic
, Embedded
, Shape
};
117 enum FieldmarkType
{ NONE
, TEXT
, CHECK
}; // Used for simulating fieldmarks in OpenDocument 1.n Strict (for n <= 2). CHECK currently ignored.
120 void exportTextRangeSpan(
121 const css::uno::Reference
< css::text::XTextRange
> & rTextRange
,
122 css::uno::Reference
< css::beans::XPropertySet
> const & xPropSet
,
123 css::uno::Reference
< css::beans::XPropertySetInfo
> & xPropSetInfo
,
124 const bool bIsUICharStyle
,
125 const bool bHasAutoStyle
,
126 const OUString
& sStyle
,
127 bool& rPrevCharIsSpace
,
128 FieldmarkType
& openFieldMark
);
132 // Implement Title/Description Elements UI (#i73249#)
133 static constexpr OUStringLiteral gsAnchorCharStyleName
= u
"AnchorCharStyleName";
134 static constexpr OUStringLiteral gsBeginNotice
= u
"BeginNotice";
135 static constexpr OUStringLiteral gsCategory
= u
"Category";
136 static constexpr OUStringLiteral gsCharStyleName
= u
"CharStyleName";
137 static constexpr OUStringLiteral gsCharStyleNames
= u
"CharStyleNames";
138 static constexpr OUStringLiteral gsEndNotice
= u
"EndNotice";
139 static constexpr OUStringLiteral gsFootnote
= u
"Footnote";
140 static constexpr OUStringLiteral gsFootnoteCounting
= u
"FootnoteCounting";
141 static constexpr OUStringLiteral gsNumberingType
= u
"NumberingType";
142 static constexpr OUStringLiteral gsPageDescName
= u
"PageDescName";
143 static constexpr OUStringLiteral gsPageStyleName
= u
"PageStyleName";
144 static constexpr OUStringLiteral gsParaStyleName
= u
"ParaStyleName";
145 static constexpr OUStringLiteral gsPositionEndOfDoc
= u
"PositionEndOfDoc";
146 static constexpr OUStringLiteral gsPrefix
= u
"Prefix";
147 static constexpr OUStringLiteral gsReferenceId
= u
"ReferenceId";
148 static constexpr OUStringLiteral gsStartAt
= u
"StartAt";
149 static constexpr OUStringLiteral gsSuffix
= u
"Suffix";
150 static constexpr OUStringLiteral gsTextEndnoteService
= u
"com.sun.star.text.Endnote";
151 static constexpr OUStringLiteral gsTextSection
= u
"TextSection";
154 static constexpr OUStringLiteral gsFrameStyleName
= u
"FrameStyleName";
155 SinglePropertySetInfoCache aCharStyleNamesPropInfoCache
;
157 SvXMLAutoStylePoolP
& GetAutoStylePool() { return rAutoStylePool
; }
158 const SvXMLAutoStylePoolP
& GetAutoStylePool() const { return rAutoStylePool
; }
161 const rtl::Reference
< SvXMLExportPropertyMapper
>& GetParaPropMapper() const
163 return xParaPropMapper
;
166 const rtl::Reference
< SvXMLExportPropertyMapper
>& GetTextPropMapper() const
168 return xTextPropMapper
;
171 const rtl::Reference
< SvXMLExportPropertyMapper
>& GetAutoFramePropMapper() const
173 return xAutoFramePropMapper
;
175 const rtl::Reference
< SvXMLExportPropertyMapper
>& GetSectionPropMapper() const
177 return xSectionPropMapper
;
179 const rtl::Reference
< SvXMLExportPropertyMapper
>& GetRubyPropMapper() const
181 return xRubyPropMapper
;
184 OUString
FindTextStyleAndHyperlink(
185 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
187 bool& rbHasCharStyle
,
188 bool& rbHasAutoStyle
,
189 const XMLPropertyState
** pAddState
= nullptr) const;
190 bool addHyperlinkAttributes(
191 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
192 const css::uno::Reference
< css::beans::XPropertyState
> & rPropState
,
193 const css::uno::Reference
< css::beans::XPropertySetInfo
> & rPropSetInfo
);
195 void exportTextRangeEnumeration(
196 const css::uno::Reference
< css::container::XEnumeration
> & rRangeEnum
,
197 bool bAutoStyles
, bool bProgress
, bool & rPrevCharIsSpace
);
201 XMLShapeExportFlags
addTextFrameAttributes(
202 const css::uno::Reference
< css::beans::XPropertySet
>& rPropSet
,
204 basegfx::B2DPoint
* pCenter
= nullptr,
205 OUString
*pMinHeightValue
= nullptr,
206 OUString
*pMinWidthValue
= nullptr );
208 virtual void exportStyleAttributes(
209 const css::uno::Reference
< css::style::XStyle
> & rStyle
) override
;
211 void exportPageFrames( bool bProgress
);
212 void exportFrameFrames( bool bAutoStyles
, bool bProgress
,
213 const css::uno::Reference
< css::text::XTextFrame
> *pParentTxtFrame
);
215 void exportNumStyles( bool bUsed
);
218 const css::uno::Reference
<
219 css::text::XText
> & rText
,
220 bool bAutoStyles
, bool bProgress
, bool bExportParagraph
, TextPNS eExtensionNS
= TextPNS::ODF
);
223 const css::uno::Reference
< css::text::XText
> & rText
,
224 const css::uno::Reference
< css::text::XTextSection
> & rBaseSection
,
225 bool bAutoStyles
, bool bProgress
, bool bExportParagraph
);
227 void exportTextContentEnumeration(
228 const css::uno::Reference
< css::container::XEnumeration
> & rContentEnum
,
230 const css::uno::Reference
< css::text::XTextSection
> & rBaseSection
,
232 bool bExportParagraph
= true,
233 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
= nullptr,
234 TextPNS eExtensionNS
= TextPNS::ODF
);
235 void exportParagraph(
236 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
237 bool bAutoStyles
, bool bProgress
,
238 bool bExportParagraph
,
239 MultiPropertySetHelper
& rPropSetHelper
,
240 TextPNS eExtensionNS
);
242 virtual void exportTable(
243 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
244 bool bAutoStyles
, bool bProgress
);
246 void exportTextField(
247 const css::uno::Reference
< css::text::XTextRange
> & rTextRange
,
248 bool bAutoStyles
, bool bProgress
, bool * pPrevCharIsSpace
);
250 void exportTextField(
251 const css::uno::Reference
< css::text::XTextField
> & xTextField
,
252 const bool bAutoStyles
, const bool bProgress
,
253 const bool bRecursive
, bool * pPrevCharIsSpace
);
255 void exportAnyTextFrame(
256 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
258 bool bAutoStyles
, bool bProgress
, bool bExportContent
,
259 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
);
260 void _exportTextFrame(
261 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
262 const css::uno::Reference
< css::beans::XPropertySetInfo
> & rPropSetInfo
,
264 inline void exportTextFrame(
265 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
266 bool bAutoStyles
, bool bProgress
, bool bExportContent
,
267 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
= nullptr );
268 inline void exportShape(
269 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
271 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
= nullptr );
274 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
275 const css::uno::Reference
< css::beans::XPropertySetInfo
> & rPropSetInfo
);
276 void _exportTextGraphic(
277 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
278 const css::uno::Reference
< css::beans::XPropertySetInfo
> & rPropSetInfo
);
279 inline void exportTextGraphic(
280 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
282 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
= nullptr );
284 virtual void _collectTextEmbeddedAutoStyles(
285 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
);
286 virtual void _exportTextEmbedded(
287 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
288 const css::uno::Reference
< css::beans::XPropertySetInfo
> & rPropSetInfo
);
289 inline void exportTextEmbedded(
290 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
292 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
= nullptr );
294 /// export a footnote and styles
295 void exportTextFootnote(
296 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
297 const OUString
& sString
,
298 bool bAutoStyles
, bool bProgress
);
300 /// helper for exportTextFootnote
301 void exportTextFootnoteHelper(
302 const css::uno::Reference
< css::text::XFootnote
> & rPropSet
,
303 const css::uno::Reference
< css::text::XText
> & rText
,
304 const OUString
& sString
,
306 bool bIsEndnote
, bool bProgress
);
308 /// export footnote and endnote configuration elements
309 void exportTextFootnoteConfiguration();
311 void exportTextFootnoteConfigurationHelper(
312 const css::uno::Reference
< css::beans::XPropertySet
> & rFootnoteSupplier
,
316 const css::uno::Reference
< css::beans::XPropertySet
> & xPropSet
,
317 const OUString
& rProperty
,
318 const enum ::xmloff::token::XMLTokenEnum pElements
[],
321 void exportSoftPageBreak();
323 void exportTextRange(
324 const css::uno::Reference
< css::text::XTextRange
> & rTextRange
,
326 bool& rPrevCharWasSpace
,
327 FieldmarkType
& openFieldmarkType
);
329 void exportListChange( const XMLTextNumRuleInfo
& rPrvInfo
,
330 const XMLTextNumRuleInfo
& rNextInfo
);
332 /// check if current section or current list has changed;
333 /// calls exportListChange as appropriate
334 void exportListAndSectionChange(
335 css::uno::Reference
< css::text::XTextSection
> & rOldSection
,
336 const css::uno::Reference
< css::text::XTextSection
> & rNewSection
,
337 const XMLTextNumRuleInfo
& rOldList
,
338 const XMLTextNumRuleInfo
& rNewList
,
341 /// overload for exportListAndSectionChange;
342 /// takes new content rather than new section.
343 void exportListAndSectionChange(
344 css::uno::Reference
< css::text::XTextSection
> & rOldSection
,
345 const css::uno::Reference
< css::text::XTextContent
> & rNewContent
,
346 const XMLTextNumRuleInfo
& rOldList
,
347 const XMLTextNumRuleInfo
& rNewList
,
349 void exportListAndSectionChange(
350 css::uno::Reference
< css::text::XTextSection
> & rOldSection
,
351 MultiPropertySetHelper
& rPropSetHelper
,
352 sal_Int16 nTextSectionId
,
353 const css::uno::Reference
< css::text::XTextContent
> & rNewContent
,
354 const XMLTextNumRuleInfo
& rOldList
,
355 const XMLTextNumRuleInfo
& rNewList
,
360 const css::uno::Reference
< css::beans::XPropertySet
> & rPortionPropSet
,
363 /// export a text:meta
365 const css::uno::Reference
< css::beans::XPropertySet
> & i_xPortion
,
366 bool i_bAutoStyles
, bool i_isProgress
, bool & rPrevCharIsSpace
);
368 bool isAutoStylesCollected() const { return mbCollected
; }
370 virtual void exportTableAutoStyles();
374 XMLTextParagraphExport(
376 SvXMLAutoStylePoolP
& rASP
378 virtual ~XMLTextParagraphExport() override
;
380 /// add autostyle for specified family
382 XmlStyleFamily nFamily
,
383 MultiPropertySetHelper
& rPropSetHelper
,
384 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
);
386 XmlStyleFamily nFamily
,
387 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
388 const XMLPropertyState
** pAddState
= nullptr, bool bDontSeek
= false );
390 /// find style name for specified family and parent
392 XmlStyleFamily nFamily
,
393 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
394 const OUString
& rParent
,
395 const XMLPropertyState
** pAddState
= nullptr ) const;
397 static SvXMLExportPropertyMapper
*CreateShapeExtPropMapper(
398 SvXMLExport
& rExport
);
399 static SvXMLExportPropertyMapper
*CreateCharExtPropMapper(
400 SvXMLExport
& rExport
);
401 static SvXMLExportPropertyMapper
*CreateParaExtPropMapper(
402 SvXMLExport
& rExport
);
403 static SvXMLExportPropertyMapper
*CreateParaDefaultExtPropMapper(
404 SvXMLExport
& rExport
);
406 // This methods exports all (or all used) styles
407 void exportTextStyles( bool bUsed
, bool bProg
);
409 /// This method exports (text field) declarations etc.
410 void exportTextDeclarations();
412 /// export the (text field) declarations for a particular XText
413 void exportTextDeclarations(
414 const css::uno::Reference
< css::text::XText
> & rText
);
416 /// export all declarations
417 void exportUsedDeclarations();
419 /// Export the list of change information (enclosed by <tracked-changes>)
420 /// (or the necessary automatic styles)
421 void exportTrackedChanges(bool bAutoStyle
);
423 /// Export the list of change information (enclosed by <tracked-changes>)
424 /// (or the necessary automatic styles)
425 void exportTrackedChanges(const css::uno::Reference
< css::text::XText
> & rText
,
428 /// Record tracked changes for this particular XText
429 /// (empty reference stop recording)
430 /// This should be used if tracked changes for e.g. footers are to
431 /// be exported separately via the exportTrackedChanges(bool,
432 /// Reference<XText>) method.
433 void recordTrackedChangesForXText(
434 const css::uno::Reference
< css::text::XText
> & rText
);
437 /// Stop recording tracked changes.
438 /// This is the same as calling recordTrackedChanges(...) with an
440 void recordTrackedChangesNoXText();
443 // This method exports the given OUString
444 void exportCharacterData(
445 const OUString
& rText
,
446 bool& rPrevCharWasSpace
);
448 // This method collects all automatic styles for the given XText
449 void collectTextAutoStyles(
450 const css::uno::Reference
< css::text::XText
> & rText
,
451 bool bIsProgress
= false,
452 bool bExportParagraph
= true )
454 exportText( rText
, true, bIsProgress
, bExportParagraph
);
457 void collectTextAutoStyles(
458 const css::uno::Reference
< css::text::XText
> & rText
,
459 const css::uno::Reference
< css::text::XTextSection
> & rBaseSection
,
462 exportText( rText
, rBaseSection
, true, bIsProgress
, true/*bExportParagraph*/ );
465 // It the model implements the xAutoStylesSupplier interface, the automatic
466 // styles can exported without iterating over the text portions
467 void collectTextAutoStylesOptimized( bool bIsProgress
);
469 // This method exports all automatic styles that have been collected.
470 void exportTextAutoStyles();
472 void exportEvents( const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
);
474 // Implement Title/Description Elements UI (#i73249#)
475 void exportTitleAndDescription( const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
476 const css::uno::Reference
< css::beans::XPropertySetInfo
> & rPropSetInfo
);
478 // This method exports the given XText
480 const css::uno::Reference
< css::text::XText
> & rText
,
481 bool bIsProgress
= false,
482 bool bExportParagraph
= true, TextPNS eExtensionNS
= TextPNS::ODF
)
484 exportText( rText
, false, bIsProgress
, bExportParagraph
, eExtensionNS
);
488 const css::uno::Reference
< css::text::XText
> & rText
,
489 const css::uno::Reference
< css::text::XTextSection
> & rBaseSection
,
492 exportText( rText
, rBaseSection
, false, bIsProgress
, true/*bExportParagraph*/ );
495 void exportFramesBoundToPage( bool bIsProgress
)
497 exportPageFrames( bIsProgress
);
499 inline const XMLTextListAutoStylePool
& GetListAutoStylePool() const;
501 void SetBlockMode( bool bSet
) { bBlock
= bSet
; }
502 bool IsBlockMode() const { return bBlock
; }
505 const rtl::Reference
< SvXMLExportPropertyMapper
>& GetParagraphPropertyMapper() const
507 return xParaPropMapper
;
511 /** exclude form controls which are in mute sections.
513 * This method is necessary to prevent the form layer export from exporting
514 * control models whose controls are not represented in the document. To
515 * achieve this, this method iterates over all shapes, checks to see if
516 * they are control shapes, and if so, whether they should be exported or
517 * not. If not, the form layer export will be notified accordingly.
519 * The reason this method is located here is that it needs to access the
520 * XMLSectionExport, which is only available here.
522 void PreventExportOfControlsInMuteSections(
523 const css::uno::Reference
< css::container::XIndexAccess
> & rShapes
,
524 const rtl::Reference
<xmloff::OFormLayerXMLExport
>& xFormExport
);
526 SinglePropertySetInfoCache
& GetCharStyleNamesPropInfoCache() { return aCharStyleNamesPropInfoCache
; }
528 void PushNewTextListsHelper();
530 void PopTextListsHelper();
533 XMLTextParagraphExport(XMLTextParagraphExport
const &) = delete;
536 inline const XMLTextListAutoStylePool
&
537 XMLTextParagraphExport::GetListAutoStylePool() const
539 return maListAutoPool
;
542 inline void XMLTextParagraphExport::exportTextFrame(
543 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
544 bool bAutoStyles
, bool bIsProgress
, bool bExportContent
,
545 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
)
547 exportAnyTextFrame( rTextContent
, FrameType::Text
, bAutoStyles
, bIsProgress
,
548 bExportContent
, pRangePropSet
);
551 inline void XMLTextParagraphExport::exportTextGraphic(
552 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
554 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
)
556 exportAnyTextFrame( rTextContent
, FrameType::Graphic
, bAutoStyles
, false,
557 true, pRangePropSet
);
560 inline void XMLTextParagraphExport::exportTextEmbedded(
561 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
563 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
)
565 exportAnyTextFrame( rTextContent
, FrameType::Embedded
, bAutoStyles
, false,
566 true, pRangePropSet
);
569 inline void XMLTextParagraphExport::exportShape(
570 const css::uno::Reference
< css::text::XTextContent
> & rTextContent
,
572 const css::uno::Reference
< css::beans::XPropertySet
> *pRangePropSet
)
574 exportAnyTextFrame( rTextContent
, FrameType::Shape
, bAutoStyles
, false,
575 true, pRangePropSet
);
580 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */