xref: /aoo42x/main/svx/inc/svx/svdograf.hxx (revision 172c67b2)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVDOGRAF_HXX
25 #define _SVDOGRAF_HXX
26 
27 #include <com/sun/star/io/XInputStream.hpp>
28 #include <vcl/graph.hxx>
29 #include <svx/svdorect.hxx>
30 #include <svtools/grfmgr.hxx>
31 #include "svx/svxdllapi.h"
32 
33 //////////////////////////////////////////////////////////////////////////////
34 // predeclarations
35 
36 namespace sdr
37 {
38 	namespace properties
39 	{
40 		class GraphicProperties;
41 	} // end of namespace properties
42 	namespace contact
43 	{
44 		class ViewObjectContactOfGraphic;
45 	} // end of namespace contact
46 } // end of namespace sdr
47 
48 // -----------
49 // - Defines -
50 // -----------
51 
52 #define SDRGRAFOBJ_TRANSFORMATTR_NONE		0x00000000UL
53 #define SDRGRAFOBJ_TRANSFORMATTR_COLOR		0x00000001UL
54 #define SDRGRAFOBJ_TRANSFORMATTR_MIRROR		0x00000002UL
55 #define SDRGRAFOBJ_TRANSFORMATTR_ROTATE		0x00000004UL
56 #define SDRGRAFOBJ_TRANSFORMATTR_ALL		0xffffffffUL
57 
58 // ---------------------
59 // - SdrGrafObjGeoData -
60 // ---------------------
61 
62 // #109872#
63 class SdrGrafObjGeoData : public SdrTextObjGeoData
64 {
65 public:
66 	sal_Bool					bMirrored;
67 
68 	SdrGrafObjGeoData()
69 	:	bMirrored(sal_False)
70 	{
71 	}
72 };
73 
74 // --------------
75 // - SdrGrafObj -
76 // --------------
77 
78 class GraphicObject;
79 class SdrGraphicLink;
80 
81 class SVX_DLLPUBLIC SdrGrafObj : public SdrRectObj
82 {
83 private:
84 	// to allow sdr::properties::GraphicProperties access to SetXPolyDirty()
85 	friend class sdr::properties::GraphicProperties;
86 
87 	// to allow sdr::contact::ViewObjectContactOfGraphic access to ImpUpdateGraphicLink()
88 	friend class sdr::contact::ViewObjectContactOfGraphic;
89 	friend class SdrGraphicLink;
90 
91 protected:
92 	virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
93 	virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
94 
95 	void					ImpSetAttrToGrafInfo(); // Werte vom Pool kopieren
96 	void					ImpSetGrafInfoToAttr(); // Werte in den Pool kopieren
97 	GraphicAttr				aGrafInfo;
98 
99 	Rectangle				aCropRect;			// Wenn aCropRect nicht Empty ist, dann enthaelt es den sichtbaren
100 												// Ausschnitt der Grafik in logischen Eingeiten der Grafik! Also Bitmap->=Pixel
101 	String					aFileName;			// Wenn es sich um einen Link handelt, steht hier der Dateiname drin.
102 	String					aFilterName;
103 	GraphicObject*			pGraphic;			// Zur Beschleunigung von Bitmapausgaben, besonders von gedrehten.
104     GraphicObject*			mpReplacementGraphic;
105 	SdrGraphicLink*			pGraphicLink;		// Und hier noch ein Pointer fuer gelinkte Grafiken
106 	bool    				bMirrored;			// True bedeutet, die Grafik ist horizontal, d.h. ueber die Y-Achse gespiegelt auszugeben.
107 
108 	// #111096#
109 	// Flag for allowing text animation. Default is sal_true.
110 	unsigned					mbGrafAnimationAllowed : 1;
111 
112 	// #i25616#
113 	unsigned					mbInsidePaint : 1;
114 	unsigned					mbIsPreview   : 1;
115 
116 protected:
117 
118 	void					ImpLinkAnmeldung();
119 	void					ImpLinkAbmeldung();
120 	sal_Bool				ImpUpdateGraphicLink( sal_Bool bAsynchron = sal_True ) const;
121 	void					ImpSetLinkedGraphic( const Graphic& rGraphic );
122 							DECL_LINK( ImpSwapHdl, GraphicObject* );
123     void onGraphicChanged();
124 
125 public:
126 
127 							TYPEINFO();
128 
129 							SdrGrafObj();
130 							SdrGrafObj(const Graphic& rGrf);
131 							SdrGrafObj(const Graphic& rGrf, const Rectangle& rRect);
132 	virtual					~SdrGrafObj();
133 
134     void					SetGraphicObject( const GraphicObject& rGrfObj );
135 	const GraphicObject&	GetGraphicObject( bool bForceSwapIn = false) const;
136     const GraphicObject*    GetReplacementGraphicObject() const;
137 
138 	void					NbcSetGraphic(const Graphic& rGrf);
139 	void					SetGraphic(const Graphic& rGrf);
140 	const Graphic&			GetGraphic() const;
141 
142 	Graphic					GetTransformedGraphic( sal_uIntPtr nTransformFlags = SDRGRAFOBJ_TRANSFORMATTR_ALL ) const;
143 
144 	GraphicType				GetGraphicType() const;
145 
146 	// #111096#
147 	// Keep ATM for SD.
148 	sal_Bool IsAnimated() const;
149 	sal_Bool IsEPS() const;
150 	sal_Bool IsSwappedOut() const;
151 
152 	const MapMode&			GetGrafPrefMapMode() const;
153 	const Size&				GetGrafPrefSize() const;
154 
155 	void					SetGrafStreamURL( const String& rGraphicStreamURL );
156 	String					GetGrafStreamURL() const;
157 
158 	void					ForceSwapIn() const;
159 	void					ForceSwapOut() const;
160 
161 	void					SetGraphicLink(const String& rFileName, const String& rFilterName);
162 	void					ReleaseGraphicLink();
163 	sal_Bool IsLinkedGraphic() const { return (sal_Bool)aFileName.Len(); }
164 
165 	void					SetFileName(const String& rFileName);
166 	const String&			GetFileName() const { return aFileName; }
167 	void					SetFilterName(const String& rFilterName);
168 	const String&			GetFilterName() const { return aFilterName; }
169 
170 	void					StartAnimation(OutputDevice* pOutDev, const Point& rPoint, const Size& rSize, long nExtraData=0L);
171 	void					StopAnimation(OutputDevice* pOutDev=NULL, long nExtraData=0L);
172 
173 	virtual void			TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
174 	virtual sal_uInt16			GetObjIdentifier() const;
175 
176 	virtual void			TakeObjNameSingul(String& rName) const;
177 	virtual void			TakeObjNamePlural(String& rName) const;
178 
179 	// #i25616#
180 	virtual basegfx::B2DPolyPolygon TakeXorPoly() const;
181 
182 	virtual void			operator=(const SdrObject& rObj);
183 
184     virtual sal_uInt32 GetHdlCount() const;
185 	virtual SdrHdl*			GetHdl(sal_uInt32 nHdlNum) const;
186 
187 	virtual void			NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
188 	virtual void			NbcRotate(const Point& rRef, long nWink, double sn, double cs);
189 	virtual void			NbcMirror(const Point& rRef1, const Point& rRef2);
190 	virtual void			NbcShear (const Point& rRef, long nWink, double tn, FASTBOOL bVShear);
191 	virtual void			NbcSetSnapRect(const Rectangle& rRect);
192 	virtual void			NbcSetLogicRect(const Rectangle& rRect);
193 	virtual SdrObjGeoData*	NewGeoData() const;
194 	virtual void			SaveGeoData(SdrObjGeoData& rGeo) const;
195 	virtual void			RestGeoData(const SdrObjGeoData& rGeo);
196 
197 	FASTBOOL				HasGDIMetaFile() const;
198 	const GDIMetaFile*		GetGDIMetaFile() const;
199 
200 	virtual void			SetPage(SdrPage* pNewPage);
201 	virtual void			SetModel(SdrModel* pNewModel);
202 
203     bool isEmbeddedSvg() const;
204     GDIMetaFile getMetafileFromEmbeddedSvg() const;
205 
206     virtual SdrObject*		DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const;
207 
208 	virtual void			AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly = false );
209 
210 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
211 
212 	bool					IsMirrored() { return bMirrored; }
213 	void					SetMirrored( bool _bMirrored ) { bMirrored = _bMirrored; }
214 
215 	// #111096#
216 	// Access to GrafAnimationAllowed flag
217 	sal_Bool IsGrafAnimationAllowed() const;
218 	void SetGrafAnimationAllowed(sal_Bool bNew);
219 
220 	// #i25616#
221 	sal_Bool IsObjectTransparent() const;
222 
223 	::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > getInputStream();
224 
225     // #i103116# FullDrag support
226 	virtual SdrObject* getFullDragClone() const;
227 };
228 
229 #endif //_SVDOGRAF_HXX
230