nss: upgrade to release 3.73
[LibreOffice.git] / include / xmloff / txtparae.hxx
blob2495f0f504d0fc6ed98b57834dd90e799944c586
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #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>
32 #include <memory>
33 #include <vector>
35 class XMLTextListsHelper;
36 class SvXMLExport;
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;
55 class XTextField; }
58 namespace xmloff
60 class OFormLayerXMLExport;
61 class BoundFrameSets;
65 namespace basegfx
67 class B2DPoint;
70 enum class TextPNS
72 ODF,
73 EXTENSION
76 class XMLOFF_DLLPUBLIC XMLTextParagraphExport : public XMLStyleExport
78 struct Impl;
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;
100 bool bProgress;
102 bool bBlock;
104 // keep track of open rubies
105 OUString sOpenRubyText;
106 OUString sOpenRubyCharStyle;
107 bool bOpenRuby;
109 XMLTextListsHelper* mpTextListsHelper;
110 ::std::vector< std::unique_ptr<XMLTextListsHelper> > maTextListsHelperStack;
112 bool mbCollected;
114 enum class FrameType { Text, Graphic, Embedded, Shape };
115 public:
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);
130 private:
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";
153 protected:
154 static constexpr OUStringLiteral gsFrameStyleName = u"FrameStyleName";
155 SinglePropertySetInfoCache aCharStyleNamesPropInfoCache;
157 SvXMLAutoStylePoolP& GetAutoStylePool() { return rAutoStylePool; }
158 const SvXMLAutoStylePoolP& GetAutoStylePool() const { return rAutoStylePool; }
160 public:
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,
186 bool& rbHyperlink,
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);
199 protected:
201 XMLShapeExportFlags addTextFrameAttributes(
202 const css::uno::Reference< css::beans::XPropertySet >& rPropSet,
203 bool bShape,
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 );
217 void exportText(
218 const css::uno::Reference <
219 css::text::XText > & rText,
220 bool bAutoStyles, bool bProgress, bool bExportParagraph, TextPNS eExtensionNS = TextPNS::ODF );
222 void exportText(
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,
229 bool bAutoStyles,
230 const css::uno::Reference< css::text::XTextSection > & rBaseSection,
231 bool bProgress,
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,
257 FrameType eTxpe,
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,
263 bool bProgress );
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,
270 bool bAutoStyles,
271 const css::uno::Reference< css::beans::XPropertySet > *pRangePropSet = nullptr );
273 void exportContour(
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,
281 bool bAutoStyles,
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,
291 bool bAutoStyles,
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,
305 bool bAutoStyles,
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,
313 bool bIsEndnote);
315 void exportTextMark(
316 const css::uno::Reference< css::beans::XPropertySet> & xPropSet,
317 const OUString& rProperty,
318 const enum ::xmloff::token::XMLTokenEnum pElements[],
319 bool bAutoStyles);
321 void exportSoftPageBreak();
323 void exportTextRange(
324 const css::uno::Reference< css::text::XTextRange > & rTextRange,
325 bool bAutoStyles,
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,
339 bool bAutoStyles );
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,
348 bool bAutoStyles );
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,
356 bool bAutoStyles );
358 /// export a ruby
359 void exportRuby(
360 const css::uno::Reference< css::beans::XPropertySet> & rPortionPropSet,
361 bool bAutoStyles );
363 /// export a text:meta
364 void exportMeta(
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();
372 public:
374 XMLTextParagraphExport(
375 SvXMLExport& rExp,
376 SvXMLAutoStylePoolP & rASP
378 virtual ~XMLTextParagraphExport() override;
380 /// add autostyle for specified family
381 void Add(
382 XmlStyleFamily nFamily,
383 MultiPropertySetHelper& rPropSetHelper,
384 const css::uno::Reference< css::beans::XPropertySet > & rPropSet );
385 void Add(
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
391 OUString Find(
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,
426 bool bAutoStyle );
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
439 /// empty reference.
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,
460 bool bIsProgress )
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
479 void exportText(
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 );
487 void exportText(
488 const css::uno::Reference< css::text::XText > & rText,
489 const css::uno::Reference< css::text::XTextSection > & rBaseSection,
490 bool bIsProgress)
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();
532 private:
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,
553 bool bAutoStyles,
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,
562 bool bAutoStyles,
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,
571 bool bAutoStyles,
572 const css::uno::Reference< css::beans::XPropertySet > *pRangePropSet )
574 exportAnyTextFrame( rTextContent, FrameType::Shape, bAutoStyles, false,
575 true, pRangePropSet );
578 #endif
580 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */