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

Generated by: LCOV version 1.10