LCOV - code coverage report
Current view: top level - sw/inc - frmfmt.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 29 96.6 %
Date: 2012-08-25 Functions: 20 21 95.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 36 36.1 %

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

Generated by: LCOV version 1.10