1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlexprt.hxx,v $
10 * $Revision: 1.84.52.1 $
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 ************************************************************************/
30 #ifndef SC_XMLEXPRT_HXX
31 #define SC_XMLEXPRT_HXX
33 #include <xmloff/xmlexp.hxx>
34 #include <com/sun/star/sheet/XSpreadsheet.hpp>
35 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
36 #include <com/sun/star/table/CellRangeAddress.hpp>
37 #include <com/sun/star/table/CellAddress.hpp>
38 #include <com/sun/star/drawing/XShapes.hpp>
39 #include <com/sun/star/table/XCellRange.hpp>
41 namespace com
{ namespace sun
{ namespace star
{
42 namespace beans
{ class XPropertySet
; }
48 class SvXMLExportPropertyMapper
;
49 class ScMyShapesContainer
;
50 class ScMyMergedRangesContainer
;
51 class ScMyValidationsContainer
;
52 class ScMyNotEmptyCellsIterator
;
53 class ScChangeTrackingExportHelper
;
56 class ScFormatRangeStyles
;
57 class ScRowFormatRanges
;
58 class ScMyOpenCloseColumnRowGroup
;
59 class ScMyAreaLinksContainer
;
60 class ScMyDetectiveOpContainer
;
64 class ScMyDefaultStyles
;
65 class XMLNumberFormatAttributesExportHelper
;
66 class ScChartListener
;
71 typedef std::vector
< com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
> > ScMyXShapesVec
;
73 class ScXMLExport
: public SvXMLExport
76 com::sun::star::uno::Reference
<com::sun::star::sheet::XSpreadsheet
> xCurrentTable
;
77 com::sun::star::uno::Reference
<com::sun::star::table::XCellRange
> xCurrentTableCellRange
;
79 com::sun::star::uno::Reference
<com::sun::star::io::XInputStream
> xSourceStream
;
80 sal_Int32 nSourceStreamPos
;
82 UniReference
< XMLPropertyHandlerFactory
> xScPropHdlFactory
;
83 UniReference
< XMLPropertySetMapper
> xCellStylesPropertySetMapper
;
84 UniReference
< XMLPropertySetMapper
> xColumnStylesPropertySetMapper
;
85 UniReference
< XMLPropertySetMapper
> xRowStylesPropertySetMapper
;
86 UniReference
< XMLPropertySetMapper
> xTableStylesPropertySetMapper
;
87 UniReference
< SvXMLExportPropertyMapper
> xCellStylesExportPropertySetMapper
;
88 UniReference
< SvXMLExportPropertyMapper
> xColumnStylesExportPropertySetMapper
;
89 UniReference
< SvXMLExportPropertyMapper
> xRowStylesExportPropertySetMapper
;
90 UniReference
< SvXMLExportPropertyMapper
> xTableStylesExportPropertySetMapper
;
91 XMLNumberFormatAttributesExportHelper
* pNumberFormatAttributesExportHelper
;
92 typedef ::std::hash_map
<sal_Int32
, sal_Int32
> NumberFormatIndexMap
;
93 NumberFormatIndexMap aNumFmtIndexMap
;
94 ScMySharedData
* pSharedData
;
95 ScColumnStyles
* pColumnStyles
;
96 ScRowStyles
* pRowStyles
;
97 ScFormatRangeStyles
* pCellStyles
;
98 ScRowFormatRanges
* pRowFormatRanges
;
99 std::vector
<rtl::OUString
> aTableStyles
;
100 com::sun::star::table::CellRangeAddress aRowHeaderRange
;
101 ScMyOpenCloseColumnRowGroup
* pGroupColumns
;
102 ScMyOpenCloseColumnRowGroup
* pGroupRows
;
103 ScMyDefaultStyles
* pDefaults
;
104 ScChartListener
* pChartListener
;
105 const ScMyCell
* pCurrentCell
;
107 ScMyMergedRangesContainer
* pMergedRangesContainer
;
108 ScMyValidationsContainer
* pValidationsContainer
;
109 ScMyNotEmptyCellsIterator
* pCellsItr
;
110 ScChangeTrackingExportHelper
* pChangeTrackingExportHelper
;
111 const rtl::OUString sLayerID
;
112 const rtl::OUString sCaptionShape
;
113 rtl::OUString sExternalRefTabStyleName
;
114 rtl::OUString sAttrName
;
115 rtl::OUString sAttrStyleName
;
116 rtl::OUString sAttrColumnsRepeated
;
117 rtl::OUString sAttrFormula
;
118 rtl::OUString sAttrValueType
;
119 rtl::OUString sAttrStringValue
;
120 rtl::OUString sElemCell
;
121 rtl::OUString sElemCoveredCell
;
122 rtl::OUString sElemCol
;
123 rtl::OUString sElemRow
;
124 rtl::OUString sElemTab
;
125 rtl::OUString sElemP
;
127 sal_Int32 nProgressCount
;
128 sal_uInt16 nCurrentTable
;
129 sal_Bool bHasRowHeader
;
130 sal_Bool bRowHeaderOpen
;
131 sal_Bool mbShowProgress
;
133 sal_Int32
GetNumberFormatStyleIndex(sal_Int32 nNumFmt
) const;
134 sal_Bool
HasDrawPages(com::sun::star::uno::Reference
<com::sun::star::sheet::XSpreadsheetDocument
>& xDoc
);
135 void CollectSharedData(sal_Int32
& nTableCount
, sal_Int32
& nShapesCount
, const sal_Int32 nCellCount
);
136 void CollectShapesAutoStyles(const sal_Int32 nTableCount
);
137 void WriteTablesView(const com::sun::star::uno::Any
& aTableView
);
138 void WriteView(const com::sun::star::uno::Any
& aView
);
139 virtual void _ExportFontDecls();
140 virtual void _ExportStyles( sal_Bool bUsed
);
141 virtual void _ExportAutoStyles();
142 virtual void _ExportMasterStyles();
143 virtual void SetBodyAttributes();
144 virtual void _ExportContent();
145 virtual void _ExportMeta();
147 void CollectInternalShape( ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> xShape
);
149 com::sun::star::table::CellRangeAddress
GetEndAddress(const com::sun::star::uno::Reference
<com::sun::star::sheet::XSpreadsheet
>& xTable
,
150 const sal_Int32 nTable
);
151 // ScMyEmptyDatabaseRangesContainer GetEmptyDatabaseRanges();
152 void GetAreaLinks( com::sun::star::uno::Reference
< com::sun::star::sheet::XSpreadsheetDocument
>& xSpreadDoc
, ScMyAreaLinksContainer
& rAreaLinks
);
153 void GetDetectiveOpList( ScMyDetectiveOpContainer
& rDetOp
);
154 void WriteSingleColumn(const sal_Int32 nRepeatColumns
, const sal_Int32 nStyleIndex
,
155 const sal_Int32 nIndex
, const sal_Bool bIsAutoStyle
, const sal_Bool bIsVisible
);
156 void WriteColumn(const sal_Int32 nColumn
, const sal_Int32 nRepeatColumns
,
157 const sal_Int32 nStyleIndex
, const sal_Bool bIsVisible
);
158 void OpenHeaderColumn();
159 void CloseHeaderColumn();
160 void ExportColumns(const sal_Int32 nTable
, const com::sun::star::table::CellRangeAddress
& aColumnHeaderRange
, const sal_Bool bHasColumnHeader
);
161 void ExportExternalRefCacheStyles();
162 void ExportFormatRanges(const sal_Int32 nStartCol
, const sal_Int32 nStartRow
,
163 const sal_Int32 nEndCol
, const sal_Int32 nEndRow
, const sal_Int32 nSheet
);
164 void WriteRowContent();
165 void WriteRowStartTag(sal_Int32 nRow
, const sal_Int32 nIndex
, const sal_Int8 nFlag
, const sal_Int32 nEmptyRows
);
166 void OpenHeaderRows();
167 void CloseHeaderRows();
168 void OpenNewRow(const sal_Int32 nIndex
, const sal_Int8 nFlag
, const sal_Int32 nStartRow
, const sal_Int32 nEmptyRows
);
169 void OpenAndCloseRow(const sal_Int32 nIndex
, const sal_Int8 nFlag
,
170 const sal_Int32 nStartRow
, const sal_Int32 nEmptyRows
);
171 void OpenRow(const sal_Int32 nTable
, const sal_Int32 nStartRow
, const sal_Int32 nRepeatRow
);
172 void CloseRow(const sal_Int32 nRow
);
173 void GetColumnRowHeader(sal_Bool
& bHasColumnHeader
, com::sun::star::table::CellRangeAddress
& aColumnHeaderRange
,
174 sal_Bool
& bHasRowHeader
, com::sun::star::table::CellRangeAddress
& aRowHeaderRange
,
175 rtl::OUString
& rPrintRanges
) const;
176 void FillFieldGroup(ScOutlineArray
* pFields
, ScMyOpenCloseColumnRowGroup
* pGroups
);
177 void FillColumnRowGroups();
179 //UNUSED2008-05 sal_Bool GetMerge (const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheet>& xTable,
180 //UNUSED2008-05 sal_Int32 nCol, sal_Int32 nRow,
181 //UNUSED2008-05 com::sun::star::table::CellRangeAddress& aCellAddress);
183 sal_Bool
GetMerged (const com::sun::star::table::CellRangeAddress
* pCellRange
,
184 const com::sun::star::uno::Reference
<com::sun::star::sheet::XSpreadsheet
>& xTable
);
186 sal_Bool
GetCellText (ScMyCell
& rMyCell
, const ScAddress
& aPos
) const;
188 void WriteCell (ScMyCell
& aCell
);
189 void WriteAreaLink(const ScMyCell
& rMyCell
);
190 void WriteAnnotation(ScMyCell
& rMyCell
);
191 void WriteDetective(const ScMyCell
& rMyCell
);
192 void ExportShape(const com::sun::star::uno::Reference
< com::sun::star::drawing::XShape
>& xShape
, com::sun::star::awt::Point
* pPoint
);
193 void WriteShapes(const ScMyCell
& rMyCell
);
194 void WriteTableShapes();
195 void SetRepeatAttribute (const sal_Int32 nEqualCellCount
);
197 sal_Bool
IsCellTypeEqual (const ScMyCell
& aCell1
, const ScMyCell
& aCell2
) const;
198 sal_Bool
IsEditCell(const com::sun::star::table::CellAddress
& aAddress
, ScMyCell
* pMyCell
= NULL
) const;
199 //UNUSED2008-05 sal_Bool IsEditCell(const com::sun::star::uno::Reference <com::sun::star::table::XCell>& xCell) const;
200 sal_Bool
IsEditCell(ScMyCell
& rCell
) const;
201 sal_Bool
IsMultiLineFormulaCell(ScMyCell
& rCell
) const;
202 //UNUSED2008-05 sal_Bool IsAnnotationEqual(const com::sun::star::uno::Reference<com::sun::star::table::XCell>& xCell1,
203 //UNUSED2008-05 const com::sun::star::uno::Reference<com::sun::star::table::XCell>& xCell2);
204 sal_Bool
IsCellEqual (ScMyCell
& aCell1
, ScMyCell
& aCell2
);
206 void WriteCalculationSettings(const com::sun::star::uno::Reference
<com::sun::star::sheet::XSpreadsheetDocument
>& xSpreadDoc
);
207 void WriteTableSource();
208 void WriteScenario(); // core implementation
209 void WriteTheLabelRanges(const com::sun::star::uno::Reference
< com::sun::star::sheet::XSpreadsheetDocument
>& xSpreadDoc
);
210 void WriteLabelRanges( const com::sun::star::uno::Reference
< com::sun::star::container::XIndexAccess
>& xRangesIAccess
, sal_Bool bColumn
);
211 void WriteNamedExpressions(const com::sun::star::uno::Reference
<com::sun::star::sheet::XSpreadsheetDocument
>& xSpreadDoc
);
212 void WriteExternalRefCaches();
213 void WriteConsolidation(); // core implementation
215 void CollectUserDefinedNamespaces(const SfxItemPool
* pPool
, sal_uInt16 nAttrib
);
217 void AddStyleFromCells(
218 const com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
>& xProperties
,
219 const com::sun::star::uno::Reference
< com::sun::star::sheet::XSpreadsheet
>& xTable
,
220 sal_Int32 nTable
, const rtl::OUString
* pOldName
);
221 void AddStyleFromColumn(
222 const com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
>& xColumnProperties
,
223 const rtl::OUString
* pOldName
, sal_Int32
& rIndex
, sal_Bool
& rIsVisible
);
224 void AddStyleFromRow(
225 const com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
>& xRowProperties
,
226 const rtl::OUString
* pOldName
, sal_Int32
& rIndex
);
228 void IncrementProgressBar(sal_Bool bEditCell
, sal_Int32 nInc
= 1);
230 void CopySourceStream( sal_Int32 nStartOffset
, sal_Int32 nEndOffset
, sal_Int32
& rNewStart
, sal_Int32
& rNewEnd
);
233 virtual SvXMLAutoStylePoolP
* CreateAutoStylePool();
234 virtual XMLPageExport
* CreatePageExport();
235 virtual XMLShapeExport
* CreateShapeExport();
236 virtual XMLFontAutoStylePool
* CreateFontAutoStylePool();
240 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory
,
241 const sal_uInt16 nExportFlag
);
243 virtual ~ScXMLExport();
245 static sal_Int16
GetFieldUnit();
246 inline ScDocument
* GetDocument() { return pDoc
; }
247 inline const ScDocument
* GetDocument() const { return pDoc
; }
248 //UNUSED2008-05 sal_Bool IsMatrix (const com::sun::star::uno::Reference <com::sun::star::table::XCellRange>& xCellRange,
249 //UNUSED2008-05 const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheet>& xTable,
250 //UNUSED2008-05 const sal_Int32 nCol, const sal_Int32 nRow,
251 //UNUSED2008-05 com::sun::star::table::CellRangeAddress& aCellAddress, sal_Bool& bIsFirst) const;
252 sal_Bool
IsMatrix (const ScAddress
& aCell
,
253 com::sun::star::table::CellRangeAddress
& aCellAddress
, sal_Bool
& bIsFirst
) const;
255 UniReference
< XMLPropertySetMapper
> GetCellStylesPropertySetMapper() { return xCellStylesPropertySetMapper
; }
256 UniReference
< XMLPropertySetMapper
> GetTableStylesPropertySetMapper() { return xTableStylesPropertySetMapper
; }
258 void SetSourceStream( const com::sun::star::uno::Reference
<com::sun::star::io::XInputStream
>& xNewStream
);
260 void GetChangeTrackViewSettings(com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& rProps
);
261 virtual void GetViewSettings(com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& rProps
);
262 virtual void GetConfigurationSettings(com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& rProps
);
264 virtual void exportAnnotationMeta( const com::sun::star::uno::Reference
< com::sun::star::drawing::XShape
>& xShape
);
266 void CreateSharedData(const sal_Int32 nTableCount
);
267 void SetSharedData(ScMySharedData
* pTemp
) { pSharedData
= pTemp
; }
268 ScMySharedData
* GetSharedData() { return pSharedData
; }
269 XMLNumberFormatAttributesExportHelper
* GetNumberFormatAttributesExportHelper();
271 // Export the document.
272 virtual sal_uInt32
exportDoc( enum ::xmloff::token::XMLTokenEnum eClass
= ::xmloff::token::XML_TOKEN_INVALID
);
275 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
);
278 virtual sal_Bool SAL_CALL
filter( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aDescriptor
) throw(::com::sun::star::uno::RuntimeException
);
279 virtual void SAL_CALL
cancel() throw(::com::sun::star::uno::RuntimeException
);
282 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
);
285 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
286 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
287 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
290 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
292 virtual void DisposingModel();