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