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 .
22 #include "OOXMLDocumentImpl.hxx"
23 #include "OOXMLPropertySet.hxx"
25 namespace writerfilter::ooxml
28 * Struct to store our 'alternate state'. If multiple mc:AlternateContent
29 * elements arrive, then while the inner ones are active, the original state is
30 * saved away, and once they inner goes out of scope, the original state is
33 struct SavedAlternateState
35 bool m_bDiscardChildren
;
36 bool m_bTookChoice
; ///< Did we take the Choice or want Fallback instead?
39 class OOXMLParserState final
: public virtual SvRefBase
41 bool mbInSectionGroup
;
42 bool mbInParagraphGroup
;
43 bool mbInCharacterGroup
;
44 bool mbLastParagraphInSection
;
46 unsigned int mnContexts
;
47 unsigned int mnHandle
;
48 OOXMLDocumentImpl
* mpDocument
;
49 OOXMLPropertySet::Pointer_t mpCharacterProps
;
50 std::stack
<OOXMLPropertySet::Pointer_t
> mCellProps
;
51 std::stack
<OOXMLPropertySet::Pointer_t
> mRowProps
;
52 std::stack
<OOXMLPropertySet::Pointer_t
> mTableProps
;
54 // these 4 save when inTxbxContent
55 bool m_savedInParagraphGroup
;
56 bool m_savedInCharacterGroup
;
57 bool m_savedLastParagraphInSection
;
58 std::vector
<SavedAlternateState
> maSavedAlternateStates
;
59 std::vector
<OOXMLPropertySet::Pointer_t
> mvPostponedBreaks
;
61 /// We just ended a floating table. Starting a paragraph or table resets this.
62 bool m_bFloatingTableEnded
= false;
65 typedef tools::SvRef
<OOXMLParserState
> Pointer_t
;
68 ~OOXMLParserState() override
;
70 bool isInSectionGroup() const { return mbInSectionGroup
; }
71 void setInSectionGroup(bool bInSectionGroup
);
73 void setLastParagraphInSection(bool bLastParagraphInSection
);
74 bool isLastParagraphInSection() const { return mbLastParagraphInSection
; }
76 std::vector
<SavedAlternateState
>& getSavedAlternateStates() { return maSavedAlternateStates
; }
78 bool isInParagraphGroup() const { return mbInParagraphGroup
; }
79 void setInParagraphGroup(bool bInParagraphGroup
);
81 bool isInCharacterGroup() const { return mbInCharacterGroup
; }
82 void setInCharacterGroup(bool bInCharacterGroup
);
84 void setForwardEvents(bool bForwardEvents
);
85 bool isForwardEvents() const { return mbForwardEvents
; }
87 std::string
getHandle() const;
90 void setDocument(OOXMLDocumentImpl
* pDocument
);
91 OOXMLDocumentImpl
* getDocument() const { return mpDocument
; }
93 void setXNoteId(const sal_Int32 rId
);
94 sal_Int32
getXNoteId() const;
96 const OUString
& getTarget() const;
98 void resolveCharacterProperties(Stream
& rStream
);
99 void setCharacterProperties(const OOXMLPropertySet::Pointer_t
& pProps
);
100 void resolveCellProperties(Stream
& rStream
);
101 void setCellProperties(const OOXMLPropertySet::Pointer_t
& pProps
);
102 void resolveRowProperties(Stream
& rStream
);
103 void setRowProperties(const OOXMLPropertySet::Pointer_t
& pProps
);
104 void resolveTableProperties(Stream
& rStream
);
105 void setTableProperties(const OOXMLPropertySet::Pointer_t
& pProps
);
106 OOXMLPropertySet::Pointer_t
GetTableProperties() const;
108 void resolvePostponedBreak(Stream
& rStream
);
109 void setPostponedBreak(const OOXMLPropertySet::Pointer_t
& pProps
);
114 void incContextCount();
116 void startTxbxContent();
117 void endTxbxContent();
119 void setStartFootnote(bool bStartFootnote
);
120 bool isStartFootnote() const { return mbStartFootnote
; }
122 void SetFloatingTableEnded(bool bFloatingTableEnded
)
124 m_bFloatingTableEnded
= bFloatingTableEnded
;
126 bool GetFloatingTableEnded() const { return m_bFloatingTableEnded
; }
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */