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 .
19 #ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_DOMAINMAPPER_IMPL_HXX
20 #define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_DOMAINMAPPER_IMPL_HXX
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 <unotools/saveopt.hxx>
34 #include <unordered_map>
36 #include <boost/optional.hpp>
38 #include <ooxml/resourceids.hxx>
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"
58 namespace com
{ namespace sun
{ namespace star
{
63 class XMultiServiceFactory
;
71 namespace beans
{ class XPropertySet
;}
74 namespace writerfilter
{
101 /// property stack element
110 enum { NUMBER_OF_CONTEXTS
= CONTEXT_LIST
+ 1 };
119 * Storage for state that is relevant outside a header/footer, but not inside it.
121 * In case some state of DomainMapper_Impl should be reset before handling the
122 * header/footer and should be restored once handling of header/footer is done,
123 * then you can use this class to do so.
125 class HeaderFooterContext
127 bool const m_bTextInserted
;
129 explicit HeaderFooterContext(bool bTextInserted
);
130 bool getTextInserted();
133 /// field stack element
134 class FieldContext
: public virtual SvRefBase
136 bool m_bFieldCommandCompleted
;
137 css::uno::Reference
<css::text::XTextRange
> m_xStartRange
;
141 boost::optional
<FieldId
> m_eFieldId
;
144 css::uno::Reference
<css::text::XTextField
> m_xTextField
;
145 css::uno::Reference
<css::text::XFormField
> m_xFormField
;
146 css::uno::Reference
<css::beans::XPropertySet
> m_xTOC
;
147 css::uno::Reference
<css::beans::XPropertySet
> m_xTC
; // TOX entry
148 css::uno::Reference
<css::beans::XPropertySet
> m_xCustomField
;
150 OUString m_sHyperlinkURL
;
151 /// A frame for the hyperlink when one exists.
152 OUString m_sHyperlinkTarget
;
153 OUString m_sHyperlinkStyle
;
155 FFDataHandler::Pointer_t m_pFFDataHandler
;
156 FormControlHelper::Pointer_t m_pFormControlHelper
;
157 /// (Character) properties of the field itself.
158 PropertyMapPtr m_pProperties
;
161 explicit FieldContext(css::uno::Reference
<css::text::XTextRange
> const& xStart
);
162 ~FieldContext() override
;
164 const css::uno::Reference
<css::text::XTextRange
>& GetStartRange() const { return m_xStartRange
; }
166 void AppendCommand(const OUString
& rPart
);
167 const OUString
& GetCommand() const {return m_sCommand
; }
169 void SetFieldId(FieldId eFieldId
) { m_eFieldId
= eFieldId
; }
170 boost::optional
<FieldId
> const & GetFieldId() const { return m_eFieldId
; }
172 void AppendResult(OUString
const& rResult
) { m_sResult
+= rResult
; }
173 const OUString
& GetResult() const { return m_sResult
; }
175 void SetCommandCompleted() { m_bFieldCommandCompleted
= true; }
176 bool IsCommandCompleted() const { return m_bFieldCommandCompleted
; }
178 void SetFieldLocked() { m_bFieldLocked
= true; }
179 bool IsFieldLocked() { return m_bFieldLocked
; }
181 const css::uno::Reference
<css::beans::XPropertySet
>& GetCustomField() const { return m_xCustomField
; }
182 void SetCustomField(css::uno::Reference
<css::beans::XPropertySet
> const& xCustomField
) { m_xCustomField
= xCustomField
; }
183 const css::uno::Reference
<css::text::XTextField
>& GetTextField() const { return m_xTextField
;}
184 void SetTextField(css::uno::Reference
<css::text::XTextField
> const& xTextField
) { m_xTextField
= xTextField
;}
185 const css::uno::Reference
<css::text::XFormField
>& GetFormField() const { return m_xFormField
;}
186 void SetFormField(css::uno::Reference
<css::text::XFormField
> const& xFormField
) { m_xFormField
= xFormField
;}
188 void SetTOC(css::uno::Reference
<css::beans::XPropertySet
> const& xTOC
) { m_xTOC
= xTOC
; }
189 const css::uno::Reference
<css::beans::XPropertySet
>& GetTOC() { return m_xTOC
; }
191 void SetTC(css::uno::Reference
<css::beans::XPropertySet
> const& xTC
) { m_xTC
= xTC
; }
192 const css::uno::Reference
<css::beans::XPropertySet
>& GetTC() { return m_xTC
; }
194 void SetHyperlinkURL( const OUString
& rURL
) { m_sHyperlinkURL
= rURL
; }
195 const OUString
& GetHyperlinkURL() { return m_sHyperlinkURL
; }
196 void SetHyperlinkTarget(const OUString
& rTarget
) { m_sHyperlinkTarget
= rTarget
; }
197 const OUString
& GetHyperlinkTarget() { return m_sHyperlinkTarget
; }
198 void SetHyperlinkStyle(const OUString
& rStyle
) { m_sHyperlinkStyle
= rStyle
; }
199 const OUString
& GetHyperlinkStyle() { return m_sHyperlinkStyle
; }
201 void setFFDataHandler(FFDataHandler::Pointer_t pFFDataHandler
) { m_pFFDataHandler
= pFFDataHandler
; }
202 const FFDataHandler::Pointer_t
& getFFDataHandler() const { return m_pFFDataHandler
; }
204 void setFormControlHelper(FormControlHelper::Pointer_t pFormControlHelper
) { m_pFormControlHelper
= pFormControlHelper
; }
205 const FormControlHelper::Pointer_t
& getFormControlHelper() const { return m_pFormControlHelper
; }
206 const PropertyMapPtr
& getProperties() { return m_pProperties
; }
208 ::std::vector
<OUString
> GetCommandParts() const;
211 struct TextAppendContext
213 css::uno::Reference
<css::text::XTextAppend
> xTextAppend
;
214 css::uno::Reference
<css::text::XTextRange
> xInsertPosition
;
215 css::uno::Reference
<css::text::XParagraphCursor
> xCursor
;
216 ParagraphPropertiesPtr pLastParagraphProperties
;
219 * Objects anchored to the current paragraph, may affect the paragraph
222 std::vector
<AnchoredObjectInfo
> m_aAnchoredObjects
;
224 TextAppendContext(const css::uno::Reference
<css::text::XTextAppend
>& xAppend
, const css::uno::Reference
<css::text::XTextCursor
>& xCur
)
225 : xTextAppend(xAppend
)
227 xCursor
.set(xCur
, css::uno::UNO_QUERY
);
228 xInsertPosition
.set(xCursor
, css::uno::UNO_QUERY
);
232 struct AnchoredContext
234 css::uno::Reference
<css::text::XTextContent
> xTextContent
;
237 explicit AnchoredContext(const css::uno::Reference
<css::text::XTextContent
>& xContent
)
238 : xTextContent(xContent
), bToRemove(false)
243 typedef tools::SvRef
<FieldContext
> FieldContextPtr
;
245 /*-------------------------------------------------------------------------
246 extended tab stop struct
247 -----------------------------------------------------------------------*/
248 struct DeletableTabStop
: public css::style::TabStop
251 explicit DeletableTabStop()
254 // same defaults as SvxXMLTabStopContext_Impl
258 DeletableTabStop(const css::style::TabStop
& rTabStop
)
264 /// helper to remember bookmark start position
265 struct BookmarkInsertPosition
267 bool const m_bIsStartOfText
;
268 OUString m_sBookmarkName
;
269 css::uno::Reference
<css::text::XTextRange
> m_xTextRange
;
270 BookmarkInsertPosition(bool bIsStartOfText
, const OUString
& rName
, css::uno::Reference
<css::text::XTextRange
> const& xTextRange
):
271 m_bIsStartOfText( bIsStartOfText
),
272 m_sBookmarkName( rName
),
273 m_xTextRange( xTextRange
)
277 struct PermInsertPosition
279 bool const m_bIsStartOfText
;
280 sal_Int32
const m_Id
;
284 css::uno::Reference
<css::text::XTextRange
> m_xTextRange
;
286 PermInsertPosition(bool bIsStartOfText
, sal_Int32 id
, const OUString
& ed
, const OUString
& edGrp
, css::uno::Reference
<css::text::XTextRange
> const& xTextRange
)
287 : m_bIsStartOfText(bIsStartOfText
)
291 , m_xTextRange(xTextRange
)
294 OUString
createBookmarkName() const
296 OUString bookmarkName
;
298 assert((!m_Ed
.isEmpty()) || (!m_EdGrp
.isEmpty()));
302 bookmarkName
+= "permission-for-group:";
303 bookmarkName
+= OUString::number(m_Id
);
305 bookmarkName
+= m_EdGrp
;
309 bookmarkName
+= "permission-for-user:";
310 bookmarkName
+= OUString::number(m_Id
);
312 bookmarkName
+= m_Ed
;
315 //todo: make sure the name is not used already!
320 /// Stores the start/end positions of an annotation before its insertion.
321 struct AnnotationPosition
323 css::uno::Reference
<css::text::XTextRange
> m_xStart
;
324 css::uno::Reference
<css::text::XTextRange
> m_xEnd
;
332 sal_uInt32 nRubyAlign
;
334 sal_uInt32 nHpsBaseText
;
345 struct LineNumberSettings
349 bool bRestartAtEachPage
;
350 LineNumberSettings() :
353 ,bRestartAtEachPage(true)
358 /// Contains information about a table that will be potentially converted to a floating one at the section end.
359 struct FloatingTableInfo
361 css::uno::Reference
<css::text::XTextRange
> m_xStart
;
362 css::uno::Reference
<css::text::XTextRange
> m_xEnd
;
363 css::uno::Sequence
<css::beans::PropertyValue
> const m_aFrameProperties
;
364 sal_Int32
const m_nTableWidth
;
365 sal_Int32
const m_nTableWidthType
;
366 /// Break type of the section that contains this table.
367 sal_Int32 m_nBreakType
= -1;
369 FloatingTableInfo(css::uno::Reference
<css::text::XTextRange
> const& xStart
,
370 css::uno::Reference
<css::text::XTextRange
> const& xEnd
,
371 const css::uno::Sequence
<css::beans::PropertyValue
>& aFrameProperties
,
372 sal_Int32 nTableWidth
, sal_Int32 nTableWidthType
)
375 m_aFrameProperties(aFrameProperties
),
376 m_nTableWidth(nTableWidth
),
377 m_nTableWidthType(nTableWidthType
)
380 css::uno::Any
getPropertyValue(const OUString
&propertyName
);
383 /// Stores original/in-file-format info about a single anchored object.
384 struct AnchoredObjectInfo
386 css::uno::Reference
<css::text::XTextContent
> m_xAnchoredObject
;
387 sal_Int32 m_nLeftMargin
= 0;
390 /// Stores info about objects anchored to a given paragraph.
391 struct AnchoredObjectsInfo
393 css::uno::Reference
<css::text::XTextRange
> m_xParagraph
;
394 std::vector
<AnchoredObjectInfo
> m_aAnchoredObjects
;
408 class DomainMapper_Impl final
411 typedef std::map
< OUString
, BookmarkInsertPosition
> BookmarkMap_t
;
412 typedef std::map
< sal_Int32
, PermInsertPosition
> PermMap_t
;
415 SourceDocumentType
const m_eDocumentType
;
416 DomainMapper
& m_rDMapper
;
417 SvtSaveOptions
const m_aSaveOpt
;
419 css::uno::Reference
<css::text::XTextDocument
> m_xTextDocument
;
420 css::uno::Reference
<css::beans::XPropertySet
> m_xDocumentSettings
;
421 css::uno::Reference
<css::lang::XMultiServiceFactory
> m_xTextFactory
;
422 css::uno::Reference
<css::uno::XComponentContext
> m_xComponentContext
;
423 css::uno::Reference
<css::container::XNameContainer
> m_xPageStyles
;
424 css::uno::Reference
<css::text::XText
> m_xBodyText
;
425 css::uno::Reference
<css::text::XTextContent
> m_xEmbedded
;
427 std::stack
<TextAppendContext
> m_aTextAppendStack
;
428 std::stack
<AnchoredContext
> m_aAnchoredStack
;
429 std::stack
<HeaderFooterContext
> m_aHeaderFooterStack
;
430 std::stack
<FieldContextPtr
> m_aFieldStack
;
431 bool m_bSetUserFieldContent
;
433 bool m_bSetDateValue
;
434 bool m_bIsFirstSection
;
435 bool m_bIsColumnBreakDeferred
;
436 bool m_bIsPageBreakDeferred
;
437 /// If we want to set "sdt end" on the next character context.
438 bool m_bSdtEndDeferred
;
439 /// If we want to set "paragraph sdt end" on the next paragraph context.
440 bool m_bParaSdtEndDeferred
;
442 bool m_bStartTOCHeaderFooter
;
443 /// If we got any text that is the pre-rendered result of the TOC field.
446 bool m_bStartBibliography
;
447 bool m_bStartGenericField
;
448 bool m_bTextInserted
;
449 LineNumberSettings m_aLineNumberSettings
;
451 BookmarkMap_t m_aBookmarkMap
;
452 OUString m_sCurrentBkmkId
;
453 OUString m_sCurrentBkmkName
;
455 PermMap_t m_aPermMap
;
456 sal_Int32 m_sCurrentPermId
;
457 OUString m_sCurrentPermEd
;
458 OUString m_sCurrentPermEdGrp
;
460 PageMar m_aPageMargins
;
461 SymbolData m_aSymbolData
;
463 // TableManagers are stacked: one for each stream to avoid any confusion
464 std::stack
< tools::SvRef
< DomainMapperTableManager
> > m_aTableManagers
;
465 tools::SvRef
<DomainMapperTableHandler
> m_pTableHandler
;
467 //each context needs a stack of currently used attributes
468 std::stack
<PropertyMapPtr
> m_aPropertyStacks
[NUMBER_OF_CONTEXTS
];
469 std::stack
<ContextType
> m_aContextStack
;
470 FontTablePtr m_pFontTable
;
471 ListsManager::Pointer m_pListTable
;
472 std::deque
< css::uno::Reference
<css::drawing::XShape
> > m_aPendingShapes
;
473 StyleSheetTablePtr m_pStyleSheetTable
;
474 ThemeTablePtr m_pThemeTable
;
475 SettingsTablePtr m_pSettingsTable
;
476 GraphicImportPtr m_pGraphicImport
;
479 PropertyMapPtr m_pTopContext
;
480 PropertyMapPtr m_pLastSectionContext
;
481 PropertyMapPtr m_pLastCharacterContext
;
483 ::std::vector
<DeletableTabStop
> m_aCurrentTabStops
;
484 OUString m_sCurrentParaStyleName
; //highly inaccurate. Overwritten by "overlapping" paragraphs like comments, flys.
485 OUString m_sDefaultParaStyleName
; //caches the ConvertedStyleName of the default paragraph style
486 bool m_bInStyleSheetImport
; //in import of fonts, styles, lists or lfos
487 bool m_bInAnyTableImport
; //in import of fonts, styles, lists or lfos
488 enum class HeaderFooterImportState
493 } m_eInHeaderFooterImport
;
494 bool m_bDiscardHeaderFooter
;
495 bool m_bInFootOrEndnote
;
496 /// Did we get a <w:separator/> for this footnote already?
497 bool m_bSeenFootOrEndnoteSeparator
;
499 bool m_bLineNumberingSet
;
500 bool m_bIsInFootnoteProperties
;
501 bool m_bIsCustomFtnMark
;
503 RubyInfo m_aRubyInfo
;
504 //registered frame properties
505 std::vector
<css::beans::PropertyValue
> m_aFrameProperties
;
506 css::uno::Reference
<css::text::XTextRange
> m_xFrameStartRange
;
507 css::uno::Reference
<css::text::XTextRange
> m_xFrameEndRange
;
510 std::stack
< std::vector
< RedlineParamsPtr
> > m_aRedlines
;
511 // The redline currently read, may be also stored by a context instead of m_aRedlines.
512 RedlineParamsPtr m_currentRedline
;
513 RedlineParamsPtr m_pParaMarkerRedline
;
514 bool m_bIsParaMarkerChange
;
515 // redline data of the terminating run, if it's a moveFrom deletion
516 RedlineParamsPtr m_pParaMarkerRedlineMoveFrom
;
518 /// If the current paragraph has any runs.
520 bool m_bIsFirstParaInSection
;
521 bool m_bIsFirstParaInShape
= false;
522 bool m_bDummyParaAddedForTableInSection
;
523 bool m_bTextFrameInserted
;
524 bool m_bIsPreviousParagraphFramed
;
525 bool m_bIsLastParaInSection
;
526 bool m_bIsLastSectionGroup
;
527 bool m_bIsInComments
;
528 /// If the current paragraph contains section property definitions.
530 bool m_bUsingEnhancedFields
;
531 /// If the current paragraph is inside a structured document element.
534 bool m_bIsOutsideAParagraph
;
536 css::uno::Reference
< css::text::XTextCursor
> xTOCMarkerCursor
;
537 css::uno::Reference
< css::text::XTextCursor
> mxTOCTextCursor
;
540 css::uno::Reference
< css::beans::XPropertySet
> m_xAnnotationField
;
541 sal_Int32 m_nAnnotationId
;
542 std::unordered_map
< sal_Int32
, AnnotationPosition
> m_aAnnotationPositions
;
544 void GetCurrentLocale(css::lang::Locale
& rLocale
);
545 void SetNumberFormat(const OUString
& rCommand
, css::uno::Reference
<css::beans::XPropertySet
> const& xPropertySet
, bool bDetectFormat
= false);
546 /// @throws css::uno::Exception
547 css::uno::Reference
<css::beans::XPropertySet
> FindOrCreateFieldMaster(const sal_Char
* pFieldMasterService
, const OUString
& rFieldMasterName
);
548 css::uno::Reference
<css::beans::XPropertySet
> const & GetDocumentSettings();
550 std::map
<sal_Int32
, css::uno::Any
> deferredCharacterProperties
;
551 SmartTagHandler m_aSmartTagHandler
;
553 css::uno::Reference
<css::text::XTextRange
> m_xGlossaryEntryStart
;
554 css::uno::Reference
<css::text::XTextRange
> m_xStdEntryStart
;
557 css::uno::Reference
<css::text::XTextRange
> m_xInsertTextRange
;
559 bool const m_bIsNewDoc
;
560 bool const m_bIsReadGlossaries
;
563 DomainMapper
& rDMapper
,
564 css::uno::Reference
< css::uno::XComponentContext
> const& xContext
,
565 css::uno::Reference
< css::lang::XComponent
> const& xModel
,
566 SourceDocumentType eDocumentType
,
567 utl::MediaDescriptor
const & rMediaDesc
);
568 ~DomainMapper_Impl();
570 SectionPropertyMap
* GetLastSectionContext( )
572 return dynamic_cast< SectionPropertyMap
* >( m_pLastSectionContext
.get( ) );
575 css::uno::Reference
<css::container::XNameContainer
> const & GetPageStyles();
576 css::uno::Reference
<css::text::XText
> const & GetBodyText();
577 const css::uno::Reference
<css::lang::XMultiServiceFactory
>& GetTextFactory() const
579 return m_xTextFactory
;
581 const css::uno::Reference
<css::text::XTextDocument
>& GetTextDocument() const
583 return m_xTextDocument
;
585 void SetDocumentSettingsProperty( const OUString
& rPropName
, const css::uno::Any
& rValue
);
587 void CreateRedline(css::uno::Reference
<css::text::XTextRange
> const& xRange
, const RedlineParamsPtr
& pRedline
);
589 void CheckParaMarkerRedline(css::uno::Reference
<css::text::XTextRange
> const& xRange
);
591 void CheckRedline(css::uno::Reference
<css::text::XTextRange
> const& xRange
);
593 void StartParaMarkerChange( );
594 void EndParaMarkerChange( );
595 void ChainTextFrames();
597 void RemoveDummyParaForTableInSection();
598 void AddDummyParaForTableInSection();
599 void RemoveLastParagraph( );
600 void SetIsLastParagraphInSection( bool bIsLast
);
601 bool GetIsLastParagraphInSection() { return m_bIsLastParaInSection
;}
602 void SetRubySprmId( sal_uInt32 nSprmId
) { m_aRubyInfo
.nSprmId
= nSprmId
; }
603 void SetRubyText( OUString
const &sText
, OUString
const &sStyle
) {
604 m_aRubyInfo
.sRubyText
= sText
;
605 m_aRubyInfo
.sRubyStyle
= sStyle
;
607 const RubyInfo
& GetRubyInfo() const { return m_aRubyInfo
;}
608 void SetRubyInfo(const RubyInfo
& rInfo
) { m_aRubyInfo
= rInfo
;}
610 void SetIsLastSectionGroup( bool bIsLast
);
611 bool GetIsLastSectionGroup() { return m_bIsLastSectionGroup
;}
612 void SetIsFirstParagraphInSection( bool bIsFirst
);
613 bool GetIsFirstParagraphInSection();
614 void SetIsFirstParagraphInShape(bool bIsFirst
);
615 bool GetIsFirstParagraphInShape() { return m_bIsFirstParaInShape
; }
616 void SetIsDummyParaAddedForTableInSection( bool bIsAdded
);
617 bool GetIsDummyParaAddedForTableInSection() { return m_bDummyParaAddedForTableInSection
;}
619 /// Track if a textframe has been inserted into this section
620 void SetIsTextFrameInserted( bool bIsInserted
);
621 bool GetIsTextFrameInserted() { return m_bTextFrameInserted
;}
623 void SetIsPreviousParagraphFramed( bool bIsFramed
) { m_bIsPreviousParagraphFramed
= bIsFramed
; }
624 bool GetIsPreviousParagraphFramed() { return m_bIsPreviousParagraphFramed
; }
625 void SetParaSectpr(bool bParaSectpr
);
626 bool GetParaSectpr() { return m_bParaSectpr
;}
628 void SetSymbolChar( sal_Int32 nSymbol
) { m_aSymbolData
.cSymbol
= sal_Unicode(nSymbol
); }
629 void SetSymbolFont( OUString
const &rName
) { m_aSymbolData
.sFont
= rName
; }
630 const SymbolData
& GetSymbolData() { return m_aSymbolData
;}
632 /// Setter method for m_bSdt.
633 void SetSdt(bool bSdt
);
634 /// Getter method for m_bSdt.
635 bool GetSdt() { return m_bSdt
;}
636 bool GetParaChanged() { return m_bParaChanged
;}
638 void deferBreak( BreakType deferredBreakType
);
639 bool isBreakDeferred( BreakType deferredBreakType
);
640 void clearDeferredBreaks();
641 void clearDeferredBreak(BreakType deferredBreakType
);
643 void setSdtEndDeferred(bool bSdtEndDeferred
);
644 bool isSdtEndDeferred();
645 void setParaSdtEndDeferred(bool bParaSdtEndDeferred
);
646 bool isParaSdtEndDeferred();
648 void finishParagraph( const PropertyMapPtr
& pPropertyMap
, const bool bRemove
= false);
649 void appendTextPortion( const OUString
& rString
, const PropertyMapPtr
& pPropertyMap
);
650 void appendTextContent(const css::uno::Reference
<css::text::XTextContent
>&, const css::uno::Sequence
<css::beans::PropertyValue
>&);
651 void appendOLE( const OUString
& rStreamName
, const std::shared_ptr
<OLEHandler
>& pOleHandler
);
652 void appendStarMath( const Value
& v
);
653 css::uno::Reference
<css::beans::XPropertySet
> appendTextSectionAfter(css::uno::Reference
<css::text::XTextRange
> const & xBefore
);
655 /// AutoText import: each entry is placed in the separate section
656 void appendGlossaryEntry();
657 /// Remember where entry was started
658 void setGlossaryEntryStart( css::uno::Reference
<css::text::XTextRange
> const & xStart
)
660 m_xGlossaryEntryStart
= xStart
;
663 // push the new properties onto the stack and make it the 'current' property map
664 void PushProperties(ContextType eId
);
665 void PushStyleProperties(const PropertyMapPtr
& pStyleProperties
);
666 void PushListProperties(const PropertyMapPtr
& pListProperties
);
667 void PopProperties(ContextType eId
);
669 ContextType
GetTopContextType() const { return m_aContextStack
.top(); }
670 const PropertyMapPtr
& GetTopContext()
672 return m_pTopContext
;
674 PropertyMapPtr
GetTopContextOfType(ContextType eId
);
676 bool HasTopText() const;
677 css::uno::Reference
<css::text::XTextAppend
> const & GetTopTextAppend();
678 FieldContextPtr
const & GetTopFieldContext();
680 FontTablePtr
const & GetFontTable()
683 m_pFontTable
= new FontTable();
686 StyleSheetTablePtr
const & GetStyleSheetTable()
688 if(!m_pStyleSheetTable
)
689 m_pStyleSheetTable
= new StyleSheetTable( m_rDMapper
, m_xTextDocument
, m_bIsNewDoc
);
690 return m_pStyleSheetTable
;
692 ListsManager::Pointer
const & GetListTable();
693 ThemeTablePtr
const & GetThemeTable()
696 m_pThemeTable
= new ThemeTable
;
697 return m_pThemeTable
;
700 SettingsTablePtr
const & GetSettingsTable()
702 if( !m_pSettingsTable
)
703 m_pSettingsTable
= new SettingsTable(m_rDMapper
);
704 return m_pSettingsTable
;
707 GraphicImportPtr
const & GetGraphicImport( GraphicImportType eGraphicImportType
);
708 void ResetGraphicImport();
709 // this method deletes the current m_pGraphicImport after import
710 void ImportGraphic(const writerfilter::Reference
< Properties
>::Pointer_t
&, GraphicImportType eGraphicImportType
);
712 void InitTabStopFromStyle(const css::uno::Sequence
<css::style::TabStop
>& rInitTabStops
);
713 void IncorporateTabStop( const DeletableTabStop
&aTabStop
);
714 css::uno::Sequence
<css::style::TabStop
> GetCurrentTabStopAndClear();
716 void SetCurrentParaStyleName(const OUString
& sStringValue
) {m_sCurrentParaStyleName
= sStringValue
;}
717 const OUString
GetCurrentParaStyleName();
718 const OUString
GetDefaultParaStyleName();
720 css::uno::Any
GetPropertyFromStyleSheet(PropertyIds eId
);
721 // get property first from the given context, or secondly from its stylesheet
722 css::uno::Any
GetAnyProperty(PropertyIds eId
, const PropertyMapPtr
& rContext
);
723 void SetStyleSheetImport( bool bSet
) { m_bInStyleSheetImport
= bSet
;}
724 bool IsStyleSheetImport()const { return m_bInStyleSheetImport
;}
725 void SetAnyTableImport( bool bSet
) { m_bInAnyTableImport
= bSet
;}
726 bool IsAnyTableImport()const { return m_bInAnyTableImport
;}
727 bool IsInShape()const { return m_aAnchoredStack
.size() > 0;}
729 void PushShapeContext(const css::uno::Reference
<css::drawing::XShape
>& xShape
);
730 void PopShapeContext();
731 void UpdateEmbeddedShapeProps(const css::uno::Reference
<css::drawing::XShape
>& xShape
);
732 /// Add a pending shape: it's currently inserted into the document, but it should be removed before the import finishes.
733 void PushPendingShape(const css::uno::Reference
<css::drawing::XShape
>& xShape
);
734 /// Get the first pending shape, if there are any.
735 css::uno::Reference
<css::drawing::XShape
> PopPendingShape();
737 void PushPageHeader(SectionPropertyMap::PageType eType
);
738 void PushPageFooter(SectionPropertyMap::PageType eType
);
740 void PopPageHeaderFooter();
741 bool IsInHeaderFooter() const { return m_eInHeaderFooterImport
!= HeaderFooterImportState::none
; }
742 bool IsInFooter() const { return m_eInHeaderFooterImport
== HeaderFooterImportState::footer
; }
744 bool IsInTOC() const { return m_bStartTOC
; }
746 void PushFootOrEndnote( bool bIsFootnote
);
747 void PopFootOrEndnote();
748 bool IsInFootOrEndnote() const { return m_bInFootOrEndnote
; }
749 /// Got a <w:separator/>.
750 void SeenFootOrEndnoteSeparator();
752 void PushAnnotation();
753 void PopAnnotation();
755 /// A field context starts with a cFieldStart.
756 void PushFieldContext();
757 //the current field context waits for the completion of the command
758 bool IsOpenFieldCommand() const;
759 bool IsOpenField() const;
760 //mark field in current context as locked (fixed)
761 void SetFieldLocked();
762 //collect the pieces of the command
763 void AppendFieldCommand(OUString
const & rPartOfCommand
);
764 void handleRubyEQField( const FieldContextPtr
& pContext
);
766 (const FieldContextPtr
& pContext
,
767 css::uno::Reference
< css::uno::XInterface
> const & xFieldInterface
,
768 css::uno::Reference
< css::beans::XPropertySet
> const& xFieldProperties
);
770 (const FieldContextPtr
& pContext
,
771 css::uno::Reference
< css::uno::XInterface
> & xFieldInterface
,
772 css::uno::Reference
< css::beans::XPropertySet
> const& xFieldProperties
);
773 static void handleFieldFormula
774 (const FieldContextPtr
& pContext
,
775 css::uno::Reference
< css::beans::XPropertySet
> const& xFieldProperties
);
777 (const FieldContextPtr
& pContext
,
778 css::uno::Reference
< css::uno::XInterface
> const & xFieldInterface
,
779 css::uno::Reference
< css::beans::XPropertySet
> const& xFieldProperties
);
780 static void handleAuthor
781 (OUString
const& rFirstParam
,
782 css::uno::Reference
< css::beans::XPropertySet
> const& xFieldProperties
,
784 void handleDocProperty
785 (const FieldContextPtr
& pContext
,
786 OUString
const& rFirstParam
,
787 css::uno::Reference
< css::uno::XInterface
> & xFieldInterface
);
789 (const FieldContextPtr
& pContext
,
790 const OUString
& sTOCServiceName
);
792 (const FieldContextPtr
& pContext
,
793 const OUString
& sTOCServiceName
);
795 void handleBibliography
796 (const FieldContextPtr
& pContext
,
797 const OUString
& sTOCServiceName
);
798 /// The field command has to be closed (cFieldSep appeared).
799 void CloseFieldCommand();
800 //the _current_ fields require a string type result while TOCs accept richt results
801 bool IsFieldResultAsString();
802 void AppendFieldResult(OUString
const& rResult
);
803 //apply the result text to the related field
804 void SetFieldResult(OUString
const& rResult
);
805 // set FFData of top field context
806 void SetFieldFFData( const FFDataHandler::Pointer_t
& pFFDataHandler
);
807 /// The end of field is reached (cFieldEnd appeared) - the command might still be open.
808 void PopFieldContext();
810 /// Returns title of the TOC placed in paragraph(s) before TOC field inside STD-frame
811 OUString
extractTocTitle();
812 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
);
814 void SetBookmarkName( const OUString
& rBookmarkName
);
815 void StartOrEndBookmark( const OUString
& rId
);
817 void setPermissionRangeEd(const OUString
& user
);
818 void setPermissionRangeEdGrp(const OUString
& group
);
819 void startOrEndPermissionRange(sal_Int32 permissinId
);
821 void AddAnnotationPosition(
823 const sal_Int32 nAnnotationId
);
825 bool hasTableManager() const
827 return !m_aTableManagers
.empty();
830 DomainMapperTableManager
& getTableManager()
832 tools::SvRef
< DomainMapperTableManager
> pMngr
= m_aTableManagers
.top();
833 return *pMngr
.get( );
836 void appendTableManager( )
838 tools::SvRef
<DomainMapperTableManager
> pMngr(new DomainMapperTableManager());
839 m_aTableManagers
.push( pMngr
);
842 void appendTableHandler( )
844 if (m_pTableHandler
.get())
845 m_aTableManagers
.top()->setHandler(m_pTableHandler
);
848 void popTableManager( )
850 if (hasTableManager())
851 m_aTableManagers
.pop();
854 void SetLineNumbering( sal_Int32 nLnnMod
, sal_uInt32 nLnc
, sal_Int32 ndxaLnn
);
855 bool IsLineNumberingSet() const {return m_bLineNumberingSet
;}
857 DeletableTabStop m_aCurrentTabStop
;
859 /// If we're right after the end of a table.
860 bool m_bConvertedTable
= false;
862 bool IsOOXMLImport() const { return m_eDocumentType
== SourceDocumentType::OOXML
; }
864 bool IsRTFImport() const { return m_eDocumentType
== SourceDocumentType::RTF
; }
866 void InitPageMargins() { m_aPageMargins
= PageMar(); }
867 void SetPageMarginTwip( PageMarElement eElement
, sal_Int32 nValue
);
868 const PageMar
& GetPageMargins() const {return m_aPageMargins
;}
870 const LineNumberSettings
& GetLineNumberSettings() const { return m_aLineNumberSettings
;}
871 void SetLineNumberSettings(const LineNumberSettings
& rSet
) { m_aLineNumberSettings
= rSet
;}
873 void SetInFootnoteProperties(bool bSet
) { m_bIsInFootnoteProperties
= bSet
;}
874 bool IsInFootnoteProperties() const { return m_bIsInFootnoteProperties
;}
876 void SetCustomFtnMark(bool bSet
) { m_bIsCustomFtnMark
= bSet
; }
877 bool IsCustomFtnMark() const { return m_bIsCustomFtnMark
; }
879 bool IsInComments() const { return m_bIsInComments
; };
881 void CheckUnregisteredFrameConversion( );
883 void RegisterFrameConversion(css::uno::Reference
<css::text::XTextRange
> const& xFrameStartRange
,
884 css::uno::Reference
<css::text::XTextRange
> const& xFrameEndRange
,
885 const std::vector
<css::beans::PropertyValue
>& aFrameProperties
);
886 void ExecuteFrameConversion();
888 void AddNewRedline( sal_uInt32 sprmId
);
890 sal_Int32
GetCurrentRedlineToken( );
891 void SetCurrentRedlineAuthor( const OUString
& sAuthor
);
892 void SetCurrentRedlineDate( const OUString
& sDate
);
893 void SetCurrentRedlineId( sal_Int32 nId
);
894 void SetCurrentRedlineToken( sal_Int32 nToken
);
895 void SetCurrentRedlineRevertProperties( const css::uno::Sequence
<css::beans::PropertyValue
>& aProperties
);
896 void SetCurrentRedlineIsRead();
897 void RemoveTopRedline( );
898 void SetCurrentRedlineInitials( const OUString
& sInitials
);
899 bool IsFirstRun() { return m_bIsFirstRun
;}
900 void SetIsFirstRun(bool bval
) { m_bIsFirstRun
= bval
;}
901 bool IsOutsideAParagraph() { return m_bIsOutsideAParagraph
;}
902 void SetIsOutsideAParagraph(bool bval
) { m_bIsOutsideAParagraph
= bval
;}
904 void ApplySettingsTable();
905 SectionPropertyMap
* GetSectionContext();
906 /// If the current paragraph has a numbering style associated, this method returns its character style (part of the numbering rules)
907 css::uno::Reference
<css::beans::XPropertySet
> GetCurrentNumberingCharStyle();
908 /// If the current paragraph has a numbering style associated, this method returns its numbering rules
909 css::uno::Reference
<css::container::XIndexAccess
> GetCurrentNumberingRules(sal_Int32
* pListLevel
);
912 Used for attributes/sprms which cannot be evaluated immediately (e.g. they depend
913 on another one that comes in the same CONTEXT_CHARACTER). The property will be processed
914 again in DomainMapper::processDeferredCharacterProperties().
916 void deferCharacterProperty(sal_Int32 id
, const css::uno::Any
& value
);
918 Processes properties deferred using deferCharacterProperty(). To be called whenever the top
919 CONTEXT_CHARACTER is going to be used (e.g. by appendText()).
921 void processDeferredCharacterProperties();
923 sal_Int32
getNumberingProperty(const sal_Int32 nListId
, sal_Int32 nListLevel
, const OUString
& aProp
);
924 /// Get a property of the current numbering style's current level.
925 sal_Int32
getCurrentNumberingProperty(const OUString
& aProp
);
927 /// If we're importing into a new document, or just pasting to an existing one.
928 bool IsNewDoc() { return m_bIsNewDoc
;}
930 /// If we're importing autotext.
931 bool IsReadGlossaries() { return m_bIsReadGlossaries
;}
933 /// If we're inside <w:rPr>, inside <w:style w:type="table">
934 bool m_bInTableStyleRunProps
;
936 tools::SvRef
<SdtHelper
> m_pSdtHelper
;
938 /// Document background color, applied to every page style.
939 boost::optional
<sal_Int32
> m_oBackgroundColor
;
942 * This contains the raw table depth. m_nTableDepth > 0 is the same as
943 * getTableManager().isInTable(), unless we're in the first paragraph of a
944 * table, or first paragraph after a table, as the table manager is only
945 * updated once we ended the paragraph (and know if the para has the
946 * inTbl SPRM or not).
948 sal_Int32 m_nTableDepth
;
949 /// Raw table cell depth.
950 sal_Int32 m_nTableCellDepth
;
951 /// Table cell depth of the last finished paragraph.
952 sal_Int32 m_nLastTableCellParagraphDepth
;
954 /// If the current section has footnotes.
956 /// If the current section has a footnote separator.
959 /// If the next newline should be ignored, used by the special footnote separator paragraph.
960 bool m_bIgnoreNextPara
;
961 /// If the next tab should be ignored, used for footnotes.
962 bool m_bCheckFirstFootnoteTab
;
963 bool m_bIgnoreNextTab
;
964 /// Pending floating tables: they may be converted to text frames at the section end.
965 std::vector
<FloatingTableInfo
> m_aPendingFloatingTables
;
967 /// Paragraphs with anchored objects in the current section.
968 std::vector
<AnchoredObjectsInfo
> m_aAnchoredObjectAnchors
;
970 /// Append a property to a sub-grabbag if necessary (e.g. 'lineRule', 'auto')
971 void appendGrabBag(std::vector
<css::beans::PropertyValue
>& rInteropGrabBag
, const OUString
& aKey
, const OUString
& aValue
);
972 void appendGrabBag(std::vector
<css::beans::PropertyValue
>& rInteropGrabBag
, const OUString
& aKey
, std::vector
<css::beans::PropertyValue
>& rValue
);
974 /// Enable, disable an check status of grabbags
975 void enableInteropGrabBag(const OUString
& aName
);
976 void disableInteropGrabBag();
977 bool isInteropGrabBagEnabled();
979 /// Name of m_aInteropGrabBag.
980 OUString m_aInteropGrabBagName
;
982 /// A toplevel dmapper grabbag, like 'pPr'.
983 std::vector
<css::beans::PropertyValue
> m_aInteropGrabBag
;
985 /// A sub-grabbag of m_aInteropGrabBag, like 'spacing'.
986 std::vector
<css::beans::PropertyValue
> m_aSubInteropGrabBag
;
988 /// ST_PositionOffset values we received
989 std::pair
<OUString
, OUString
> m_aPositionOffsets
;
990 /// ST_AlignH/V values we received
991 std::pair
<OUString
, OUString
> m_aAligns
;
992 /// ST_PositivePercentage values we received
993 std::queue
<OUString
> m_aPositivePercentages
;
994 bool isInIndexContext() { return m_bStartIndex
;}
995 bool isInBibliographyContext() { return m_bStartBibliography
;}
996 SmartTagHandler
& getSmartTagHandler() { return m_aSmartTagHandler
; }
998 void substream(Id rName
, ::writerfilter::Reference
<Stream
>::Pointer_t
const& ref
);
1000 /// If the document needs to split paragraph.
1001 bool m_bIsSplitPara
;
1003 /// Check if "SdtEndBefore" property is set
1004 bool IsSdtEndBefore();
1006 bool IsDiscardHeaderFooter();
1008 void SetParaAutoBefore(bool bParaAutoBefore
) { m_bParaAutoBefore
= bParaAutoBefore
; }
1010 /// Forget about the previous paragraph, as it's not inside the same
1012 void ClearPreviousParagraph();
1015 void PushPageHeaderFooter(bool bHeader
, SectionPropertyMap::PageType eType
);
1016 std::vector
<css::uno::Reference
< css::drawing::XShape
> > m_vTextFramesForChaining
;
1017 /// Current paragraph had at least one field in it.
1018 bool m_bParaHadField
;
1019 css::uno::Reference
<css::beans::XPropertySet
> m_xPreviousParagraph
;
1020 /// Current paragraph has automatic before spacing.
1021 bool m_bParaAutoBefore
;
1022 /// Current paragraph in a table is first paragraph of a cell
1023 bool m_bFirstParagraphInCell
;
1024 bool m_bSaveFirstParagraphInCell
;
1027 } //namespace dmapper
1028 } //namespace writerfilter
1031 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */