xref: /AOO41X/main/svx/source/svdraw/svdograf.cxx (revision e1390266ac3390ed01f5e7bc5d6890c477f08573)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define _ANIMATION
28cdf0e10cSrcweir #include <unotools/streamwrap.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
31cdf0e10cSrcweir #include <math.h>
32cdf0e10cSrcweir #include <vcl/salbtype.hxx>
33cdf0e10cSrcweir #include <sot/formats.hxx>
34cdf0e10cSrcweir #include <sot/storage.hxx>
35cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
36cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
37cdf0e10cSrcweir #include <svl/style.hxx>
38cdf0e10cSrcweir #include <svtools/filter.hxx>
39cdf0e10cSrcweir #include <svl/urihelper.hxx>
40cdf0e10cSrcweir #include <svtools/grfmgr.hxx>
41cdf0e10cSrcweir #include <vcl/svapp.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
44cdf0e10cSrcweir #include <sfx2/docfile.hxx>
45cdf0e10cSrcweir #include <svx/svdetc.hxx>
46cdf0e10cSrcweir #include "svx/svdglob.hxx"
47cdf0e10cSrcweir #include "svx/svdstr.hrc"
48cdf0e10cSrcweir #include <svx/svdpool.hxx>
49cdf0e10cSrcweir #include <svx/svdmodel.hxx>
50cdf0e10cSrcweir #include <svx/svdpage.hxx>
51cdf0e10cSrcweir #include <svx/svdmrkv.hxx>
52cdf0e10cSrcweir #include <svx/svdpagv.hxx>
53cdf0e10cSrcweir #include "svx/svdviter.hxx"
54cdf0e10cSrcweir #include <svx/svdview.hxx>
55cdf0e10cSrcweir #include "svtools/filter.hxx"
56cdf0e10cSrcweir #include <svx/svdograf.hxx>
57cdf0e10cSrcweir #include <svx/svdogrp.hxx>
58cdf0e10cSrcweir #include <svx/xbtmpit.hxx>
59cdf0e10cSrcweir #include <svx/xflbmtit.hxx>
60cdf0e10cSrcweir #include <svx/svdundo.hxx>
61cdf0e10cSrcweir #include "svdfmtf.hxx"
62cdf0e10cSrcweir #include <svx/sdgcpitm.hxx>
63cdf0e10cSrcweir #include <editeng/eeitem.hxx>
64cdf0e10cSrcweir #include <svx/sdr/properties/graphicproperties.hxx>
65cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofgraphic.hxx>
66cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
67cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
68cdf0e10cSrcweir #include <osl/thread.hxx>
69cdf0e10cSrcweir #include <vos/mutex.hxx>
70172c67b2SArmin Le Grand #include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
71172c67b2SArmin Le Grand #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
7288b53a7cSArmin Le Grand #include <unotools/cacheoptions.hxx>
73414a0e15SArmin Le Grand #include <basegfx/matrix/b2dhommatrixtools.hxx>
74cdf0e10cSrcweir 
75cdf0e10cSrcweir using namespace ::com::sun::star::uno;
76cdf0e10cSrcweir using namespace ::com::sun::star::io;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir // -----------
79cdf0e10cSrcweir // - Defines -
80cdf0e10cSrcweir // -----------
81cdf0e10cSrcweir 
82cdf0e10cSrcweir #define GRAFSTREAMPOS_INVALID   0xffffffff
83cdf0e10cSrcweir #define SWAPGRAPHIC_TIMEOUT     5000
84cdf0e10cSrcweir 
8588b53a7cSArmin Le Grand // #122985# it is not correct to se the swap-timeout to a hard-coded 5000ms as it was before.
8688b53a7cSArmin Le Grand // Added code and experimented what to do as a good compromize, see description
getCacheTimeInMs()8788b53a7cSArmin Le Grand sal_uInt32 getCacheTimeInMs()
8888b53a7cSArmin Le Grand {
8988b53a7cSArmin Le Grand     static bool bSetAtAll(true);
9088b53a7cSArmin Le Grand 
9188b53a7cSArmin Le Grand     if(bSetAtAll)
9288b53a7cSArmin Le Grand     {
9388b53a7cSArmin Le Grand         static bool bSetToPreferenceTime(true);
9488b53a7cSArmin Le Grand 
9588b53a7cSArmin Le Grand         if(bSetToPreferenceTime)
9688b53a7cSArmin Le Grand         {
9788b53a7cSArmin Le Grand             const SvtCacheOptions aCacheOptions;
9888b53a7cSArmin Le Grand             const sal_Int32 nSeconds(aCacheOptions.GetGraphicManagerObjectReleaseTime());
9988b53a7cSArmin Le Grand 
10088b53a7cSArmin Le Grand             // the default is 10 minutes. The minimum is one minute, thus 60 seconds. When the minimum
10188b53a7cSArmin Le Grand             // should match to the former hard-coded 5 seconds, we have a divisor of 12 to use. For the
10288b53a7cSArmin Le Grand             // default of 10 minutes this would mean 50 seconds. Compared to before this is ten times
10388b53a7cSArmin Le Grand             // more (would allow better navigation by switching through pages) and is controllable
10488b53a7cSArmin Le Grand             // by the user by setting the tools/options/memory/Remove_from_memory_after setting. Seems
10588b53a7cSArmin Le Grand             // to be a good compromize to me.
10688b53a7cSArmin Le Grand             return nSeconds * 1000 / 12;
10788b53a7cSArmin Le Grand         }
10888b53a7cSArmin Le Grand         else
10988b53a7cSArmin Le Grand         {
11088b53a7cSArmin Le Grand             return SWAPGRAPHIC_TIMEOUT;
11188b53a7cSArmin Le Grand         }
11288b53a7cSArmin Le Grand     }
11388b53a7cSArmin Le Grand 
11488b53a7cSArmin Le Grand     return 0;
11588b53a7cSArmin Le Grand }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir // ------------------
118cdf0e10cSrcweir // - SdrGraphicLink	-
119cdf0e10cSrcweir // ------------------
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
ImpLoadLinkedGraphic(const String aFileName,const String aFilterName)122e6693332SEike Rathke const Graphic ImpLoadLinkedGraphic( const String aFileName, const String aFilterName )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	Graphic aGraphic;
125cdf0e10cSrcweir 
126e6693332SEike Rathke 	SfxMedium xMed( aFileName, STREAM_STD_READ, sal_True );
127cdf0e10cSrcweir 	xMed.DownLoad();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	SvStream* pInStrm = xMed.GetInStream();
130cdf0e10cSrcweir 	if ( pInStrm )
131cdf0e10cSrcweir 	{
132cdf0e10cSrcweir 		pInStrm->Seek( STREAM_SEEK_TO_BEGIN );
133cdf0e10cSrcweir 		GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
134cdf0e10cSrcweir 
135e6693332SEike Rathke 		const sal_uInt16 nFilter = aFilterName.Len() && pGF->GetImportFormatCount()
136e6693332SEike Rathke 							? pGF->GetImportFormatNumber( aFilterName )
137cdf0e10cSrcweir 							: GRFILTER_FORMAT_DONTKNOW;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aFilterData( 1 );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 		// Room for improvment:
142cdf0e10cSrcweir 		// As this is a linked graphic the GfxLink is not needed if saving/loading our own format.
143cdf0e10cSrcweir 		// But this link is required by some filters to access the native graphic (pdf export/ms export),
144cdf0e10cSrcweir 		// there we should create a new service to provide this data if needed
145cdf0e10cSrcweir 		aFilterData[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CreateNativeLink" ) );
146cdf0e10cSrcweir 		aFilterData[ 0 ].Value = Any( sal_True );
1473706bbdeSArmin Le Grand 
1483706bbdeSArmin Le Grand         // #123042# for e.g SVG the path is needed, so hand it over here. I have no real idea
1493706bbdeSArmin Le Grand         // what consequences this may have; maybe this is not handed over by purpose here. Not
1503706bbdeSArmin Le Grand         // handing it over means that any GraphicFormat that internallv needs a path as base
1513706bbdeSArmin Le Grand         // to interpret included links may fail.
1523706bbdeSArmin Le Grand         // Alternatively the path may be set at the result after this call when it is known
1533706bbdeSArmin Le Grand         // that it is a SVG graphic, but only because noone yet tried to interpret it.
1543706bbdeSArmin Le Grand         pGF->ImportGraphic( aGraphic, aFileName, *pInStrm, nFilter, NULL, 0, &aFilterData );
155cdf0e10cSrcweir 	}
156cdf0e10cSrcweir 	return aGraphic;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir class SdrGraphicUpdater;
160cdf0e10cSrcweir class SdrGraphicLink : public sfx2::SvBaseLink
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	SdrGrafObj*			pGrafObj;
163cdf0e10cSrcweir 	SdrGraphicUpdater*	pGraphicUpdater;
164cdf0e10cSrcweir 
165cdf0e10cSrcweir public:
166cdf0e10cSrcweir 						SdrGraphicLink(SdrGrafObj* pObj);
167cdf0e10cSrcweir 	virtual				~SdrGraphicLink();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	virtual void		Closed();
170cdf0e10cSrcweir 	virtual void		DataChanged( const String& rMimeType,
171cdf0e10cSrcweir 								const ::com::sun::star::uno::Any & rValue );
172cdf0e10cSrcweir 	void				DataChanged( const Graphic& rGraphic );
173cdf0e10cSrcweir 
Connect()174cdf0e10cSrcweir 	sal_Bool				Connect() { return 0 != GetRealObject(); }
175cdf0e10cSrcweir 	void				UpdateAsynchron();
176cdf0e10cSrcweir 	void				RemoveGraphicUpdater();
177cdf0e10cSrcweir };
178cdf0e10cSrcweir 
179cdf0e10cSrcweir class SdrGraphicUpdater : public ::osl::Thread
180cdf0e10cSrcweir {
181cdf0e10cSrcweir public:
182cdf0e10cSrcweir     SdrGraphicUpdater( const String& rFileName, const String& rFilterName, SdrGraphicLink& );
183cdf0e10cSrcweir     virtual ~SdrGraphicUpdater( void );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	void SAL_CALL Terminate( void );
186cdf0e10cSrcweir 
GraphicLinkChanged(const String & rFileName)187e6693332SEike Rathke     sal_Bool GraphicLinkChanged( const String& rFileName ){ return maFileName != rFileName;	};
188cdf0e10cSrcweir 
189cdf0e10cSrcweir protected:
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	/**	is called from the inherited create method and acts as the
192cdf0e10cSrcweir 		main function of this thread.
193cdf0e10cSrcweir 	*/
194cdf0e10cSrcweir 	virtual void SAL_CALL run(void);
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     /**	Called after the thread is terminated via the terminate
197cdf0e10cSrcweir     	method.  Used to kill the thread by calling delete on this.
198cdf0e10cSrcweir     */
199cdf0e10cSrcweir     virtual void SAL_CALL onTerminated(void);
200cdf0e10cSrcweir 
201cdf0e10cSrcweir private:
202cdf0e10cSrcweir 
203e6693332SEike Rathke     const String	maFileName;
204e6693332SEike Rathke 	const String	maFilterName;
205cdf0e10cSrcweir 	SdrGraphicLink& mrGraphicLink;
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	volatile bool mbIsTerminated;
208cdf0e10cSrcweir };
209cdf0e10cSrcweir 
SdrGraphicUpdater(const String & rFileName,const String & rFilterName,SdrGraphicLink & rGraphicLink)210cdf0e10cSrcweir SdrGraphicUpdater::SdrGraphicUpdater( const String& rFileName, const String& rFilterName, SdrGraphicLink& rGraphicLink )
211e6693332SEike Rathke : maFileName( rFileName )
212e6693332SEike Rathke , maFilterName( rFilterName )
213cdf0e10cSrcweir , mrGraphicLink( rGraphicLink )
214cdf0e10cSrcweir , mbIsTerminated( sal_False )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir 	create();
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
~SdrGraphicUpdater(void)219cdf0e10cSrcweir SdrGraphicUpdater::~SdrGraphicUpdater( void )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
Terminate()223cdf0e10cSrcweir void SdrGraphicUpdater::Terminate()
224cdf0e10cSrcweir {
225cdf0e10cSrcweir     mbIsTerminated = sal_True;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
onTerminated(void)228cdf0e10cSrcweir void SAL_CALL SdrGraphicUpdater::onTerminated(void)
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	delete this;
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
run(void)233cdf0e10cSrcweir void SAL_CALL SdrGraphicUpdater::run(void)
234cdf0e10cSrcweir {
235*e1390266SArrigo Marchiori 	sfx2::LinkManager *linkMgr = mrGraphicLink.GetLinkManager();
236*e1390266SArrigo Marchiori 	Graphic aGraphic;
237*e1390266SArrigo Marchiori 	if ( (linkMgr == NULL) ||
238*e1390266SArrigo Marchiori 		 ( !linkMgr->urlIsVendor( maFileName ) && ( linkMgr->GetUserAllowsLinkUpdate(NULL) ) ) ) {
239*e1390266SArrigo Marchiori 		aGraphic = ImpLoadLinkedGraphic( maFileName, maFilterName );
240*e1390266SArrigo Marchiori 	}
241cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
242cdf0e10cSrcweir 	if ( !mbIsTerminated )
243cdf0e10cSrcweir 	{
244cdf0e10cSrcweir 		mrGraphicLink.DataChanged( aGraphic );
245cdf0e10cSrcweir 		mrGraphicLink.RemoveGraphicUpdater();
246cdf0e10cSrcweir 	}
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir // -----------------------------------------------------------------------------
250cdf0e10cSrcweir 
SdrGraphicLink(SdrGrafObj * pObj)251cdf0e10cSrcweir SdrGraphicLink::SdrGraphicLink(SdrGrafObj* pObj)
252cdf0e10cSrcweir : ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, SOT_FORMATSTR_ID_SVXB )
253cdf0e10cSrcweir , pGrafObj( pObj )
254cdf0e10cSrcweir , pGraphicUpdater( NULL )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	SetSynchron( sal_False );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir // -----------------------------------------------------------------------------
260cdf0e10cSrcweir 
~SdrGraphicLink()261cdf0e10cSrcweir SdrGraphicLink::~SdrGraphicLink()
262cdf0e10cSrcweir {
263cdf0e10cSrcweir 	if ( pGraphicUpdater )
264cdf0e10cSrcweir 		pGraphicUpdater->Terminate();
265cdf0e10cSrcweir }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir // -----------------------------------------------------------------------------
268cdf0e10cSrcweir 
DataChanged(const Graphic & rGraphic)269cdf0e10cSrcweir void SdrGraphicLink::DataChanged( const Graphic& rGraphic )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir 	pGrafObj->ImpSetLinkedGraphic( rGraphic );
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir // -----------------------------------------------------------------------------
275cdf0e10cSrcweir 
RemoveGraphicUpdater()276cdf0e10cSrcweir void SdrGraphicLink::RemoveGraphicUpdater()
277cdf0e10cSrcweir {
278cdf0e10cSrcweir 	pGraphicUpdater = NULL;
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir // -----------------------------------------------------------------------------
282cdf0e10cSrcweir 
DataChanged(const String & rMimeType,const::com::sun::star::uno::Any & rValue)283cdf0e10cSrcweir void SdrGraphicLink::DataChanged( const String& rMimeType,
284cdf0e10cSrcweir 								const ::com::sun::star::uno::Any & rValue )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir 	SdrModel*       pModel      = pGrafObj ? pGrafObj->GetModel() : 0;
287cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager= pModel  ? pModel->GetLinkManager() : 0;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	if( pLinkManager && rValue.hasValue() )
290cdf0e10cSrcweir 	{
291cdf0e10cSrcweir 		pLinkManager->GetDisplayNames( this, 0, &pGrafObj->aFileName, 0, &pGrafObj->aFilterName );
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 		Graphic aGraphic;
294cdf0e10cSrcweir 		if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGraphic ))
295cdf0e10cSrcweir 		{
296cdf0e10cSrcweir    			pGrafObj->NbcSetGraphic( aGraphic );
297cdf0e10cSrcweir 			pGrafObj->ActionChanged();
298cdf0e10cSrcweir 		}
299cdf0e10cSrcweir 		else if( SotExchange::GetFormatIdFromMimeType( rMimeType ) != sfx2::LinkManager::RegisterStatusInfoId() )
300cdf0e10cSrcweir 		{
301cdf0e10cSrcweir 			// broadcasting, to update slidesorter
302cdf0e10cSrcweir 			pGrafObj->BroadcastObjectChange();
303cdf0e10cSrcweir 		}
304cdf0e10cSrcweir 	}
305cdf0e10cSrcweir }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir // -----------------------------------------------------------------------------
308cdf0e10cSrcweir 
Closed()309cdf0e10cSrcweir void SdrGraphicLink::Closed()
310cdf0e10cSrcweir {
311cdf0e10cSrcweir 	// Die Verbindung wird aufgehoben; pLink des Objekts auf NULL setzen, da die Link-Instanz ja gerade destruiert wird.
312cdf0e10cSrcweir 	pGrafObj->ForceSwapIn();
313cdf0e10cSrcweir 	pGrafObj->pGraphicLink=NULL;
314cdf0e10cSrcweir 	pGrafObj->ReleaseGraphicLink();
315cdf0e10cSrcweir 	SvBaseLink::Closed();
316cdf0e10cSrcweir }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir // -----------------------------------------------------------------------------
319cdf0e10cSrcweir 
UpdateAsynchron()320cdf0e10cSrcweir void SdrGraphicLink::UpdateAsynchron()
321cdf0e10cSrcweir {
322cdf0e10cSrcweir 	if( GetObj() )
323cdf0e10cSrcweir 	{
324cdf0e10cSrcweir 		if ( pGraphicUpdater )
325cdf0e10cSrcweir 		{
326cdf0e10cSrcweir 			if ( pGraphicUpdater->GraphicLinkChanged( pGrafObj->GetFileName() ) )
327cdf0e10cSrcweir 			{
328cdf0e10cSrcweir 				pGraphicUpdater->Terminate();
329cdf0e10cSrcweir 				pGraphicUpdater = new SdrGraphicUpdater( pGrafObj->GetFileName(), pGrafObj->GetFilterName(), *this );
330cdf0e10cSrcweir 			}
331cdf0e10cSrcweir 		}
332cdf0e10cSrcweir 		else
333cdf0e10cSrcweir 			pGraphicUpdater = new SdrGraphicUpdater( pGrafObj->GetFileName(), pGrafObj->GetFilterName(), *this );
334cdf0e10cSrcweir 	}
335cdf0e10cSrcweir }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir // --------------
338cdf0e10cSrcweir // - SdrGrafObj -
339cdf0e10cSrcweir // --------------
340cdf0e10cSrcweir 
341cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
342cdf0e10cSrcweir // BaseProperties section
343cdf0e10cSrcweir 
CreateObjectSpecificProperties()344cdf0e10cSrcweir sdr::properties::BaseProperties* SdrGrafObj::CreateObjectSpecificProperties()
345cdf0e10cSrcweir {
346cdf0e10cSrcweir 	return new sdr::properties::GraphicProperties(*this);
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
350cdf0e10cSrcweir // DrawContact section
351cdf0e10cSrcweir 
CreateObjectSpecificViewContact()352cdf0e10cSrcweir sdr::contact::ViewContact* SdrGrafObj::CreateObjectSpecificViewContact()
353cdf0e10cSrcweir {
354cdf0e10cSrcweir 	return new sdr::contact::ViewContactOfGraphic(*this);
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
358172c67b2SArmin Le Grand // check if SVG and if try to get ObjectInfoPrimitive2D and extract info
359172c67b2SArmin Le Grand 
onGraphicChanged()360172c67b2SArmin Le Grand void SdrGrafObj::onGraphicChanged()
361172c67b2SArmin Le Grand {
362172c67b2SArmin Le Grand     String aName;
363172c67b2SArmin Le Grand     String aTitle;
364172c67b2SArmin Le Grand     String aDesc;
365172c67b2SArmin Le Grand 
366172c67b2SArmin Le Grand     if(pGraphic)
367172c67b2SArmin Le Grand     {
368172c67b2SArmin Le Grand         const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData();
369172c67b2SArmin Le Grand 
370172c67b2SArmin Le Grand         if(rSvgDataPtr.get())
371172c67b2SArmin Le Grand         {
372172c67b2SArmin Le Grand             const drawinglayer::primitive2d::Primitive2DSequence aSequence(rSvgDataPtr->getPrimitive2DSequence());
373172c67b2SArmin Le Grand 
374172c67b2SArmin Le Grand             if(aSequence.hasElements())
375172c67b2SArmin Le Grand             {
376172c67b2SArmin Le Grand                 drawinglayer::geometry::ViewInformation2D aViewInformation2D;
377172c67b2SArmin Le Grand                 drawinglayer::processor2d::ObjectInfoPrimitiveExtractor2D aProcessor(aViewInformation2D);
378172c67b2SArmin Le Grand 
379172c67b2SArmin Le Grand                 aProcessor.process(aSequence);
380172c67b2SArmin Le Grand 
381172c67b2SArmin Le Grand                 const drawinglayer::primitive2d::ObjectInfoPrimitive2D* pResult = aProcessor.getResult();
382172c67b2SArmin Le Grand 
383172c67b2SArmin Le Grand                 if(pResult)
384172c67b2SArmin Le Grand                 {
385172c67b2SArmin Le Grand                     aName = pResult->getName();
386172c67b2SArmin Le Grand 			        aTitle = pResult->getTitle();
387172c67b2SArmin Le Grand 			        aDesc = pResult->getDesc();
388172c67b2SArmin Le Grand                 }
389172c67b2SArmin Le Grand             }
390172c67b2SArmin Le Grand         }
391172c67b2SArmin Le Grand     }
392172c67b2SArmin Le Grand 
393172c67b2SArmin Le Grand     if(aName.Len())
394172c67b2SArmin Le Grand     {
395172c67b2SArmin Le Grand         SetName(aName);
396172c67b2SArmin Le Grand     }
397172c67b2SArmin Le Grand 
398172c67b2SArmin Le Grand     if(aTitle.Len())
399172c67b2SArmin Le Grand     {
400172c67b2SArmin Le Grand     	SetTitle(aTitle);
401172c67b2SArmin Le Grand     }
402172c67b2SArmin Le Grand 
403172c67b2SArmin Le Grand     if(aDesc.Len())
404172c67b2SArmin Le Grand     {
405172c67b2SArmin Le Grand     	SetDescription(aDesc);
406172c67b2SArmin Le Grand     }
407172c67b2SArmin Le Grand }
408172c67b2SArmin Le Grand 
409172c67b2SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
410cdf0e10cSrcweir 
411cdf0e10cSrcweir TYPEINIT1(SdrGrafObj,SdrRectObj);
412cdf0e10cSrcweir 
413cdf0e10cSrcweir // -----------------------------------------------------------------------------
414cdf0e10cSrcweir 
SdrGrafObj()415cdf0e10cSrcweir SdrGrafObj::SdrGrafObj()
416cdf0e10cSrcweir :	SdrRectObj(),
417cdf0e10cSrcweir 	pGraphicLink	( NULL ),
418cdf0e10cSrcweir 	bMirrored		( sal_False )
419cdf0e10cSrcweir {
420cdf0e10cSrcweir 	pGraphic = new GraphicObject;
421ddde725dSArmin Le Grand     mpReplacementGraphic = 0;
42288b53a7cSArmin Le Grand 	pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
423172c67b2SArmin Le Grand     onGraphicChanged();
424a5258243SPedro Giffuni 
425a5258243SPedro Giffuni     // #i118485# Shear allowed and possible now
426a5258243SPedro Giffuni     bNoShear = false;
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 	// #111096#
429cdf0e10cSrcweir 	mbGrafAnimationAllowed = sal_True;
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 	// #i25616#
432cdf0e10cSrcweir 	mbLineIsOutsideGeometry = sal_True;
433cdf0e10cSrcweir 	mbInsidePaint = sal_False;
434cdf0e10cSrcweir 	mbIsPreview = sal_False;
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 	// #i25616#
437cdf0e10cSrcweir 	mbSupportTextIndentingOnLineWidthChange = sal_False;
438cdf0e10cSrcweir }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir // -----------------------------------------------------------------------------
441cdf0e10cSrcweir 
SdrGrafObj(const Graphic & rGrf,const Rectangle & rRect)442cdf0e10cSrcweir SdrGrafObj::SdrGrafObj(const Graphic& rGrf, const Rectangle& rRect)
443cdf0e10cSrcweir :	SdrRectObj		( rRect ),
444cdf0e10cSrcweir 	pGraphicLink	( NULL ),
445cdf0e10cSrcweir 	bMirrored		( sal_False )
446cdf0e10cSrcweir {
447cdf0e10cSrcweir 	pGraphic = new GraphicObject( rGrf );
448ddde725dSArmin Le Grand     mpReplacementGraphic = 0;
44988b53a7cSArmin Le Grand 	pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
450172c67b2SArmin Le Grand     onGraphicChanged();
451a5258243SPedro Giffuni 
452a5258243SPedro Giffuni     // #i118485# Shear allowed and possible now
453a5258243SPedro Giffuni     bNoShear = false;
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 	// #111096#
456cdf0e10cSrcweir 	mbGrafAnimationAllowed = sal_True;
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 	// #i25616#
459cdf0e10cSrcweir 	mbLineIsOutsideGeometry = sal_True;
460cdf0e10cSrcweir 	mbInsidePaint = sal_False;
461cdf0e10cSrcweir 	mbIsPreview	= sal_False;
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 	// #i25616#
464cdf0e10cSrcweir 	mbSupportTextIndentingOnLineWidthChange = sal_False;
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir // -----------------------------------------------------------------------------
468cdf0e10cSrcweir 
SdrGrafObj(const Graphic & rGrf)469cdf0e10cSrcweir SdrGrafObj::SdrGrafObj( const Graphic& rGrf )
470cdf0e10cSrcweir :	SdrRectObj(),
471cdf0e10cSrcweir 	pGraphicLink	( NULL ),
472cdf0e10cSrcweir 	bMirrored		( sal_False )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	pGraphic = new GraphicObject( rGrf );
475ddde725dSArmin Le Grand     mpReplacementGraphic = 0;
47688b53a7cSArmin Le Grand 	pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
477172c67b2SArmin Le Grand     onGraphicChanged();
478a5258243SPedro Giffuni 
479a5258243SPedro Giffuni     // #i118485# Shear allowed and possible now
480a5258243SPedro Giffuni     bNoShear = false;
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 	// #111096#
483cdf0e10cSrcweir 	mbGrafAnimationAllowed = sal_True;
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	// #i25616#
486cdf0e10cSrcweir 	mbLineIsOutsideGeometry = sal_True;
487cdf0e10cSrcweir 	mbInsidePaint = sal_False;
488cdf0e10cSrcweir 	mbIsPreview	= sal_False;
489cdf0e10cSrcweir 
490cdf0e10cSrcweir 	// #i25616#
491cdf0e10cSrcweir 	mbSupportTextIndentingOnLineWidthChange = sal_False;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
494cdf0e10cSrcweir // -----------------------------------------------------------------------------
495cdf0e10cSrcweir 
~SdrGrafObj()496cdf0e10cSrcweir SdrGrafObj::~SdrGrafObj()
497cdf0e10cSrcweir {
498cdf0e10cSrcweir 	delete pGraphic;
499ddde725dSArmin Le Grand     delete mpReplacementGraphic;
500cdf0e10cSrcweir 	ImpLinkAbmeldung();
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir // -----------------------------------------------------------------------------
504cdf0e10cSrcweir 
SetGraphicObject(const GraphicObject & rGrfObj)505cdf0e10cSrcweir void SdrGrafObj::SetGraphicObject( const GraphicObject& rGrfObj )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir 	*pGraphic = rGrfObj;
508ddde725dSArmin Le Grand     delete mpReplacementGraphic;
509ddde725dSArmin Le Grand     mpReplacementGraphic = 0;
51088b53a7cSArmin Le Grand 	pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
511cdf0e10cSrcweir 	pGraphic->SetUserData();
512cdf0e10cSrcweir 	mbIsPreview = sal_False;
513cdf0e10cSrcweir 	SetChanged();
514cdf0e10cSrcweir 	BroadcastObjectChange();
515172c67b2SArmin Le Grand     onGraphicChanged();
516cdf0e10cSrcweir }
517cdf0e10cSrcweir 
518cdf0e10cSrcweir // -----------------------------------------------------------------------------
519cdf0e10cSrcweir 
GetGraphicObject(bool bForceSwapIn) const520cdf0e10cSrcweir const GraphicObject& SdrGrafObj::GetGraphicObject(bool bForceSwapIn) const
521cdf0e10cSrcweir {
522cdf0e10cSrcweir 	if(bForceSwapIn)
523cdf0e10cSrcweir 	{
524cdf0e10cSrcweir 		ForceSwapIn();
525cdf0e10cSrcweir 	}
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 	return *pGraphic;
528cdf0e10cSrcweir }
529cdf0e10cSrcweir 
GetReplacementGraphicObject() const530ddde725dSArmin Le Grand const GraphicObject* SdrGrafObj::GetReplacementGraphicObject() const
531ddde725dSArmin Le Grand {
532ddde725dSArmin Le Grand     if(!mpReplacementGraphic && pGraphic)
533ddde725dSArmin Le Grand     {
534ddde725dSArmin Le Grand         const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData();
535ddde725dSArmin Le Grand 
536ddde725dSArmin Le Grand         if(rSvgDataPtr.get())
537ddde725dSArmin Le Grand         {
538ddde725dSArmin Le Grand             const_cast< SdrGrafObj* >(this)->mpReplacementGraphic = new GraphicObject(rSvgDataPtr->getReplacement());
539ddde725dSArmin Le Grand         }
540ddde725dSArmin Le Grand     }
541ddde725dSArmin Le Grand 
542ddde725dSArmin Le Grand     return mpReplacementGraphic;
543ddde725dSArmin Le Grand }
544ddde725dSArmin Le Grand 
545cdf0e10cSrcweir // -----------------------------------------------------------------------------
546cdf0e10cSrcweir 
NbcSetGraphic(const Graphic & rGrf)547cdf0e10cSrcweir void SdrGrafObj::NbcSetGraphic( const Graphic& rGrf )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir 	pGraphic->SetGraphic( rGrf );
550ddde725dSArmin Le Grand     delete mpReplacementGraphic;
551ddde725dSArmin Le Grand     mpReplacementGraphic = 0;
552cdf0e10cSrcweir 	pGraphic->SetUserData();
553cdf0e10cSrcweir 	mbIsPreview = sal_False;
554172c67b2SArmin Le Grand     onGraphicChanged();
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
SetGraphic(const Graphic & rGrf)557cdf0e10cSrcweir void SdrGrafObj::SetGraphic( const Graphic& rGrf )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir     NbcSetGraphic(rGrf);
560cdf0e10cSrcweir 	SetChanged();
561cdf0e10cSrcweir 	BroadcastObjectChange();
562cdf0e10cSrcweir }
563cdf0e10cSrcweir 
564cdf0e10cSrcweir // -----------------------------------------------------------------------------
565cdf0e10cSrcweir 
GetGraphic() const566cdf0e10cSrcweir const Graphic& SdrGrafObj::GetGraphic() const
567cdf0e10cSrcweir {
568cdf0e10cSrcweir 	ForceSwapIn();
569cdf0e10cSrcweir 	return pGraphic->GetGraphic();
570cdf0e10cSrcweir }
571cdf0e10cSrcweir 
572cdf0e10cSrcweir // -----------------------------------------------------------------------------
573cdf0e10cSrcweir 
GetTransformedGraphic(sal_uIntPtr nTransformFlags) const574cdf0e10cSrcweir Graphic SdrGrafObj::GetTransformedGraphic( sal_uIntPtr nTransformFlags ) const
575cdf0e10cSrcweir {
576cdf0e10cSrcweir     // #107947# Refactored most of the code to GraphicObject, where
577cdf0e10cSrcweir     // everybody can use e.g. the cropping functionality
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 	GraphicType	    eType = GetGraphicType();
580cdf0e10cSrcweir     MapMode   		aDestMap( pModel->GetScaleUnit(), Point(), pModel->GetScaleFraction(), pModel->GetScaleFraction() );
581cdf0e10cSrcweir     const Size      aDestSize( GetLogicRect().GetSize() );
582cdf0e10cSrcweir     const sal_Bool      bMirror = ( nTransformFlags & SDRGRAFOBJ_TRANSFORMATTR_MIRROR ) != 0;
583cdf0e10cSrcweir     const sal_Bool      bRotate = ( ( nTransformFlags & SDRGRAFOBJ_TRANSFORMATTR_ROTATE ) != 0 ) &&
584cdf0e10cSrcweir         ( aGeo.nDrehWink && aGeo.nDrehWink != 18000 ) && ( GRAPHIC_NONE != eType );
585cdf0e10cSrcweir 
586cdf0e10cSrcweir     // #104115# Need cropping info earlier
587cdf0e10cSrcweir     ( (SdrGrafObj*) this )->ImpSetAttrToGrafInfo();
588cdf0e10cSrcweir     GraphicAttr aActAttr;
589cdf0e10cSrcweir 
590cdf0e10cSrcweir 	if( SDRGRAFOBJ_TRANSFORMATTR_NONE != nTransformFlags &&
591cdf0e10cSrcweir         GRAPHIC_NONE != eType )
592cdf0e10cSrcweir 	{
593cdf0e10cSrcweir         // actually transform the graphic only in this case. On the
594cdf0e10cSrcweir         // other hand, cropping will always happen
595cdf0e10cSrcweir         aActAttr = aGrafInfo;
596cdf0e10cSrcweir 
597cdf0e10cSrcweir         if( bMirror )
598cdf0e10cSrcweir 		{
599cdf0e10cSrcweir 			sal_uInt16		nMirrorCase = ( aGeo.nDrehWink == 18000 ) ? ( bMirrored ? 3 : 4 ) : ( bMirrored ? 2 : 1 );
600cdf0e10cSrcweir 			FASTBOOL	bHMirr = nMirrorCase == 2 || nMirrorCase == 4;
601cdf0e10cSrcweir 			FASTBOOL	bVMirr = nMirrorCase == 3 || nMirrorCase == 4;
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 			aActAttr.SetMirrorFlags( ( bHMirr ? BMP_MIRROR_HORZ : 0 ) | ( bVMirr ? BMP_MIRROR_VERT : 0 ) );
604cdf0e10cSrcweir 		}
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 		if( bRotate )
607cdf0e10cSrcweir 			aActAttr.SetRotation( sal_uInt16(aGeo.nDrehWink / 10) );
608cdf0e10cSrcweir 	}
609cdf0e10cSrcweir 
610cdf0e10cSrcweir     // #107947# Delegate to moved code in GraphicObject
611cdf0e10cSrcweir     return GetGraphicObject().GetTransformedGraphic( aDestSize, aDestMap, aActAttr );
612cdf0e10cSrcweir }
613cdf0e10cSrcweir 
614cdf0e10cSrcweir // -----------------------------------------------------------------------------
615cdf0e10cSrcweir 
GetGraphicType() const616cdf0e10cSrcweir GraphicType SdrGrafObj::GetGraphicType() const
617cdf0e10cSrcweir {
618cdf0e10cSrcweir 	return pGraphic->GetType();
619cdf0e10cSrcweir }
620cdf0e10cSrcweir 
IsAnimated() const621cdf0e10cSrcweir sal_Bool SdrGrafObj::IsAnimated() const
622cdf0e10cSrcweir {
623cdf0e10cSrcweir 	return pGraphic->IsAnimated();
624cdf0e10cSrcweir }
625cdf0e10cSrcweir 
IsEPS() const626cdf0e10cSrcweir sal_Bool SdrGrafObj::IsEPS() const
627cdf0e10cSrcweir {
628cdf0e10cSrcweir 	return pGraphic->IsEPS();
629cdf0e10cSrcweir }
630cdf0e10cSrcweir 
IsSwappedOut() const631cdf0e10cSrcweir sal_Bool SdrGrafObj::IsSwappedOut() const
632cdf0e10cSrcweir {
633cdf0e10cSrcweir 	return mbIsPreview ? sal_True : pGraphic->IsSwappedOut();
634cdf0e10cSrcweir }
635cdf0e10cSrcweir 
GetGrafPrefMapMode() const636cdf0e10cSrcweir const MapMode& SdrGrafObj::GetGrafPrefMapMode() const
637cdf0e10cSrcweir {
638cdf0e10cSrcweir 	return pGraphic->GetPrefMapMode();
639cdf0e10cSrcweir }
640cdf0e10cSrcweir 
GetGrafPrefSize() const641cdf0e10cSrcweir const Size& SdrGrafObj::GetGrafPrefSize() const
642cdf0e10cSrcweir {
643cdf0e10cSrcweir 	return pGraphic->GetPrefSize();
644cdf0e10cSrcweir }
645cdf0e10cSrcweir 
646cdf0e10cSrcweir // -----------------------------------------------------------------------------
647cdf0e10cSrcweir 
SetGrafStreamURL(const String & rGraphicStreamURL)648cdf0e10cSrcweir void SdrGrafObj::SetGrafStreamURL( const String& rGraphicStreamURL )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir 	mbIsPreview = sal_False;
651cdf0e10cSrcweir 	if( !rGraphicStreamURL.Len() )
652cdf0e10cSrcweir 	{
653cdf0e10cSrcweir 		pGraphic->SetUserData();
654cdf0e10cSrcweir 	}
655cdf0e10cSrcweir 	else if( pModel->IsSwapGraphics() )
656cdf0e10cSrcweir 	{
657cdf0e10cSrcweir 		pGraphic->SetUserData( rGraphicStreamURL );
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 		// set state of graphic object to 'swapped out'
660cdf0e10cSrcweir 		if( pGraphic->GetType() == GRAPHIC_NONE )
661cdf0e10cSrcweir 			pGraphic->SetSwapState();
662cdf0e10cSrcweir 	}
663cdf0e10cSrcweir }
664cdf0e10cSrcweir 
665cdf0e10cSrcweir // -----------------------------------------------------------------------------
666cdf0e10cSrcweir 
GetGrafStreamURL() const667cdf0e10cSrcweir String SdrGrafObj::GetGrafStreamURL() const
668cdf0e10cSrcweir {
669cdf0e10cSrcweir 	return pGraphic->GetUserData();
670cdf0e10cSrcweir }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir // -----------------------------------------------------------------------------
673cdf0e10cSrcweir 
SetFileName(const String & rFileName)674cdf0e10cSrcweir void SdrGrafObj::SetFileName(const String& rFileName)
675cdf0e10cSrcweir {
676cdf0e10cSrcweir 	aFileName = rFileName;
677cdf0e10cSrcweir 	SetChanged();
678cdf0e10cSrcweir }
679cdf0e10cSrcweir 
680cdf0e10cSrcweir // -----------------------------------------------------------------------------
681cdf0e10cSrcweir 
SetFilterName(const String & rFilterName)682cdf0e10cSrcweir void SdrGrafObj::SetFilterName(const String& rFilterName)
683cdf0e10cSrcweir {
684cdf0e10cSrcweir 	aFilterName = rFilterName;
685cdf0e10cSrcweir 	SetChanged();
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
688cdf0e10cSrcweir // -----------------------------------------------------------------------------
689cdf0e10cSrcweir 
ForceSwapIn() const690cdf0e10cSrcweir void SdrGrafObj::ForceSwapIn() const
691cdf0e10cSrcweir {
692cdf0e10cSrcweir 	if( mbIsPreview )
693cdf0e10cSrcweir 	{
694cdf0e10cSrcweir 		// removing preview graphic
695cdf0e10cSrcweir 		const String aUserData( pGraphic->GetUserData() );
696cdf0e10cSrcweir 
697cdf0e10cSrcweir 		Graphic aEmpty;
698cdf0e10cSrcweir 		pGraphic->SetGraphic( aEmpty );
699cdf0e10cSrcweir 		pGraphic->SetUserData( aUserData );
700cdf0e10cSrcweir 		pGraphic->SetSwapState();
701cdf0e10cSrcweir 
702cdf0e10cSrcweir 		const_cast< SdrGrafObj* >( this )->mbIsPreview = sal_False;
703cdf0e10cSrcweir 	}
704cdf0e10cSrcweir 	if ( pGraphicLink && pGraphic->IsSwappedOut() )
705cdf0e10cSrcweir 		ImpUpdateGraphicLink( sal_False );
706cdf0e10cSrcweir 	else
707cdf0e10cSrcweir 		pGraphic->FireSwapInRequest();
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 	if( pGraphic->IsSwappedOut() ||
710cdf0e10cSrcweir 	    ( pGraphic->GetType() == GRAPHIC_NONE ) ||
711cdf0e10cSrcweir 		( pGraphic->GetType() == GRAPHIC_DEFAULT ) )
712cdf0e10cSrcweir 	{
713cdf0e10cSrcweir 		Graphic aDefaultGraphic;
714cdf0e10cSrcweir 		aDefaultGraphic.SetDefaultType();
715cdf0e10cSrcweir 		pGraphic->SetGraphic( aDefaultGraphic );
716cdf0e10cSrcweir 	}
717cdf0e10cSrcweir }
718cdf0e10cSrcweir 
719cdf0e10cSrcweir // -----------------------------------------------------------------------------
720cdf0e10cSrcweir 
ForceSwapOut() const721cdf0e10cSrcweir void SdrGrafObj::ForceSwapOut() const
722cdf0e10cSrcweir {
723cdf0e10cSrcweir 	pGraphic->FireSwapOutRequest();
724cdf0e10cSrcweir }
725cdf0e10cSrcweir 
726cdf0e10cSrcweir // -----------------------------------------------------------------------------
727cdf0e10cSrcweir 
ImpLinkAnmeldung()728cdf0e10cSrcweir void SdrGrafObj::ImpLinkAnmeldung()
729cdf0e10cSrcweir {
730cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL;
731cdf0e10cSrcweir 
732cdf0e10cSrcweir 	if( pLinkManager != NULL && pGraphicLink == NULL )
733cdf0e10cSrcweir 	{
734cdf0e10cSrcweir 		if( aFileName.Len() )
735cdf0e10cSrcweir 		{
736cdf0e10cSrcweir 			pGraphicLink = new SdrGraphicLink( this );
737cdf0e10cSrcweir 			pLinkManager->InsertFileLink( *pGraphicLink, OBJECT_CLIENT_GRF, aFileName, ( aFilterName.Len() ? &aFilterName : NULL ), NULL );
738cdf0e10cSrcweir 			pGraphicLink->Connect();
739cdf0e10cSrcweir 		}
740cdf0e10cSrcweir 	}
741cdf0e10cSrcweir }
742cdf0e10cSrcweir 
743cdf0e10cSrcweir // -----------------------------------------------------------------------------
744cdf0e10cSrcweir 
ImpLinkAbmeldung()745cdf0e10cSrcweir void SdrGrafObj::ImpLinkAbmeldung()
746cdf0e10cSrcweir {
747cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL;
748cdf0e10cSrcweir 
749cdf0e10cSrcweir 	if( pLinkManager != NULL && pGraphicLink!=NULL)
750cdf0e10cSrcweir 	{
751cdf0e10cSrcweir 		// Bei Remove wird *pGraphicLink implizit deleted
752cdf0e10cSrcweir 		pLinkManager->Remove( pGraphicLink );
753cdf0e10cSrcweir 		pGraphicLink=NULL;
754cdf0e10cSrcweir 	}
755cdf0e10cSrcweir }
756cdf0e10cSrcweir 
757cdf0e10cSrcweir // -----------------------------------------------------------------------------
758cdf0e10cSrcweir 
SetGraphicLink(const String & rFileName,const String & rFilterName)759cdf0e10cSrcweir void SdrGrafObj::SetGraphicLink( const String& rFileName, const String& rFilterName )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir 	ImpLinkAbmeldung();
762cdf0e10cSrcweir 	aFileName = rFileName;
763cdf0e10cSrcweir 	aFilterName = rFilterName;
764cdf0e10cSrcweir 	ImpLinkAnmeldung();
765cdf0e10cSrcweir 	pGraphic->SetUserData();
766cdf0e10cSrcweir 
767cdf0e10cSrcweir     // #92205# A linked graphic is per definition swapped out (has to be loaded)
768cdf0e10cSrcweir     pGraphic->SetSwapState();
769cdf0e10cSrcweir }
770cdf0e10cSrcweir 
771cdf0e10cSrcweir // -----------------------------------------------------------------------------
772cdf0e10cSrcweir 
ReleaseGraphicLink()773cdf0e10cSrcweir void SdrGrafObj::ReleaseGraphicLink()
774cdf0e10cSrcweir {
775cdf0e10cSrcweir 	ImpLinkAbmeldung();
776cdf0e10cSrcweir 	aFileName = String();
777cdf0e10cSrcweir 	aFilterName = String();
778cdf0e10cSrcweir }
779cdf0e10cSrcweir 
780cdf0e10cSrcweir // -----------------------------------------------------------------------------
781cdf0e10cSrcweir 
TakeObjInfo(SdrObjTransformInfoRec & rInfo) const782cdf0e10cSrcweir void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
783cdf0e10cSrcweir {
784cdf0e10cSrcweir 	FASTBOOL bNoPresGrf = ( pGraphic->GetType() != GRAPHIC_NONE ) && !bEmptyPresObj;
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 	rInfo.bResizeFreeAllowed = aGeo.nDrehWink % 9000 == 0 ||
787cdf0e10cSrcweir 							   aGeo.nDrehWink % 18000 == 0 ||
788cdf0e10cSrcweir 							   aGeo.nDrehWink % 27000 == 0;
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 	rInfo.bResizePropAllowed = sal_True;
7915f27b83cSArmin Le Grand 	rInfo.bRotateFreeAllowed = bNoPresGrf;
7925f27b83cSArmin Le Grand 	rInfo.bRotate90Allowed = bNoPresGrf;
7935f27b83cSArmin Le Grand 	rInfo.bMirrorFreeAllowed = bNoPresGrf;
7945f27b83cSArmin Le Grand 	rInfo.bMirror45Allowed = bNoPresGrf;
795ddde725dSArmin Le Grand 	rInfo.bMirror90Allowed = !bEmptyPresObj;
796cdf0e10cSrcweir 	rInfo.bTransparenceAllowed = sal_False;
797cdf0e10cSrcweir 	rInfo.bGradientAllowed = sal_False;
798a5258243SPedro Giffuni 
799a5258243SPedro Giffuni     // #i118485# Shear allowed and possible now
800a5258243SPedro Giffuni 	rInfo.bShearAllowed = true;
801a5258243SPedro Giffuni 
802cdf0e10cSrcweir     rInfo.bEdgeRadiusAllowed=sal_False;
803ddde725dSArmin Le Grand 	rInfo.bCanConvToPath = !IsEPS();
804cdf0e10cSrcweir 	rInfo.bCanConvToPathLineToArea = sal_False;
805cdf0e10cSrcweir 	rInfo.bCanConvToPolyLineToArea = sal_False;
806ddde725dSArmin Le Grand 	rInfo.bCanConvToPoly = !IsEPS();
807cdf0e10cSrcweir 	rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
808cdf0e10cSrcweir }
809cdf0e10cSrcweir 
810cdf0e10cSrcweir // -----------------------------------------------------------------------------
811cdf0e10cSrcweir 
GetObjIdentifier() const812cdf0e10cSrcweir sal_uInt16 SdrGrafObj::GetObjIdentifier() const
813cdf0e10cSrcweir {
814cdf0e10cSrcweir 	return sal_uInt16( OBJ_GRAF );
815cdf0e10cSrcweir }
816cdf0e10cSrcweir 
817cdf0e10cSrcweir // -----------------------------------------------------------------------------
818cdf0e10cSrcweir 
819cdf0e10cSrcweir /* The graphic of the GraphicLink will be loaded. If it is called with
820cdf0e10cSrcweir    bAsynchron = true then the graphic will be set later via DataChanged
821cdf0e10cSrcweir */
ImpUpdateGraphicLink(sal_Bool bAsynchron) const822cdf0e10cSrcweir sal_Bool SdrGrafObj::ImpUpdateGraphicLink( sal_Bool bAsynchron ) const
823cdf0e10cSrcweir {
824cdf0e10cSrcweir     sal_Bool bRet = sal_False;
825cdf0e10cSrcweir     if( pGraphicLink )
826cdf0e10cSrcweir 	{
827f8c074b1SArrigo Marchiori         sfx2::LinkManager *linkMgr = pGraphicLink->GetLinkManager();
828*e1390266SArrigo Marchiori         if ( (linkMgr == NULL) ||
829*e1390266SArrigo Marchiori              ( !linkMgr->urlIsVendor( aFileName ) && ( linkMgr->GetUserAllowsLinkUpdate(NULL) ) ) ) {
830cdf0e10cSrcweir             if ( bAsynchron )
831cdf0e10cSrcweir                 pGraphicLink->UpdateAsynchron();
832cdf0e10cSrcweir             else
833cdf0e10cSrcweir                 pGraphicLink->DataChanged( ImpLoadLinkedGraphic( aFileName, aFilterName ) );
834f8c074b1SArrigo Marchiori         } // else links shall not be updated
835cdf0e10cSrcweir         bRet = sal_True;
836cdf0e10cSrcweir     }
837cdf0e10cSrcweir 	return bRet;
838cdf0e10cSrcweir }
839cdf0e10cSrcweir 
840cdf0e10cSrcweir // -----------------------------------------------------------------------------
841cdf0e10cSrcweir 
ImpSetLinkedGraphic(const Graphic & rGraphic)842cdf0e10cSrcweir void SdrGrafObj::ImpSetLinkedGraphic( const Graphic& rGraphic )
843cdf0e10cSrcweir {
844cdf0e10cSrcweir 	const sal_Bool bIsChanged = GetModel()->IsChanged();
845cdf0e10cSrcweir 	NbcSetGraphic( rGraphic );
846cdf0e10cSrcweir 	ActionChanged();
847cdf0e10cSrcweir 	BroadcastObjectChange();
848cdf0e10cSrcweir 	GetModel()->SetChanged( bIsChanged );
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
851cdf0e10cSrcweir // -----------------------------------------------------------------------------
852cdf0e10cSrcweir 
TakeObjNameSingul(XubString & rName) const853cdf0e10cSrcweir void SdrGrafObj::TakeObjNameSingul(XubString& rName) const
854cdf0e10cSrcweir {
855ddde725dSArmin Le Grand     if(pGraphic)
856ddde725dSArmin Le Grand     {
857ddde725dSArmin Le Grand         const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData();
858ddde725dSArmin Le Grand 
859ddde725dSArmin Le Grand         if(rSvgDataPtr.get())
860ddde725dSArmin Le Grand         {
861ddde725dSArmin Le Grand             rName = ImpGetResStr(STR_ObjNameSingulGRAFSVG);
862ddde725dSArmin Le Grand         }
863ddde725dSArmin Le Grand         else
864ddde725dSArmin Le Grand         {
865cdf0e10cSrcweir 	        switch( pGraphic->GetType() )
866cdf0e10cSrcweir 	        {
867cdf0e10cSrcweir 		        case GRAPHIC_BITMAP:
868cdf0e10cSrcweir                 {
869cdf0e10cSrcweir                     const sal_uInt16 nId = ( ( pGraphic->IsTransparent() || ( (const SdrGrafTransparenceItem&) GetObjectItem( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ) ?
870cdf0e10cSrcweir                                          ( IsLinkedGraphic() ? STR_ObjNameSingulGRAFBMPTRANSLNK : STR_ObjNameSingulGRAFBMPTRANS ) :
871cdf0e10cSrcweir                                          ( IsLinkedGraphic() ? STR_ObjNameSingulGRAFBMPLNK : STR_ObjNameSingulGRAFBMP ) );
872cdf0e10cSrcweir 
873cdf0e10cSrcweir                     rName=ImpGetResStr( nId );
874cdf0e10cSrcweir                 }
875cdf0e10cSrcweir                 break;
876cdf0e10cSrcweir 
877cdf0e10cSrcweir 		        case GRAPHIC_GDIMETAFILE:
878cdf0e10cSrcweir                     rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFMTFLNK : STR_ObjNameSingulGRAFMTF );
879cdf0e10cSrcweir                 break;
880cdf0e10cSrcweir 
881cdf0e10cSrcweir                 case GRAPHIC_NONE:
882cdf0e10cSrcweir                     rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFNONELNK : STR_ObjNameSingulGRAFNONE );
883cdf0e10cSrcweir                 break;
884cdf0e10cSrcweir 
885cdf0e10cSrcweir                 default:
886cdf0e10cSrcweir                     rName=ImpGetResStr(  IsLinkedGraphic() ? STR_ObjNameSingulGRAFLNK : STR_ObjNameSingulGRAF );
887cdf0e10cSrcweir                 break;
888cdf0e10cSrcweir 	        }
889ddde725dSArmin Le Grand         }
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 	    const String aName(GetName());
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 	    if( aName.Len() )
894cdf0e10cSrcweir 	    {
895cdf0e10cSrcweir 		    rName.AppendAscii( " '" );
896cdf0e10cSrcweir 		    rName += aName;
897cdf0e10cSrcweir 		    rName += sal_Unicode( '\'' );
898cdf0e10cSrcweir 	    }
899cdf0e10cSrcweir     }
900ddde725dSArmin Le Grand }
901cdf0e10cSrcweir 
902cdf0e10cSrcweir // -----------------------------------------------------------------------------
903cdf0e10cSrcweir 
TakeObjNamePlural(XubString & rName) const904cdf0e10cSrcweir void SdrGrafObj::TakeObjNamePlural( XubString& rName ) const
905cdf0e10cSrcweir {
906ddde725dSArmin Le Grand     if(pGraphic)
907ddde725dSArmin Le Grand     {
908ddde725dSArmin Le Grand         const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData();
909ddde725dSArmin Le Grand 
910ddde725dSArmin Le Grand         if(rSvgDataPtr.get())
911ddde725dSArmin Le Grand         {
912ddde725dSArmin Le Grand             rName = ImpGetResStr(STR_ObjNamePluralGRAFSVG);
913ddde725dSArmin Le Grand         }
914ddde725dSArmin Le Grand         else
915ddde725dSArmin Le Grand         {
916cdf0e10cSrcweir 	        switch( pGraphic->GetType() )
917cdf0e10cSrcweir 	        {
918cdf0e10cSrcweir 		        case GRAPHIC_BITMAP:
919cdf0e10cSrcweir                 {
920cdf0e10cSrcweir                     const sal_uInt16 nId = ( ( pGraphic->IsTransparent() || ( (const SdrGrafTransparenceItem&) GetObjectItem( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ) ?
921cdf0e10cSrcweir                                          ( IsLinkedGraphic() ? STR_ObjNamePluralGRAFBMPTRANSLNK : STR_ObjNamePluralGRAFBMPTRANS ) :
922cdf0e10cSrcweir                                          ( IsLinkedGraphic() ? STR_ObjNamePluralGRAFBMPLNK : STR_ObjNamePluralGRAFBMP ) );
923cdf0e10cSrcweir 
924cdf0e10cSrcweir                     rName=ImpGetResStr( nId );
925cdf0e10cSrcweir                 }
926cdf0e10cSrcweir                 break;
927cdf0e10cSrcweir 
928cdf0e10cSrcweir 		        case GRAPHIC_GDIMETAFILE:
929cdf0e10cSrcweir                     rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFMTFLNK : STR_ObjNamePluralGRAFMTF );
930cdf0e10cSrcweir                 break;
931cdf0e10cSrcweir 
932cdf0e10cSrcweir                 case GRAPHIC_NONE:
933cdf0e10cSrcweir                     rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFNONELNK : STR_ObjNamePluralGRAFNONE );
934cdf0e10cSrcweir                 break;
935cdf0e10cSrcweir 
936cdf0e10cSrcweir                 default:
937cdf0e10cSrcweir                     rName=ImpGetResStr(  IsLinkedGraphic() ? STR_ObjNamePluralGRAFLNK : STR_ObjNamePluralGRAF );
938cdf0e10cSrcweir                 break;
939cdf0e10cSrcweir 	        }
940ddde725dSArmin Le Grand         }
941cdf0e10cSrcweir 
942cdf0e10cSrcweir 	    const String aName(GetName());
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 	    if( aName.Len() )
945cdf0e10cSrcweir 	    {
946cdf0e10cSrcweir 		    rName.AppendAscii( " '" );
947cdf0e10cSrcweir 		    rName += aName;
948cdf0e10cSrcweir 		    rName += sal_Unicode( '\'' );
949cdf0e10cSrcweir 	    }
950cdf0e10cSrcweir     }
951ddde725dSArmin Le Grand }
952cdf0e10cSrcweir 
953cdf0e10cSrcweir // -----------------------------------------------------------------------------
954cdf0e10cSrcweir 
getFullDragClone() const955cdf0e10cSrcweir SdrObject* SdrGrafObj::getFullDragClone() const
956cdf0e10cSrcweir {
957cdf0e10cSrcweir     // call parent
958cdf0e10cSrcweir     SdrGrafObj* pRetval = static_cast< SdrGrafObj* >(SdrRectObj::getFullDragClone());
959cdf0e10cSrcweir 
960cdf0e10cSrcweir     // #i103116# the full drag clone leads to problems
961cdf0e10cSrcweir     // with linked graphics, so reset the link in this
962cdf0e10cSrcweir     // temporary interaction object and load graphic
963cdf0e10cSrcweir     if(pRetval && IsLinkedGraphic())
964cdf0e10cSrcweir     {
965cdf0e10cSrcweir         pRetval->ForceSwapIn();
966cdf0e10cSrcweir         pRetval->ReleaseGraphicLink();
967cdf0e10cSrcweir     }
968cdf0e10cSrcweir 
969cdf0e10cSrcweir     return pRetval;
970cdf0e10cSrcweir }
971cdf0e10cSrcweir 
operator =(const SdrObject & rObj)972cdf0e10cSrcweir void SdrGrafObj::operator=( const SdrObject& rObj )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir 	SdrRectObj::operator=( rObj );
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 	const SdrGrafObj& rGraf = (SdrGrafObj&) rObj;
977cdf0e10cSrcweir 
978cdf0e10cSrcweir 	pGraphic->SetGraphic( rGraf.GetGraphic(), &rGraf.GetGraphicObject() );
979cdf0e10cSrcweir 	aCropRect = rGraf.aCropRect;
980cdf0e10cSrcweir 	aFileName = rGraf.aFileName;
981cdf0e10cSrcweir 	aFilterName = rGraf.aFilterName;
982cdf0e10cSrcweir 	bMirrored = rGraf.bMirrored;
983cdf0e10cSrcweir 
984cdf0e10cSrcweir 	if( rGraf.pGraphicLink != NULL)
985cdf0e10cSrcweir 	{
986cdf0e10cSrcweir 		SetGraphicLink( aFileName, aFilterName );
987cdf0e10cSrcweir 	}
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 	ImpSetAttrToGrafInfo();
990cdf0e10cSrcweir }
991cdf0e10cSrcweir 
992cdf0e10cSrcweir // -----------------------------------------------------------------------------
993cdf0e10cSrcweir // #i25616#
994cdf0e10cSrcweir 
TakeXorPoly() const995cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrGrafObj::TakeXorPoly() const
996cdf0e10cSrcweir {
997cdf0e10cSrcweir 	if(mbInsidePaint)
998cdf0e10cSrcweir 	{
999cdf0e10cSrcweir 		basegfx::B2DPolyPolygon aRetval;
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 		// take grown rectangle
1002cdf0e10cSrcweir 		const sal_Int32 nHalfLineWidth(ImpGetLineWdt() / 2);
1003cdf0e10cSrcweir 		const Rectangle aGrownRect(
1004cdf0e10cSrcweir 			aRect.Left() - nHalfLineWidth,
1005cdf0e10cSrcweir 			aRect.Top() - nHalfLineWidth,
1006cdf0e10cSrcweir 			aRect.Right() + nHalfLineWidth,
1007cdf0e10cSrcweir 			aRect.Bottom() + nHalfLineWidth);
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 		XPolygon aXPoly(ImpCalcXPoly(aGrownRect, GetEckenradius()));
1010cdf0e10cSrcweir 		aRetval.append(aXPoly.getB2DPolygon());
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir 		return aRetval;
1013cdf0e10cSrcweir 	}
1014cdf0e10cSrcweir 	else
1015cdf0e10cSrcweir 	{
1016cdf0e10cSrcweir 		// call parent
1017cdf0e10cSrcweir 		return SdrRectObj::TakeXorPoly();
1018cdf0e10cSrcweir 	}
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir // -----------------------------------------------------------------------------
1022cdf0e10cSrcweir 
GetHdlCount() const1023cdf0e10cSrcweir sal_uInt32 SdrGrafObj::GetHdlCount() const
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir 	return 8L;
1026cdf0e10cSrcweir }
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir // -----------------------------------------------------------------------------
1029cdf0e10cSrcweir 
GetHdl(sal_uInt32 nHdlNum) const1030cdf0e10cSrcweir SdrHdl* SdrGrafObj::GetHdl(sal_uInt32 nHdlNum) const
1031cdf0e10cSrcweir {
1032cdf0e10cSrcweir 	return SdrRectObj::GetHdl( nHdlNum + 1L );
1033cdf0e10cSrcweir }
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir // -----------------------------------------------------------------------------
1036cdf0e10cSrcweir 
NbcResize(const Point & rRef,const Fraction & xFact,const Fraction & yFact)1037cdf0e10cSrcweir void SdrGrafObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir 	SdrRectObj::NbcResize( rRef, xFact, yFact );
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 	FASTBOOL bMirrX = xFact.GetNumerator() < 0;
1042cdf0e10cSrcweir 	FASTBOOL bMirrY = yFact.GetNumerator() < 0;
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 	if( bMirrX != bMirrY )
1045cdf0e10cSrcweir 		bMirrored = !bMirrored;
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir // -----------------------------------------------------------------------------
1049cdf0e10cSrcweir 
NbcRotate(const Point & rRef,long nWink,double sn,double cs)1050cdf0e10cSrcweir void SdrGrafObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir 	SdrRectObj::NbcRotate(rRef,nWink,sn,cs);
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir // -----------------------------------------------------------------------------
1056cdf0e10cSrcweir 
NbcMirror(const Point & rRef1,const Point & rRef2)1057cdf0e10cSrcweir void SdrGrafObj::NbcMirror(const Point& rRef1, const Point& rRef2)
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir 	SdrRectObj::NbcMirror(rRef1,rRef2);
1060cdf0e10cSrcweir 	bMirrored = !bMirrored;
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir // -----------------------------------------------------------------------------
1064cdf0e10cSrcweir 
NbcShear(const Point & rRef,long nWink,double tn,FASTBOOL bVShear)1065cdf0e10cSrcweir void SdrGrafObj::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
1066cdf0e10cSrcweir {
1067a5258243SPedro Giffuni     // #i118485# Call Shear now, old version redirected to rotate
1068a5258243SPedro Giffuni 	SdrRectObj::NbcShear(rRef, nWink, tn, bVShear);
1069cdf0e10cSrcweir }
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir // -----------------------------------------------------------------------------
1072cdf0e10cSrcweir 
NbcSetSnapRect(const Rectangle & rRect)1073cdf0e10cSrcweir void SdrGrafObj::NbcSetSnapRect(const Rectangle& rRect)
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir 	SdrRectObj::NbcSetSnapRect(rRect);
1076cdf0e10cSrcweir }
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir // -----------------------------------------------------------------------------
1079cdf0e10cSrcweir 
NbcSetLogicRect(const Rectangle & rRect)1080cdf0e10cSrcweir void SdrGrafObj::NbcSetLogicRect( const Rectangle& rRect)
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir 	//int bChg=rRect.GetSize()!=aRect.GetSize();
1083cdf0e10cSrcweir 	SdrRectObj::NbcSetLogicRect(rRect);
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir // -----------------------------------------------------------------------------
1087cdf0e10cSrcweir 
NewGeoData() const1088cdf0e10cSrcweir SdrObjGeoData* SdrGrafObj::NewGeoData() const
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir 	return new SdrGrafObjGeoData;
1091cdf0e10cSrcweir }
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir // -----------------------------------------------------------------------------
1094cdf0e10cSrcweir 
SaveGeoData(SdrObjGeoData & rGeo) const1095cdf0e10cSrcweir void SdrGrafObj::SaveGeoData(SdrObjGeoData& rGeo) const
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir 	SdrRectObj::SaveGeoData(rGeo);
1098cdf0e10cSrcweir 	SdrGrafObjGeoData& rGGeo=(SdrGrafObjGeoData&)rGeo;
1099cdf0e10cSrcweir 	rGGeo.bMirrored=bMirrored;
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir // -----------------------------------------------------------------------------
1103cdf0e10cSrcweir 
RestGeoData(const SdrObjGeoData & rGeo)1104cdf0e10cSrcweir void SdrGrafObj::RestGeoData(const SdrObjGeoData& rGeo)
1105cdf0e10cSrcweir {
1106cdf0e10cSrcweir 	//long		nDrehMerk = aGeo.nDrehWink;
1107cdf0e10cSrcweir 	//long		nShearMerk = aGeo.nShearWink;
1108cdf0e10cSrcweir 	//int	bMirrMerk = bMirrored;
1109cdf0e10cSrcweir 	Size		aSizMerk( aRect.GetSize() );
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir 	SdrRectObj::RestGeoData(rGeo);
1112cdf0e10cSrcweir 	SdrGrafObjGeoData& rGGeo=(SdrGrafObjGeoData&)rGeo;
1113cdf0e10cSrcweir 	bMirrored=rGGeo.bMirrored;
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir // -----------------------------------------------------------------------------
1117cdf0e10cSrcweir 
SetPage(SdrPage * pNewPage)1118cdf0e10cSrcweir void SdrGrafObj::SetPage( SdrPage* pNewPage )
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir 	FASTBOOL bRemove = pNewPage == NULL && pPage != NULL;
1121cdf0e10cSrcweir 	FASTBOOL bInsert = pNewPage != NULL && pPage == NULL;
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir 	if( bRemove )
1124cdf0e10cSrcweir 	{
1125cdf0e10cSrcweir 		// hier kein SwapIn noetig, weil wenn nicht geladen, dann auch nicht animiert.
1126cdf0e10cSrcweir 		if( pGraphic->IsAnimated())
1127cdf0e10cSrcweir 			pGraphic->StopAnimation();
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 		if( pGraphicLink != NULL )
1130cdf0e10cSrcweir 			ImpLinkAbmeldung();
1131cdf0e10cSrcweir 	}
1132cdf0e10cSrcweir 
11339e9dd2d5SArmin Le Grand     if(!pModel && !GetStyleSheet() && pNewPage->GetModel())
11349e9dd2d5SArmin Le Grand     {
11359e9dd2d5SArmin Le Grand         // #119287# Set default StyleSheet for SdrGrafObj here, it is different from 'Default'. This
11369e9dd2d5SArmin Le Grand         // needs to be done before the style 'Default' is set from the :SetModel() call which is triggered
11379e9dd2d5SArmin Le Grand         // from the following :SetPage().
11389e9dd2d5SArmin Le Grand         // TTTT: Needs to be moved in branch aw080 due to having a SdrModel from the beginning, is at this
11399e9dd2d5SArmin Le Grand         // place for convenience currently (works in both versions, is not in the way)
11409e9dd2d5SArmin Le Grand 		SfxStyleSheet* pSheet = pNewPage->GetModel()->GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj();
11419e9dd2d5SArmin Le Grand 
11429e9dd2d5SArmin Le Grand 		if(pSheet)
11439e9dd2d5SArmin Le Grand 		{
11449e9dd2d5SArmin Le Grand 			SetStyleSheet(pSheet, false);
11459e9dd2d5SArmin Le Grand 		}
11469e9dd2d5SArmin Le Grand         else
11479e9dd2d5SArmin Le Grand         {
11489e9dd2d5SArmin Le Grand 		    SetMergedItem(XFillStyleItem(XFILL_NONE));
11499e9dd2d5SArmin Le Grand 		    SetMergedItem(XLineStyleItem(XLINE_NONE));
11509e9dd2d5SArmin Le Grand         }
11519e9dd2d5SArmin Le Grand     }
11529e9dd2d5SArmin Le Grand 
1153cdf0e10cSrcweir 	SdrRectObj::SetPage( pNewPage );
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir 	if(aFileName.Len() && bInsert)
1156cdf0e10cSrcweir 		ImpLinkAnmeldung();
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir // -----------------------------------------------------------------------------
1160cdf0e10cSrcweir 
SetModel(SdrModel * pNewModel)1161cdf0e10cSrcweir void SdrGrafObj::SetModel( SdrModel* pNewModel )
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir 	FASTBOOL bChg = pNewModel != pModel;
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 	if( bChg )
1166cdf0e10cSrcweir 	{
1167cdf0e10cSrcweir 		if( pGraphic->HasUserData() )
1168cdf0e10cSrcweir 		{
1169cdf0e10cSrcweir 			ForceSwapIn();
1170cdf0e10cSrcweir 			pGraphic->SetUserData();
1171cdf0e10cSrcweir 		}
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir 		if( pGraphicLink != NULL )
1174cdf0e10cSrcweir 			ImpLinkAbmeldung();
1175cdf0e10cSrcweir 	}
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir 	// Model umsetzen
1178cdf0e10cSrcweir 	SdrRectObj::SetModel(pNewModel);
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir 	if( bChg && aFileName.Len() )
1181cdf0e10cSrcweir 		ImpLinkAnmeldung();
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir // -----------------------------------------------------------------------------
1185cdf0e10cSrcweir 
StartAnimation(OutputDevice *,const Point &,const Size &,long)1186cdf0e10cSrcweir void SdrGrafObj::StartAnimation( OutputDevice* /*pOutDev*/, const Point& /*rPoint*/, const Size& /*rSize*/, long /*nExtraData*/)
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir 	// #111096#
1189cdf0e10cSrcweir 	// use new graf animation
1190cdf0e10cSrcweir 	SetGrafAnimationAllowed(sal_True);
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir // -----------------------------------------------------------------------------
1194cdf0e10cSrcweir 
StopAnimation(OutputDevice *,long)1195cdf0e10cSrcweir void SdrGrafObj::StopAnimation(OutputDevice* /*pOutDev*/, long /*nExtraData*/)
1196cdf0e10cSrcweir {
1197cdf0e10cSrcweir 	// #111096#
1198cdf0e10cSrcweir 	// use new graf animation
1199cdf0e10cSrcweir 	SetGrafAnimationAllowed(sal_False);
1200cdf0e10cSrcweir }
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir // -----------------------------------------------------------------------------
1203cdf0e10cSrcweir 
HasGDIMetaFile() const1204cdf0e10cSrcweir FASTBOOL SdrGrafObj::HasGDIMetaFile() const
1205cdf0e10cSrcweir {
1206cdf0e10cSrcweir 	return( pGraphic->GetType() == GRAPHIC_GDIMETAFILE );
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir // -----------------------------------------------------------------------------
1210cdf0e10cSrcweir 
GetGDIMetaFile() const1211cdf0e10cSrcweir const GDIMetaFile* SdrGrafObj::GetGDIMetaFile() const
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir 	DBG_ERROR( "Invalid return value! Don't use it! (KA)" );
1214cdf0e10cSrcweir 	return &GetGraphic().GetGDIMetaFile();
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir // -----------------------------------------------------------------------------
1218cdf0e10cSrcweir 
isEmbeddedSvg() const1219ddde725dSArmin Le Grand bool SdrGrafObj::isEmbeddedSvg() const
1220ddde725dSArmin Le Grand {
1221ddde725dSArmin Le Grand     return GRAPHIC_BITMAP == GetGraphicType() && GetGraphic().getSvgData().get();
1222ddde725dSArmin Le Grand }
1223ddde725dSArmin Le Grand 
getMetafileFromEmbeddedSvg() const1224ddde725dSArmin Le Grand GDIMetaFile SdrGrafObj::getMetafileFromEmbeddedSvg() const
1225ddde725dSArmin Le Grand {
1226ddde725dSArmin Le Grand     GDIMetaFile aRetval;
1227ddde725dSArmin Le Grand 
1228ddde725dSArmin Le Grand     if(isEmbeddedSvg() && GetModel())
1229ddde725dSArmin Le Grand     {
1230ddde725dSArmin Le Grand         VirtualDevice aOut;
1231ddde725dSArmin Le Grand         const Rectangle aBoundRect(GetCurrentBoundRect());
1232ddde725dSArmin Le Grand         const MapMode aMap(GetModel()->GetScaleUnit(), Point(), GetModel()->GetScaleFraction(), GetModel()->GetScaleFraction());
1233ddde725dSArmin Le Grand 
1234ddde725dSArmin Le Grand         aOut.EnableOutput(false);
1235ddde725dSArmin Le Grand         aOut.SetMapMode(aMap);
1236ddde725dSArmin Le Grand         aRetval.Record(&aOut);
1237ddde725dSArmin Le Grand         SingleObjectPainter(aOut);
1238ddde725dSArmin Le Grand         aRetval.Stop();
1239ddde725dSArmin Le Grand         aRetval.WindStart();
1240ddde725dSArmin Le Grand         aRetval.Move(-aBoundRect.Left(), -aBoundRect.Top());
1241ddde725dSArmin Le Grand         aRetval.SetPrefMapMode(aMap);
1242ddde725dSArmin Le Grand         aRetval.SetPrefSize(aBoundRect.GetSize());
1243ddde725dSArmin Le Grand     }
1244ddde725dSArmin Le Grand 
1245ddde725dSArmin Le Grand     return aRetval;
1246ddde725dSArmin Le Grand }
1247ddde725dSArmin Le Grand 
DoConvertToPolyObj(sal_Bool bBezier,bool bAddText) const1248a5258243SPedro Giffuni SdrObject* SdrGrafObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir 	SdrObject* pRetval = NULL;
1251ddde725dSArmin Le Grand     GraphicType aGraphicType(GetGraphicType());
1252ddde725dSArmin Le Grand     GDIMetaFile aMtf;
1253cdf0e10cSrcweir 
1254ddde725dSArmin Le Grand     if(isEmbeddedSvg())
1255ddde725dSArmin Le Grand     {
1256ddde725dSArmin Le Grand         // Embedded Svg
1257ddde725dSArmin Le Grand         // There is currently no helper to create SdrObjects from primitives (even if I'm thinking
1258ddde725dSArmin Le Grand         // about writing one for some time). To get the roundtrip to SdrObjects it is necessary to
1259ddde725dSArmin Le Grand         // use the old converter path over the MetaFile mechanism. Create Metafile from Svg
1260ddde725dSArmin Le Grand         // primitives here pretty directly
1261ddde725dSArmin Le Grand         aMtf = getMetafileFromEmbeddedSvg();
1262ddde725dSArmin Le Grand         aGraphicType = GRAPHIC_GDIMETAFILE;
1263ddde725dSArmin Le Grand     }
1264ddde725dSArmin Le Grand     else if(GRAPHIC_GDIMETAFILE == aGraphicType)
1265ddde725dSArmin Le Grand     {
1266ddde725dSArmin Le Grand         aMtf = GetTransformedGraphic(SDRGRAFOBJ_TRANSFORMATTR_COLOR|SDRGRAFOBJ_TRANSFORMATTR_MIRROR).GetGDIMetaFile();
1267ddde725dSArmin Le Grand     }
1268ddde725dSArmin Le Grand 
1269ddde725dSArmin Le Grand 	switch(aGraphicType)
1270cdf0e10cSrcweir 	{
1271cdf0e10cSrcweir 		case GRAPHIC_GDIMETAFILE:
1272cdf0e10cSrcweir 		{
1273cdf0e10cSrcweir 			// NUR die aus dem MetaFile erzeugbaren Objekte in eine Gruppe packen und zurueckliefern
12748718d260SArmin Le Grand 			ImpSdrGDIMetaFileImport aFilter(*GetModel(), GetLayer(), aRect);
1275a5258243SPedro Giffuni 			SdrObjGroup* pGrp = new SdrObjGroup();
1276ddde725dSArmin Le Grand 			sal_uInt32 nInsAnz = aFilter.DoImport(aMtf, *pGrp->GetSubList(), 0);
1277a5258243SPedro Giffuni 
1278cdf0e10cSrcweir             if(nInsAnz)
1279cdf0e10cSrcweir 			{
1280a5258243SPedro Giffuni                 {
1281a5258243SPedro Giffuni                         // copy transformation
1282a5258243SPedro Giffuni                 	GeoStat aGeoStat(GetGeoStat());
1283a5258243SPedro Giffuni 
1284a5258243SPedro Giffuni 	                if(aGeoStat.nShearWink)
1285a5258243SPedro Giffuni                     {
1286a5258243SPedro Giffuni                         aGeoStat.RecalcTan();
1287a5258243SPedro Giffuni                         pGrp->NbcShear(aRect.TopLeft(), aGeoStat.nShearWink, aGeoStat.nTan, false);
1288a5258243SPedro Giffuni                     }
1289a5258243SPedro Giffuni 
1290a5258243SPedro Giffuni 	                if(aGeoStat.nDrehWink)
1291a5258243SPedro Giffuni                     {
1292a5258243SPedro Giffuni 	                    aGeoStat.RecalcSinCos();
1293a5258243SPedro Giffuni                         pGrp->NbcRotate(aRect.TopLeft(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos);
1294a5258243SPedro Giffuni                     }
1295a5258243SPedro Giffuni                 }
1296a5258243SPedro Giffuni 
1297cdf0e10cSrcweir                 pRetval = pGrp;
1298cdf0e10cSrcweir 				pGrp->NbcSetLayer(GetLayer());
1299cdf0e10cSrcweir 				pGrp->SetModel(GetModel());
1300dfe9de19SHerbert Dürr 
1301dfe9de19SHerbert Dürr                 if(bAddText)
1302dfe9de19SHerbert Dürr                 {
1303cdf0e10cSrcweir 				    pRetval = ImpConvertAddText(pRetval, bBezier);
1304dfe9de19SHerbert Dürr                 }
1305cdf0e10cSrcweir 
1306cdf0e10cSrcweir                 // convert all children
1307cdf0e10cSrcweir                 if( pRetval )
1308cdf0e10cSrcweir                 {
1309cdf0e10cSrcweir                     SdrObject* pHalfDone = pRetval;
1310a5258243SPedro Giffuni                     pRetval = pHalfDone->DoConvertToPolyObj(bBezier, bAddText);
1311cdf0e10cSrcweir                     SdrObject::Free( pHalfDone ); // resulting object is newly created
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir                     if( pRetval )
1314cdf0e10cSrcweir                     {
1315cdf0e10cSrcweir                         // flatten subgroups. As we call
1316cdf0e10cSrcweir                         // DoConvertToPolyObj() on the resulting group
1317cdf0e10cSrcweir                         // objects, subgroups can exist (e.g. text is
1318cdf0e10cSrcweir                         // a group object for every line).
1319cdf0e10cSrcweir                         SdrObjList* pList = pRetval->GetSubList();
1320cdf0e10cSrcweir                         if( pList )
1321cdf0e10cSrcweir                             pList->FlattenGroups();
1322cdf0e10cSrcweir                     }
1323cdf0e10cSrcweir                 }
1324cdf0e10cSrcweir 			}
1325cdf0e10cSrcweir 			else
1326a5258243SPedro Giffuni             {
1327cdf0e10cSrcweir 				delete pGrp;
1328a5258243SPedro Giffuni             }
1329a5258243SPedro Giffuni 
1330a5258243SPedro Giffuni             // #i118485# convert line and fill
1331a5258243SPedro Giffuni             SdrObject* pLineFill = SdrRectObj::DoConvertToPolyObj(bBezier, false);
1332a5258243SPedro Giffuni 
1333a5258243SPedro Giffuni             if(pLineFill)
1334a5258243SPedro Giffuni             {
1335a5258243SPedro Giffuni                 if(pRetval)
1336a5258243SPedro Giffuni                 {
1337a5258243SPedro Giffuni                     pGrp = dynamic_cast< SdrObjGroup* >(pRetval);
1338a5258243SPedro Giffuni 
1339a5258243SPedro Giffuni                     if(!pGrp)
1340a5258243SPedro Giffuni                     {
1341a5258243SPedro Giffuni             			pGrp = new SdrObjGroup();
1342a5258243SPedro Giffuni 
1343a5258243SPedro Giffuni                         pGrp->NbcSetLayer(GetLayer());
1344a5258243SPedro Giffuni 				        pGrp->SetModel(GetModel());
1345a5258243SPedro Giffuni                         pGrp->GetSubList()->NbcInsertObject(pRetval);
1346a5258243SPedro Giffuni                     }
1347a5258243SPedro Giffuni 
1348a5258243SPedro Giffuni                     pGrp->GetSubList()->NbcInsertObject(pLineFill, 0);
1349a5258243SPedro Giffuni                 }
1350a5258243SPedro Giffuni                 else
1351a5258243SPedro Giffuni                 {
1352a5258243SPedro Giffuni                     pRetval = pLineFill;
1353a5258243SPedro Giffuni                 }
1354a5258243SPedro Giffuni             }
1355a5258243SPedro Giffuni 
1356cdf0e10cSrcweir 			break;
1357cdf0e10cSrcweir 		}
1358cdf0e10cSrcweir 		case GRAPHIC_BITMAP:
1359cdf0e10cSrcweir 		{
1360cdf0e10cSrcweir 			// Grundobjekt kreieren und Fuellung ergaenzen
1361a5258243SPedro Giffuni 			pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir 			// Bitmap als Attribut retten
1364cdf0e10cSrcweir 			if(pRetval)
1365cdf0e10cSrcweir 			{
1366cdf0e10cSrcweir 				// Bitmap als Fuellung holen
1367cdf0e10cSrcweir 				SfxItemSet aSet(GetObjectItemSet());
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir 				aSet.Put(XFillStyleItem(XFILL_BITMAP));
137070d3707aSArmin Le Grand 				const BitmapEx aBitmapEx(GetTransformedGraphic().GetBitmapEx());
137170d3707aSArmin Le Grand 				aSet.Put(XFillBitmapItem(String(), Graphic(aBitmapEx)));
137270d3707aSArmin Le Grand 				aSet.Put(XFillBmpTileItem(false));
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir 				pRetval->SetMergedItemSet(aSet);
1375cdf0e10cSrcweir 			}
1376cdf0e10cSrcweir 			break;
1377cdf0e10cSrcweir 		}
1378cdf0e10cSrcweir 		case GRAPHIC_NONE:
1379cdf0e10cSrcweir 		case GRAPHIC_DEFAULT:
1380cdf0e10cSrcweir 		{
1381a5258243SPedro Giffuni 			pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
1382cdf0e10cSrcweir 			break;
1383cdf0e10cSrcweir 		}
1384cdf0e10cSrcweir 	}
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir 	return pRetval;
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir // -----------------------------------------------------------------------------
1390cdf0e10cSrcweir 
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)1391cdf0e10cSrcweir void SdrGrafObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1392cdf0e10cSrcweir {
1393cdf0e10cSrcweir 	SetXPolyDirty();
1394cdf0e10cSrcweir 	SdrRectObj::Notify( rBC, rHint );
1395cdf0e10cSrcweir 	ImpSetAttrToGrafInfo();
1396cdf0e10cSrcweir }
1397cdf0e10cSrcweir 
ImpSetAttrToGrafInfo()1398cdf0e10cSrcweir void SdrGrafObj::ImpSetAttrToGrafInfo()
1399cdf0e10cSrcweir {
1400cdf0e10cSrcweir 	const SfxItemSet& rSet = GetObjectItemSet();
1401cdf0e10cSrcweir 	const sal_uInt16 nTrans = ( (SdrGrafTransparenceItem&) rSet.Get( SDRATTR_GRAFTRANSPARENCE ) ).GetValue();
1402cdf0e10cSrcweir 	const SdrGrafCropItem&	rCrop = (const SdrGrafCropItem&) rSet.Get( SDRATTR_GRAFCROP );
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir 	aGrafInfo.SetLuminance( ( (SdrGrafLuminanceItem&) rSet.Get( SDRATTR_GRAFLUMINANCE ) ).GetValue() );
1405cdf0e10cSrcweir 	aGrafInfo.SetContrast( ( (SdrGrafContrastItem&) rSet.Get( SDRATTR_GRAFCONTRAST ) ).GetValue() );
1406cdf0e10cSrcweir 	aGrafInfo.SetChannelR( ( (SdrGrafRedItem&) rSet.Get( SDRATTR_GRAFRED ) ).GetValue() );
1407cdf0e10cSrcweir 	aGrafInfo.SetChannelG( ( (SdrGrafGreenItem&) rSet.Get( SDRATTR_GRAFGREEN ) ).GetValue() );
1408cdf0e10cSrcweir 	aGrafInfo.SetChannelB( ( (SdrGrafBlueItem&) rSet.Get( SDRATTR_GRAFBLUE ) ).GetValue() );
1409cdf0e10cSrcweir 	aGrafInfo.SetGamma( ( (SdrGrafGamma100Item&) rSet.Get( SDRATTR_GRAFGAMMA ) ).GetValue() * 0.01 );
1410cdf0e10cSrcweir 	aGrafInfo.SetTransparency( (sal_uInt8) FRound( Min( nTrans, (sal_uInt16) 100 )  * 2.55 ) );
1411cdf0e10cSrcweir 	aGrafInfo.SetInvert( ( (SdrGrafInvertItem&) rSet.Get( SDRATTR_GRAFINVERT ) ).GetValue() );
1412cdf0e10cSrcweir 	aGrafInfo.SetDrawMode( ( (SdrGrafModeItem&) rSet.Get( SDRATTR_GRAFMODE ) ).GetValue() );
1413cdf0e10cSrcweir 	aGrafInfo.SetCrop( rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom() );
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir 	SetXPolyDirty();
1416cdf0e10cSrcweir 	SetRectsDirty();
1417cdf0e10cSrcweir }
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir // -----------------------------------------------------------------------------
1420cdf0e10cSrcweir 
ImpSetGrafInfoToAttr()1421cdf0e10cSrcweir void SdrGrafObj::ImpSetGrafInfoToAttr()
1422cdf0e10cSrcweir {
1423cdf0e10cSrcweir 	SetObjectItem( SdrGrafLuminanceItem( aGrafInfo.GetLuminance() ) );
1424cdf0e10cSrcweir 	SetObjectItem( SdrGrafContrastItem( aGrafInfo.GetContrast() ) );
1425cdf0e10cSrcweir 	SetObjectItem( SdrGrafRedItem( aGrafInfo.GetChannelR() ) );
1426cdf0e10cSrcweir 	SetObjectItem( SdrGrafGreenItem( aGrafInfo.GetChannelG() ) );
1427cdf0e10cSrcweir 	SetObjectItem( SdrGrafBlueItem( aGrafInfo.GetChannelB() ) );
1428cdf0e10cSrcweir 	SetObjectItem( SdrGrafGamma100Item( FRound( aGrafInfo.GetGamma() * 100.0 ) ) );
1429cdf0e10cSrcweir 	SetObjectItem( SdrGrafTransparenceItem( (sal_uInt16) FRound( aGrafInfo.GetTransparency() / 2.55 ) ) );
1430cdf0e10cSrcweir 	SetObjectItem( SdrGrafInvertItem( aGrafInfo.IsInvert() ) );
1431cdf0e10cSrcweir 	SetObjectItem( SdrGrafModeItem( aGrafInfo.GetDrawMode() ) );
1432cdf0e10cSrcweir 	SetObjectItem( SdrGrafCropItem( aGrafInfo.GetLeftCrop(), aGrafInfo.GetTopCrop(), aGrafInfo.GetRightCrop(), aGrafInfo.GetBottomCrop() ) );
1433cdf0e10cSrcweir }
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir // -----------------------------------------------------------------------------
1436cdf0e10cSrcweir 
AdjustToMaxRect(const Rectangle & rMaxRect,bool bShrinkOnly)1437cdf0e10cSrcweir void SdrGrafObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly )
1438cdf0e10cSrcweir {
1439cdf0e10cSrcweir 	Size aSize;
1440cdf0e10cSrcweir 	Size aMaxSize( rMaxRect.GetSize() );
1441cdf0e10cSrcweir 	if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
1442cdf0e10cSrcweir 		aSize = Application::GetDefaultDevice()->PixelToLogic( pGraphic->GetPrefSize(), MAP_100TH_MM );
1443cdf0e10cSrcweir 	else
1444cdf0e10cSrcweir 		aSize = OutputDevice::LogicToLogic( pGraphic->GetPrefSize(),
1445cdf0e10cSrcweir 										    pGraphic->GetPrefMapMode(),
1446cdf0e10cSrcweir 										    MapMode( MAP_100TH_MM ) );
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir 	if( aSize.Height() != 0 && aSize.Width() != 0 )
1449cdf0e10cSrcweir 	{
1450cdf0e10cSrcweir 		Point aPos( rMaxRect.TopLeft() );
1451cdf0e10cSrcweir 
1452cdf0e10cSrcweir 		// Falls Grafik zu gross, wird die Grafik
1453cdf0e10cSrcweir 		// in die Seite eingepasst
1454cdf0e10cSrcweir 		if ( (!bShrinkOnly                          ||
1455cdf0e10cSrcweir 	    	 ( aSize.Height() > aMaxSize.Height() ) ||
1456cdf0e10cSrcweir 		 	( aSize.Width()  > aMaxSize.Width()  ) )&&
1457cdf0e10cSrcweir 		 	aSize.Height() && aMaxSize.Height() )
1458cdf0e10cSrcweir 		{
1459cdf0e10cSrcweir 			float fGrfWH =	(float)aSize.Width() /
1460cdf0e10cSrcweir 							(float)aSize.Height();
1461cdf0e10cSrcweir 			float fWinWH =	(float)aMaxSize.Width() /
1462cdf0e10cSrcweir 							(float)aMaxSize.Height();
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir 			// Grafik an Pagesize anpassen (skaliert)
1465cdf0e10cSrcweir 			if ( fGrfWH < fWinWH )
1466cdf0e10cSrcweir 			{
1467cdf0e10cSrcweir 				aSize.Width() = (long)(aMaxSize.Height() * fGrfWH);
1468cdf0e10cSrcweir 				aSize.Height()= aMaxSize.Height();
1469cdf0e10cSrcweir 			}
1470cdf0e10cSrcweir 			else if ( fGrfWH > 0.F )
1471cdf0e10cSrcweir 			{
1472cdf0e10cSrcweir 				aSize.Width() = aMaxSize.Width();
1473cdf0e10cSrcweir 				aSize.Height()= (long)(aMaxSize.Width() / fGrfWH);
1474cdf0e10cSrcweir 			}
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir 			aPos = rMaxRect.Center();
1477cdf0e10cSrcweir 		}
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir 		if( bShrinkOnly )
1480cdf0e10cSrcweir 			aPos = aRect.TopLeft();
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir 		aPos.X() -= aSize.Width() / 2;
1483cdf0e10cSrcweir 		aPos.Y() -= aSize.Height() / 2;
1484cdf0e10cSrcweir 		SetLogicRect( Rectangle( aPos, aSize ) );
1485cdf0e10cSrcweir 	}
1486cdf0e10cSrcweir }
1487cdf0e10cSrcweir 
1488cdf0e10cSrcweir // -----------------------------------------------------------------------------
1489cdf0e10cSrcweir 
IMPL_LINK(SdrGrafObj,ImpSwapHdl,GraphicObject *,pO)1490cdf0e10cSrcweir IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
1491cdf0e10cSrcweir {
1492cdf0e10cSrcweir 	SvStream* pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir 	if( pO->IsInSwapOut() )
1495cdf0e10cSrcweir 	{
1496cdf0e10cSrcweir 		if( pModel && !mbIsPreview && pModel->IsSwapGraphics() && pGraphic->GetSizeBytes() > 20480 )
1497cdf0e10cSrcweir 		{
1498cdf0e10cSrcweir 			// test if this object is visualized from someone
1499cdf0e10cSrcweir             // ## test only if there are VOCs other than the preview renderer
1500cdf0e10cSrcweir 			if(!GetViewContact().HasViewObjectContacts(true))
1501cdf0e10cSrcweir 			{
1502cdf0e10cSrcweir 				const sal_uIntPtr	nSwapMode = pModel->GetSwapGraphicsMode();
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir 				if( ( pGraphic->HasUserData() || pGraphicLink ) &&
1505cdf0e10cSrcweir 					( nSwapMode & SDR_SWAPGRAPHICSMODE_PURGE ) )
1506cdf0e10cSrcweir 				{
1507cdf0e10cSrcweir 					pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
1508cdf0e10cSrcweir 				}
1509cdf0e10cSrcweir 				else if( nSwapMode & SDR_SWAPGRAPHICSMODE_TEMP )
1510cdf0e10cSrcweir 				{
1511cdf0e10cSrcweir 					pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
1512cdf0e10cSrcweir 					pGraphic->SetUserData();
1513cdf0e10cSrcweir 				}
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir 				// #i102380#
1516cdf0e10cSrcweir 				sdr::contact::ViewContactOfGraphic* pVC = dynamic_cast< sdr::contact::ViewContactOfGraphic* >(&GetViewContact());
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir 				if(pVC)
1519cdf0e10cSrcweir 				{
1520cdf0e10cSrcweir 					pVC->flushGraphicObjects();
1521cdf0e10cSrcweir 				}
1522cdf0e10cSrcweir 			}
1523cdf0e10cSrcweir 		}
1524cdf0e10cSrcweir 	}
1525cdf0e10cSrcweir 	else if( pO->IsInSwapIn() )
1526cdf0e10cSrcweir 	{
1527cdf0e10cSrcweir 		// kann aus dem original Doc-Stream nachgeladen werden...
1528cdf0e10cSrcweir 		if( pModel != NULL )
1529cdf0e10cSrcweir 		{
1530cdf0e10cSrcweir 			if( pGraphic->HasUserData() )
1531cdf0e10cSrcweir 			{
1532cdf0e10cSrcweir 				SdrDocumentStreamInfo aStreamInfo;
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir 				aStreamInfo.mbDeleteAfterUse = sal_False;
1535cdf0e10cSrcweir 				aStreamInfo.maUserData = pGraphic->GetUserData();
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir 				SvStream* pStream = pModel->GetDocumentStream( aStreamInfo );
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir 				if( pStream != NULL )
1540cdf0e10cSrcweir 				{
1541cdf0e10cSrcweir 					Graphic aGraphic;
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir                     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData = NULL;
1544cdf0e10cSrcweir 
1545cdf0e10cSrcweir 					if(mbInsidePaint && !GetViewContact().HasViewObjectContacts(true))
1546cdf0e10cSrcweir                     {
1547cdf0e10cSrcweir                         pFilterData = new com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >( 3 );
1548cdf0e10cSrcweir 
1549d2c409beSOliver-Rainer Wittmann                         const com::sun::star::awt::Size aPreviewSizeHint( 64, 64 );
1550d2c409beSOliver-Rainer Wittmann                         const sal_Bool bAllowPartialStreamRead = sal_True;
1551d2c409beSOliver-Rainer Wittmann                         // create <GfxLink> instance also for previews in order to avoid that its corresponding
1552d2c409beSOliver-Rainer Wittmann                         // data is cleared in the graphic cache entry in case that the preview data equals the complete graphic data
1553d2c409beSOliver-Rainer Wittmann                         const sal_Bool bCreateNativeLink = sal_True;
1554cdf0e10cSrcweir                         (*pFilterData)[ 0 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "PreviewSizeHint" ) );
1555cdf0e10cSrcweir                         (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
1556cdf0e10cSrcweir                         (*pFilterData)[ 1 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "AllowPartialStreamRead" ) );
1557cdf0e10cSrcweir                         (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead;
1558cdf0e10cSrcweir                         (*pFilterData)[ 2 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "CreateNativeLink" ) );
1559cdf0e10cSrcweir                         (*pFilterData)[ 2 ].Value <<= bCreateNativeLink;
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir                         mbIsPreview = sal_True;
1562cdf0e10cSrcweir                     }
1563cdf0e10cSrcweir 
1564ddde725dSArmin Le Grand                     if(!GraphicFilter::GetGraphicFilter()->ImportGraphic(
1565ddde725dSArmin Le Grand                         aGraphic, aStreamInfo.maUserData, *pStream,
1566cdf0e10cSrcweir                         GRFILTER_FORMAT_DONTKNOW, NULL, 0, pFilterData))
1567cdf0e10cSrcweir                     {
1568cdf0e10cSrcweir                         const String aUserData( pGraphic->GetUserData() );
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir                         pGraphic->SetGraphic( aGraphic );
1571cdf0e10cSrcweir                         pGraphic->SetUserData( aUserData );
1572cdf0e10cSrcweir 
1573cdf0e10cSrcweir                         // #142146# Graphic successfully swapped in.
1574cdf0e10cSrcweir                         pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
1575cdf0e10cSrcweir                     }
1576cdf0e10cSrcweir                     delete pFilterData;
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir                     pStream->ResetError();
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir                     if( aStreamInfo.mbDeleteAfterUse || aStreamInfo.mxStorageRef.is() )
1581cdf0e10cSrcweir                     {
1582cdf0e10cSrcweir                         if ( aStreamInfo.mxStorageRef.is() )
1583cdf0e10cSrcweir                         {
1584cdf0e10cSrcweir                             aStreamInfo.mxStorageRef->dispose();
1585cdf0e10cSrcweir                             aStreamInfo.mxStorageRef = 0;
1586cdf0e10cSrcweir                         }
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir                         delete pStream;
1589cdf0e10cSrcweir                     }
1590cdf0e10cSrcweir                 }
1591cdf0e10cSrcweir 			}
1592cdf0e10cSrcweir 			else if( !ImpUpdateGraphicLink( sal_False ) )
1593cdf0e10cSrcweir             {
1594cdf0e10cSrcweir 				pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
1595cdf0e10cSrcweir             }
1596cdf0e10cSrcweir 			else
1597cdf0e10cSrcweir             {
1598cdf0e10cSrcweir                 pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
1599cdf0e10cSrcweir             }
1600cdf0e10cSrcweir 		}
1601cdf0e10cSrcweir 		else
1602cdf0e10cSrcweir 			pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
1603cdf0e10cSrcweir 	}
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir 	return (long)(void*) pRet;
1606cdf0e10cSrcweir }
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir // -----------------------------------------------------------------------------
1609cdf0e10cSrcweir 
1610cdf0e10cSrcweir // #111096#
1611cdf0e10cSrcweir // Access to GrafAnimationAllowed flag
IsGrafAnimationAllowed() const1612cdf0e10cSrcweir sal_Bool SdrGrafObj::IsGrafAnimationAllowed() const
1613cdf0e10cSrcweir {
1614cdf0e10cSrcweir 	return mbGrafAnimationAllowed;
1615cdf0e10cSrcweir }
1616cdf0e10cSrcweir 
SetGrafAnimationAllowed(sal_Bool bNew)1617cdf0e10cSrcweir void SdrGrafObj::SetGrafAnimationAllowed(sal_Bool bNew)
1618cdf0e10cSrcweir {
1619cdf0e10cSrcweir 	if(mbGrafAnimationAllowed != bNew)
1620cdf0e10cSrcweir 	{
1621cdf0e10cSrcweir 		mbGrafAnimationAllowed = bNew;
1622cdf0e10cSrcweir 		ActionChanged();
1623cdf0e10cSrcweir 	}
1624cdf0e10cSrcweir }
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir // #i25616#
IsObjectTransparent() const1627cdf0e10cSrcweir sal_Bool SdrGrafObj::IsObjectTransparent() const
1628cdf0e10cSrcweir {
1629cdf0e10cSrcweir 	if(((const SdrGrafTransparenceItem&)GetObjectItem(SDRATTR_GRAFTRANSPARENCE)).GetValue()
1630cdf0e10cSrcweir 		|| pGraphic->IsTransparent())
1631cdf0e10cSrcweir 	{
1632cdf0e10cSrcweir 		return sal_True;
1633cdf0e10cSrcweir 	}
1634cdf0e10cSrcweir 
1635cdf0e10cSrcweir 	return sal_False;
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir 
getInputStream()1638cdf0e10cSrcweir Reference< XInputStream > SdrGrafObj::getInputStream()
1639cdf0e10cSrcweir {
1640cdf0e10cSrcweir 	Reference< XInputStream > xStream;
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir 	if( pModel )
1643cdf0e10cSrcweir 	{
1644cdf0e10cSrcweir //		if( !pGraphic->HasUserData() )
1645cdf0e10cSrcweir //			pGraphic->SwapOut();
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir 		// kann aus dem original Doc-Stream nachgeladen werden...
1648cdf0e10cSrcweir 		if( pGraphic->HasUserData() )
1649cdf0e10cSrcweir 		{
1650cdf0e10cSrcweir 			SdrDocumentStreamInfo aStreamInfo;
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir 			aStreamInfo.mbDeleteAfterUse = sal_False;
1653cdf0e10cSrcweir 			aStreamInfo.maUserData = pGraphic->GetUserData();
1654cdf0e10cSrcweir 
1655cdf0e10cSrcweir 			SvStream* pStream = pModel->GetDocumentStream( aStreamInfo );
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir 			if( pStream )
1658cdf0e10cSrcweir 				xStream.set( new utl::OInputStreamWrapper( pStream, sal_True ) );
1659cdf0e10cSrcweir 		}
1660cdf0e10cSrcweir 		else if( pGraphic && GetGraphic().IsLink() )
1661cdf0e10cSrcweir 		{
1662cdf0e10cSrcweir 			Graphic aGraphic( GetGraphic() );
1663cdf0e10cSrcweir 			GfxLink aLink( aGraphic.GetLink() );
1664cdf0e10cSrcweir 			sal_uInt32 nSize = aLink.GetDataSize();
1665cdf0e10cSrcweir 			const void* pSourceData = (const void*)aLink.GetData();
1666cdf0e10cSrcweir 			if( nSize && pSourceData )
1667cdf0e10cSrcweir 			{
1668cdf0e10cSrcweir 				sal_uInt8 * pBuffer = new sal_uInt8[ nSize ];
1669cdf0e10cSrcweir 				if( pBuffer )
1670cdf0e10cSrcweir 				{
1671cdf0e10cSrcweir 					memcpy( pBuffer, pSourceData, nSize );
1672cdf0e10cSrcweir 
1673cdf0e10cSrcweir 					SvMemoryStream* pStream = new SvMemoryStream( (void*)pBuffer, (sal_Size)nSize, STREAM_READ );
1674cdf0e10cSrcweir 					pStream->ObjectOwnsMemory( sal_True );
1675cdf0e10cSrcweir 					xStream.set( new utl::OInputStreamWrapper( pStream, sal_True ) );
1676cdf0e10cSrcweir 				}
1677cdf0e10cSrcweir 			}
1678cdf0e10cSrcweir 		}
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir 		if( !xStream.is() && aFileName.Len() )
1681cdf0e10cSrcweir 		{
1682cdf0e10cSrcweir 			SvFileStream* pStream = new SvFileStream( aFileName, STREAM_READ );
1683cdf0e10cSrcweir 			if( pStream )
1684cdf0e10cSrcweir 				xStream.set( new utl::OInputStreamWrapper( pStream ) );
1685cdf0e10cSrcweir 		}
1686cdf0e10cSrcweir 	}
1687cdf0e10cSrcweir 
1688cdf0e10cSrcweir 	return xStream;
1689cdf0e10cSrcweir }
1690cdf0e10cSrcweir 
1691414a0e15SArmin Le Grand // moved crop handle creation here; this is the object type using them
addCropHandles(SdrHdlList & rTarget) const1692414a0e15SArmin Le Grand void SdrGrafObj::addCropHandles(SdrHdlList& rTarget) const
1693414a0e15SArmin Le Grand {
1694414a0e15SArmin Le Grand     basegfx::B2DHomMatrix aMatrix;
1695414a0e15SArmin Le Grand     basegfx::B2DPolyPolygon aPolyPolygon;
1696414a0e15SArmin Le Grand 
1697414a0e15SArmin Le Grand     // get object transformation
1698414a0e15SArmin Le Grand     TRGetBaseGeometry(aMatrix, aPolyPolygon);
1699414a0e15SArmin Le Grand 
1700414a0e15SArmin Le Grand     // part of object transformation correction, but used later, so defined outside next scope
1701414a0e15SArmin Le Grand     double fShearX(0.0), fRotate(0.0);
1702414a0e15SArmin Le Grand 
1703414a0e15SArmin Le Grand     {   // TTTT correct shear, it comes currently mirrored from TRGetBaseGeometry, can be removed with aw080
1704414a0e15SArmin Le Grand         basegfx::B2DTuple aScale;
1705414a0e15SArmin Le Grand         basegfx::B2DTuple aTranslate;
1706414a0e15SArmin Le Grand 
1707414a0e15SArmin Le Grand         aMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
1708414a0e15SArmin Le Grand 
1709414a0e15SArmin Le Grand         if(!basegfx::fTools::equalZero(fShearX))
1710414a0e15SArmin Le Grand         {
1711414a0e15SArmin Le Grand             // shearX is used, correct it
1712414a0e15SArmin Le Grand             fShearX = -fShearX;
1713414a0e15SArmin Le Grand         }
1714414a0e15SArmin Le Grand 
1715414a0e15SArmin Le Grand         aMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
1716414a0e15SArmin Le Grand             aScale,
1717414a0e15SArmin Le Grand             fShearX,
1718414a0e15SArmin Le Grand             fRotate,
1719414a0e15SArmin Le Grand             aTranslate);
1720414a0e15SArmin Le Grand     }
1721414a0e15SArmin Le Grand 
1722414a0e15SArmin Le Grand     // get crop values
1723414a0e15SArmin Le Grand     const SdrGrafCropItem& rCrop = static_cast< const SdrGrafCropItem& >(GetMergedItem(SDRATTR_GRAFCROP));
1724414a0e15SArmin Le Grand 
1725414a0e15SArmin Le Grand     if(rCrop.GetLeft() || rCrop.GetTop() || rCrop.GetRight() ||rCrop.GetBottom())
1726414a0e15SArmin Le Grand     {
1727414a0e15SArmin Le Grand         // decompose object transformation to have current translate and scale
1728414a0e15SArmin Le Grand         basegfx::B2DVector aScale, aTranslate;
1729414a0e15SArmin Le Grand         double fRotate, fShearX;
1730414a0e15SArmin Le Grand 
1731414a0e15SArmin Le Grand         aMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
1732414a0e15SArmin Le Grand 
1733414a0e15SArmin Le Grand         if(!aScale.equalZero())
1734414a0e15SArmin Le Grand         {
1735414a0e15SArmin Le Grand             // get crop scale
1736414a0e15SArmin Le Grand             const basegfx::B2DVector aCropScaleFactor(
1737414a0e15SArmin Le Grand                 GetGraphicObject().calculateCropScaling(
1738414a0e15SArmin Le Grand                     aScale.getX(),
1739414a0e15SArmin Le Grand                     aScale.getY(),
1740414a0e15SArmin Le Grand                     rCrop.GetLeft(),
1741414a0e15SArmin Le Grand                     rCrop.GetTop(),
1742414a0e15SArmin Le Grand                     rCrop.GetRight(),
1743414a0e15SArmin Le Grand                     rCrop.GetBottom()));
1744414a0e15SArmin Le Grand 
1745414a0e15SArmin Le Grand             // apply crop scale
1746414a0e15SArmin Le Grand             const double fCropLeft(rCrop.GetLeft() * aCropScaleFactor.getX());
1747414a0e15SArmin Le Grand             const double fCropTop(rCrop.GetTop() * aCropScaleFactor.getY());
1748414a0e15SArmin Le Grand             const double fCropRight(rCrop.GetRight() * aCropScaleFactor.getX());
1749414a0e15SArmin Le Grand             const double fCropBottom(rCrop.GetBottom() * aCropScaleFactor.getY());
1750414a0e15SArmin Le Grand             basegfx::B2DHomMatrix aMatrixForCropViewHdl(aMatrix);
1751414a0e15SArmin Le Grand 
1752414a0e15SArmin Le Grand             if(IsMirrored())
1753414a0e15SArmin Le Grand             {
1754414a0e15SArmin Le Grand                 // create corrected new matrix, TTTT can be removed with aw080
1755414a0e15SArmin Le Grand                 // the old mirror only can mirror horizontally; the vertical mirror
1756414a0e15SArmin Le Grand                 // is faked by using the horizontal and 180 degree rotation. Since
1757414a0e15SArmin Le Grand                 // the object can be rotated differently from 180 degree, this is
1758414a0e15SArmin Le Grand                 // not safe to detect. Just correct horizontal mirror (which is
1759414a0e15SArmin Le Grand                 // in IsMirrored()) and keep the rotation angle
1760414a0e15SArmin Le Grand                 // caution: Do not modify aMatrix, it is used below to calculate
1761414a0e15SArmin Le Grand                 // the exact handle positions
1762414a0e15SArmin Le Grand                 basegfx::B2DHomMatrix aPreMultiply;
1763414a0e15SArmin Le Grand 
1764414a0e15SArmin Le Grand                 // mirrored X, apply
1765414a0e15SArmin Le Grand                 aPreMultiply.translate(-0.5, 0.0);
1766414a0e15SArmin Le Grand                 aPreMultiply.scale(-1.0, 1.0);
1767414a0e15SArmin Le Grand                 aPreMultiply.translate(0.5, 0.0);
1768414a0e15SArmin Le Grand 
1769414a0e15SArmin Le Grand                 aMatrixForCropViewHdl = aMatrixForCropViewHdl * aPreMultiply;
1770414a0e15SArmin Le Grand             }
1771414a0e15SArmin Le Grand 
1772414a0e15SArmin Le Grand             rTarget.AddHdl(
1773414a0e15SArmin Le Grand                 new SdrCropViewHdl(
1774414a0e15SArmin Le Grand                     aMatrixForCropViewHdl,
1775414a0e15SArmin Le Grand                     GetGraphicObject().GetGraphic(),
1776414a0e15SArmin Le Grand                     fCropLeft,
1777414a0e15SArmin Le Grand                     fCropTop,
1778414a0e15SArmin Le Grand                     fCropRight,
1779414a0e15SArmin Le Grand                     fCropBottom));
1780414a0e15SArmin Le Grand         }
1781414a0e15SArmin Le Grand     }
1782414a0e15SArmin Le Grand 
1783414a0e15SArmin Le Grand     basegfx::B2DPoint aPos;
1784414a0e15SArmin Le Grand 
1785414a0e15SArmin Le Grand     aPos = aMatrix * basegfx::B2DPoint(0.0, 0.0);
1786414a0e15SArmin Le Grand     rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_UPLFT, fShearX, fRotate));
1787414a0e15SArmin Le Grand     aPos = aMatrix * basegfx::B2DPoint(0.5, 0.0);
1788414a0e15SArmin Le Grand     rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_UPPER, fShearX, fRotate));
1789414a0e15SArmin Le Grand     aPos = aMatrix * basegfx::B2DPoint(1.0, 0.0);
1790414a0e15SArmin Le Grand     rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_UPRGT, fShearX, fRotate));
1791414a0e15SArmin Le Grand     aPos = aMatrix * basegfx::B2DPoint(0.0, 0.5);
1792414a0e15SArmin Le Grand     rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_LEFT , fShearX, fRotate));
1793414a0e15SArmin Le Grand     aPos = aMatrix * basegfx::B2DPoint(1.0, 0.5);
1794414a0e15SArmin Le Grand     rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_RIGHT, fShearX, fRotate));
1795414a0e15SArmin Le Grand     aPos = aMatrix * basegfx::B2DPoint(0.0, 1.0);
1796414a0e15SArmin Le Grand     rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_LWLFT, fShearX, fRotate));
1797414a0e15SArmin Le Grand     aPos = aMatrix * basegfx::B2DPoint(0.5, 1.0);
1798414a0e15SArmin Le Grand     rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_LOWER, fShearX, fRotate));
1799414a0e15SArmin Le Grand     aPos = aMatrix * basegfx::B2DPoint(1.0, 1.0);
1800414a0e15SArmin Le Grand     rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), HDL_LWRGT, fShearX, fRotate));
1801414a0e15SArmin Le Grand }
1802414a0e15SArmin Le Grand 
1803cdf0e10cSrcweir // eof
1804