merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / draw / sdxmlimp_impl.hxx
blob3cf1468ba2b6e0545edd59ac22fca8e40e7cb6b9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdxmlimp_impl.hxx,v $
10 * $Revision: 1.31 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SDXMLIMP_IMPL_HXX
32 #define _SDXMLIMP_IMPL_HXX
34 #include <com/sun/star/drawing/XDrawPage.hpp>
35 #include <com/sun/star/frame/XModel.hpp>
36 #include <com/sun/star/task/XStatusIndicator.hpp>
37 #include <xmloff/xmltkmap.hxx>
38 #include <com/sun/star/container/XNameAccess.hpp>
40 #ifndef __SGI_STL_VECTOR
41 #include <vector>
42 #endif
43 #include <xmloff/xmlimp.hxx>
45 //////////////////////////////////////////////////////////////////////////////
47 enum SdXMLDocElemTokenMap
49 XML_TOK_DOC_FONTDECLS,
50 XML_TOK_DOC_STYLES,
51 XML_TOK_DOC_AUTOSTYLES,
52 XML_TOK_DOC_MASTERSTYLES,
53 XML_TOK_DOC_META,
54 XML_TOK_DOC_BODY,
55 XML_TOK_DOC_SCRIPT,
56 XML_TOK_DOC_SETTINGS,
57 XML_TOK_OFFICE_END = XML_TOK_UNKNOWN
60 enum SdXMLBodyElemTokenMap
62 XML_TOK_BODY_PAGE,
63 XML_TOK_BODY_SETTINGS,
64 XML_TOK_BODY_HEADER_DECL,
65 XML_TOK_BODY_FOOTER_DECL,
66 XML_TOK_BODY_DATE_TIME_DECL
69 enum SdXMLStylesElemTokenMap
71 XML_TOK_STYLES_MASTER_PAGE,
72 XML_TOK_STYLES_STYLE,
73 XML_TOK_STYLES_PAGE_MASTER,
74 XML_TOK_STYLES_PRESENTATION_PAGE_LAYOUT
77 enum SdXMLAutoStylesElemTokenMap
79 XML_TOK_AUTOSTYLES_STYLE
82 enum SdXMLMasterPageElemTokenMap
84 XML_TOK_MASTERPAGE_STYLE,
85 XML_TOK_MASTERPAGE_NOTES
88 enum SdXMLMasterPageAttrTokenMap
90 XML_TOK_MASTERPAGE_NAME,
91 XML_TOK_MASTERPAGE_DISPLAY_NAME,
92 XML_TOK_MASTERPAGE_PAGE_MASTER_NAME,
93 XML_TOK_MASTERPAGE_STYLE_NAME,
94 XML_TOK_MASTERPAGE_PAGE_LAYOUT_NAME,
95 XML_TOK_MASTERPAGE_USE_HEADER_NAME,
96 XML_TOK_MASTERPAGE_USE_FOOTER_NAME,
97 XML_TOK_MASTERPAGE_USE_DATE_TIME_NAME
100 enum SdXMLPageMasterAttrTokenMap
102 XML_TOK_PAGEMASTER_NAME
105 enum SdXMLPageMasterStyleAttrTokenMap
107 XML_TOK_PAGEMASTERSTYLE_MARGIN_TOP,
108 XML_TOK_PAGEMASTERSTYLE_MARGIN_BOTTOM,
109 XML_TOK_PAGEMASTERSTYLE_MARGIN_LEFT,
110 XML_TOK_PAGEMASTERSTYLE_MARGIN_RIGHT,
111 XML_TOK_PAGEMASTERSTYLE_PAGE_WIDTH,
112 XML_TOK_PAGEMASTERSTYLE_PAGE_HEIGHT,
113 XML_TOK_PAGEMASTERSTYLE_PAGE_ORIENTATION
116 enum SdXMLDocStyleAttrTokenMap
118 XML_TOK_DOCSTYLE_NAME,
119 XML_TOK_DOCSTYLE_FAMILY,
120 XML_TOK_DOCSTYLE_PARENT_STYLE_NAME,
121 XML_TOK_DOCSTYLE_AUTOMATIC
124 enum SdXMLDocStyleElemTokenMap
126 XML_TOK_DOCSTYLE_PROPERTIES,
127 XML_TOK_DOCSTYLE_PRESENTATION_PLACEHOLDER
130 enum SdXMLDrawPageAttrTokenMap
132 XML_TOK_DRAWPAGE_NAME,
133 XML_TOK_DRAWPAGE_STYLE_NAME,
134 XML_TOK_DRAWPAGE_MASTER_PAGE_NAME,
135 XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME,
136 XML_TOK_DRAWPAGE_ID,
137 XML_TOK_DRAWPAGE_HREF,
138 XML_TOK_DRAWPAGE_USE_HEADER_NAME,
139 XML_TOK_DRAWPAGE_USE_FOOTER_NAME,
140 XML_TOK_DRAWPAGE_USE_DATE_TIME_NAME
143 enum SdXMLDrawPageElemTokenMap
145 XML_TOK_DRAWPAGE_NOTES,
146 XML_TOK_DRAWPAGE_PAR,
147 XML_TOK_DRAWPAGE_SEQ
150 enum SdXMLPresentationPlaceholderAttrTokenMap
152 XML_TOK_PRESENTATIONPLACEHOLDER_OBJECTNAME,
153 XML_TOK_PRESENTATIONPLACEHOLDER_X,
154 XML_TOK_PRESENTATIONPLACEHOLDER_Y,
155 XML_TOK_PRESENTATIONPLACEHOLDER_WIDTH,
156 XML_TOK_PRESENTATIONPLACEHOLDER_HEIGHT
159 //////////////////////////////////////////////////////////////////////////////
161 struct SdXMLltXDrawPageId
163 bool operator()(sal_Int32 nId1, sal_Int32 nId2 ) const
165 return nId1 < nId2;
169 typedef std::map< sal_Int32, com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage >, SdXMLltXDrawPageId > DrawPageIdMap;
171 //////////////////////////////////////////////////////////////////////////////
173 class SvXMLUnitConverter;
174 class SvXMLTokenMap;
175 class XMLSdPropHdlFactory;
176 class XMLPropertySetMapper;
177 class XMLPropStyleContext;
178 class SdXMLStylesContext;
179 class SdXMLMasterStylesContext;
181 //////////////////////////////////////////////////////////////////////////////
183 struct DateTimeDeclContextImpl
185 rtl::OUString maStrText;
186 sal_Bool mbFixed;
187 rtl::OUString maStrDateTimeFormat;
189 DateTimeDeclContextImpl() : mbFixed(sal_True) {}
192 DECLARE_STL_USTRINGACCESS_MAP( ::rtl::OUString, HeaderFooterDeclMap );
193 DECLARE_STL_USTRINGACCESS_MAP( DateTimeDeclContextImpl, DateTimeDeclMap );
195 //////////////////////////////////////////////////////////////////////////////
197 class SdXMLImport: public SvXMLImport
199 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > mxDocStyleFamilies;
200 com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > mxDocMasterPages;
201 com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > mxDocDrawPages;
202 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > mxPageLayouts;
204 // contexts for Style and AutoStyle import
205 SdXMLMasterStylesContext* mpMasterStylesContext;
207 // token map lists
208 SvXMLTokenMap* mpDocElemTokenMap;
209 SvXMLTokenMap* mpBodyElemTokenMap;
210 SvXMLTokenMap* mpStylesElemTokenMap;
211 SvXMLTokenMap* mpAutoStylesElemTokenMap;
212 SvXMLTokenMap* mpMasterPageElemTokenMap;
213 SvXMLTokenMap* mpMasterPageAttrTokenMap;
214 SvXMLTokenMap* mpPageMasterAttrTokenMap;
215 SvXMLTokenMap* mpPageMasterStyleAttrTokenMap;
216 SvXMLTokenMap* mpDocStyleAttrTokenMap;
217 SvXMLTokenMap* mpDocStyleElemTokenMap;
218 SvXMLTokenMap* mpDrawPageAttrTokenMap;
219 SvXMLTokenMap* mpDrawPageElemTokenMap;
220 SvXMLTokenMap* mpPresentationPlaceholderAttrTokenMap;
222 sal_uInt16 mnStyleFamilyMask;
224 sal_Int32 mnNewPageCount;
225 sal_Int32 mnNewMasterPageCount;
227 sal_Bool mbIsDraw;
228 sal_Bool mbLoadDoc;
229 sal_Bool mbPreview;
231 DrawPageIdMap maDrawPageIds;
233 ::rtl::OUString msPageLayouts;
234 ::rtl::OUString msPreview;
236 HeaderFooterDeclMap maHeaderDeclsMap;
237 HeaderFooterDeclMap maFooterDeclsMap;
238 DateTimeDeclMap maDateTimeDeclsMap;
240 protected:
241 // This method is called after the namespace map has been updated, but
242 // before a context for the current element has been pushed.
243 virtual SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
244 const rtl::OUString& rLocalName,
245 const com::sun::star::uno::Reference<
246 com::sun::star::xml::sax::XAttributeList>& xAttrList);
248 public:
249 // #110680#
250 SdXMLImport(
251 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
252 sal_Bool bIsDraw, sal_uInt16 nImportFlags = IMPORT_ALL );
253 ~SdXMLImport() throw ();
255 // XImporter
256 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);
258 // XInitialization
259 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);
261 void SetProgress(sal_Int32 nProg);
263 virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
264 virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps);
266 // namespace office
267 // NB: in contrast to other CreateFooContexts, this particular one handles
268 // the root element (i.e. office:document-meta)
269 SvXMLImportContext* CreateMetaContext(const rtl::OUString& rLocalName,
270 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
271 SvXMLImportContext* CreateScriptContext( const ::rtl::OUString& rLocalName );
272 SvXMLImportContext* CreateBodyContext(const rtl::OUString& rLocalName,
273 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
274 SvXMLStylesContext* CreateStylesContext(const rtl::OUString& rLocalName,
275 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
276 SvXMLStylesContext* CreateAutoStylesContext(const rtl::OUString& rLocalName,
277 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
278 SvXMLImportContext* CreateMasterStylesContext(const rtl::OUString& rLocalName,
279 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
280 SvXMLImportContext *CreateFontDeclsContext(const ::rtl::OUString& rLocalName,
281 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
283 // Styles and AutoStyles contexts
284 const SdXMLMasterStylesContext* GetMasterStylesContext() const { return mpMasterStylesContext; }
286 sal_uInt16 GetStyleFamilyMask() const { return mnStyleFamilyMask; }
287 sal_Bool IsStylesOnlyMode() const { return !mbLoadDoc; }
289 const SvXMLTokenMap& GetDocElemTokenMap();
290 const SvXMLTokenMap& GetBodyElemTokenMap();
291 const SvXMLTokenMap& GetStylesElemTokenMap();
292 const SvXMLTokenMap& GetMasterPageElemTokenMap();
293 const SvXMLTokenMap& GetMasterPageAttrTokenMap();
294 const SvXMLTokenMap& GetPageMasterAttrTokenMap();
295 const SvXMLTokenMap& GetPageMasterStyleAttrTokenMap();
296 const SvXMLTokenMap& GetDrawPageAttrTokenMap();
297 const SvXMLTokenMap& GetDrawPageElemTokenMap();
298 const SvXMLTokenMap& GetPresentationPlaceholderAttrTokenMap();
300 // export local parameters concerning page access and similar
301 const com::sun::star::uno::Reference<
302 com::sun::star::container::XNameAccess >& GetLocalDocStyleFamilies() const { return mxDocStyleFamilies; }
303 const com::sun::star::uno::Reference<
304 com::sun::star::container::XIndexAccess >& GetLocalMasterPages() const { return mxDocMasterPages; }
305 const com::sun::star::uno::Reference<
306 com::sun::star::container::XIndexAccess >& GetLocalDrawPages() const { return mxDocDrawPages; }
308 sal_Int32 GetNewPageCount() const { return mnNewPageCount; }
309 void IncrementNewPageCount() { mnNewPageCount++; }
310 sal_Int32 GetNewMasterPageCount() const { return mnNewMasterPageCount; }
311 void IncrementNewMasterPageCount() { mnNewMasterPageCount++; }
313 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getPageLayouts() const { return mxPageLayouts; }
315 sal_Bool IsDraw() const { return mbIsDraw; }
316 sal_Bool IsImpress() const { return !mbIsDraw; }
318 // import pool defaults. Parameter contains pool defaults read
319 // from input data. These data needs to be set at the model.
320 void ImportPoolDefaults(const XMLPropStyleContext* pPool);
322 // #80365#
323 virtual void SetStatistics(
324 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue> & i_rStats);
326 sal_Bool IsPreview() const { return mbPreview; }
328 // XServiceInfo ( : SvXMLExport )
329 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
331 void AddHeaderDecl( const ::rtl::OUString& rName, const ::rtl::OUString& rText );
332 void AddFooterDecl( const ::rtl::OUString& rName, const ::rtl::OUString& rText );
333 void AddDateTimeDecl( const ::rtl::OUString& rName, const ::rtl::OUString& rText, sal_Bool bFixed, const ::rtl::OUString& rDateTimeFormat );
335 ::rtl::OUString GetHeaderDecl( const ::rtl::OUString& rName ) const;
336 ::rtl::OUString GetFooterDecl( const ::rtl::OUString& rName ) const;
337 ::rtl::OUString GetDateTimeDecl( const ::rtl::OUString& rName, sal_Bool& rbFixed, ::rtl::OUString& rDateTimeFormat );
341 #endif // _SDXMLIMP_HXX