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