diff options
author | Daniel Rentz <dr@openoffice.org> | 2000-11-08 11:56:05 +0000 |
---|---|---|
committer | Daniel Rentz <dr@openoffice.org> | 2000-11-08 11:56:05 +0000 |
commit | c35144700a303c46050bdac92708b9f8320ad75d (patch) | |
tree | 3d662ba738141cf3666b8dd06bb1e7bee91b9bfd /sc/source/filter/xml/XMLExportIterator.hxx | |
parent | 620d508194d98be0daf57bfdbfe0f1624bbd0ca9 (diff) |
chg: improved export cell iterator
Diffstat (limited to 'sc/source/filter/xml/XMLExportIterator.hxx')
-rw-r--r-- | sc/source/filter/xml/XMLExportIterator.hxx | 367 |
1 files changed, 367 insertions, 0 deletions
diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx new file mode 100644 index 000000000000..793b8f369688 --- /dev/null +++ b/sc/source/filter/xml/XMLExportIterator.hxx @@ -0,0 +1,367 @@ +/************************************************************************* + * + * $RCSfile: XMLExportIterator.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dr $ $Date: 2000-11-08 12:56:05 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SC_XMLEXPORTITERATOR_HXX +#define _SC_XMLEXPORTITERATOR_HXX + +#ifndef __SGI_STL_VECTOR +#include <stl/vector> +#endif + +#ifndef _COM_SUN_STAR_UNO_ANY_H_ +#include <com/sun/star/uno/Any.h> +#endif +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + +#ifndef _COM_SUN_STAR_SHEET_CONDITIONOPERATOR_HPP_ +#include <com/sun/star/sheet/ConditionOperator.hpp> +#endif +#ifndef _COM_SUN_STAR_SHEET_VALIDATIONALERTSTYLE_HPP_ +#include <com/sun/star/sheet/ValidationAlertStyle.hpp> +#endif +#ifndef _COM_SUN_STAR_SHEET_VALIDATIONTYPE_HPP_ +#include <com/sun/star/sheet/ValidationType.hpp> +#endif +#ifndef _COM_SUN_STAR_SHEET_XSPREADSHEET_HPP_ +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#endif + +#ifndef _COM_SUN_STAR_TABLE_CELLADDRESS_HPP_ +#include <com/sun/star/table/CellAddress.hpp> +#endif +#ifndef _COM_SUN_STAR_TABLE_CELLRANGEADDRESS_HPP_ +#include <com/sun/star/table/CellRangeAddress.hpp> +#endif +#ifndef _COM_SUN_STAR_TABLE_XCELL_HPP_ +#include <com/sun/star/table/XCell.hpp> +#endif + +#ifndef SC_SCGLOB_HXX +#include "global.hxx" +#endif + +class ScHorizontalCellIterator; +struct ScMyCell; +class ScXMLExport; + +//============================================================================== + +class ScMyIteratorBase +{ +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) = 0; + +public: + ScMyIteratorBase(); + virtual ~ScMyIteratorBase(); + + virtual void SetCellData( ScMyCell& rMyCell ) = 0; + virtual void Sort() = 0; + + virtual void UpdateAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +}; + +//============================================================================== + +struct ScMyShape +{ + ScAddress aAddress; + sal_Int32 nIndex; +}; + +typedef std::vector<ScMyShape> ScMyShapeVec; + +class ScMyShapesContainer : ScMyIteratorBase +{ +private: + ScMyShapeVec aShapeVec; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyShapesContainer(); + virtual ~ScMyShapesContainer(); + + ScMyIteratorBase::UpdateAddress; + void AddNewShape(const ScMyShape& aShape); + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); +}; + +//============================================================================== + +struct ScMyMergedRange +{ + com::sun::star::table::CellRangeAddress aCellRange; + sal_Int32 nRows; + sal_Bool bIsFirst; +}; + +typedef std::vector<ScMyMergedRange> ScMyMergedRangeVec; + +class ScMyMergedRangesContainer : ScMyIteratorBase +{ +private: + ScMyMergedRangeVec aRangeVec; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyMergedRangesContainer(); + virtual ~ScMyMergedRangesContainer(); + void AddRange(const com::sun::star::table::CellRangeAddress aMergedRange); + + ScMyIteratorBase::UpdateAddress; + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); // + remove doublets +}; + +//============================================================================== + +struct ScMyAreaLink +{ + ::rtl::OUString sFilter; + ::rtl::OUString sFilterOptions; + ::rtl::OUString sURL; + ::rtl::OUString sSourceStr; + ::com::sun::star::table::CellRangeAddress aDestRange; + + inline sal_Int32 GetColCount() const { return aDestRange.EndColumn - aDestRange.StartColumn + 1; } + inline sal_Int32 GetRowCount() const { return aDestRange.EndRow - aDestRange.StartRow + 1; } + + sal_Bool Compare( const ScMyAreaLink& rAreaLink ) const; + + static sal_Bool operator<( const ScMyAreaLink& rAreaLink1, const ScMyAreaLink& rAreaLink2 ); +}; + +typedef ::std::vector< ScMyAreaLink > ScMyAreaLinkVec; + +class ScMyAreaLinksContainer : ScMyIteratorBase +{ +private: + ScMyAreaLinkVec aAreaLinkVec; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyAreaLinksContainer(); + virtual ~ScMyAreaLinksContainer(); + + inline void AddNewAreaLink( const ScMyAreaLink& rAreaLink ) + { aAreaLinkVec.push_back( rAreaLink ); } + + ScMyIteratorBase::UpdateAddress; + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); +}; + +//============================================================================== + +typedef std::vector<com::sun::star::table::CellRangeAddress> ScMyEmptyDatabaseRangeVec; + +class ScMyEmptyDatabaseRangesContainer : ScMyIteratorBase +{ +private: + ScMyEmptyDatabaseRangeVec aDatabaseVec; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyEmptyDatabaseRangesContainer(); + virtual ~ScMyEmptyDatabaseRangesContainer(); + void AddNewEmptyDatabaseRange(const com::sun::star::table::CellRangeAddress& aCellRangeAddress); + + ScMyIteratorBase::UpdateAddress; + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); +}; + +//============================================================================== + +struct ScMyValidationRange +{ + com::sun::star::table::CellRangeAddress aRange; + sal_Int32 nIndex; + sal_Bool bUsed; + + ScMyValidationRange(); + ~ScMyValidationRange(); +}; + +struct ScMyValidation +{ + rtl::OUString sName; + rtl::OUString sErrorMessage; + rtl::OUString sErrorTitle; + rtl::OUString sImputMessage; + rtl::OUString sImputTitle; + rtl::OUString sFormula1; + rtl::OUString sFormula2; + com::sun::star::table::CellAddress aBaseCell; + com::sun::star::sheet::ValidationAlertStyle aAlertStyle; + com::sun::star::sheet::ValidationType aValidationType; + com::sun::star::sheet::ConditionOperator aOperator; + sal_Bool bShowErrorMessage; + sal_Bool bShowImputMessage; + sal_Bool bIgnoreBlanks; + + ScMyValidation(); + ~ScMyValidation(); + + sal_Bool IsEqual(const ScMyValidation& aVal) const; +}; + +typedef std::vector<ScMyValidation> ScMyValidationVec; +typedef std::vector<ScMyValidationRange> ScMyValidationRangeVec; + +class ScMyValidationsContainer : ScMyIteratorBase +{ +private: + ScMyValidationVec aValidationVec; + ScMyValidationRangeVec aValidationRangeVec; + rtl::OUString sEmptyString; +protected: + virtual sal_Bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ); +public: + ScMyValidationsContainer(); + virtual ~ScMyValidationsContainer(); + sal_Bool AddValidation(const com::sun::star::uno::Any& aAny, + const com::sun::star::table::CellRangeAddress& aCellRange); + rtl::OUString GetCondition(const ScMyValidation& aValidation); + rtl::OUString GetBaseCellAddress(ScDocument* pDoc, const com::sun::star::table::CellAddress& aCell); + void WriteMessage(ScXMLExport& rExport, + const rtl::OUString& sTitle, const rtl::OUString& sMessage, + const sal_Bool bShowMessage, const sal_Bool bIsHelpMessage); + void WriteValidations(ScXMLExport& rExport); + const rtl::OUString& GetValidationName(const sal_Int32 nIndex); + const sal_Int32 GetValidationIndex(const com::sun::star::table::CellAddress& aCell); + + ScMyIteratorBase::UpdateAddress; + virtual void SetCellData( ScMyCell& rMyCell ); + virtual void Sort(); +}; + +//============================================================================== + +// contains data to export for the current cell position +struct ScMyCell +{ + com::sun::star::uno::Reference<com::sun::star::table::XCell> xCell; + com::sun::star::table::CellAddress aCellAddress; + com::sun::star::table::CellRangeAddress aMergeRange; + com::sun::star::table::CellRangeAddress aMatrixRange; + + ScMyAreaLink aAreaLink; + std::vector<ScMyShape> aShapes; + sal_Int32 nValidationIndex; + + sal_Bool bHasShape; + sal_Bool bIsMergedBase; + sal_Bool bIsCovered; + sal_Bool bHasAreaLink; + sal_Bool bHasEmptyDatabase; + + sal_Bool bIsMatrixBase; + sal_Bool bIsMatrixCovered; + sal_Bool bHasAnnotation; + + ScMyCell(); + ~ScMyCell(); +}; + +//============================================================================== + +class ScMyNotEmptyCellsIterator +{ + com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet> xTable; + + ScMyShapesContainer* pShapes; + ScMyEmptyDatabaseRangesContainer* pEmptyDatabaseRanges; + ScMyMergedRangesContainer* pMergedRanges; + ScMyAreaLinksContainer* pAreaLinks; + ScMyValidationsContainer* pValidations; + + ScXMLExport& rExport; + ScHorizontalCellIterator* pCellItr; + + sal_uInt16 nCellCol; + sal_uInt16 nCellRow; + sal_Int16 nCurrentTable; + + void UpdateAddress( ::com::sun::star::table::CellAddress& rAddress ); + void SetCellData( ScMyCell& rMyCell, ::com::sun::star::table::CellAddress& rAddress ); + + void SetMatrixCellData( ScMyCell& rMyCell ); + void HasAnnotation( ScMyCell& aCell ); +public: + ScMyNotEmptyCellsIterator(ScXMLExport& rExport); + ~ScMyNotEmptyCellsIterator(); + + void SetShapes(ScMyShapesContainer* pShapes); + void SetEmptyDatabaseRanges(ScMyEmptyDatabaseRangesContainer* pEmptyDatabaseRanges); + void SetMergedRanges(ScMyMergedRangesContainer* pMergedRanges); + void SetAreaLinks(ScMyAreaLinksContainer* pAreaLinks); + void SetValidations(ScMyValidationsContainer* pValidations); + void SetCurrentTable(const sal_Int32 nTable); + + sal_Bool GetNext(ScMyCell& aCell); +}; + +#endif + |