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

Generated by: LCOV version 1.11