xref: /aoo42x/main/svx/source/svdraw/svdograf.cxx (revision a5258243)
1cdf0e10cSrcweir /*************************************************************************
2cdf0e10cSrcweir  *
3cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4cdf0e10cSrcweir  *
5cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6cdf0e10cSrcweir  *
7cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8cdf0e10cSrcweir  *
9cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10cdf0e10cSrcweir  *
11cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14cdf0e10cSrcweir  *
15cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20cdf0e10cSrcweir  *
21cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25cdf0e10cSrcweir  *
26cdf0e10cSrcweir  ************************************************************************/
27cdf0e10cSrcweir 
28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29cdf0e10cSrcweir #include "precompiled_svx.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #define _ANIMATION
32cdf0e10cSrcweir #include <unotools/streamwrap.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
35cdf0e10cSrcweir #include <math.h>
36cdf0e10cSrcweir #include <vcl/salbtype.hxx>
37cdf0e10cSrcweir #include <sot/formats.hxx>
38cdf0e10cSrcweir #include <sot/storage.hxx>
39cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
40cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
41cdf0e10cSrcweir #include <svl/style.hxx>
42cdf0e10cSrcweir #include <svtools/filter.hxx>
43cdf0e10cSrcweir #include <svl/urihelper.hxx>
44cdf0e10cSrcweir #include <svtools/grfmgr.hxx>
45cdf0e10cSrcweir #include <vcl/svapp.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
48cdf0e10cSrcweir #include <sfx2/docfile.hxx>
49cdf0e10cSrcweir #include <svx/svdetc.hxx>
50cdf0e10cSrcweir #include "svx/svdglob.hxx"
51cdf0e10cSrcweir #include "svx/svdstr.hrc"
52cdf0e10cSrcweir #include <svx/svdpool.hxx>
53cdf0e10cSrcweir #include <svx/svdmodel.hxx>
54cdf0e10cSrcweir #include <svx/svdpage.hxx>
55cdf0e10cSrcweir #include <svx/svdmrkv.hxx>
56cdf0e10cSrcweir #include <svx/svdpagv.hxx>
57cdf0e10cSrcweir #include "svx/svdviter.hxx"
58cdf0e10cSrcweir #include <svx/svdview.hxx>
59cdf0e10cSrcweir #include "svtools/filter.hxx"
60cdf0e10cSrcweir #include <svx/svdograf.hxx>
61cdf0e10cSrcweir #include <svx/svdogrp.hxx>
62cdf0e10cSrcweir #include <svx/xbitmap.hxx>
63cdf0e10cSrcweir #include <svx/xbtmpit.hxx>
64cdf0e10cSrcweir #include <svx/xflbmtit.hxx>
65cdf0e10cSrcweir #include <svx/svdundo.hxx>
66cdf0e10cSrcweir #include "svdfmtf.hxx"
67cdf0e10cSrcweir #include <svx/sdgcpitm.hxx>
68cdf0e10cSrcweir #include <editeng/eeitem.hxx>
69cdf0e10cSrcweir #include <svx/sdr/properties/graphicproperties.hxx>
70cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofgraphic.hxx>
71cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
72cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
73cdf0e10cSrcweir #include <osl/thread.hxx>
74cdf0e10cSrcweir #include <vos/mutex.hxx>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir using namespace ::com::sun::star::uno;
77cdf0e10cSrcweir using namespace ::com::sun::star::io;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // -----------
80cdf0e10cSrcweir // - Defines -
81cdf0e10cSrcweir // -----------
82cdf0e10cSrcweir 
83cdf0e10cSrcweir #define GRAFSTREAMPOS_INVALID   0xffffffff
84cdf0e10cSrcweir #define SWAPGRAPHIC_TIMEOUT     5000
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 
87cdf0e10cSrcweir // ------------------
88cdf0e10cSrcweir // - SdrGraphicLink	-
89cdf0e10cSrcweir // ------------------
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92e6693332SEike Rathke const Graphic ImpLoadLinkedGraphic( const String aFileName, const String aFilterName )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	Graphic aGraphic;
95cdf0e10cSrcweir 
96e6693332SEike Rathke 	SfxMedium xMed( aFileName, STREAM_STD_READ, sal_True );
97cdf0e10cSrcweir 	xMed.DownLoad();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	SvStream* pInStrm = xMed.GetInStream();
100cdf0e10cSrcweir 	if ( pInStrm )
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir 		pInStrm->Seek( STREAM_SEEK_TO_BEGIN );
103cdf0e10cSrcweir 		GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
104cdf0e10cSrcweir 
105e6693332SEike Rathke 		const sal_uInt16 nFilter = aFilterName.Len() && pGF->GetImportFormatCount()
106e6693332SEike Rathke 							? pGF->GetImportFormatNumber( aFilterName )
107cdf0e10cSrcweir 							: GRFILTER_FORMAT_DONTKNOW;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 		String aEmptyStr;
110cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aFilterData( 1 );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 		// Room for improvment:
113cdf0e10cSrcweir 		// As this is a linked graphic the GfxLink is not needed if saving/loading our own format.
114cdf0e10cSrcweir 		// But this link is required by some filters to access the native graphic (pdf export/ms export),
115cdf0e10cSrcweir 		// there we should create a new service to provide this data if needed
116cdf0e10cSrcweir 		aFilterData[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CreateNativeLink" ) );
117cdf0e10cSrcweir 		aFilterData[ 0 ].Value = Any( sal_True );
118cdf0e10cSrcweir 		pGF->ImportGraphic( aGraphic, aEmptyStr, *pInStrm, nFilter, NULL, 0, &aFilterData );
119cdf0e10cSrcweir 	}
120cdf0e10cSrcweir 	return aGraphic;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir class SdrGraphicUpdater;
124cdf0e10cSrcweir class SdrGraphicLink : public sfx2::SvBaseLink
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	SdrGrafObj*			pGrafObj;
127cdf0e10cSrcweir 	SdrGraphicUpdater*	pGraphicUpdater;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir public:
130cdf0e10cSrcweir 						SdrGraphicLink(SdrGrafObj* pObj);
131cdf0e10cSrcweir 	virtual				~SdrGraphicLink();
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	virtual void		Closed();
134cdf0e10cSrcweir 	virtual void		DataChanged( const String& rMimeType,
135cdf0e10cSrcweir 								const ::com::sun::star::uno::Any & rValue );
136cdf0e10cSrcweir 	void				DataChanged( const Graphic& rGraphic );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	sal_Bool				Connect() { return 0 != GetRealObject(); }
139cdf0e10cSrcweir 	void				UpdateAsynchron();
140cdf0e10cSrcweir 	void				RemoveGraphicUpdater();
141cdf0e10cSrcweir };
142cdf0e10cSrcweir 
143cdf0e10cSrcweir class SdrGraphicUpdater : public ::osl::Thread
144cdf0e10cSrcweir {
145cdf0e10cSrcweir public:
146cdf0e10cSrcweir     SdrGraphicUpdater( const String& rFileName, const String& rFilterName, SdrGraphicLink& );
147cdf0e10cSrcweir     virtual ~SdrGraphicUpdater( void );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	void SAL_CALL Terminate( void );
150cdf0e10cSrcweir 
151e6693332SEike Rathke     sal_Bool GraphicLinkChanged( const String& rFileName ){ return maFileName != rFileName;	};
152cdf0e10cSrcweir 
153cdf0e10cSrcweir protected:
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	/**	is called from the inherited create method and acts as the
156cdf0e10cSrcweir 		main function of this thread.
157cdf0e10cSrcweir 	*/
158cdf0e10cSrcweir 	virtual void SAL_CALL run(void);
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     /**	Called after the thread is terminated via the terminate
161cdf0e10cSrcweir     	method.  Used to kill the thread by calling delete on this.
162cdf0e10cSrcweir     */
163cdf0e10cSrcweir     virtual void SAL_CALL onTerminated(void);
164cdf0e10cSrcweir 
165cdf0e10cSrcweir private:
166cdf0e10cSrcweir 
167e6693332SEike Rathke     const String	maFileName;
168e6693332SEike Rathke 	const String	maFilterName;
169cdf0e10cSrcweir 	SdrGraphicLink& mrGraphicLink;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	volatile bool mbIsTerminated;
172cdf0e10cSrcweir };
173cdf0e10cSrcweir 
174cdf0e10cSrcweir SdrGraphicUpdater::SdrGraphicUpdater( const String& rFileName, const String& rFilterName, SdrGraphicLink& rGraphicLink )
175e6693332SEike Rathke : maFileName( rFileName )
176e6693332SEike Rathke , maFilterName( rFilterName )
177cdf0e10cSrcweir , mrGraphicLink( rGraphicLink )
178cdf0e10cSrcweir , mbIsTerminated( sal_False )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir 	create();
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir SdrGraphicUpdater::~SdrGraphicUpdater( void )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir void SdrGraphicUpdater::Terminate()
188cdf0e10cSrcweir {
189cdf0e10cSrcweir     mbIsTerminated = sal_True;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir void SAL_CALL SdrGraphicUpdater::onTerminated(void)
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	delete this;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir void SAL_CALL SdrGraphicUpdater::run(void)
198cdf0e10cSrcweir {
199e6693332SEike Rathke 	Graphic aGraphic( ImpLoadLinkedGraphic( maFileName, maFilterName ) );
200cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
201cdf0e10cSrcweir 	if ( !mbIsTerminated )
202cdf0e10cSrcweir 	{
203cdf0e10cSrcweir 		mrGraphicLink.DataChanged( aGraphic );
204cdf0e10cSrcweir 		mrGraphicLink.RemoveGraphicUpdater();
205cdf0e10cSrcweir 	}
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir // -----------------------------------------------------------------------------
209cdf0e10cSrcweir 
210cdf0e10cSrcweir SdrGraphicLink::SdrGraphicLink(SdrGrafObj* pObj)
211cdf0e10cSrcweir : ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, SOT_FORMATSTR_ID_SVXB )
212cdf0e10cSrcweir , pGrafObj( pObj )
213cdf0e10cSrcweir , pGraphicUpdater( NULL )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir 	SetSynchron( sal_False );
216cdf0e10cSrcweir }
217cdf0e10cSrcweir 
218cdf0e10cSrcweir // -----------------------------------------------------------------------------
219cdf0e10cSrcweir 
220cdf0e10cSrcweir SdrGraphicLink::~SdrGraphicLink()
221cdf0e10cSrcweir {
222cdf0e10cSrcweir 	if ( pGraphicUpdater )
223cdf0e10cSrcweir 		pGraphicUpdater->Terminate();
224cdf0e10cSrcweir }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir // -----------------------------------------------------------------------------
227cdf0e10cSrcweir 
228cdf0e10cSrcweir void SdrGraphicLink::DataChanged( const Graphic& rGraphic )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	pGrafObj->ImpSetLinkedGraphic( rGraphic );
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir // -----------------------------------------------------------------------------
234cdf0e10cSrcweir 
235cdf0e10cSrcweir void SdrGraphicLink::RemoveGraphicUpdater()
236cdf0e10cSrcweir {
237cdf0e10cSrcweir 	pGraphicUpdater = NULL;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir 
240cdf0e10cSrcweir // -----------------------------------------------------------------------------
241cdf0e10cSrcweir 
242cdf0e10cSrcweir void SdrGraphicLink::DataChanged( const String& rMimeType,
243cdf0e10cSrcweir 								const ::com::sun::star::uno::Any & rValue )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	SdrModel*       pModel      = pGrafObj ? pGrafObj->GetModel() : 0;
246cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager= pModel  ? pModel->GetLinkManager() : 0;
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 	if( pLinkManager && rValue.hasValue() )
249cdf0e10cSrcweir 	{
250cdf0e10cSrcweir 		pLinkManager->GetDisplayNames( this, 0, &pGrafObj->aFileName, 0, &pGrafObj->aFilterName );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 		Graphic aGraphic;
253cdf0e10cSrcweir 		if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGraphic ))
254cdf0e10cSrcweir 		{
255cdf0e10cSrcweir    			pGrafObj->NbcSetGraphic( aGraphic );
256cdf0e10cSrcweir 			pGrafObj->ActionChanged();
257cdf0e10cSrcweir 		}
258cdf0e10cSrcweir 		else if( SotExchange::GetFormatIdFromMimeType( rMimeType ) != sfx2::LinkManager::RegisterStatusInfoId() )
259cdf0e10cSrcweir 		{
260cdf0e10cSrcweir 			// broadcasting, to update slidesorter
261cdf0e10cSrcweir 			pGrafObj->BroadcastObjectChange();
262cdf0e10cSrcweir 		}
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir // -----------------------------------------------------------------------------
267cdf0e10cSrcweir 
268cdf0e10cSrcweir void SdrGraphicLink::Closed()
269cdf0e10cSrcweir {
270cdf0e10cSrcweir 	// Die Verbindung wird aufgehoben; pLink des Objekts auf NULL setzen, da die Link-Instanz ja gerade destruiert wird.
271cdf0e10cSrcweir 	pGrafObj->ForceSwapIn();
272cdf0e10cSrcweir 	pGrafObj->pGraphicLink=NULL;
273cdf0e10cSrcweir 	pGrafObj->ReleaseGraphicLink();
274cdf0e10cSrcweir 	SvBaseLink::Closed();
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir // -----------------------------------------------------------------------------
278cdf0e10cSrcweir 
279cdf0e10cSrcweir void SdrGraphicLink::UpdateAsynchron()
280cdf0e10cSrcweir {
281cdf0e10cSrcweir 	if( GetObj() )
282cdf0e10cSrcweir 	{
283cdf0e10cSrcweir 		if ( pGraphicUpdater )
284cdf0e10cSrcweir 		{
285cdf0e10cSrcweir 			if ( pGraphicUpdater->GraphicLinkChanged( pGrafObj->GetFileName() ) )
286cdf0e10cSrcweir 			{
287cdf0e10cSrcweir 				pGraphicUpdater->Terminate();
288cdf0e10cSrcweir 				pGraphicUpdater = new SdrGraphicUpdater( pGrafObj->GetFileName(), pGrafObj->GetFilterName(), *this );
289cdf0e10cSrcweir 			}
290cdf0e10cSrcweir 		}
291cdf0e10cSrcweir 		else
292cdf0e10cSrcweir 			pGraphicUpdater = new SdrGraphicUpdater( pGrafObj->GetFileName(), pGrafObj->GetFilterName(), *this );
293cdf0e10cSrcweir 	}
294cdf0e10cSrcweir }
295cdf0e10cSrcweir 
296cdf0e10cSrcweir // --------------
297cdf0e10cSrcweir // - SdrGrafObj -
298cdf0e10cSrcweir // --------------
299cdf0e10cSrcweir 
300cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
301cdf0e10cSrcweir // BaseProperties section
302cdf0e10cSrcweir 
303cdf0e10cSrcweir sdr::properties::BaseProperties* SdrGrafObj::CreateObjectSpecificProperties()
304cdf0e10cSrcweir {
305cdf0e10cSrcweir 	return new sdr::properties::GraphicProperties(*this);
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
309cdf0e10cSrcweir // DrawContact section
310cdf0e10cSrcweir 
311cdf0e10cSrcweir sdr::contact::ViewContact* SdrGrafObj::CreateObjectSpecificViewContact()
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	return new sdr::contact::ViewContactOfGraphic(*this);
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
317cdf0e10cSrcweir 
318cdf0e10cSrcweir TYPEINIT1(SdrGrafObj,SdrRectObj);
319cdf0e10cSrcweir 
320cdf0e10cSrcweir // -----------------------------------------------------------------------------
321cdf0e10cSrcweir 
322cdf0e10cSrcweir SdrGrafObj::SdrGrafObj()
323cdf0e10cSrcweir :	SdrRectObj(),
324cdf0e10cSrcweir 	pGraphicLink	( NULL ),
325cdf0e10cSrcweir 	bMirrored		( sal_False )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir 	pGraphic = new GraphicObject;
328cdf0e10cSrcweir 	pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
329*a5258243SPedro Giffuni 
330*a5258243SPedro Giffuni     // #i118485# Shear allowed and possible now
331*a5258243SPedro Giffuni     bNoShear = false;
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 	// #111096#
334cdf0e10cSrcweir 	mbGrafAnimationAllowed = sal_True;
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	// #i25616#
337cdf0e10cSrcweir 	mbLineIsOutsideGeometry = sal_True;
338cdf0e10cSrcweir 	mbInsidePaint = sal_False;
339cdf0e10cSrcweir 	mbIsPreview = sal_False;
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 	// #i25616#
342cdf0e10cSrcweir 	mbSupportTextIndentingOnLineWidthChange = sal_False;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir // -----------------------------------------------------------------------------
346cdf0e10cSrcweir 
347cdf0e10cSrcweir SdrGrafObj::SdrGrafObj(const Graphic& rGrf, const Rectangle& rRect)
348cdf0e10cSrcweir :	SdrRectObj		( rRect ),
349cdf0e10cSrcweir 	pGraphicLink	( NULL ),
350cdf0e10cSrcweir 	bMirrored		( sal_False )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir 	pGraphic = new GraphicObject( rGrf );
353cdf0e10cSrcweir 	pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
354*a5258243SPedro Giffuni 
355*a5258243SPedro Giffuni     // #i118485# Shear allowed and possible now
356*a5258243SPedro Giffuni     bNoShear = false;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	// #111096#
359cdf0e10cSrcweir 	mbGrafAnimationAllowed = sal_True;
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 	// #i25616#
362cdf0e10cSrcweir 	mbLineIsOutsideGeometry = sal_True;
363cdf0e10cSrcweir 	mbInsidePaint = sal_False;
364cdf0e10cSrcweir 	mbIsPreview	= sal_False;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 	// #i25616#
367cdf0e10cSrcweir 	mbSupportTextIndentingOnLineWidthChange = sal_False;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir // -----------------------------------------------------------------------------
371cdf0e10cSrcweir 
372cdf0e10cSrcweir SdrGrafObj::SdrGrafObj( const Graphic& rGrf )
373cdf0e10cSrcweir :	SdrRectObj(),
374cdf0e10cSrcweir 	pGraphicLink	( NULL ),
375cdf0e10cSrcweir 	bMirrored		( sal_False )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir 	pGraphic = new GraphicObject( rGrf );
378cdf0e10cSrcweir 	pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
379*a5258243SPedro Giffuni 
380*a5258243SPedro Giffuni     // #i118485# Shear allowed and possible now
381*a5258243SPedro Giffuni     bNoShear = false;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 	// #111096#
384cdf0e10cSrcweir 	mbGrafAnimationAllowed = sal_True;
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 	// #i25616#
387cdf0e10cSrcweir 	mbLineIsOutsideGeometry = sal_True;
388cdf0e10cSrcweir 	mbInsidePaint = sal_False;
389cdf0e10cSrcweir 	mbIsPreview	= sal_False;
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 	// #i25616#
392cdf0e10cSrcweir 	mbSupportTextIndentingOnLineWidthChange = sal_False;
393cdf0e10cSrcweir }
394cdf0e10cSrcweir 
395cdf0e10cSrcweir // -----------------------------------------------------------------------------
396cdf0e10cSrcweir 
397cdf0e10cSrcweir SdrGrafObj::~SdrGrafObj()
398cdf0e10cSrcweir {
399cdf0e10cSrcweir 	delete pGraphic;
400cdf0e10cSrcweir 	ImpLinkAbmeldung();
401cdf0e10cSrcweir }
402cdf0e10cSrcweir 
403cdf0e10cSrcweir // -----------------------------------------------------------------------------
404cdf0e10cSrcweir 
405cdf0e10cSrcweir void SdrGrafObj::SetGraphicObject( const GraphicObject& rGrfObj )
406cdf0e10cSrcweir {
407cdf0e10cSrcweir 	*pGraphic = rGrfObj;
408cdf0e10cSrcweir 	pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
409cdf0e10cSrcweir 	pGraphic->SetUserData();
410cdf0e10cSrcweir 	mbIsPreview = sal_False;
411cdf0e10cSrcweir 	SetChanged();
412cdf0e10cSrcweir 	BroadcastObjectChange();
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir // -----------------------------------------------------------------------------
416cdf0e10cSrcweir 
417cdf0e10cSrcweir const GraphicObject& SdrGrafObj::GetGraphicObject(bool bForceSwapIn) const
418cdf0e10cSrcweir {
419cdf0e10cSrcweir 	if(bForceSwapIn)
420cdf0e10cSrcweir 	{
421cdf0e10cSrcweir 		ForceSwapIn();
422cdf0e10cSrcweir 	}
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 	return *pGraphic;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
427cdf0e10cSrcweir // -----------------------------------------------------------------------------
428cdf0e10cSrcweir 
429cdf0e10cSrcweir void SdrGrafObj::NbcSetGraphic( const Graphic& rGrf )
430cdf0e10cSrcweir {
431cdf0e10cSrcweir 	pGraphic->SetGraphic( rGrf );
432cdf0e10cSrcweir 	pGraphic->SetUserData();
433cdf0e10cSrcweir 	mbIsPreview = sal_False;
434cdf0e10cSrcweir }
435cdf0e10cSrcweir 
436cdf0e10cSrcweir void SdrGrafObj::SetGraphic( const Graphic& rGrf )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir     NbcSetGraphic(rGrf);
439cdf0e10cSrcweir 	SetChanged();
440cdf0e10cSrcweir 	BroadcastObjectChange();
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
443cdf0e10cSrcweir // -----------------------------------------------------------------------------
444cdf0e10cSrcweir 
445cdf0e10cSrcweir const Graphic& SdrGrafObj::GetGraphic() const
446cdf0e10cSrcweir {
447cdf0e10cSrcweir 	ForceSwapIn();
448cdf0e10cSrcweir 	return pGraphic->GetGraphic();
449cdf0e10cSrcweir }
450cdf0e10cSrcweir 
451cdf0e10cSrcweir // -----------------------------------------------------------------------------
452cdf0e10cSrcweir 
453cdf0e10cSrcweir Graphic SdrGrafObj::GetTransformedGraphic( sal_uIntPtr nTransformFlags ) const
454cdf0e10cSrcweir {
455cdf0e10cSrcweir     // #107947# Refactored most of the code to GraphicObject, where
456cdf0e10cSrcweir     // everybody can use e.g. the cropping functionality
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 	GraphicType	    eType = GetGraphicType();
459cdf0e10cSrcweir     MapMode   		aDestMap( pModel->GetScaleUnit(), Point(), pModel->GetScaleFraction(), pModel->GetScaleFraction() );
460cdf0e10cSrcweir     const Size      aDestSize( GetLogicRect().GetSize() );
461cdf0e10cSrcweir     const sal_Bool      bMirror = ( nTransformFlags & SDRGRAFOBJ_TRANSFORMATTR_MIRROR ) != 0;
462cdf0e10cSrcweir     const sal_Bool      bRotate = ( ( nTransformFlags & SDRGRAFOBJ_TRANSFORMATTR_ROTATE ) != 0 ) &&
463cdf0e10cSrcweir         ( aGeo.nDrehWink && aGeo.nDrehWink != 18000 ) && ( GRAPHIC_NONE != eType );
464cdf0e10cSrcweir 
465cdf0e10cSrcweir     // #104115# Need cropping info earlier
466cdf0e10cSrcweir     ( (SdrGrafObj*) this )->ImpSetAttrToGrafInfo();
467cdf0e10cSrcweir     GraphicAttr aActAttr;
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 	if( SDRGRAFOBJ_TRANSFORMATTR_NONE != nTransformFlags &&
470cdf0e10cSrcweir         GRAPHIC_NONE != eType )
471cdf0e10cSrcweir 	{
472cdf0e10cSrcweir         // actually transform the graphic only in this case. On the
473cdf0e10cSrcweir         // other hand, cropping will always happen
474cdf0e10cSrcweir         aActAttr = aGrafInfo;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir         if( bMirror )
477cdf0e10cSrcweir 		{
478cdf0e10cSrcweir 			sal_uInt16		nMirrorCase = ( aGeo.nDrehWink == 18000 ) ? ( bMirrored ? 3 : 4 ) : ( bMirrored ? 2 : 1 );
479cdf0e10cSrcweir 			FASTBOOL	bHMirr = nMirrorCase == 2 || nMirrorCase == 4;
480cdf0e10cSrcweir 			FASTBOOL	bVMirr = nMirrorCase == 3 || nMirrorCase == 4;
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 			aActAttr.SetMirrorFlags( ( bHMirr ? BMP_MIRROR_HORZ : 0 ) | ( bVMirr ? BMP_MIRROR_VERT : 0 ) );
483cdf0e10cSrcweir 		}
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 		if( bRotate )
486cdf0e10cSrcweir 			aActAttr.SetRotation( sal_uInt16(aGeo.nDrehWink / 10) );
487cdf0e10cSrcweir 	}
488cdf0e10cSrcweir 
489cdf0e10cSrcweir     // #107947# Delegate to moved code in GraphicObject
490cdf0e10cSrcweir     return GetGraphicObject().GetTransformedGraphic( aDestSize, aDestMap, aActAttr );
491cdf0e10cSrcweir }
492cdf0e10cSrcweir 
493cdf0e10cSrcweir // -----------------------------------------------------------------------------
494cdf0e10cSrcweir 
495cdf0e10cSrcweir GraphicType SdrGrafObj::GetGraphicType() const
496cdf0e10cSrcweir {
497cdf0e10cSrcweir 	return pGraphic->GetType();
498cdf0e10cSrcweir }
499cdf0e10cSrcweir 
500cdf0e10cSrcweir sal_Bool SdrGrafObj::IsAnimated() const
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	return pGraphic->IsAnimated();
503cdf0e10cSrcweir }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir sal_Bool SdrGrafObj::IsEPS() const
506cdf0e10cSrcweir {
507cdf0e10cSrcweir 	return pGraphic->IsEPS();
508cdf0e10cSrcweir }
509cdf0e10cSrcweir 
510cdf0e10cSrcweir sal_Bool SdrGrafObj::IsRenderGraphic() const
511cdf0e10cSrcweir {
512cdf0e10cSrcweir 	return pGraphic->IsRenderGraphic();
513cdf0e10cSrcweir }
514cdf0e10cSrcweir 
515cdf0e10cSrcweir sal_Bool SdrGrafObj::HasRenderGraphic() const
516cdf0e10cSrcweir {
517cdf0e10cSrcweir 	return pGraphic->HasRenderGraphic();
518cdf0e10cSrcweir }
519cdf0e10cSrcweir 
520cdf0e10cSrcweir sal_Bool SdrGrafObj::IsSwappedOut() const
521cdf0e10cSrcweir {
522cdf0e10cSrcweir 	return mbIsPreview ? sal_True : pGraphic->IsSwappedOut();
523cdf0e10cSrcweir }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir const MapMode& SdrGrafObj::GetGrafPrefMapMode() const
526cdf0e10cSrcweir {
527cdf0e10cSrcweir 	return pGraphic->GetPrefMapMode();
528cdf0e10cSrcweir }
529cdf0e10cSrcweir 
530cdf0e10cSrcweir const Size& SdrGrafObj::GetGrafPrefSize() const
531cdf0e10cSrcweir {
532cdf0e10cSrcweir 	return pGraphic->GetPrefSize();
533cdf0e10cSrcweir }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir // -----------------------------------------------------------------------------
536cdf0e10cSrcweir 
537cdf0e10cSrcweir void SdrGrafObj::SetGrafStreamURL( const String& rGraphicStreamURL )
538cdf0e10cSrcweir {
539cdf0e10cSrcweir 	mbIsPreview = sal_False;
540cdf0e10cSrcweir 	if( !rGraphicStreamURL.Len() )
541cdf0e10cSrcweir 	{
542cdf0e10cSrcweir 		pGraphic->SetUserData();
543cdf0e10cSrcweir 	}
544cdf0e10cSrcweir 	else if( pModel->IsSwapGraphics() )
545cdf0e10cSrcweir 	{
546cdf0e10cSrcweir 		pGraphic->SetUserData( rGraphicStreamURL );
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 		// set state of graphic object to 'swapped out'
549cdf0e10cSrcweir 		if( pGraphic->GetType() == GRAPHIC_NONE )
550cdf0e10cSrcweir 			pGraphic->SetSwapState();
551cdf0e10cSrcweir 	}
552cdf0e10cSrcweir }
553cdf0e10cSrcweir 
554cdf0e10cSrcweir // -----------------------------------------------------------------------------
555cdf0e10cSrcweir 
556cdf0e10cSrcweir String SdrGrafObj::GetGrafStreamURL() const
557cdf0e10cSrcweir {
558cdf0e10cSrcweir 	return pGraphic->GetUserData();
559cdf0e10cSrcweir }
560cdf0e10cSrcweir 
561cdf0e10cSrcweir // -----------------------------------------------------------------------------
562cdf0e10cSrcweir 
563cdf0e10cSrcweir void SdrGrafObj::SetFileName(const String& rFileName)
564cdf0e10cSrcweir {
565cdf0e10cSrcweir 	aFileName = rFileName;
566cdf0e10cSrcweir 	SetChanged();
567cdf0e10cSrcweir }
568cdf0e10cSrcweir 
569cdf0e10cSrcweir // -----------------------------------------------------------------------------
570cdf0e10cSrcweir 
571cdf0e10cSrcweir void SdrGrafObj::SetFilterName(const String& rFilterName)
572cdf0e10cSrcweir {
573cdf0e10cSrcweir 	aFilterName = rFilterName;
574cdf0e10cSrcweir 	SetChanged();
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir // -----------------------------------------------------------------------------
578cdf0e10cSrcweir 
579cdf0e10cSrcweir void SdrGrafObj::ForceSwapIn() const
580cdf0e10cSrcweir {
581cdf0e10cSrcweir 	if( mbIsPreview )
582cdf0e10cSrcweir 	{
583cdf0e10cSrcweir 		// removing preview graphic
584cdf0e10cSrcweir 		const String aUserData( pGraphic->GetUserData() );
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 		Graphic aEmpty;
587cdf0e10cSrcweir 		pGraphic->SetGraphic( aEmpty );
588cdf0e10cSrcweir 		pGraphic->SetUserData( aUserData );
589cdf0e10cSrcweir 		pGraphic->SetSwapState();
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 		const_cast< SdrGrafObj* >( this )->mbIsPreview = sal_False;
592cdf0e10cSrcweir 	}
593cdf0e10cSrcweir 	if ( pGraphicLink && pGraphic->IsSwappedOut() )
594cdf0e10cSrcweir 		ImpUpdateGraphicLink( sal_False );
595cdf0e10cSrcweir 	else
596cdf0e10cSrcweir 		pGraphic->FireSwapInRequest();
597cdf0e10cSrcweir 
598cdf0e10cSrcweir 	if( pGraphic->IsSwappedOut() ||
599cdf0e10cSrcweir 	    ( pGraphic->GetType() == GRAPHIC_NONE ) ||
600cdf0e10cSrcweir 		( pGraphic->GetType() == GRAPHIC_DEFAULT ) )
601cdf0e10cSrcweir 	{
602cdf0e10cSrcweir 		Graphic aDefaultGraphic;
603cdf0e10cSrcweir 		aDefaultGraphic.SetDefaultType();
604cdf0e10cSrcweir 		pGraphic->SetGraphic( aDefaultGraphic );
605cdf0e10cSrcweir 	}
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir // -----------------------------------------------------------------------------
609cdf0e10cSrcweir 
610cdf0e10cSrcweir void SdrGrafObj::ForceSwapOut() const
611cdf0e10cSrcweir {
612cdf0e10cSrcweir 	pGraphic->FireSwapOutRequest();
613cdf0e10cSrcweir }
614cdf0e10cSrcweir 
615cdf0e10cSrcweir // -----------------------------------------------------------------------------
616cdf0e10cSrcweir 
617cdf0e10cSrcweir void SdrGrafObj::ImpLinkAnmeldung()
618cdf0e10cSrcweir {
619cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL;
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 	if( pLinkManager != NULL && pGraphicLink == NULL )
622cdf0e10cSrcweir 	{
623cdf0e10cSrcweir 		if( aFileName.Len() )
624cdf0e10cSrcweir 		{
625cdf0e10cSrcweir 			pGraphicLink = new SdrGraphicLink( this );
626cdf0e10cSrcweir 			pLinkManager->InsertFileLink( *pGraphicLink, OBJECT_CLIENT_GRF, aFileName, ( aFilterName.Len() ? &aFilterName : NULL ), NULL );
627cdf0e10cSrcweir 			pGraphicLink->Connect();
628cdf0e10cSrcweir 		}
629cdf0e10cSrcweir 	}
630cdf0e10cSrcweir }
631cdf0e10cSrcweir 
632cdf0e10cSrcweir // -----------------------------------------------------------------------------
633cdf0e10cSrcweir 
634cdf0e10cSrcweir void SdrGrafObj::ImpLinkAbmeldung()
635cdf0e10cSrcweir {
636cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL;
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 	if( pLinkManager != NULL && pGraphicLink!=NULL)
639cdf0e10cSrcweir 	{
640cdf0e10cSrcweir 		// Bei Remove wird *pGraphicLink implizit deleted
641cdf0e10cSrcweir 		pLinkManager->Remove( pGraphicLink );
642cdf0e10cSrcweir 		pGraphicLink=NULL;
643cdf0e10cSrcweir 	}
644cdf0e10cSrcweir }
645cdf0e10cSrcweir 
646cdf0e10cSrcweir // -----------------------------------------------------------------------------
647cdf0e10cSrcweir 
648cdf0e10cSrcweir void SdrGrafObj::SetGraphicLink( const String& rFileName, const String& rFilterName )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir 	ImpLinkAbmeldung();
651cdf0e10cSrcweir 	aFileName = rFileName;
652cdf0e10cSrcweir 	aFilterName = rFilterName;
653cdf0e10cSrcweir 	ImpLinkAnmeldung();
654cdf0e10cSrcweir 	pGraphic->SetUserData();
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     // #92205# A linked graphic is per definition swapped out (has to be loaded)
657cdf0e10cSrcweir     pGraphic->SetSwapState();
658cdf0e10cSrcweir }
659cdf0e10cSrcweir 
660cdf0e10cSrcweir // -----------------------------------------------------------------------------
661cdf0e10cSrcweir 
662cdf0e10cSrcweir void SdrGrafObj::ReleaseGraphicLink()
663cdf0e10cSrcweir {
664cdf0e10cSrcweir 	ImpLinkAbmeldung();
665cdf0e10cSrcweir 	aFileName = String();
666cdf0e10cSrcweir 	aFilterName = String();
667cdf0e10cSrcweir }
668cdf0e10cSrcweir 
669cdf0e10cSrcweir // -----------------------------------------------------------------------------
670cdf0e10cSrcweir 
671cdf0e10cSrcweir void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
672cdf0e10cSrcweir {
673cdf0e10cSrcweir 	FASTBOOL bAnim = pGraphic->IsAnimated();
674cdf0e10cSrcweir     FASTBOOL bRenderGraphic = pGraphic->HasRenderGraphic();
675cdf0e10cSrcweir 	FASTBOOL bNoPresGrf = ( pGraphic->GetType() != GRAPHIC_NONE ) && !bEmptyPresObj;
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	rInfo.bResizeFreeAllowed = aGeo.nDrehWink % 9000 == 0 ||
678cdf0e10cSrcweir 							   aGeo.nDrehWink % 18000 == 0 ||
679cdf0e10cSrcweir 							   aGeo.nDrehWink % 27000 == 0;
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 	rInfo.bResizePropAllowed = sal_True;
682cdf0e10cSrcweir 	rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic;
683cdf0e10cSrcweir 	rInfo.bRotate90Allowed = bNoPresGrf && !bAnim && !bRenderGraphic;
684cdf0e10cSrcweir 	rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic;
685cdf0e10cSrcweir 	rInfo.bMirror45Allowed = bNoPresGrf && !bAnim && !bRenderGraphic;
686cdf0e10cSrcweir 	rInfo.bMirror90Allowed = !bEmptyPresObj && !bRenderGraphic;
687cdf0e10cSrcweir 	rInfo.bTransparenceAllowed = sal_False;
688cdf0e10cSrcweir 	rInfo.bGradientAllowed = sal_False;
689*a5258243SPedro Giffuni 
690*a5258243SPedro Giffuni     // #i118485# Shear allowed and possible now
691*a5258243SPedro Giffuni 	rInfo.bShearAllowed = true;
692*a5258243SPedro Giffuni 
693*a5258243SPedro Giffuni     rInfo.bEdgeRadiusAllowed=sal_False;
694*a5258243SPedro Giffuni 	rInfo.bCanConvToPath = !IsEPS() && !bRenderGraphic;
695cdf0e10cSrcweir 	rInfo.bCanConvToPathLineToArea = sal_False;
696cdf0e10cSrcweir 	rInfo.bCanConvToPolyLineToArea = sal_False;
697cdf0e10cSrcweir 	rInfo.bCanConvToPoly = !IsEPS() && !bRenderGraphic;
698cdf0e10cSrcweir 	rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
699cdf0e10cSrcweir }
700cdf0e10cSrcweir 
701cdf0e10cSrcweir // -----------------------------------------------------------------------------
702cdf0e10cSrcweir 
703cdf0e10cSrcweir sal_uInt16 SdrGrafObj::GetObjIdentifier() const
704cdf0e10cSrcweir {
705cdf0e10cSrcweir 	return sal_uInt16( OBJ_GRAF );
706cdf0e10cSrcweir }
707cdf0e10cSrcweir 
708cdf0e10cSrcweir // -----------------------------------------------------------------------------
709cdf0e10cSrcweir 
710cdf0e10cSrcweir /* The graphic of the GraphicLink will be loaded. If it is called with
711cdf0e10cSrcweir    bAsynchron = true then the graphic will be set later via DataChanged
712cdf0e10cSrcweir */
713cdf0e10cSrcweir sal_Bool SdrGrafObj::ImpUpdateGraphicLink( sal_Bool bAsynchron ) const
714cdf0e10cSrcweir {
715cdf0e10cSrcweir     sal_Bool bRet = sal_False;
716cdf0e10cSrcweir     if( pGraphicLink )
717cdf0e10cSrcweir 	{
718cdf0e10cSrcweir 		if ( bAsynchron )
719cdf0e10cSrcweir 			pGraphicLink->UpdateAsynchron();
720cdf0e10cSrcweir 		else
721cdf0e10cSrcweir 			pGraphicLink->DataChanged( ImpLoadLinkedGraphic( aFileName, aFilterName ) );
722cdf0e10cSrcweir         bRet = sal_True;
723cdf0e10cSrcweir     }
724cdf0e10cSrcweir 	return bRet;
725cdf0e10cSrcweir }
726cdf0e10cSrcweir 
727cdf0e10cSrcweir // -----------------------------------------------------------------------------
728cdf0e10cSrcweir 
729cdf0e10cSrcweir void SdrGrafObj::ImpSetLinkedGraphic( const Graphic& rGraphic )
730cdf0e10cSrcweir {
731cdf0e10cSrcweir 	const sal_Bool bIsChanged = GetModel()->IsChanged();
732cdf0e10cSrcweir 	NbcSetGraphic( rGraphic );
733cdf0e10cSrcweir 	ActionChanged();
734cdf0e10cSrcweir 	BroadcastObjectChange();
735cdf0e10cSrcweir 	GetModel()->SetChanged( bIsChanged );
736cdf0e10cSrcweir }
737cdf0e10cSrcweir 
738cdf0e10cSrcweir // -----------------------------------------------------------------------------
739cdf0e10cSrcweir 
740cdf0e10cSrcweir void SdrGrafObj::TakeObjNameSingul(XubString& rName) const
741cdf0e10cSrcweir {
742cdf0e10cSrcweir 	switch( pGraphic->GetType() )
743cdf0e10cSrcweir 	{
744cdf0e10cSrcweir 		case GRAPHIC_BITMAP:
745cdf0e10cSrcweir         {
746cdf0e10cSrcweir             const sal_uInt16 nId = ( ( pGraphic->IsTransparent() || ( (const SdrGrafTransparenceItem&) GetObjectItem( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ) ?
747cdf0e10cSrcweir                                  ( IsLinkedGraphic() ? STR_ObjNameSingulGRAFBMPTRANSLNK : STR_ObjNameSingulGRAFBMPTRANS ) :
748cdf0e10cSrcweir                                  ( IsLinkedGraphic() ? STR_ObjNameSingulGRAFBMPLNK : STR_ObjNameSingulGRAFBMP ) );
749cdf0e10cSrcweir 
750cdf0e10cSrcweir             rName=ImpGetResStr( nId );
751cdf0e10cSrcweir         }
752cdf0e10cSrcweir         break;
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 		case GRAPHIC_GDIMETAFILE:
755cdf0e10cSrcweir             rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFMTFLNK : STR_ObjNameSingulGRAFMTF );
756cdf0e10cSrcweir         break;
757cdf0e10cSrcweir 
758cdf0e10cSrcweir         case GRAPHIC_NONE:
759cdf0e10cSrcweir             rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFNONELNK : STR_ObjNameSingulGRAFNONE );
760cdf0e10cSrcweir         break;
761cdf0e10cSrcweir 
762cdf0e10cSrcweir         default:
763cdf0e10cSrcweir             rName=ImpGetResStr(  IsLinkedGraphic() ? STR_ObjNameSingulGRAFLNK : STR_ObjNameSingulGRAF );
764cdf0e10cSrcweir         break;
765cdf0e10cSrcweir 	}
766cdf0e10cSrcweir 
767cdf0e10cSrcweir 	const String aName(GetName());
768cdf0e10cSrcweir 
769cdf0e10cSrcweir 	if( aName.Len() )
770cdf0e10cSrcweir 	{
771cdf0e10cSrcweir 		rName.AppendAscii( " '" );
772cdf0e10cSrcweir 		rName += aName;
773cdf0e10cSrcweir 		rName += sal_Unicode( '\'' );
774cdf0e10cSrcweir 	}
775cdf0e10cSrcweir }
776cdf0e10cSrcweir 
777cdf0e10cSrcweir // -----------------------------------------------------------------------------
778cdf0e10cSrcweir 
779cdf0e10cSrcweir void SdrGrafObj::TakeObjNamePlural( XubString& rName ) const
780cdf0e10cSrcweir {
781cdf0e10cSrcweir 	switch( pGraphic->GetType() )
782cdf0e10cSrcweir 	{
783cdf0e10cSrcweir 		case GRAPHIC_BITMAP:
784cdf0e10cSrcweir         {
785cdf0e10cSrcweir             const sal_uInt16 nId = ( ( pGraphic->IsTransparent() || ( (const SdrGrafTransparenceItem&) GetObjectItem( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ) ?
786cdf0e10cSrcweir                                  ( IsLinkedGraphic() ? STR_ObjNamePluralGRAFBMPTRANSLNK : STR_ObjNamePluralGRAFBMPTRANS ) :
787cdf0e10cSrcweir                                  ( IsLinkedGraphic() ? STR_ObjNamePluralGRAFBMPLNK : STR_ObjNamePluralGRAFBMP ) );
788cdf0e10cSrcweir 
789cdf0e10cSrcweir             rName=ImpGetResStr( nId );
790cdf0e10cSrcweir         }
791cdf0e10cSrcweir         break;
792cdf0e10cSrcweir 
793cdf0e10cSrcweir 		case GRAPHIC_GDIMETAFILE:
794cdf0e10cSrcweir             rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFMTFLNK : STR_ObjNamePluralGRAFMTF );
795cdf0e10cSrcweir         break;
796cdf0e10cSrcweir 
797cdf0e10cSrcweir         case GRAPHIC_NONE:
798cdf0e10cSrcweir             rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFNONELNK : STR_ObjNamePluralGRAFNONE );
799cdf0e10cSrcweir         break;
800cdf0e10cSrcweir 
801cdf0e10cSrcweir         default:
802cdf0e10cSrcweir             rName=ImpGetResStr(  IsLinkedGraphic() ? STR_ObjNamePluralGRAFLNK : STR_ObjNamePluralGRAF );
803cdf0e10cSrcweir         break;
804cdf0e10cSrcweir 	}
805cdf0e10cSrcweir 
806cdf0e10cSrcweir 	const String aName(GetName());
807cdf0e10cSrcweir 
808cdf0e10cSrcweir 	if( aName.Len() )
809cdf0e10cSrcweir 	{
810cdf0e10cSrcweir 		rName.AppendAscii( " '" );
811cdf0e10cSrcweir 		rName += aName;
812cdf0e10cSrcweir 		rName += sal_Unicode( '\'' );
813cdf0e10cSrcweir 	}
814cdf0e10cSrcweir }
815cdf0e10cSrcweir 
816cdf0e10cSrcweir // -----------------------------------------------------------------------------
817cdf0e10cSrcweir 
818cdf0e10cSrcweir SdrObject* SdrGrafObj::getFullDragClone() const
819cdf0e10cSrcweir {
820cdf0e10cSrcweir     // call parent
821cdf0e10cSrcweir     SdrGrafObj* pRetval = static_cast< SdrGrafObj* >(SdrRectObj::getFullDragClone());
822cdf0e10cSrcweir 
823cdf0e10cSrcweir     // #i103116# the full drag clone leads to problems
824cdf0e10cSrcweir     // with linked graphics, so reset the link in this
825cdf0e10cSrcweir     // temporary interaction object and load graphic
826cdf0e10cSrcweir     if(pRetval && IsLinkedGraphic())
827cdf0e10cSrcweir     {
828cdf0e10cSrcweir         pRetval->ForceSwapIn();
829cdf0e10cSrcweir         pRetval->ReleaseGraphicLink();
830cdf0e10cSrcweir     }
831cdf0e10cSrcweir 
832cdf0e10cSrcweir     return pRetval;
833cdf0e10cSrcweir }
834cdf0e10cSrcweir 
835cdf0e10cSrcweir void SdrGrafObj::operator=( const SdrObject& rObj )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir 	SdrRectObj::operator=( rObj );
838cdf0e10cSrcweir 
839cdf0e10cSrcweir 	const SdrGrafObj& rGraf = (SdrGrafObj&) rObj;
840cdf0e10cSrcweir 
841cdf0e10cSrcweir 	pGraphic->SetGraphic( rGraf.GetGraphic(), &rGraf.GetGraphicObject() );
842cdf0e10cSrcweir 	aCropRect = rGraf.aCropRect;
843cdf0e10cSrcweir 	aFileName = rGraf.aFileName;
844cdf0e10cSrcweir 	aFilterName = rGraf.aFilterName;
845cdf0e10cSrcweir 	bMirrored = rGraf.bMirrored;
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 	if( rGraf.pGraphicLink != NULL)
848cdf0e10cSrcweir 	{
849cdf0e10cSrcweir 		SetGraphicLink( aFileName, aFilterName );
850cdf0e10cSrcweir 	}
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 	ImpSetAttrToGrafInfo();
853cdf0e10cSrcweir }
854cdf0e10cSrcweir 
855cdf0e10cSrcweir // -----------------------------------------------------------------------------
856cdf0e10cSrcweir // #i25616#
857cdf0e10cSrcweir 
858cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrGrafObj::TakeXorPoly() const
859cdf0e10cSrcweir {
860cdf0e10cSrcweir 	if(mbInsidePaint)
861cdf0e10cSrcweir 	{
862cdf0e10cSrcweir 		basegfx::B2DPolyPolygon aRetval;
863cdf0e10cSrcweir 
864cdf0e10cSrcweir 		// take grown rectangle
865cdf0e10cSrcweir 		const sal_Int32 nHalfLineWidth(ImpGetLineWdt() / 2);
866cdf0e10cSrcweir 		const Rectangle aGrownRect(
867cdf0e10cSrcweir 			aRect.Left() - nHalfLineWidth,
868cdf0e10cSrcweir 			aRect.Top() - nHalfLineWidth,
869cdf0e10cSrcweir 			aRect.Right() + nHalfLineWidth,
870cdf0e10cSrcweir 			aRect.Bottom() + nHalfLineWidth);
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 		XPolygon aXPoly(ImpCalcXPoly(aGrownRect, GetEckenradius()));
873cdf0e10cSrcweir 		aRetval.append(aXPoly.getB2DPolygon());
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 		return aRetval;
876cdf0e10cSrcweir 	}
877cdf0e10cSrcweir 	else
878cdf0e10cSrcweir 	{
879cdf0e10cSrcweir 		// call parent
880cdf0e10cSrcweir 		return SdrRectObj::TakeXorPoly();
881cdf0e10cSrcweir 	}
882cdf0e10cSrcweir }
883cdf0e10cSrcweir 
884cdf0e10cSrcweir // -----------------------------------------------------------------------------
885cdf0e10cSrcweir 
886cdf0e10cSrcweir sal_uInt32 SdrGrafObj::GetHdlCount() const
887cdf0e10cSrcweir {
888cdf0e10cSrcweir 	return 8L;
889cdf0e10cSrcweir }
890cdf0e10cSrcweir 
891cdf0e10cSrcweir // -----------------------------------------------------------------------------
892cdf0e10cSrcweir 
893cdf0e10cSrcweir SdrHdl* SdrGrafObj::GetHdl(sal_uInt32 nHdlNum) const
894cdf0e10cSrcweir {
895cdf0e10cSrcweir 	return SdrRectObj::GetHdl( nHdlNum + 1L );
896cdf0e10cSrcweir }
897cdf0e10cSrcweir 
898cdf0e10cSrcweir // -----------------------------------------------------------------------------
899cdf0e10cSrcweir 
900cdf0e10cSrcweir void SdrGrafObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
901cdf0e10cSrcweir {
902cdf0e10cSrcweir 	SdrRectObj::NbcResize( rRef, xFact, yFact );
903cdf0e10cSrcweir 
904cdf0e10cSrcweir 	FASTBOOL bMirrX = xFact.GetNumerator() < 0;
905cdf0e10cSrcweir 	FASTBOOL bMirrY = yFact.GetNumerator() < 0;
906cdf0e10cSrcweir 
907cdf0e10cSrcweir 	if( bMirrX != bMirrY )
908cdf0e10cSrcweir 		bMirrored = !bMirrored;
909cdf0e10cSrcweir }
910cdf0e10cSrcweir 
911cdf0e10cSrcweir // -----------------------------------------------------------------------------
912cdf0e10cSrcweir 
913cdf0e10cSrcweir void SdrGrafObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
914cdf0e10cSrcweir {
915cdf0e10cSrcweir 	SdrRectObj::NbcRotate(rRef,nWink,sn,cs);
916cdf0e10cSrcweir }
917cdf0e10cSrcweir 
918cdf0e10cSrcweir // -----------------------------------------------------------------------------
919cdf0e10cSrcweir 
920cdf0e10cSrcweir void SdrGrafObj::NbcMirror(const Point& rRef1, const Point& rRef2)
921cdf0e10cSrcweir {
922cdf0e10cSrcweir 	SdrRectObj::NbcMirror(rRef1,rRef2);
923cdf0e10cSrcweir 	bMirrored = !bMirrored;
924cdf0e10cSrcweir }
925cdf0e10cSrcweir 
926cdf0e10cSrcweir // -----------------------------------------------------------------------------
927cdf0e10cSrcweir 
928cdf0e10cSrcweir void SdrGrafObj::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
929cdf0e10cSrcweir {
930*a5258243SPedro Giffuni     // #i118485# Call Shear now, old version redirected to rotate
931*a5258243SPedro Giffuni 	SdrRectObj::NbcShear(rRef, nWink, tn, bVShear);
932cdf0e10cSrcweir }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir // -----------------------------------------------------------------------------
935cdf0e10cSrcweir 
936cdf0e10cSrcweir void SdrGrafObj::NbcSetSnapRect(const Rectangle& rRect)
937cdf0e10cSrcweir {
938cdf0e10cSrcweir 	SdrRectObj::NbcSetSnapRect(rRect);
939cdf0e10cSrcweir }
940cdf0e10cSrcweir 
941cdf0e10cSrcweir // -----------------------------------------------------------------------------
942cdf0e10cSrcweir 
943cdf0e10cSrcweir void SdrGrafObj::NbcSetLogicRect( const Rectangle& rRect)
944cdf0e10cSrcweir {
945cdf0e10cSrcweir 	//int bChg=rRect.GetSize()!=aRect.GetSize();
946cdf0e10cSrcweir 	SdrRectObj::NbcSetLogicRect(rRect);
947cdf0e10cSrcweir }
948cdf0e10cSrcweir 
949cdf0e10cSrcweir // -----------------------------------------------------------------------------
950cdf0e10cSrcweir 
951cdf0e10cSrcweir SdrObjGeoData* SdrGrafObj::NewGeoData() const
952cdf0e10cSrcweir {
953cdf0e10cSrcweir 	return new SdrGrafObjGeoData;
954cdf0e10cSrcweir }
955cdf0e10cSrcweir 
956cdf0e10cSrcweir // -----------------------------------------------------------------------------
957cdf0e10cSrcweir 
958cdf0e10cSrcweir void SdrGrafObj::SaveGeoData(SdrObjGeoData& rGeo) const
959cdf0e10cSrcweir {
960cdf0e10cSrcweir 	SdrRectObj::SaveGeoData(rGeo);
961cdf0e10cSrcweir 	SdrGrafObjGeoData& rGGeo=(SdrGrafObjGeoData&)rGeo;
962cdf0e10cSrcweir 	rGGeo.bMirrored=bMirrored;
963cdf0e10cSrcweir }
964cdf0e10cSrcweir 
965cdf0e10cSrcweir // -----------------------------------------------------------------------------
966cdf0e10cSrcweir 
967cdf0e10cSrcweir void SdrGrafObj::RestGeoData(const SdrObjGeoData& rGeo)
968cdf0e10cSrcweir {
969cdf0e10cSrcweir 	//long		nDrehMerk = aGeo.nDrehWink;
970cdf0e10cSrcweir 	//long		nShearMerk = aGeo.nShearWink;
971cdf0e10cSrcweir 	//int	bMirrMerk = bMirrored;
972cdf0e10cSrcweir 	Size		aSizMerk( aRect.GetSize() );
973cdf0e10cSrcweir 
974cdf0e10cSrcweir 	SdrRectObj::RestGeoData(rGeo);
975cdf0e10cSrcweir 	SdrGrafObjGeoData& rGGeo=(SdrGrafObjGeoData&)rGeo;
976cdf0e10cSrcweir 	bMirrored=rGGeo.bMirrored;
977cdf0e10cSrcweir }
978cdf0e10cSrcweir 
979cdf0e10cSrcweir // -----------------------------------------------------------------------------
980cdf0e10cSrcweir 
981cdf0e10cSrcweir void SdrGrafObj::SetPage( SdrPage* pNewPage )
982cdf0e10cSrcweir {
983cdf0e10cSrcweir 	FASTBOOL bRemove = pNewPage == NULL && pPage != NULL;
984cdf0e10cSrcweir 	FASTBOOL bInsert = pNewPage != NULL && pPage == NULL;
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 	if( bRemove )
987cdf0e10cSrcweir 	{
988cdf0e10cSrcweir 		// hier kein SwapIn noetig, weil wenn nicht geladen, dann auch nicht animiert.
989cdf0e10cSrcweir 		if( pGraphic->IsAnimated())
990cdf0e10cSrcweir 			pGraphic->StopAnimation();
991cdf0e10cSrcweir 
992cdf0e10cSrcweir 		if( pGraphicLink != NULL )
993cdf0e10cSrcweir 			ImpLinkAbmeldung();
994cdf0e10cSrcweir 	}
995cdf0e10cSrcweir 
996cdf0e10cSrcweir 	SdrRectObj::SetPage( pNewPage );
997cdf0e10cSrcweir 
998cdf0e10cSrcweir 	if(aFileName.Len() && bInsert)
999cdf0e10cSrcweir 		ImpLinkAnmeldung();
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir // -----------------------------------------------------------------------------
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir void SdrGrafObj::SetModel( SdrModel* pNewModel )
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir 	FASTBOOL bChg = pNewModel != pModel;
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir 	if( bChg )
1009cdf0e10cSrcweir 	{
1010cdf0e10cSrcweir 		if( pGraphic->HasUserData() )
1011cdf0e10cSrcweir 		{
1012cdf0e10cSrcweir 			ForceSwapIn();
1013cdf0e10cSrcweir 			pGraphic->SetUserData();
1014cdf0e10cSrcweir 		}
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir 		if( pGraphicLink != NULL )
1017cdf0e10cSrcweir 			ImpLinkAbmeldung();
1018cdf0e10cSrcweir 	}
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 	// Model umsetzen
1021cdf0e10cSrcweir 	SdrRectObj::SetModel(pNewModel);
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 	if( bChg && aFileName.Len() )
1024cdf0e10cSrcweir 		ImpLinkAnmeldung();
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir // -----------------------------------------------------------------------------
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir void SdrGrafObj::StartAnimation( OutputDevice* /*pOutDev*/, const Point& /*rPoint*/, const Size& /*rSize*/, long /*nExtraData*/)
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir 	// #111096#
1032cdf0e10cSrcweir 	// use new graf animation
1033cdf0e10cSrcweir 	SetGrafAnimationAllowed(sal_True);
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir // -----------------------------------------------------------------------------
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir void SdrGrafObj::StopAnimation(OutputDevice* /*pOutDev*/, long /*nExtraData*/)
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir 	// #111096#
1041cdf0e10cSrcweir 	// use new graf animation
1042cdf0e10cSrcweir 	SetGrafAnimationAllowed(sal_False);
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir // -----------------------------------------------------------------------------
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir FASTBOOL SdrGrafObj::HasGDIMetaFile() const
1048cdf0e10cSrcweir {
1049cdf0e10cSrcweir 	return( pGraphic->GetType() == GRAPHIC_GDIMETAFILE );
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir // -----------------------------------------------------------------------------
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir const GDIMetaFile* SdrGrafObj::GetGDIMetaFile() const
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir 	DBG_ERROR( "Invalid return value! Don't use it! (KA)" );
1057cdf0e10cSrcweir 	return &GetGraphic().GetGDIMetaFile();
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir // -----------------------------------------------------------------------------
1061cdf0e10cSrcweir 
1062*a5258243SPedro Giffuni SdrObject* SdrGrafObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir 	SdrObject* pRetval = NULL;
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 	switch( GetGraphicType() )
1067cdf0e10cSrcweir 	{
1068cdf0e10cSrcweir 		case GRAPHIC_GDIMETAFILE:
1069cdf0e10cSrcweir 		{
1070cdf0e10cSrcweir 			// NUR die aus dem MetaFile erzeugbaren Objekte in eine Gruppe packen und zurueckliefern
1071cdf0e10cSrcweir 			ImpSdrGDIMetaFileImport aFilter(*GetModel());
1072*a5258243SPedro Giffuni 			aFilter.SetScaleRect(aRect);
1073cdf0e10cSrcweir 			aFilter.SetLayer(GetLayer());
1074cdf0e10cSrcweir 
1075*a5258243SPedro Giffuni 			SdrObjGroup* pGrp = new SdrObjGroup();
1076*a5258243SPedro Giffuni 			sal_uInt32 nInsAnz = aFilter.DoImport(GetTransformedGraphic(
1077*a5258243SPedro Giffuni                 SDRGRAFOBJ_TRANSFORMATTR_COLOR|SDRGRAFOBJ_TRANSFORMATTR_MIRROR).GetGDIMetaFile(),
1078*a5258243SPedro Giffuni                 *pGrp->GetSubList(), 0);
1079*a5258243SPedro Giffuni 
1080*a5258243SPedro Giffuni             if(nInsAnz)
1081cdf0e10cSrcweir 			{
1082*a5258243SPedro Giffuni                 {
1083*a5258243SPedro Giffuni                     // copy transformation
1084*a5258243SPedro Giffuni                 	GeoStat aGeoStat(GetGeoStat());
1085*a5258243SPedro Giffuni 
1086*a5258243SPedro Giffuni 	                if(aGeoStat.nShearWink)
1087*a5258243SPedro Giffuni                     {
1088*a5258243SPedro Giffuni                         aGeoStat.RecalcTan();
1089*a5258243SPedro Giffuni                         pGrp->NbcShear(aRect.TopLeft(), aGeoStat.nShearWink, aGeoStat.nTan, false);
1090*a5258243SPedro Giffuni                     }
1091*a5258243SPedro Giffuni 
1092*a5258243SPedro Giffuni 	                if(aGeoStat.nDrehWink)
1093*a5258243SPedro Giffuni                     {
1094*a5258243SPedro Giffuni 	                    aGeoStat.RecalcSinCos();
1095*a5258243SPedro Giffuni                         pGrp->NbcRotate(aRect.TopLeft(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos);
1096*a5258243SPedro Giffuni                     }
1097*a5258243SPedro Giffuni                 }
1098*a5258243SPedro Giffuni 
1099*a5258243SPedro Giffuni                 pRetval = pGrp;
1100cdf0e10cSrcweir 				pGrp->NbcSetLayer(GetLayer());
1101cdf0e10cSrcweir 				pGrp->SetModel(GetModel());
1102cdf0e10cSrcweir 				pRetval = ImpConvertAddText(pRetval, bBezier);
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir                 // convert all children
1105cdf0e10cSrcweir                 if( pRetval )
1106cdf0e10cSrcweir                 {
1107cdf0e10cSrcweir                     SdrObject* pHalfDone = pRetval;
1108*a5258243SPedro Giffuni                     pRetval = pHalfDone->DoConvertToPolyObj(bBezier, bAddText);
1109cdf0e10cSrcweir                     SdrObject::Free( pHalfDone ); // resulting object is newly created
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir                     if( pRetval )
1112cdf0e10cSrcweir                     {
1113cdf0e10cSrcweir                         // flatten subgroups. As we call
1114cdf0e10cSrcweir                         // DoConvertToPolyObj() on the resulting group
1115cdf0e10cSrcweir                         // objects, subgroups can exist (e.g. text is
1116cdf0e10cSrcweir                         // a group object for every line).
1117cdf0e10cSrcweir                         SdrObjList* pList = pRetval->GetSubList();
1118cdf0e10cSrcweir                         if( pList )
1119cdf0e10cSrcweir                             pList->FlattenGroups();
1120cdf0e10cSrcweir                     }
1121cdf0e10cSrcweir                 }
1122cdf0e10cSrcweir 			}
1123cdf0e10cSrcweir 			else
1124*a5258243SPedro Giffuni             {
1125cdf0e10cSrcweir 				delete pGrp;
1126*a5258243SPedro Giffuni             }
1127*a5258243SPedro Giffuni 
1128*a5258243SPedro Giffuni             // #i118485# convert line and fill
1129*a5258243SPedro Giffuni             SdrObject* pLineFill = SdrRectObj::DoConvertToPolyObj(bBezier, false);
1130*a5258243SPedro Giffuni 
1131*a5258243SPedro Giffuni             if(pLineFill)
1132*a5258243SPedro Giffuni             {
1133*a5258243SPedro Giffuni                 if(pRetval)
1134*a5258243SPedro Giffuni                 {
1135*a5258243SPedro Giffuni                     pGrp = dynamic_cast< SdrObjGroup* >(pRetval);
1136*a5258243SPedro Giffuni 
1137*a5258243SPedro Giffuni                     if(!pGrp)
1138*a5258243SPedro Giffuni                     {
1139*a5258243SPedro Giffuni             			pGrp = new SdrObjGroup();
1140*a5258243SPedro Giffuni 
1141*a5258243SPedro Giffuni                         pGrp->NbcSetLayer(GetLayer());
1142*a5258243SPedro Giffuni 				        pGrp->SetModel(GetModel());
1143*a5258243SPedro Giffuni                         pGrp->GetSubList()->NbcInsertObject(pRetval);
1144*a5258243SPedro Giffuni                     }
1145*a5258243SPedro Giffuni 
1146*a5258243SPedro Giffuni                     pGrp->GetSubList()->NbcInsertObject(pLineFill, 0);
1147*a5258243SPedro Giffuni                 }
1148*a5258243SPedro Giffuni                 else
1149*a5258243SPedro Giffuni                 {
1150*a5258243SPedro Giffuni                     pRetval = pLineFill;
1151*a5258243SPedro Giffuni                 }
1152*a5258243SPedro Giffuni             }
1153*a5258243SPedro Giffuni 
1154cdf0e10cSrcweir 			break;
1155cdf0e10cSrcweir 		}
1156cdf0e10cSrcweir 		case GRAPHIC_BITMAP:
1157cdf0e10cSrcweir 		{
1158cdf0e10cSrcweir 			// Grundobjekt kreieren und Fuellung ergaenzen
1159*a5258243SPedro Giffuni 			pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
1160cdf0e10cSrcweir 
1161cdf0e10cSrcweir 			// Bitmap als Attribut retten
1162cdf0e10cSrcweir 			if(pRetval)
1163cdf0e10cSrcweir 			{
1164cdf0e10cSrcweir 				// Bitmap als Fuellung holen
1165cdf0e10cSrcweir 				SfxItemSet aSet(GetObjectItemSet());
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir 				aSet.Put(XFillStyleItem(XFILL_BITMAP));
1168cdf0e10cSrcweir 				Bitmap aBitmap( GetTransformedGraphic().GetBitmap() );
1169cdf0e10cSrcweir 				XOBitmap aXBmp(aBitmap, XBITMAP_STRETCH);
1170cdf0e10cSrcweir 				aSet.Put(XFillBitmapItem(String(), aXBmp));
1171cdf0e10cSrcweir 				aSet.Put(XFillBmpTileItem(sal_False));
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir 				pRetval->SetMergedItemSet(aSet);
1174cdf0e10cSrcweir 			}
1175cdf0e10cSrcweir 			break;
1176cdf0e10cSrcweir 		}
1177cdf0e10cSrcweir 		case GRAPHIC_NONE:
1178cdf0e10cSrcweir 		case GRAPHIC_DEFAULT:
1179cdf0e10cSrcweir 		{
1180*a5258243SPedro Giffuni 			pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
1181cdf0e10cSrcweir 			break;
1182cdf0e10cSrcweir 		}
1183cdf0e10cSrcweir 	}
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir 	return pRetval;
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir // -----------------------------------------------------------------------------
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir void SdrGrafObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir 	SetXPolyDirty();
1193cdf0e10cSrcweir 	SdrRectObj::Notify( rBC, rHint );
1194cdf0e10cSrcweir 	ImpSetAttrToGrafInfo();
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir void SdrGrafObj::ImpSetAttrToGrafInfo()
1198cdf0e10cSrcweir {
1199cdf0e10cSrcweir 	const SfxItemSet& rSet = GetObjectItemSet();
1200cdf0e10cSrcweir 	const sal_uInt16 nTrans = ( (SdrGrafTransparenceItem&) rSet.Get( SDRATTR_GRAFTRANSPARENCE ) ).GetValue();
1201cdf0e10cSrcweir 	const SdrGrafCropItem&	rCrop = (const SdrGrafCropItem&) rSet.Get( SDRATTR_GRAFCROP );
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir 	aGrafInfo.SetLuminance( ( (SdrGrafLuminanceItem&) rSet.Get( SDRATTR_GRAFLUMINANCE ) ).GetValue() );
1204cdf0e10cSrcweir 	aGrafInfo.SetContrast( ( (SdrGrafContrastItem&) rSet.Get( SDRATTR_GRAFCONTRAST ) ).GetValue() );
1205cdf0e10cSrcweir 	aGrafInfo.SetChannelR( ( (SdrGrafRedItem&) rSet.Get( SDRATTR_GRAFRED ) ).GetValue() );
1206cdf0e10cSrcweir 	aGrafInfo.SetChannelG( ( (SdrGrafGreenItem&) rSet.Get( SDRATTR_GRAFGREEN ) ).GetValue() );
1207cdf0e10cSrcweir 	aGrafInfo.SetChannelB( ( (SdrGrafBlueItem&) rSet.Get( SDRATTR_GRAFBLUE ) ).GetValue() );
1208cdf0e10cSrcweir 	aGrafInfo.SetGamma( ( (SdrGrafGamma100Item&) rSet.Get( SDRATTR_GRAFGAMMA ) ).GetValue() * 0.01 );
1209cdf0e10cSrcweir 	aGrafInfo.SetTransparency( (sal_uInt8) FRound( Min( nTrans, (sal_uInt16) 100 )  * 2.55 ) );
1210cdf0e10cSrcweir 	aGrafInfo.SetInvert( ( (SdrGrafInvertItem&) rSet.Get( SDRATTR_GRAFINVERT ) ).GetValue() );
1211cdf0e10cSrcweir 	aGrafInfo.SetDrawMode( ( (SdrGrafModeItem&) rSet.Get( SDRATTR_GRAFMODE ) ).GetValue() );
1212cdf0e10cSrcweir 	aGrafInfo.SetCrop( rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom() );
1213cdf0e10cSrcweir 
1214cdf0e10cSrcweir 	SetXPolyDirty();
1215cdf0e10cSrcweir 	SetRectsDirty();
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir // -----------------------------------------------------------------------------
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir void SdrGrafObj::ImpSetGrafInfoToAttr()
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir 	SetObjectItem( SdrGrafLuminanceItem( aGrafInfo.GetLuminance() ) );
1223cdf0e10cSrcweir 	SetObjectItem( SdrGrafContrastItem( aGrafInfo.GetContrast() ) );
1224cdf0e10cSrcweir 	SetObjectItem( SdrGrafRedItem( aGrafInfo.GetChannelR() ) );
1225cdf0e10cSrcweir 	SetObjectItem( SdrGrafGreenItem( aGrafInfo.GetChannelG() ) );
1226cdf0e10cSrcweir 	SetObjectItem( SdrGrafBlueItem( aGrafInfo.GetChannelB() ) );
1227cdf0e10cSrcweir 	SetObjectItem( SdrGrafGamma100Item( FRound( aGrafInfo.GetGamma() * 100.0 ) ) );
1228cdf0e10cSrcweir 	SetObjectItem( SdrGrafTransparenceItem( (sal_uInt16) FRound( aGrafInfo.GetTransparency() / 2.55 ) ) );
1229cdf0e10cSrcweir 	SetObjectItem( SdrGrafInvertItem( aGrafInfo.IsInvert() ) );
1230cdf0e10cSrcweir 	SetObjectItem( SdrGrafModeItem( aGrafInfo.GetDrawMode() ) );
1231cdf0e10cSrcweir 	SetObjectItem( SdrGrafCropItem( aGrafInfo.GetLeftCrop(), aGrafInfo.GetTopCrop(), aGrafInfo.GetRightCrop(), aGrafInfo.GetBottomCrop() ) );
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir // -----------------------------------------------------------------------------
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir void SdrGrafObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly )
1237cdf0e10cSrcweir {
1238cdf0e10cSrcweir 	Size aSize;
1239cdf0e10cSrcweir 	Size aMaxSize( rMaxRect.GetSize() );
1240cdf0e10cSrcweir 	if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
1241cdf0e10cSrcweir 		aSize = Application::GetDefaultDevice()->PixelToLogic( pGraphic->GetPrefSize(), MAP_100TH_MM );
1242cdf0e10cSrcweir 	else
1243cdf0e10cSrcweir 		aSize = OutputDevice::LogicToLogic( pGraphic->GetPrefSize(),
1244cdf0e10cSrcweir 										    pGraphic->GetPrefMapMode(),
1245cdf0e10cSrcweir 										    MapMode( MAP_100TH_MM ) );
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir 	if( aSize.Height() != 0 && aSize.Width() != 0 )
1248cdf0e10cSrcweir 	{
1249cdf0e10cSrcweir 		Point aPos( rMaxRect.TopLeft() );
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir 		// Falls Grafik zu gross, wird die Grafik
1252cdf0e10cSrcweir 		// in die Seite eingepasst
1253cdf0e10cSrcweir 		if ( (!bShrinkOnly                          ||
1254cdf0e10cSrcweir 	    	 ( aSize.Height() > aMaxSize.Height() ) ||
1255cdf0e10cSrcweir 		 	( aSize.Width()  > aMaxSize.Width()  ) )&&
1256cdf0e10cSrcweir 		 	aSize.Height() && aMaxSize.Height() )
1257cdf0e10cSrcweir 		{
1258cdf0e10cSrcweir 			float fGrfWH =	(float)aSize.Width() /
1259cdf0e10cSrcweir 							(float)aSize.Height();
1260cdf0e10cSrcweir 			float fWinWH =	(float)aMaxSize.Width() /
1261cdf0e10cSrcweir 							(float)aMaxSize.Height();
1262cdf0e10cSrcweir 
1263cdf0e10cSrcweir 			// Grafik an Pagesize anpassen (skaliert)
1264cdf0e10cSrcweir 			if ( fGrfWH < fWinWH )
1265cdf0e10cSrcweir 			{
1266cdf0e10cSrcweir 				aSize.Width() = (long)(aMaxSize.Height() * fGrfWH);
1267cdf0e10cSrcweir 				aSize.Height()= aMaxSize.Height();
1268cdf0e10cSrcweir 			}
1269cdf0e10cSrcweir 			else if ( fGrfWH > 0.F )
1270cdf0e10cSrcweir 			{
1271cdf0e10cSrcweir 				aSize.Width() = aMaxSize.Width();
1272cdf0e10cSrcweir 				aSize.Height()= (long)(aMaxSize.Width() / fGrfWH);
1273cdf0e10cSrcweir 			}
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir 			aPos = rMaxRect.Center();
1276cdf0e10cSrcweir 		}
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir 		if( bShrinkOnly )
1279cdf0e10cSrcweir 			aPos = aRect.TopLeft();
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir 		aPos.X() -= aSize.Width() / 2;
1282cdf0e10cSrcweir 		aPos.Y() -= aSize.Height() / 2;
1283cdf0e10cSrcweir 		SetLogicRect( Rectangle( aPos, aSize ) );
1284cdf0e10cSrcweir 	}
1285cdf0e10cSrcweir }
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir // -----------------------------------------------------------------------------
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir 	SvStream* pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir 	if( pO->IsInSwapOut() )
1294cdf0e10cSrcweir 	{
1295cdf0e10cSrcweir 		if( pModel && !mbIsPreview && pModel->IsSwapGraphics() && pGraphic->GetSizeBytes() > 20480 )
1296cdf0e10cSrcweir 		{
1297cdf0e10cSrcweir 			// test if this object is visualized from someone
1298cdf0e10cSrcweir             // ## test only if there are VOCs other than the preview renderer
1299cdf0e10cSrcweir 			if(!GetViewContact().HasViewObjectContacts(true))
1300cdf0e10cSrcweir 			{
1301cdf0e10cSrcweir 				const sal_uIntPtr	nSwapMode = pModel->GetSwapGraphicsMode();
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir 				if( ( pGraphic->HasUserData() || pGraphicLink ) &&
1304cdf0e10cSrcweir 					( nSwapMode & SDR_SWAPGRAPHICSMODE_PURGE ) )
1305cdf0e10cSrcweir 				{
1306cdf0e10cSrcweir 					pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
1307cdf0e10cSrcweir 				}
1308cdf0e10cSrcweir 				else if( nSwapMode & SDR_SWAPGRAPHICSMODE_TEMP )
1309cdf0e10cSrcweir 				{
1310cdf0e10cSrcweir 					pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
1311cdf0e10cSrcweir 					pGraphic->SetUserData();
1312cdf0e10cSrcweir 				}
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir 				// #i102380#
1315cdf0e10cSrcweir 				sdr::contact::ViewContactOfGraphic* pVC = dynamic_cast< sdr::contact::ViewContactOfGraphic* >(&GetViewContact());
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir 				if(pVC)
1318cdf0e10cSrcweir 				{
1319cdf0e10cSrcweir 					pVC->flushGraphicObjects();
1320cdf0e10cSrcweir 				}
1321cdf0e10cSrcweir 			}
1322cdf0e10cSrcweir 		}
1323cdf0e10cSrcweir 	}
1324cdf0e10cSrcweir 	else if( pO->IsInSwapIn() )
1325cdf0e10cSrcweir 	{
1326cdf0e10cSrcweir 		// kann aus dem original Doc-Stream nachgeladen werden...
1327cdf0e10cSrcweir 		if( pModel != NULL )
1328cdf0e10cSrcweir 		{
1329cdf0e10cSrcweir 			if( pGraphic->HasUserData() )
1330cdf0e10cSrcweir 			{
1331cdf0e10cSrcweir 				SdrDocumentStreamInfo aStreamInfo;
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir 				aStreamInfo.mbDeleteAfterUse = sal_False;
1334cdf0e10cSrcweir 				aStreamInfo.maUserData = pGraphic->GetUserData();
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir 				SvStream* pStream = pModel->GetDocumentStream( aStreamInfo );
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir 				if( pStream != NULL )
1339cdf0e10cSrcweir 				{
1340cdf0e10cSrcweir 					Graphic aGraphic;
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir                     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData = NULL;
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir 					if(mbInsidePaint && !GetViewContact().HasViewObjectContacts(true))
1345cdf0e10cSrcweir                     {
1346cdf0e10cSrcweir //							Rectangle aSnapRect(GetSnapRect());
1347cdf0e10cSrcweir //							const Rectangle aSnapRectPixel(pOutDev->LogicToPixel(aSnapRect));
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir                         pFilterData = new com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >( 3 );
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir                         com::sun::star::awt::Size aPreviewSizeHint( 64, 64 );
1352cdf0e10cSrcweir                         sal_Bool bAllowPartialStreamRead = sal_True;
1353cdf0e10cSrcweir                         sal_Bool bCreateNativeLink = sal_False;
1354cdf0e10cSrcweir                         (*pFilterData)[ 0 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "PreviewSizeHint" ) );
1355cdf0e10cSrcweir                         (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
1356cdf0e10cSrcweir                         (*pFilterData)[ 1 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "AllowPartialStreamRead" ) );
1357cdf0e10cSrcweir                         (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead;
1358cdf0e10cSrcweir                         (*pFilterData)[ 2 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "CreateNativeLink" ) );
1359cdf0e10cSrcweir                         (*pFilterData)[ 2 ].Value <<= bCreateNativeLink;
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir                         mbIsPreview = sal_True;
1362cdf0e10cSrcweir                     }
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir                     if( !GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *pStream,
1365cdf0e10cSrcweir                                                         GRFILTER_FORMAT_DONTKNOW, NULL, 0, pFilterData ) )
1366cdf0e10cSrcweir                     {
1367cdf0e10cSrcweir                         const String aUserData( pGraphic->GetUserData() );
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir                         pGraphic->SetGraphic( aGraphic );
1370cdf0e10cSrcweir                         pGraphic->SetUserData( aUserData );
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir                         // #142146# Graphic successfully swapped in.
1373cdf0e10cSrcweir                         pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
1374cdf0e10cSrcweir                     }
1375cdf0e10cSrcweir                     delete pFilterData;
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir                     pStream->ResetError();
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir                     if( aStreamInfo.mbDeleteAfterUse || aStreamInfo.mxStorageRef.is() )
1380cdf0e10cSrcweir                     {
1381cdf0e10cSrcweir                         if ( aStreamInfo.mxStorageRef.is() )
1382cdf0e10cSrcweir                         {
1383cdf0e10cSrcweir                             aStreamInfo.mxStorageRef->dispose();
1384cdf0e10cSrcweir                             aStreamInfo.mxStorageRef = 0;
1385cdf0e10cSrcweir                         }
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir                         delete pStream;
1388cdf0e10cSrcweir                     }
1389cdf0e10cSrcweir                 }
1390cdf0e10cSrcweir 			}
1391cdf0e10cSrcweir 			else if( !ImpUpdateGraphicLink( sal_False ) )
1392cdf0e10cSrcweir             {
1393cdf0e10cSrcweir 				pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
1394cdf0e10cSrcweir             }
1395cdf0e10cSrcweir 			else
1396cdf0e10cSrcweir             {
1397cdf0e10cSrcweir                 pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
1398cdf0e10cSrcweir             }
1399cdf0e10cSrcweir 		}
1400cdf0e10cSrcweir 		else
1401cdf0e10cSrcweir 			pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
1402cdf0e10cSrcweir 	}
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir 	return (long)(void*) pRet;
1405cdf0e10cSrcweir }
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir // -----------------------------------------------------------------------------
1408cdf0e10cSrcweir 
1409cdf0e10cSrcweir // #111096#
1410cdf0e10cSrcweir // Access to GrafAnimationAllowed flag
1411cdf0e10cSrcweir sal_Bool SdrGrafObj::IsGrafAnimationAllowed() const
1412cdf0e10cSrcweir {
1413cdf0e10cSrcweir 	return mbGrafAnimationAllowed;
1414cdf0e10cSrcweir }
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir void SdrGrafObj::SetGrafAnimationAllowed(sal_Bool bNew)
1417cdf0e10cSrcweir {
1418cdf0e10cSrcweir 	if(mbGrafAnimationAllowed != bNew)
1419cdf0e10cSrcweir 	{
1420cdf0e10cSrcweir 		mbGrafAnimationAllowed = bNew;
1421cdf0e10cSrcweir 		ActionChanged();
1422cdf0e10cSrcweir 	}
1423cdf0e10cSrcweir }
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir // #i25616#
1426cdf0e10cSrcweir sal_Bool SdrGrafObj::IsObjectTransparent() const
1427cdf0e10cSrcweir {
1428cdf0e10cSrcweir 	if(((const SdrGrafTransparenceItem&)GetObjectItem(SDRATTR_GRAFTRANSPARENCE)).GetValue()
1429cdf0e10cSrcweir 		|| pGraphic->IsTransparent())
1430cdf0e10cSrcweir 	{
1431cdf0e10cSrcweir 		return sal_True;
1432cdf0e10cSrcweir 	}
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir 	return sal_False;
1435cdf0e10cSrcweir }
1436cdf0e10cSrcweir 
1437cdf0e10cSrcweir Reference< XInputStream > SdrGrafObj::getInputStream()
1438cdf0e10cSrcweir {
1439cdf0e10cSrcweir 	Reference< XInputStream > xStream;
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir 	if( pModel )
1442cdf0e10cSrcweir 	{
1443cdf0e10cSrcweir //		if( !pGraphic->HasUserData() )
1444cdf0e10cSrcweir //			pGraphic->SwapOut();
1445cdf0e10cSrcweir 
1446cdf0e10cSrcweir 		// kann aus dem original Doc-Stream nachgeladen werden...
1447cdf0e10cSrcweir 		if( pGraphic->HasUserData() )
1448cdf0e10cSrcweir 		{
1449cdf0e10cSrcweir 			SdrDocumentStreamInfo aStreamInfo;
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir 			aStreamInfo.mbDeleteAfterUse = sal_False;
1452cdf0e10cSrcweir 			aStreamInfo.maUserData = pGraphic->GetUserData();
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir 			SvStream* pStream = pModel->GetDocumentStream( aStreamInfo );
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir 			if( pStream )
1457cdf0e10cSrcweir 				xStream.set( new utl::OInputStreamWrapper( pStream, sal_True ) );
1458cdf0e10cSrcweir 		}
1459cdf0e10cSrcweir 		else if( pGraphic && GetGraphic().IsLink() )
1460cdf0e10cSrcweir 		{
1461cdf0e10cSrcweir 			Graphic aGraphic( GetGraphic() );
1462cdf0e10cSrcweir 			GfxLink aLink( aGraphic.GetLink() );
1463cdf0e10cSrcweir 			sal_uInt32 nSize = aLink.GetDataSize();
1464cdf0e10cSrcweir 			const void* pSourceData = (const void*)aLink.GetData();
1465cdf0e10cSrcweir 			if( nSize && pSourceData )
1466cdf0e10cSrcweir 			{
1467cdf0e10cSrcweir 				sal_uInt8 * pBuffer = new sal_uInt8[ nSize ];
1468cdf0e10cSrcweir 				if( pBuffer )
1469cdf0e10cSrcweir 				{
1470cdf0e10cSrcweir 					memcpy( pBuffer, pSourceData, nSize );
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir 					SvMemoryStream* pStream = new SvMemoryStream( (void*)pBuffer, (sal_Size)nSize, STREAM_READ );
1473cdf0e10cSrcweir 					pStream->ObjectOwnsMemory( sal_True );
1474cdf0e10cSrcweir 					xStream.set( new utl::OInputStreamWrapper( pStream, sal_True ) );
1475cdf0e10cSrcweir 				}
1476cdf0e10cSrcweir 			}
1477cdf0e10cSrcweir 		}
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir 		if( !xStream.is() && aFileName.Len() )
1480cdf0e10cSrcweir 		{
1481cdf0e10cSrcweir 			SvFileStream* pStream = new SvFileStream( aFileName, STREAM_READ );
1482cdf0e10cSrcweir 			if( pStream )
1483cdf0e10cSrcweir 				xStream.set( new utl::OInputStreamWrapper( pStream ) );
1484cdf0e10cSrcweir 		}
1485cdf0e10cSrcweir 	}
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir 	return xStream;
1488cdf0e10cSrcweir }
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir // eof
1491