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 #ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_DOMAINMAPPER_IMPL_HXX
20 #define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_DOMAINMAPPER_IMPL_HXX
21 
22 #include <com/sun/star/text/XParagraphCursor.hpp>
23 #include <com/sun/star/text/XTextDocument.hpp>
24 #include <com/sun/star/text/XTextCursor.hpp>
25 #include <com/sun/star/text/XTextAppend.hpp>
26 #include <com/sun/star/text/XTextAppendAndConvert.hpp>
27 #include <com/sun/star/text/XTextFrame.hpp>
28 #include <com/sun/star/style/TabStop.hpp>
29 #include <com/sun/star/container/XNameContainer.hpp>
30 #include <queue>
31 #include <stack>
32 #include <tuple>
33 #include <set>
34 #include <unordered_map>
35 #include <vector>
36 #include <boost/optional.hpp>
37 
38 #include <ooxml/resourceids.hxx>
39 
40 #include "DomainMapper.hxx"
41 #include "DomainMapperTableManager.hxx"
42 #include "DomainMapperTableHandler.hxx"
43 #include "PropertyMap.hxx"
44 #include "FontTable.hxx"
45 #include "NumberingManager.hxx"
46 #include "StyleSheetTable.hxx"
47 #include "SettingsTable.hxx"
48 #include "ThemeTable.hxx"
49 #include "GraphicImport.hxx"
50 #include "OLEHandler.hxx"
51 #include "FFDataHandler.hxx"
52 #include "SmartTagHandler.hxx"
53 #include "FormControlHelper.hxx"
54 #include <map>
55 
56 #include <string.h>
57 
58 namespace com{ namespace sun{ namespace star{
59         namespace awt{
60             struct Size;
61         }
62         namespace lang{
63             class XMultiServiceFactory;
64             struct Locale;
65         }
66         namespace text
67         {
68                 class XTextField;
69                 class XFormField;
70         }
71         namespace beans{ class XPropertySet;}
72 }}}
73 
74 namespace writerfilter {
75 namespace dmapper {
76 
77 class SdtHelper;
78 
79 struct PageMar
80 {
81     sal_Int32 top;
82     sal_Int32 right;
83     sal_Int32 bottom;
84     sal_Int32 left;
85     sal_Int32 header;
86     sal_Int32 footer;
87     public:
88         PageMar();
89 };
90 enum PageMarElement
91 {
92     PAGE_MAR_TOP,
93     PAGE_MAR_RIGHT,
94     PAGE_MAR_BOTTOM,
95     PAGE_MAR_LEFT,
96     PAGE_MAR_HEADER,
97     PAGE_MAR_FOOTER,
98     PAGE_MAR_GUTTER
99 };
100 
101 /// property stack element
102 enum ContextType
103 {
104     CONTEXT_SECTION,
105     CONTEXT_PARAGRAPH,
106     CONTEXT_CHARACTER,
107     CONTEXT_STYLESHEET,
108     CONTEXT_LIST
109 };
110 enum { NUMBER_OF_CONTEXTS = CONTEXT_LIST + 1 };
111 
112 enum BreakType
113 {
114     PAGE_BREAK,
115     COLUMN_BREAK
116 };
117 
118 enum SkipFootnoteSeparator
119 {
120     OFF,
121     ON,
122     SKIPPING
123 };
124 
125 /**
126  * Storage for state that is relevant outside a header/footer, but not inside it.
127  *
128  * In case some state of DomainMapper_Impl should be reset before handling the
129  * header/footer and should be restored once handling of header/footer is done,
130  * then you can use this class to do so.
131  */
132 class HeaderFooterContext
133 {
134     bool const m_bTextInserted;
135 public:
136     explicit HeaderFooterContext(bool bTextInserted);
137     bool getTextInserted() const;
138 };
139 
140 /// Information about a paragraph to be finished after a field end.
141 struct FieldParagraph
142 {
143     PropertyMapPtr m_pPropertyMap;
144     bool m_bRemove = false;
145 };
146 
147 /// field stack element
148 class FieldContext : public virtual SvRefBase
149 {
150     bool m_bFieldCommandCompleted;
151     css::uno::Reference<css::text::XTextRange> m_xStartRange;
152 
153     OUString m_sCommand;
154     OUString m_sResult;
155     boost::optional<FieldId> m_eFieldId;
156     bool m_bFieldLocked;
157 
158     css::uno::Reference<css::text::XTextField> m_xTextField;
159     css::uno::Reference<css::text::XFormField> m_xFormField;
160     css::uno::Reference<css::beans::XPropertySet> m_xTOC;
161     css::uno::Reference<css::beans::XPropertySet> m_xTC; // TOX entry
162     css::uno::Reference<css::beans::XPropertySet> m_xCustomField;
163 
164     OUString m_sHyperlinkURL;
165     /// A frame for the hyperlink when one exists.
166     OUString m_sHyperlinkTarget;
167 
168     FFDataHandler::Pointer_t m_pFFDataHandler;
169     FormControlHelper::Pointer_t m_pFormControlHelper;
170     /// (Character) properties of the field itself.
171     PropertyMapPtr m_pProperties;
172 
173     std::vector<FieldParagraph> m_aParagraphsToFinish;
174 
175 public:
176     explicit FieldContext(css::uno::Reference<css::text::XTextRange> const& xStart);
177     ~FieldContext() override;
178 
GetStartRange() const179     const css::uno::Reference<css::text::XTextRange>& GetStartRange() const { return m_xStartRange; }
180 
181     void                    AppendCommand(const OUString& rPart);
GetCommand() const182     const OUString&  GetCommand() const {return m_sCommand; }
183 
SetFieldId(FieldId eFieldId)184     void SetFieldId(FieldId eFieldId ) { m_eFieldId = eFieldId; }
GetFieldId() const185     boost::optional<FieldId> const & GetFieldId() const { return m_eFieldId; }
186 
AppendResult(OUString const & rResult)187     void AppendResult(OUString const& rResult) { m_sResult += rResult; }
GetResult() const188     const OUString&  GetResult() const { return m_sResult; }
189 
SetCommandCompleted()190     void                    SetCommandCompleted() { m_bFieldCommandCompleted = true; }
IsCommandCompleted() const191     bool                    IsCommandCompleted() const { return m_bFieldCommandCompleted;    }
192 
SetFieldLocked()193     void                    SetFieldLocked() { m_bFieldLocked = true; }
IsFieldLocked() const194     bool                    IsFieldLocked() const { return m_bFieldLocked; }
195 
GetCustomField() const196     const css::uno::Reference<css::beans::XPropertySet>& GetCustomField() const { return m_xCustomField; }
SetCustomField(css::uno::Reference<css::beans::XPropertySet> const & xCustomField)197     void SetCustomField(css::uno::Reference<css::beans::XPropertySet> const& xCustomField) { m_xCustomField = xCustomField; }
GetTextField() const198     const css::uno::Reference<css::text::XTextField>& GetTextField() const { return m_xTextField;}
SetTextField(css::uno::Reference<css::text::XTextField> const & xTextField)199     void SetTextField(css::uno::Reference<css::text::XTextField> const& xTextField) { m_xTextField = xTextField;}
GetFormField() const200     const css::uno::Reference<css::text::XFormField>& GetFormField() const { return m_xFormField;}
SetFormField(css::uno::Reference<css::text::XFormField> const & xFormField)201     void SetFormField(css::uno::Reference<css::text::XFormField> const& xFormField) { m_xFormField = xFormField;}
202 
SetTOC(css::uno::Reference<css::beans::XPropertySet> const & xTOC)203     void SetTOC(css::uno::Reference<css::beans::XPropertySet> const& xTOC) { m_xTOC = xTOC; }
GetTOC() const204     const css::uno::Reference<css::beans::XPropertySet>& GetTOC() const { return m_xTOC; }
205 
SetTC(css::uno::Reference<css::beans::XPropertySet> const & xTC)206     void SetTC(css::uno::Reference<css::beans::XPropertySet> const& xTC) { m_xTC = xTC; }
GetTC() const207     const css::uno::Reference<css::beans::XPropertySet>& GetTC() const { return m_xTC; }
208 
SetHyperlinkURL(const OUString & rURL)209     void  SetHyperlinkURL( const OUString& rURL ) { m_sHyperlinkURL = rURL; }
GetHyperlinkURL() const210     const OUString& GetHyperlinkURL() const { return m_sHyperlinkURL; }
SetHyperlinkTarget(const OUString & rTarget)211     void SetHyperlinkTarget(const OUString& rTarget) { m_sHyperlinkTarget = rTarget; }
GetHyperlinkTarget() const212     const OUString& GetHyperlinkTarget() const { return m_sHyperlinkTarget; }
213 
setFFDataHandler(FFDataHandler::Pointer_t pFFDataHandler)214     void setFFDataHandler(FFDataHandler::Pointer_t pFFDataHandler) { m_pFFDataHandler = pFFDataHandler; }
getFFDataHandler() const215     const FFDataHandler::Pointer_t& getFFDataHandler() const { return m_pFFDataHandler; }
216 
setFormControlHelper(FormControlHelper::Pointer_t pFormControlHelper)217     void setFormControlHelper(FormControlHelper::Pointer_t pFormControlHelper) { m_pFormControlHelper = pFormControlHelper; }
getFormControlHelper() const218     const FormControlHelper::Pointer_t& getFormControlHelper() const { return m_pFormControlHelper; }
getProperties() const219     const PropertyMapPtr& getProperties() const { return m_pProperties; }
220 
221     ::std::vector<OUString> GetCommandParts() const;
222 
GetParagraphsToFinish()223     std::vector<FieldParagraph>& GetParagraphsToFinish() { return m_aParagraphsToFinish; }
224 };
225 
226 struct TextAppendContext
227 {
228     css::uno::Reference<css::text::XTextAppend> xTextAppend;
229     css::uno::Reference<css::text::XTextRange> xInsertPosition;
230     css::uno::Reference<css::text::XParagraphCursor> xCursor;
231     ParagraphPropertiesPtr pLastParagraphProperties;
232 
233     /**
234      * Objects anchored to the current paragraph, may affect the paragraph
235      * spacing.
236      */
237     std::vector<AnchoredObjectInfo> m_aAnchoredObjects;
238 
TextAppendContextwriterfilter::dmapper::TextAppendContext239     TextAppendContext(const css::uno::Reference<css::text::XTextAppend>& xAppend, const css::uno::Reference<css::text::XTextCursor>& xCur)
240         : xTextAppend(xAppend)
241     {
242         xCursor.set(xCur, css::uno::UNO_QUERY);
243         xInsertPosition = xCursor;
244     }
245 };
246 
247 struct AnchoredContext
248 {
249     css::uno::Reference<css::text::XTextContent> xTextContent;
250     bool bToRemove;
251 
AnchoredContextwriterfilter::dmapper::AnchoredContext252     explicit AnchoredContext(const css::uno::Reference<css::text::XTextContent>& xContent)
253         : xTextContent(xContent), bToRemove(false)
254     {
255     }
256 };
257 
258 typedef tools::SvRef<FieldContext>  FieldContextPtr;
259 
260 /*-------------------------------------------------------------------------
261     extended tab stop struct
262   -----------------------------------------------------------------------*/
263 struct DeletableTabStop : public css::style::TabStop
264 {
265     bool bDeleted;
DeletableTabStopwriterfilter::dmapper::DeletableTabStop266     explicit DeletableTabStop()
267         : bDeleted(false)
268     {
269         // same defaults as SvxXMLTabStopContext_Impl
270         FillChar = ' ';
271         DecimalChar = ',';
272     }
DeletableTabStopwriterfilter::dmapper::DeletableTabStop273     DeletableTabStop(const css::style::TabStop& rTabStop)
274         : TabStop(rTabStop),
275         bDeleted(false)
276     {
277     }
278 };
279 /// helper to remember bookmark start position
280 struct BookmarkInsertPosition
281 {
282     bool const                                                       m_bIsStartOfText;
283     OUString                                                         m_sBookmarkName;
284     css::uno::Reference<css::text::XTextRange> m_xTextRange;
BookmarkInsertPositionwriterfilter::dmapper::BookmarkInsertPosition285     BookmarkInsertPosition(bool bIsStartOfText, const OUString& rName, css::uno::Reference<css::text::XTextRange> const& xTextRange):
286         m_bIsStartOfText( bIsStartOfText ),
287         m_sBookmarkName( rName ),
288         m_xTextRange( xTextRange )
289      {}
290 };
291 
292 struct PermInsertPosition
293 {
294     bool const        m_bIsStartOfText;
295     sal_Int32 const   m_Id;
296     OUString    m_Ed;
297     OUString    m_EdGrp;
298 
299     css::uno::Reference<css::text::XTextRange> m_xTextRange;
300 
PermInsertPositionwriterfilter::dmapper::PermInsertPosition301     PermInsertPosition(bool bIsStartOfText, sal_Int32 id, const OUString& ed, const OUString& edGrp, css::uno::Reference<css::text::XTextRange> const& xTextRange)
302         : m_bIsStartOfText(bIsStartOfText)
303         , m_Id(id)
304         , m_Ed(ed)
305         , m_EdGrp(edGrp)
306         , m_xTextRange(xTextRange)
307     {}
308 
createBookmarkNamewriterfilter::dmapper::PermInsertPosition309     OUString createBookmarkName() const
310     {
311         OUString bookmarkName;
312 
313         assert((!m_Ed.isEmpty()) || (!m_EdGrp.isEmpty()));
314 
315         if (m_Ed.isEmpty())
316         {
317             bookmarkName += "permission-for-group:" +
318                 OUString::number(m_Id) +
319                 ":" +
320                 m_EdGrp;
321         }
322         else
323         {
324             bookmarkName += "permission-for-user:" +
325                 OUString::number(m_Id) +
326                 ":" +
327                 m_Ed;
328         }
329 
330         //todo: make sure the name is not used already!
331         return bookmarkName;
332     }
333 };
334 
335 /// Stores the start/end positions of an annotation before its insertion.
336 struct AnnotationPosition
337 {
338     css::uno::Reference<css::text::XTextRange> m_xStart;
339     css::uno::Reference<css::text::XTextRange> m_xEnd;
340 };
341 
342 struct RubyInfo
343 {
344     OUString    sRubyText;
345     OUString    sRubyStyle;
346     sal_uInt32  nSprmId;
347     sal_uInt32  nRubyAlign;
348     sal_uInt32  nHps;
349     sal_uInt32  nHpsBaseText;
350 
RubyInfowriterfilter::dmapper::RubyInfo351     RubyInfo():
352         nSprmId(0),
353         nRubyAlign(0),
354         nHps(0),
355         nHpsBaseText(0)
356     {
357     }
358 };
359 
360 struct LineNumberSettings
361 {
362     sal_Int32   nDistance;
363     sal_Int32   nInterval;
364     bool        bRestartAtEachPage;
LineNumberSettingswriterfilter::dmapper::LineNumberSettings365     LineNumberSettings() :
366          nDistance(-1)
367         ,nInterval(0)
368         ,bRestartAtEachPage(true)
369     {}
370 
371 };
372 
373 /// Contains information about a table that will be potentially converted to a floating one at the section end.
374 struct FloatingTableInfo
375 {
376     css::uno::Reference<css::text::XTextRange> m_xStart;
377     css::uno::Reference<css::text::XTextRange> m_xEnd;
378     css::uno::Sequence<css::beans::PropertyValue> const m_aFrameProperties;
379     sal_Int32 const m_nTableWidth;
380     sal_Int32 const m_nTableWidthType;
381     /// Break type of the section that contains this table.
382     sal_Int32 m_nBreakType = -1;
383 
FloatingTableInfowriterfilter::dmapper::FloatingTableInfo384     FloatingTableInfo(css::uno::Reference<css::text::XTextRange> const& xStart,
385             css::uno::Reference<css::text::XTextRange> const& xEnd,
386             const css::uno::Sequence<css::beans::PropertyValue>& aFrameProperties,
387             sal_Int32 nTableWidth, sal_Int32 nTableWidthType)
388         : m_xStart(xStart),
389         m_xEnd(xEnd),
390         m_aFrameProperties(aFrameProperties),
391         m_nTableWidth(nTableWidth),
392         m_nTableWidthType(nTableWidthType)
393     {
394     }
395     css::uno::Any getPropertyValue(const OUString &propertyName);
396 };
397 
398 /// Stores original/in-file-format info about a single anchored object.
399 struct AnchoredObjectInfo
400 {
401     css::uno::Reference<css::text::XTextContent> m_xAnchoredObject;
402     sal_Int32 m_nLeftMargin = 0;
403 };
404 
405 /// Stores info about objects anchored to a given paragraph.
406 struct AnchoredObjectsInfo
407 {
408     css::uno::Reference<css::text::XTextRange> m_xParagraph;
409     std::vector<AnchoredObjectInfo> m_aAnchoredObjects;
410 };
411 
412 struct SymbolData
413 {
414     sal_Unicode cSymbol;
415     OUString    sFont;
SymbolDatawriterfilter::dmapper::SymbolData416     SymbolData():
417         cSymbol(),
418         sFont()
419     { }
420 };
421 
422 class DomainMapper;
423 class DomainMapper_Impl final
424 {
425 public:
426     typedef std::map < OUString, BookmarkInsertPosition > BookmarkMap_t;
427     typedef std::map < sal_Int32, PermInsertPosition >    PermMap_t;
428 
429 private:
430     SourceDocumentType const                                                        m_eDocumentType;
431     DomainMapper&                                                                   m_rDMapper;
432     OUString m_aBaseUrl;
433     css::uno::Reference<css::text::XTextDocument> m_xTextDocument;
434     css::uno::Reference<css::beans::XPropertySet> m_xDocumentSettings;
435     css::uno::Reference<css::lang::XMultiServiceFactory> m_xTextFactory;
436     css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
437     css::uno::Reference<css::container::XNameContainer> m_xPageStyles1;
438     // cache next available number, expensive to repeatedly compute
439     boost::optional<int> m_xNextUnusedPageStyleNo;
440     css::uno::Reference<css::text::XText> m_xBodyText;
441     css::uno::Reference<css::text::XTextContent> m_xEmbedded;
442 
443     std::stack<TextAppendContext>                                                   m_aTextAppendStack;
444     std::stack<AnchoredContext>                                                     m_aAnchoredStack;
445     std::stack<HeaderFooterContext>                                                 m_aHeaderFooterStack;
446     std::deque<FieldContextPtr> m_aFieldStack;
447     bool m_bForceGenericFields;
448     bool                                                                            m_bSetUserFieldContent;
449     bool                                                                            m_bSetCitation;
450     bool                                                                            m_bSetDateValue;
451     bool                                                                            m_bIsFirstSection;
452     bool                                                                            m_bIsColumnBreakDeferred;
453     bool                                                                            m_bIsPageBreakDeferred;
454     /// If we want to set "sdt end" on the next character context.
455     bool                                                                            m_bSdtEndDeferred;
456     /// If we want to set "paragraph sdt end" on the next paragraph context.
457     bool                                                                            m_bParaSdtEndDeferred;
458     bool                                                                            m_bStartTOC;
459     bool                                                                            m_bStartTOCHeaderFooter;
460     /// If we got any text that is the pre-rendered result of the TOC field.
461     bool                                                                            m_bStartedTOC;
462     bool                                                                            m_bStartIndex;
463     bool                                                                            m_bStartBibliography;
464     unsigned int                                                                    m_nStartGenericField;
465     bool                                                                            m_bTextInserted;
466     LineNumberSettings                                                              m_aLineNumberSettings;
467 
468     BookmarkMap_t                                                                   m_aBookmarkMap;
469     OUString                                                                        m_sCurrentBkmkId;
470     OUString                                                                        m_sCurrentBkmkName;
471 
472     PermMap_t                                                                       m_aPermMap;
473     sal_Int32                                                                       m_sCurrentPermId;
474     OUString                                                                        m_sCurrentPermEd;
475     OUString                                                                        m_sCurrentPermEdGrp;
476 
477     PageMar                                                                        m_aPageMargins;
478     SymbolData                                                                      m_aSymbolData;
479 
480     // TableManagers are stacked: one for each stream to avoid any confusion
481     std::stack< tools::SvRef< DomainMapperTableManager > > m_aTableManagers;
482     tools::SvRef<DomainMapperTableHandler> m_pTableHandler;
483     // List of document lists overrides. They are applied only once on first occurrence in document
484     std::set<sal_Int32> m_aListOverrideApplied;
485 
486     //each context needs a stack of currently used attributes
487     std::stack<PropertyMapPtr>  m_aPropertyStacks[NUMBER_OF_CONTEXTS];
488     std::stack<ContextType> m_aContextStack;
489     FontTablePtr            m_pFontTable;
490     ListsManager::Pointer   m_pListTable;
491     std::deque< css::uno::Reference<css::drawing::XShape> > m_aPendingShapes;
492     StyleSheetTablePtr      m_pStyleSheetTable;
493     ThemeTablePtr           m_pThemeTable;
494     SettingsTablePtr        m_pSettingsTable;
495     GraphicImportPtr        m_pGraphicImport;
496 
497 
498     PropertyMapPtr                  m_pTopContext;
499     PropertyMapPtr           m_pLastSectionContext;
500     PropertyMapPtr           m_pLastCharacterContext;
501 
502     ::std::vector<DeletableTabStop> m_aCurrentTabStops;
503     OUString                        m_sCurrentParaStyleName; //highly inaccurate. Overwritten by "overlapping" paragraphs like comments, flys.
504     OUString                        m_sDefaultParaStyleName; //caches the ConvertedStyleName of the default paragraph style
505     bool                            m_bInStyleSheetImport; //in import of fonts, styles, lists or lfos
506     bool                            m_bInAnyTableImport; //in import of fonts, styles, lists or lfos
507     enum class HeaderFooterImportState
508     {
509         none,
510         header,
511         footer,
512     }                               m_eInHeaderFooterImport;
513     bool                            m_bDiscardHeaderFooter;
514     bool                            m_bInFootOrEndnote;
515     PropertyMapPtr m_pFootnoteContext;
516     bool m_bHasFootnoteStyle;
517     bool m_bCheckFootnoteStyle;
518     /// Skip paragraphs from the <w:separator/> footnote
519     SkipFootnoteSeparator           m_eSkipFootnoteState;
520 
521     bool                            m_bLineNumberingSet;
522     bool                            m_bIsInFootnoteProperties;
523 
524     RubyInfo                        m_aRubyInfo;
525     //registered frame properties
526     std::vector<css::beans::PropertyValue> m_aFrameProperties;
527     css::uno::Reference<css::text::XTextRange> m_xFrameStartRange;
528     css::uno::Reference<css::text::XTextRange> m_xFrameEndRange;
529 
530     // Redline stack
531     std::stack< std::vector< RedlineParamsPtr > > m_aRedlines;
532     // The redline currently read, may be also stored by a context instead of m_aRedlines.
533     RedlineParamsPtr                m_currentRedline;
534     RedlineParamsPtr                m_previousRedline;
535     RedlineParamsPtr                m_pParaMarkerRedline;
536     bool                            m_bIsParaMarkerChange;
537     // redline data of the terminating run, if it's a moveFrom deletion
538     RedlineParamsPtr                m_pParaMarkerRedlineMoveFrom;
539 
540     /// If the current paragraph has any runs.
541     bool                            m_bParaChanged;
542     bool                            m_bIsFirstParaInSection;
543     bool                            m_bIsFirstParaInSectionAfterRedline;
544     bool                            m_bIsFirstParaInShape = false;
545     bool                            m_bDummyParaAddedForTableInSection;
546     bool                            m_bTextFrameInserted;
547     bool                            m_bIsPreviousParagraphFramed;
548     bool                            m_bIsLastParaInSection;
549     bool                            m_bIsLastSectionGroup;
550     bool                            m_bIsInComments;
551     /// If the current paragraph contains section property definitions.
552     bool                            m_bParaSectpr;
553     bool                            m_bUsingEnhancedFields;
554     /// If the current paragraph is inside a structured document element.
555     bool                            m_bSdt;
556     bool                            m_bIsFirstRun;
557     bool                            m_bIsOutsideAParagraph;
558     /// This is a continuation of already finished paragraph - e.g., first in an index section
559     bool                            m_bRemoveThisParagraph = false;
560 
561     css::uno::Reference< css::text::XTextCursor > xTOCMarkerCursor;
562     css::uno::Reference< css::text::XTextCursor > mxTOCTextCursor;
563 
564     //annotation import
565     css::uno::Reference< css::beans::XPropertySet > m_xAnnotationField;
566     sal_Int32 m_nAnnotationId;
567     std::unordered_map< sal_Int32, AnnotationPosition > m_aAnnotationPositions;
568 
569     void GetCurrentLocale(css::lang::Locale& rLocale);
570     void SetNumberFormat(const OUString& rCommand, css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, bool bDetectFormat = false);
571     /// @throws css::uno::Exception
572     css::uno::Reference<css::beans::XPropertySet> FindOrCreateFieldMaster(const sal_Char* pFieldMasterService, const OUString& rFieldMasterName);
573     css::uno::Reference<css::beans::XPropertySet> const & GetDocumentSettings();
574 
575     std::map<sal_Int32, css::uno::Any> deferredCharacterProperties;
576     SmartTagHandler m_aSmartTagHandler;
577 
578     css::uno::Reference<css::text::XTextRange> m_xGlossaryEntryStart;
579     css::uno::Reference<css::text::XTextRange> m_xStdEntryStart;
580 
581 public:
582     css::uno::Reference<css::text::XTextRange> m_xInsertTextRange;
583 private:
584     bool const m_bIsNewDoc;
585     bool const m_bIsReadGlossaries;
586 public:
587     DomainMapper_Impl(
588             DomainMapper& rDMapper,
589             css::uno::Reference < css::uno::XComponentContext > const& xContext,
590             css::uno::Reference< css::lang::XComponent > const& xModel,
591             SourceDocumentType eDocumentType,
592             utl::MediaDescriptor const & rMediaDesc);
593     ~DomainMapper_Impl();
594 
GetLastSectionContext()595     SectionPropertyMap* GetLastSectionContext( )
596     {
597         return dynamic_cast< SectionPropertyMap* >( m_pLastSectionContext.get( ) );
598     }
599 
600     css::uno::Reference<css::container::XNameContainer> const & GetPageStyles();
601     OUString GetUnusedPageStyleName();
602     css::uno::Reference<css::text::XText> const & GetBodyText();
GetTextFactory() const603     const css::uno::Reference<css::lang::XMultiServiceFactory>& GetTextFactory() const
604     {
605         return m_xTextFactory;
606     }
GetTextDocument() const607     const css::uno::Reference<css::text::XTextDocument>& GetTextDocument() const
608     {
609         return m_xTextDocument;
610     }
611     void SetDocumentSettingsProperty( const OUString& rPropName, const css::uno::Any& rValue );
612 
613     void CreateRedline(css::uno::Reference<css::text::XTextRange> const& xRange, const RedlineParamsPtr& pRedline);
614 
615     void CheckParaMarkerRedline(css::uno::Reference<css::text::XTextRange> const& xRange);
616 
617     void CheckRedline(css::uno::Reference<css::text::XTextRange> const& xRange);
618 
619     void StartParaMarkerChange( );
620     void EndParaMarkerChange( );
621     void ChainTextFrames();
622 
623     void RemoveDummyParaForTableInSection();
624     void AddDummyParaForTableInSection();
625     void RemoveLastParagraph( );
626     void SetIsLastParagraphInSection( bool bIsLast );
GetIsLastParagraphInSection() const627     bool GetIsLastParagraphInSection() const { return m_bIsLastParaInSection;}
SetRubySprmId(sal_uInt32 nSprmId)628     void SetRubySprmId( sal_uInt32 nSprmId) { m_aRubyInfo.nSprmId = nSprmId ; }
SetRubyText(OUString const & sText,OUString const & sStyle)629     void SetRubyText( OUString const &sText, OUString const &sStyle) {
630         m_aRubyInfo.sRubyText = sText;
631         m_aRubyInfo.sRubyStyle = sStyle;
632     }
GetRubyInfo() const633     const RubyInfo & GetRubyInfo() const { return m_aRubyInfo;}
SetRubyInfo(const RubyInfo & rInfo)634     void SetRubyInfo(const RubyInfo & rInfo) { m_aRubyInfo = rInfo;}
635 
636     void SetIsLastSectionGroup( bool bIsLast );
GetIsLastSectionGroup() const637     bool GetIsLastSectionGroup() const { return m_bIsLastSectionGroup;}
638     void SetIsFirstParagraphInSection( bool bIsFirst );
639     void SetIsFirstParagraphInSectionAfterRedline( bool bIsFirstAfterRedline );
640     bool GetIsFirstParagraphInSection( bool bAfterRedline = false ) const;
641     void SetIsFirstParagraphInShape(bool bIsFirst);
GetIsFirstParagraphInShape() const642     bool GetIsFirstParagraphInShape() const { return m_bIsFirstParaInShape; }
643     void SetIsDummyParaAddedForTableInSection( bool bIsAdded );
GetIsDummyParaAddedForTableInSection() const644     bool GetIsDummyParaAddedForTableInSection() const { return m_bDummyParaAddedForTableInSection;}
645 
646     /// Track if a textframe has been inserted into this section
647     void SetIsTextFrameInserted( bool bIsInserted );
GetIsTextFrameInserted() const648     bool GetIsTextFrameInserted() const { return m_bTextFrameInserted;}
649 
SetIsPreviousParagraphFramed(bool bIsFramed)650     void SetIsPreviousParagraphFramed( bool bIsFramed ) { m_bIsPreviousParagraphFramed = bIsFramed; }
GetIsPreviousParagraphFramed() const651     bool GetIsPreviousParagraphFramed() const { return m_bIsPreviousParagraphFramed; }
652     void SetParaSectpr(bool bParaSectpr);
GetParaSectpr() const653     bool GetParaSectpr() const { return m_bParaSectpr;}
654 
SetSymbolChar(sal_Int32 nSymbol)655     void SetSymbolChar( sal_Int32 nSymbol) { m_aSymbolData.cSymbol = sal_Unicode(nSymbol); }
SetSymbolFont(OUString const & rName)656     void SetSymbolFont( OUString const &rName ) { m_aSymbolData.sFont = rName; }
GetSymbolData() const657     const SymbolData & GetSymbolData() const { return m_aSymbolData;}
658 
659     /// Setter method for m_bSdt.
660     void SetSdt(bool bSdt);
661     /// Getter method for m_bSdt.
GetSdt() const662     bool GetSdt() const { return m_bSdt;}
GetParaChanged() const663     bool GetParaChanged() const { return m_bParaChanged;}
GetRemoveThisPara() const664     bool GetRemoveThisPara() const { return m_bRemoveThisParagraph; }
665 
666     void deferBreak( BreakType deferredBreakType );
667     bool isBreakDeferred( BreakType deferredBreakType );
668     void clearDeferredBreaks();
669     void clearDeferredBreak(BreakType deferredBreakType);
670 
671     void setSdtEndDeferred(bool bSdtEndDeferred);
672     bool isSdtEndDeferred() const;
673     void setParaSdtEndDeferred(bool bParaSdtEndDeferred);
674     bool isParaSdtEndDeferred() const;
675 
676     void finishParagraph( const PropertyMapPtr& pPropertyMap, const bool bRemove = false);
677     void appendTextPortion( const OUString& rString, const PropertyMapPtr& pPropertyMap );
678     void appendTextContent(const css::uno::Reference<css::text::XTextContent>&, const css::uno::Sequence<css::beans::PropertyValue>&);
679     void appendOLE( const OUString& rStreamName, const std::shared_ptr<OLEHandler>& pOleHandler );
680     void appendStarMath( const Value& v );
681     css::uno::Reference<css::beans::XPropertySet> appendTextSectionAfter(css::uno::Reference<css::text::XTextRange> const & xBefore);
682 
683     /// AutoText import: each entry is placed in the separate section
684     void appendGlossaryEntry();
685     /// Remember where entry was started
setGlossaryEntryStart(css::uno::Reference<css::text::XTextRange> const & xStart)686     void setGlossaryEntryStart( css::uno::Reference<css::text::XTextRange> const & xStart )
687     {
688         m_xGlossaryEntryStart = xStart;
689     }
690 
691     // push the new properties onto the stack and make it the 'current' property map
692     void    PushProperties(ContextType eId);
693     void    PushStyleProperties(const PropertyMapPtr& pStyleProperties);
694     void    PushListProperties(const PropertyMapPtr& pListProperties);
695     void    PopProperties(ContextType eId);
696 
GetTopContextType() const697     ContextType GetTopContextType() const { return m_aContextStack.top(); }
GetTopContext() const698     const PropertyMapPtr& GetTopContext() const
699     {
700         return m_pTopContext;
701     }
702     PropertyMapPtr GetTopContextOfType(ContextType eId);
703 
704     bool HasTopText() const;
705     css::uno::Reference<css::text::XTextAppend> const & GetTopTextAppend();
706     FieldContextPtr const & GetTopFieldContext();
707 
GetFontTable()708     FontTablePtr const & GetFontTable()
709     {
710         if(!m_pFontTable)
711             m_pFontTable = new FontTable();
712         return m_pFontTable;
713     }
GetStyleSheetTable()714     StyleSheetTablePtr const & GetStyleSheetTable()
715     {
716         if(!m_pStyleSheetTable)
717             m_pStyleSheetTable = new StyleSheetTable( m_rDMapper, m_xTextDocument, m_bIsNewDoc );
718         return m_pStyleSheetTable;
719     }
720     ListsManager::Pointer const & GetListTable();
GetThemeTable()721     ThemeTablePtr const & GetThemeTable()
722     {
723         if(!m_pThemeTable)
724             m_pThemeTable = new ThemeTable;
725         return m_pThemeTable;
726     }
727 
GetSettingsTable()728     SettingsTablePtr const & GetSettingsTable()
729     {
730         if( !m_pSettingsTable )
731             m_pSettingsTable = new SettingsTable(m_rDMapper);
732         return m_pSettingsTable;
733     }
734 
735     GraphicImportPtr const & GetGraphicImport( GraphicImportType eGraphicImportType );
736     void            ResetGraphicImport();
737     // this method deletes the current m_pGraphicImport after import
738     void    ImportGraphic(const writerfilter::Reference< Properties>::Pointer_t&, GraphicImportType eGraphicImportType );
739 
740     void InitTabStopFromStyle(const css::uno::Sequence<css::style::TabStop>& rInitTabStops);
741     void    IncorporateTabStop( const DeletableTabStop &aTabStop );
742     css::uno::Sequence<css::style::TabStop> GetCurrentTabStopAndClear();
743 
SetCurrentParaStyleName(const OUString & sStringValue)744     void            SetCurrentParaStyleName(const OUString& sStringValue) {m_sCurrentParaStyleName = sStringValue;}
745     OUString  GetCurrentParaStyleName();
746     OUString  GetDefaultParaStyleName();
747 
748     // specified style - including inherited properties. Indicate whether paragraph defaults should be checked.
749     css::uno::Any GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bDocDefaults, const bool bPara);
750     // current paragraph style - including inherited properties
751     css::uno::Any GetPropertyFromParaStyleSheet(PropertyIds eId);
752     // context's character style - including inherited properties
753     css::uno::Any GetPropertyFromCharStyleSheet(PropertyIds eId, const PropertyMapPtr& rContext);
754     // get property first from the given context, or secondly via inheritance from styles/docDefaults
755     css::uno::Any GetAnyProperty(PropertyIds eId, const PropertyMapPtr& rContext);
SetStyleSheetImport(bool bSet)756     void        SetStyleSheetImport( bool bSet ) { m_bInStyleSheetImport = bSet;}
IsStyleSheetImport() const757     bool        IsStyleSheetImport()const { return m_bInStyleSheetImport;}
SetAnyTableImport(bool bSet)758     void        SetAnyTableImport( bool bSet ) { m_bInAnyTableImport = bSet;}
IsAnyTableImport() const759     bool        IsAnyTableImport()const { return m_bInAnyTableImport;}
IsInShape() const760     bool        IsInShape()const { return m_aAnchoredStack.size() > 0;}
761 
762     void PushShapeContext(const css::uno::Reference<css::drawing::XShape>& xShape);
763     void PopShapeContext();
764     void UpdateEmbeddedShapeProps(const css::uno::Reference<css::drawing::XShape>& xShape);
765     /// Add a pending shape: it's currently inserted into the document, but it should be removed before the import finishes.
766     void PushPendingShape(const css::uno::Reference<css::drawing::XShape>& xShape);
767     /// Get the first pending shape, if there are any.
768     css::uno::Reference<css::drawing::XShape> PopPendingShape();
769 
770     void PushPageHeader(SectionPropertyMap::PageType eType);
771     void PushPageFooter(SectionPropertyMap::PageType eType);
772 
773     void PopPageHeaderFooter();
IsInHeaderFooter() const774     bool IsInHeaderFooter() const { return m_eInHeaderFooterImport != HeaderFooterImportState::none; }
775 
IsInTOC() const776     bool IsInTOC() const { return m_bStartTOC; }
777 
778     void PushFootOrEndnote( bool bIsFootnote );
779     void PopFootOrEndnote();
IsInFootOrEndnote() const780     bool IsInFootOrEndnote() const { return m_bInFootOrEndnote; }
781 
782     void StartCustomFootnote(const PropertyMapPtr pContext);
783     void EndCustomFootnote();
IsInCustomFootnote() const784     bool IsInCustomFootnote() const { return m_bHasFootnoteStyle; }
CheckFootnoteStyle() const785     bool CheckFootnoteStyle() const { return m_bCheckFootnoteStyle; }
SetHasFootnoteStyle(bool bVal)786     void SetHasFootnoteStyle(bool bVal) { m_bHasFootnoteStyle = bVal; }
SetCheckFootnoteStyle(bool bVal)787     void SetCheckFootnoteStyle(bool bVal) { m_bCheckFootnoteStyle = bVal; }
788 
GetFootnoteContext() const789     const PropertyMapPtr& GetFootnoteContext() const { return m_pFootnoteContext; }
790 
GetSkipFootnoteState() const791     SkipFootnoteSeparator GetSkipFootnoteState() const { return m_eSkipFootnoteState; }
SetSkipFootnoteState(SkipFootnoteSeparator eId)792     void SetSkipFootnoteState(SkipFootnoteSeparator eId) { m_eSkipFootnoteState =  eId; }
793 
794     void PushAnnotation();
795     void PopAnnotation();
796 
797     /// A field context starts with a cFieldStart.
798     void PushFieldContext();
799     //the current field context waits for the completion of the command
800     bool IsOpenFieldCommand() const;
801     bool IsOpenField() const;
802     //mark field in current context as locked (fixed)
803     void SetFieldLocked();
804     //collect the pieces of the command
805     void AppendFieldCommand(OUString const & rPartOfCommand);
806     void handleRubyEQField( const FieldContextPtr& pContext);
807     void handleFieldSet
808         (const FieldContextPtr& pContext,
809         css::uno::Reference< css::uno::XInterface > const & xFieldInterface,
810         css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties);
811     void handleFieldAsk
812         (const FieldContextPtr& pContext,
813         css::uno::Reference< css::uno::XInterface > & xFieldInterface,
814         css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties);
815     static void handleFieldFormula
816         (const FieldContextPtr& pContext,
817         css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties);
818     void handleAutoNum
819         (const FieldContextPtr& pContext,
820         css::uno::Reference< css::uno::XInterface > const & xFieldInterface,
821         css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties);
822     static void handleAuthor
823         (OUString const& rFirstParam,
824         css::uno::Reference< css::beans::XPropertySet > const& xFieldProperties,
825         FieldId eFieldId);
826     void handleDocProperty
827         (const FieldContextPtr& pContext,
828         OUString const& rFirstParam,
829         css::uno::Reference< css::uno::XInterface > & xFieldInterface);
830     void handleToc
831         (const FieldContextPtr& pContext,
832         const OUString & sTOCServiceName);
833     void handleIndex
834         (const FieldContextPtr& pContext,
835         const OUString & sTOCServiceName);
836 
837     void handleBibliography
838         (const FieldContextPtr& pContext,
839         const OUString & sTOCServiceName);
840     /// The field command has to be closed (cFieldSep appeared).
841     void CloseFieldCommand();
842     //the _current_ fields require a string type result while TOCs accept richt results
843     bool IsFieldResultAsString();
844     void AppendFieldResult(OUString const& rResult);
845     //apply the result text to the related field
846     void SetFieldResult(OUString const& rResult);
847     // set FFData of top field context
848     void SetFieldFFData( const FFDataHandler::Pointer_t& pFFDataHandler );
849     /// The end of field is reached (cFieldEnd appeared) - the command might still be open.
850     void PopFieldContext();
851 
852     /// Returns title of the TOC placed in paragraph(s) before TOC field inside STD-frame
853     OUString extractTocTitle();
854     css::uno::Reference<css::beans::XPropertySet> createSectionForRange(css::uno::Reference< css::text::XTextRange > xStart, css::uno::Reference< css::text::XTextRange > xEnd, const OUString & sObjectType, bool stepLeft);
855 
856     void SetBookmarkName( const OUString& rBookmarkName );
857     void StartOrEndBookmark( const OUString& rId );
858 
859     void setPermissionRangeEd(const OUString& user);
860     void setPermissionRangeEdGrp(const OUString& group);
861     void startOrEndPermissionRange(sal_Int32 permissinId);
862 
863     void AddAnnotationPosition(
864         const bool bStart,
865         const sal_Int32 nAnnotationId );
866 
hasTableManager() const867     bool hasTableManager() const
868     {
869         return !m_aTableManagers.empty();
870     }
871 
getTableManager()872     DomainMapperTableManager& getTableManager()
873     {
874         return *m_aTableManagers.top();
875     }
876 
appendTableManager()877     void appendTableManager( )
878     {
879         tools::SvRef<DomainMapperTableManager> pMngr(new DomainMapperTableManager());
880         m_aTableManagers.push( pMngr );
881     }
882 
appendTableHandler()883     void appendTableHandler( )
884     {
885         if (m_pTableHandler.get())
886             m_aTableManagers.top()->setHandler(m_pTableHandler);
887     }
888 
popTableManager()889     void popTableManager( )
890     {
891         if (hasTableManager())
892             m_aTableManagers.pop();
893     }
894 
895     void SetLineNumbering( sal_Int32 nLnnMod, sal_uInt32 nLnc, sal_Int32 ndxaLnn );
IsLineNumberingSet() const896     bool IsLineNumberingSet() const {return m_bLineNumberingSet;}
897 
898     DeletableTabStop                m_aCurrentTabStop;
899 
900     /// If we're right after the end of a table.
901     bool m_bConvertedTable = false;
902 
IsOOXMLImport() const903     bool IsOOXMLImport() const { return m_eDocumentType == SourceDocumentType::OOXML; }
904 
IsRTFImport() const905     bool IsRTFImport() const { return m_eDocumentType == SourceDocumentType::RTF; }
906 
InitPageMargins()907     void InitPageMargins() { m_aPageMargins = PageMar(); }
908     void SetPageMarginTwip( PageMarElement eElement, sal_Int32 nValue );
GetPageMargins() const909     const PageMar& GetPageMargins() const {return m_aPageMargins;}
910 
GetLineNumberSettings() const911     const LineNumberSettings& GetLineNumberSettings() const { return m_aLineNumberSettings;}
SetLineNumberSettings(const LineNumberSettings & rSet)912     void SetLineNumberSettings(const LineNumberSettings& rSet) { m_aLineNumberSettings = rSet;}
913 
SetInFootnoteProperties(bool bSet)914     void SetInFootnoteProperties(bool bSet) { m_bIsInFootnoteProperties = bSet;}
IsInFootnoteProperties() const915     bool IsInFootnoteProperties() const { return m_bIsInFootnoteProperties;}
916 
IsInComments() const917     bool IsInComments() const { return m_bIsInComments; };
918 
919     void CheckUnregisteredFrameConversion( );
920 
921     void RegisterFrameConversion(css::uno::Reference<css::text::XTextRange> const& xFrameStartRange,
922                                  css::uno::Reference<css::text::XTextRange> const& xFrameEndRange,
923                                  const std::vector<css::beans::PropertyValue>& aFrameProperties);
924     void ExecuteFrameConversion();
925 
926     void AddNewRedline( sal_uInt32 sprmId );
927 
928     sal_Int32 GetCurrentRedlineToken( ) const;
929     void SetCurrentRedlineAuthor( const OUString& sAuthor );
930     void SetCurrentRedlineDate( const OUString& sDate );
931     void SetCurrentRedlineId( sal_Int32 nId );
932     void SetCurrentRedlineToken( sal_Int32 nToken );
933     void SetCurrentRedlineRevertProperties( const css::uno::Sequence<css::beans::PropertyValue>& aProperties );
934     void SetCurrentRedlineIsRead();
935     void RemoveTopRedline( );
936     void SetCurrentRedlineInitials( const OUString& sInitials );
IsFirstRun() const937     bool IsFirstRun() const { return m_bIsFirstRun;}
SetIsFirstRun(bool bval)938     void SetIsFirstRun(bool bval) { m_bIsFirstRun = bval;}
IsOutsideAParagraph() const939     bool IsOutsideAParagraph() const { return m_bIsOutsideAParagraph;}
SetIsOutsideAParagraph(bool bval)940     void SetIsOutsideAParagraph(bool bval) { m_bIsOutsideAParagraph = bval;}
941 
942     void ApplySettingsTable();
943 
GetCurrentXText()944     css::uno::Reference<css::text::XTextAppend> GetCurrentXText() {
945         return m_aTextAppendStack.empty() ? nullptr : m_aTextAppendStack.top().xTextAppend;
946     }
947 
948     SectionPropertyMap * GetSectionContext();
949     /// If the current paragraph has a numbering style associated, this method returns its character style (part of the numbering rules)
950     css::uno::Reference<css::beans::XPropertySet> GetCurrentNumberingCharStyle();
951     /// If the current paragraph has a numbering style associated, this method returns its numbering rules
952     css::uno::Reference<css::container::XIndexAccess> GetCurrentNumberingRules(sal_Int32* pListLevel);
953 
954     /**
955      Used for attributes/sprms which cannot be evaluated immediately (e.g. they depend
956      on another one that comes in the same CONTEXT_CHARACTER). The property will be processed
957      again in DomainMapper::processDeferredCharacterProperties().
958     */
959     void deferCharacterProperty(sal_Int32 id, const css::uno::Any& value);
960     /**
961      Processes properties deferred using deferCharacterProperty(). To be called whenever the top
962      CONTEXT_CHARACTER is going to be used (e.g. by appendText()).
963     */
964     void processDeferredCharacterProperties();
965 
966     sal_Int32 getNumberingProperty(const sal_Int32 nListId, sal_Int32 nListLevel, const OUString& aProp);
967     /// Get a property of the current numbering style's current level.
968     sal_Int32 getCurrentNumberingProperty(const OUString& aProp);
969 
970     /// If we're importing into a new document, or just pasting to an existing one.
IsNewDoc() const971     bool IsNewDoc() const { return m_bIsNewDoc;}
972 
973     /// If we're importing autotext.
IsReadGlossaries() const974     bool IsReadGlossaries() const { return m_bIsReadGlossaries;}
975 
976     /// If we're inside <w:rPr>, inside <w:style w:type="table">
977     bool m_bInTableStyleRunProps;
978 
979     tools::SvRef<SdtHelper> m_pSdtHelper;
980 
981     /// Document background color, applied to every page style.
982     boost::optional<sal_Int32> m_oBackgroundColor;
983 
984     /**
985      * This contains the raw table depth. m_nTableDepth > 0 is the same as
986      * getTableManager().isInTable(), unless we're in the first paragraph of a
987      * table, or first paragraph after a table, as the table manager is only
988      * updated once we ended the paragraph (and know if the para has the
989      * inTbl SPRM or not).
990      */
991     sal_Int32 m_nTableDepth;
992     /// Raw table cell depth.
993     sal_Int32 m_nTableCellDepth;
994     /// Table cell depth of the last finished paragraph.
995     sal_Int32 m_nLastTableCellParagraphDepth;
996 
997     /// If the current section has footnotes.
998     bool m_bHasFtn;
999     /// If the current section has a footnote separator.
1000     bool m_bHasFtnSep;
1001 
1002     /// If the next tab should be ignored, used for footnotes.
1003     bool m_bCheckFirstFootnoteTab;
1004     bool m_bIgnoreNextTab;
1005     /// Pending floating tables: they may be converted to text frames at the section end.
1006     std::vector<FloatingTableInfo> m_aPendingFloatingTables;
1007 
1008     /// Paragraphs with anchored objects in the current section.
1009     std::vector<AnchoredObjectsInfo> m_aAnchoredObjectAnchors;
1010 
1011     /// Append a property to a sub-grabbag if necessary (e.g. 'lineRule', 'auto')
1012     void appendGrabBag(std::vector<css::beans::PropertyValue>& rInteropGrabBag, const OUString& aKey, const OUString& aValue);
1013     void appendGrabBag(std::vector<css::beans::PropertyValue>& rInteropGrabBag, const OUString& aKey, std::vector<css::beans::PropertyValue>& rValue);
1014 
1015     /// Enable, disable and check status of grabbags
1016     void enableInteropGrabBag(const OUString& aName);
1017     void disableInteropGrabBag();
1018     bool isInteropGrabBagEnabled() const;
1019 
1020     /// Name of m_aInteropGrabBag.
1021     OUString m_aInteropGrabBagName;
1022 
1023     /// A toplevel dmapper grabbag, like 'pPr'.
1024     std::vector<css::beans::PropertyValue> m_aInteropGrabBag;
1025 
1026     /// A sub-grabbag of m_aInteropGrabBag, like 'spacing'.
1027     std::vector<css::beans::PropertyValue> m_aSubInteropGrabBag;
1028 
1029     /// ST_PositionOffset values we received
1030     std::pair<OUString, OUString> m_aPositionOffsets;
1031     /// ST_AlignH/V values we received
1032     std::pair<OUString, OUString> m_aAligns;
1033     /// ST_PositivePercentage values we received
1034     std::queue<OUString> m_aPositivePercentages;
isInIndexContext() const1035     bool isInIndexContext() const { return m_bStartIndex;}
isInBibliographyContext() const1036     bool isInBibliographyContext() const { return m_bStartBibliography;}
getSmartTagHandler()1037     SmartTagHandler& getSmartTagHandler() { return m_aSmartTagHandler; }
1038 
1039     void substream(Id rName, ::writerfilter::Reference<Stream>::Pointer_t const& ref);
1040 
1041     /// If the document needs to split paragraph.
1042     bool m_bIsSplitPara;
1043 
1044     /// Check if "SdtEndBefore" property is set
1045     bool IsSdtEndBefore();
1046 
1047     bool IsDiscardHeaderFooter() const;
1048 
IsForceGenericFields() const1049     bool IsForceGenericFields() const { return m_bForceGenericFields; }
1050 
SetParaAutoBefore(bool bParaAutoBefore)1051     void SetParaAutoBefore(bool bParaAutoBefore) { m_bParaAutoBefore = bParaAutoBefore; }
1052 
1053     /// Forget about the previous paragraph, as it's not inside the same
1054     /// start/end node.
1055     void ClearPreviousParagraph();
1056 
1057     /// Handle redline text portions in frames:
1058     /// store their data, and create them after frame creation
1059     bool m_bIsActualParagraphFramed;
1060     std::vector<css::uno::Any> aFramedRedlines;
1061 
1062 private:
1063     void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType);
1064     // Start a new index section; if needed, finish current paragraph
1065     css::uno::Reference<css::beans::XPropertySet> StartIndexSectionChecked(const OUString& sServiceName);
1066     std::vector<css::uno::Reference< css::drawing::XShape > > m_vTextFramesForChaining ;
1067     /// Current paragraph had at least one field in it.
1068     bool m_bParaHadField;
1069     css::uno::Reference<css::beans::XPropertySet> m_xPreviousParagraph;
1070     /// Current paragraph has automatic before spacing.
1071     bool m_bParaAutoBefore;
1072     /// Current paragraph in a table is first paragraph of a cell
1073     bool m_bFirstParagraphInCell;
1074     bool m_bSaveFirstParagraphInCell;
1075 };
1076 
1077 } //namespace dmapper
1078 } //namespace writerfilter
1079 #endif
1080 
1081 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1082