LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/xml - XMLExportIterator.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 252 512 49.2 %
Date: 2013-07-09 Functions: 48 83 57.8 %
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             : #include "XMLExportIterator.hxx"
      21             : #include <com/sun/star/text/XSimpleText.hpp>
      22             : #include <com/sun/star/sheet/XCellAddressable.hpp>
      23             : #include <com/sun/star/sheet/CellFlags.hpp>
      24             : #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
      25             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      26             : #include <xmloff/xmlnmspe.hxx>
      27             : #include "dociter.hxx"
      28             : #include "convuno.hxx"
      29             : #include "xmlexprt.hxx"
      30             : #include "XMLExportSharedData.hxx"
      31             : #include "XMLStylesExportHelper.hxx"
      32             : #include "document.hxx"
      33             : 
      34             : #include <algorithm>
      35             : 
      36             : using namespace ::com::sun::star;
      37             : 
      38             : //==============================================================================
      39             : 
      40          44 : ScMyIteratorBase::ScMyIteratorBase()
      41             : {
      42          44 : }
      43             : 
      44          44 : ScMyIteratorBase::~ScMyIteratorBase()
      45             : {
      46          44 : }
      47             : 
      48        1109 : void ScMyIteratorBase::UpdateAddress( table::CellAddress& rCellAddress )
      49             : {
      50        1109 :     table::CellAddress aNewAddr( rCellAddress );
      51        1109 :     if( GetFirstAddress( aNewAddr ) )
      52             :     {
      53           4 :         if( (aNewAddr.Sheet == rCellAddress.Sheet) &&
      54           2 :             ((aNewAddr.Row < rCellAddress.Row) ||
      55           0 :             ((aNewAddr.Row == rCellAddress.Row) && (aNewAddr.Column < rCellAddress.Column))) )
      56           2 :             rCellAddress = aNewAddr;
      57             :     }
      58        1109 : }
      59             : 
      60             : 
      61             : //==============================================================================
      62             : 
      63           0 : bool ScMyShape::operator<(const ScMyShape& aShape) const
      64             : {
      65           0 :     if( aAddress.Tab() != aShape.aAddress.Tab() )
      66           0 :         return (aAddress.Tab() < aShape.aAddress.Tab());
      67           0 :     else if( aAddress.Row() != aShape.aAddress.Row() )
      68           0 :         return (aAddress.Row() < aShape.aAddress.Row());
      69             :     else
      70           0 :         return (aAddress.Col() < aShape.aAddress.Col());
      71             : }
      72             : 
      73           2 : ScMyShapesContainer::ScMyShapesContainer()
      74           2 :     : aShapeList()
      75             : {
      76           2 : }
      77             : 
      78           4 : ScMyShapesContainer::~ScMyShapesContainer()
      79             : {
      80           4 : }
      81             : 
      82           2 : void ScMyShapesContainer::AddNewShape( const ScMyShape& aShape )
      83             : {
      84           2 :     aShapeList.push_back(aShape);
      85           2 : }
      86             : 
      87           4 : bool ScMyShapesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
      88             : {
      89           4 :     sal_Int32 nTable(rCellAddress.Sheet);
      90           4 :     if( !aShapeList.empty() )
      91             :     {
      92           2 :         ScUnoConversion::FillApiAddress( rCellAddress, aShapeList.begin()->aAddress );
      93           2 :         return (nTable == rCellAddress.Sheet);
      94             :     }
      95           2 :     return false;
      96             : }
      97             : 
      98           2 : void ScMyShapesContainer::SetCellData( ScMyCell& rMyCell )
      99             : {
     100           2 :     rMyCell.aShapeList.clear();
     101           2 :     ScAddress aAddress;
     102           2 :     ScUnoConversion::FillScAddress( aAddress, rMyCell.aCellAddress );
     103             : 
     104           2 :     ScMyShapeList::iterator aItr(aShapeList.begin());
     105           2 :     ScMyShapeList::iterator aEndItr(aShapeList.end());
     106           6 :     while( (aItr != aEndItr) && (aItr->aAddress == aAddress) )
     107             :     {
     108           2 :         rMyCell.aShapeList.push_back(*aItr);
     109           2 :         aItr = aShapeList.erase(aItr);
     110             :     }
     111           2 :     rMyCell.bHasShape = !rMyCell.aShapeList.empty();
     112           2 : }
     113             : 
     114           0 : void ScMyShapesContainer::SkipTable(SCTAB nSkip)
     115             : {
     116           0 :     ScMyShapeList::iterator aItr = aShapeList.begin();
     117           0 :     while( (aItr != aShapeList.end()) && (aItr->aAddress.Tab() == nSkip) )
     118           0 :         aItr = aShapeList.erase(aItr);
     119           0 : }
     120             : 
     121           2 : void ScMyShapesContainer::Sort()
     122             : {
     123           2 :     aShapeList.sort();
     124           2 : }
     125             : 
     126           0 : bool ScMyNoteShape::operator<(const ScMyNoteShape& aNote) const
     127             : {
     128           0 :     if( aPos.Tab() != aNote.aPos.Tab() )
     129           0 :         return (aPos.Tab() < aNote.aPos.Tab());
     130           0 :     else if( aPos.Row() != aNote.aPos.Row() )
     131           0 :         return (aPos.Row() < aNote.aPos.Row());
     132             :     else
     133           0 :         return (aPos.Col() < aNote.aPos.Col());
     134             : }
     135             : 
     136           0 : ScMyNoteShapesContainer::ScMyNoteShapesContainer()
     137           0 :     : aNoteShapeList()
     138             : {
     139           0 : }
     140             : 
     141           0 : ScMyNoteShapesContainer::~ScMyNoteShapesContainer()
     142             : {
     143           0 : }
     144             : 
     145           0 : void ScMyNoteShapesContainer::AddNewNote( const ScMyNoteShape& aNote )
     146             : {
     147           0 :     aNoteShapeList.push_back(aNote);
     148           0 : }
     149             : 
     150           0 : bool ScMyNoteShapesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
     151             : {
     152           0 :     sal_Int16 nTable = rCellAddress.Sheet;
     153           0 :     if( !aNoteShapeList.empty() )
     154             :     {
     155           0 :         ScUnoConversion::FillApiAddress( rCellAddress, aNoteShapeList.begin()->aPos );
     156           0 :         return (nTable == rCellAddress.Sheet);
     157             :     }
     158           0 :     return false;
     159             : }
     160             : 
     161           0 : void ScMyNoteShapesContainer::SetCellData( ScMyCell& rMyCell )
     162             : {
     163           0 :     rMyCell.xNoteShape.clear();
     164           0 :     ScAddress aAddress;
     165           0 :     ScUnoConversion::FillScAddress( aAddress, rMyCell.aCellAddress );
     166             : 
     167           0 :     ScMyNoteShapeList::iterator aItr = aNoteShapeList.begin();
     168           0 :     while( (aItr != aNoteShapeList.end()) && (aItr->aPos == aAddress) )
     169             :     {
     170           0 :         rMyCell.xNoteShape = aItr->xShape;
     171           0 :         aItr = aNoteShapeList.erase(aItr);
     172             :     }
     173           0 : }
     174             : 
     175           0 : void ScMyNoteShapesContainer::SkipTable(SCTAB nSkip)
     176             : {
     177           0 :     ScMyNoteShapeList::iterator aItr = aNoteShapeList.begin();
     178           0 :     while( (aItr != aNoteShapeList.end()) && (aItr->aPos.Tab() == nSkip) )
     179           0 :         aItr = aNoteShapeList.erase(aItr);
     180           0 : }
     181             : 
     182           0 : void ScMyNoteShapesContainer::Sort()
     183             : {
     184           0 :     aNoteShapeList.sort();
     185           0 : }
     186             : 
     187             : //==============================================================================
     188             : 
     189           0 : bool ScMyMergedRange::operator<(const ScMyMergedRange& aRange) const
     190             : {
     191           0 :     if( aCellRange.Sheet != aRange.aCellRange.Sheet )
     192           0 :         return (aCellRange.Sheet < aRange.aCellRange.Sheet);
     193           0 :     else if( aCellRange.StartRow != aRange.aCellRange.StartRow )
     194           0 :         return (aCellRange.StartRow < aRange.aCellRange.StartRow);
     195             :     else
     196           0 :         return (aCellRange.StartColumn < aRange.aCellRange.StartColumn);
     197             : }
     198             : 
     199             : 
     200          10 : ScMyMergedRangesContainer::ScMyMergedRangesContainer()
     201          10 :     : aRangeList()
     202             : {
     203          10 : }
     204             : 
     205          20 : ScMyMergedRangesContainer::~ScMyMergedRangesContainer()
     206             : {
     207          20 : }
     208             : 
     209           0 : void ScMyMergedRangesContainer::AddRange(const table::CellRangeAddress aMergedRange)
     210             : {
     211           0 :     sal_Int32 nStartRow(aMergedRange.StartRow);
     212           0 :     sal_Int32 nEndRow(aMergedRange.EndRow);
     213             : 
     214           0 :     ScMyMergedRange aRange;
     215           0 :     aRange.bIsFirst = true;
     216           0 :     aRange.aCellRange = aMergedRange;
     217           0 :     aRange.aCellRange.EndRow = nStartRow;
     218           0 :     aRange.nRows = nEndRow - nStartRow + 1;
     219           0 :     aRangeList.push_back( aRange );
     220             : 
     221           0 :     aRange.bIsFirst = false;
     222           0 :     aRange.nRows = 0;
     223           0 :     for( sal_Int32 nRow = nStartRow + 1; nRow <= nEndRow; ++nRow )
     224             :     {
     225           0 :         aRange.aCellRange.StartRow = aRange.aCellRange.EndRow = nRow;
     226           0 :         aRangeList.push_back(aRange);
     227             :     }
     228           0 : }
     229             : 
     230         221 : bool ScMyMergedRangesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
     231             : {
     232         221 :     sal_Int32 nTable(rCellAddress.Sheet);
     233         221 :     if( !aRangeList.empty() )
     234             :     {
     235           0 :         ScUnoConversion::FillApiStartAddress( rCellAddress, aRangeList.begin()->aCellRange );
     236           0 :         return (nTable == rCellAddress.Sheet);
     237             :     }
     238         221 :     return false;
     239             : }
     240             : 
     241         212 : void ScMyMergedRangesContainer::SetCellData( ScMyCell& rMyCell )
     242             : {
     243         212 :     rMyCell.bIsMergedBase = rMyCell.bIsCovered = false;
     244         212 :     ScMyMergedRangeList::iterator aItr(aRangeList.begin());
     245         212 :     if( aItr != aRangeList.end() )
     246             :     {
     247           0 :         table::CellAddress aFirstAddress;
     248           0 :         ScUnoConversion::FillApiStartAddress( aFirstAddress, aItr->aCellRange );
     249           0 :         if( aFirstAddress == rMyCell.aCellAddress )
     250             :         {
     251           0 :             rMyCell.aMergeRange = aItr->aCellRange;
     252           0 :             if (aItr->bIsFirst)
     253           0 :                 rMyCell.aMergeRange.EndRow = rMyCell.aMergeRange.StartRow + aItr->nRows - 1;
     254           0 :             rMyCell.bIsMergedBase = aItr->bIsFirst;
     255           0 :             rMyCell.bIsCovered = !aItr->bIsFirst;
     256           0 :             if( aItr->aCellRange.StartColumn < aItr->aCellRange.EndColumn )
     257             :             {
     258           0 :                 ++(aItr->aCellRange.StartColumn);
     259           0 :                 aItr->bIsFirst = false;
     260             :             }
     261             :             else
     262           0 :                 aRangeList.erase(aItr);
     263             :         }
     264             :     }
     265         212 : }
     266             : 
     267           0 : void ScMyMergedRangesContainer::SkipTable(SCTAB nSkip)
     268             : {
     269           0 :     ScMyMergedRangeList::iterator aItr = aRangeList.begin();
     270           0 :     while( (aItr != aRangeList.end()) && (aItr->aCellRange.Sheet == nSkip) )
     271           0 :         aItr = aRangeList.erase(aItr);
     272           0 : }
     273             : 
     274           8 : void ScMyMergedRangesContainer::Sort()
     275             : {
     276           8 :     aRangeList.sort();
     277           8 : }
     278             : 
     279             : //==============================================================================
     280             : 
     281           0 : bool ScMyAreaLink::Compare( const ScMyAreaLink& rAreaLink ) const
     282             : {
     283           0 :     return  (GetRowCount() == rAreaLink.GetRowCount()) &&
     284           0 :             (sFilter == rAreaLink.sFilter) &&
     285           0 :             (sFilterOptions == rAreaLink.sFilterOptions) &&
     286           0 :             (sURL == rAreaLink.sURL) &&
     287           0 :             (sSourceStr == rAreaLink.sSourceStr);
     288             : }
     289             : 
     290           0 : bool ScMyAreaLink::operator<(const ScMyAreaLink& rAreaLink ) const
     291             : {
     292           0 :     if( aDestRange.Sheet != rAreaLink.aDestRange.Sheet )
     293           0 :         return (aDestRange.Sheet < rAreaLink.aDestRange.Sheet);
     294           0 :     else if( aDestRange.StartRow != rAreaLink.aDestRange.StartRow )
     295           0 :         return (aDestRange.StartRow < rAreaLink.aDestRange.StartRow);
     296             :     else
     297           0 :         return (aDestRange.StartColumn < rAreaLink.aDestRange.StartColumn);
     298             : }
     299             : 
     300           8 : ScMyAreaLinksContainer::ScMyAreaLinksContainer() :
     301           8 :     aAreaLinkList()
     302             : {
     303           8 : }
     304             : 
     305           8 : ScMyAreaLinksContainer::~ScMyAreaLinksContainer()
     306             : {
     307           8 : }
     308             : 
     309         221 : bool ScMyAreaLinksContainer::GetFirstAddress( table::CellAddress& rCellAddress )
     310             : {
     311         221 :     sal_Int32 nTable(rCellAddress.Sheet);
     312         221 :     if( !aAreaLinkList.empty() )
     313             :     {
     314           0 :         ScUnoConversion::FillApiStartAddress( rCellAddress, aAreaLinkList.begin()->aDestRange );
     315           0 :         return (nTable == rCellAddress.Sheet);
     316             :     }
     317         221 :     return false;
     318             : }
     319             : 
     320         212 : void ScMyAreaLinksContainer::SetCellData( ScMyCell& rMyCell )
     321             : {
     322         212 :     rMyCell.bHasAreaLink = false;
     323         212 :     ScMyAreaLinkList::iterator aItr(aAreaLinkList.begin());
     324         212 :     if( aItr != aAreaLinkList.end() )
     325             :     {
     326           0 :         table::CellAddress aAddress;
     327           0 :         ScUnoConversion::FillApiStartAddress( aAddress, aItr->aDestRange );
     328           0 :         if( aAddress == rMyCell.aCellAddress )
     329             :         {
     330           0 :             rMyCell.bHasAreaLink = true;
     331           0 :             rMyCell.aAreaLink = *aItr;
     332           0 :             aItr = aAreaLinkList.erase( aItr );
     333           0 :             bool bFound = true;
     334           0 :             while (aItr != aAreaLinkList.end() && bFound)
     335             :             {
     336           0 :                 ScUnoConversion::FillApiStartAddress( aAddress, aItr->aDestRange );
     337           0 :                 if (aAddress == rMyCell.aCellAddress)
     338             :                 {
     339             :                     OSL_FAIL("more than one linked range on one cell");
     340           0 :                     aItr = aAreaLinkList.erase( aItr );
     341             :                 }
     342             :                 else
     343           0 :                     bFound = false;
     344             :             }
     345             :         }
     346             :     }
     347         212 : }
     348             : 
     349           0 : void ScMyAreaLinksContainer::SkipTable(SCTAB nSkip)
     350             : {
     351           0 :     ScMyAreaLinkList::iterator aItr = aAreaLinkList.begin();
     352           0 :     while( (aItr != aAreaLinkList.end()) && (aItr->aDestRange.Sheet == nSkip) )
     353           0 :         aItr = aAreaLinkList.erase(aItr);
     354           0 : }
     355             : 
     356           8 : void ScMyAreaLinksContainer::Sort()
     357             : {
     358           8 :     aAreaLinkList.sort();
     359           8 : }
     360             : 
     361             : //==============================================================================
     362             : 
     363           0 : ScMyCellRangeAddress::ScMyCellRangeAddress(const table::CellRangeAddress& rRange)
     364           0 :     : table::CellRangeAddress(rRange)
     365             : {
     366           0 : }
     367             : 
     368           0 : bool ScMyCellRangeAddress::operator<(const ScMyCellRangeAddress& rRange ) const
     369             : {
     370           0 :     if( Sheet != rRange.Sheet )
     371           0 :         return (Sheet < rRange.Sheet);
     372           0 :     else if( StartRow != rRange.StartRow )
     373           0 :         return (StartRow < rRange.StartRow);
     374             :     else
     375           0 :         return (StartColumn < rRange.StartColumn);
     376             : }
     377             : 
     378           8 : ScMyEmptyDatabaseRangesContainer::ScMyEmptyDatabaseRangesContainer()
     379           8 :     : aDatabaseList()
     380             : {
     381           8 : }
     382             : 
     383           8 : ScMyEmptyDatabaseRangesContainer::~ScMyEmptyDatabaseRangesContainer()
     384             : {
     385           8 : }
     386             : 
     387           0 : void ScMyEmptyDatabaseRangesContainer::AddNewEmptyDatabaseRange(const table::CellRangeAddress& aCellRange)
     388             : {
     389           0 :     sal_Int32 nStartRow(aCellRange.StartRow);
     390           0 :     sal_Int32 nEndRow(aCellRange.EndRow);
     391           0 :     ScMyCellRangeAddress aRange( aCellRange );
     392           0 :     for( sal_Int32 nRow = nStartRow; nRow <= nEndRow; ++nRow )
     393             :     {
     394           0 :         aRange.StartRow = aRange.EndRow = nRow;
     395           0 :         aDatabaseList.push_back( aRange );
     396             :     }
     397           0 : }
     398             : 
     399         221 : bool ScMyEmptyDatabaseRangesContainer::GetFirstAddress( table::CellAddress& rCellAddress )
     400             : {
     401         221 :     sal_Int32 nTable(rCellAddress.Sheet);
     402         221 :     if( !aDatabaseList.empty() )
     403             :     {
     404           0 :         ScUnoConversion::FillApiStartAddress( rCellAddress, *(aDatabaseList.begin()) );
     405           0 :         return (nTable == rCellAddress.Sheet);
     406             :     }
     407         221 :     return false;
     408             : }
     409             : 
     410         212 : void ScMyEmptyDatabaseRangesContainer::SetCellData( ScMyCell& rMyCell )
     411             : {
     412         212 :     rMyCell.bHasEmptyDatabase = false;
     413         212 :     ScMyEmptyDatabaseRangeList::iterator aItr(aDatabaseList.begin());
     414         212 :     if( aItr != aDatabaseList.end() )
     415             :     {
     416           0 :         table::CellAddress aFirstAddress;
     417           0 :         ScUnoConversion::FillApiStartAddress( aFirstAddress, *aItr );
     418           0 :         if( aFirstAddress == rMyCell.aCellAddress )
     419             :         {
     420           0 :             rMyCell.bHasEmptyDatabase = true;
     421           0 :             if( aItr->StartColumn < aItr->EndColumn )
     422           0 :                 ++(aItr->StartColumn);
     423             :             else
     424           0 :                 aDatabaseList.erase(aItr);
     425             :         }
     426             :     }
     427         212 : }
     428             : 
     429           0 : void ScMyEmptyDatabaseRangesContainer::SkipTable(SCTAB nSkip)
     430             : {
     431           0 :     ScMyEmptyDatabaseRangeList::iterator aItr = aDatabaseList.begin();
     432           0 :     while( (aItr != aDatabaseList.end()) && (aItr->Sheet == nSkip) )
     433           0 :         aItr = aDatabaseList.erase(aItr);
     434           0 : }
     435             : 
     436           0 : void ScMyEmptyDatabaseRangesContainer::Sort()
     437             : {
     438           0 :     aDatabaseList.sort();
     439           0 : }
     440             : 
     441             : //==============================================================================
     442             : 
     443           0 : bool ScMyDetectiveObj::operator<( const ScMyDetectiveObj& rDetObj) const
     444             : {
     445           0 :     if( aPosition.Sheet != rDetObj.aPosition.Sheet )
     446           0 :         return (aPosition.Sheet < rDetObj.aPosition.Sheet);
     447           0 :     else if( aPosition.Row != rDetObj.aPosition.Row )
     448           0 :         return (aPosition.Row < rDetObj.aPosition.Row);
     449             :     else
     450           0 :         return (aPosition.Column < rDetObj.aPosition.Column);
     451             : }
     452             : 
     453           8 : ScMyDetectiveObjContainer::ScMyDetectiveObjContainer() :
     454           8 :     aDetectiveObjList()
     455             : {
     456           8 : }
     457             : 
     458          16 : ScMyDetectiveObjContainer::~ScMyDetectiveObjContainer()
     459             : {
     460          16 : }
     461             : 
     462           0 : void ScMyDetectiveObjContainer::AddObject( ScDetectiveObjType eObjType, const SCTAB nSheet,
     463             :                                             const ScAddress& rPosition, const ScRange& rSourceRange,
     464             :                                             bool bHasError )
     465             : {
     466           0 :     if( (eObjType == SC_DETOBJ_ARROW) ||
     467           0 :         (eObjType == SC_DETOBJ_FROMOTHERTAB) ||
     468           0 :         (eObjType == SC_DETOBJ_TOOTHERTAB) ||
     469             :         (eObjType == SC_DETOBJ_CIRCLE) )
     470             :     {
     471           0 :         ScMyDetectiveObj aDetObj;
     472           0 :         aDetObj.eObjType = eObjType;
     473           0 :         if( eObjType == SC_DETOBJ_TOOTHERTAB )
     474           0 :             ScUnoConversion::FillApiAddress( aDetObj.aPosition, rSourceRange.aStart );
     475             :         else
     476           0 :             ScUnoConversion::FillApiAddress( aDetObj.aPosition, rPosition );
     477           0 :         ScUnoConversion::FillApiRange( aDetObj.aSourceRange, rSourceRange );
     478             : 
     479             :         // #111064#; take the sheet where the object is found and not the sheet given in the ranges, because they are not always true
     480           0 :         if (eObjType != SC_DETOBJ_FROMOTHERTAB)
     481             :         {
     482             :             // if the ObjType == SC_DETOBJ_FROMOTHERTAB then the SourceRange is not used and so it has not to be tested and changed
     483             :             OSL_ENSURE(aDetObj.aPosition.Sheet == aDetObj.aSourceRange.Sheet, "It seems to be possible to have different sheets");
     484           0 :             aDetObj.aSourceRange.Sheet = nSheet;
     485             :         }
     486           0 :         aDetObj.aPosition.Sheet = nSheet;
     487             : 
     488           0 :         aDetObj.bHasError = bHasError;
     489           0 :         aDetectiveObjList.push_back( aDetObj );
     490             :     }
     491           0 : }
     492             : 
     493         221 : bool ScMyDetectiveObjContainer::GetFirstAddress( table::CellAddress& rCellAddress )
     494             : {
     495         221 :     sal_Int32 nTable(rCellAddress.Sheet);
     496         221 :     if( !aDetectiveObjList.empty() )
     497             :     {
     498           0 :         rCellAddress = aDetectiveObjList.begin()->aPosition;
     499           0 :         return (nTable == rCellAddress.Sheet);
     500             :     }
     501         221 :     return false;
     502             : }
     503             : 
     504         212 : void ScMyDetectiveObjContainer::SetCellData( ScMyCell& rMyCell )
     505             : {
     506         212 :     rMyCell.aDetectiveObjVec.clear();
     507         212 :     ScMyDetectiveObjList::iterator aItr(aDetectiveObjList.begin());
     508         212 :     ScMyDetectiveObjList::iterator aEndItr(aDetectiveObjList.end());
     509         424 :     while( (aItr != aEndItr) && (aItr->aPosition == rMyCell.aCellAddress) )
     510             :     {
     511           0 :         rMyCell.aDetectiveObjVec.push_back( *aItr );
     512           0 :         aItr = aDetectiveObjList.erase( aItr );
     513             :     }
     514         212 :     rMyCell.bHasDetectiveObj = (rMyCell.aDetectiveObjVec.size() != 0);
     515         212 : }
     516             : 
     517           0 : void ScMyDetectiveObjContainer::SkipTable(SCTAB nSkip)
     518             : {
     519           0 :     ScMyDetectiveObjList::iterator aItr = aDetectiveObjList.begin();
     520           0 :     while( (aItr != aDetectiveObjList.end()) && (aItr->aPosition.Sheet == nSkip) )
     521           0 :         aItr = aDetectiveObjList.erase(aItr);
     522           0 : }
     523             : 
     524           8 : void ScMyDetectiveObjContainer::Sort()
     525             : {
     526           8 :     aDetectiveObjList.sort();
     527           8 : }
     528             : 
     529             : //==============================================================================
     530             : 
     531           0 : bool ScMyDetectiveOp::operator<( const ScMyDetectiveOp& rDetOp) const
     532             : {
     533           0 :     if( aPosition.Sheet != rDetOp.aPosition.Sheet )
     534           0 :         return (aPosition.Sheet < rDetOp.aPosition.Sheet);
     535           0 :     else if( aPosition.Row != rDetOp.aPosition.Row )
     536           0 :         return (aPosition.Row < rDetOp.aPosition.Row);
     537             :     else
     538           0 :         return (aPosition.Column < rDetOp.aPosition.Column);
     539             : }
     540             : 
     541           8 : ScMyDetectiveOpContainer::ScMyDetectiveOpContainer() :
     542           8 :     aDetectiveOpList()
     543             : {
     544           8 : }
     545             : 
     546           8 : ScMyDetectiveOpContainer::~ScMyDetectiveOpContainer()
     547             : {
     548           8 : }
     549             : 
     550           0 : void ScMyDetectiveOpContainer::AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex )
     551             : {
     552           0 :     ScMyDetectiveOp aDetOp;
     553           0 :     aDetOp.eOpType = eOpType;
     554           0 :     ScUnoConversion::FillApiAddress( aDetOp.aPosition, rPosition );
     555           0 :     aDetOp.nIndex = nIndex;
     556           0 :     aDetectiveOpList.push_back( aDetOp );
     557           0 : }
     558             : 
     559         221 : bool ScMyDetectiveOpContainer::GetFirstAddress( table::CellAddress& rCellAddress )
     560             : {
     561         221 :     sal_Int32 nTable(rCellAddress.Sheet);
     562         221 :     if( !aDetectiveOpList.empty() )
     563             :     {
     564           0 :         rCellAddress = aDetectiveOpList.begin()->aPosition;
     565           0 :         return (nTable == rCellAddress.Sheet);
     566             :     }
     567         221 :     return false;
     568             : }
     569             : 
     570         212 : void ScMyDetectiveOpContainer::SetCellData( ScMyCell& rMyCell )
     571             : {
     572         212 :     rMyCell.aDetectiveOpVec.clear();
     573         212 :     ScMyDetectiveOpList::iterator aItr(aDetectiveOpList.begin());
     574         212 :     ScMyDetectiveOpList::iterator aEndItr(aDetectiveOpList.end());
     575         424 :     while( (aItr != aEndItr) && (aItr->aPosition == rMyCell.aCellAddress) )
     576             :     {
     577           0 :         rMyCell.aDetectiveOpVec.push_back( *aItr );
     578           0 :         aItr = aDetectiveOpList.erase( aItr );
     579             :     }
     580         212 :     rMyCell.bHasDetectiveOp = (rMyCell.aDetectiveOpVec.size() != 0);
     581         212 : }
     582             : 
     583           0 : void ScMyDetectiveOpContainer::SkipTable(SCTAB nSkip)
     584             : {
     585           0 :     ScMyDetectiveOpList::iterator aItr = aDetectiveOpList.begin();
     586           0 :     while( (aItr != aDetectiveOpList.end()) && (aItr->aPosition.Sheet == nSkip) )
     587           0 :         aItr = aDetectiveOpList.erase(aItr);
     588           0 : }
     589             : 
     590           0 : void ScMyDetectiveOpContainer::Sort()
     591             : {
     592           0 :     aDetectiveOpList.sort();
     593           0 : }
     594             : 
     595             : //==============================================================================
     596             : 
     597          18 : ScMyCell::ScMyCell() :
     598             :     aShapeList(),
     599             :     aDetectiveObjVec(),
     600             :     fValue(0.0),
     601             :     nValidationIndex(-1),
     602             :     bIsAutoStyle( false ),
     603             :     bHasShape( false ),
     604             :     bIsMergedBase( false ),
     605             :     bIsCovered( false ),
     606             :     bHasAreaLink( false ),
     607             :     bHasEmptyDatabase( false ),
     608             :     bHasDetectiveObj( false ),
     609             :     bHasDetectiveOp( false ),
     610             :     bIsEditCell( false ),
     611             :     bKnowWhetherIsEditCell( false ),
     612             :     bHasStringValue( false ),
     613             :     bHasDoubleValue( false ),
     614             :     bHasXText( false ),
     615             :     bIsMatrixBase( false ),
     616             :     bIsMatrixCovered( false ),
     617          18 :     bHasAnnotation( false )
     618             : {
     619          18 : }
     620             : 
     621          18 : ScMyCell::~ScMyCell()
     622             : {
     623          18 : }
     624             : 
     625             : //==============================================================================
     626             : 
     627           0 : bool ScMyExportAnnotation::operator<(const ScMyExportAnnotation& rAnno) const
     628             : {
     629           0 :     if( aCellAddress.Row != rAnno.aCellAddress.Row )
     630           0 :         return (aCellAddress.Row < rAnno.aCellAddress.Row);
     631             :     else
     632           0 :         return (aCellAddress.Column < rAnno.aCellAddress.Column);
     633             : }
     634             : 
     635             : 
     636          10 : ScMyNotEmptyCellsIterator::ScMyNotEmptyCellsIterator(ScXMLExport& rTempXMLExport)
     637             :     : pShapes(NULL),
     638             :     pNoteShapes(NULL),
     639             :     pEmptyDatabaseRanges(NULL),
     640             :     pMergedRanges(NULL),
     641             :     pAreaLinks(NULL),
     642             :     pDetectiveObj(NULL),
     643             :     pDetectiveOp(NULL),
     644             :     rExport(rTempXMLExport),
     645             :     pCellItr(NULL),
     646          10 :     nCurrentTable(SCTAB_MAX)
     647             : {
     648          10 : }
     649             : 
     650          20 : ScMyNotEmptyCellsIterator::~ScMyNotEmptyCellsIterator()
     651             : {
     652          10 :     Clear();
     653          10 : }
     654             : 
     655          18 : void ScMyNotEmptyCellsIterator::Clear()
     656             : {
     657          18 :     if (pCellItr)
     658           8 :         delete pCellItr;
     659          18 :     if (!aAnnotations.empty())
     660             :     {
     661             :         OSL_FAIL("not all Annotations saved");
     662           0 :         aAnnotations.clear();
     663             :     }
     664          18 :     maNoteExportList.clear();
     665          18 :     pCellItr = NULL;
     666          18 :     pShapes = NULL;
     667          18 :     pNoteShapes = NULL;
     668          18 :     pMergedRanges = NULL;
     669          18 :     pAreaLinks = NULL;
     670          18 :     pEmptyDatabaseRanges = NULL;
     671          18 :     pDetectiveObj = NULL;
     672          18 :     pDetectiveOp = NULL;
     673          18 :     nCurrentTable = SCTAB_MAX;
     674          18 : }
     675             : 
     676         221 : void ScMyNotEmptyCellsIterator::UpdateAddress( table::CellAddress& rAddress )
     677             : {
     678         221 :     if( pCellItr->GetPos( nCellCol, nCellRow ) )
     679             :     {
     680         210 :         rAddress.Column = nCellCol;
     681         210 :         rAddress.Row = nCellRow;
     682             :     }
     683         221 : }
     684             : 
     685         212 : void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, table::CellAddress& rAddress )
     686             : {
     687         212 :     rMyCell.aCellAddress = rAddress;
     688         212 :     rMyCell.bHasStringValue = false;
     689         212 :     rMyCell.bHasDoubleValue = false;
     690         212 :     rMyCell.bHasXText = false;
     691         212 :     rMyCell.bKnowWhetherIsEditCell = false;
     692         212 :     rMyCell.bIsEditCell = false;
     693         212 :     if( (nCellCol == rAddress.Column) && (nCellRow == rAddress.Row) )
     694         210 :         pCellItr->GetNext( nCellCol, nCellRow );
     695         212 : }
     696             : 
     697         212 : void ScMyNotEmptyCellsIterator::SetMatrixCellData( ScMyCell& rMyCell )
     698             : {
     699         212 :     rMyCell.bIsMatrixCovered = false;
     700         212 :     rMyCell.bIsMatrixBase = false;
     701             : 
     702         212 :     bool bIsMatrixBase(false);
     703             : 
     704         212 :     ScAddress aScAddress;
     705         212 :     ScUnoConversion::FillScAddress( aScAddress, rMyCell.aCellAddress );
     706         212 :     CellType eCalcType = rExport.GetDocument()->GetCellType( aScAddress );
     707         212 :     switch (eCalcType)
     708             :     {
     709             :         case CELLTYPE_VALUE:
     710         202 :             rMyCell.nType = table::CellContentType_VALUE;
     711         202 :             break;
     712             :         case CELLTYPE_STRING:
     713             :         case CELLTYPE_EDIT:
     714           8 :             rMyCell.nType = table::CellContentType_TEXT;
     715           8 :             break;
     716             :         case CELLTYPE_FORMULA:
     717           0 :             rMyCell.nType = table::CellContentType_FORMULA;
     718           0 :             break;
     719             :         default:
     720           2 :             rMyCell.nType = table::CellContentType_EMPTY;
     721             :     }
     722             : 
     723         212 :     if (rMyCell.nType == table::CellContentType_FORMULA)
     724           0 :         if( rExport.IsMatrix( aScAddress, rMyCell.aMatrixRange, bIsMatrixBase ) )
     725             :         {
     726           0 :             rMyCell.bIsMatrixBase = bIsMatrixBase;
     727           0 :             rMyCell.bIsMatrixCovered = !bIsMatrixBase;
     728             :         }
     729         212 : }
     730             : 
     731         212 : void ScMyNotEmptyCellsIterator::HasAnnotation(ScMyCell& aCell)
     732             : {
     733         212 :     aCell.bHasAnnotation = false;
     734         212 :     if (!aAnnotations.empty())
     735             :     {
     736           0 :         ScMyExportAnnotationList::iterator aItr(aAnnotations.begin());
     737           0 :         if ((aCell.aCellAddress.Column == aItr->aCellAddress.Column) &&
     738           0 :             (aCell.aCellAddress.Row == aItr->aCellAddress.Row))
     739             :         {
     740           0 :             aCell.xAnnotation.set(aItr->xAnnotation);
     741           0 :             uno::Reference<text::XSimpleText> xSimpleText(aCell.xAnnotation, uno::UNO_QUERY);
     742           0 :             if (aCell.xAnnotation.is() && xSimpleText.is())
     743             :             {
     744           0 :                 aCell.sAnnotationText = xSimpleText->getString();
     745           0 :                 if (!aCell.sAnnotationText.isEmpty())
     746           0 :                     aCell.bHasAnnotation = true;
     747             :             }
     748           0 :             aAnnotations.erase(aItr);
     749             :         }
     750             :     }
     751             : 
     752             :     // test - bypass the API
     753             :     // if (xCellRange.is())
     754             :     //  aCell.xCell.set(xCellRange->getCellByPosition(aCell.aCellAddress.Column, aCell.aCellAddress.Row));
     755         212 : }
     756             : 
     757             : 
     758           9 : void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
     759             :     uno::Reference<sheet::XSpreadsheet>& rxTable)
     760             : {
     761             :     OSL_ENSURE(aAnnotations.empty(), "not all Annotations saved");
     762           9 :     aLastAddress.Row = 0;
     763           9 :     aLastAddress.Column = 0;
     764           9 :     aLastAddress.Sheet = nTable;
     765           9 :     if (nCurrentTable != nTable)
     766             :     {
     767           9 :         maNoteExportList.clear();
     768           9 :         nCurrentTable = nTable;
     769           9 :         if (pCellItr)
     770           1 :             delete pCellItr;
     771           9 :         pCellItr = new ScHorizontalCellIterator(rExport.GetDocument(), nCurrentTable, 0, 0,
     772           9 :             static_cast<SCCOL>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)), static_cast<SCROW>(rExport.GetSharedData()->GetLastRow(nCurrentTable)));
     773             : 
     774           9 :         ScNotes* pNotes = rExport.GetDocument()->GetNotes(nTable);
     775           9 :         if(pNotes)
     776             :         {
     777           9 :             for(ScNotes::iterator itr = pNotes->begin(), itrEnd = pNotes->end(); itr != itrEnd; ++itr)
     778             :             {
     779             :                 ScNoteExportData aExportData;
     780           0 :                 aExportData.nCol = itr->first.first;
     781           0 :                 aExportData.nRow = itr->first.second;
     782           0 :                 aExportData.pNote = itr->second;
     783           0 :                 maNoteExportList.insert( aExportData );
     784             :             }
     785             :         }
     786           9 :         maNoteExportListItr = maNoteExportList.begin();
     787             : 
     788           9 :         xTable.set(rxTable);
     789           9 :         xCellRange.set(xTable, uno::UNO_QUERY);
     790           9 :         uno::Reference<sheet::XSheetAnnotationsSupplier> xSheetAnnotationsSupplier (xTable, uno::UNO_QUERY);
     791           9 :         if (xSheetAnnotationsSupplier.is())
     792             :         {
     793           9 :             uno::Reference<container::XEnumerationAccess> xAnnotationAccess ( xSheetAnnotationsSupplier->getAnnotations(), uno::UNO_QUERY);
     794           9 :             if (xAnnotationAccess.is())
     795             :             {
     796           9 :                 uno::Reference<container::XEnumeration> xAnnotations(xAnnotationAccess->createEnumeration());
     797           9 :                 if (xAnnotations.is())
     798             :                 {
     799          18 :                     while (xAnnotations->hasMoreElements())
     800             :                     {
     801           0 :                         ScMyExportAnnotation aAnnotation;
     802           0 :                         aAnnotation.xAnnotation.set(xAnnotations->nextElement(), uno::UNO_QUERY);
     803           0 :                         if (aAnnotation.xAnnotation.is())
     804             :                         {
     805           0 :                             aAnnotation.aCellAddress = aAnnotation.xAnnotation->getPosition();
     806           0 :                             aAnnotations.push_back(aAnnotation);
     807             :                         }
     808           0 :                     }
     809           9 :                     if (!aAnnotations.empty())
     810           0 :                         aAnnotations.sort();
     811           9 :                 }
     812           9 :             }
     813           9 :         }
     814             :     }
     815           9 : }
     816             : 
     817           0 : void ScMyNotEmptyCellsIterator::SkipTable(SCTAB nSkip)
     818             : {
     819             :     // Skip entries for a sheet that is copied instead of saving normally.
     820             :     // Cells (including aAnnotations) are handled separately in SetCurrentTable.
     821             : 
     822           0 :     if( pShapes )
     823           0 :         pShapes->SkipTable(nSkip);
     824           0 :     if( pNoteShapes )
     825           0 :         pNoteShapes->SkipTable(nSkip);
     826           0 :     if( pEmptyDatabaseRanges )
     827           0 :         pEmptyDatabaseRanges->SkipTable(nSkip);
     828           0 :     if( pMergedRanges )
     829           0 :         pMergedRanges->SkipTable(nSkip);
     830           0 :     if( pAreaLinks )
     831           0 :         pAreaLinks->SkipTable(nSkip);
     832           0 :     if( pDetectiveObj )
     833           0 :         pDetectiveObj->SkipTable(nSkip);
     834           0 :     if( pDetectiveOp )
     835           0 :         pDetectiveOp->SkipTable(nSkip);
     836           0 : }
     837             : 
     838         221 : bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles)
     839             : {
     840         221 :     table::CellAddress  aAddress( nCurrentTable, MAXCOL + 1, MAXROW + 1 );
     841             : 
     842         221 :     UpdateAddress( aAddress );
     843             : 
     844         221 :     if( pShapes )
     845           4 :         pShapes->UpdateAddress( aAddress );
     846         221 :     if( pNoteShapes )
     847           0 :         pNoteShapes->UpdateAddress( aAddress );
     848         221 :     if( pEmptyDatabaseRanges )
     849         221 :         pEmptyDatabaseRanges->UpdateAddress( aAddress );
     850         221 :     if( pMergedRanges )
     851         221 :         pMergedRanges->UpdateAddress( aAddress );
     852         221 :     if( pAreaLinks )
     853         221 :         pAreaLinks->UpdateAddress( aAddress );
     854         221 :     if( pDetectiveObj )
     855         221 :         pDetectiveObj->UpdateAddress( aAddress );
     856         221 :     if( pDetectiveOp )
     857         221 :         pDetectiveOp->UpdateAddress( aAddress );
     858             : 
     859         221 :     bool bFoundCell((aAddress.Column <= MAXCOL) && (aAddress.Row <= MAXROW));
     860         221 :     if( bFoundCell )
     861             :     {
     862         212 :         SetCellData( aCell, aAddress );
     863         212 :         if( pShapes )
     864           2 :             pShapes->SetCellData( aCell );
     865         212 :         if( pNoteShapes )
     866           0 :             pNoteShapes->SetCellData( aCell );
     867         212 :         if( pEmptyDatabaseRanges )
     868         212 :             pEmptyDatabaseRanges->SetCellData( aCell );
     869         212 :         if( pMergedRanges )
     870         212 :             pMergedRanges->SetCellData( aCell );
     871         212 :         if( pAreaLinks )
     872         212 :             pAreaLinks->SetCellData( aCell );
     873         212 :         if( pDetectiveObj )
     874         212 :             pDetectiveObj->SetCellData( aCell );
     875         212 :         if( pDetectiveOp )
     876         212 :             pDetectiveOp->SetCellData( aCell );
     877             : 
     878         212 :         HasAnnotation( aCell );
     879         212 :         SetMatrixCellData( aCell );
     880             :         bool bIsAutoStyle;
     881             :         // Ranges before the previous cell are not needed by ExportFormatRanges anymore and can be removed
     882         212 :         sal_Int32 nRemoveBeforeRow = aLastAddress.Row;
     883             :         aCell.nStyleIndex = pCellStyles->GetStyleNameIndex(aCell.aCellAddress.Sheet,
     884             :             aCell.aCellAddress.Column, aCell.aCellAddress.Row,
     885         212 :             bIsAutoStyle, aCell.nValidationIndex, aCell.nNumberFormat, nRemoveBeforeRow);
     886         212 :         aLastAddress = aCell.aCellAddress;
     887         212 :         aCell.bIsAutoStyle = bIsAutoStyle;
     888             : 
     889             :         //#102799#; if the cell is in a DatabaseRange which should saved empty, the cell should have the type empty
     890         212 :         if (aCell.bHasEmptyDatabase)
     891           0 :             aCell.nType = table::CellContentType_EMPTY;
     892             :     }
     893         221 :     return bFoundCell;
     894          93 : }
     895             : 
     896             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10