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

Generated by: LCOV version 1.10