Line data Source code
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_OOXML_OOXMLPARSERSTATE_HXX
20 : #define INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLPARSERSTATE_HXX
21 :
22 : #include <stack>
23 : #include "OOXMLDocumentImpl.hxx"
24 : #include "OOXMLPropertySetImpl.hxx"
25 :
26 : namespace writerfilter {
27 : namespace ooxml
28 : {
29 :
30 : /**
31 : * Struct to store our 'alternate state'. If multiple mc:AlternateContent
32 : * elements arrive, then while the inner ones are active, the original state is
33 : * saved away, and once they inner goes out of scope, the original state is
34 : * restored.
35 : */
36 : struct SavedAlternateState
37 : {
38 : bool m_bDiscardChildren;
39 : bool m_bTookChoice; ///< Did we take the Choice or want Fallback instead?
40 : };
41 :
42 : class OOXMLParserState
43 : {
44 : bool mbInSectionGroup;
45 : bool mbInParagraphGroup;
46 : bool mbInCharacterGroup;
47 : bool mbLastParagraphInSection;
48 : bool mbForwardEvents;
49 : unsigned int mnContexts;
50 : unsigned int mnHandle;
51 : OOXMLDocumentImpl* mpDocument;
52 : OOXMLPropertySet::Pointer_t mpCharacterProps;
53 : std::stack<OOXMLPropertySet::Pointer_t> mCellProps;
54 : std::stack<OOXMLPropertySet::Pointer_t> mRowProps;
55 : std::stack<OOXMLPropertySet::Pointer_t> mTableProps;
56 : bool inTxbxContent;
57 : // these 4 save when inTxbxContent
58 : bool savedInParagraphGroup;
59 : bool savedInCharacterGroup;
60 : bool savedLastParagraphInSection;
61 : std::vector<SavedAlternateState> maSavedAlternateStates;
62 :
63 : public:
64 : typedef std::shared_ptr<OOXMLParserState> Pointer_t;
65 :
66 : OOXMLParserState();
67 : virtual ~OOXMLParserState();
68 :
69 33940 : bool isInSectionGroup() const { return mbInSectionGroup;}
70 : void setInSectionGroup(bool bInSectionGroup);
71 :
72 : void setLastParagraphInSection(bool bLastParagraphInSection);
73 26661 : bool isLastParagraphInSection() const { return mbLastParagraphInSection;}
74 :
75 2820 : std::vector<SavedAlternateState>& getSavedAlternateStates() { return maSavedAlternateStates; }
76 :
77 155562 : bool isInParagraphGroup() const { return mbInParagraphGroup;}
78 : void setInParagraphGroup(bool bInParagraphGroup);
79 :
80 261384 : bool isInCharacterGroup() const { return mbInCharacterGroup;}
81 : void setInCharacterGroup(bool bInCharacterGroup);
82 :
83 : void setForwardEvents(bool bForwardEvents);
84 390410 : bool isForwardEvents() const { return mbForwardEvents;}
85 :
86 : const std::string getHandle() const;
87 : void setHandle();
88 :
89 : void setDocument(OOXMLDocumentImpl* pDocument);
90 89365 : OOXMLDocumentImpl* getDocument() const { return mpDocument;}
91 :
92 : void setXNoteId(const sal_Int32 rId);
93 : sal_Int32 getXNoteId() const;
94 :
95 : const OUString & getTarget() const;
96 :
97 : void resolveCharacterProperties(Stream & rStream);
98 : void setCharacterProperties(OOXMLPropertySet::Pointer_t pProps);
99 : void resolveCellProperties(Stream & rStream);
100 : void setCellProperties(OOXMLPropertySet::Pointer_t pProps);
101 : void resolveRowProperties(Stream & rStream);
102 : void setRowProperties(OOXMLPropertySet::Pointer_t pProps);
103 : void resolveTableProperties(Stream & rStream);
104 : void setTableProperties(OOXMLPropertySet::Pointer_t pProps);
105 :
106 : void startTable();
107 : void endTable();
108 :
109 : void incContextCount();
110 :
111 : void startTxbxContent();
112 : void endTxbxContent();
113 :
114 : };
115 :
116 : }}
117 :
118 : #endif // INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLPARSERSTATE_HXX
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|