1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_FRMFMT_HXX
20 #define INCLUDED_SW_INC_FRMFMT_HXX
22 #include <com/sun/star/text/PositionLayoutDir.hpp>
23 #include <cppuhelper/weakref.hxx>
24 #include <tools/gen.hxx>
29 class SwAnchoredObject
;
36 namespace sw
{ class DocumentLayoutManager
; }
38 /// Style of a layout element.
39 class SW_DLLPUBLIC SwFrameFormat
: public SwFormat
42 friend class SwPageDesc
; ///< Is allowed to call protected CTor.
43 friend class ::sw::DocumentLayoutManager
; ///< Is allowed to call protected CTor.
45 ::com::sun::star::uno::WeakReference
<
46 ::com::sun::star::uno::XInterface
> m_wXObject
;
48 //UUUU DrawingLayer FillAttributes in a preprocessed form for primitive usage
49 drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes
;
54 const sal_Char
* pFormatNm
,
55 SwFrameFormat
*pDrvdFrm
,
56 sal_uInt16 nFormatWhich
= RES_FRMFMT
,
57 const sal_uInt16
* pWhichRange
= 0);
61 const OUString
&rFormatNm
,
62 SwFrameFormat
*pDrvdFrm
,
63 sal_uInt16 nFormatWhich
= RES_FRMFMT
,
64 const sal_uInt16
* pWhichRange
= 0);
66 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
* pNewValue
) SAL_OVERRIDE
;
69 TYPEINFO_OVERRIDE(); ///< Already in base class Client.
70 virtual ~SwFrameFormat();
72 /// Destroys all Frms in aDepend (Frms are identified via PTR_CAST).
73 virtual void DelFrms();
75 /// Creates the views.
76 virtual void MakeFrms();
78 virtual Graphic
MakeGraphic( ImageMap
* pMap
= NULL
);
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;
87 /** @return the real size of the frame - or an empty rectangle
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;
94 /** Searches SdrObject. SdrObjUserCall is client of the format.
95 The UserCall knows its SdrObject. */
96 SwContact
*FindContactObj();
97 const SwContact
*FindContactObj() const
98 { return const_cast<SwFrameFormat
*>(this)->FindContactObj(); }
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 const SdrObject
*FindSdrObject() const
106 { return const_cast<SwFrameFormat
*>(this)->FindSdrObject(); }
108 SdrObject
*FindRealSdrObject();
109 const SdrObject
*FindRealSdrObject() const
110 { return const_cast<SwFrameFormat
*>(this)->FindRealSdrObject(); }
112 bool IsLowerOf( const SwFrameFormat
& rFormat
) const;
119 VERT_L2R
///< Not supported yet.
122 virtual SwFrameFormat::tLayoutDir
GetLayoutDir() const;
123 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir
);
125 virtual sal_Int16
GetPositionLayoutDir() const;
126 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir
);
128 virtual OUString
GetDescription() const;
130 SAL_DLLPRIVATE ::com::sun::star::uno::WeakReference
<
131 ::com::sun::star::uno::XInterface
> const& GetXObject() const
132 { return m_wXObject
; }
133 SAL_DLLPRIVATE
void SetXObject(::com::sun::star::uno::Reference
<
134 ::com::sun::star::uno::XInterface
> const& xObject
)
135 { m_wXObject
= xObject
; }
137 DECL_FIXEDMEMPOOL_NEWDEL_DLL(SwFrameFormat
)
138 void RegisterToFormat( SwFormat
& rFormat
);
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
;
144 void dumpAsXml(struct _xmlTextWriter
* pWriter
) const;
147 // The FlyFrame-Format
149 class SW_DLLPUBLIC SwFlyFrameFormat
: public SwFrameFormat
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
;
161 SwFlyFrameFormat( const SwFlyFrameFormat
&rCpy
) SAL_DELETED_FUNCTION
;
162 SwFlyFrameFormat
&operator=( const SwFlyFrameFormat
&rCpy
) SAL_DELETED_FUNCTION
;
165 SwFlyFrameFormat( SwAttrPool
& rPool
, const sal_Char
* pFormatNm
,
166 SwFrameFormat
*pDrvdFrm
)
167 : SwFrameFormat( rPool
, pFormatNm
, pDrvdFrm
, RES_FLYFRMFMT
)
169 SwFlyFrameFormat( SwAttrPool
& rPool
, const OUString
&rFormatNm
,
170 SwFrameFormat
*pDrvdFrm
)
171 : SwFrameFormat( rPool
, rFormatNm
, pDrvdFrm
, RES_FLYFRMFMT
)
176 virtual ~SwFlyFrameFormat();
178 /// Creates the views.
179 virtual void MakeFrms() SAL_OVERRIDE
;
181 SwFlyFrm
* GetFrm( const Point
* pDocPos
= 0,
182 const bool bCalcFrm
= false ) const;
184 SwAnchoredObject
* GetAnchoredObj( const Point
* pDocPos
= 0,
185 const bool bCalcFrm
= false ) const;
187 virtual Graphic
MakeGraphic( ImageMap
* pMap
= NULL
) SAL_OVERRIDE
;
189 virtual bool GetInfo( SfxPoolItem
& rInfo
) const SAL_OVERRIDE
;
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 );
196 /** SwFlyFrameFormat::IsBackgroundTransparent
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.
204 @return true, if background color is transparent, but not "no fill"
205 or a existing background graphic is transparent.
207 virtual bool IsBackgroundTransparent() const SAL_OVERRIDE
;
209 /** SwFlyFrameFormat::IsBackgroundBrushInherited
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"
218 @return true, if background brush is "inherited" from parent/grandparent
220 bool IsBackgroundBrushInherited() const;
222 const Point
& GetLastFlyFrmPrtRectPos() const { return m_aLastFlyFrmPrtRectPos
; }
223 void SetLastFlyFrmPrtRectPos( const Point
&rPoint
) { m_aLastFlyFrmPrtRectPos
= rPoint
; }
225 DECL_FIXEDMEMPOOL_NEWDEL(SwFlyFrameFormat
)
228 //The DrawFrame-Format
230 class SW_DLLPUBLIC SwDrawFrameFormat
: public SwFrameFormat
234 mutable const SdrObject
* pSdrObjCached
;
235 mutable OUString sSdrObjCachedComment
;
237 SwDrawFrameFormat( const SwDrawFrameFormat
&rCpy
) SAL_DELETED_FUNCTION
;
238 SwDrawFrameFormat
&operator=( const SwDrawFrameFormat
&rCpy
) SAL_DELETED_FUNCTION
;
240 SwFrameFormat::tLayoutDir meLayoutDir
;
242 sal_Int16 mnPositionLayoutDir
;
247 SwDrawFrameFormat( SwAttrPool
& rPool
, const sal_Char
* pFormatNm
,
248 SwFrameFormat
*pDrvdFrm
)
249 : SwFrameFormat( rPool
, pFormatNm
, pDrvdFrm
, RES_DRAWFRMFMT
),
252 meLayoutDir( SwFrameFormat::HORI_L2R
),
254 mnPositionLayoutDir( com::sun::star::text::PositionLayoutDir::PositionInLayoutDirOfAnchor
),
256 mbPosAttrSet( false )
259 SwDrawFrameFormat( SwAttrPool
& rPool
, const OUString
&rFormatNm
,
260 SwFrameFormat
*pDrvdFrm
)
261 : SwFrameFormat( rPool
, rFormatNm
, pDrvdFrm
, RES_DRAWFRMFMT
),
263 meLayoutDir( SwFrameFormat::HORI_L2R
),
265 mnPositionLayoutDir( com::sun::star::text::PositionLayoutDir::PositionInLayoutDirOfAnchor
),
267 mbPosAttrSet( false )
272 virtual ~SwDrawFrameFormat();
274 /** DrawObjects are removed from the arrays at the layout.
275 The DrawObjects are marked as deleted. */
276 virtual void DelFrms() SAL_OVERRIDE
;
278 /** Register DrawObjects in the arrays at layout.
279 Reset delete marks. */
280 virtual void MakeFrms() SAL_OVERRIDE
;
282 virtual Graphic
MakeGraphic( ImageMap
* pMap
= NULL
) SAL_OVERRIDE
;
284 virtual SwFrameFormat::tLayoutDir
GetLayoutDir() const SAL_OVERRIDE
;
285 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir
) SAL_OVERRIDE
;
287 virtual sal_Int16
GetPositionLayoutDir() const SAL_OVERRIDE
;
288 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir
) SAL_OVERRIDE
;
290 inline bool IsPosAttrSet() const { return mbPosAttrSet
; }
291 inline void PosAttrSet() { mbPosAttrSet
= true; }
293 inline void ResetPosAttr()
295 mbPosAttrSet
= false;
298 virtual OUString
GetDescription() const SAL_OVERRIDE
;
300 DECL_FIXEDMEMPOOL_NEWDEL(SwDrawFrameFormat
);
303 SW_DLLPUBLIC
bool IsFlyFrameFormatInHeader(const SwFrameFormat
& rFormat
);
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */