LCOV - code coverage report
Current view: top level - sw/source/core/inc - flyfrm.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 23 25 92.0 %
Date: 2014-11-03 Functions: 23 24 95.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10