Branch data 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 : :
20 : : #ifndef INCLUDED_OOXML_FACTORY_HXX
21 : : #define INCLUDED_OOXML_FACTORY_HXX
22 : :
23 : : #include <boost/unordered_map.hpp>
24 : : #include <boost/shared_ptr.hpp>
25 : :
26 : : #include <resourcemodel/WW8ResourceModel.hxx>
27 : :
28 : : #include <ooxml/OOXMLFastTokens.hxx>
29 : :
30 : : #include "OOXMLFastContextHandler.hxx"
31 : :
32 : : namespace writerfilter {
33 : : namespace ooxml {
34 : :
35 : : using namespace std;
36 : :
37 : : enum ResourceType_t {
38 : : RT_NoResource,
39 : : RT_Table,
40 : : RT_Stream,
41 : : RT_StreamProperties,
42 : : RT_List,
43 : : RT_Integer,
44 : : RT_Properties,
45 : : RT_Hex,
46 : : RT_String,
47 : : RT_Shape,
48 : : RT_Boolean,
49 : : RT_HexValue,
50 : : RT_Value,
51 : : RT_XNote,
52 : : RT_TextTableCell,
53 : : RT_TextTableRow,
54 : : RT_TextTable,
55 : : RT_PropertyTable,
56 : : RT_Math,
57 : : RT_Any
58 : : };
59 : :
60 : : struct AttributeInfo
61 : : {
62 : : ResourceType_t m_nResource;
63 : : Id m_nRef;
64 : :
65 : : AttributeInfo(ResourceType_t nResource, Id nRef);
66 : : AttributeInfo();
67 : : };
68 : :
69 : : typedef boost::unordered_map<Token_t, AttributeInfo> AttributeToResourceMap;
70 : : typedef boost::shared_ptr<AttributeToResourceMap> AttributeToResourceMapPointer;
71 : : typedef boost::unordered_map<Id, AttributeToResourceMapPointer> AttributesMap;
72 : :
73 : : typedef boost::unordered_map<OUString, sal_Int32, OUStringHash> ListValueMap;
74 : : typedef boost::shared_ptr<ListValueMap> ListValueMapPointer;
75 : : typedef boost::unordered_map<Id, ListValueMapPointer> ListValuesMap;
76 : :
77 : : struct CreateElement
78 : : {
79 : : ResourceType_t m_nResource;
80 : : Id m_nId;
81 : :
82 : : CreateElement(ResourceType_t nResource, Id nId);
83 : : CreateElement();
84 : : };
85 : :
86 : : typedef boost::unordered_map<Token_t, CreateElement> CreateElementMap;
87 : : typedef boost::shared_ptr<CreateElementMap> CreateElementMapPointer;
88 : : typedef boost::unordered_map<Id, CreateElementMapPointer> CreateElementsMap;
89 : : typedef boost::unordered_map<Id, string> IdToStringMap;
90 : : typedef boost::shared_ptr<IdToStringMap> IdToStringMapPointer;
91 : :
92 : : typedef boost::unordered_map<Id, Token_t> TokenToIdMap;
93 : : typedef boost::shared_ptr<TokenToIdMap> TokenToIdMapPointer;
94 : : typedef boost::unordered_map<Id, TokenToIdMapPointer> TokenToIdsMap;
95 : :
96 [ + - ][ + - ]: 192 : class OOXMLFactory_ns {
[ + - ][ + - ]
97 : : public:
98 : : typedef boost::shared_ptr<OOXMLFactory_ns> Pointer_t;
99 : :
100 : : virtual void startAction(OOXMLFastContextHandler * pHandler);
101 : : virtual void charactersAction(OOXMLFastContextHandler * pHandler, const OUString & rString);
102 : : virtual void endAction(OOXMLFastContextHandler * pHandler);
103 : : virtual void attributeAction(OOXMLFastContextHandler * pHandler, Token_t nToken, OOXMLValue::Pointer_t pValue);
104 : : virtual string getDefineName(Id nId) const;
105 : : #ifdef DEBUG_FACTORY
106 : : virtual string getName() const;
107 : : #endif
108 : :
109 : : AttributeToResourceMapPointer getAttributeToResourceMap(Id nId);
110 : : ListValueMapPointer getListValueMap(Id nId);
111 : : CreateElementMapPointer getCreateElementMap(Id nId);
112 : : TokenToIdMapPointer getTokenToIdMap(Id nId);
113 : :
114 : : protected:
115 : : virtual ~OOXMLFactory_ns();
116 : :
117 : : AttributesMap m_AttributesMap;
118 : : ListValuesMap m_ListValuesMap;
119 : : CreateElementsMap m_CreateElementsMap;
120 : : TokenToIdsMap m_TokenToIdsMap;
121 : :
122 : : virtual AttributeToResourceMapPointer createAttributeToResourceMap(Id nId) = 0;
123 : : virtual ListValueMapPointer createListValueMap(Id nId) = 0;
124 : : virtual CreateElementMapPointer createCreateElementMap(Id nId) = 0;
125 : : virtual TokenToIdMapPointer createTokenToIdMap(Id nId) = 0;
126 : : };
127 : :
128 : : class OOXMLFactory
129 : : {
130 : : public:
131 : : typedef boost::shared_ptr<OOXMLFactory> Pointer_t;
132 : :
133 : : static Pointer_t getInstance();
134 : :
135 : : uno::Reference< xml::sax::XFastContextHandler> createFastChildContext
136 : : (OOXMLFastContextHandler * pHandler, Token_t Element);
137 : :
138 : : uno::Reference< xml::sax::XFastContextHandler> createFastChildContextFromStart
139 : : (OOXMLFastContextHandler * pHandler, Token_t Element);
140 : :
141 : : void attributes(OOXMLFastContextHandler * pHandler,
142 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs);
143 : :
144 : : void characters(OOXMLFastContextHandler * pHandler,
145 : : const OUString & rString);
146 : :
147 : : void startAction(OOXMLFastContextHandler * pHandler, Token_t nToken);
148 : : void endAction(OOXMLFastContextHandler * pHandler, Token_t nToken);
149 : :
150 : : virtual ~OOXMLFactory();
151 : :
152 : : private:
153 : : static Pointer_t m_Instance;
154 : :
155 : : OOXMLFactory();
156 : : OOXMLFactory_ns::Pointer_t getFactoryForNamespace(Id id);
157 : :
158 : : uno::Reference< xml::sax::XFastContextHandler>
159 : : createFastChildContextFromFactory(OOXMLFastContextHandler * pHandler,
160 : : OOXMLFactory_ns::Pointer_t pFactory,
161 : : Token_t Element);
162 : : };
163 : :
164 : : }
165 : : }
166 : :
167 : : #endif // INCLUDED_OOXML_FACTORY_HXX
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|