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

Generated by: LCOV version 1.11