LCOV - code coverage report
Current view: top level - sc/inc - dbdata.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 25 96.0 %
Date: 2012-08-25 Functions: 25 26 96.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SC_DBCOLECT_HXX
      30                 :            : #define SC_DBCOLECT_HXX
      31                 :            : 
      32                 :            : #include "scdllapi.h"
      33                 :            : #include "refreshtimer.hxx"
      34                 :            : #include "address.hxx"
      35                 :            : #include "global.hxx"
      36                 :            : 
      37                 :            : #include <boost/ptr_container/ptr_vector.hpp>
      38                 :            : #include <boost/ptr_container/ptr_set.hpp>
      39                 :            : #include <boost/scoped_ptr.hpp>
      40                 :            : 
      41                 :            : class ScDocument;
      42                 :            : struct ScSortParam;
      43                 :            : struct ScQueryParam;
      44                 :            : struct ScSubTotalParam;
      45                 :            : struct ScImportParam;
      46                 :            : 
      47                 :            : class ScDBData : public ScRefreshTimer
      48                 :            : {
      49                 :            : private:
      50                 :            :     boost::scoped_ptr<ScSortParam> mpSortParam;
      51                 :            :     boost::scoped_ptr<ScQueryParam> mpQueryParam;
      52                 :            :     boost::scoped_ptr<ScSubTotalParam> mpSubTotal;
      53                 :            :     boost::scoped_ptr<ScImportParam> mpImportParam;
      54                 :            : 
      55                 :            :     // DBParam
      56                 :            :     const ::rtl::OUString aName;
      57                 :            :     ::rtl::OUString aUpper;
      58                 :            :     SCTAB           nTable;
      59                 :            :     SCCOL           nStartCol;
      60                 :            :     SCROW           nStartRow;
      61                 :            :     SCCOL           nEndCol;
      62                 :            :     SCROW           nEndRow;
      63                 :            :     bool            bByRow;
      64                 :            :     bool            bHasHeader;
      65                 :            :     bool            bDoSize;
      66                 :            :     bool            bKeepFmt;
      67                 :            :     bool            bStripData;
      68                 :            : 
      69                 :            :     // QueryParam
      70                 :            :     bool            bIsAdvanced;        // true if created by advanced filter
      71                 :            :     ScRange         aAdvSource;         // source range
      72                 :            : 
      73                 :            :     bool            bDBSelection;       // not in Param: if selection, block update
      74                 :            : 
      75                 :            :     sal_uInt16      nIndex;             // unique index formulas
      76                 :            :     bool            bAutoFilter;        // AutoFilter? (not saved)
      77                 :            :     bool            bModified;          // is set/cleared for/by(?) UpdateReference
      78                 :            : 
      79                 :            :     using ScRefreshTimer::operator==;
      80                 :            : 
      81                 :            : public:
      82                 :            :     struct less : public ::std::binary_function<ScDBData, ScDBData, bool>
      83                 :            :     {
      84                 :            :         bool operator() (const ScDBData& left, const ScDBData& right) const;
      85                 :            :     };
      86                 :            : 
      87                 :            :     SC_DLLPUBLIC ScDBData(const ::rtl::OUString& rName,
      88                 :            :              SCTAB nTab,
      89                 :            :              SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
      90                 :            :              bool bByR = true, bool bHasH = true);
      91                 :            :     ScDBData(const ScDBData& rData);
      92                 :            :     ScDBData(const ::rtl::OUString& rName, const ScDBData& rData);
      93                 :            :     ~ScDBData();
      94                 :            : 
      95                 :            :     ScDBData&   operator= (const ScDBData& rData);
      96                 :            : 
      97                 :            :     bool        operator== (const ScDBData& rData) const;
      98                 :            : 
      99                 :        632 :     const ::rtl::OUString& GetName() const { return aName; }
     100                 :          6 :     const ::rtl::OUString& GetUpperName() const { return aUpper; }
     101                 :            :     void        GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const;
     102                 :            :     SC_DLLPUBLIC void GetArea(ScRange& rRange) const;
     103                 :            :     void        SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
     104                 :            :     void        MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
     105                 :            :     bool        IsByRow() const                 { return bByRow; }
     106                 :         20 :     void        SetByRow(bool bByR)             { bByRow = bByR; }
     107                 :          6 :     bool        HasHeader() const               { return bHasHeader; }
     108                 :         45 :     void        SetHeader(bool bHasH)           { bHasHeader = bHasH; }
     109                 :         26 :     void        SetIndex(sal_uInt16 nInd)           { nIndex = nInd; }
     110                 :         40 :     sal_uInt16  GetIndex() const                { return nIndex; }
     111                 :         13 :     bool        IsDoSize() const                { return bDoSize; }
     112                 :         29 :     void        SetDoSize(bool bSet)            { bDoSize = bSet; }
     113                 :         13 :     bool        IsKeepFmt() const               { return bKeepFmt; }
     114                 :         29 :     void        SetKeepFmt(bool bSet)           { bKeepFmt = bSet; }
     115                 :         21 :     bool        IsStripData() const             { return bStripData; }
     116                 :         29 :     void        SetStripData(bool bSet)         { bStripData = bSet; }
     117                 :            : 
     118                 :            :     ::rtl::OUString GetSourceString() const;
     119                 :            :     ::rtl::OUString GetOperations() const;
     120                 :            : 
     121                 :            :     void        GetSortParam(ScSortParam& rSortParam) const;
     122                 :            :     void        SetSortParam(const ScSortParam& rSortParam);
     123                 :            : 
     124                 :            :     SC_DLLPUBLIC void       GetQueryParam(ScQueryParam& rQueryParam) const;
     125                 :            :     SC_DLLPUBLIC void       SetQueryParam(const ScQueryParam& rQueryParam);
     126                 :            :     SC_DLLPUBLIC bool       GetAdvancedQuerySource(ScRange& rSource) const;
     127                 :            :     SC_DLLPUBLIC void       SetAdvancedQuerySource(const ScRange* pSource);
     128                 :            : 
     129                 :            :     void        GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
     130                 :            :     void        SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
     131                 :            : 
     132                 :            :     void        GetImportParam(ScImportParam& rImportParam) const;
     133                 :            :     void        SetImportParam(const ScImportParam& rImportParam);
     134                 :            : 
     135                 :            :     bool        IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
     136                 :            :     bool        IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
     137                 :            : 
     138                 :            :     bool        HasImportParam() const;
     139                 :            :     SC_DLLPUBLIC bool HasQueryParam() const;
     140                 :            :     bool        HasSortParam() const;
     141                 :            :     bool        HasSubTotalParam() const;
     142                 :            : 
     143                 :          7 :     bool        HasImportSelection() const      { return bDBSelection; }
     144                 :          9 :     void        SetImportSelection(bool bSet)   { bDBSelection = bSet; }
     145                 :            : 
     146                 :         34 :     bool        HasAutoFilter() const       { return bAutoFilter; }
     147                 :         57 :     void        SetAutoFilter(bool bSet)    { bAutoFilter = bSet; }
     148                 :            : 
     149                 :          0 :     bool        IsModified() const          { return bModified; }
     150                 :          8 :     void        SetModified(bool bMod)      { bModified = bMod; }
     151                 :            : 
     152                 :            :     void    UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
     153                 :            :     void    UpdateReference(ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
     154                 :            :                         SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     155                 :            :                         SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
     156                 :            :                         SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
     157                 :            : 
     158                 :            :     void ExtendDataArea(ScDocument* pDoc);
     159                 :            : };
     160                 :            : 
     161         [ +  - ]:       1704 : class SC_DLLPUBLIC ScDBCollection
     162                 :            : {
     163                 :            : public:
     164                 :            :     enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous };
     165                 :            : 
     166                 :            :     /**
     167                 :            :      * Stores global named database ranges.
     168                 :            :      */
     169                 :       1704 :     class SC_DLLPUBLIC NamedDBs
     170                 :            :     {
     171                 :            :         friend class ScDBCollection;
     172                 :            : 
     173                 :            :         typedef ::boost::ptr_set<ScDBData, ScDBData::less> DBsType;
     174                 :            :         DBsType maDBs;
     175                 :            :         ScDBCollection& mrParent;
     176                 :            :         ScDocument& mrDoc;
     177                 :            :         NamedDBs(ScDBCollection& rParent, ScDocument& rDoc);
     178                 :            :         NamedDBs(const NamedDBs& r);
     179                 :            :     public:
     180                 :            :         typedef DBsType::iterator iterator;
     181                 :            :         typedef DBsType::const_iterator const_iterator;
     182                 :            : 
     183                 :            :         iterator begin();
     184                 :            :         iterator end();
     185                 :            :         const_iterator begin() const;
     186                 :            :         const_iterator end() const;
     187                 :            :         ScDBData* findByIndex(sal_uInt16 nIndex);
     188                 :            :         ScDBData* findByName(const ::rtl::OUString& rName);
     189                 :            :         ScDBData* findByUpperName(const ::rtl::OUString& rName);
     190                 :            :         bool insert(ScDBData* p);
     191                 :            :         void erase(iterator itr);
     192                 :            :         void erase(const ScDBData& r);
     193                 :            :         bool empty() const;
     194                 :            :         size_t size() const;
     195                 :            :         bool operator== (const NamedDBs& r) const;
     196                 :            :     };
     197                 :            : 
     198                 :            :     /**
     199                 :            :      * Stores global anonymous database ranges.
     200                 :            :      */
     201                 :       3584 :     class AnonDBs
     202                 :            :     {
     203                 :            :         typedef ::boost::ptr_vector<ScDBData> DBsType;
     204                 :            :         DBsType maDBs;
     205                 :            :     public:
     206                 :            :         typedef DBsType::iterator iterator;
     207                 :            :         typedef DBsType::const_iterator const_iterator;
     208                 :            : 
     209                 :            :         iterator begin();
     210                 :            :         iterator end();
     211                 :            :         const_iterator begin() const;
     212                 :            :         const_iterator end() const;
     213                 :            :         const ScDBData* findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
     214                 :            :         const ScDBData* findByRange(const ScRange& rRange) const;
     215                 :            :         ScDBData* getByRange(const ScRange& rRange);
     216                 :            :         void insert(ScDBData* p);
     217                 :            :         bool empty() const;
     218                 :            :         bool operator== (const AnonDBs& r) const;
     219                 :            :     };
     220                 :            : 
     221                 :            : private:
     222                 :            :     Link        aRefreshHandler;
     223                 :            :     ScDocument* pDoc;
     224                 :            :     sal_uInt16 nEntryIndex;         // counter for unique indices
     225                 :            :     NamedDBs maNamedDBs;
     226                 :            :     AnonDBs maAnonDBs;
     227                 :            : 
     228                 :            : public:
     229                 :            :     ScDBCollection(ScDocument* pDocument);
     230                 :            :     ScDBCollection(const ScDBCollection& r);
     231                 :            : 
     232                 :            :     NamedDBs& getNamedDBs();
     233                 :            :     const NamedDBs& getNamedDBs() const;
     234                 :            : 
     235                 :            :     AnonDBs& getAnonDBs();
     236                 :            :     const AnonDBs& getAnonDBs() const;
     237                 :            : 
     238                 :            :     const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const;
     239                 :            :     ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly);
     240                 :            :     const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
     241                 :            :     ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
     242                 :            :     ScDBData* GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab );
     243                 :            : 
     244                 :            :     void    DeleteOnTab( SCTAB nTab );
     245                 :            :     void    UpdateReference(UpdateRefMode eUpdateRefMode,
     246                 :            :                                 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     247                 :            :                                 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
     248                 :            :                                 SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
     249                 :            :     void    UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
     250                 :            : 
     251                 :            :     sal_uInt16  GetEntryIndex()                 { return nEntryIndex; }
     252                 :            :     void    SetEntryIndex(sal_uInt16 nInd)      { nEntryIndex = nInd; }
     253                 :            : 
     254                 :        846 :     void            SetRefreshHandler( const Link& rLink )
     255                 :        846 :                         { aRefreshHandler = rLink; }
     256                 :          3 :     const Link&     GetRefreshHandler() const   { return aRefreshHandler; }
     257                 :            : 
     258                 :            :     bool empty() const;
     259                 :            :     bool operator== (const ScDBCollection& r) const;
     260                 :            : };
     261                 :            : 
     262                 :            : #endif
     263                 :            : 
     264                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10