LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/inc - dbdata.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 25 96.0 %
Date: 2013-07-09 Functions: 25 26 96.2 %
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_DBCOLECT_HXX
      21             : #define SC_DBCOLECT_HXX
      22             : 
      23             : #include "scdllapi.h"
      24             : #include "refreshtimer.hxx"
      25             : #include "address.hxx"
      26             : #include "global.hxx"
      27             : 
      28             : #include <boost/ptr_container/ptr_vector.hpp>
      29             : #include <boost/ptr_container/ptr_set.hpp>
      30             : #include <boost/scoped_ptr.hpp>
      31             : 
      32             : class ScDocument;
      33             : struct ScSortParam;
      34             : struct ScQueryParam;
      35             : struct ScSubTotalParam;
      36             : struct ScImportParam;
      37             : 
      38             : class ScDBData : public ScRefreshTimer
      39             : {
      40             : private:
      41             :     boost::scoped_ptr<ScSortParam> mpSortParam;
      42             :     boost::scoped_ptr<ScQueryParam> mpQueryParam;
      43             :     boost::scoped_ptr<ScSubTotalParam> mpSubTotal;
      44             :     boost::scoped_ptr<ScImportParam> mpImportParam;
      45             : 
      46             :     /// DBParam
      47             :     const OUString aName;
      48             :     OUString aUpper;
      49             :     SCTAB           nTable;
      50             :     SCCOL           nStartCol;
      51             :     SCROW           nStartRow;
      52             :     SCCOL           nEndCol;
      53             :     SCROW           nEndRow;
      54             :     bool            bByRow;
      55             :     bool            bHasHeader;
      56             :     bool            bDoSize;
      57             :     bool            bKeepFmt;
      58             :     bool            bStripData;
      59             : 
      60             :     /// QueryParam
      61             :     bool            bIsAdvanced;        ///< true if created by advanced filter
      62             :     ScRange         aAdvSource;         ///< source range
      63             : 
      64             :     bool            bDBSelection;       ///< not in Param: if selection, block update
      65             : 
      66             :     sal_uInt16      nIndex;             ///< unique index formulas
      67             :     bool            bAutoFilter;        ///< AutoFilter? (not saved)
      68             :     bool            bModified;          ///< is set/cleared for/by(?) UpdateReference
      69             : 
      70             :     using ScRefreshTimer::operator==;
      71             : 
      72             : public:
      73             :     struct less : public ::std::binary_function<ScDBData, ScDBData, bool>
      74             :     {
      75             :         bool operator() (const ScDBData& left, const ScDBData& right) const;
      76             :     };
      77             : 
      78             :     SC_DLLPUBLIC ScDBData(const OUString& rName,
      79             :              SCTAB nTab,
      80             :              SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
      81             :              bool bByR = true, bool bHasH = true);
      82             :     ScDBData(const ScDBData& rData);
      83             :     ScDBData(const OUString& rName, const ScDBData& rData);
      84             :     ~ScDBData();
      85             : 
      86             :     ScDBData&   operator= (const ScDBData& rData);
      87             : 
      88             :     bool        operator== (const ScDBData& rData) const;
      89             : 
      90          70 :     const OUString& GetName() const { return aName; }
      91         367 :     const OUString& GetUpperName() const { return aUpper; }
      92             :     void        GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const;
      93             :     SC_DLLPUBLIC void GetArea(ScRange& rRange) const;
      94             :     void        SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
      95             :     void        MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
      96             :     bool        IsByRow() const                 { return bByRow; }
      97          11 :     void        SetByRow(bool bByR)             { bByRow = bByR; }
      98           2 :     bool        HasHeader() const               { return bHasHeader; }
      99          48 :     void        SetHeader(bool bHasH)           { bHasHeader = bHasH; }
     100          13 :     void        SetIndex(sal_uInt16 nInd)           { nIndex = nInd; }
     101          19 :     sal_uInt16  GetIndex() const                { return nIndex; }
     102          11 :     bool        IsDoSize() const                { return bDoSize; }
     103          14 :     void        SetDoSize(bool bSet)            { bDoSize = bSet; }
     104          11 :     bool        IsKeepFmt() const               { return bKeepFmt; }
     105          14 :     void        SetKeepFmt(bool bSet)           { bKeepFmt = bSet; }
     106          14 :     bool        IsStripData() const             { return bStripData; }
     107          14 :     void        SetStripData(bool bSet)         { bStripData = bSet; }
     108             : 
     109             :     OUString GetSourceString() const;
     110             :     OUString GetOperations() const;
     111             : 
     112             :     void        GetSortParam(ScSortParam& rSortParam) const;
     113             :     void        SetSortParam(const ScSortParam& rSortParam);
     114             : 
     115             :     SC_DLLPUBLIC void       GetQueryParam(ScQueryParam& rQueryParam) const;
     116             :     SC_DLLPUBLIC void       SetQueryParam(const ScQueryParam& rQueryParam);
     117             :     SC_DLLPUBLIC bool       GetAdvancedQuerySource(ScRange& rSource) const;
     118             :     SC_DLLPUBLIC void       SetAdvancedQuerySource(const ScRange* pSource);
     119             : 
     120             :     void        GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
     121             :     void        SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
     122             : 
     123             :     void        GetImportParam(ScImportParam& rImportParam) const;
     124             :     void        SetImportParam(const ScImportParam& rImportParam);
     125             : 
     126             :     bool        IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
     127             :     bool        IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
     128             : 
     129             :     bool        HasImportParam() const;
     130             :     SC_DLLPUBLIC bool HasQueryParam() const;
     131             :     bool        HasSortParam() const;
     132             :     bool        HasSubTotalParam() const;
     133             : 
     134           7 :     bool        HasImportSelection() const      { return bDBSelection; }
     135           7 :     void        SetImportSelection(bool bSet)   { bDBSelection = bSet; }
     136             : 
     137          43 :     bool        HasAutoFilter() const       { return bAutoFilter; }
     138          28 :     void        SetAutoFilter(bool bSet)    { bAutoFilter = bSet; }
     139             : 
     140           0 :     bool        IsModified() const          { return bModified; }
     141           6 :     void        SetModified(bool bMod)      { bModified = bMod; }
     142             : 
     143             :     void    UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
     144             :     void    UpdateReference(ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
     145             :                         SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     146             :                         SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
     147             :                         SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
     148             : 
     149             :     void ExtendDataArea(ScDocument* pDoc);
     150             : };
     151             : 
     152        1470 : class SC_DLLPUBLIC ScDBCollection
     153             : {
     154             : public:
     155             :     enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous };
     156             : 
     157             :     /**
     158             :      * Stores global named database ranges.
     159             :      */
     160        1470 :     class SC_DLLPUBLIC NamedDBs
     161             :     {
     162             :         friend class ScDBCollection;
     163             : 
     164             :         typedef ::boost::ptr_set<ScDBData, ScDBData::less> DBsType;
     165             :         DBsType maDBs;
     166             :         ScDBCollection& mrParent;
     167             :         ScDocument& mrDoc;
     168             :         NamedDBs(ScDBCollection& rParent, ScDocument& rDoc);
     169             :         NamedDBs(const NamedDBs& r);
     170             :     public:
     171             :         typedef DBsType::iterator iterator;
     172             :         typedef DBsType::const_iterator const_iterator;
     173             : 
     174             :         iterator begin();
     175             :         iterator end();
     176             :         const_iterator begin() const;
     177             :         const_iterator end() const;
     178             :         ScDBData* findByIndex(sal_uInt16 nIndex);
     179             :         ScDBData* findByUpperName(const OUString& rName);
     180             :         bool insert(ScDBData* p);
     181             :         void erase(iterator itr);
     182             :         void erase(const ScDBData& r);
     183             :         bool empty() const;
     184             :         size_t size() const;
     185             :         bool operator== (const NamedDBs& r) const;
     186             :     };
     187             : 
     188             :     /**
     189             :      * Stores global anonymous database ranges.
     190             :      */
     191        3056 :     class AnonDBs
     192             :     {
     193             :         typedef ::boost::ptr_vector<ScDBData> DBsType;
     194             :         DBsType maDBs;
     195             :     public:
     196             :         typedef DBsType::iterator iterator;
     197             :         typedef DBsType::const_iterator const_iterator;
     198             : 
     199             :         iterator begin();
     200             :         iterator end();
     201             :         const_iterator begin() const;
     202             :         const_iterator end() const;
     203             :         const ScDBData* findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
     204             :         const ScDBData* findByRange(const ScRange& rRange) const;
     205             :         ScDBData* getByRange(const ScRange& rRange);
     206             :         void insert(ScDBData* p);
     207             :         bool empty() const;
     208             :         bool operator== (const AnonDBs& r) const;
     209             :     };
     210             : 
     211             : private:
     212             :     Link        aRefreshHandler;
     213             :     ScDocument* pDoc;
     214             :     sal_uInt16 nEntryIndex;         ///< counter for unique indices
     215             :     NamedDBs maNamedDBs;
     216             :     AnonDBs maAnonDBs;
     217             : 
     218             : public:
     219             :     ScDBCollection(ScDocument* pDocument);
     220             :     ScDBCollection(const ScDBCollection& r);
     221             : 
     222             :     NamedDBs& getNamedDBs();
     223             :     const NamedDBs& getNamedDBs() const;
     224             : 
     225             :     AnonDBs& getAnonDBs();
     226             :     const AnonDBs& getAnonDBs() const;
     227             : 
     228             :     const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const;
     229             :     ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly);
     230             :     const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
     231             :     ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
     232             :     ScDBData* GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab );
     233             : 
     234             :     void    DeleteOnTab( SCTAB nTab );
     235             :     void    UpdateReference(UpdateRefMode eUpdateRefMode,
     236             :                                 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     237             :                                 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
     238             :                                 SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
     239             :     void    UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
     240             : 
     241             :     sal_uInt16  GetEntryIndex()                 { return nEntryIndex; }
     242             :     void    SetEntryIndex(sal_uInt16 nInd)      { nEntryIndex = nInd; }
     243             : 
     244         577 :     void            SetRefreshHandler( const Link& rLink )
     245         577 :                         { aRefreshHandler = rLink; }
     246           3 :     const Link&     GetRefreshHandler() const   { return aRefreshHandler; }
     247             : 
     248             :     bool empty() const;
     249             :     bool operator== (const ScDBCollection& r) const;
     250             : };
     251             : 
     252             : #endif
     253             : 
     254             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10