LCOV - code coverage report
Current view: top level - sc/inc - editutil.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 13 76.9 %
Date: 2012-08-25 Functions: 16 18 88.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 16 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_EDITUTIL_HXX
      30                 :            : #define SC_EDITUTIL_HXX
      31                 :            : 
      32                 :            : #include "scdllapi.h"
      33                 :            : #include "address.hxx"
      34                 :            : #include <editeng/editeng.hxx>
      35                 :            : #include <svx/pageitem.hxx>
      36                 :            : #include <tools/date.hxx>
      37                 :            : #include <tools/time.hxx>
      38                 :            : #include <tools/gen.hxx>
      39                 :            : #include <tools/fract.hxx>
      40                 :            : 
      41                 :            : 
      42                 :            : class OutputDevice;
      43                 :            : class ScDocument;
      44                 :            : class ScPatternAttr;
      45                 :            : class ScEditEngineDefaulter;
      46                 :            : 
      47                 :            : class ScEditUtil
      48                 :            : {
      49                 :            :     ScDocument*     pDoc;
      50                 :            :     SCCOL           nCol;
      51                 :            :     SCROW           nRow;
      52                 :            :     SCTAB           nTab;
      53                 :            :     Point           aScrPos;
      54                 :            :     OutputDevice*   pDev;           // MapMode has to be set
      55                 :            :     double          nPPTX;
      56                 :            :     double          nPPTY;
      57                 :            :     Fraction        aZoomX;
      58                 :            :     Fraction        aZoomY;
      59                 :            : 
      60                 :            :     static const char pCalcDelimiters[];
      61                 :            : 
      62                 :            : public:
      63                 :            :     static String ModifyDelimiters( const String& rOld );
      64                 :            : 
      65                 :            :     /// Retrieves string with paragraphs delimited by spaces
      66                 :            :     static String GetSpaceDelimitedString( const EditEngine& rEngine );
      67                 :            : 
      68                 :            :     /// Retrieves string with paragraphs delimited by new lines ('\n').
      69                 :            :     static String GetMultilineString( const EditEngine& rEngine );
      70                 :            : 
      71                 :            : public:
      72                 :          0 :                 ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ,
      73                 :            :                             const Point& rScrPosPixel,
      74                 :            :                             OutputDevice* pDevice, double nScaleX, double nScaleY,
      75                 :            :                             const Fraction& rX, const Fraction& rY ) :
      76                 :            :                     pDoc(pDocument),nCol(nX),nRow(nY),nTab(nZ),
      77                 :            :                     aScrPos(rScrPosPixel),pDev(pDevice),
      78                 :          0 :                     nPPTX(nScaleX),nPPTY(nScaleY),aZoomX(rX),aZoomY(rY) {}
      79                 :            : 
      80                 :            :     Rectangle   GetEditArea( const ScPatternAttr* pPattern, sal_Bool bForceToTop );
      81                 :            : };
      82                 :            : 
      83                 :            : 
      84                 :            : class ScEditAttrTester
      85                 :            : {
      86                 :            :     ScEditEngineDefaulter* pEngine;
      87                 :            :     SfxItemSet* pEditAttrs;
      88                 :            :     sal_Bool        bNeedsObject;
      89                 :            :     sal_Bool        bNeedsCellAttr;
      90                 :            : 
      91                 :            : public:
      92                 :            :                 ScEditAttrTester( ScEditEngineDefaulter* pEng );
      93                 :            :                 ~ScEditAttrTester();
      94                 :            : 
      95                 :        262 :     sal_Bool                NeedsObject() const     { return bNeedsObject; }
      96                 :        262 :     sal_Bool                NeedsCellAttr() const   { return bNeedsCellAttr; }
      97                 :        165 :     const SfxItemSet&   GetAttribs() const      { return *pEditAttrs; }
      98                 :            : };
      99                 :            : 
     100                 :            : 
     101                 :            : // construct pool before constructing EditEngine, destroy pool after EditEngine
     102                 :            : class ScEnginePoolHelper
     103                 :            : {
     104                 :            : protected:
     105                 :            :     SfxItemPool*    pEnginePool;
     106                 :            :     SfxItemSet*     pDefaults;
     107                 :            :     sal_Bool            bDeleteEnginePool;
     108                 :            :     sal_Bool            bDeleteDefaults;
     109                 :            : 
     110                 :            :                     ScEnginePoolHelper( SfxItemPool* pEnginePool,
     111                 :            :                         sal_Bool bDeleteEnginePool = false );
     112                 :            :                     ScEnginePoolHelper( const ScEnginePoolHelper& rOrg );
     113                 :            :     virtual         ~ScEnginePoolHelper();
     114                 :            : };
     115                 :            : 
     116                 :            : 
     117                 :            : class SC_DLLPUBLIC ScEditEngineDefaulter : public ScEnginePoolHelper, public EditEngine
     118                 :            : {
     119                 :            : private:
     120                 :            :     using EditEngine::SetText;
     121                 :            : 
     122                 :            : public:
     123                 :            :                     /// bDeleteEnginePool: Engine becomes the owner of the pool
     124                 :            :                     /// and deletes it on destruction
     125                 :            :                     ScEditEngineDefaulter( SfxItemPool* pEnginePool,
     126                 :            :                         sal_Bool bDeleteEnginePool = false );
     127                 :            :                     /// If rOrg.bDeleteEnginePool: pool gets cloned and will be
     128                 :            :                     /// deleted on destruction. Defaults are not set.
     129                 :            :                     ScEditEngineDefaulter( const ScEditEngineDefaulter& rOrg );
     130                 :            :     virtual         ~ScEditEngineDefaulter();
     131                 :            : 
     132                 :            :                     /// Creates a copy of SfxItemSet if bRememberCopy set
     133                 :            :     void            SetDefaults( const SfxItemSet& rDefaults, sal_Bool bRememberCopy = sal_True );
     134                 :            : 
     135                 :            :                     /// Becomes the owner of the SfxItemSet if bTakeOwnership set
     136                 :            :     void            SetDefaults( SfxItemSet* pDefaults, sal_Bool bTakeOwnership = sal_True );
     137                 :            : 
     138                 :            :                     /// Set the item in the default ItemSet which is created
     139                 :            :                     /// if it doesn't exist yet.
     140                 :            :                     /// The default ItemSet is then applied to each paragraph.
     141                 :            :     void            SetDefaultItem( const SfxPoolItem& rItem );
     142                 :            : 
     143                 :            :                     /// Returns the stored defaults, used to find non-default character attributes
     144                 :            :     const SfxItemSet& GetDefaults();
     145                 :            : 
     146                 :            :                     /// Overwritten method to be able to apply defaults already set
     147                 :            :     void            SetText( const EditTextObject& rTextObject );
     148                 :            :                     /// Current defaults are not applied, new defaults are applied
     149                 :            :     void            SetTextNewDefaults( const EditTextObject& rTextObject,
     150                 :            :                         const SfxItemSet& rDefaults, sal_Bool bRememberCopy = sal_True );
     151                 :            :                     /// Current defaults are not applied, new defaults are applied
     152                 :            :     void            SetTextNewDefaults( const EditTextObject& rTextObject,
     153                 :            :                         SfxItemSet* pDefaults, sal_Bool bTakeOwnership = sal_True );
     154                 :            : 
     155                 :            :                     /// Overwritten method to be able to apply defaults already set
     156                 :            :     void            SetText( const String& rText );
     157                 :            :                     /// Current defaults are not applied, new defaults are applied
     158                 :            :     void            SetTextNewDefaults( const String& rText,
     159                 :            :                         const SfxItemSet& rDefaults, sal_Bool bRememberCopy = sal_True );
     160                 :            :                     /// Current defaults are not applied, new defaults are applied
     161                 :            :     void            SetTextNewDefaults( const String& rText,
     162                 :            :                         SfxItemSet* pDefaults, sal_Bool bTakeOwnership = sal_True );
     163                 :            : 
     164                 :            :                     /// Paragraph attributes that are not defaults are copied to
     165                 :            :                     /// character attributes and all paragraph attributes reset
     166                 :            :     void            RemoveParaAttribs();
     167                 :            : 
     168                 :            :                     /// Re-apply existing defaults if set, same as in SetText,
     169                 :            :                     /// but without EnableUndo/SetUpdateMode.
     170                 :            :     void            RepeatDefaults();
     171                 :            : };
     172                 :            : 
     173                 :            : 
     174                 :            : // 1/100 mm
     175         [ -  + ]:       3832 : class SC_DLLPUBLIC ScTabEditEngine : public ScEditEngineDefaulter
     176                 :            : {
     177                 :            : private:
     178                 :            :     void    Init(const ScPatternAttr& rPattern);
     179                 :            : public:
     180                 :            :     ScTabEditEngine( ScDocument* pDoc );            // Default
     181                 :            :     ScTabEditEngine( const ScPatternAttr& rPattern,
     182                 :            :                     SfxItemPool* pEnginePool,
     183                 :            :                     SfxItemPool* pTextObjectPool = NULL );
     184                 :            : };
     185                 :            : 
     186                 :            : 
     187 [ +  - ][ +  - ]:       6429 : struct ScHeaderFieldData
                 [ +  - ]
     188                 :            : {
     189                 :            :     String      aTitle;             // title or file name (if no title)
     190                 :            :     String      aLongDocName;       // path and file name
     191                 :            :     String      aShortDocName;      // pure file name
     192                 :            :     String      aTabName;
     193                 :            :     Date        aDate;
     194                 :            :     Time        aTime;
     195                 :            :     long        nPageNo;
     196                 :            :     long        nTotalPages;
     197                 :            :     SvxNumType  eNumType;
     198                 :            : 
     199                 :            :     ScHeaderFieldData();
     200                 :            : };
     201                 :            : 
     202                 :            : 
     203                 :            : // for field commands (or just fields?) in a table
     204         [ -  + ]:       2010 : class SC_DLLPUBLIC ScFieldEditEngine : public ScEditEngineDefaulter
     205                 :            : {
     206                 :            : private:
     207                 :            :     ScDocument* mpDoc;
     208                 :            :     bool bExecuteURL;
     209                 :            : 
     210                 :            : public:
     211                 :            :     ScFieldEditEngine(
     212                 :            :         ScDocument* pDoc, SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool = NULL,
     213                 :            :         bool bDeleteEnginePool = false);
     214                 :            : 
     215                 :        205 :     void SetExecuteURL(bool bSet)    { bExecuteURL = bSet; }
     216                 :            : 
     217                 :            :     virtual void    FieldClicked( const SvxFieldItem& rField, sal_uInt16, sal_uInt16 );
     218                 :            :     virtual String  CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rTxtColor, Color*& rFldColor );
     219                 :            : };
     220                 :            : 
     221                 :            : 
     222                 :            : // for headers/footers with fields
     223 [ +  - ][ -  + ]:       4704 : class SC_DLLPUBLIC ScHeaderEditEngine : public ScEditEngineDefaulter
     224                 :            : {
     225                 :            : private:
     226                 :            :     ScHeaderFieldData   aData;
     227                 :            : 
     228                 :            : public:
     229                 :            :     ScHeaderEditEngine( SfxItemPool* pEnginePool, sal_Bool bDeleteEnginePool = false );
     230                 :            :     virtual String CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rTxtColor, Color*& rFldColor );
     231                 :            : 
     232                 :          0 :     void SetNumType(SvxNumType eNew)                { aData.eNumType = eNew; }
     233                 :       1708 :     void SetData(const ScHeaderFieldData& rNew)     { aData = rNew; }
     234                 :            : };
     235                 :            : 
     236                 :            : // for Note text objects.
     237         [ -  + ]:         53 : class ScNoteEditEngine : public ScEditEngineDefaulter
     238                 :            : {
     239                 :            : 
     240                 :            : public:
     241                 :            :     ScNoteEditEngine( SfxItemPool* pEnginePool,
     242                 :            :                 SfxItemPool* pTextObjectPool = NULL,
     243                 :            :                 sal_Bool bDeleteEnginePool = false );
     244                 :            : 
     245                 :            : };
     246                 :            : 
     247                 :            : //  SvxFieldData derivations were moved to Svx (comment can be deleted?)
     248                 :            : 
     249                 :            : 
     250                 :            : #endif
     251                 :            : 
     252                 :            : 
     253                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10