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 SC_XMLEXPRT_HXX
20 : #define SC_XMLEXPRT_HXX
21 :
22 : #include <xmloff/xmlexp.hxx>
23 : #include <com/sun/star/sheet/XSpreadsheet.hpp>
24 : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
25 : #include <com/sun/star/table/CellRangeAddress.hpp>
26 : #include <com/sun/star/table/CellAddress.hpp>
27 : #include <com/sun/star/drawing/XShapes.hpp>
28 : #include <com/sun/star/table/XCellRange.hpp>
29 :
30 : #include "address.hxx"
31 :
32 : namespace com { namespace sun { namespace star {
33 : namespace beans { class XPropertySet; }
34 : } } }
35 :
36 : #include <boost/unordered_map.hpp>
37 :
38 : class ScOutlineArray;
39 : class SvXMLExportPropertyMapper;
40 : class ScMyMergedRangesContainer;
41 : class ScMyValidationsContainer;
42 : class ScMyNotEmptyCellsIterator;
43 : class ScChangeTrackingExportHelper;
44 : class ScColumnStyles;
45 : class ScRowStyles;
46 : class ScFormatRangeStyles;
47 : class ScRowFormatRanges;
48 : class ScMyOpenCloseColumnRowGroup;
49 : class ScMyAreaLinksContainer;
50 : class ScMyDetectiveOpContainer;
51 : struct ScMyCell;
52 : class ScDocument;
53 : class ScMySharedData;
54 : class ScMyDefaultStyles;
55 : class XMLNumberFormatAttributesExportHelper;
56 : class ScChartListener;
57 : class SfxItemPool;
58 : class ScAddress;
59 : class ScXMLCachedRowAttrAccess;
60 : class ScRangeName;
61 :
62 : typedef std::vector< com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > > ScMyXShapesVec;
63 :
64 : class ScXMLExport : public SvXMLExport
65 : {
66 : ScDocument* pDoc;
67 : com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheet> xCurrentTable;
68 : com::sun::star::uno::Reference <com::sun::star::table::XCellRange> xCurrentTableCellRange;
69 :
70 : com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xSourceStream;
71 : sal_Int32 nSourceStreamPos;
72 :
73 : UniReference < XMLPropertyHandlerFactory > xScPropHdlFactory;
74 : UniReference < XMLPropertySetMapper > xCellStylesPropertySetMapper;
75 : UniReference < XMLPropertySetMapper > xColumnStylesPropertySetMapper;
76 : UniReference < XMLPropertySetMapper > xRowStylesPropertySetMapper;
77 : UniReference < XMLPropertySetMapper > xTableStylesPropertySetMapper;
78 : UniReference < SvXMLExportPropertyMapper > xCellStylesExportPropertySetMapper;
79 : UniReference < SvXMLExportPropertyMapper > xColumnStylesExportPropertySetMapper;
80 : UniReference < SvXMLExportPropertyMapper > xRowStylesExportPropertySetMapper;
81 : UniReference < SvXMLExportPropertyMapper > xTableStylesExportPropertySetMapper;
82 : XMLNumberFormatAttributesExportHelper* pNumberFormatAttributesExportHelper;
83 : typedef ::boost::unordered_map<sal_Int32, sal_Int32> NumberFormatIndexMap;
84 : NumberFormatIndexMap aNumFmtIndexMap;
85 : ScMySharedData* pSharedData;
86 : ScColumnStyles* pColumnStyles;
87 : ScRowStyles* pRowStyles;
88 : ScFormatRangeStyles* pCellStyles;
89 : ScRowFormatRanges* pRowFormatRanges;
90 : std::vector<rtl::OUString> aTableStyles;
91 : com::sun::star::table::CellRangeAddress aRowHeaderRange;
92 : ScMyOpenCloseColumnRowGroup* pGroupColumns;
93 : ScMyOpenCloseColumnRowGroup* pGroupRows;
94 : ScMyDefaultStyles* pDefaults;
95 : ScChartListener* pChartListener;
96 : const ScMyCell* pCurrentCell;
97 :
98 : ScMyMergedRangesContainer* pMergedRangesContainer;
99 : ScMyValidationsContainer* pValidationsContainer;
100 : ScMyNotEmptyCellsIterator* pCellsItr;
101 : ScChangeTrackingExportHelper* pChangeTrackingExportHelper;
102 : const rtl::OUString sLayerID;
103 : const rtl::OUString sCaptionShape;
104 : rtl::OUString sExternalRefTabStyleName;
105 : rtl::OUString sAttrName;
106 : rtl::OUString sAttrStyleName;
107 : rtl::OUString sAttrColumnsRepeated;
108 : rtl::OUString sAttrFormula;
109 : rtl::OUString sAttrValueType;
110 : rtl::OUString sAttrStringValue;
111 : rtl::OUString sElemCell;
112 : rtl::OUString sElemCoveredCell;
113 : rtl::OUString sElemCol;
114 : rtl::OUString sElemRow;
115 : rtl::OUString sElemTab;
116 : rtl::OUString sElemP;
117 : sal_Int32 nOpenRow;
118 : sal_Int32 nProgressCount;
119 : sal_uInt16 nCurrentTable;
120 : bool bHasRowHeader;
121 : bool bRowHeaderOpen;
122 : bool mbShowProgress;
123 :
124 : sal_Int32 GetNumberFormatStyleIndex(sal_Int32 nNumFmt) const;
125 : void CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCount);
126 : void CollectShapesAutoStyles(const sal_Int32 nTableCount);
127 : void WriteTablesView(const com::sun::star::uno::Any& aTableView);
128 : void WriteView(const com::sun::star::uno::Any& aView);
129 : virtual void _ExportFontDecls();
130 : virtual void _ExportStyles( sal_Bool bUsed );
131 : virtual void _ExportAutoStyles();
132 : virtual void _ExportMasterStyles();
133 : virtual void SetBodyAttributes();
134 : virtual void _ExportContent();
135 : virtual void _ExportMeta();
136 :
137 : void CollectInternalShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
138 :
139 : com::sun::star::table::CellRangeAddress GetEndAddress(const com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet>& xTable,
140 : const sal_Int32 nTable);
141 : // ScMyEmptyDatabaseRangesContainer GetEmptyDatabaseRanges();
142 : void GetAreaLinks( com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc, ScMyAreaLinksContainer& rAreaLinks );
143 : void GetDetectiveOpList( ScMyDetectiveOpContainer& rDetOp );
144 : void WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_Int32 nStyleIndex,
145 : const sal_Int32 nIndex, const bool bIsAutoStyle, const bool bIsVisible);
146 : void WriteColumn(const sal_Int32 nColumn, const sal_Int32 nRepeatColumns,
147 : const sal_Int32 nStyleIndex, const bool bIsVisible);
148 : void OpenHeaderColumn();
149 : void CloseHeaderColumn();
150 : void ExportColumns(const sal_Int32 nTable, const com::sun::star::table::CellRangeAddress& aColumnHeaderRange, const bool bHasColumnHeader);
151 : void ExportExternalRefCacheStyles();
152 : void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow,
153 : const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet);
154 : void WriteRowContent();
155 : void WriteRowStartTag(sal_Int32 nRow, const sal_Int32 nIndex, const sal_Int32 nEmptyRows, bool bHidden, bool bFiltered);
156 : void OpenHeaderRows();
157 : void CloseHeaderRows();
158 : void OpenNewRow(const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEmptyRows,
159 : bool bHidden, bool bFiltered);
160 : void OpenAndCloseRow(const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEmptyRows,
161 : bool bHidden, bool bFiltered);
162 : void OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, const sal_Int32 nRepeatRow, ScXMLCachedRowAttrAccess& rRowAttr);
163 : void CloseRow(const sal_Int32 nRow);
164 : void GetColumnRowHeader(bool& bHasColumnHeader, com::sun::star::table::CellRangeAddress& aColumnHeaderRange,
165 : bool& bHasRowHeader, com::sun::star::table::CellRangeAddress& aRowHeaderRange,
166 : rtl::OUString& rPrintRanges) const;
167 : void FillFieldGroup(ScOutlineArray* pFields, ScMyOpenCloseColumnRowGroup* pGroups);
168 : void FillColumnRowGroups();
169 :
170 : bool GetMerged (const com::sun::star::table::CellRangeAddress* pCellRange,
171 : const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheet>& xTable);
172 :
173 : bool GetCellText (ScMyCell& rMyCell, const ScAddress& aPos) const;
174 :
175 : void WriteTable(sal_Int32 nTable, const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet>& xTable);
176 : void WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount);
177 : void WriteAreaLink(const ScMyCell& rMyCell);
178 : void WriteAnnotation(ScMyCell& rMyCell);
179 : void WriteDetective(const ScMyCell& rMyCell);
180 : void ExportShape(const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape, com::sun::star::awt::Point* pPoint);
181 : void WriteShapes(const ScMyCell& rMyCell);
182 : void WriteTableShapes();
183 : void SetRepeatAttribute(sal_Int32 nEqualCellCount, bool bIncProgress);
184 :
185 : bool IsCellTypeEqual (const ScMyCell& aCell1, const ScMyCell& aCell2) const;
186 : bool IsEditCell(const com::sun::star::table::CellAddress& aAddress, ScMyCell* pMyCell = NULL) const;
187 : bool IsEditCell(ScMyCell& rCell) const;
188 : bool IsMultiLineFormulaCell(ScMyCell& rCell) const;
189 : bool IsCellEqual (ScMyCell& aCell1, ScMyCell& aCell2);
190 :
191 : void WriteCalculationSettings(const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc);
192 : void WriteTableSource();
193 : void WriteScenario(); // core implementation
194 : void WriteTheLabelRanges(const com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheetDocument >& xSpreadDoc);
195 : void WriteLabelRanges( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xRangesIAccess, bool bColumn );
196 : void WriteNamedExpressions();
197 : void WriteNamedRange(ScRangeName* pRangeName);
198 : void ExportConditionalFormat(SCTAB nTab);
199 : void WriteExternalRefCaches();
200 : void WriteConsolidation(); // core implementation
201 :
202 :
203 : void CollectUserDefinedNamespaces(const SfxItemPool* pPool, sal_uInt16 nAttrib);
204 :
205 : void AddStyleFromCells(
206 : const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xProperties,
207 : const com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheet >& xTable,
208 : sal_Int32 nTable, const rtl::OUString* pOldName );
209 : void AddStyleFromColumn(
210 : const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xColumnProperties,
211 : const rtl::OUString* pOldName, sal_Int32& rIndex, bool& rIsVisible );
212 : void AddStyleFromRow(
213 : const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xRowProperties,
214 : const rtl::OUString* pOldName, sal_Int32& rIndex );
215 :
216 : void IncrementProgressBar(bool bEditCell, sal_Int32 nInc = 1);
217 :
218 : void CopySourceStream( sal_Int32 nStartOffset, sal_Int32 nEndOffset, sal_Int32& rNewStart, sal_Int32& rNewEnd );
219 :
220 : protected:
221 : virtual SvXMLAutoStylePoolP* CreateAutoStylePool();
222 : virtual XMLPageExport* CreatePageExport();
223 : virtual XMLShapeExport* CreateShapeExport();
224 : virtual XMLFontAutoStylePool* CreateFontAutoStylePool();
225 : public:
226 : // #110680#
227 : ScXMLExport(
228 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
229 : const sal_uInt16 nExportFlag);
230 :
231 : virtual ~ScXMLExport();
232 :
233 : static sal_Int16 GetFieldUnit();
234 74 : inline ScDocument* GetDocument() { return pDoc; }
235 0 : inline const ScDocument* GetDocument() const { return pDoc; }
236 : bool IsMatrix (const ScAddress& aCell,
237 : com::sun::star::table::CellRangeAddress& aCellAddress, bool& bIsFirst) const;
238 :
239 2 : UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() { return xCellStylesPropertySetMapper; }
240 8 : UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() { return xTableStylesPropertySetMapper; }
241 :
242 : void SetSourceStream( const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xNewStream );
243 :
244 : void GetChangeTrackViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rProps);
245 : virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rProps);
246 : virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rProps);
247 :
248 : virtual void exportAnnotationMeta( const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape);
249 :
250 : void CreateSharedData(const sal_Int32 nTableCount);
251 8 : void SetSharedData(ScMySharedData* pTemp) { pSharedData = pTemp; }
252 12 : ScMySharedData* GetSharedData() { return pSharedData; }
253 : XMLNumberFormatAttributesExportHelper* GetNumberFormatAttributesExportHelper();
254 :
255 : // Export the document.
256 : virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID );
257 :
258 : // XExporter
259 : 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);
260 :
261 : // XFilter
262 : virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) throw(::com::sun::star::uno::RuntimeException);
263 : virtual void SAL_CALL cancel() throw(::com::sun::star::uno::RuntimeException);
264 :
265 : // XInitialization
266 : 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);
267 :
268 : // XServiceInfo
269 : virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
270 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
271 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
272 :
273 : // XUnoTunnel
274 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
275 :
276 : virtual void DisposingModel();
277 : };
278 :
279 : #endif
280 :
281 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|