bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / draw / sdxmlimp_impl.hxx
blob23e192903495cd6ace10af41461e645db91784ce
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_XMLOFF_SOURCE_DRAW_SDXMLIMP_IMPL_HXX
21 #define INCLUDED_XMLOFF_SOURCE_DRAW_SDXMLIMP_IMPL_HXX
23 #include <com/sun/star/drawing/XDrawPage.hpp>
24 #include <com/sun/star/frame/XModel.hpp>
25 #include <com/sun/star/task/XStatusIndicator.hpp>
26 #include <xmloff/xmltkmap.hxx>
27 #include <com/sun/star/container/XNameAccess.hpp>
29 #include <map>
30 #include <vector>
31 #include <xmloff/xmlimp.hxx>
33 enum SdXMLDocElemTokenMap
35 XML_TOK_DOC_FONTDECLS,
36 XML_TOK_DOC_STYLES,
37 XML_TOK_DOC_AUTOSTYLES,
38 XML_TOK_DOC_MASTERSTYLES,
39 XML_TOK_DOC_META,
40 XML_TOK_DOC_BODY,
41 XML_TOK_DOC_SCRIPT,
42 XML_TOK_DOC_SETTINGS,
43 XML_TOK_OFFICE_END = XML_TOK_UNKNOWN
46 enum SdXMLBodyElemTokenMap
48 XML_TOK_BODY_PAGE,
49 XML_TOK_BODY_SETTINGS,
50 XML_TOK_BODY_HEADER_DECL,
51 XML_TOK_BODY_FOOTER_DECL,
52 XML_TOK_BODY_DATE_TIME_DECL
55 enum SdXMLStylesElemTokenMap
57 XML_TOK_STYLES_MASTER_PAGE,
58 XML_TOK_STYLES_STYLE,
59 XML_TOK_STYLES_PAGE_MASTER,
60 XML_TOK_STYLES_PRESENTATION_PAGE_LAYOUT
63 enum SdXMLAutoStylesElemTokenMap
65 XML_TOK_AUTOSTYLES_STYLE
68 enum SdXMLMasterPageElemTokenMap
70 XML_TOK_MASTERPAGE_STYLE,
71 XML_TOK_MASTERPAGE_NOTES
74 enum SdXMLMasterPageAttrTokenMap
76 XML_TOK_MASTERPAGE_NAME,
77 XML_TOK_MASTERPAGE_DISPLAY_NAME,
78 XML_TOK_MASTERPAGE_PAGE_MASTER_NAME,
79 XML_TOK_MASTERPAGE_STYLE_NAME,
80 XML_TOK_MASTERPAGE_PAGE_LAYOUT_NAME,
81 XML_TOK_MASTERPAGE_USE_HEADER_NAME,
82 XML_TOK_MASTERPAGE_USE_FOOTER_NAME,
83 XML_TOK_MASTERPAGE_USE_DATE_TIME_NAME
86 enum SdXMLPageMasterAttrTokenMap
88 XML_TOK_PAGEMASTER_NAME
91 enum SdXMLPageMasterStyleAttrTokenMap
93 XML_TOK_PAGEMASTERSTYLE_MARGIN_TOP,
94 XML_TOK_PAGEMASTERSTYLE_MARGIN_BOTTOM,
95 XML_TOK_PAGEMASTERSTYLE_MARGIN_LEFT,
96 XML_TOK_PAGEMASTERSTYLE_MARGIN_RIGHT,
97 XML_TOK_PAGEMASTERSTYLE_PAGE_WIDTH,
98 XML_TOK_PAGEMASTERSTYLE_PAGE_HEIGHT,
99 XML_TOK_PAGEMASTERSTYLE_PAGE_ORIENTATION
102 enum SdXMLDocStyleAttrTokenMap
104 XML_TOK_DOCSTYLE_NAME,
105 XML_TOK_DOCSTYLE_FAMILY,
106 XML_TOK_DOCSTYLE_PARENT_STYLE_NAME,
107 XML_TOK_DOCSTYLE_AUTOMATIC
110 enum SdXMLDocStyleElemTokenMap
112 XML_TOK_DOCSTYLE_PROPERTIES,
113 XML_TOK_DOCSTYLE_PRESENTATION_PLACEHOLDER
116 enum SdXMLDrawPageAttrTokenMap
118 XML_TOK_DRAWPAGE_NAME,
119 XML_TOK_DRAWPAGE_STYLE_NAME,
120 XML_TOK_DRAWPAGE_MASTER_PAGE_NAME,
121 XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME,
122 XML_TOK_DRAWPAGE_DRAWID,
123 XML_TOK_DRAWPAGE_XMLID,
124 XML_TOK_DRAWPAGE_HREF,
125 XML_TOK_DRAWPAGE_USE_HEADER_NAME,
126 XML_TOK_DRAWPAGE_USE_FOOTER_NAME,
127 XML_TOK_DRAWPAGE_USE_DATE_TIME_NAME
130 enum SdXMLDrawPageElemTokenMap
132 XML_TOK_DRAWPAGE_NOTES,
133 XML_TOK_DRAWPAGE_PAR,
134 XML_TOK_DRAWPAGE_SEQ
137 enum SdXMLPresentationPlaceholderAttrTokenMap
139 XML_TOK_PRESENTATIONPLACEHOLDER_OBJECTNAME,
140 XML_TOK_PRESENTATIONPLACEHOLDER_X,
141 XML_TOK_PRESENTATIONPLACEHOLDER_Y,
142 XML_TOK_PRESENTATIONPLACEHOLDER_WIDTH,
143 XML_TOK_PRESENTATIONPLACEHOLDER_HEIGHT
146 struct SdXMLltXDrawPageId
148 bool operator()(sal_Int32 nId1, sal_Int32 nId2 ) const
150 return nId1 < nId2;
154 typedef std::map< sal_Int32, com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage >, SdXMLltXDrawPageId > DrawPageIdMap;
156 class SvXMLUnitConverter;
157 class SvXMLTokenMap;
158 class SdXMLMasterStylesContext;
160 struct DateTimeDeclContextImpl
162 OUString maStrText;
163 bool mbFixed;
164 OUString maStrDateTimeFormat;
166 DateTimeDeclContextImpl() : mbFixed(true) {}
169 typedef std::map<OUString, OUString> HeaderFooterDeclMap;
170 typedef std::map<OUString, DateTimeDeclContextImpl> DateTimeDeclMap;
172 class SdXMLImport: public SvXMLImport
174 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > mxDocStyleFamilies;
175 com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > mxDocMasterPages;
176 com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > mxDocDrawPages;
177 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > mxPageLayouts;
179 // contexts for Style and AutoStyle import
180 SdXMLMasterStylesContext* mpMasterStylesContext;
182 // token map lists
183 SvXMLTokenMap* mpDocElemTokenMap;
184 SvXMLTokenMap* mpBodyElemTokenMap;
185 SvXMLTokenMap* mpStylesElemTokenMap;
186 SvXMLTokenMap* mpMasterPageElemTokenMap;
187 SvXMLTokenMap* mpMasterPageAttrTokenMap;
188 SvXMLTokenMap* mpPageMasterAttrTokenMap;
189 SvXMLTokenMap* mpPageMasterStyleAttrTokenMap;
190 SvXMLTokenMap* mpDrawPageAttrTokenMap;
191 SvXMLTokenMap* mpDrawPageElemTokenMap;
192 SvXMLTokenMap* mpPresentationPlaceholderAttrTokenMap;
194 sal_uInt16 mnStyleFamilyMask;
196 sal_Int32 mnNewPageCount;
197 sal_Int32 mnNewMasterPageCount;
199 bool mbIsDraw;
200 bool mbLoadDoc;
201 bool mbPreview;
203 DrawPageIdMap maDrawPageIds;
205 OUString msPageLayouts;
206 OUString msPreview;
208 HeaderFooterDeclMap maHeaderDeclsMap;
209 HeaderFooterDeclMap maFooterDeclsMap;
210 DateTimeDeclMap maDateTimeDeclsMap;
212 protected:
213 // This method is called after the namespace map has been updated, but
214 // before a context for the current element has been pushed.
215 virtual SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
216 const OUString& rLocalName,
217 const com::sun::star::uno::Reference<
218 com::sun::star::xml::sax::XAttributeList>& xAttrList) SAL_OVERRIDE;
220 public:
221 SdXMLImport(
222 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
223 OUString const & implementationName,
224 bool bIsDraw, SvXMLImportFlags nImportFlags );
225 virtual ~SdXMLImport() throw ();
227 // XImporter
228 virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
230 // XInitialization
231 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
233 virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps) SAL_OVERRIDE;
234 virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps) SAL_OVERRIDE;
236 // namespace office
237 // NB: in contrast to other CreateFooContexts, this particular one handles
238 // the root element (i.e. office:document-meta)
239 SvXMLImportContext* CreateMetaContext(const OUString& rLocalName,
240 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
241 SvXMLImportContext* CreateScriptContext( const OUString& rLocalName );
242 SvXMLImportContext* CreateBodyContext(const OUString& rLocalName,
243 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
244 SvXMLStylesContext* CreateStylesContext(const OUString& rLocalName,
245 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
246 SvXMLStylesContext* CreateAutoStylesContext(const OUString& rLocalName,
247 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
248 SvXMLImportContext* CreateMasterStylesContext(const OUString& rLocalName,
249 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
250 SvXMLImportContext *CreateFontDeclsContext(const OUString& rLocalName,
251 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
253 // Styles and AutoStyles contexts
254 const SdXMLMasterStylesContext* GetMasterStylesContext() const { return mpMasterStylesContext; }
256 sal_uInt16 GetStyleFamilyMask() const { return mnStyleFamilyMask; }
257 bool IsStylesOnlyMode() const { return !mbLoadDoc; }
259 const SvXMLTokenMap& GetDocElemTokenMap();
260 const SvXMLTokenMap& GetBodyElemTokenMap();
261 const SvXMLTokenMap& GetStylesElemTokenMap();
262 const SvXMLTokenMap& GetMasterPageElemTokenMap();
263 const SvXMLTokenMap& GetMasterPageAttrTokenMap();
264 const SvXMLTokenMap& GetPageMasterAttrTokenMap();
265 const SvXMLTokenMap& GetPageMasterStyleAttrTokenMap();
266 const SvXMLTokenMap& GetDrawPageAttrTokenMap();
267 const SvXMLTokenMap& GetDrawPageElemTokenMap();
268 const SvXMLTokenMap& GetPresentationPlaceholderAttrTokenMap();
270 // export local parameters concerning page access and similar
271 const com::sun::star::uno::Reference<
272 com::sun::star::container::XNameAccess >& GetLocalDocStyleFamilies() const { return mxDocStyleFamilies; }
273 const com::sun::star::uno::Reference<
274 com::sun::star::container::XIndexAccess >& GetLocalMasterPages() const { return mxDocMasterPages; }
275 const com::sun::star::uno::Reference<
276 com::sun::star::container::XIndexAccess >& GetLocalDrawPages() const { return mxDocDrawPages; }
278 sal_Int32 GetNewPageCount() const { return mnNewPageCount; }
279 void IncrementNewPageCount() { mnNewPageCount++; }
280 sal_Int32 GetNewMasterPageCount() const { return mnNewMasterPageCount; }
281 void IncrementNewMasterPageCount() { mnNewMasterPageCount++; }
283 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getPageLayouts() const { return mxPageLayouts; }
285 bool IsDraw() const { return mbIsDraw; }
286 bool IsImpress() const { return !mbIsDraw; }
288 // #80365#
289 virtual void SetStatistics(
290 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue> & i_rStats) SAL_OVERRIDE;
292 bool IsPreview() const { return mbPreview; }
294 void AddHeaderDecl( const OUString& rName, const OUString& rText );
295 void AddFooterDecl( const OUString& rName, const OUString& rText );
296 void AddDateTimeDecl( const OUString& rName, const OUString& rText, bool bFixed, const OUString& rDateTimeFormat );
298 OUString GetHeaderDecl( const OUString& rName ) const;
299 OUString GetFooterDecl( const OUString& rName ) const;
300 OUString GetDateTimeDecl( const OUString& rName, bool& rbFixed, OUString& rDateTimeFormat );
302 virtual void NotifyEmbeddedFontRead() SAL_OVERRIDE;
305 #endif // _SDXMLIMP_HXX
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */