LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/xml - XMLExportIterator.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 38 44.7 %
Date: 2012-12-27 Functions: 11 32 34.4 %
Legend: Lines: hit not hit

          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             : 
      20             : #ifndef SC_XMLEXPORTITERATOR_HXX
      21             : #define SC_XMLEXPORTITERATOR_HXX
      22             : 
      23             : #include <vector>
      24             : #include <list>
      25             : #include <set>
      26             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      27             : #include <com/sun/star/table/CellAddress.hpp>
      28             : #include <com/sun/star/table/CellRangeAddress.hpp>
      29             : #include <com/sun/star/table/XCell.hpp>
      30             : #include <com/sun/star/text/XText.hpp>
      31             : #include <com/sun/star/sheet/XSheetAnnotation.hpp>
      32             : #include <com/sun/star/drawing/XShape.hpp>
      33             : #include "global.hxx"
      34             : #include "detfunc.hxx"
      35             : #include "detdata.hxx"
      36             : #include "postit.hxx"
      37             : 
      38             : class   ScHorizontalCellIterator;
      39             : struct  ScMyCell;
      40             : class   ScXMLExport;
      41             : class   ScFormatRangeStyles;
      42             : class   ScBaseCell;
      43             : 
      44             : //==============================================================================
      45             : 
      46             : class ScMyIteratorBase
      47             : {
      48             : protected:
      49             :     virtual bool                GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) = 0;
      50             : 
      51             : public:
      52             :                                 ScMyIteratorBase();
      53             :     virtual                     ~ScMyIteratorBase();
      54             : 
      55             :     virtual void                SetCellData( ScMyCell& rMyCell ) = 0;
      56             :     virtual void                Sort() = 0;
      57             : 
      58             :     virtual void                UpdateAddress( ::com::sun::star::table::CellAddress& rCellAddress );
      59             : };
      60             : 
      61             : //==============================================================================
      62             : 
      63           0 : struct ScMyShape
      64             : {
      65             :     ScAddress   aAddress;
      66             :     ScAddress   aEndAddress;
      67             :     sal_Int32       nEndX;
      68             :     sal_Int32       nEndY;
      69             :     com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
      70             : 
      71             :     bool operator<(const ScMyShape& aShape) const;
      72             : };
      73             : 
      74             : typedef std::list<ScMyShape>    ScMyShapeList;
      75             : 
      76             : class ScMyShapesContainer : ScMyIteratorBase
      77             : {
      78             : private:
      79             :     ScMyShapeList               aShapeList;
      80             : protected:
      81             :     virtual bool                GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
      82             : public:
      83             :                                 ScMyShapesContainer();
      84             :     virtual                     ~ScMyShapesContainer();
      85             : 
      86             :                                 using ScMyIteratorBase::UpdateAddress;
      87             :     void                        AddNewShape(const ScMyShape& aShape);
      88           0 :     bool                        HasShapes() { return !aShapeList.empty(); }
      89           0 :     const ScMyShapeList*        GetShapes() const { return &aShapeList; }
      90             :     virtual void                SetCellData( ScMyCell& rMyCell );
      91             :     virtual void                Sort();
      92             :     void                        SkipTable(SCTAB nSkip);
      93             : };
      94             : 
      95           0 : struct ScMyNoteShape
      96             : {
      97             :     com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
      98             :     ScAddress aPos;
      99             : 
     100             :     bool operator<(const ScMyNoteShape& aNote) const;
     101             : };
     102             : 
     103             : typedef std::list<ScMyNoteShape>    ScMyNoteShapeList;
     104             : 
     105             : class ScMyNoteShapesContainer : ScMyIteratorBase
     106             : {
     107             : private:
     108             :     ScMyNoteShapeList           aNoteShapeList;
     109             : protected:
     110             :     virtual bool                GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
     111             : public:
     112             :                                 ScMyNoteShapesContainer();
     113             :     virtual                     ~ScMyNoteShapesContainer();
     114             : 
     115             :                                 using ScMyIteratorBase::UpdateAddress;
     116             :     void                        AddNewNote(const ScMyNoteShape& aNote);
     117             :     bool                        HasNotes() { return !aNoteShapeList.empty(); }
     118           0 :     const ScMyNoteShapeList*    GetNotes() const { return &aNoteShapeList; }
     119             :     virtual void                SetCellData( ScMyCell& rMyCell );
     120             :     virtual void                Sort();
     121             :     void                        SkipTable(SCTAB nSkip);
     122             : };
     123             : 
     124             : //==============================================================================
     125             : 
     126           0 : struct ScMyMergedRange
     127             : {
     128             :     com::sun::star::table::CellRangeAddress aCellRange;
     129             :     sal_Int32                   nRows;
     130             :     bool                        bIsFirst;
     131             :     bool                        operator<(const ScMyMergedRange& aRange) const;
     132             : };
     133             : 
     134             : typedef std::list<ScMyMergedRange>  ScMyMergedRangeList;
     135             : 
     136             : class ScMyMergedRangesContainer : ScMyIteratorBase
     137             : {
     138             : private:
     139             :     ScMyMergedRangeList         aRangeList;
     140             : protected:
     141             :     virtual bool                GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
     142             : public:
     143             :                                 ScMyMergedRangesContainer();
     144             :     virtual                     ~ScMyMergedRangesContainer();
     145             :     void                        AddRange(const com::sun::star::table::CellRangeAddress aMergedRange);
     146             : 
     147             :                                 using ScMyIteratorBase::UpdateAddress;
     148             :     virtual void                SetCellData( ScMyCell& rMyCell );
     149             :     virtual void                Sort(); // + remove doublets
     150             :     void                        SkipTable(SCTAB nSkip);
     151             : };
     152             : 
     153             : //==============================================================================
     154             : 
     155           6 : struct ScMyAreaLink
     156             : {
     157             :     ::rtl::OUString             sFilter;
     158             :     ::rtl::OUString             sFilterOptions;
     159             :     ::rtl::OUString             sURL;
     160             :     ::rtl::OUString             sSourceStr;
     161             :     ::com::sun::star::table::CellRangeAddress aDestRange;
     162             :     sal_Int32                   nRefresh;
     163             : 
     164           4 :     inline                      ScMyAreaLink() : nRefresh( 0 ) {}
     165             : 
     166           0 :     inline sal_Int32            GetColCount() const { return aDestRange.EndColumn - aDestRange.StartColumn + 1; }
     167           0 :     inline sal_Int32            GetRowCount() const { return aDestRange.EndRow - aDestRange.StartRow + 1; }
     168             : 
     169             :     bool                        Compare( const ScMyAreaLink& rAreaLink ) const;
     170             :     bool                        operator<(const ScMyAreaLink& rAreaLink ) const;
     171             : };
     172             : 
     173             : typedef ::std::list< ScMyAreaLink > ScMyAreaLinkList;
     174             : 
     175             : class ScMyAreaLinksContainer : ScMyIteratorBase
     176             : {
     177             : private:
     178             :     ScMyAreaLinkList            aAreaLinkList;
     179             : protected:
     180             :     virtual bool                GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
     181             : public:
     182             :                                 ScMyAreaLinksContainer();
     183             :     virtual                     ~ScMyAreaLinksContainer();
     184             : 
     185           0 :     inline void                 AddNewAreaLink( const ScMyAreaLink& rAreaLink )
     186           0 :                                     { aAreaLinkList.push_back( rAreaLink ); }
     187             : 
     188             :                                 using ScMyIteratorBase::UpdateAddress;
     189             :     virtual void                SetCellData( ScMyCell& rMyCell );
     190             :     virtual void                Sort();
     191             :     void                        SkipTable(SCTAB nSkip);
     192             : };
     193             : 
     194             : //==============================================================================
     195             : 
     196             : struct ScMyCellRangeAddress : com::sun::star::table::CellRangeAddress
     197             : {
     198             :     ScMyCellRangeAddress(const com::sun::star::table::CellRangeAddress& rRange);
     199             :     bool                        operator<(const ScMyCellRangeAddress& rCellRangeAddress ) const;
     200             : };
     201             : 
     202             : typedef std::list<ScMyCellRangeAddress> ScMyEmptyDatabaseRangeList;
     203             : 
     204             : class ScMyEmptyDatabaseRangesContainer : ScMyIteratorBase
     205             : {
     206             : private:
     207             :     ScMyEmptyDatabaseRangeList  aDatabaseList;
     208             : protected:
     209             :     virtual bool                GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
     210             : public:
     211             :                                 ScMyEmptyDatabaseRangesContainer();
     212             :     virtual                     ~ScMyEmptyDatabaseRangesContainer();
     213             :     void                        AddNewEmptyDatabaseRange(const com::sun::star::table::CellRangeAddress& aCellRangeAddress);
     214             : 
     215             :                                 using ScMyIteratorBase::UpdateAddress;
     216             :     virtual void                SetCellData( ScMyCell& rMyCell );
     217             :     virtual void                Sort();
     218             :     void                        SkipTable(SCTAB nSkip);
     219             : };
     220             : 
     221             : //==============================================================================
     222             : 
     223           0 : struct ScMyDetectiveObj
     224             : {
     225             :     ::com::sun::star::table::CellAddress        aPosition;
     226             :     ::com::sun::star::table::CellRangeAddress   aSourceRange;
     227             :     ScDetectiveObjType                          eObjType;
     228             :     bool                                        bHasError;
     229             :     bool operator<(const ScMyDetectiveObj& rDetObj) const;
     230             : };
     231             : 
     232             : typedef ::std::list< ScMyDetectiveObj > ScMyDetectiveObjList;
     233             : typedef ::std::vector< ScMyDetectiveObj > ScMyDetectiveObjVec;
     234             : 
     235             : class ScMyDetectiveObjContainer : ScMyIteratorBase
     236             : {
     237             : private:
     238             :     ScMyDetectiveObjList        aDetectiveObjList;
     239             : protected:
     240             :     virtual bool                GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
     241             : public:
     242             :                                 ScMyDetectiveObjContainer();
     243             :     virtual                     ~ScMyDetectiveObjContainer();
     244             : 
     245             :     void                        AddObject(
     246             :                                     ScDetectiveObjType eObjType,
     247             :                                     const SCTAB nSheet,
     248             :                                     const ScAddress& rPosition,
     249             :                                     const ScRange& rSourceRange,
     250             :                                     bool bHasError );
     251             : 
     252             :                                 using ScMyIteratorBase::UpdateAddress;
     253             :     virtual void                SetCellData( ScMyCell& rMyCell );
     254             :     virtual void                Sort();
     255             :     void                        SkipTable(SCTAB nSkip);
     256             : };
     257             : 
     258             : //==============================================================================
     259             : 
     260           0 : struct ScMyDetectiveOp
     261             : {
     262             :     ::com::sun::star::table::CellAddress    aPosition;
     263             :     ScDetOpType                             eOpType;
     264             :     sal_Int32                               nIndex;
     265             :     bool operator<(const ScMyDetectiveOp& rDetOp) const;
     266             : };
     267             : 
     268             : typedef ::std::list< ScMyDetectiveOp > ScMyDetectiveOpList;
     269             : typedef ::std::vector< ScMyDetectiveOp > ScMyDetectiveOpVec;
     270             : 
     271             : class ScMyDetectiveOpContainer : ScMyIteratorBase
     272             : {
     273             : private:
     274             :     ScMyDetectiveOpList         aDetectiveOpList;
     275             : protected:
     276             :     virtual bool                GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
     277             : public:
     278             :                                 ScMyDetectiveOpContainer();
     279             :     virtual                     ~ScMyDetectiveOpContainer();
     280             : 
     281             :     void                        AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex );
     282             : 
     283             :                                 using ScMyIteratorBase::UpdateAddress;
     284             :     virtual void                SetCellData( ScMyCell& rMyCell );
     285             :     virtual void                Sort();
     286             :     void                        SkipTable(SCTAB nSkip);
     287             : };
     288             : 
     289             : //==============================================================================
     290             : 
     291             : // contains data to export for the current cell position
     292           2 : struct ScMyCell
     293             : {
     294             : //  com::sun::star::uno::Reference<com::sun::star::table::XCell> xCell;
     295             : //  com::sun::star::uno::Reference<com::sun::star::text::XText> xText;
     296             :     com::sun::star::uno::Reference<com::sun::star::sheet::XSheetAnnotation> xAnnotation;
     297             :     com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xNoteShape;
     298             :     com::sun::star::table::CellAddress      aCellAddress;
     299             :     com::sun::star::table::CellRangeAddress aMergeRange;
     300             :     com::sun::star::table::CellRangeAddress aMatrixRange;
     301             : 
     302             :     rtl::OUString               sStringValue;
     303             :     rtl::OUString               sAnnotationText;
     304             : 
     305             :     ScMyAreaLink                aAreaLink;
     306             :     ScMyShapeList               aShapeList;
     307             :     ScMyDetectiveObjVec         aDetectiveObjVec;
     308             :     ScMyDetectiveOpVec          aDetectiveOpVec;
     309             : 
     310             :     double                      fValue;
     311             :     sal_Int32                   nValidationIndex;
     312             :     sal_Int32                   nStyleIndex;
     313             :     sal_Int32                   nNumberFormat;
     314             :     com::sun::star::table::CellContentType  nType;
     315             : 
     316             :     ScBaseCell*                 pBaseCell;
     317             : 
     318             :     bool                        bIsAutoStyle;
     319             : 
     320             :     bool                        bHasShape;
     321             :     bool                        bIsMergedBase;
     322             :     bool                        bIsCovered;
     323             :     bool                        bHasAreaLink;
     324             :     bool                        bHasEmptyDatabase;
     325             :     bool                        bHasDetectiveObj;
     326             :     bool                        bHasDetectiveOp;
     327             : 
     328             :     bool                        bIsEditCell;
     329             :     bool                        bKnowWhetherIsEditCell;
     330             :     bool                        bHasStringValue;
     331             :     bool                        bHasDoubleValue;
     332             :     bool                        bHasXText;
     333             : 
     334             :     bool                        bIsMatrixBase;
     335             :     bool                        bIsMatrixCovered;
     336             :     bool                        bHasAnnotation;
     337             : 
     338             :                                 ScMyCell();
     339             :                                 ~ScMyCell();
     340             : };
     341             : 
     342             : //==============================================================================
     343             : 
     344           0 : struct ScMyExportAnnotation
     345             : {
     346             :     com::sun::star::uno::Reference<com::sun::star::sheet::XSheetAnnotation> xAnnotation;
     347             :     com::sun::star::table::CellAddress      aCellAddress;
     348             :     bool operator<(const ScMyExportAnnotation& rAnno) const;
     349             : };
     350             : 
     351             : struct ScNoteExportData
     352             : {
     353             :     SCROW nRow;
     354             :     SCCOL nCol;
     355             :     ScPostIt* pNote;
     356             : 
     357           0 :     bool operator<(const ScNoteExportData& r) const
     358             :     {
     359           0 :         if(nRow < r.nRow)
     360           0 :             return true;
     361           0 :         else if(nRow > r.nRow)
     362           0 :             return false;
     363             :         else
     364             :         {
     365           0 :             if(nCol < r.nCol)
     366           0 :                 return true;
     367             :             else
     368           0 :                 return false;
     369             :         }
     370             :     }
     371             : };
     372             : 
     373             : typedef ::std::list< ScMyExportAnnotation > ScMyExportAnnotationList;
     374             : typedef ::std::set< ScNoteExportData > ScMyNoteExportDataList;
     375             : 
     376             : class ScMyNotEmptyCellsIterator
     377             : {
     378             :     com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet> xTable;
     379             :     com::sun::star::uno::Reference<com::sun::star::table::XCellRange> xCellRange;
     380             :     com::sun::star::table::CellAddress  aLastAddress;
     381             :     ScMyExportAnnotationList            aAnnotations;
     382             : 
     383             :     ScMyShapesContainer*                pShapes;
     384             :     ScMyNoteShapesContainer*            pNoteShapes;
     385             :     ScMyEmptyDatabaseRangesContainer*   pEmptyDatabaseRanges;
     386             :     ScMyMergedRangesContainer*          pMergedRanges;
     387             :     ScMyAreaLinksContainer*             pAreaLinks;
     388             :     ScMyDetectiveObjContainer*          pDetectiveObj;
     389             :     ScMyDetectiveOpContainer*           pDetectiveOp;
     390             :     ScMyNoteExportDataList              maNoteExportList;
     391             :     ScMyNoteExportDataList::iterator  maNoteExportListItr;
     392             : 
     393             :     ScXMLExport&                rExport;
     394             :     ScHorizontalCellIterator*   pCellItr;
     395             : 
     396             :     SCCOL                       nCellCol;
     397             :     SCROW                       nCellRow;
     398             :     SCTAB                       nCurrentTable;
     399             : 
     400             :     void                        UpdateAddress( ::com::sun::star::table::CellAddress& rAddress );
     401             :     void                        SetCellData( ScMyCell& rMyCell, ::com::sun::star::table::CellAddress& rAddress );
     402             : 
     403             :     void                        SetMatrixCellData( ScMyCell& rMyCell );
     404             :     void                        HasAnnotation( ScMyCell& aCell );
     405             : public:
     406             :                                 ScMyNotEmptyCellsIterator(ScXMLExport& rExport);
     407             :                                 ~ScMyNotEmptyCellsIterator();
     408             : 
     409             :     void                        Clear();
     410             : 
     411           2 :     inline void                 SetShapes(ScMyShapesContainer* pNewShapes)
     412           2 :                                     { pShapes = pNewShapes; }
     413           2 :     inline void                 SetNoteShapes(ScMyNoteShapesContainer* pNewNoteShapes)
     414           2 :                                     { pNoteShapes = pNewNoteShapes; }
     415           2 :     inline void                 SetEmptyDatabaseRanges(ScMyEmptyDatabaseRangesContainer* pNewEmptyDatabaseRanges)
     416           2 :                                     { pEmptyDatabaseRanges = pNewEmptyDatabaseRanges; }
     417           2 :     inline void                 SetMergedRanges(ScMyMergedRangesContainer* pNewMergedRanges)
     418           2 :                                     { pMergedRanges = pNewMergedRanges; }
     419           2 :     inline void                 SetAreaLinks(ScMyAreaLinksContainer* pNewAreaLinks)
     420           2 :                                     { pAreaLinks = pNewAreaLinks; }
     421           2 :     inline void                 SetDetectiveObj(ScMyDetectiveObjContainer* pNewDetectiveObj)
     422           2 :                                     { pDetectiveObj = pNewDetectiveObj; }
     423           2 :     inline void                 SetDetectiveOp(ScMyDetectiveOpContainer* pNewDetectiveOp)
     424           2 :                                     { pDetectiveOp = pNewDetectiveOp; }
     425             : 
     426             :     void                        SetCurrentTable(const SCTAB nTable,
     427             :                                     com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet>& rxTable);
     428             :     void                        SkipTable(SCTAB nSkip);
     429             : 
     430             :     bool                        GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
     431             : };
     432             : 
     433             : #endif
     434             : 
     435             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10