1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SDXMLEXP_IMPL_HXX
25 #define _SDXMLEXP_IMPL_HXX
26 
27 #include <xmloff/xmlexp.hxx>
28 
29 
30 #include <com/sun/star/frame/XModel.hpp>
31 #include <com/sun/star/task/XStatusIndicator.hpp>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/drawing/XDrawPage.hpp>
34 #include <comphelper/stl_types.hxx>
35 
36 //////////////////////////////////////////////////////////////////////////////
37 
38 class SvXMLUnitConverter;
39 class SvXMLExportItemMapper;
40 class SfxPoolItem;
41 class SfxItemSet;
42 class OUStrings_Impl;
43 class OUStringsSort_Impl;
44 class Rectangle;
45 
46 class ImpPresPageDrawStylePropMapper;
47 class ImpXMLEXPPageMasterList;
48 class ImpXMLEXPPageMasterInfo;
49 class ImpXMLDrawPageInfoList;
50 class ImpXMLAutoLayoutInfoList;
51 class SvXMLAutoStylePoolP;
52 class XMLSdPropHdlFactory;
53 class ImpXMLShapeStyleInfo;
54 class XMLShapeExportPropertyMapper;
55 class XMLPageExportPropertyMapper;
56 
57 //////////////////////////////////////////////////////////////////////////////
58 
59 enum XmlPlaceholder
60 {
61 	XmlPlaceholderTitle,
62 	XmlPlaceholderOutline,
63 	XmlPlaceholderSubtitle,
64 	XmlPlaceholderText,
65 	XmlPlaceholderGraphic,
66 	XmlPlaceholderObject,
67 	XmlPlaceholderChart,
68 	XmlPlaceholderOrgchart,
69 	XmlPlaceholderTable,
70 	XmlPlaceholderPage,
71 	XmlPlaceholderNotes,
72 	XmlPlaceholderHandout,
73 	XmlPlaceholderVerticalTitle,
74 	XmlPlaceholderVerticalOutline
75 };
76 
77 DECLARE_STL_STDKEY_SET( sal_Int32, SdXMLFormatMap );
78 
79 //////////////////////////////////////////////////////////////////////////////
80 
81 struct HeaderFooterPageSettingsImpl
82 {
83 	rtl::OUString maStrHeaderDeclName;
84 	rtl::OUString maStrFooterDeclName;
85 	rtl::OUString maStrDateTimeDeclName;
86 };
87 
88 struct DateTimeDeclImpl
89 {
90 	rtl::OUString maStrText;
91 	sal_Bool mbFixed;
92 	sal_Int32 mnFormat;
93 };
94 
95 
96 //////////////////////////////////////////////////////////////////////////////
97 
98 class SdXMLExport : public SvXMLExport
99 {
100 	com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > mxDocStyleFamilies;
101 	com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > mxDocMasterPages;
102 	com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > mxDocDrawPages;
103 	sal_Int32					mnDocMasterPageCount;
104 	sal_Int32					mnDocDrawPageCount;
105 	sal_uInt32					mnShapeStyleInfoIndex;
106 	sal_uInt32					mnObjectCount;
107 
108 	// temporary infos
109 	ImpXMLEXPPageMasterList*	mpPageMasterInfoList;
110 	ImpXMLEXPPageMasterList*	mpPageMasterUsageList;
111 	ImpXMLEXPPageMasterList*	mpNotesPageMasterUsageList;
112 	ImpXMLEXPPageMasterInfo*	mpHandoutPageMaster;
113 	ImpXMLAutoLayoutInfoList*	mpAutoLayoutInfoList;
114 
115 	com::sun::star::uno::Sequence< ::rtl::OUString > maDrawPagesAutoLayoutNames;
116 
117 	::std::vector< ::rtl::OUString >		maDrawPagesStyleNames;
118 	::std::vector< ::rtl::OUString >		maDrawNotesPagesStyleNames;
119 	::std::vector< ::rtl::OUString >		maMasterPagesStyleNames;
120 	::rtl::OUString							maHandoutMasterStyleName;
121 	::std::vector< HeaderFooterPageSettingsImpl >	maDrawPagesHeaderFooterSettings;
122 	::std::vector< HeaderFooterPageSettingsImpl >	maDrawNotesPagesHeaderFooterSettings;
123 
124 	::std::vector< ::rtl::OUString >		maHeaderDeclsVector;
125 	::std::vector< ::rtl::OUString >		maFooterDeclsVector;
126 	::std::vector< DateTimeDeclImpl >		maDateTimeDeclsVector;
127 
128 	HeaderFooterPageSettingsImpl			maHandoutPageHeaderFooterSettings;
129 
130 	XMLSdPropHdlFactory*				mpSdPropHdlFactory;
131 	XMLShapeExportPropertyMapper*		mpPropertySetMapper;
132 	XMLPageExportPropertyMapper*		mpPresPagePropsMapper;
133 
134 	SdXMLFormatMap	maUsedDateStyles;			// this is a vector with the used formatings for date fields
135 	SdXMLFormatMap	maUsedTimeStyles;			// this is a vector with the used formatings for time fields
136 
137 	sal_Bool					mbIsDraw;
138 	sal_Bool					mbFamilyGraphicUsed;
139 	sal_Bool					mbFamilyPresentationUsed;
140 
141 	const rtl::OUString			msZIndex;
142 	const rtl::OUString			msEmptyPres;
143 	const rtl::OUString			msModel;
144 	const rtl::OUString			msStartShape;
145 	const rtl::OUString			msEndShape;
146 	const rtl::OUString			msPageLayoutNames;
147 
148 	virtual void _ExportStyles(sal_Bool bUsed);
149 	virtual void _ExportAutoStyles();
150 	virtual void _ExportMasterStyles();
151 	virtual void _ExportContent();
152 	// #82003#
153 	virtual void _ExportMeta();
154 
155 	ImpXMLEXPPageMasterInfo* ImpGetOrCreatePageMasterInfo( com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > xMasterPage );
156 	void ImpPrepPageMasterInfos();
157 	void ImpPrepDrawMasterInfos();
158 	void ImpWritePageMasterInfos();
159 	void ImpPrepAutoLayoutInfos();
160 	HeaderFooterPageSettingsImpl ImpPrepDrawPageHeaderFooterDecls( const com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage >& xDrawPage );
161 	ImpXMLEXPPageMasterInfo* ImpGetPageMasterInfoByName(const rtl::OUString& rName);
162 
163 	void ImpPrepDrawPageInfos();
164 	void ImpPrepMasterPageInfos();
165 	void ImpWritePresentationStyles();
166 	::rtl::OUString ImpCreatePresPageStyleName( com::sun::star::uno::Reference<com::sun::star::drawing::XDrawPage> xDrawPage, bool bExportBackground = true );
167 
168 	sal_Bool ImpPrepAutoLayoutInfo(const com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage >& xPage, rtl::OUString& rName);
169 	void ImpWriteAutoLayoutInfos();
170 	void ImpWriteAutoLayoutPlaceholder(XmlPlaceholder ePl, const Rectangle& rRect);
171 	void ImpWriteHeaderFooterDecls();
172 	void ImplExportHeaderFooterDeclAttributes( const HeaderFooterPageSettingsImpl& aSettings );
173 
174 	void exportFormsElement( com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > xDrawPage );
175 	void exportPresentationSettings();
176 
177 	// #82003# helper function for recursive object count
178 	sal_uInt32 ImpRecursiveObjectCount( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xShapes);
179 
180 	rtl::OUString getNavigationOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage );
181 
182 	void collectAnnotationAutoStyles( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage );
183 	void exportAnnotations( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage );
184 
185 protected:
186 	virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
187 	virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
188 
189 public:
190 	// #110680#
191 	SdXMLExport(
192 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
193 		sal_Bool bIsDraw, sal_uInt16 nExportFlags = EXPORT_ALL );
194 	virtual ~SdXMLExport();
195 
196 	void SetProgress(sal_Int32 nProg);
197 
198 	// XExporter
199 	virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
200 
201 	// get factories and mappers
GetSdPropHdlFactory() const202 	XMLSdPropHdlFactory* GetSdPropHdlFactory() const { return mpSdPropHdlFactory; }
GetPropertySetMapper() const203 	XMLShapeExportPropertyMapper* GetPropertySetMapper() const { return mpPropertySetMapper; }
GetPresPagePropsMapper() const204 	XMLPageExportPropertyMapper* GetPresPagePropsMapper() const { return mpPresPagePropsMapper; }
205 
IsDraw() const206 	sal_Bool IsDraw() const { return mbIsDraw; }
IsImpress() const207 	sal_Bool IsImpress() const { return !mbIsDraw; }
208 
IsFamilyGraphicUsed() const209 	sal_Bool IsFamilyGraphicUsed() const { return mbFamilyGraphicUsed; }
SetFamilyGraphicUsed()210 	void SetFamilyGraphicUsed() { mbFamilyGraphicUsed = sal_True; }
IsFamilyPresentationUsed() const211 	sal_Bool IsFamilyPresentationUsed() const { return mbFamilyPresentationUsed; }
SetFamilyPresentationUsed()212 	void SetFamilyPresentationUsed() { mbFamilyPresentationUsed = sal_True; }
213 
214 	virtual void addDataStyle(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat = sal_False );
215 	virtual void exportDataStyles();
216 	virtual void exportAutoDataStyles();
217 	virtual rtl::OUString getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool bTimeFormat = sal_False ) const;
218 
219     // XServiceInfo ( : SvXMLExport )
220     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
221 };
222 
223 #endif	//  _SDXMLEXP_HXX
224 
225