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