LCOV - code coverage report
Current view: top level - sw/inc - frmfmt.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 22 23 95.7 %
Date: 2014-11-03 Functions: 18 19 94.7 %
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             : #ifndef INCLUDED_SW_INC_FRMFMT_HXX
      20             : #define INCLUDED_SW_INC_FRMFMT_HXX
      21             : 
      22             : #include <com/sun/star/text/PositionLayoutDir.hpp>
      23             : #include <cppuhelper/weakref.hxx>
      24             : #include <tools/gen.hxx>
      25             : #include <format.hxx>
      26             : #include "swdllapi.h"
      27             : 
      28             : class SwFlyFrm;
      29             : class SwAnchoredObject;
      30             : class Graphic;
      31             : class ImageMap;
      32             : class IMapObject;
      33             : class SwRect;
      34             : class SwContact;
      35             : class SdrObject;
      36             : namespace sw { class DocumentLayoutManager; }
      37             : 
      38             : /// Style of a layout element.
      39      242246 : class SW_DLLPUBLIC SwFrmFmt: public SwFmt
      40             : {
      41             :     friend class SwDoc;
      42             :     friend class SwPageDesc;    ///< Is allowed to call protected CTor.
      43             :     friend class ::sw::DocumentLayoutManager; ///< Is allowed to call protected CTor.
      44             : 
      45             :     ::com::sun::star::uno::WeakReference<
      46             :         ::com::sun::star::uno::XInterface> m_wXObject;
      47             : 
      48             :     //UUUU DrawingLayer FillAttributes in a preprocessed form for primitive usage
      49             :     drawinglayer::attribute::SdrAllFillAttributesHelperPtr  maFillAttributes;
      50             : 
      51             : protected:
      52             :     SwFrmFmt(
      53             :         SwAttrPool& rPool,
      54             :         const sal_Char* pFmtNm,
      55             :         SwFrmFmt *pDrvdFrm,
      56             :         sal_uInt16 nFmtWhich = RES_FRMFMT,
      57             :         const sal_uInt16* pWhichRange = 0);
      58             : 
      59             :     SwFrmFmt(
      60             :         SwAttrPool& rPool,
      61             :         const OUString &rFmtNm,
      62             :         SwFrmFmt *pDrvdFrm,
      63             :         sal_uInt16 nFmtWhich = RES_FRMFMT,
      64             :         const sal_uInt16* pWhichRange = 0);
      65             : 
      66             :     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) SAL_OVERRIDE;
      67             : 
      68             : public:
      69             :     TYPEINFO_OVERRIDE();     ///< Already in base class Client.
      70             : 
      71             :     /// Destroys all Frms in aDepend (Frms are identified via PTR_CAST).
      72             :     virtual void DelFrms();
      73             : 
      74             :     /// Creates the views.
      75             :     virtual void MakeFrms();
      76             : 
      77             :     virtual Graphic MakeGraphic( ImageMap* pMap = NULL );
      78             : 
      79             :     /**  @return the IMapObject defined at format (Fly)
      80             :         in the ImageMap at position Point.
      81             :         rPoint - test on DocPosition.
      82             :         pFly - optional FlyFrame, in case it is already known. */
      83             :     IMapObject* GetIMapObject( const Point& rPoint,
      84             :                                 const SwFlyFrm *pFly = 0 ) const;
      85             : 
      86             :     /** @return the real size of the frame - or an empty rectangle
      87             :        if no layout exists.
      88             :        If pPoint is given, look for the frame closest to it. */
      89             :     SwRect FindLayoutRect( const bool bPrtArea = false,
      90             :                            const Point* pPoint = 0,
      91             :                            const bool bCalcFrm = false ) const;
      92             : 
      93             :     /** Searches SdrObject. SdrObjUserCall is client of the format.
      94             :        The UserCall knows its SdrObject. */
      95             :           SwContact *FindContactObj();
      96         944 :     const SwContact *FindContactObj() const
      97         944 :         { return ((SwFrmFmt*)this)->FindContactObj(); }
      98             : 
      99             :     /** @return the SdrObject, that is connected to the ContactObject.
     100             :        Only DrawFrmFmts are connected to the "real SdrObject". FlyFrmFmts
     101             :        are connected to a Master and all FlyFrms has the "real SdrObject".
     102             :        "Real SdrObject" has position and a Z-order. */
     103             :           SdrObject *FindSdrObject();
     104        2210 :     const SdrObject *FindSdrObject() const
     105        2210 :         { return ((SwFrmFmt*)this)->FindSdrObject(); }
     106             : 
     107             :           SdrObject *FindRealSdrObject();
     108        6638 :     const SdrObject *FindRealSdrObject() const
     109        6638 :         { return ((SwFrmFmt*)this)->FindRealSdrObject(); }
     110             : 
     111             :     bool IsLowerOf( const SwFrmFmt& rFmt ) const;
     112             : 
     113             :     enum tLayoutDir
     114             :     {
     115             :         HORI_L2R,
     116             :         HORI_R2L,
     117             :         VERT_R2L,
     118             :         VERT_L2R    ///< Not supported yet.
     119             :     };
     120             : 
     121             :     virtual SwFrmFmt::tLayoutDir GetLayoutDir() const;
     122             :     virtual void SetLayoutDir( const SwFrmFmt::tLayoutDir _eLayoutDir );
     123             : 
     124             :     virtual sal_Int16 GetPositionLayoutDir() const;
     125             :     virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
     126             : 
     127             :     virtual OUString GetDescription() const;
     128             : 
     129             :     SAL_DLLPRIVATE ::com::sun::star::uno::WeakReference<
     130       29656 :         ::com::sun::star::uno::XInterface> const& GetXObject() const
     131       29656 :             { return m_wXObject; }
     132       27994 :     SAL_DLLPRIVATE void SetXObject(::com::sun::star::uno::Reference<
     133             :                     ::com::sun::star::uno::XInterface> const& xObject)
     134       27994 :             { m_wXObject = xObject; }
     135             : 
     136             :     DECL_FIXEDMEMPOOL_NEWDEL_DLL(SwFrmFmt)
     137             :     void RegisterToFormat( SwFmt& rFmt );
     138             : 
     139             :     //UUUU Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
     140             :     virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const SAL_OVERRIDE;
     141             :     virtual bool supportsFullDrawingLayerFillAttributeSet() const SAL_OVERRIDE;
     142             : };
     143             : 
     144             : // The FlyFrame-Format
     145             : 
     146             : class SW_DLLPUBLIC SwFlyFrmFmt: public SwFrmFmt
     147             : {
     148             :     friend class SwDoc;
     149             :     OUString msTitle;
     150             :     OUString msDesc;
     151             : 
     152             :     /** Both not existent.
     153             :        it stores the previous position of Prt rectangle from RequestObjectResize
     154             :        so it can be used to move frames of non-resizable objects to align them correctly
     155             :        when they get borders (this is done in SwWrtShell::CalcAndGetScale) */
     156             :     Point   m_aLastFlyFrmPrtRectPos;
     157             : 
     158             :     SwFlyFrmFmt( const SwFlyFrmFmt &rCpy );
     159             :     SwFlyFrmFmt &operator=( const SwFlyFrmFmt &rCpy );
     160             : 
     161             : protected:
     162             :     SwFlyFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
     163             :                     SwFrmFmt *pDrvdFrm )
     164             :         : SwFrmFmt( rPool, pFmtNm, pDrvdFrm, RES_FLYFRMFMT )
     165             :     {}
     166        3916 :     SwFlyFrmFmt( SwAttrPool& rPool, const OUString &rFmtNm,
     167             :                     SwFrmFmt *pDrvdFrm )
     168        3916 :         : SwFrmFmt( rPool, rFmtNm, pDrvdFrm, RES_FLYFRMFMT )
     169        3916 :     {}
     170             : 
     171             : public:
     172             :     TYPEINFO_OVERRIDE();
     173             :     virtual ~SwFlyFrmFmt();
     174             : 
     175             :     /// Creates the views.
     176             :     virtual void MakeFrms() SAL_OVERRIDE;
     177             : 
     178             :     SwFlyFrm* GetFrm( const Point* pDocPos = 0,
     179             :                       const bool bCalcFrm = false ) const;
     180             : 
     181             :     SwAnchoredObject* GetAnchoredObj( const Point* pDocPos = 0,
     182             :                                       const bool bCalcFrm = false ) const;
     183             : 
     184             :     virtual Graphic MakeGraphic( ImageMap* pMap = NULL ) SAL_OVERRIDE;
     185             : 
     186             :     virtual bool GetInfo( SfxPoolItem& rInfo ) const SAL_OVERRIDE;
     187             : 
     188             :     OUString GetObjTitle() const;
     189             :     void SetObjTitle( const OUString& rTitle, bool bBroadcast = false );
     190             :     OUString GetObjDescription() const;
     191             :     void SetObjDescription( const OUString& rDescription, bool bBroadcast = false );
     192             : 
     193             :     /** SwFlyFrmFmt::IsBackgroundTransparent
     194             : 
     195             :         Overloading virtual method and its default implementation,
     196             :         because format of fly frame provides transparent backgrounds.
     197             :         Method determines, if background of fly frame is transparent.
     198             : 
     199             :         @author OD
     200             : 
     201             :         @return true, if background color is transparent, but not "no fill"
     202             :         or a existing background graphic is transparent.
     203             :     */
     204             :     virtual bool IsBackgroundTransparent() const SAL_OVERRIDE;
     205             : 
     206             :     /** SwFlyFrmFmt::IsBackgroundBrushInherited
     207             : 
     208             :         Method to determine, if the brush for drawing the
     209             :         background is "inherited" from its parent/grandparent.
     210             :         This is the case, if no background graphic is set and the background
     211             :         color is "no fill"/"auto fill"
     212             : 
     213             :         @author OD
     214             : 
     215             :         @return true, if background brush is "inherited" from parent/grandparent
     216             :     */
     217             :     bool IsBackgroundBrushInherited() const;
     218             : 
     219           0 :     const Point & GetLastFlyFrmPrtRectPos() const       { return m_aLastFlyFrmPrtRectPos; }
     220          62 :     void SetLastFlyFrmPrtRectPos( const Point &rPoint ) { m_aLastFlyFrmPrtRectPos = rPoint; }
     221             : 
     222        7832 :     DECL_FIXEDMEMPOOL_NEWDEL(SwFlyFrmFmt)
     223             : };
     224             : 
     225             : //The DrawFrame-Format
     226             : 
     227             : class SW_DLLPUBLIC SwDrawFrmFmt: public SwFrmFmt
     228             : {
     229             :     friend class SwDoc;
     230             : 
     231             :     mutable const SdrObject * pSdrObjCached;
     232             :     mutable OUString sSdrObjCachedComment;
     233             : 
     234             :     /// Both not existent.
     235             :     SwDrawFrmFmt( const SwDrawFrmFmt &rCpy );
     236             :     SwDrawFrmFmt &operator=( const SwDrawFrmFmt &rCpy );
     237             : 
     238             :     SwFrmFmt::tLayoutDir meLayoutDir;
     239             : 
     240             :     sal_Int16 mnPositionLayoutDir;
     241             : 
     242             :     bool mbPosAttrSet;
     243             : 
     244             : protected:
     245             :     SwDrawFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
     246             :                     SwFrmFmt *pDrvdFrm )
     247             :         : SwFrmFmt( rPool, pFmtNm, pDrvdFrm, RES_DRAWFRMFMT ),
     248             :           pSdrObjCached(NULL),
     249             : 
     250             :           meLayoutDir( SwFrmFmt::HORI_L2R ),
     251             : 
     252             :           mnPositionLayoutDir( com::sun::star::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
     253             : 
     254             :           mbPosAttrSet( false )
     255             : 
     256             :     {}
     257        4470 :     SwDrawFrmFmt( SwAttrPool& rPool, const OUString &rFmtNm,
     258             :                     SwFrmFmt *pDrvdFrm )
     259             :         : SwFrmFmt( rPool, rFmtNm, pDrvdFrm, RES_DRAWFRMFMT ),
     260             :           pSdrObjCached(NULL),
     261             :           meLayoutDir( SwFrmFmt::HORI_L2R ),
     262             : 
     263             :           mnPositionLayoutDir( com::sun::star::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
     264             : 
     265        4470 :           mbPosAttrSet( false )
     266        4470 :     {}
     267             : 
     268             : public:
     269             :     TYPEINFO_OVERRIDE();
     270             :     virtual ~SwDrawFrmFmt();
     271             : 
     272             :     /** DrawObjects are removed from the arrays at the layout.
     273             :      The DrawObjects are marked as deleted. */
     274             :     virtual void DelFrms() SAL_OVERRIDE;
     275             : 
     276             :     /** Register DrawObjects in the arrays at layout.
     277             :      Reset delete marks. */
     278             :     virtual void MakeFrms() SAL_OVERRIDE;
     279             : 
     280             :     virtual Graphic MakeGraphic( ImageMap* pMap = NULL ) SAL_OVERRIDE;
     281             : 
     282             :     virtual SwFrmFmt::tLayoutDir GetLayoutDir() const SAL_OVERRIDE;
     283             :     virtual void SetLayoutDir( const SwFrmFmt::tLayoutDir _eLayoutDir ) SAL_OVERRIDE;
     284             : 
     285             :     virtual sal_Int16 GetPositionLayoutDir() const SAL_OVERRIDE;
     286             :     virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir ) SAL_OVERRIDE;
     287             : 
     288        3784 :     inline bool IsPosAttrSet() const { return mbPosAttrSet; }
     289        3068 :     inline void PosAttrSet() { mbPosAttrSet = true; }
     290             : 
     291             :     inline void ResetPosAttr()
     292             :     {
     293             :         mbPosAttrSet = false;
     294             :     }
     295             : 
     296             :     virtual OUString GetDescription() const SAL_OVERRIDE;
     297             : 
     298        8938 :     DECL_FIXEDMEMPOOL_NEWDEL(SwDrawFrmFmt);
     299             : };
     300             : 
     301             : SW_DLLPUBLIC bool IsFlyFrmFmtInHeader(const SwFrmFmt& rFmt);
     302             : 
     303             : #endif
     304             : 
     305             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10