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