15900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
35900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
55900e8ecSAndrew Rist * distributed with this work for additional information
65900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
75900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
105900e8ecSAndrew Rist *
115900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
125900e8ecSAndrew Rist *
135900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist * software distributed under the License is distributed on an
155900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
175900e8ecSAndrew Rist * specific language governing permissions and limitations
185900e8ecSAndrew Rist * under the License.
195900e8ecSAndrew Rist *
205900e8ecSAndrew Rist *************************************************************/
215900e8ecSAndrew Rist
225900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <svtools/embedhlp.hxx>
28cdf0e10cSrcweir #include <svtools/filter.hxx>
29cdf0e10cSrcweir #include <svtools/svtools.hrc>
30cdf0e10cSrcweir #include <svtools/svtdata.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <comphelper/embeddedobjectcontainer.hxx>
33cdf0e10cSrcweir #include <comphelper/seqstream.hxx>
34cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
35cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
36cdf0e10cSrcweir #include <unotools/streamwrap.hxx>
372bfcd321SSteve Yin #include <com/sun/star/chart2/XChartDocument.hpp>
382bfcd321SSteve Yin #include <com/sun/star/chart2/XCoordinateSystem.hpp>
392bfcd321SSteve Yin #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
402bfcd321SSteve Yin #include <com/sun/star/chart2/XDiagram.hpp>
412bfcd321SSteve Yin #include <com/sun/star/chart2/XChartTypeContainer.hpp>
422bfcd321SSteve Yin #include <com/sun/star/chart2/XChartType.hpp>
43cdf0e10cSrcweir #include <tools/globname.hxx>
44cdf0e10cSrcweir #include <sot/clsids.hxx>
45cdf0e10cSrcweir #include <com/sun/star/util/XModifyListener.hpp>
46cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XMODIFYiBLE_HPP_
47cdf0e10cSrcweir #include <com/sun/star/util/XModifiable.hpp>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
50cdf0e10cSrcweir #include <com/sun/star/embed/EmbedMisc.hpp>
51cdf0e10cSrcweir #include <com/sun/star/embed/XStateChangeListener.hpp>
52cdf0e10cSrcweir #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
53cdf0e10cSrcweir #include <com/sun/star/util/XModifiable.hpp>
54cdf0e10cSrcweir #include <com/sun/star/datatransfer/XTransferable.hpp>
55cdf0e10cSrcweir #include <com/sun/star/chart2/XDefaultSizeTransmitter.hpp>
56cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx>
57cdf0e10cSrcweir #include "vcl/svapp.hxx"
58cdf0e10cSrcweir #include <rtl/logfile.hxx>
59cdf0e10cSrcweir #include <vos/mutex.hxx>
60cdf0e10cSrcweir
61cdf0e10cSrcweir using namespace com::sun::star;
62cdf0e10cSrcweir
63cdf0e10cSrcweir namespace svt
64cdf0e10cSrcweir {
65cdf0e10cSrcweir
66cdf0e10cSrcweir class EmbedEventListener_Impl : public ::cppu::WeakImplHelper4 < embed::XStateChangeListener,
67cdf0e10cSrcweir document::XEventListener,
68cdf0e10cSrcweir util::XModifyListener,
69cdf0e10cSrcweir util::XCloseListener >
70cdf0e10cSrcweir {
71cdf0e10cSrcweir public:
72cdf0e10cSrcweir EmbeddedObjectRef* pObject;
73cdf0e10cSrcweir sal_Int32 nState;
74cdf0e10cSrcweir
EmbedEventListener_Impl(EmbeddedObjectRef * p)75cdf0e10cSrcweir EmbedEventListener_Impl( EmbeddedObjectRef* p ) :
76cdf0e10cSrcweir pObject(p)
77cdf0e10cSrcweir , nState(-1)
78cdf0e10cSrcweir {}
79cdf0e10cSrcweir
80cdf0e10cSrcweir static EmbedEventListener_Impl* Create( EmbeddedObjectRef* );
81cdf0e10cSrcweir
82cdf0e10cSrcweir virtual void SAL_CALL changingState( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
83cdf0e10cSrcweir throw (embed::WrongStateException, uno::RuntimeException);
84cdf0e10cSrcweir virtual void SAL_CALL stateChanged( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
85cdf0e10cSrcweir throw (uno::RuntimeException);
86cdf0e10cSrcweir virtual void SAL_CALL queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership )
87cdf0e10cSrcweir throw (util::CloseVetoException, uno::RuntimeException);
88cdf0e10cSrcweir virtual void SAL_CALL notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException);
89cdf0e10cSrcweir virtual void SAL_CALL notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException );
90cdf0e10cSrcweir virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw( uno::RuntimeException );
91cdf0e10cSrcweir virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
92cdf0e10cSrcweir };
93cdf0e10cSrcweir
Create(EmbeddedObjectRef * p)94cdf0e10cSrcweir EmbedEventListener_Impl* EmbedEventListener_Impl::Create( EmbeddedObjectRef* p )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir EmbedEventListener_Impl* xRet = new EmbedEventListener_Impl( p );
97cdf0e10cSrcweir xRet->acquire();
98cdf0e10cSrcweir
99cdf0e10cSrcweir if ( p->GetObject().is() )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir p->GetObject()->addStateChangeListener( xRet );
102cdf0e10cSrcweir
103cdf0e10cSrcweir uno::Reference < util::XCloseable > xClose( p->GetObject(), uno::UNO_QUERY );
104cdf0e10cSrcweir DBG_ASSERT( xClose.is(), "Object does not support XCloseable!" );
105cdf0e10cSrcweir if ( xClose.is() )
106cdf0e10cSrcweir xClose->addCloseListener( xRet );
107cdf0e10cSrcweir
108cdf0e10cSrcweir uno::Reference < document::XEventBroadcaster > xBrd( p->GetObject(), uno::UNO_QUERY );
109cdf0e10cSrcweir if ( xBrd.is() )
110cdf0e10cSrcweir xBrd->addEventListener( xRet );
111cdf0e10cSrcweir
112cdf0e10cSrcweir xRet->nState = p->GetObject()->getCurrentState();
113cdf0e10cSrcweir if ( xRet->nState == embed::EmbedStates::RUNNING )
114cdf0e10cSrcweir {
115cdf0e10cSrcweir uno::Reference < util::XModifiable > xMod( p->GetObject()->getComponent(), uno::UNO_QUERY );
116cdf0e10cSrcweir if ( xMod.is() )
117cdf0e10cSrcweir // listen for changes in running state (update replacements in case of changes)
118cdf0e10cSrcweir xMod->addModifyListener( xRet );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir return xRet;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
changingState(const lang::EventObject &,::sal_Int32,::sal_Int32)125cdf0e10cSrcweir void SAL_CALL EmbedEventListener_Impl::changingState( const lang::EventObject&,
126cdf0e10cSrcweir ::sal_Int32,
127cdf0e10cSrcweir ::sal_Int32 )
128cdf0e10cSrcweir throw ( embed::WrongStateException,
129cdf0e10cSrcweir uno::RuntimeException )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
stateChanged(const lang::EventObject &,::sal_Int32 nOldState,::sal_Int32 nNewState)133cdf0e10cSrcweir void SAL_CALL EmbedEventListener_Impl::stateChanged( const lang::EventObject&,
134cdf0e10cSrcweir ::sal_Int32 nOldState,
135cdf0e10cSrcweir ::sal_Int32 nNewState )
136cdf0e10cSrcweir throw ( uno::RuntimeException )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
139cdf0e10cSrcweir nState = nNewState;
140cdf0e10cSrcweir if ( !pObject )
141cdf0e10cSrcweir return;
142cdf0e10cSrcweir
143cdf0e10cSrcweir uno::Reference < util::XModifiable > xMod( pObject->GetObject()->getComponent(), uno::UNO_QUERY );
144cdf0e10cSrcweir if ( nNewState == embed::EmbedStates::RUNNING )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir // TODO/LATER: container must be set before!
147cdf0e10cSrcweir // When is this event created? Who sets the new container when it changed?
148cdf0e10cSrcweir if( ( pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON ) && nOldState != embed::EmbedStates::LOADED && !pObject->IsChart() )
149cdf0e10cSrcweir // get new replacement after deactivation
150cdf0e10cSrcweir pObject->UpdateReplacement();
151cdf0e10cSrcweir
152cdf0e10cSrcweir if( pObject->IsChart() && nOldState == embed::EmbedStates::UI_ACTIVE )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir //create a new metafile replacement when leaving the edit mode
155cdf0e10cSrcweir //for buggy documents where the old image looks different from the correct one
156cdf0e10cSrcweir if( xMod.is() && !xMod->isModified() )//in case of modification a new replacement will be requested anyhow
157cdf0e10cSrcweir pObject->UpdateReplacementOnDemand();
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
160cdf0e10cSrcweir if ( xMod.is() && nOldState == embed::EmbedStates::LOADED )
161cdf0e10cSrcweir // listen for changes (update replacements in case of changes)
162cdf0e10cSrcweir xMod->addModifyListener( this );
163cdf0e10cSrcweir }
164cdf0e10cSrcweir else if ( nNewState == embed::EmbedStates::LOADED )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir // in loaded state we can't listen
167cdf0e10cSrcweir if ( xMod.is() )
168cdf0e10cSrcweir xMod->removeModifyListener( this );
169cdf0e10cSrcweir }
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
modified(const lang::EventObject &)172cdf0e10cSrcweir void SAL_CALL EmbedEventListener_Impl::modified( const lang::EventObject& ) throw (uno::RuntimeException)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
175cdf0e10cSrcweir if ( pObject && pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir if ( nState == embed::EmbedStates::RUNNING )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir // updates only necessary in non-active states
180cdf0e10cSrcweir if( pObject->IsChart() )
181cdf0e10cSrcweir pObject->UpdateReplacementOnDemand();
182cdf0e10cSrcweir else
183cdf0e10cSrcweir pObject->UpdateReplacement();
184cdf0e10cSrcweir }
185cdf0e10cSrcweir else if ( nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::INPLACE_ACTIVE )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir // in case the object is inplace or UI active the replacement image should be updated on demand
188cdf0e10cSrcweir pObject->UpdateReplacementOnDemand();
189cdf0e10cSrcweir }
190cdf0e10cSrcweir }
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
notifyEvent(const document::EventObject & aEvent)193cdf0e10cSrcweir void SAL_CALL EmbedEventListener_Impl::notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
196cdf0e10cSrcweir
197cdf0e10cSrcweir #if 0
198cdf0e10cSrcweir if ( pObject && aEvent.EventName.equalsAscii("OnSaveDone") || aEvent.EventName.equalsAscii("OnSaveAsDone") )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir // TODO/LATER: container must be set before!
201cdf0e10cSrcweir // When is this event created? Who sets the new container when it changed?
202cdf0e10cSrcweir pObject->UpdateReplacement();
203cdf0e10cSrcweir }
204cdf0e10cSrcweir else
205cdf0e10cSrcweir #endif
206cdf0e10cSrcweir if ( pObject && aEvent.EventName.equalsAscii("OnVisAreaChanged") && pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON && !pObject->IsChart() )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir pObject->UpdateReplacement();
209cdf0e10cSrcweir }
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
queryClosing(const lang::EventObject & Source,::sal_Bool)212cdf0e10cSrcweir void SAL_CALL EmbedEventListener_Impl::queryClosing( const lang::EventObject& Source, ::sal_Bool )
213cdf0e10cSrcweir throw ( util::CloseVetoException, uno::RuntimeException)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir // An embedded object can be shared between several objects (f.e. for undo purposes)
216cdf0e10cSrcweir // the object will not be closed before the last "customer" is destroyed
217cdf0e10cSrcweir // Now the EmbeddedObjectRef helper class works like a "lock" on the object
218cdf0e10cSrcweir if ( pObject && pObject->IsLocked() && Source.Source == pObject->GetObject() )
219cdf0e10cSrcweir throw util::CloseVetoException();
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
notifyClosing(const lang::EventObject & Source)222cdf0e10cSrcweir void SAL_CALL EmbedEventListener_Impl::notifyClosing( const lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
223cdf0e10cSrcweir {
224cdf0e10cSrcweir if ( pObject && Source.Source == pObject->GetObject() )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir pObject->Clear();
227cdf0e10cSrcweir pObject = 0;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
disposing(const lang::EventObject & aEvent)231cdf0e10cSrcweir void SAL_CALL EmbedEventListener_Impl::disposing( const lang::EventObject& aEvent ) throw( uno::RuntimeException )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir if ( pObject && aEvent.Source == pObject->GetObject() )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir pObject->Clear();
236cdf0e10cSrcweir pObject = 0;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
240cdf0e10cSrcweir struct EmbeddedObjectRef_Impl
241cdf0e10cSrcweir {
242cdf0e10cSrcweir EmbedEventListener_Impl* xListener;
243cdf0e10cSrcweir ::rtl::OUString aPersistName;
244cdf0e10cSrcweir ::rtl::OUString aMediaType;
245cdf0e10cSrcweir comphelper::EmbeddedObjectContainer* pContainer;
246cdf0e10cSrcweir Graphic* pGraphic;
247cdf0e10cSrcweir Graphic* pHCGraphic;
248cdf0e10cSrcweir sal_Int64 nViewAspect;
249cdf0e10cSrcweir sal_Bool bIsLocked;
250cdf0e10cSrcweir sal_Bool bNeedUpdate;
251cdf0e10cSrcweir
252cdf0e10cSrcweir // #i104867#
253cdf0e10cSrcweir sal_uInt32 mnGraphicVersion;
254cdf0e10cSrcweir awt::Size aDefaultSizeForChart_In_100TH_MM;//#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this member
255cdf0e10cSrcweir };
256cdf0e10cSrcweir
Construct_Impl()257cdf0e10cSrcweir void EmbeddedObjectRef::Construct_Impl()
258cdf0e10cSrcweir {
259cdf0e10cSrcweir mpImp = new EmbeddedObjectRef_Impl;
260cdf0e10cSrcweir mpImp->pContainer = 0;
261cdf0e10cSrcweir mpImp->pGraphic = 0;
262cdf0e10cSrcweir mpImp->pHCGraphic = 0;
263cdf0e10cSrcweir mpImp->nViewAspect = embed::Aspects::MSOLE_CONTENT;
264cdf0e10cSrcweir mpImp->bIsLocked = sal_False;
265cdf0e10cSrcweir mpImp->bNeedUpdate = sal_False;
266cdf0e10cSrcweir mpImp->mnGraphicVersion = 0;
267cdf0e10cSrcweir mpImp->aDefaultSizeForChart_In_100TH_MM = awt::Size(8000,7000);
268cdf0e10cSrcweir }
269cdf0e10cSrcweir
EmbeddedObjectRef()270cdf0e10cSrcweir EmbeddedObjectRef::EmbeddedObjectRef()
271cdf0e10cSrcweir {
272cdf0e10cSrcweir Construct_Impl();
273cdf0e10cSrcweir }
274cdf0e10cSrcweir
EmbeddedObjectRef(const NS_UNO::Reference<NS_EMBED::XEmbeddedObject> & xObj,sal_Int64 nAspect)275cdf0e10cSrcweir EmbeddedObjectRef::EmbeddedObjectRef( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& xObj, sal_Int64 nAspect )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir Construct_Impl();
278cdf0e10cSrcweir mpImp->nViewAspect = nAspect;
279cdf0e10cSrcweir mxObj = xObj;
280cdf0e10cSrcweir mpImp->xListener = EmbedEventListener_Impl::Create( this );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir
EmbeddedObjectRef(const EmbeddedObjectRef & rObj)283cdf0e10cSrcweir EmbeddedObjectRef::EmbeddedObjectRef( const EmbeddedObjectRef& rObj )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir mpImp = new EmbeddedObjectRef_Impl;
286cdf0e10cSrcweir mpImp->pContainer = rObj.mpImp->pContainer;
287cdf0e10cSrcweir mpImp->nViewAspect = rObj.mpImp->nViewAspect;
288cdf0e10cSrcweir mpImp->bIsLocked = rObj.mpImp->bIsLocked;
289cdf0e10cSrcweir mxObj = rObj.mxObj;
290cdf0e10cSrcweir mpImp->xListener = EmbedEventListener_Impl::Create( this );
291cdf0e10cSrcweir mpImp->aPersistName = rObj.mpImp->aPersistName;
292cdf0e10cSrcweir mpImp->aMediaType = rObj.mpImp->aMediaType;
293cdf0e10cSrcweir mpImp->bNeedUpdate = rObj.mpImp->bNeedUpdate;
294cdf0e10cSrcweir mpImp->aDefaultSizeForChart_In_100TH_MM = rObj.mpImp->aDefaultSizeForChart_In_100TH_MM;
295cdf0e10cSrcweir
296cdf0e10cSrcweir if ( rObj.mpImp->pGraphic && !rObj.mpImp->bNeedUpdate )
297cdf0e10cSrcweir mpImp->pGraphic = new Graphic( *rObj.mpImp->pGraphic );
298cdf0e10cSrcweir else
299cdf0e10cSrcweir mpImp->pGraphic = 0;
300cdf0e10cSrcweir
301cdf0e10cSrcweir mpImp->pHCGraphic = 0;
302cdf0e10cSrcweir mpImp->mnGraphicVersion = 0;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
~EmbeddedObjectRef()305cdf0e10cSrcweir EmbeddedObjectRef::~EmbeddedObjectRef()
306cdf0e10cSrcweir {
307cdf0e10cSrcweir delete mpImp->pGraphic;
308cdf0e10cSrcweir if ( mpImp->pHCGraphic )
309cdf0e10cSrcweir DELETEZ( mpImp->pHCGraphic );
310cdf0e10cSrcweir Clear();
3114fa9ac85SHerbert Dürr delete mpImp;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir /*
314cdf0e10cSrcweir EmbeddedObjectRef& EmbeddedObjectRef::operator = ( const EmbeddedObjectRef& rObj )
315cdf0e10cSrcweir {
316cdf0e10cSrcweir DBG_ASSERT( !mxObj.is(), "Never assign an already assigned object!" );
317cdf0e10cSrcweir
318cdf0e10cSrcweir delete mpImp->pGraphic;
319cdf0e10cSrcweir if ( mpImp->pHCGraphic ) DELETEZ( mpImp->pHCGraphic );
320cdf0e10cSrcweir Clear();
321cdf0e10cSrcweir
322cdf0e10cSrcweir mpImp->nViewAspect = rObj.mpImp->nViewAspect;
323cdf0e10cSrcweir mpImp->bIsLocked = rObj.mpImp->bIsLocked;
324cdf0e10cSrcweir mxObj = rObj.mxObj;
325cdf0e10cSrcweir mpImp->xListener = EmbedEventListener_Impl::Create( this );
326cdf0e10cSrcweir mpImp->pContainer = rObj.mpImp->pContainer;
327cdf0e10cSrcweir mpImp->aPersistName = rObj.mpImp->aPersistName;
328cdf0e10cSrcweir mpImp->aMediaType = rObj.mpImp->aMediaType;
329cdf0e10cSrcweir mpImp->bNeedUpdate = rObj.mpImp->bNeedUpdate;
330cdf0e10cSrcweir
331cdf0e10cSrcweir if ( rObj.mpImp->pGraphic && !rObj.mpImp->bNeedUpdate )
332cdf0e10cSrcweir mpImp->pGraphic = new Graphic( *rObj.mpImp->pGraphic );
333cdf0e10cSrcweir else
334cdf0e10cSrcweir mpImp->pGraphic = 0;
335cdf0e10cSrcweir return *this;
336cdf0e10cSrcweir }
337cdf0e10cSrcweir */
Assign(const NS_UNO::Reference<NS_EMBED::XEmbeddedObject> & xObj,sal_Int64 nAspect)338cdf0e10cSrcweir void EmbeddedObjectRef::Assign( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& xObj, sal_Int64 nAspect )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir DBG_ASSERT( !mxObj.is(), "Never assign an already assigned object!" );
341cdf0e10cSrcweir
342cdf0e10cSrcweir Clear();
343cdf0e10cSrcweir mpImp->nViewAspect = nAspect;
344cdf0e10cSrcweir mxObj = xObj;
345cdf0e10cSrcweir mpImp->xListener = EmbedEventListener_Impl::Create( this );
346cdf0e10cSrcweir
347cdf0e10cSrcweir //#i103460#
348cdf0e10cSrcweir if ( IsChart() )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::chart2::XDefaultSizeTransmitter > xSizeTransmitter( xObj, uno::UNO_QUERY );
351cdf0e10cSrcweir DBG_ASSERT( xSizeTransmitter.is(), "Object does not support XDefaultSizeTransmitter -> will cause #i103460#!" );
352cdf0e10cSrcweir if( xSizeTransmitter.is() )
353cdf0e10cSrcweir xSizeTransmitter->setDefaultSize( mpImp->aDefaultSizeForChart_In_100TH_MM );
354cdf0e10cSrcweir }
355cdf0e10cSrcweir }
356cdf0e10cSrcweir
Clear()357cdf0e10cSrcweir void EmbeddedObjectRef::Clear()
358cdf0e10cSrcweir {
359cdf0e10cSrcweir if ( mxObj.is() && mpImp->xListener )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir mxObj->removeStateChangeListener( mpImp->xListener );
362cdf0e10cSrcweir
363cdf0e10cSrcweir uno::Reference < util::XCloseable > xClose( mxObj, uno::UNO_QUERY );
364cdf0e10cSrcweir if ( xClose.is() )
365cdf0e10cSrcweir xClose->removeCloseListener( mpImp->xListener );
366cdf0e10cSrcweir
367cdf0e10cSrcweir uno::Reference < document::XEventBroadcaster > xBrd( mxObj, uno::UNO_QUERY );
368cdf0e10cSrcweir if ( xBrd.is() )
369cdf0e10cSrcweir xBrd->removeEventListener( mpImp->xListener );
370cdf0e10cSrcweir
371cdf0e10cSrcweir if ( mpImp->bIsLocked )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir if ( xClose.is() )
374cdf0e10cSrcweir {
375cdf0e10cSrcweir try
376cdf0e10cSrcweir {
377cdf0e10cSrcweir mxObj->changeState( embed::EmbedStates::LOADED );
378cdf0e10cSrcweir xClose->close( sal_True );
379cdf0e10cSrcweir }
380cdf0e10cSrcweir catch ( util::CloseVetoException& )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir // there's still someone who needs the object!
383cdf0e10cSrcweir }
384cdf0e10cSrcweir catch ( uno::Exception& )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir OSL_ENSURE( sal_False, "Error on switching of the object to loaded state and closing!\n" );
387cdf0e10cSrcweir }
388cdf0e10cSrcweir }
389cdf0e10cSrcweir }
390cdf0e10cSrcweir
391cdf0e10cSrcweir if ( mpImp->xListener )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir mpImp->xListener->pObject = 0;
394cdf0e10cSrcweir mpImp->xListener->release();
395cdf0e10cSrcweir mpImp->xListener = 0;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir
398cdf0e10cSrcweir mxObj = 0;
399cdf0e10cSrcweir mpImp->bNeedUpdate = sal_False;
400cdf0e10cSrcweir }
401cdf0e10cSrcweir
402cdf0e10cSrcweir mpImp->pContainer = 0;
403cdf0e10cSrcweir mpImp->bIsLocked = sal_False;
404cdf0e10cSrcweir mpImp->bNeedUpdate = sal_False;
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
AssignToContainer(comphelper::EmbeddedObjectContainer * pContainer,const::rtl::OUString & rPersistName)407cdf0e10cSrcweir void EmbeddedObjectRef::AssignToContainer( comphelper::EmbeddedObjectContainer* pContainer, const ::rtl::OUString& rPersistName )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir mpImp->pContainer = pContainer;
410cdf0e10cSrcweir mpImp->aPersistName = rPersistName;
411cdf0e10cSrcweir
412cdf0e10cSrcweir if ( mpImp->pGraphic && !mpImp->bNeedUpdate && pContainer )
413cdf0e10cSrcweir SetGraphicToContainer( *mpImp->pGraphic, *pContainer, mpImp->aPersistName, ::rtl::OUString() );
414cdf0e10cSrcweir }
415cdf0e10cSrcweir
GetContainer() const416cdf0e10cSrcweir comphelper::EmbeddedObjectContainer* EmbeddedObjectRef::GetContainer() const
417cdf0e10cSrcweir {
418cdf0e10cSrcweir return mpImp->pContainer;
419cdf0e10cSrcweir }
420cdf0e10cSrcweir
GetPersistName() const421cdf0e10cSrcweir ::rtl::OUString EmbeddedObjectRef::GetPersistName() const
422cdf0e10cSrcweir {
423cdf0e10cSrcweir return mpImp->aPersistName;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir
GetMapUnit() const426cdf0e10cSrcweir MapUnit EmbeddedObjectRef::GetMapUnit() const
427cdf0e10cSrcweir {
428cdf0e10cSrcweir if ( mpImp->nViewAspect == embed::Aspects::MSOLE_CONTENT )
429cdf0e10cSrcweir return VCLUnoHelper::UnoEmbed2VCLMapUnit( mxObj->getMapUnit( mpImp->nViewAspect ) );
430cdf0e10cSrcweir else
431cdf0e10cSrcweir // TODO/LATER: currently only CONTENT aspect requires communication with the object
432cdf0e10cSrcweir return MAP_100TH_MM;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir
GetViewAspect() const435cdf0e10cSrcweir sal_Int64 EmbeddedObjectRef::GetViewAspect() const
436cdf0e10cSrcweir {
437cdf0e10cSrcweir return mpImp->nViewAspect;
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
SetViewAspect(sal_Int64 nAspect)440cdf0e10cSrcweir void EmbeddedObjectRef::SetViewAspect( sal_Int64 nAspect )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir mpImp->nViewAspect = nAspect;
443cdf0e10cSrcweir }
444cdf0e10cSrcweir
Lock(sal_Bool bLock)445cdf0e10cSrcweir void EmbeddedObjectRef::Lock( sal_Bool bLock )
446cdf0e10cSrcweir {
447cdf0e10cSrcweir mpImp->bIsLocked = bLock;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir
IsLocked() const450cdf0e10cSrcweir sal_Bool EmbeddedObjectRef::IsLocked() const
451cdf0e10cSrcweir {
452cdf0e10cSrcweir return mpImp->bIsLocked;
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
GetReplacement(sal_Bool bUpdate)455cdf0e10cSrcweir void EmbeddedObjectRef::GetReplacement( sal_Bool bUpdate )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir if ( bUpdate )
458cdf0e10cSrcweir {
459cdf0e10cSrcweir DELETEZ( mpImp->pGraphic );
460cdf0e10cSrcweir mpImp->aMediaType = ::rtl::OUString();
461cdf0e10cSrcweir mpImp->pGraphic = new Graphic;
462cdf0e10cSrcweir if ( mpImp->pHCGraphic )
463cdf0e10cSrcweir DELETEZ( mpImp->pHCGraphic );
464cdf0e10cSrcweir mpImp->mnGraphicVersion++;
465cdf0e10cSrcweir }
466cdf0e10cSrcweir else if ( !mpImp->pGraphic )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir mpImp->pGraphic = new Graphic;
469cdf0e10cSrcweir mpImp->mnGraphicVersion++;
470cdf0e10cSrcweir }
471cdf0e10cSrcweir else
472cdf0e10cSrcweir {
473cdf0e10cSrcweir DBG_ERROR("No update, but replacement exists already!");
474cdf0e10cSrcweir return;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
477cdf0e10cSrcweir SvStream* pGraphicStream = GetGraphicStream( bUpdate );
478cdf0e10cSrcweir if ( pGraphicStream )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
481cdf0e10cSrcweir if( mpImp->pGraphic )
482cdf0e10cSrcweir pGF->ImportGraphic( *mpImp->pGraphic, String(), *pGraphicStream, GRFILTER_FORMAT_DONTKNOW );
483cdf0e10cSrcweir mpImp->mnGraphicVersion++;
484cdf0e10cSrcweir delete pGraphicStream;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir }
487cdf0e10cSrcweir
GetGraphic(::rtl::OUString * pMediaType) const488cdf0e10cSrcweir Graphic* EmbeddedObjectRef::GetGraphic( ::rtl::OUString* pMediaType ) const
489cdf0e10cSrcweir {
4902c35faf5SArmin Le Grand try
4912c35faf5SArmin Le Grand {
4922c35faf5SArmin Le Grand if ( mpImp->bNeedUpdate )
4932c35faf5SArmin Le Grand // bNeedUpdate will be set to false while retrieving new replacement
4942c35faf5SArmin Le Grand const_cast < EmbeddedObjectRef* >(this)->GetReplacement( sal_True );
4952c35faf5SArmin Le Grand else if ( !mpImp->pGraphic )
4962c35faf5SArmin Le Grand const_cast < EmbeddedObjectRef* >(this)->GetReplacement( sal_False );
4972c35faf5SArmin Le Grand }
4982c35faf5SArmin Le Grand catch( uno::Exception& )
4992c35faf5SArmin Le Grand {
5002c35faf5SArmin Le Grand OSL_ENSURE( sal_False, "Something went wrong on getting the graphic!" );
5012c35faf5SArmin Le Grand }
502cdf0e10cSrcweir
503cdf0e10cSrcweir if ( mpImp->pGraphic && pMediaType )
504cdf0e10cSrcweir *pMediaType = mpImp->aMediaType;
505cdf0e10cSrcweir return mpImp->pGraphic;
506cdf0e10cSrcweir }
507cdf0e10cSrcweir
GetSize(MapMode * pTargetMapMode) const508cdf0e10cSrcweir Size EmbeddedObjectRef::GetSize( MapMode* pTargetMapMode ) const
509cdf0e10cSrcweir {
510cdf0e10cSrcweir MapMode aSourceMapMode( MAP_100TH_MM );
511cdf0e10cSrcweir Size aResult;
512cdf0e10cSrcweir
513cdf0e10cSrcweir if ( mpImp->nViewAspect == embed::Aspects::MSOLE_ICON )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir Graphic* pGraphic = GetGraphic();
516cdf0e10cSrcweir if ( pGraphic )
517cdf0e10cSrcweir {
518cdf0e10cSrcweir aSourceMapMode = pGraphic->GetPrefMapMode();
519cdf0e10cSrcweir aResult = pGraphic->GetPrefSize();
520cdf0e10cSrcweir }
521cdf0e10cSrcweir else
522cdf0e10cSrcweir aResult = Size( 2500, 2500 );
523cdf0e10cSrcweir }
524cdf0e10cSrcweir else
525cdf0e10cSrcweir {
526cdf0e10cSrcweir awt::Size aSize;
527cdf0e10cSrcweir
528cdf0e10cSrcweir if ( mxObj.is() )
529cdf0e10cSrcweir {
530cdf0e10cSrcweir try
531cdf0e10cSrcweir {
532cdf0e10cSrcweir aSize = mxObj->getVisualAreaSize( mpImp->nViewAspect );
533cdf0e10cSrcweir }
534cdf0e10cSrcweir catch( embed::NoVisualAreaSizeException& )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir }
537cdf0e10cSrcweir catch( uno::Exception& )
538cdf0e10cSrcweir {
539cdf0e10cSrcweir OSL_ENSURE( sal_False, "Something went wrong on getting of the size of the object!" );
540cdf0e10cSrcweir }
541cdf0e10cSrcweir
542cdf0e10cSrcweir try
543cdf0e10cSrcweir {
544cdf0e10cSrcweir aSourceMapMode = VCLUnoHelper::UnoEmbed2VCLMapUnit( mxObj->getMapUnit( mpImp->nViewAspect ) );
545cdf0e10cSrcweir }
546cdf0e10cSrcweir catch( uno::Exception )
547cdf0e10cSrcweir {
548cdf0e10cSrcweir OSL_ENSURE( sal_False, "Can not get the map mode!" );
549cdf0e10cSrcweir }
550cdf0e10cSrcweir }
551cdf0e10cSrcweir
552cdf0e10cSrcweir if ( !aSize.Height && !aSize.Width )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir aSize.Width = 5000;
555cdf0e10cSrcweir aSize.Height = 5000;
556cdf0e10cSrcweir }
557cdf0e10cSrcweir
558cdf0e10cSrcweir aResult = Size( aSize.Width, aSize.Height );
559cdf0e10cSrcweir }
560cdf0e10cSrcweir
561cdf0e10cSrcweir if ( pTargetMapMode )
562cdf0e10cSrcweir aResult = OutputDevice::LogicToLogic( aResult, aSourceMapMode, *pTargetMapMode );
563cdf0e10cSrcweir
564cdf0e10cSrcweir return aResult;
565cdf0e10cSrcweir }
566cdf0e10cSrcweir
GetHCGraphic() const567cdf0e10cSrcweir Graphic* EmbeddedObjectRef::GetHCGraphic() const
568cdf0e10cSrcweir {
569cdf0e10cSrcweir if ( !mpImp->pHCGraphic )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir uno::Reference< io::XInputStream > xInStream;
572cdf0e10cSrcweir try
573cdf0e10cSrcweir {
574cdf0e10cSrcweir // if the object needs size on load, that means that it is not our object
575cdf0e10cSrcweir // currently the HC mode is supported only for OOo own objects so the following
576cdf0e10cSrcweir // check is used as an optimization
577cdf0e10cSrcweir // TODO/LATER: shouldn't there be a special status flag to detect alien implementation?
578cdf0e10cSrcweir if ( mpImp->nViewAspect == embed::Aspects::MSOLE_CONTENT
579cdf0e10cSrcweir && mxObj.is() && !( mxObj->getStatus( mpImp->nViewAspect ) & embed::EmbedMisc::EMBED_NEEDSSIZEONLOAD ) )
580cdf0e10cSrcweir {
581cdf0e10cSrcweir // TODO/LATER: optimization, it makes no sence to do it for OLE objects
582cdf0e10cSrcweir if ( mxObj->getCurrentState() == embed::EmbedStates::LOADED )
583cdf0e10cSrcweir mxObj->changeState( embed::EmbedStates::RUNNING );
584cdf0e10cSrcweir
585cdf0e10cSrcweir // TODO: return for the aspect of the document
586cdf0e10cSrcweir embed::VisualRepresentation aVisualRepresentation;
587cdf0e10cSrcweir uno::Reference< datatransfer::XTransferable > xTransferable( mxObj->getComponent(), uno::UNO_QUERY );
588cdf0e10cSrcweir if ( !xTransferable.is() )
589cdf0e10cSrcweir throw uno::RuntimeException();
590cdf0e10cSrcweir
591cdf0e10cSrcweir datatransfer::DataFlavor aDataFlavor(
592cdf0e10cSrcweir ::rtl::OUString::createFromAscii(
593cdf0e10cSrcweir "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"" ),
594cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "GDIMetaFile" ),
595cdf0e10cSrcweir ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
596cdf0e10cSrcweir
597cdf0e10cSrcweir uno::Sequence < sal_Int8 > aSeq;
598cdf0e10cSrcweir if ( ( xTransferable->getTransferData( aDataFlavor ) >>= aSeq ) && aSeq.getLength() )
599cdf0e10cSrcweir xInStream = new ::comphelper::SequenceInputStream( aSeq );
600cdf0e10cSrcweir }
601cdf0e10cSrcweir }
602cdf0e10cSrcweir catch ( uno::Exception& )
603cdf0e10cSrcweir {
6042c35faf5SArmin Le Grand OSL_ENSURE( sal_False, "Something went wrong on getting the high contrast graphic!" );
605cdf0e10cSrcweir }
606cdf0e10cSrcweir
607cdf0e10cSrcweir if ( xInStream.is() )
608cdf0e10cSrcweir {
609cdf0e10cSrcweir SvStream* pStream = NULL;
610cdf0e10cSrcweir pStream = ::utl::UcbStreamHelper::CreateStream( xInStream );
611cdf0e10cSrcweir if ( pStream )
612cdf0e10cSrcweir {
613cdf0e10cSrcweir if ( !pStream->GetError() )
614cdf0e10cSrcweir {
615cdf0e10cSrcweir GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
616cdf0e10cSrcweir Graphic* pGraphic = new Graphic();
617cdf0e10cSrcweir if ( pGF->ImportGraphic( *pGraphic, String(), *pStream, GRFILTER_FORMAT_DONTKNOW ) == 0 )
618cdf0e10cSrcweir mpImp->pHCGraphic = pGraphic;
619cdf0e10cSrcweir else
620cdf0e10cSrcweir delete pGraphic;
621cdf0e10cSrcweir mpImp->mnGraphicVersion++;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
624cdf0e10cSrcweir delete pStream;
625cdf0e10cSrcweir }
626cdf0e10cSrcweir }
627cdf0e10cSrcweir }
628cdf0e10cSrcweir
629cdf0e10cSrcweir return mpImp->pHCGraphic;
630cdf0e10cSrcweir }
631cdf0e10cSrcweir
SetGraphicStream(const uno::Reference<io::XInputStream> & xInGrStream,const::rtl::OUString & rMediaType)632cdf0e10cSrcweir void EmbeddedObjectRef::SetGraphicStream( const uno::Reference< io::XInputStream >& xInGrStream,
633cdf0e10cSrcweir const ::rtl::OUString& rMediaType )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir if ( mpImp->pGraphic )
636cdf0e10cSrcweir delete mpImp->pGraphic;
637cdf0e10cSrcweir mpImp->pGraphic = new Graphic();
638cdf0e10cSrcweir mpImp->aMediaType = rMediaType;
639cdf0e10cSrcweir if ( mpImp->pHCGraphic )
640cdf0e10cSrcweir DELETEZ( mpImp->pHCGraphic );
641cdf0e10cSrcweir mpImp->mnGraphicVersion++;
642cdf0e10cSrcweir
643cdf0e10cSrcweir SvStream* pGraphicStream = ::utl::UcbStreamHelper::CreateStream( xInGrStream );
644cdf0e10cSrcweir
645cdf0e10cSrcweir if ( pGraphicStream )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
648cdf0e10cSrcweir pGF->ImportGraphic( *mpImp->pGraphic, String(), *pGraphicStream, GRFILTER_FORMAT_DONTKNOW );
649cdf0e10cSrcweir mpImp->mnGraphicVersion++;
650cdf0e10cSrcweir
651cdf0e10cSrcweir if ( mpImp->pContainer )
652cdf0e10cSrcweir {
653cdf0e10cSrcweir pGraphicStream->Seek( 0 );
654*d321cf2fSArrigo Marchiori uno::Reference< io::XInputStream > xInSeekGrStream;
655*d321cf2fSArrigo Marchiori xInSeekGrStream = new ::utl::OSeekableInputStreamWrapper( pGraphicStream );
656cdf0e10cSrcweir
657cdf0e10cSrcweir mpImp->pContainer->InsertGraphicStream( xInSeekGrStream, mpImp->aPersistName, rMediaType );
658cdf0e10cSrcweir }
659cdf0e10cSrcweir
660cdf0e10cSrcweir delete pGraphicStream;
661cdf0e10cSrcweir }
662cdf0e10cSrcweir
663cdf0e10cSrcweir mpImp->bNeedUpdate = sal_False;
664cdf0e10cSrcweir
665cdf0e10cSrcweir }
666cdf0e10cSrcweir
SetGraphic(const Graphic & rGraphic,const::rtl::OUString & rMediaType)667cdf0e10cSrcweir void EmbeddedObjectRef::SetGraphic( const Graphic& rGraphic, const ::rtl::OUString& rMediaType )
668cdf0e10cSrcweir {
669cdf0e10cSrcweir if ( mpImp->pGraphic )
670cdf0e10cSrcweir delete mpImp->pGraphic;
671cdf0e10cSrcweir mpImp->pGraphic = new Graphic( rGraphic );
672cdf0e10cSrcweir mpImp->aMediaType = rMediaType;
673cdf0e10cSrcweir if ( mpImp->pHCGraphic )
674cdf0e10cSrcweir DELETEZ( mpImp->pHCGraphic );
675cdf0e10cSrcweir mpImp->mnGraphicVersion++;
676cdf0e10cSrcweir
677cdf0e10cSrcweir if ( mpImp->pContainer )
678cdf0e10cSrcweir SetGraphicToContainer( rGraphic, *mpImp->pContainer, mpImp->aPersistName, rMediaType );
679cdf0e10cSrcweir
680cdf0e10cSrcweir mpImp->bNeedUpdate = sal_False;
681cdf0e10cSrcweir }
682cdf0e10cSrcweir
GetGraphicStream(sal_Bool bUpdate) const683cdf0e10cSrcweir SvStream* EmbeddedObjectRef::GetGraphicStream( sal_Bool bUpdate ) const
684cdf0e10cSrcweir {
685cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "svtools (mv76033) svt::EmbeddedObjectRef::GetGraphicStream" );
686cdf0e10cSrcweir DBG_ASSERT( bUpdate || mpImp->pContainer, "Can't retrieve current graphic!" );
687cdf0e10cSrcweir uno::Reference < io::XInputStream > xStream;
688cdf0e10cSrcweir if ( mpImp->pContainer && !bUpdate )
689cdf0e10cSrcweir {
690cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE( aLog, "getting stream from container" );
691cdf0e10cSrcweir // try to get graphic stream from container storage
692cdf0e10cSrcweir xStream = mpImp->pContainer->GetGraphicStream( mxObj, &mpImp->aMediaType );
693cdf0e10cSrcweir if ( xStream.is() )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir const sal_Int32 nConstBufferSize = 32000;
696cdf0e10cSrcweir SvStream *pStream = new SvMemoryStream( 32000, 32000 );
697cdf0e10cSrcweir sal_Int32 nRead=0;
698cdf0e10cSrcweir uno::Sequence < sal_Int8 > aSequence ( nConstBufferSize );
699cdf0e10cSrcweir do
700cdf0e10cSrcweir {
701cdf0e10cSrcweir nRead = xStream->readBytes ( aSequence, nConstBufferSize );
702cdf0e10cSrcweir pStream->Write( aSequence.getConstArray(), nRead );
703cdf0e10cSrcweir }
704cdf0e10cSrcweir while ( nRead == nConstBufferSize );
705cdf0e10cSrcweir pStream->Seek(0);
706cdf0e10cSrcweir return pStream;
707cdf0e10cSrcweir }
708cdf0e10cSrcweir }
709cdf0e10cSrcweir
710cdf0e10cSrcweir if ( !xStream.is() )
711cdf0e10cSrcweir {
712cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE( aLog, "getting stream from object" );
7130dfb9e37SArmin Le Grand bool bUserAllowsLinkUpdate(true);
7140dfb9e37SArmin Le Grand const comphelper::EmbeddedObjectContainer* pContainer = GetContainer();
715cdf0e10cSrcweir
7160dfb9e37SArmin Le Grand if(pContainer)
7170dfb9e37SArmin Le Grand {
7180dfb9e37SArmin Le Grand bUserAllowsLinkUpdate = pContainer->getUserAllowsLinkUpdate();
7190dfb9e37SArmin Le Grand }
7200dfb9e37SArmin Le Grand
7210dfb9e37SArmin Le Grand if(bUserAllowsLinkUpdate)
7220dfb9e37SArmin Le Grand {
7230dfb9e37SArmin Le Grand // update wanted or no stream in container storage available
7240dfb9e37SArmin Le Grand xStream = GetGraphicReplacementStream(mpImp->nViewAspect,mxObj,&mpImp->aMediaType);
7250dfb9e37SArmin Le Grand
7260dfb9e37SArmin Le Grand if(xStream.is())
7270dfb9e37SArmin Le Grand {
7280dfb9e37SArmin Le Grand if(mpImp->pContainer)
7290dfb9e37SArmin Le Grand mpImp->pContainer->InsertGraphicStream(xStream,mpImp->aPersistName,mpImp->aMediaType);
730cdf0e10cSrcweir
7310dfb9e37SArmin Le Grand SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream );
7320dfb9e37SArmin Le Grand if ( pResult && bUpdate )
7330dfb9e37SArmin Le Grand mpImp->bNeedUpdate = sal_False;
734cdf0e10cSrcweir
7350dfb9e37SArmin Le Grand return pResult;
7360dfb9e37SArmin Le Grand }
737cdf0e10cSrcweir }
738cdf0e10cSrcweir }
739cdf0e10cSrcweir
740cdf0e10cSrcweir return NULL;
741cdf0e10cSrcweir }
742cdf0e10cSrcweir
DrawPaintReplacement(const Rectangle & rRect,const String & rText,OutputDevice * pOut)743cdf0e10cSrcweir void EmbeddedObjectRef::DrawPaintReplacement( const Rectangle &rRect, const String &rText, OutputDevice *pOut )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir MapMode aMM( MAP_APPFONT );
746cdf0e10cSrcweir Size aAppFontSz = pOut->LogicToLogic( Size( 0, 8 ), &aMM, NULL );
747cdf0e10cSrcweir Font aFnt( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "Helvetica" ) ), aAppFontSz );
748cdf0e10cSrcweir aFnt.SetTransparent( sal_True );
749cdf0e10cSrcweir aFnt.SetColor( Color( COL_LIGHTRED ) );
750cdf0e10cSrcweir aFnt.SetWeight( WEIGHT_BOLD );
751cdf0e10cSrcweir aFnt.SetFamily( FAMILY_SWISS );
752cdf0e10cSrcweir
753cdf0e10cSrcweir pOut->Push();
754cdf0e10cSrcweir pOut->SetBackground();
755cdf0e10cSrcweir pOut->SetFont( aFnt );
756cdf0e10cSrcweir
757cdf0e10cSrcweir Point aPt;
758cdf0e10cSrcweir // Nun den Text so skalieren, dass er in das Rect passt.
759cdf0e10cSrcweir // Wir fangen mit der Defaultsize an und gehen 1-AppFont runter
760cdf0e10cSrcweir for( sal_uInt16 i = 8; i > 2; i-- )
761cdf0e10cSrcweir {
762cdf0e10cSrcweir aPt.X() = (rRect.GetWidth() - pOut->GetTextWidth( rText )) / 2;
763cdf0e10cSrcweir aPt.Y() = (rRect.GetHeight() - pOut->GetTextHeight()) / 2;
764cdf0e10cSrcweir
765cdf0e10cSrcweir sal_Bool bTiny = sal_False;
766cdf0e10cSrcweir if( aPt.X() < 0 ) bTiny = sal_True, aPt.X() = 0;
767cdf0e10cSrcweir if( aPt.Y() < 0 ) bTiny = sal_True, aPt.Y() = 0;
768cdf0e10cSrcweir if( bTiny )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir // heruntergehen bei kleinen Bildern
771cdf0e10cSrcweir aFnt.SetSize( Size( 0, aAppFontSz.Height() * i / 8 ) );
772cdf0e10cSrcweir pOut->SetFont( aFnt );
773cdf0e10cSrcweir }
774cdf0e10cSrcweir else
775cdf0e10cSrcweir break;
776cdf0e10cSrcweir }
777cdf0e10cSrcweir
778cdf0e10cSrcweir Bitmap aBmp( SvtResId( BMP_PLUGIN ) );
779cdf0e10cSrcweir long nHeight = rRect.GetHeight() - pOut->GetTextHeight();
780cdf0e10cSrcweir long nWidth = rRect.GetWidth();
781cdf0e10cSrcweir if( nHeight > 0 )
782cdf0e10cSrcweir {
783cdf0e10cSrcweir aPt.Y() = nHeight;
784cdf0e10cSrcweir Point aP = rRect.TopLeft();
785cdf0e10cSrcweir Size aBmpSize = aBmp.GetSizePixel();
786cdf0e10cSrcweir // Bitmap einpassen
787cdf0e10cSrcweir if( nHeight * 10 / nWidth
788cdf0e10cSrcweir > aBmpSize.Height() * 10 / aBmpSize.Width() )
789cdf0e10cSrcweir {
790cdf0e10cSrcweir // nach der Breite ausrichten
791cdf0e10cSrcweir // Proportion beibehalten
792cdf0e10cSrcweir long nH = nWidth * aBmpSize.Height() / aBmpSize.Width();
793cdf0e10cSrcweir // zentrieren
794cdf0e10cSrcweir aP.Y() += (nHeight - nH) / 2;
795cdf0e10cSrcweir nHeight = nH;
796cdf0e10cSrcweir }
797cdf0e10cSrcweir else
798cdf0e10cSrcweir {
799cdf0e10cSrcweir // nach der H"ohe ausrichten
800cdf0e10cSrcweir // Proportion beibehalten
801cdf0e10cSrcweir long nW = nHeight * aBmpSize.Width() / aBmpSize.Height();
802cdf0e10cSrcweir // zentrieren
803cdf0e10cSrcweir aP.X() += (nWidth - nW) / 2;
804cdf0e10cSrcweir nWidth = nW;
805cdf0e10cSrcweir }
806cdf0e10cSrcweir
807cdf0e10cSrcweir pOut->DrawBitmap( aP, Size( nWidth, nHeight ), aBmp );
808cdf0e10cSrcweir }
809cdf0e10cSrcweir
810cdf0e10cSrcweir pOut->IntersectClipRegion( rRect );
811cdf0e10cSrcweir aPt += rRect.TopLeft();
812cdf0e10cSrcweir pOut->DrawText( aPt, rText );
813cdf0e10cSrcweir pOut->Pop();
814cdf0e10cSrcweir }
815cdf0e10cSrcweir
DrawShading(const Rectangle & rRect,OutputDevice * pOut)816cdf0e10cSrcweir void EmbeddedObjectRef::DrawShading( const Rectangle &rRect, OutputDevice *pOut )
817cdf0e10cSrcweir {
818cdf0e10cSrcweir GDIMetaFile * pMtf = pOut->GetConnectMetaFile();
819cdf0e10cSrcweir if( pMtf && pMtf->IsRecord() )
820cdf0e10cSrcweir return;
821cdf0e10cSrcweir
822cdf0e10cSrcweir pOut->Push();
823cdf0e10cSrcweir pOut->SetLineColor( Color( COL_BLACK ) );
824cdf0e10cSrcweir
825cdf0e10cSrcweir Size aPixSize = pOut->LogicToPixel( rRect.GetSize() );
826cdf0e10cSrcweir aPixSize.Width() -= 1;
827cdf0e10cSrcweir aPixSize.Height() -= 1;
828cdf0e10cSrcweir Point aPixViewPos = pOut->LogicToPixel( rRect.TopLeft() );
829cdf0e10cSrcweir sal_Int32 nMax = aPixSize.Width() + aPixSize.Height();
830cdf0e10cSrcweir for( sal_Int32 i = 5; i < nMax; i += 5 )
831cdf0e10cSrcweir {
832cdf0e10cSrcweir Point a1( aPixViewPos ), a2( aPixViewPos );
833cdf0e10cSrcweir if( i > aPixSize.Width() )
834cdf0e10cSrcweir a1 += Point( aPixSize.Width(), i - aPixSize.Width() );
835cdf0e10cSrcweir else
836cdf0e10cSrcweir a1 += Point( i, 0 );
837cdf0e10cSrcweir if( i > aPixSize.Height() )
838cdf0e10cSrcweir a2 += Point( i - aPixSize.Height(), aPixSize.Height() );
839cdf0e10cSrcweir else
840cdf0e10cSrcweir a2 += Point( 0, i );
841cdf0e10cSrcweir
842cdf0e10cSrcweir pOut->DrawLine( pOut->PixelToLogic( a1 ), pOut->PixelToLogic( a2 ) );
843cdf0e10cSrcweir }
844cdf0e10cSrcweir
845cdf0e10cSrcweir pOut->Pop();
846cdf0e10cSrcweir
847cdf0e10cSrcweir }
848cdf0e10cSrcweir
TryRunningState()849cdf0e10cSrcweir sal_Bool EmbeddedObjectRef::TryRunningState()
850cdf0e10cSrcweir {
851cdf0e10cSrcweir return TryRunningState( mxObj );
852cdf0e10cSrcweir }
853cdf0e10cSrcweir
TryRunningState(const uno::Reference<embed::XEmbeddedObject> & xEmbObj)854cdf0e10cSrcweir sal_Bool EmbeddedObjectRef::TryRunningState( const uno::Reference < embed::XEmbeddedObject >& xEmbObj )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir if ( !xEmbObj.is() )
857cdf0e10cSrcweir return sal_False;
858cdf0e10cSrcweir
859cdf0e10cSrcweir try
860cdf0e10cSrcweir {
861cdf0e10cSrcweir if ( xEmbObj->getCurrentState() == embed::EmbedStates::LOADED )
862cdf0e10cSrcweir xEmbObj->changeState( embed::EmbedStates::RUNNING );
863cdf0e10cSrcweir }
864cdf0e10cSrcweir catch ( uno::Exception& )
865cdf0e10cSrcweir {
866cdf0e10cSrcweir return sal_False;
867cdf0e10cSrcweir }
868cdf0e10cSrcweir
869cdf0e10cSrcweir return sal_True;
870cdf0e10cSrcweir }
871cdf0e10cSrcweir
SetGraphicToContainer(const Graphic & rGraphic,comphelper::EmbeddedObjectContainer & aContainer,const::rtl::OUString & aName,const::rtl::OUString & aMediaType)872cdf0e10cSrcweir void EmbeddedObjectRef::SetGraphicToContainer( const Graphic& rGraphic,
873cdf0e10cSrcweir comphelper::EmbeddedObjectContainer& aContainer,
874cdf0e10cSrcweir const ::rtl::OUString& aName,
875cdf0e10cSrcweir const ::rtl::OUString& aMediaType )
876cdf0e10cSrcweir {
877cdf0e10cSrcweir SvMemoryStream aStream;
878cdf0e10cSrcweir aStream.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
879cdf0e10cSrcweir if ( rGraphic.ExportNative( aStream ) )
880cdf0e10cSrcweir {
881cdf0e10cSrcweir aStream.Seek( 0 );
882cdf0e10cSrcweir
883cdf0e10cSrcweir uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( aStream );
884cdf0e10cSrcweir aContainer.InsertGraphicStream( xStream, aName, aMediaType );
885cdf0e10cSrcweir }
886cdf0e10cSrcweir else
887cdf0e10cSrcweir OSL_ENSURE( sal_False, "Export of graphic is failed!\n" );
888cdf0e10cSrcweir }
889cdf0e10cSrcweir
ObjectIsModified(const uno::Reference<embed::XEmbeddedObject> & xObj)890cdf0e10cSrcweir sal_Bool EmbeddedObjectRef::ObjectIsModified( const uno::Reference< embed::XEmbeddedObject >& xObj )
891cdf0e10cSrcweir throw( uno::Exception )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir sal_Bool bResult = sal_False;
894cdf0e10cSrcweir
895cdf0e10cSrcweir sal_Int32 nState = xObj->getCurrentState();
896cdf0e10cSrcweir if ( nState != embed::EmbedStates::LOADED && nState != embed::EmbedStates::RUNNING )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir // the object is active so if the model is modified the replacement
899cdf0e10cSrcweir // should be retrieved from the object
900cdf0e10cSrcweir uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
901cdf0e10cSrcweir if ( xModifiable.is() )
902cdf0e10cSrcweir bResult = xModifiable->isModified();
903cdf0e10cSrcweir }
904cdf0e10cSrcweir
905cdf0e10cSrcweir return bResult;
906cdf0e10cSrcweir }
907cdf0e10cSrcweir
GetGraphicReplacementStream(sal_Int64 nViewAspect,const uno::Reference<embed::XEmbeddedObject> & xObj,::rtl::OUString * pMediaType)908cdf0e10cSrcweir uno::Reference< io::XInputStream > EmbeddedObjectRef::GetGraphicReplacementStream(
909cdf0e10cSrcweir sal_Int64 nViewAspect,
910cdf0e10cSrcweir const uno::Reference< embed::XEmbeddedObject >& xObj,
911cdf0e10cSrcweir ::rtl::OUString* pMediaType )
912cdf0e10cSrcweir throw()
913cdf0e10cSrcweir {
914cdf0e10cSrcweir return ::comphelper::EmbeddedObjectContainer::GetGraphicReplacementStream(nViewAspect,xObj,pMediaType);
915cdf0e10cSrcweir }
916cdf0e10cSrcweir
UpdateReplacementOnDemand()917cdf0e10cSrcweir void EmbeddedObjectRef::UpdateReplacementOnDemand()
918cdf0e10cSrcweir {
919cdf0e10cSrcweir DELETEZ( mpImp->pGraphic );
920cdf0e10cSrcweir mpImp->bNeedUpdate = sal_True;
921cdf0e10cSrcweir if ( mpImp->pHCGraphic )
922cdf0e10cSrcweir DELETEZ( mpImp->pHCGraphic );
923cdf0e10cSrcweir mpImp->mnGraphicVersion++;
924cdf0e10cSrcweir
925cdf0e10cSrcweir if( mpImp->pContainer )
926cdf0e10cSrcweir {
927cdf0e10cSrcweir //remove graphic from container thus a new up to date one is requested on save
928cdf0e10cSrcweir mpImp->pContainer->RemoveGraphicStream( mpImp->aPersistName );
929cdf0e10cSrcweir }
930cdf0e10cSrcweir }
931cdf0e10cSrcweir
IsChart() const932cdf0e10cSrcweir sal_Bool EmbeddedObjectRef::IsChart() const
933cdf0e10cSrcweir {
934cdf0e10cSrcweir //todo maybe for 3.0:
935cdf0e10cSrcweir //if the changes work good for chart
936cdf0e10cSrcweir //we should apply them for all own ole objects
937cdf0e10cSrcweir
938cdf0e10cSrcweir //#i83708# #i81857# #i79578# request an ole replacement image only if really necessary
939cdf0e10cSrcweir //as this call can be very expensive and does block the user interface as long at it takes
940cdf0e10cSrcweir
941cdf0e10cSrcweir if ( !mxObj.is() )
942cdf0e10cSrcweir return false;
943cdf0e10cSrcweir
944cdf0e10cSrcweir SvGlobalName aObjClsId( mxObj->getClassID() );
945cdf0e10cSrcweir if(
946cdf0e10cSrcweir SvGlobalName(SO3_SCH_CLASSID_30) == aObjClsId
947cdf0e10cSrcweir || SvGlobalName(SO3_SCH_CLASSID_40) == aObjClsId
948cdf0e10cSrcweir || SvGlobalName(SO3_SCH_CLASSID_50) == aObjClsId
949cdf0e10cSrcweir || SvGlobalName(SO3_SCH_CLASSID_60) == aObjClsId)
950cdf0e10cSrcweir {
951cdf0e10cSrcweir return sal_True;
952cdf0e10cSrcweir }
953cdf0e10cSrcweir
954cdf0e10cSrcweir return sal_False;
955cdf0e10cSrcweir }
956cdf0e10cSrcweir
9572bfcd321SSteve Yin // MT: Only used for getting accessible attributes, which are not localized
GetChartType()9582bfcd321SSteve Yin rtl::OUString EmbeddedObjectRef::GetChartType()
9592bfcd321SSteve Yin {
9602bfcd321SSteve Yin rtl::OUString Style;
9612bfcd321SSteve Yin if ( mxObj.is() )
9622bfcd321SSteve Yin {
9632bfcd321SSteve Yin if ( IsChart() )
9642bfcd321SSteve Yin {
9652bfcd321SSteve Yin if ( svt::EmbeddedObjectRef::TryRunningState( mxObj ) )
9662bfcd321SSteve Yin {
9672bfcd321SSteve Yin uno::Reference< chart2::XChartDocument > xChart( mxObj->getComponent(), uno::UNO_QUERY );
9682bfcd321SSteve Yin if (xChart.is())
9692bfcd321SSteve Yin {
9702bfcd321SSteve Yin uno::Reference< chart2::XDiagram > xDiagram( xChart->getFirstDiagram());
9712bfcd321SSteve Yin if( ! xDiagram.is())
9722bfcd321SSteve Yin return String();
9732bfcd321SSteve Yin uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
9742bfcd321SSteve Yin uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
9752bfcd321SSteve Yin // IA2 CWS. Unused: int nCoordinateCount = aCooSysSeq.getLength();
9762bfcd321SSteve Yin sal_Bool bGetChartType = sal_False;
9772bfcd321SSteve Yin for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
9782bfcd321SSteve Yin {
9792bfcd321SSteve Yin uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
9802bfcd321SSteve Yin uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
9812bfcd321SSteve Yin int nDimesionCount = aCooSysSeq[nCooSysIdx]->getDimension();
9822bfcd321SSteve Yin if( nDimesionCount == 3 )
9832bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("3D ");
9842bfcd321SSteve Yin else
9852bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("2D ");
9862bfcd321SSteve Yin for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx )
9872bfcd321SSteve Yin {
9882bfcd321SSteve Yin rtl::OUString strChartType = aChartTypes[nCTIdx]->getChartType();
9892bfcd321SSteve Yin if (strChartType.equals(::rtl::OUString::createFromAscii("com.sun.star.chart2.AreaChartType")))
9902bfcd321SSteve Yin {
9912bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("Areas");
9922bfcd321SSteve Yin bGetChartType = sal_True;
9932bfcd321SSteve Yin }
9942bfcd321SSteve Yin else if (strChartType.equals(::rtl::OUString::createFromAscii("com.sun.star.chart2.BarChartType")))
9952bfcd321SSteve Yin {
9962bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("Bars");
9972bfcd321SSteve Yin bGetChartType = sal_True;
9982bfcd321SSteve Yin }
9992bfcd321SSteve Yin else if (strChartType.equals(::rtl::OUString::createFromAscii("com.sun.star.chart2.ColumnChartType")))
10002bfcd321SSteve Yin {
10012bfcd321SSteve Yin uno::Reference< beans::XPropertySet > xProp( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY );
10022bfcd321SSteve Yin if( xProp.is())
10032bfcd321SSteve Yin {
10042bfcd321SSteve Yin bool bCurrent = false;
10052bfcd321SSteve Yin if( xProp->getPropertyValue( rtl::OUString::createFromAscii("SwapXAndYAxis") ) >>= bCurrent )
10062bfcd321SSteve Yin {
10072bfcd321SSteve Yin if (bCurrent)
10082bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("Bars");
10092bfcd321SSteve Yin else
10102bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("Columns");
10112bfcd321SSteve Yin bGetChartType = sal_True;
10122bfcd321SSteve Yin }
10132bfcd321SSteve Yin }
10142bfcd321SSteve Yin }
10152bfcd321SSteve Yin else if (strChartType.equals(::rtl::OUString::createFromAscii("com.sun.star.chart2.LineChartType")))
10162bfcd321SSteve Yin {
10172bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("Lines");
10182bfcd321SSteve Yin bGetChartType = sal_True;
10192bfcd321SSteve Yin }
10202bfcd321SSteve Yin else if (strChartType.equals(::rtl::OUString::createFromAscii("com.sun.star.chart2.ScatterChartType")))
10212bfcd321SSteve Yin {
10222bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("XY Chart");
10232bfcd321SSteve Yin bGetChartType = sal_True;
10242bfcd321SSteve Yin }
10252bfcd321SSteve Yin else if (strChartType.equals(::rtl::OUString::createFromAscii("com.sun.star.chart2.PieChartType")))
10262bfcd321SSteve Yin {
10272bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("Pies");
10282bfcd321SSteve Yin bGetChartType = sal_True;
10292bfcd321SSteve Yin }
10302bfcd321SSteve Yin else if (strChartType.equals(::rtl::OUString::createFromAscii("com.sun.star.chart2.NetChartType")))
10312bfcd321SSteve Yin {
10322bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("Radar");
10332bfcd321SSteve Yin bGetChartType = sal_True;
10342bfcd321SSteve Yin }
10352bfcd321SSteve Yin else if (strChartType.equals(::rtl::OUString::createFromAscii("com.sun.star.chart2.CandleStickChartType")))
10362bfcd321SSteve Yin {
10372bfcd321SSteve Yin Style += rtl::OUString::createFromAscii("Candle Stick Chart");
10382bfcd321SSteve Yin bGetChartType = sal_True;
10392bfcd321SSteve Yin }
10402bfcd321SSteve Yin if (bGetChartType)
10412bfcd321SSteve Yin return Style;
10422bfcd321SSteve Yin }
10432bfcd321SSteve Yin }
10442bfcd321SSteve Yin }
10452bfcd321SSteve Yin }
10462bfcd321SSteve Yin }
10472bfcd321SSteve Yin }
10482bfcd321SSteve Yin return Style;
10492bfcd321SSteve Yin }
10502bfcd321SSteve Yin
1051cdf0e10cSrcweir // #i104867#
getGraphicVersion() const1052cdf0e10cSrcweir sal_uInt32 EmbeddedObjectRef::getGraphicVersion() const
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir return mpImp->mnGraphicVersion;
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir
SetDefaultSizeForChart(const Size & rSizeIn_100TH_MM)1057cdf0e10cSrcweir void EmbeddedObjectRef::SetDefaultSizeForChart( const Size& rSizeIn_100TH_MM )
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir //#i103460# charts do not necessaryly have an own size within ODF files,
1060cdf0e10cSrcweir //for this case they need to use the size settings from the surrounding frame,
1061cdf0e10cSrcweir //which is made available with this method
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir mpImp->aDefaultSizeForChart_In_100TH_MM = awt::Size( rSizeIn_100TH_MM.getWidth(), rSizeIn_100TH_MM.getHeight() );
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::chart2::XDefaultSizeTransmitter > xSizeTransmitter( mxObj, uno::UNO_QUERY );
1066cdf0e10cSrcweir DBG_ASSERT( xSizeTransmitter.is(), "Object does not support XDefaultSizeTransmitter -> will cause #i103460#!" );
1067cdf0e10cSrcweir if( xSizeTransmitter.is() )
1068cdf0e10cSrcweir xSizeTransmitter->setDefaultSize( mpImp->aDefaultSizeForChart_In_100TH_MM );
1069cdf0e10cSrcweir }
1070cdf0e10cSrcweir
1071cdf0e10cSrcweir } // namespace svt
1072cdf0e10cSrcweir
1073