LCOV - code coverage report
Current view: top level - sc/source/filter/inc - excrecds.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 15 32 46.9 %
Date: 2015-06-13 12:38:46 Functions: 25 66 37.9 %
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_SOURCE_FILTER_INC_EXCRECDS_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_EXCRECDS_HXX
      22             : 
      23             : #include <rtl/string.hxx>
      24             : #include <rtl/ustring.hxx>
      25             : #include <svl/zforlist.hxx>
      26             : #include <tools/solar.h>
      27             : #include <tools/color.hxx>
      28             : #include <vcl/vclenum.hxx>
      29             : 
      30             : #include "olinetab.hxx"
      31             : #include "filter.hxx"
      32             : #include "rangelst.hxx"
      33             : #include "xerecord.hxx"
      34             : #include "xeroot.hxx"
      35             : #include "xeformula.hxx"
      36             : #include "xestring.hxx"
      37             : #include "root.hxx"
      38             : #include "excdefs.hxx"
      39             : #include <memory>
      40             : #include <vector>
      41             : 
      42             : //------------------------------------------------------------------ Forwards -
      43             : 
      44             : struct ScQueryEntry;
      45             : 
      46             : //----------------------------------------------------------- class ExcRecord -
      47             : 
      48        1887 : class ExcRecord : public XclExpRecord
      49             : {
      50             : public:
      51             :     virtual void            Save( XclExpStream& rStrm ) SAL_OVERRIDE;
      52             :     virtual void            SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
      53             : 
      54             :     virtual sal_uInt16          GetNum() const = 0;
      55             :     virtual sal_Size        GetLen() const = 0;
      56             : 
      57             : protected:
      58             :     virtual void            SaveCont( XclExpStream& rStrm );
      59             : 
      60             : private:
      61             :     /** Writes the body of the record. */
      62             :     virtual void            WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
      63             : };
      64             : 
      65             : //--------------------------------------------------------- class ExcEmptyRec -
      66             : 
      67         262 : class ExcEmptyRec : public ExcRecord
      68             : {
      69             : private:
      70             : protected:
      71             : public:
      72             :     virtual void            Save( XclExpStream& rStrm ) SAL_OVERRIDE;
      73             :     virtual sal_uInt16          GetNum() const SAL_OVERRIDE;
      74             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
      75             : };
      76             : 
      77             : //--------------------------------------------------------- class ExcDummyRec -
      78             : 
      79           0 : class ExcDummyRec : public ExcRecord
      80             : {
      81             : protected:
      82             : public:
      83             :     virtual void            Save( XclExpStream& rStrm ) SAL_OVERRIDE;
      84             :     virtual sal_uInt16          GetNum() const SAL_OVERRIDE;
      85             :     virtual const sal_uInt8*        GetData() const = 0;    // byte data must contain header and body
      86             : };
      87             : 
      88             : //------------------------------------------------------- class ExcBoolRecord -
      89             : // stores bool as 16bit val ( 0x0000 | 0x0001 )
      90             : 
      91          72 : class ExcBoolRecord : public ExcRecord
      92             : {
      93             : private:
      94             :     virtual void            SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
      95             : 
      96             : protected:
      97             :     bool                    bVal;
      98             : 
      99          72 :     inline                  ExcBoolRecord() : bVal( false ) {}
     100             : 
     101             : public:
     102             :     inline                  ExcBoolRecord( const bool bDefault ) : bVal( bDefault ) {}
     103             : 
     104             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
     105             : };
     106             : 
     107             : //--------------------------------------------------------- class ExcBof_Base -
     108             : 
     109          46 : class ExcBof_Base : public ExcRecord
     110             : {
     111             : private:
     112             : protected:
     113             :     sal_uInt16                  nDocType;
     114             :     sal_uInt16                  nVers;
     115             :     sal_uInt16                  nRupBuild;
     116             :     sal_uInt16                  nRupYear;
     117             : public:
     118             :                             ExcBof_Base();
     119             : };
     120             : 
     121             : //-------------------------------------------------------------- class ExcBof -
     122             : // Header Record fuer WORKSHEETS
     123             : 
     124           0 : class ExcBof : public ExcBof_Base
     125             : {
     126             : private:
     127             :     virtual void            SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
     128             : public:
     129             :                             ExcBof();
     130             : 
     131             :     virtual sal_uInt16          GetNum() const SAL_OVERRIDE;
     132             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
     133             : };
     134             : 
     135             : //------------------------------------------------------------- class ExcBofW -
     136             : // Header Record fuer WORKBOOKS
     137             : 
     138           0 : class ExcBofW : public ExcBof_Base
     139             : {
     140             : private:
     141             :     virtual void            SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
     142             : public:
     143             :                             ExcBofW();
     144             : 
     145             :     virtual sal_uInt16          GetNum() const SAL_OVERRIDE;
     146             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
     147             : };
     148             : 
     149             : //-------------------------------------------------------------- class ExcEof -
     150             : 
     151         141 : class ExcEof : public ExcRecord
     152             : {
     153             : private:
     154             : public:
     155             :     virtual sal_uInt16          GetNum() const SAL_OVERRIDE;
     156             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
     157             : };
     158             : 
     159             : //--------------------------------------------------------- class ExcDummy_00 -
     160             : // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
     161             : 
     162           0 : class ExcDummy_00 : public ExcDummyRec
     163             : {
     164             : private:
     165             :     static const sal_uInt8      pMyData[];
     166             :     static const sal_Size   nMyLen;
     167             : public:
     168             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
     169             :     virtual const sal_uInt8*        GetData() const SAL_OVERRIDE;
     170             : };
     171             : 
     172             : // EXC_ID_WINDOWPROTECTION
     173           0 : class XclExpWindowProtection : public   XclExpBoolRecord
     174             : {
     175             :     public:
     176             :         XclExpWindowProtection(bool bValue);
     177             : 
     178             :     virtual void            SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     179             : };
     180             : 
     181             : // EXC_ID_PROTECT  Document Protection
     182           1 : class XclExpProtection : public XclExpBoolRecord
     183             : {
     184             :     public:
     185             :         XclExpProtection(bool bValue);
     186             : };
     187             : 
     188           2 : class XclExpSheetProtection : public XclExpProtection
     189             : {
     190             :     SCTAB                   mnTab;
     191             :     public:
     192             :         XclExpSheetProtection(bool bValue, SCTAB nTab);
     193             :     virtual void            SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     194             : };
     195             : 
     196             : class XclExpPassHash : public XclExpRecord
     197             : {
     198             : public:
     199             :     XclExpPassHash(const ::com::sun::star::uno::Sequence<sal_Int8>& aHash);
     200             :     virtual ~XclExpPassHash();
     201             : 
     202             : private:
     203             :     virtual void    WriteBody(XclExpStream& rStrm) SAL_OVERRIDE;
     204             : 
     205             : private:
     206             :     sal_uInt16  mnHash;
     207             : };
     208             : 
     209             : //-------------------------------------------------------- class ExcDummy_04x -
     210             : // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
     211             : 
     212           0 : class ExcDummy_040 : public ExcDummyRec
     213             : {
     214             : private:
     215             :     static const sal_uInt8      pMyData[];
     216             :     static const sal_Size   nMyLen;
     217             : public:
     218             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
     219             :     virtual const sal_uInt8*        GetData() const SAL_OVERRIDE;
     220             : };
     221             : 
     222           0 : class ExcDummy_041 : public ExcDummyRec
     223             : {
     224             : private:
     225             :     static const sal_uInt8      pMyData[];
     226             :     static const sal_Size   nMyLen;
     227             : public:
     228             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
     229             :     virtual const sal_uInt8*        GetData() const SAL_OVERRIDE;
     230             : };
     231             : 
     232             : //------------------------------------------------------------- class Exc1904 -
     233             : 
     234         144 : class Exc1904 : public ExcBoolRecord
     235             : {
     236             : public:
     237             :                             Exc1904( ScDocument& rDoc );
     238             :     virtual sal_uInt16          GetNum() const SAL_OVERRIDE;
     239             : 
     240             :     virtual void            SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     241             : private:
     242             :     bool                    bDateCompatibility;
     243             : };
     244             : 
     245             : //------------------------------------------------------ class ExcBundlesheet -
     246             : 
     247         129 : class ExcBundlesheetBase : public ExcRecord
     248             : {
     249             : protected:
     250             :     sal_uInt64              m_nStrPos;
     251             :     sal_uInt64              m_nOwnPos;    // Position after # and Len
     252             :     sal_uInt16                  nGrbit;
     253             :     SCTAB                   nTab;
     254             : 
     255             :                             ExcBundlesheetBase();
     256             : 
     257             : public:
     258             :                             ExcBundlesheetBase( RootData& rRootData, SCTAB nTab );
     259             : 
     260          29 :     inline void             SetStreamPos(sal_uInt64 const nStrPos) { m_nStrPos = nStrPos; }
     261             :     void                    UpdateStreamPos( XclExpStream& rStrm );
     262             : 
     263             :     virtual sal_uInt16          GetNum() const SAL_OVERRIDE;
     264             : };
     265             : 
     266           0 : class ExcBundlesheet : public ExcBundlesheetBase
     267             : {
     268             : private:
     269             :     OString            aName;
     270             : 
     271             :     virtual void            SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
     272             : 
     273             : public:
     274             :                             ExcBundlesheet( RootData& rRootData, SCTAB nTab );
     275             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
     276             : };
     277             : 
     278             : //--------------------------------------------------------- class ExcDummy_02 -
     279             : // sheet dummies: CALCMODE to SETUP
     280             : 
     281           0 : class ExcDummy_02a : public ExcDummyRec
     282             : {
     283             : private:
     284             :     static const sal_uInt8      pMyData[];
     285             :     static const sal_Size   nMyLen;
     286             : public:
     287             :     virtual sal_Size        GetLen() const SAL_OVERRIDE;
     288             :     virtual const sal_uInt8*        GetData() const SAL_OVERRIDE;
     289             : };
     290             : 
     291             : /** This record contains the Windows country IDs for the UI and document language. */
     292          34 : class XclExpCountry : public XclExpRecord
     293             : {
     294             : public:
     295             :     explicit                    XclExpCountry( const XclExpRoot& rRoot );
     296             : 
     297             : private:
     298             :     sal_uInt16                  mnUICountry;        /// The UI country ID.
     299             :     sal_uInt16                  mnDocCountry;       /// The document country ID.
     300             : 
     301             :     /** Writes the body of the COUNTRY record. */
     302             :     virtual void                WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     303             : };
     304             : 
     305             : // XclExpWsbool ===============================================================
     306             : 
     307          58 : class XclExpWsbool : public XclExpUInt16Record
     308             : {
     309             : public:
     310             :     explicit XclExpWsbool( bool bFitToPages );
     311             : };
     312             : 
     313             : /**
     314             :  * Save sheetPr element and its children for xlsx export.
     315             :  */
     316         200 : class XclExpXmlSheetPr : public XclExpRecordBase
     317             : {
     318             : public:
     319             :     explicit XclExpXmlSheetPr(
     320             :         bool bFitToPages, SCTAB nScTab, const Color& rTabColor, XclExpFilterManager* pManager );
     321             : 
     322             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     323             : 
     324             : private:
     325             :     SCTAB mnScTab;
     326             :     XclExpFilterManager* mpManager;
     327             :     bool mbFitToPage;
     328             :     Color maTabColor;
     329             : };
     330             : 
     331           0 : class XclExpFiltermode : public XclExpEmptyRecord
     332             : {
     333             : public:
     334             :     explicit            XclExpFiltermode();
     335             : };
     336             : 
     337           0 : class XclExpAutofilterinfo : public XclExpUInt16Record
     338             : {
     339             : public:
     340             :     explicit            XclExpAutofilterinfo( const ScAddress& rStartPos, SCCOL nScCol );
     341             : 
     342           0 :     inline const ScAddress GetStartPos() const { return maStartPos; }
     343           0 :     inline SCCOL        GetColCount() const { return static_cast< SCCOL >( GetValue() ); }
     344             : 
     345             : private:
     346             :     ScAddress           maStartPos;
     347             : };
     348             : 
     349             : class ExcFilterCondition
     350             : {
     351             : private:
     352             :     sal_uInt8               nType;
     353             :     sal_uInt8               nOper;
     354             :     double                  fVal;
     355             :     XclExpString*           pText;
     356             : 
     357             : protected:
     358             : public:
     359             :                             ExcFilterCondition();
     360             :                             ~ExcFilterCondition();
     361             : 
     362           0 :     inline bool             IsEmpty() const     { return (nType == EXC_AFTYPE_NOTUSED); }
     363             :     inline bool             HasEqual() const    { return (nOper == EXC_AFOPER_EQUAL); }
     364             :     sal_uLong               GetTextBytes() const;
     365             : 
     366             :     void                    SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, OUString* pT );
     367             : 
     368             :     void                    Save( XclExpStream& rStrm );
     369             :     void                    SaveXml( XclExpXmlStream& rStrm );
     370             :     void                    SaveText( XclExpStream& rStrm );
     371             : };
     372             : 
     373           0 : class XclExpAutofilter : public XclExpRecord, protected XclExpRoot
     374             : {
     375             : private:
     376             :     enum FilterType { FilterCondition, MultiValue };
     377             :     FilterType              meType;
     378             :     sal_uInt16              nCol;
     379             :     sal_uInt16              nFlags;
     380             :     ExcFilterCondition      aCond[ 2 ];
     381             :     std::vector<OUString> maMultiValues;
     382             : 
     383             :     bool                    AddCondition( ScQueryConnect eConn, sal_uInt8 nType,
     384             :                                 sal_uInt8 nOp, double fVal, OUString* pText,
     385             :                                 bool bSimple = false );
     386             : 
     387             :     virtual void            WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     388             : 
     389             : public:
     390             :                             XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC );
     391             : 
     392           0 :     inline sal_uInt16       GetCol() const          { return nCol; }
     393           0 :     inline bool             HasTop10() const        { return ::get_flag( nFlags, EXC_AFFLAG_TOP10 ); }
     394             : 
     395             :     bool                    HasCondition() const;
     396             :     bool                    AddEntry( const ScQueryEntry& rEntry );
     397             :     bool                    AddMultiValueEntry( const ScQueryEntry& rEntry );
     398             : 
     399             :     virtual void            SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     400             : };
     401             : 
     402             : class ExcAutoFilterRecs : public XclExpRecordBase, protected XclExpRoot
     403             : {
     404             : public:
     405             :     explicit            ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab );
     406             :     virtual             ~ExcAutoFilterRecs();
     407             : 
     408             :     void                AddObjRecs();
     409             : 
     410             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     411             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     412             : 
     413             :     bool                HasFilterMode() const;
     414             : 
     415             : private:
     416             :     XclExpAutofilter*   GetByCol( SCCOL nCol ); // always 0-based
     417             :     bool                IsFiltered( SCCOL nCol );
     418             : 
     419             : private:
     420             :     typedef XclExpRecordList< XclExpAutofilter >    XclExpAutofilterList;
     421             :     typedef XclExpAutofilterList::RecordRefType     XclExpAutofilterRef;
     422             : 
     423             :     XclExpAutofilterList maFilterList;
     424             :     XclExpFiltermode*   pFilterMode;
     425             :     XclExpAutofilterinfo* pFilterInfo;
     426             :     ScRange                 maRef;
     427             :     bool mbAutoFilter;
     428             : };
     429             : 
     430             : /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
     431         144 : class XclExpFilterManager : protected XclExpRoot
     432             : {
     433             : public:
     434             :     explicit            XclExpFilterManager( const XclExpRoot& rRoot );
     435             : 
     436             :     /** Creates the filter records for the specified sheet.
     437             :         @descr  Creates and inserts related built-in NAME records. Therefore this
     438             :             function is called from the name buffer itself. */
     439             :     void                InitTabFilter( SCTAB nScTab );
     440             : 
     441             :     /** Returns a record object containing all filter records for the specified sheet. */
     442             :     XclExpRecordRef     CreateRecord( SCTAB nScTab );
     443             : 
     444             :     /** Returns whether or not FilterMode is present */
     445             :     bool                HasFilterMode( SCTAB nScTab );
     446             : 
     447             : private:
     448             :     using               XclExpRoot::CreateRecord;
     449             : 
     450             :     typedef std::shared_ptr< ExcAutoFilterRecs >  XclExpTabFilterRef;
     451             :     typedef ::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap;
     452             : 
     453             :     XclExpTabFilterMap  maFilterMap;
     454             : };
     455             : 
     456             : #endif
     457             : 
     458             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11