update credits
[LibreOffice.git] / sw / inc / frmfmt.hxx
blobbf016ee467654e2a259bd3eb5de404a8425f471b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _FRMFMT_HXX
20 #define _FRMFMT_HXX
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"
28 class SwFlyFrm;
29 class SwAnchoredObject;
30 class Graphic;
31 class ImageMap;
32 class IMapObject;
33 class SwRect;
34 class SwContact;
35 class SdrObject;
37 /// Style of a layout element.
38 class SW_DLLPUBLIC SwFrmFmt: public SwFmt
40 friend class SwDoc;
41 friend class SwPageDesc; ///< Is allowed to call protected CTor.
43 ::com::sun::star::uno::WeakReference<
44 ::com::sun::star::uno::XInterface> m_wXObject;
46 protected:
47 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 pDrvdFrm, nFmtWhich )
54 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 pDrvdFrm, nFmtWhich )
61 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue );
63 public:
64 TYPEINFO(); ///< Already in base class Client.
66 /// Destroys all Frms in aDepend (Frms are identified via PTR_CAST).
67 virtual void DelFrms();
69 /// Creates the views.
70 virtual void MakeFrms();
72 virtual Graphic MakeGraphic( ImageMap* pMap = NULL );
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;
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;
89 /** Searches SdrObject. SdrObjUserCall is client of the format.
90 The UserCall knows its SdrObject. */
91 SwContact *FindContactObj();
92 const SwContact *FindContactObj() const
93 { return ((SwFrmFmt*)this)->FindContactObj(); }
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 const SdrObject *FindSdrObject() const
101 { return ((SwFrmFmt*)this)->FindSdrObject(); }
103 SdrObject *FindRealSdrObject();
104 const SdrObject *FindRealSdrObject() const
105 { return ((SwFrmFmt*)this)->FindRealSdrObject(); }
107 sal_Bool IsLowerOf( const SwFrmFmt& rFmt ) const;
109 enum tLayoutDir
111 HORI_L2R,
112 HORI_R2L,
113 VERT_R2L,
114 VERT_L2R ///< Not supported yet.
117 virtual SwFrmFmt::tLayoutDir GetLayoutDir() const;
118 virtual void SetLayoutDir( const SwFrmFmt::tLayoutDir _eLayoutDir );
120 virtual sal_Int16 GetPositionLayoutDir() const;
121 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
123 virtual String GetDescription() const;
125 SW_DLLPRIVATE ::com::sun::star::uno::WeakReference<
126 ::com::sun::star::uno::XInterface> const& GetXObject() const
127 { return m_wXObject; }
128 SW_DLLPRIVATE void SetXObject(::com::sun::star::uno::Reference<
129 ::com::sun::star::uno::XInterface> const& xObject)
130 { m_wXObject = xObject; }
132 DECL_FIXEDMEMPOOL_NEWDEL_DLL(SwFrmFmt)
133 void RegisterToFormat( SwFmt& rFmt );
136 // The FlyFrame-Format
138 class SW_DLLPUBLIC SwFlyFrmFmt: public SwFrmFmt
140 friend class SwDoc;
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;
148 SwFlyFrmFmt( const SwFlyFrmFmt &rCpy );
149 SwFlyFrmFmt &operator=( const SwFlyFrmFmt &rCpy );
151 protected:
152 SwFlyFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
153 SwFrmFmt *pDrvdFrm )
154 : SwFrmFmt( rPool, pFmtNm, pDrvdFrm, RES_FLYFRMFMT )
156 SwFlyFrmFmt( SwAttrPool& rPool, const String &rFmtNm,
157 SwFrmFmt *pDrvdFrm )
158 : SwFrmFmt( rPool, rFmtNm, pDrvdFrm, RES_FLYFRMFMT )
161 public:
162 TYPEINFO();
163 ~SwFlyFrmFmt();
165 /// Creates the views.
166 virtual void MakeFrms();
168 SwFlyFrm* GetFrm( const Point* pDocPos = 0,
169 const sal_Bool bCalcFrm = sal_False ) const;
171 SwAnchoredObject* GetAnchoredObj( const Point* pDocPos = 0,
172 const sal_Bool bCalcFrm = sal_False ) const;
174 virtual Graphic MakeGraphic( ImageMap* pMap = NULL );
176 virtual bool GetInfo( SfxPoolItem& rInfo ) const;
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 );
185 /** SwFlyFrmFmt::IsBackgroundTransparent
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.
191 @author OD
193 @return true, if background color is transparent, but not "no fill"
194 or a existing background graphic is transparent.
196 virtual sal_Bool IsBackgroundTransparent() const;
198 /** SwFlyFrmFmt::IsBackgroundBrushInherited
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"
205 @author OD
207 @return true, if background brush is "inherited" from parent/grandparent
209 sal_Bool IsBackgroundBrushInherited() const;
211 const Point & GetLastFlyFrmPrtRectPos() const { return m_aLastFlyFrmPrtRectPos; }
212 void SetLastFlyFrmPrtRectPos( const Point &rPoint ) { m_aLastFlyFrmPrtRectPos = rPoint; }
214 DECL_FIXEDMEMPOOL_NEWDEL(SwFlyFrmFmt)
217 //The DrawFrame-Format
219 class SW_DLLPUBLIC SwDrawFrmFmt: public SwFrmFmt
221 friend class SwDoc;
223 mutable const SdrObject * pSdrObjCached;
224 mutable String sSdrObjCachedComment;
226 /// Both not existent.
227 SwDrawFrmFmt( const SwDrawFrmFmt &rCpy );
228 SwDrawFrmFmt &operator=( const SwDrawFrmFmt &rCpy );
230 SwFrmFmt::tLayoutDir meLayoutDir;
232 sal_Int16 mnPositionLayoutDir;
234 bool mbPosAttrSet;
236 protected:
237 SwDrawFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
238 SwFrmFmt *pDrvdFrm )
239 : SwFrmFmt( rPool, pFmtNm, pDrvdFrm, RES_DRAWFRMFMT ),
240 pSdrObjCached(NULL),
242 meLayoutDir( SwFrmFmt::HORI_L2R ),
244 mnPositionLayoutDir( com::sun::star::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
246 mbPosAttrSet( false )
249 SwDrawFrmFmt( SwAttrPool& rPool, const String &rFmtNm,
250 SwFrmFmt *pDrvdFrm )
251 : SwFrmFmt( rPool, rFmtNm, pDrvdFrm, RES_DRAWFRMFMT ),
252 pSdrObjCached(NULL),
253 meLayoutDir( SwFrmFmt::HORI_L2R ),
255 mnPositionLayoutDir( com::sun::star::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
257 mbPosAttrSet( false )
260 public:
261 TYPEINFO();
262 ~SwDrawFrmFmt();
264 /** DrawObjects are removed from the arrays at the layout.
265 The DrawObjects are marked as deleted. */
266 virtual void DelFrms();
268 /** Register DrawObjects in the arrays at layout.
269 Reset delete marks. */
270 virtual void MakeFrms();
272 virtual Graphic MakeGraphic( ImageMap* pMap = NULL );
274 virtual SwFrmFmt::tLayoutDir GetLayoutDir() const;
275 virtual void SetLayoutDir( const SwFrmFmt::tLayoutDir _eLayoutDir );
277 virtual sal_Int16 GetPositionLayoutDir() const;
278 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
280 inline bool IsPosAttrSet() const { return mbPosAttrSet; }
281 inline void PosAttrSet() { mbPosAttrSet = true; }
283 inline void ResetPosAttr()
285 mbPosAttrSet = false;
288 virtual String GetDescription() const;
290 DECL_FIXEDMEMPOOL_NEWDEL(SwDrawFrmFmt);
294 #endif
296 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */