LCOV - code coverage report
Current view: top level - sw/source/core/inc - flyfrm.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 24 87.5 %
Date: 2012-08-25 Functions: 21 23 91.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 8 87.5 %

           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 SW_FLYFRM_HXX
      30                 :            : #define SW_FLYFRM_HXX
      31                 :            : 
      32                 :            : #include "layfrm.hxx"
      33                 :            : #include <list>
      34                 :            : #include "frmfmt.hxx"
      35                 :            : 
      36                 :            : class SwPageFrm;
      37                 :            : class SwFmtFrmSize;
      38                 :            : struct SwCrsrMoveState;
      39                 :            : class SwBorderAttrs;
      40                 :            : class SwVirtFlyDrawObj;
      41                 :            : class SwFrmFmts;
      42                 :            : class SwAttrSetChg;
      43                 :            : class PolyPolygon;
      44                 :            : class SwFlyDrawContact;
      45                 :            : class SwFmt;
      46                 :            : 
      47                 :            : #include <anchoredobject.hxx>
      48                 :            : 
      49                 :            : /** search an anchor for paragraph bound frames starting from pOldAnch
      50                 :            : 
      51                 :            :     needed for dragging of objects bound to a paragraph for showing an anchor
      52                 :            :     indicator as well as for changing the anchor.
      53                 :            : 
      54                 :            :     implemented in layout/flycnt.cxx
      55                 :            :  */
      56                 :            : const SwCntntFrm *FindAnchor( const SwFrm *pOldAnch, const Point &rNew,
      57                 :            :                               const sal_Bool bBody = sal_False );
      58                 :            : 
      59                 :            : /** calculate rectangle in that the object can be moved or rather be resized */
      60                 :            : sal_Bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, sal_Bool bMove = sal_True );
      61                 :            : 
      62                 :            : /** general base class for all free-flowing frames
      63                 :            : 
      64                 :            :     #i26791# - inherit also from <SwAnchoredFlyFrm>
      65                 :            : */
      66                 :            : class SwFlyFrm : public SwLayoutFrm, public SwAnchoredObject
      67                 :            : {
      68                 :            :     // is allowed to lock, implemented in frmtool.cxx
      69                 :            :     friend void AppendObjs   ( const SwFrmFmts *, sal_uLong, SwFrm *, SwPageFrm * );
      70                 :            :     friend void Notify( SwFlyFrm *, SwPageFrm *pOld, const SwRect &rOld,
      71                 :            :                         const SwRect* pOldPrt );
      72                 :            : 
      73                 :            :     void InitDrawObj( sal_Bool bNotify ); // these to methods are called in the
      74                 :            :     void FinitDrawObj();                  // constructors
      75                 :            : 
      76                 :            :     void _UpdateAttr( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
      77                 :            :                       SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );
      78                 :            : 
      79                 :            :     using SwLayoutFrm::CalcRel;
      80                 :            : 
      81                 :            :     sal_uInt32 _GetOrdNumForNewRef( const SwFlyDrawContact* );
      82                 :            :     SwVirtFlyDrawObj* CreateNewRef( SwFlyDrawContact* );
      83                 :            : 
      84                 :            : protected:
      85                 :            :     // Predecessor/Successor for chaining with text flow
      86                 :            :     SwFlyFrm *pPrevLink, *pNextLink;
      87                 :            : 
      88                 :            : private:
      89                 :            :     // It must be possible to block Cntnt-bound flys so that they will be not
      90                 :            :     // formatted; in this case MakeAll() returns immediately. This is necessary
      91                 :            :     // for page changes during formattting. In addition, it is needed during
      92                 :            :     // the constructor call of the root object since otherwise the anchor will
      93                 :            :     // be formatted before the root is anchored correctly to a shell and
      94                 :            :     // because too much would be formatted as a result.
      95                 :            :     sal_Bool bLocked :1;
      96                 :            :     // sal_True if the background of NotifyDTor needs to be notified at the end
      97                 :            :     // of a MakeAll() call.
      98                 :            :     sal_Bool bNotifyBack :1;
      99                 :            : 
     100                 :            : protected:
     101                 :            :     // Pos, PrtArea or SSize have been invalidated - they will be evaluated
     102                 :            :     // again immediately because they have to be valid _at all time_.
     103                 :            :     // The invalidation is tracked here so that LayAction knows about it and
     104                 :            :     // can handle it properly. Exceptions prove the rule.
     105                 :            :     sal_Bool bInvalid :1;
     106                 :            : 
     107                 :            :     // sal_True if the proposed height of an attribute is a minimal height
     108                 :            :     // (this means that the frame can grow higher if needed)
     109                 :            :     sal_Bool bMinHeight :1;
     110                 :            :     // sal_True if the fly frame could not format position/size based on its
     111                 :            :     // attributes, e.g. because there was not enough space.
     112                 :            :     sal_Bool bHeightClipped :1;
     113                 :            :     sal_Bool bWidthClipped :1;
     114                 :            :     // If sal_True call only the format after adjusting the width (CheckClip);
     115                 :            :     // but the width will not be re-evaluated based on the attributes.
     116                 :            :     sal_Bool bFormatHeightOnly :1;
     117                 :            : 
     118                 :            :     sal_Bool bInCnt :1;        ///< FLY_AS_CHAR, anchored as character
     119                 :            :     sal_Bool bAtCnt :1;        ///< FLY_AT_PARA, anchored at paragraph
     120                 :            :     sal_Bool bLayout :1;       ///< FLY_AT_PAGE, FLY_AT_FLY, at page or at frame
     121                 :            :     sal_Bool bAutoPosition :1; ///< FLY_AT_CHAR, anchored at character
     122                 :            : 
     123                 :            :     sal_Bool bNoShrink :1;     ///< temporary forbid shrinking to avoid loops
     124                 :            :     // If sal_True, the content of the fly frame will not be deleted when it
     125                 :            :     // is moved to an invisible layer.
     126                 :            :     sal_Bool bLockDeleteContent :1;
     127                 :            : 
     128                 :            :     friend class SwNoTxtFrm; // is allowed to call NotifyBackground
     129                 :            : 
     130                 :            :     virtual void Format( const SwBorderAttrs *pAttrs = 0 );
     131                 :            :     void MakePrtArea( const SwBorderAttrs &rAttrs );
     132                 :            : 
     133                 :       2224 :     void Lock()         { bLocked = sal_True; }
     134                 :       2422 :     void Unlock()       { bLocked = sal_False; }
     135                 :            : 
     136                 :            :     void SetMinHeight()  { bMinHeight = sal_True; }
     137                 :            :     void ResetMinHeight(){ bMinHeight = sal_False; }
     138                 :            : 
     139                 :            :     Size CalcRel( const SwFmtFrmSize &rSz ) const;
     140                 :            :     SwTwips CalcAutoWidth() const;
     141                 :            : 
     142                 :            :     SwFlyFrm( SwFlyFrmFmt*, SwFrm*, SwFrm *pAnchor );
     143                 :            : 
     144                 :            :     /** method to assure that anchored object is registered at the correct
     145                 :            :         page frame
     146                 :            : 
     147                 :            :         #i28701#
     148                 :            :     */
     149                 :            :     virtual void RegisterAtCorrectPage();
     150                 :            : 
     151                 :            :     virtual bool _SetObjTop( const SwTwips _nTop );
     152                 :            :     virtual bool _SetObjLeft( const SwTwips _nLeft );
     153                 :            : 
     154                 :            :     virtual const SwRect GetObjBoundRect() const;
     155                 :            :     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
     156                 :            : 
     157                 :            :     virtual const IDocumentDrawModelAccess* getIDocumentDrawModelAccess( );
     158                 :            : 
     159                 :            : public:
     160                 :            :     // #i26791#
     161                 :            :     TYPEINFO();
     162                 :            : 
     163                 :            :     virtual ~SwFlyFrm();
     164                 :            :     // get client information
     165                 :            :     virtual sal_Bool GetInfo( SfxPoolItem& ) const;
     166                 :            :     virtual void Paint( SwRect const&,
     167                 :            :                         SwPrintData const*const pPrintData = NULL ) const;
     168                 :            :     virtual Size ChgSize( const Size& aNewSize );
     169                 :            :     virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
     170                 :            :                               SwCrsrMoveState* = 0 ) const;
     171                 :            : 
     172                 :            :     virtual void  CheckDirection( sal_Bool bVert );
     173                 :            :     virtual void Cut();
     174                 :            : #ifdef DBG_UTIL
     175                 :            :     virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
     176                 :            : #endif
     177                 :            : 
     178                 :            :     SwTwips _Shrink( SwTwips, sal_Bool bTst );
     179                 :            :     SwTwips _Grow  ( SwTwips, sal_Bool bTst );
     180                 :            :     void    _Invalidate( SwPageFrm *pPage = 0 );
     181                 :            : 
     182                 :            :     sal_Bool FrmSizeChg( const SwFmtFrmSize & );
     183                 :            : 
     184                 :       1779 :     SwFlyFrm *GetPrevLink() const { return pPrevLink; }
     185                 :       7746 :     SwFlyFrm *GetNextLink() const { return pNextLink; }
     186                 :            : 
     187                 :            :     static void ChainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
     188                 :            :     static void UnchainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
     189                 :            : 
     190                 :            :     SwFlyFrm *FindChainNeighbour( SwFrmFmt &rFmt, SwFrm *pAnch = 0 );
     191                 :            : 
     192                 :            :     // #i26791#
     193                 :            :     const SwVirtFlyDrawObj* GetVirtDrawObj() const;
     194                 :            :     SwVirtFlyDrawObj *GetVirtDrawObj();
     195                 :            :     void NotifyDrawObj();
     196                 :            : 
     197                 :            :     void ChgRelPos( const Point &rAbsPos );
     198                 :        385 :     sal_Bool IsInvalid() const { return bInvalid; }
     199                 :        157 :     void Invalidate() const { ((SwFlyFrm*)this)->bInvalid = sal_True; }
     200                 :       1235 :     void Validate() const { ((SwFlyFrm*)this)->bInvalid = sal_False; }
     201                 :            : 
     202                 :       1028 :     sal_Bool IsMinHeight()  const { return bMinHeight; }
     203                 :       8804 :     sal_Bool IsLocked()     const { return bLocked; }
     204                 :       1707 :     sal_Bool IsAutoPos()    const { return bAutoPosition; }
     205                 :      11568 :     sal_Bool IsFlyInCntFrm() const { return bInCnt; }
     206 [ +  + ][ +  + ]:        204 :     sal_Bool IsFlyFreeFrm() const { return bAtCnt || bLayout; }
     207                 :       6548 :     sal_Bool IsFlyLayFrm() const { return bLayout; }
     208                 :       2232 :     sal_Bool IsFlyAtCntFrm() const { return bAtCnt; }
     209                 :            : 
     210                 :       3002 :     sal_Bool IsNotifyBack() const { return bNotifyBack; }
     211                 :         56 :     void SetNotifyBack()      { bNotifyBack = sal_True; }
     212                 :       1314 :     void ResetNotifyBack()    { bNotifyBack = sal_False; }
     213                 :         10 :     sal_Bool IsNoShrink()   const { return bNoShrink; }
     214                 :            :     void SetNoShrink( sal_Bool bNew ) { bNoShrink = bNew; }
     215                 :        521 :     sal_Bool IsLockDeleteContent()  const { return bLockDeleteContent; }
     216                 :            :     void SetLockDeleteContent( sal_Bool bNew ) { bLockDeleteContent = bNew; }
     217                 :            : 
     218                 :            : 
     219 [ +  + ][ -  + ]:       2335 :     sal_Bool IsClipped()        const   { return bHeightClipped || bWidthClipped; }
     220                 :          0 :     sal_Bool IsHeightClipped()  const   { return bHeightClipped; }
     221                 :            :     sal_Bool IsWidthClipped()   const   { return bWidthClipped;  }
     222                 :            : 
     223                 :            :     sal_Bool IsLowerOf( const SwLayoutFrm* pUpper ) const;
     224                 :          0 :     inline sal_Bool IsUpperOf( const SwFlyFrm& _rLower ) const
     225                 :            :     {
     226                 :          0 :         return _rLower.IsLowerOf( this );
     227                 :            :     }
     228                 :            : 
     229                 :            :     SwFrm *FindLastLower();
     230                 :            : 
     231                 :            :     // #i13147# - add parameter <_bForPaint> to avoid load of
     232                 :            :     // the graphic during paint. Default value: sal_False
     233                 :            :     sal_Bool GetContour( PolyPolygon&   rContour,
     234                 :            :                      const sal_Bool _bForPaint = sal_False ) const;
     235                 :            : 
     236                 :            : 
     237                 :            :     // Paint on this shell (consider PreView, print flag, etc. recursively)?
     238                 :            :     static sal_Bool IsPaint( SdrObject *pObj, const ViewShell *pSh );
     239                 :            : 
     240                 :            :     /** SwFlyFrm::IsBackgroundTransparent
     241                 :            : 
     242                 :            :         determines if background of fly frame has to be drawn transparently
     243                 :            : 
     244                 :            :         definition found in /core/layout/paintfrm.cxx
     245                 :            : 
     246                 :            :         @return true, if background color is transparent or a existing background
     247                 :            :         graphic is transparent.
     248                 :            :     */
     249                 :            :     sal_Bool IsBackgroundTransparent() const;
     250                 :            : 
     251                 :            :     /** SwFlyFrm::IsShadowTransparent
     252                 :            : 
     253                 :            :         determine if shadow color of fly frame has to be drawn transparently
     254                 :            : 
     255                 :            :         definition found in /core/layout/paintfrm.cxx
     256                 :            : 
     257                 :            :         @return true, if shadow color is transparent.
     258                 :            :     */
     259                 :            :     sal_Bool IsShadowTransparent() const;
     260                 :            : 
     261                 :            :     void Chain( SwFrm* _pAnchor );
     262                 :            :     void Unchain();
     263                 :            :     void InsertCnt();
     264                 :            :     void DeleteCnt();
     265                 :            :     void InsertColumns();
     266                 :            : 
     267                 :            :     // #i26791# - pure virtual methods of base class <SwAnchoredObject>
     268                 :            :     virtual void MakeObjPos();
     269                 :            :     virtual void InvalidateObjPos();
     270                 :            : 
     271                 :            :     virtual SwFrmFmt& GetFrmFmt();
     272                 :            :     virtual const SwFrmFmt& GetFrmFmt() const;
     273                 :            : 
     274                 :            :     virtual const SwRect GetObjRect() const;
     275                 :            : 
     276                 :            :     /** method to determine if a format on the Writer fly frame is possible
     277                 :            : 
     278                 :            :         #i28701#
     279                 :            :         refine 'IsFormatPossible'-conditions of method
     280                 :            :         <SwAnchoredObject::IsFormatPossible()> by:
     281                 :            :         format isn't possible, if Writer fly frame is locked resp. col-locked.
     282                 :            :     */
     283                 :            :     virtual bool IsFormatPossible() const;
     284                 :            :     static void GetAnchoredObjects( std::list<SwAnchoredObject*>&, const SwFmt& rFmt );
     285                 :            : 
     286                 :            :     // overwriting "SwFrmFmt *SwLayoutFrm::GetFmt" to provide the correct derived return type.
     287                 :            :     // (This is in order to skip on the otherwise necessary casting of the result to
     288                 :            :     // 'SwFlyFrmFmt *' after calls to this function. The casting is now done in this function.)
     289                 :            :     virtual const SwFlyFrmFmt *GetFmt() const;
     290                 :            :     virtual       SwFlyFrmFmt *GetFmt();
     291                 :            : 
     292                 :          9 :     virtual void dumpAsXml( xmlTextWriterPtr writer ) { SwLayoutFrm::dumpAsXml( writer ); };
     293                 :            : };
     294                 :            : #endif
     295                 :            : 
     296                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10