LCOV - code coverage report
Current view: top level - libreoffice/editeng/source/editeng - editdoc.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 115 139 82.7 %
Date: 2012-12-27 Functions: 101 121 83.5 %
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 _EDITDOC_HXX
      21             : #define _EDITDOC_HXX
      22             : 
      23             : #include <com/sun/star/i18n/XExtendedInputSequenceChecker.hpp>
      24             : 
      25             : #include "editattr.hxx"
      26             : #include "edtspell.hxx"
      27             : #include <editeng/svxfont.hxx>
      28             : #include <svl/itemset.hxx>
      29             : #include <svl/style.hxx>
      30             : #include <svl/itempool.hxx>
      31             : 
      32             : #include <vector>
      33             : #include <deque>
      34             : 
      35             : #include <boost/ptr_container/ptr_vector.hpp>
      36             : #include <boost/noncopyable.hpp>
      37             : 
      38             : class ImpEditEngine;
      39             : class SvxTabStop;
      40             : 
      41             : DBG_NAMEEX( EE_TextPortion )
      42             : 
      43             : #define CHARPOSGROW     16
      44             : #define DEFTAB          720
      45             : 
      46             : void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, short nScriptType = 0 );
      47             : sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, short nScriptType );
      48             : sal_Bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType );
      49             : 
      50             : EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE );
      51             : 
      52             : class ContentNode;
      53             : class EditDoc;
      54             : 
      55             : struct EPaM
      56             : {
      57             :     sal_uInt16 nPara;
      58             :     sal_uInt16 nIndex;
      59             : 
      60          18 :     EPaM()                              { nPara = 0; nIndex = 0; }
      61        2378 :     EPaM( sal_uInt16 nP, sal_uInt16 nI )        { nPara = nP; nIndex = nI; }
      62        2360 :     EPaM( const EPaM& r)                { nPara = r.nPara; nIndex = r.nIndex; }
      63          18 :     EPaM& operator = ( const EPaM& r )  { nPara = r.nPara; nIndex = r.nIndex; return *this; }
      64             :     inline sal_Bool operator == ( const EPaM& r ) const;
      65             :     inline sal_Bool operator < ( const EPaM& r ) const;
      66             : };
      67             : 
      68           6 : inline sal_Bool EPaM::operator < ( const EPaM& r ) const
      69             : {
      70             :     return ( ( nPara < r.nPara ) ||
      71           6 :              ( ( nPara == r.nPara ) && nIndex < r.nIndex ) ) ? sal_True : sal_False;
      72             : }
      73             : 
      74           6 : inline sal_Bool EPaM::operator == ( const EPaM& r ) const
      75             : {
      76           6 :     return ( ( nPara == r.nPara ) && ( nIndex == r.nIndex ) ) ? sal_True : sal_False;
      77             : }
      78             : 
      79             : struct ScriptTypePosInfo
      80             : {
      81             :     short   nScriptType;
      82             :     sal_uInt16  nStartPos;
      83             :     sal_uInt16  nEndPos;
      84             : 
      85       13737 :     ScriptTypePosInfo( short _Type, sal_uInt16 _Start, sal_uInt16 _End )
      86             :     {
      87       13737 :         nScriptType = _Type;
      88       13737 :         nStartPos = _Start;
      89       13737 :         nEndPos = _End;
      90       13737 :     }
      91             : };
      92             : 
      93             : typedef std::deque< ScriptTypePosInfo > ScriptTypePosInfos;
      94             : 
      95             : struct WritingDirectionInfo
      96             : {
      97             :     sal_uInt8   nType;
      98             :     sal_uInt16  nStartPos;
      99             :     sal_uInt16  nEndPos;
     100             : 
     101       13198 :     WritingDirectionInfo( sal_uInt8 _Type, sal_uInt16 _Start, sal_uInt16 _End )
     102             :     {
     103       13198 :         nType = _Type;
     104       13198 :         nStartPos = _Start;
     105       13198 :         nEndPos = _End;
     106       13198 :     }
     107             : };
     108             : 
     109             : 
     110             : typedef std::deque< WritingDirectionInfo > WritingDirectionInfos;
     111             : 
     112        2161 : class ContentAttribsInfo
     113             : {
     114             : private:
     115             :     typedef boost::ptr_vector<EditCharAttrib> CharAttribsType;
     116             : 
     117             :     SfxItemSet          aPrevParaAttribs;
     118             :     CharAttribsType     aPrevCharAttribs;
     119             : 
     120             : public:
     121             :                         ContentAttribsInfo( const SfxItemSet& rParaAttribs );
     122             : 
     123           0 :     const SfxItemSet&       GetPrevParaAttribs() const  { return aPrevParaAttribs; }
     124           0 :     const CharAttribsType&  GetPrevCharAttribs() const  { return aPrevCharAttribs; }
     125             : 
     126             :     void RemoveAllCharAttribsFromPool(SfxItemPool& rPool) const;
     127             :     void AppendCharAttrib(EditCharAttrib* pNew);
     128             : };
     129             : 
     130             : //  ----------------------------------------------------------------------
     131             : //  class SvxColorList
     132             : //  ----------------------------------------------------------------------
     133             : 
     134             : class SvxColorList
     135             : {
     136             : private:
     137             :     typedef std::vector<SvxColorItem*> DummyColorList;
     138             :     DummyColorList aColorList;
     139             : 
     140             : public:
     141             :             SvxColorList();
     142             :             ~SvxColorList();
     143             : 
     144             :     size_t  GetId( const SvxColorItem& rColor );
     145           0 :     size_t  Count() { return aColorList.size(); };
     146             :     void    Insert( SvxColorItem* pItem, size_t nIndex );
     147             :     SvxColorItem* GetObject( size_t nIndex );
     148             : };
     149             : 
     150             : //  ----------------------------------------------------------------------
     151             : //  class ItemList
     152             : //  ----------------------------------------------------------------------
     153             : 
     154           0 : class ItemList
     155             : {
     156             : private:
     157             :     typedef std::vector<const SfxPoolItem*> DummyItemList;
     158             :     DummyItemList aItemPool;
     159             :     size_t  CurrentItem;
     160             : 
     161             : public:
     162             :     ItemList();
     163             :     const SfxPoolItem*  First();
     164             :     const SfxPoolItem*  Next();
     165           0 :     size_t              Count() { return aItemPool.size(); };
     166             :     void                Insert( const SfxPoolItem* pItem );
     167           0 :     void                Clear() { aItemPool.clear(); };
     168             : };
     169             : 
     170             : // -------------------------------------------------------------------------
     171             : // class ContentAttribs
     172             : // -------------------------------------------------------------------------
     173             : class ContentAttribs
     174             : {
     175             : private:
     176             :     SfxStyleSheet*  pStyle;
     177             :     SfxItemSet      aAttribSet;
     178             : 
     179             : public:
     180             :                     ContentAttribs( SfxItemPool& rItemPool );
     181             :                     ContentAttribs( const ContentAttribs& );
     182             :                     ~ContentAttribs();  // only for larger Tabs
     183             : 
     184             :     SvxTabStop      FindTabStop( long nCurPos, sal_uInt16 nDefTab );
     185      215431 :     SfxItemSet&     GetItems()                          { return aAttribSet; }
     186       55693 :     const SfxItemSet& GetItems() const { return aAttribSet; }
     187           0 :     const SfxStyleSheet*  GetStyleSheet() const { return pStyle; }
     188      112967 :     SfxStyleSheet*  GetStyleSheet() { return pStyle; }
     189             :     void            SetStyleSheet( SfxStyleSheet* pS );
     190             : 
     191             :     const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
     192             :     bool HasItem( sal_uInt16 nWhich ) const;
     193             : };
     194             : 
     195             : // -------------------------------------------------------------------------
     196             : // class CharAttribList
     197             : // -------------------------------------------------------------------------
     198             : class CharAttribList
     199             : {
     200             : public:
     201             :     typedef boost::ptr_vector<EditCharAttrib> AttribsType;
     202             : 
     203             : private:
     204             :     AttribsType     aAttribs;
     205             :     SvxFont         aDefFont;          // faster than ever from the pool!
     206             :     bool            bHasEmptyAttribs;
     207             : 
     208             :                     CharAttribList( const CharAttribList& ) {;}
     209             : 
     210             : public:
     211             :                     CharAttribList();
     212             :                     ~CharAttribList();
     213             : 
     214             :     void            DeleteEmptyAttribs(  SfxItemPool& rItemPool );
     215             :     void            RemoveItemsFromPool( SfxItemPool* pItemPool );
     216             : 
     217             :     const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const;
     218             :     EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
     219             :     const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const;
     220             :     const EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const;
     221             :     EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
     222             :     const EditCharAttrib* FindFeature( sal_uInt16 nPos ) const;
     223             : 
     224             : 
     225             :     void            ResortAttribs();
     226             :     void            OptimizeRanges( SfxItemPool& rItemPool );
     227             : 
     228             :     size_t Count() const;
     229             : 
     230             :     void            InsertAttrib( EditCharAttrib* pAttrib );
     231             : 
     232      158132 :     SvxFont&        GetDefFont()            { return aDefFont; }
     233             : 
     234        1191 :     bool            HasEmptyAttribs() const { return bHasEmptyAttribs; }
     235             :     void SetHasEmptyAttribs(bool b);
     236             :     bool HasBoundingAttrib( sal_uInt16 nBound ) const;
     237             :     bool HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const;
     238             : 
     239             :     AttribsType& GetAttribs();
     240             :     const AttribsType& GetAttribs() const;
     241             : 
     242             :     void Remove(const EditCharAttrib* p);
     243             :     void Remove(size_t nPos);
     244             :     void Release(const EditCharAttrib* p);
     245             : 
     246             : #if OSL_DEBUG_LEVEL > 2
     247             :     // Debug:
     248             :     bool DbgCheckAttribs() const;
     249             : #endif
     250             : };
     251             : 
     252             : // -------------------------------------------------------------------------
     253             : // class ContentNode
     254             : // -------------------------------------------------------------------------
     255             : class ContentNode : boost::noncopyable
     256             : {
     257             : private:
     258             :     XubString maString;
     259             :     ContentAttribs  aContentAttribs;
     260             :     CharAttribList  aCharAttribList;
     261             :     WrongList*      pWrongList;
     262             : 
     263             : public:
     264             :                     ContentNode( SfxItemPool& rItemPool );
     265             :                     ContentNode( const XubString& rStr, const ContentAttribs& rContentAttribs );
     266             :                     ~ContentNode();
     267             : 
     268      492038 :     ContentAttribs& GetContentAttribs()     { return aContentAttribs; }
     269      177084 :     const ContentAttribs& GetContentAttribs() const { return aContentAttribs; }
     270      446054 :     CharAttribList& GetCharAttribs()        { return aCharAttribList; }
     271      163583 :     const CharAttribList& GetCharAttribs() const { return aCharAttribList; }
     272             : 
     273             :     void            ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNewChars, SfxItemPool& rItemPool );
     274             :     void            CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDelChars, SfxItemPool& rItemPool );
     275             :     void            AppendAttribs( ContentNode* pNextNode );
     276             :     void            CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, sal_Bool bKeepEndingAttribs );
     277             : 
     278             :     void            SetStyleSheet( SfxStyleSheet* pS, sal_Bool bRecalcFont = sal_True );
     279             :     void            SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle );
     280       67263 :     SfxStyleSheet*  GetStyleSheet() { return aContentAttribs.GetStyleSheet(); }
     281             :     const SfxStyleSheet* GetStyleSheet() const { return aContentAttribs.GetStyleSheet(); }
     282             : 
     283             :     void            CreateDefFont();
     284             : 
     285       20507 :     WrongList*      GetWrongList()          { return pWrongList; }
     286           0 :     const WrongList* GetWrongList() const { return pWrongList; }
     287             :     void            SetWrongList( WrongList* p );
     288             : 
     289             :     void            CreateWrongList();
     290             :     void            DestroyWrongList();
     291             : 
     292             :     bool IsFeature( sal_uInt16 nPos ) const;
     293             : 
     294             :     sal_uInt16 Len() const;
     295             :     const XubString& GetString() const;
     296             : 
     297             :     void SetChar(sal_uInt16 nPos, sal_Unicode c);
     298             :     void Insert(const XubString& rStr, sal_uInt16 nPos);
     299             :     void Append(const XubString& rStr);
     300             :     void Erase(sal_uInt16 nPos);
     301             :     void Erase(sal_uInt16 nPos, sal_uInt16 nCount);
     302             :     XubString Copy(sal_uInt16 nPos) const;
     303             :     XubString Copy(sal_uInt16 nPos, sal_uInt16 nCount) const;
     304             :     sal_Unicode GetChar(sal_uInt16 nPos) const;
     305             : };
     306             : 
     307             : // -------------------------------------------------------------------------
     308             : // class EditPaM
     309             : // -------------------------------------------------------------------------
     310             : class EditPaM
     311             : {
     312             : private:
     313             :     ContentNode* pNode;
     314             :     sal_uInt16          nIndex;
     315             : 
     316             : public:
     317             :     EditPaM();
     318             :     EditPaM(const EditPaM& r);
     319             :     EditPaM(ContentNode* p, sal_uInt16 n);
     320             : 
     321             :     const ContentNode* GetNode() const;
     322             :     ContentNode* GetNode();
     323             :     void SetNode(ContentNode* p);
     324             : 
     325       87295 :     sal_uInt16          GetIndex() const                { return nIndex; }
     326      236476 :     sal_uInt16&         GetIndex()                      { return nIndex; }
     327       15145 :     void            SetIndex( sal_uInt16 n )            { nIndex = n; }
     328             : 
     329             :     sal_Bool            DbgIsBuggy( EditDoc& rDoc );
     330             : 
     331             :     EditPaM&    operator = ( const EditPaM& rPaM );
     332             :     friend sal_Bool operator == ( const EditPaM& r1,  const EditPaM& r2  );
     333             :     friend sal_Bool operator != ( const EditPaM& r1,  const EditPaM& r2  );
     334             : };
     335             : 
     336             : #define PORTIONKIND_TEXT        0
     337             : #define PORTIONKIND_TAB         1
     338             : #define PORTIONKIND_LINEBREAK   2
     339             : #define PORTIONKIND_FIELD       3
     340             : #define PORTIONKIND_HYPHENATOR  4
     341             : 
     342             : #define DELMODE_SIMPLE          0
     343             : #define DELMODE_RESTOFWORD      1
     344             : #define DELMODE_RESTOFCONTENT   2
     345             : 
     346             : #define CHAR_NORMAL            0x00
     347             : #define CHAR_KANA              0x01
     348             : #define CHAR_PUNCTUATIONLEFT   0x02
     349             : #define CHAR_PUNCTUATIONRIGHT  0x04
     350             : 
     351             : // -------------------------------------------------------------------------
     352             : // struct ExtraPortionInfos
     353             : // -------------------------------------------------------------------------
     354             : struct ExtraPortionInfo
     355             : {
     356             :     long    nOrgWidth;
     357             :     long    nWidthFullCompression;
     358             : 
     359             :     long    nPortionOffsetX;
     360             : 
     361             :     sal_uInt16  nMaxCompression100thPercent;
     362             : 
     363             :     sal_uInt8    nAsianCompressionTypes;
     364             :     sal_Bool    bFirstCharIsRightPunktuation;
     365             :     sal_Bool    bCompressed;
     366             : 
     367             :     sal_Int32*    pOrgDXArray;
     368             :     ::std::vector< sal_Int32 > lineBreaksList;
     369             : 
     370             : 
     371             :             ExtraPortionInfo();
     372             :             ~ExtraPortionInfo();
     373             : 
     374             :     void    SaveOrgDXArray( const sal_Int32* pDXArray, sal_uInt16 nLen );
     375             : };
     376             : 
     377             : 
     378             : // -------------------------------------------------------------------------
     379             : // class TextPortion
     380             : // -------------------------------------------------------------------------
     381             : class TextPortion
     382             : {
     383             : private:
     384             :     ExtraPortionInfo*   pExtraInfos;
     385             :     sal_uInt16              nLen;
     386             :     Size                aOutSz;
     387             :     sal_uInt8               nKind;
     388             :     sal_uInt8                nRightToLeft;
     389             :     sal_Unicode         nExtraValue;
     390             : 
     391             : 
     392             :                 TextPortion()               { DBG_CTOR( EE_TextPortion, 0 );
     393             :                                               pExtraInfos = NULL; nLen = 0; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
     394             : 
     395             : public:
     396       29410 :                 TextPortion( sal_uInt16 nL ) : aOutSz( -1, -1 )
     397             :                                             {   DBG_CTOR( EE_TextPortion, 0 );
     398       29410 :                                                 pExtraInfos = NULL; nLen = nL; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
     399           0 :                 TextPortion( const TextPortion& r ) : aOutSz( r.aOutSz )
     400             :                                             { DBG_CTOR( EE_TextPortion, 0 );
     401           0 :                                                 pExtraInfos = NULL; nLen = r.nLen; nKind = r.nKind; nExtraValue = r.nExtraValue; nRightToLeft = r.nRightToLeft; }
     402             : 
     403       29056 :                 ~TextPortion()              {   DBG_DTOR( EE_TextPortion, 0 ); delete pExtraInfos; }
     404             : 
     405       15508 :     sal_uInt16      GetLen() const              { return nLen; }
     406      124828 :     sal_uInt16&     GetLen()                    { return nLen; }
     407           0 :     void        SetLen( sal_uInt16 nL )         { nLen = nL; }
     408             : 
     409       87604 :     Size&       GetSize()                   { return aOutSz; }
     410        3033 :     const Size& GetSize() const             { return aOutSz; }
     411             : 
     412       28225 :     sal_uInt8&      GetKind()                   { return nKind; }
     413       15866 :     sal_uInt8       GetKind() const             { return nKind; }
     414             : 
     415       10831 :     void        SetRightToLeft( sal_uInt8 b )    { nRightToLeft = b; }
     416         640 :     sal_uInt8        GetRightToLeft() const      { return nRightToLeft; }
     417         376 :     sal_Bool        IsRightToLeft() const       { return (nRightToLeft&1); }
     418             : 
     419           0 :     sal_Unicode GetExtraValue() const       { return nExtraValue; }
     420          18 :     void        SetExtraValue( sal_Unicode n )  { nExtraValue = n; }
     421             : 
     422           0 :     sal_Bool        HasValidSize() const        { return aOutSz.Width() != (-1); }
     423             : 
     424        3559 :     ExtraPortionInfo*   GetExtraInfos() const { return pExtraInfos; }
     425           0 :     void                SetExtraInfos( ExtraPortionInfo* p ) { delete pExtraInfos; pExtraInfos = p; }
     426             : };
     427             : 
     428             : // -------------------------------------------------------------------------
     429             : // class TextPortionList
     430             : // -------------------------------------------------------------------------
     431             : class TextPortionList
     432             : {
     433             :     typedef boost::ptr_vector<TextPortion> PortionsType;
     434             :     PortionsType maPortions;
     435             : 
     436             : public:
     437             :             TextPortionList();
     438             :             ~TextPortionList();
     439             : 
     440             :     void    Reset();
     441             :     size_t FindPortion(
     442             :         sal_uInt16 nCharPos, sal_uInt16& rPortionStart, bool bPreferStartingPortion = false) const;
     443             :     sal_uInt16 GetStartPos(size_t nPortion);
     444             :     void DeleteFromPortion(size_t nDelFrom);
     445             :     size_t Count() const;
     446             :     const TextPortion* operator[](size_t nPos) const;
     447             :     TextPortion* operator[](size_t nPos);
     448             : 
     449             :     void Append(TextPortion* p);
     450             :     void Insert(size_t nPos, TextPortion* p);
     451             :     void Remove(size_t nPos);
     452             :     size_t GetPos(const TextPortion* p) const;
     453             : };
     454             : 
     455             : class ParaPortion;
     456             : 
     457             : // ------------------------------------------------------------------------
     458             : // class EditLine
     459             : // -------------------------------------------------------------------------
     460             : class EditLine
     461             : {
     462             : public:
     463             :     typedef std::vector<sal_Int32> CharPosArrayType;
     464             : 
     465             : private:
     466             :     CharPosArrayType aPositions;
     467             :     long            nTxtWidth;
     468             :     sal_uInt16          nStartPosX;
     469             :     sal_uInt16          nStart;     // could be replaced by nStartPortion
     470             :     sal_uInt16          nEnd;       // could be replaced by nEndPortion
     471             :     sal_uInt16          nStartPortion;
     472             :     sal_uInt16          nEndPortion;
     473             :     sal_uInt16          nHeight;    //  Total height of the line
     474             :     sal_uInt16          nTxtHeight; // Pure Text height
     475             :     sal_uInt16          nCrsrHeight;    // For contour flow high lines => cursor is large.
     476             :     sal_uInt16          nMaxAscent;
     477             :     bool            bHangingPunctuation:1;
     478             :     bool            bInvalid:1;   // for skillful formatting
     479             : 
     480             : public:
     481             :                     EditLine();
     482             :                     EditLine( const EditLine& );
     483             :                     ~EditLine();
     484             : 
     485           0 :     sal_Bool            IsIn( sal_uInt16 nIndex ) const
     486           0 :                         { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); }
     487             : 
     488          16 :     sal_Bool            IsIn( sal_uInt16 nIndex, sal_Bool bInclEnd ) const
     489          16 :                         { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); }
     490             : 
     491       21549 :     void            SetStart( sal_uInt16 n )            { nStart = n; }
     492         777 :     sal_uInt16          GetStart() const                { return nStart; }
     493       88229 :     sal_uInt16&         GetStart()                      { return nStart; }
     494             : 
     495       32123 :     void            SetEnd( sal_uInt16 n )              { nEnd = n; }
     496         138 :     sal_uInt16          GetEnd() const                  { return nEnd; }
     497       17728 :     sal_uInt16&         GetEnd()                        { return nEnd; }
     498             : 
     499        3516 :     void            SetStartPortion( sal_uInt16 n )     { nStartPortion = n; }
     500         673 :     sal_uInt16          GetStartPortion() const         { return nStartPortion; }
     501       23887 :     sal_uInt16&         GetStartPortion()               { return nStartPortion; }
     502             : 
     503       14090 :     void            SetEndPortion( sal_uInt16 n )       { nEndPortion = n; }
     504         782 :     sal_uInt16          GetEndPortion() const           { return nEndPortion; }
     505       37855 :     sal_uInt16&         GetEndPortion()                 { return nEndPortion; }
     506             : 
     507             :     void            SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH = 0, sal_uInt16 nCrsrH = 0 );
     508      110433 :     sal_uInt16          GetHeight() const               { return nHeight; }
     509         235 :     sal_uInt16          GetTxtHeight() const            { return nTxtHeight; }
     510             :     sal_uInt16          GetCrsrHeight() const           { return nCrsrHeight; }
     511             : 
     512       10572 :     void            SetTextWidth( long n )          { nTxtWidth = n; }
     513           1 :     long            GetTextWidth() const            { return nTxtWidth; }
     514             : 
     515       31994 :     void            SetMaxAscent( sal_uInt16 n )        { nMaxAscent = n; }
     516        7078 :     sal_uInt16          GetMaxAscent() const            { return nMaxAscent; }
     517             : 
     518        4271 :     void            SetHangingPunctuation( bool b )     { bHangingPunctuation = b; }
     519       10571 :     bool            IsHangingPunctuation() const        { return bHangingPunctuation; }
     520             : 
     521       10591 :     sal_uInt16          GetLen() const                  { return nEnd - nStart; }
     522             : 
     523         654 :     sal_uInt16          GetStartPosX() const            { return nStartPosX; }
     524             :     void            SetStartPosX( long start );
     525             :     Size            CalcTextSize( ParaPortion& rParaPortion );
     526             : 
     527       24486 :     bool            IsInvalid() const               { return bInvalid; }
     528       27993 :     bool            IsValid() const                 { return !bInvalid; }
     529       10571 :     void            SetInvalid()                    { bInvalid = true; }
     530        7000 :     void            SetValid()                      { bInvalid = false; }
     531             : 
     532           1 :     sal_Bool            IsEmpty() const                 { return (nEnd > nStart) ? sal_False : sal_True; }
     533             : 
     534             :     CharPosArrayType& GetCharPosArray();
     535             :     const CharPosArrayType& GetCharPosArray() const;
     536             : 
     537             :     EditLine*       Clone() const;
     538             : 
     539             :     EditLine&   operator = ( const EditLine& rLine );
     540             :     friend sal_Bool operator == ( const EditLine& r1,  const EditLine& r2  );
     541             :     friend sal_Bool operator != ( const EditLine& r1,  const EditLine& r2  );
     542             : };
     543             : 
     544             : 
     545             : // -------------------------------------------------------------------------
     546             : // class LineList
     547             : // -------------------------------------------------------------------------
     548             : class EditLineList
     549             : {
     550             :     typedef boost::ptr_vector<EditLine> LinesType;
     551             :     LinesType maLines;
     552             : 
     553             : public:
     554             :             EditLineList();
     555             :             ~EditLineList();
     556             : 
     557             :     void Reset();
     558             :     void DeleteFromLine(size_t nDelFrom);
     559             :     size_t FindLine(sal_uInt16 nChar, bool bInclEnd);
     560             :     size_t Count() const;
     561             :     const EditLine* operator[](size_t nPos) const;
     562             :     EditLine* operator[](size_t nPos);
     563             : 
     564             :     void Append(EditLine* p);
     565             :     void Insert(size_t nPos, EditLine* p);
     566             : };
     567             : 
     568             : // -------------------------------------------------------------------------
     569             : // class ParaPortion
     570             : // -------------------------------------------------------------------------
     571             : class ParaPortion
     572             : {
     573             :     friend class ImpEditEngine; // to adjust the height
     574             : private:
     575             :     EditLineList        aLineList;
     576             :     TextPortionList     aTextPortionList;
     577             :     ContentNode*        pNode;
     578             :     long                nHeight;
     579             : 
     580             :     ScriptTypePosInfos      aScriptInfos;
     581             :     WritingDirectionInfos   aWritingDirectionInfos;
     582             : 
     583             :     sal_uInt16              nInvalidPosStart;
     584             :     sal_uInt16              nFirstLineOffset;   // For Writer-LineSpacing-Interpretation
     585             :     sal_uInt16              nBulletX;
     586             :     short                   nInvalidDiff;
     587             : 
     588             :     sal_Bool                bInvalid            : 1;
     589             :     sal_Bool                bSimple             : 1;    // only linear Tap
     590             :     sal_Bool                bVisible            : 1;    // Belongs to the node!
     591             :     sal_Bool                bForceRepaint       : 1;
     592             : 
     593             :                         ParaPortion( const ParaPortion& );
     594             : 
     595             : public:
     596             :                         ParaPortion( ContentNode* pNode );
     597             :                         ~ParaPortion();
     598             : 
     599             :     sal_uInt16 GetLineNumber( sal_uInt16 nIndex ) const;
     600             : 
     601      356992 :     EditLineList&       GetLines()                  { return aLineList; }
     602         590 :     const EditLineList& GetLines() const { return aLineList; }
     603             : 
     604       53752 :     sal_Bool                IsInvalid() const           { return bInvalid; }
     605       24645 :     sal_Bool                IsSimpleInvalid()   const   { return bSimple; }
     606       25091 :     void                SetValid()                  { bInvalid = sal_False; bSimple = sal_True;}
     607             : 
     608       52798 :     sal_Bool                MustRepaint() const         { return bForceRepaint; }
     609       19465 :     void                SetMustRepaint( sal_Bool bRP )  { bForceRepaint = bRP; }
     610             : 
     611       27683 :     sal_uInt16              GetBulletX() const          { return nBulletX; }
     612       25091 :     void                SetBulletX( sal_uInt16 n )      { nBulletX = n; }
     613             : 
     614             :     void                MarkInvalid( sal_uInt16 nStart, short nDiff);
     615             :     void                MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 nEnd );
     616             : 
     617             :     void                SetVisible( sal_Bool bVisible );
     618       77605 :     bool                IsVisible() const { return bVisible; }
     619             : 
     620       27708 :     sal_Bool            IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0]->GetLen() == 0; }
     621             : 
     622      106441 :     long                GetHeight() const           { return ( bVisible ? nHeight : 0 ); }
     623       24795 :     sal_uInt16              GetFirstLineOffset() const  { return ( bVisible ? nFirstLineOffset : 0 ); }
     624           0 :     void                ResetHeight()   { nHeight = 0; nFirstLineOffset = 0; }
     625             : 
     626      389090 :     ContentNode*        GetNode() const             { return pNode; }
     627      202572 :     TextPortionList&    GetTextPortions()           { return aTextPortionList; }
     628       12913 :     const TextPortionList& GetTextPortions() const { return aTextPortionList; }
     629             : 
     630        7058 :     sal_uInt16              GetInvalidPosStart() const  { return nInvalidPosStart; }
     631        7058 :     short               GetInvalidDiff() const      { return nInvalidDiff; }
     632             : 
     633             :     void                CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine );
     634             : #if OSL_DEBUG_LEVEL > 2
     635             :     sal_Bool                DbgCheckTextPortions();
     636             : #endif
     637             : };
     638             : 
     639             : // -------------------------------------------------------------------------
     640             : // class ParaPortionList
     641             : // -------------------------------------------------------------------------
     642             : class ParaPortionList
     643             : {
     644             :     mutable size_t nLastCache;
     645             :     boost::ptr_vector<ParaPortion> maPortions;
     646             : public:
     647             :                     ParaPortionList();
     648             :                     ~ParaPortionList();
     649             : 
     650             :     void            Reset();
     651             :     long GetYOffset(const ParaPortion* pPPortion) const;
     652             :     sal_uInt16 FindParagraph(long nYOffset) const;
     653             : 
     654             :     const ParaPortion* SafeGetObject(size_t nPos) const;
     655             :     ParaPortion* SafeGetObject(size_t nPos);
     656             : 
     657             :     sal_uInt16 GetPos(const ParaPortion* p) const;
     658             :     ParaPortion* operator[](size_t nPos);
     659             :     const ParaPortion* operator[](size_t nPos) const;
     660             : 
     661             :     ParaPortion* Release(size_t nPos);
     662             :     void Remove(size_t nPos);
     663             :     void Insert(size_t nPos, ParaPortion* p);
     664             :     void Append(ParaPortion* p);
     665             :     size_t Count() const;
     666             : 
     667             : #if OSL_DEBUG_LEVEL > 2
     668             :     // temporary:
     669             :     void            DbgCheck( EditDoc& rDoc );
     670             : #endif
     671             : };
     672             : 
     673             : // -------------------------------------------------------------------------
     674             : // class EditSelection
     675             : // -------------------------------------------------------------------------
     676       43750 : class EditSelection
     677             : {
     678             : private:
     679             :     EditPaM         aStartPaM;
     680             :     EditPaM         aEndPaM;
     681             : 
     682             : public:
     683             :                     EditSelection();    // No constructor and destructor
     684             :                                         // are automtically excecuted correctly!
     685             :                     EditSelection( const EditPaM& rStartAndAnd );
     686             :                     EditSelection( const EditPaM& rStart, const EditPaM& rEnd );
     687             : 
     688       80952 :     EditPaM&        Min()               { return aStartPaM; }
     689      118179 :     EditPaM&        Max()               { return aEndPaM; }
     690             : 
     691        4464 :     const EditPaM&  Min() const         { return aStartPaM; }
     692       12405 :     const EditPaM&  Max() const         { return aEndPaM; }
     693             : 
     694       20229 :     sal_Bool            HasRange() const    { return aStartPaM != aEndPaM; }
     695             :     sal_Bool            IsInvalid() const;
     696             :     sal_Bool            DbgIsBuggy( EditDoc& rDoc );
     697             : 
     698             :     sal_Bool            Adjust( const EditDoc& rNodes );
     699             : 
     700             :     EditSelection&  operator = ( const EditPaM& r );
     701           0 :     sal_Bool            operator == ( const EditSelection& r ) const
     702           0 :                     { return ( ( aStartPaM == r.aStartPaM ) && ( aEndPaM == r.aEndPaM ) )
     703           0 :                             ? sal_True : sal_False; }
     704           0 :     sal_Bool            operator != ( const EditSelection& r ) const { return !( r == *this ); }
     705             : };
     706             : 
     707             : // -------------------------------------------------------------------------
     708             : // class DeletedNodeInfo
     709             : // -------------------------------------------------------------------------
     710             : class DeletedNodeInfo
     711             : {
     712             : private:
     713             :     sal_uIntPtr     nInvalidAdressPtr;
     714             :     sal_uInt16  nInvalidParagraph;
     715             : 
     716             : public:
     717         216 :             DeletedNodeInfo( sal_uIntPtr nInvAdr, sal_uInt16 nPos )
     718         216 :                                             {   nInvalidAdressPtr = nInvAdr;
     719         216 :                                                 nInvalidParagraph = nPos; }
     720             : 
     721           0 :     sal_uIntPtr GetInvalidAdress() const { return nInvalidAdressPtr; }
     722           0 :     sal_uInt16  GetPosition() const { return nInvalidParagraph; }
     723             : };
     724             : 
     725             : // -------------------------------------------------------------------------
     726             : // class EditDoc
     727             : // -------------------------------------------------------------------------
     728             : class EditDoc
     729             : {
     730             : private:
     731             :     mutable size_t nLastCache;
     732             :     boost::ptr_vector<ContentNode> maContents;
     733             : 
     734             :     SfxItemPool*    pItemPool;
     735             :     Link            aModifyHdl;
     736             : 
     737             :     SvxFont         aDefFont;           //faster than ever from the pool!!
     738             :     sal_uInt16          nDefTab;
     739             :     bool            bIsVertical:1;
     740             :     bool            bIsFixedCellHeight:1;
     741             : 
     742             :     bool            bOwnerOfPool:1;
     743             :     bool            bModified:1;
     744             : 
     745             : private:
     746             :     void            ImplDestroyContents();
     747             : 
     748             : public:
     749             :                     EditDoc( SfxItemPool* pItemPool );
     750             :                     ~EditDoc();
     751             : 
     752          15 :     bool            IsModified() const      { return bModified; }
     753             :     void            SetModified( bool b );
     754             : 
     755        4318 :     void            SetModifyHdl( const Link& rLink ) { aModifyHdl = rLink; }
     756             :     Link            GetModifyHdl() const { return aModifyHdl; }
     757             : 
     758             :     void            CreateDefFont( sal_Bool bUseStyles );
     759        1621 :     const SvxFont&  GetDefFont() { return aDefFont; }
     760             : 
     761        4014 :     void            SetDefTab( sal_uInt16 nTab )    { nDefTab = nTab ? nTab : DEFTAB; }
     762          18 :     sal_uInt16          GetDefTab() const           { return nDefTab; }
     763             : 
     764           0 :     void            SetVertical( bool bVertical )   { bIsVertical = bVertical; }
     765      254728 :     bool            IsVertical() const              { return bIsVertical; }
     766             : 
     767           5 :     void            SetFixedCellHeight( bool bUseFixedCellHeight )  { bIsFixedCellHeight = bUseFixedCellHeight; }
     768       66067 :     bool            IsFixedCellHeight() const               { return bIsFixedCellHeight; }
     769             : 
     770             :     EditPaM         Clear();
     771             :     EditPaM         RemoveText();
     772             :     EditPaM         RemoveChars( EditPaM aPaM, sal_uInt16 nChars );
     773             :     EditPaM         InsertText( EditPaM aPaM, const XubString& rStr );
     774             :     EditPaM         InsertParaBreak( EditPaM aPaM, sal_Bool bKeepEndingAttribs );
     775             :     EditPaM         InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem );
     776             :     EditPaM         ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight );
     777             : 
     778             :     String          GetText( LineEnd eEnd ) const;
     779             :     sal_uLong           GetTextLen() const;
     780             : 
     781             :     XubString       GetParaAsString( sal_uInt16 nNode ) const;
     782             :     XubString       GetParaAsString(const ContentNode* pNode, sal_uInt16 nStartPos = 0, sal_uInt16 nEndPos = 0xFFFF, bool bResolveFields = true) const;
     783             : 
     784             :     EditPaM GetStartPaM() const;
     785             :     EditPaM GetEndPaM() const;
     786             : 
     787      236984 :     SfxItemPool&        GetItemPool()                   { return *pItemPool; }
     788         756 :     const SfxItemPool&  GetItemPool() const             { return *pItemPool; }
     789             : 
     790             :     void RemoveItemsFromPool(const ContentNode& rNode);
     791             : 
     792             :     void            InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd );
     793             :     void            InsertAttrib( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem );
     794             :     void            InsertAttribInSelection( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem );
     795             :     sal_Bool            RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt16 nWhich = 0 );
     796             :     sal_Bool            RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich = 0 );
     797             :     void            FindAttribs( ContentNode* pNode, sal_uInt16 nStartPos, sal_uInt16 nEndPos, SfxItemSet& rCurSet );
     798             : 
     799             :     size_t GetPos(const ContentNode* pNode) const;
     800             :     const ContentNode* GetObject(size_t nPos) const;
     801             :     ContentNode* GetObject(size_t nPos);
     802             :     size_t Count() const;
     803             :     const ContentNode* operator[](size_t nPos) const;
     804             :     ContentNode* operator[](size_t nPos);
     805             :     void Insert(size_t nPos, ContentNode* p);
     806             :     /// deletes
     807             :     void Remove(size_t nPos);
     808             :     /// does not delete
     809             :     void Release(size_t nPos);
     810             : 
     811             :     static rtl::OUString GetSepStr( LineEnd eEnd );
     812             : };
     813             : 
     814      366787 : inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, size_t nAttr)
     815             : {
     816      366787 :     return (nAttr < rAttribs.size()) ? &rAttribs[nAttr] : NULL;
     817             : }
     818             : 
     819             : bool CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart);
     820             : 
     821             : // -------------------------------------------------------------------------
     822             : // class EditEngineItemPool
     823             : // -------------------------------------------------------------------------
     824             : class EditEngineItemPool : public SfxItemPool
     825             : {
     826             : public:
     827             :                         EditEngineItemPool( sal_Bool bPersistenRefCounts );
     828             : protected:
     829             :                         virtual ~EditEngineItemPool();
     830             : public:
     831             : 
     832             :     virtual SvStream&   Store( SvStream& rStream ) const;
     833             : };
     834             : 
     835             : #endif // _EDITDOC_HXX
     836             : 
     837             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10