LCOV - code coverage report
Current view: top level - sw/source/core/inc - flyfrm.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 23 25 92.0 %
Date: 2015-06-13 12:38:46 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 SwFormatFrmSize;
      29             : struct SwCrsrMoveState;
      30             : class SwBorderAttrs;
      31             : class SwVirtFlyDrawObj;
      32             : class SwFrameFormats;
      33             : class SwAttrSetChg;
      34             : namespace tools { class PolyPolygon; }
      35             : class SwFlyDrawContact;
      36             : class SwFormat;
      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 SwContentFrm *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 SwFrameFormats *, sal_uLong, SwFrm *, SwPageFrm *, SwDoc* );
      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 Content-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             :     // 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             :     // 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             :     // 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 true then 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 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 SwNoTextFrm; // 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        7064 :     void Lock()         { bLocked = true; }
     129        7723 :     void Unlock()       { bLocked = false; }
     130             : 
     131             :     void SetMinHeight()  { bMinHeight = true; }
     132             :     void ResetMinHeight(){ bMinHeight = false; }
     133             : 
     134             :     Size CalcRel( const SwFormatFrmSize &rSz ) const;
     135             :     SwTwips CalcAutoWidth() const;
     136             : 
     137             :     SwFlyFrm( SwFlyFrameFormat*, SwFrm*, SwFrm *pAnchor );
     138             : 
     139             :     virtual void DestroyImpl() SAL_OVERRIDE;
     140             :     virtual ~SwFlyFrm();
     141             : 
     142             :     /** method to assure that anchored object is registered at the correct
     143             :         page frame
     144             : 
     145             :         #i28701#
     146             :     */
     147             :     virtual void RegisterAtCorrectPage() SAL_OVERRIDE;
     148             : 
     149             :     virtual bool _SetObjTop( const SwTwips _nTop ) SAL_OVERRIDE;
     150             :     virtual bool _SetObjLeft( const SwTwips _nLeft ) SAL_OVERRIDE;
     151             : 
     152             :     virtual const SwRect GetObjBoundRect() const SAL_OVERRIDE;
     153             :     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
     154             : 
     155             :     virtual const IDocumentDrawModelAccess* getIDocumentDrawModelAccess( ) SAL_OVERRIDE;
     156             : 
     157             :     SwTwips CalcContentHeight(const SwBorderAttrs *pAttrs, const SwTwips nMinHeight, const SwTwips nUL);
     158             : 
     159             : public:
     160             :     // #i26791#
     161             :     TYPEINFO_OVERRIDE();
     162             : 
     163             :     // get client information
     164             :     virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
     165             :     virtual void Paint( SwRect const&,
     166             :                         SwPrintData const*const pPrintData = NULL ) const SAL_OVERRIDE;
     167             :     virtual Size ChgSize( const Size& aNewSize ) SAL_OVERRIDE;
     168             :     virtual bool GetCrsrOfst( SwPosition *, Point&,
     169             :                               SwCrsrMoveState* = 0, bool bTestBackground = false ) const SAL_OVERRIDE;
     170             : 
     171             :     virtual void CheckDirection( bool bVert ) SAL_OVERRIDE;
     172             :     virtual void Cut() SAL_OVERRIDE;
     173             : #ifdef DBG_UTIL
     174             :     virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ) SAL_OVERRIDE;
     175             : #endif
     176             : 
     177             :     SwTwips _Shrink( SwTwips, bool bTst );
     178             :     SwTwips _Grow  ( SwTwips, bool bTst );
     179             :     void    _Invalidate( SwPageFrm *pPage = 0 );
     180             : 
     181             :     bool FrmSizeChg( const SwFormatFrmSize & );
     182             : 
     183       11479 :     SwFlyFrm *GetPrevLink() const { return pPrevLink; }
     184     5792801 :     SwFlyFrm *GetNextLink() const { return pNextLink; }
     185             : 
     186             :     static void ChainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
     187             :     static void UnchainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
     188             : 
     189             :     SwFlyFrm *FindChainNeighbour( SwFrameFormat &rFormat, SwFrm *pAnch = 0 );
     190             : 
     191             :     // #i26791#
     192             :     const SwVirtFlyDrawObj* GetVirtDrawObj() const;
     193             :     SwVirtFlyDrawObj *GetVirtDrawObj();
     194             :     void NotifyDrawObj();
     195             : 
     196             :     void ChgRelPos( const Point &rAbsPos );
     197        2875 :     bool IsInvalid() const { return bInvalid; }
     198        1001 :     void Invalidate() const { const_cast<SwFlyFrm*>(this)->bInvalid = true; }
     199        2769 :     void Validate() const { const_cast<SwFlyFrm*>(this)->bInvalid = false; }
     200             : 
     201        9690 :     bool IsMinHeight()  const { return bMinHeight; }
     202       43715 :     bool IsLocked()     const { return bLocked; }
     203        7233 :     bool IsAutoPos()    const { return bAutoPosition; }
     204     5848866 :     bool IsFlyInCntFrm() const { return bInCnt; }
     205        1145 :     bool IsFlyFreeFrm() const { return bAtCnt || bLayout; }
     206       70060 :     bool IsFlyLayFrm() const { return bLayout; }
     207       43358 :     bool IsFlyAtCntFrm() const { return bAtCnt; }
     208             : 
     209        7987 :     bool IsNotifyBack() const { return bNotifyBack; }
     210          78 :     void SetNotifyBack()      { bNotifyBack = true; }
     211        4903 :     void ResetNotifyBack()    { bNotifyBack = false; }
     212           4 :     bool IsNoShrink()   const { return bNoShrink; }
     213             :     void SetNoShrink( bool bNew ) { bNoShrink = bNew; }
     214        2107 :     bool IsLockDeleteContent()  const { return bLockDeleteContent; }
     215             :     void SetLockDeleteContent( bool bNew ) { bLockDeleteContent = bNew; }
     216             : 
     217        6621 :     bool IsClipped()        const   { return bHeightClipped || bWidthClipped; }
     218          43 :     bool IsHeightClipped()  const   { return bHeightClipped; }
     219             :     bool IsWidthClipped()   const   { return bWidthClipped;  }
     220             : 
     221             :     bool IsLowerOf( const SwLayoutFrm* pUpper ) const;
     222           0 :     inline bool IsUpperOf( const SwFlyFrm& _rLower ) const
     223             :     {
     224           0 :         return _rLower.IsLowerOf( this );
     225             :     }
     226             : 
     227             :     SwFrm *FindLastLower();
     228             : 
     229             :     // #i13147# - add parameter <_bForPaint> to avoid load of
     230             :     // the graphic during paint. Default value: false
     231             :     bool GetContour( tools::PolyPolygon&   rContour,
     232             :                      const bool _bForPaint = false ) const;
     233             : 
     234             :     // Paint on this shell (consider Preview, print flag, etc. recursively)?
     235             :     static bool IsPaint( SdrObject *pObj, const SwViewShell *pSh );
     236             : 
     237             :     /** SwFlyFrm::IsBackgroundTransparent
     238             : 
     239             :         determines if background of fly frame has to be drawn transparently
     240             : 
     241             :         definition found in /core/layout/paintfrm.cxx
     242             : 
     243             :         @return true, if background color is transparent or a existing background
     244             :         graphic is transparent.
     245             :     */
     246             :     bool IsBackgroundTransparent() const;
     247             : 
     248             :     void Chain( SwFrm* _pAnchor );
     249             :     void Unchain();
     250             :     void InsertCnt();
     251             :     void DeleteCnt();
     252             :     void InsertColumns();
     253             : 
     254             :     // #i26791# - pure virtual methods of base class <SwAnchoredObject>
     255             :     virtual void MakeObjPos() SAL_OVERRIDE;
     256             :     virtual void InvalidateObjPos() SAL_OVERRIDE;
     257             : 
     258             :     virtual SwFrameFormat& GetFrameFormat() SAL_OVERRIDE;
     259             :     virtual const SwFrameFormat& GetFrameFormat() const SAL_OVERRIDE;
     260             : 
     261             :     virtual const SwRect GetObjRect() const SAL_OVERRIDE;
     262             : 
     263             :     /** method to determine if a format on the Writer fly frame is possible
     264             : 
     265             :         #i28701#
     266             :         refine 'IsFormatPossible'-conditions of method
     267             :         <SwAnchoredObject::IsFormatPossible()> by:
     268             :         format isn't possible, if Writer fly frame is locked resp. col-locked.
     269             :     */
     270             :     virtual bool IsFormatPossible() const SAL_OVERRIDE;
     271             :     static void GetAnchoredObjects( std::list<SwAnchoredObject*>&, const SwFormat& rFormat );
     272             : 
     273             :     // overwriting "SwFrameFormat *SwLayoutFrm::GetFormat" to provide the correct derived return type.
     274             :     // (This is in order to skip on the otherwise necessary casting of the result to
     275             :     // 'SwFlyFrameFormat *' after calls to this function. The casting is now done in this function.)
     276             :     virtual const SwFlyFrameFormat *GetFormat() const SAL_OVERRIDE;
     277             :     virtual       SwFlyFrameFormat *GetFormat() SAL_OVERRIDE;
     278             : 
     279          20 :     virtual void dumpAsXml( xmlTextWriterPtr writer ) const SAL_OVERRIDE { SwLayoutFrm::dumpAsXml( writer ); };
     280             : 
     281             :     virtual void Calc() const SAL_OVERRIDE;
     282             : 
     283             :     const Point& ContentPos() const { return m_aContentPos; }
     284       10235 :     Point& ContentPos() { return m_aContentPos; }
     285             : 
     286             :     void InvalidateContentPos();
     287             : };
     288             : #endif
     289             : 
     290             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11