merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / model / main / ChartModel.cxx
blob5a30d97118c5b08156b3f20c3b7846022e40a8e9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "ChartModel.hxx"
31 #include "servicenames.hxx"
32 #include "MediaDescriptorHelper.hxx"
33 #include "macros.hxx"
34 #include "servicenames.hxx"
35 #include "NoWarningThisInCTOR.hxx"
36 #include "DataSourceHelper.hxx"
37 #include "ChartModelHelper.hxx"
38 #include "DiagramHelper.hxx"
39 #include "DisposeHelper.hxx"
40 #include "ControllerLockGuard.hxx"
41 #include "ObjectIdentifier.hxx"
42 #include "PageBackground.hxx"
43 #include "CloneHelper.hxx"
44 #include "NameContainer.hxx"
46 #include <com/sun/star/chart/ChartDataRowSource.hpp>
48 #include <comphelper/InlineContainer.hxx>
49 #include <comphelper/processfactory.hxx>
51 // header for class SvNumberFormatsSupplierObj
52 #include <svl/numuno.hxx>
53 #include <com/sun/star/lang/DisposedException.hpp>
54 #include <com/sun/star/lang/XInitialization.hpp>
55 #include <com/sun/star/view/XSelectionSupplier.hpp>
56 #include <com/sun/star/embed/XEmbedObjectCreator.hpp>
57 #include <com/sun/star/embed/XEmbedPersist.hpp>
58 #include <com/sun/star/embed/EmbedStates.hpp>
59 #include <com/sun/star/embed/XComponentSupplier.hpp>
60 #include <com/sun/star/embed/XStorage.hpp>
61 #include <com/sun/star/embed/EmbedMapUnits.hpp>
62 #include <com/sun/star/embed/Aspects.hpp>
63 #include <com/sun/star/awt/Gradient.hpp>
64 #include <com/sun/star/awt/XWindow.hpp>
65 #include <com/sun/star/awt/PosSize.hpp>
66 #include <com/sun/star/datatransfer/XTransferable.hpp>
67 #include <com/sun/star/drawing/Hatch.hpp>
68 #include <com/sun/star/drawing/LineDash.hpp>
69 #include <com/sun/star/drawing/XShapes.hpp>
71 // header for class SvNumberFormatter
72 #include <svl/zforlist.hxx>
74 using ::com::sun::star::uno::Sequence;
75 using ::com::sun::star::uno::Reference;
76 using ::com::sun::star::uno::Any;
77 using ::rtl::OUString;
78 using ::osl::MutexGuard;
80 using namespace ::com::sun::star;
81 using namespace ::apphelper;
82 using namespace ::chart::CloneHelper;
84 namespace
86 const OUString lcl_aGDIMetaFileMIMEType(
87 RTL_CONSTASCII_USTRINGPARAM("application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\""));
88 const OUString lcl_aGDIMetaFileMIMETypeHighContrast(
89 RTL_CONSTASCII_USTRINGPARAM("application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\""));
91 } // anonymous namespace
93 //-----------------------------------------------------------------
94 // ChartModel Constructor and Destructor
95 //-----------------------------------------------------------------
97 namespace chart
100 ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
101 : m_aLifeTimeManager( this, this )
102 , m_bReadOnly( sal_False )
103 , m_bModified( sal_False )
104 , m_nInLoad(0)
105 , m_bUpdateNotificationsPending(false)
106 , m_aControllers( m_aModelMutex )
107 , m_nControllerLockCount(0)
108 , m_xContext( xContext )
109 , m_aVisualAreaSize( ChartModelHelper::getDefaultPageSize() )
110 , m_xDataProvider( 0 )
111 , m_xInternalDataProvider( 0 )
112 , m_xPageBackground( new PageBackground( m_xContext ) )
113 , m_xXMLNamespaceMap( createNameContainer( ::getCppuType( (const OUString*) 0 ),
114 C2U( "com.sun.star.xml.NamespaceMap" ), C2U( "com.sun.star.comp.chart.XMLNameSpaceMap" ) ), uno::UNO_QUERY)
116 OSL_TRACE( "ChartModel: CTOR called" );
117 osl_incrementInterlockedCount(&m_refCount);
119 ModifyListenerHelper::addListener( m_xPageBackground, this );
120 m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext(
121 C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY );
122 m_xUndoManager = Reference< chart2::XUndoManager >(
123 this->createInstance( CHART_UNDOMANAGER_SERVICE_NAME ), uno::UNO_QUERY );
125 osl_decrementInterlockedCount(&m_refCount);
128 ChartModel::ChartModel( const ChartModel & rOther )
129 : impl::ChartModel_Base()
130 , m_aLifeTimeManager( this, this )
131 , m_bReadOnly( rOther.m_bReadOnly )
132 , m_bModified( rOther.m_bModified )
133 , m_nInLoad(0)
134 , m_bUpdateNotificationsPending(false)
135 , m_aResource( rOther.m_aResource )
136 , m_aMediaDescriptor( rOther.m_aMediaDescriptor )
137 , m_aControllers( m_aModelMutex )
138 , m_nControllerLockCount(0)
139 , m_xContext( rOther.m_xContext )
140 // @note: the old model aggregate must not be shared with other models if it
141 // is, you get mutex deadlocks
142 , m_xOldModelAgg( 0 ) //rOther.m_xOldModelAgg )
143 , m_xStorage( 0 ) //rOther.m_xStorage )
144 , m_aVisualAreaSize( rOther.m_aVisualAreaSize )
145 , m_aGraphicObjectVector( rOther.m_aGraphicObjectVector )
146 , m_xDataProvider( rOther.m_xDataProvider )
147 , m_xInternalDataProvider( rOther.m_xInternalDataProvider )
148 , m_xUndoManager( rOther.m_xUndoManager )
150 OSL_TRACE( "ChartModel: Copy-CTOR called" );
151 osl_incrementInterlockedCount(&m_refCount);
153 Reference< util::XModifyListener > xListener;
154 Reference< chart2::XTitle > xNewTitle = CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle );
155 Reference< chart2::XDiagram > xNewDiagram = CreateRefClone< Reference< chart2::XDiagram > >()( rOther.m_xDiagram );
156 Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground );
157 Reference< chart2::XChartTypeManager > xChartTypeManager = CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager );
158 Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xXMLNamespaceMap );
161 MutexGuard aGuard( m_aModelMutex );
162 xListener = this;
163 m_xTitle = xNewTitle;
164 m_xDiagram = xNewDiagram;
165 m_xPageBackground = xNewPageBackground;
166 m_xChartTypeManager = xChartTypeManager;
167 m_xXMLNamespaceMap = xXMLNamespaceMap;
170 ModifyListenerHelper::addListener( xNewTitle, xListener );
171 ModifyListenerHelper::addListener( xNewDiagram, xListener );
172 ModifyListenerHelper::addListener( xNewPageBackground, xListener );
173 xListener.clear();
175 osl_decrementInterlockedCount(&m_refCount);
178 ChartModel::~ChartModel()
180 OSL_TRACE( "ChartModel: DTOR called" );
181 if( m_xOldModelAgg.is())
182 m_xOldModelAgg->setDelegator( 0 );
186 //-----------------------------------------------------------------
187 // private methods
188 //-----------------------------------------------------------------
190 ::rtl::OUString ChartModel::impl_g_getLocation()
193 LifeTimeGuard aGuard(m_aLifeTimeManager);
194 if(!aGuard.startApiCall())
195 return ::rtl::OUString(); //behave passive if already disposed or closed or throw exception @todo?
196 //mutex is acquired
197 return m_aResource;
200 sal_Bool ChartModel::impl_isControllerConnected( const uno::Reference< frame::XController >& xController )
204 uno::Sequence< uno::Reference<uno::XInterface> > aSeq = m_aControllers.getElements();
205 for( sal_Int32 nN = aSeq.getLength(); nN--; )
207 if( aSeq[nN] == xController )
208 return sal_True;
211 catch( uno::Exception )
214 return sal_False;
217 uno::Reference< frame::XController > ChartModel::impl_getCurrentController() throw(uno::RuntimeException)
219 //@todo? hold only weak references to controllers
221 // get the last active controller of this model
222 if( m_xCurrentController.is() )
223 return m_xCurrentController;
225 // get the first controller of this model
226 if( m_aControllers.getLength() )
228 uno::Reference<uno::XInterface> xI = m_aControllers.getElements()[0];
229 return uno::Reference<frame::XController>( xI, uno::UNO_QUERY );
232 //return nothing if no controllers are connected at all
233 return uno::Reference< frame::XController > ();
236 void SAL_CALL ChartModel::impl_notifyCloseListeners()
237 throw( uno::RuntimeException)
239 ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
240 .getContainer( ::getCppuType((const uno::Reference< util::XCloseListener >*)0) );
241 if( pIC )
243 lang::EventObject aEvent( static_cast< lang::XComponent*>(this) );
244 ::cppu::OInterfaceIteratorHelper aIt( *pIC );
245 while( aIt.hasMoreElements() )
247 uno::Reference< util::XCloseListener > xListener( aIt.next(), uno::UNO_QUERY );
248 if( xListener.is() )
249 xListener->notifyClosing( aEvent );
254 void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size& aVisualAreaSize )
256 uno::Reference< beans::XPropertySet > xProperties( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY );
257 if ( xProperties.is() )
259 uno::Reference< drawing::XShapes > xShapes;
260 xProperties->getPropertyValue( C2U( "AdditionalShapes" ) ) >>= xShapes;
261 if ( xShapes.is() )
263 sal_Int32 nCount = xShapes->getCount();
264 for ( sal_Int32 i = 0; i < nCount; ++i )
266 Reference< drawing::XShape > xShape;
267 if ( xShapes->getByIndex( i ) >>= xShape )
269 if ( xShape.is() )
271 awt::Point aPos( xShape->getPosition() );
272 awt::Size aSize( xShape->getSize() );
274 double fWidth = static_cast< double >( aVisualAreaSize.Width ) / m_aVisualAreaSize.Width;
275 double fHeight = static_cast< double >( aVisualAreaSize.Height ) / m_aVisualAreaSize.Height;
277 aPos.X = static_cast< long >( aPos.X * fWidth );
278 aPos.Y = static_cast< long >( aPos.Y * fHeight );
279 aSize.Width = static_cast< long >( aSize.Width * fWidth );
280 aSize.Height = static_cast< long >( aSize.Height * fHeight );
282 xShape->setPosition( aPos );
283 xShape->setSize( aSize );
291 //-----------------------------------------------------------------
292 // lang::XServiceInfo
293 //-----------------------------------------------------------------
295 APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
297 uno::Sequence< rtl::OUString > ChartModel::getSupportedServiceNames_Static()
299 uno::Sequence< rtl::OUString > aSNS( 3 );
300 aSNS[0] = CHART_MODEL_SERVICE_NAME;
301 aSNS[1] = C2U( "com.sun.star.document.OfficeDocument" );
302 aSNS[2] = C2U( "com.sun.star.chart.ChartDocument" );
303 //// @todo : add additional services if you support any further
304 return aSNS;
307 //-----------------------------------------------------------------
308 // frame::XModel (required interface)
309 //-----------------------------------------------------------------
311 sal_Bool SAL_CALL ChartModel::attachResource( const ::rtl::OUString& rURL
312 , const uno::Sequence< beans::PropertyValue >& rMediaDescriptor )
313 throw(uno::RuntimeException)
316 The method attachResource() is used by the frame loader implementations
317 to inform the model about its URL and MediaDescriptor.
320 LifeTimeGuard aGuard(m_aLifeTimeManager);
321 if(!aGuard.startApiCall())
322 return sal_False; //behave passive if already disposed or closed or throw exception @todo?
323 //mutex is acquired
325 if(m_aResource.getLength()!=0)//we have a resource already //@todo? or is setting a new resource allowed?
326 return sal_False;
327 m_aResource = rURL;
328 m_aMediaDescriptor = rMediaDescriptor;
330 //@todo ? check rURL ??
331 //@todo ? evaluate m_aMediaDescriptor;
332 //@todo ? ... ??? --> nothing, this method is only for setting informations
334 return sal_True;
337 ::rtl::OUString SAL_CALL ChartModel::getURL() throw(uno::RuntimeException)
339 return impl_g_getLocation();
342 uno::Sequence< beans::PropertyValue > SAL_CALL ChartModel::getArgs() throw(uno::RuntimeException)
345 The method getArgs() returns a sequence of property values
346 that report the resource description according to com.sun.star.document.MediaDescriptor,
347 specified on loading or saving with storeAsURL.
350 LifeTimeGuard aGuard(m_aLifeTimeManager);
351 if(!aGuard.startApiCall())
352 return uno::Sequence< beans::PropertyValue >(); //behave passive if already disposed or closed or throw exception @todo?
353 //mutex is acquired
355 return m_aMediaDescriptor;
358 void SAL_CALL ChartModel::connectController( const uno::Reference< frame::XController >& xController )
359 throw(uno::RuntimeException)
361 //@todo? this method is declared as oneway -> ...?
363 LifeTimeGuard aGuard(m_aLifeTimeManager);
364 if(!aGuard.startApiCall())
365 return ; //behave passive if already disposed or closed
366 //mutex is acquired
368 //--add controller
369 m_aControllers.addInterface(xController);
372 void SAL_CALL ChartModel::disconnectController( const uno::Reference< frame::XController >& xController )
373 throw(uno::RuntimeException)
375 //@todo? this method is declared as oneway -> ...?
377 LifeTimeGuard aGuard(m_aLifeTimeManager);
378 if(!aGuard.startApiCall())
379 return; //behave passive if already disposed or closed
381 //--remove controller
382 m_aControllers.removeInterface(xController);
384 //case: current controller is disconnected:
385 if( m_xCurrentController == xController )
386 m_xCurrentController.clear();
388 DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
391 void SAL_CALL ChartModel::lockControllers() throw(uno::RuntimeException)
394 suspends some notifications to the controllers which are used for display updates.
396 The calls to lockControllers() and unlockControllers() may be nested
397 and even overlapping, but they must be in pairs. While there is at least one lock
398 remaining, some notifications for display updates are not broadcasted.
401 //@todo? this method is declared as oneway -> ...?
403 LifeTimeGuard aGuard(m_aLifeTimeManager);
404 if(!aGuard.startApiCall())
405 return; //behave passive if already disposed or closed or throw exception @todo?
406 ++m_nControllerLockCount;
409 void SAL_CALL ChartModel::unlockControllers() throw(uno::RuntimeException)
412 resumes the notifications which were suspended by lockControllers() .
414 The calls to lockControllers() and unlockControllers() may be nested
415 and even overlapping, but they must be in pairs. While there is at least one lock
416 remaining, some notifications for display updates are not broadcasted.
419 //@todo? this method is declared as oneway -> ...?
421 LifeTimeGuard aGuard(m_aLifeTimeManager);
422 if(!aGuard.startApiCall())
423 return; //behave passive if already disposed or closed or throw exception @todo?
424 if( m_nControllerLockCount == 0 )
426 OSL_TRACE( "ChartModel: unlockControllers called with m_nControllerLockCount == 0" );
427 return;
429 --m_nControllerLockCount;
430 if( m_nControllerLockCount == 0 && m_bUpdateNotificationsPending )
432 aGuard.clear();
433 impl_notifyModifiedListeners();
437 sal_Bool SAL_CALL ChartModel::hasControllersLocked() throw(uno::RuntimeException)
439 LifeTimeGuard aGuard(m_aLifeTimeManager);
440 if(!aGuard.startApiCall())
441 return sal_False; //behave passive if already disposed or closed or throw exception @todo?
442 return ( m_nControllerLockCount != 0 ) ;
445 uno::Reference< frame::XController > SAL_CALL ChartModel::getCurrentController() throw(uno::RuntimeException)
447 LifeTimeGuard aGuard(m_aLifeTimeManager);
448 if(!aGuard.startApiCall())
449 throw lang::DisposedException(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
450 "getCurrentController was called on an already disposed or closed model" ) )
451 , static_cast< ::cppu::OWeakObject* >(this));
453 return impl_getCurrentController();
456 void SAL_CALL ChartModel::setCurrentController( const uno::Reference< frame::XController >& xController )
457 throw(container::NoSuchElementException, uno::RuntimeException)
459 LifeTimeGuard aGuard(m_aLifeTimeManager);
460 if(!aGuard.startApiCall())
461 throw lang::DisposedException(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
462 "setCurrentController was called on an already disposed or closed model" ) )
463 , static_cast< ::cppu::OWeakObject* >(this));
465 //OSL_ENSURE( impl_isControllerConnected(xController), "setCurrentController is called with a Controller which is not connected" );
466 if(!impl_isControllerConnected(xController))
467 throw container::NoSuchElementException(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
468 "setCurrentController is called with a Controller which is not connected" ) )
469 , static_cast< ::cppu::OWeakObject* >(this));
471 m_xCurrentController = xController;
473 DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
476 uno::Reference< uno::XInterface > SAL_CALL ChartModel::getCurrentSelection() throw(uno::RuntimeException)
478 LifeTimeGuard aGuard(m_aLifeTimeManager);
479 if(!aGuard.startApiCall())
480 throw lang::DisposedException(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
481 "getCurrentSelection was called on an already disposed or closed model" ) )
482 , static_cast< ::cppu::OWeakObject* >(this));
485 uno::Reference< uno::XInterface > xReturn;
486 uno::Reference< frame::XController > xController = impl_getCurrentController();
488 aGuard.clear();
489 if( xController.is() )
491 uno::Reference< view::XSelectionSupplier > xSelectionSupl( xController, uno::UNO_QUERY );
492 if ( xSelectionSupl.is() )
494 uno::Any aSel = xSelectionSupl->getSelection();
495 rtl::OUString aObjectCID;
496 if( aSel >>= aObjectCID )
498 xReturn.set( ObjectIdentifier::getObjectPropertySet( aObjectCID, Reference< XChartDocument >(this)));
502 return xReturn;
506 //-----------------------------------------------------------------
507 // lang::XComponent (base of XModel)
508 //-----------------------------------------------------------------
509 void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException)
511 //This object should release all resources and references in the
512 //easiest possible manner
513 //This object must notify all registered listeners using the method
514 //<member>XEventListener::disposing</member>
516 //hold no mutex
517 if( !m_aLifeTimeManager.dispose() )
518 return;
520 //--release all resources and references
521 //// @todo
523 m_xDataProvider.clear();
524 m_xInternalDataProvider.clear();
525 m_xNumberFormatsSupplier.clear();
526 DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier );
527 DisposeHelper::DisposeAndClear( m_xChartTypeManager );
528 DisposeHelper::DisposeAndClear( m_xDiagram );
529 DisposeHelper::DisposeAndClear( m_xTitle );
530 DisposeHelper::DisposeAndClear( m_xPageBackground );
531 DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap );
533 // not owner of storage
534 // if( m_xStorage.is())
535 // {
536 // Reference< lang::XComponent > xComp( m_xStorage, uno::UNO_QUERY );
537 // if( xComp.is())
538 // xComp->dispose();
539 // }
540 m_xStorage.clear();
542 if( m_xOldModelAgg.is())
544 m_xOldModelAgg->setDelegator( 0 );
545 m_xOldModelAgg.clear();
548 m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this )));
549 m_xCurrentController.clear();
551 m_xStorage.clear();
552 m_xParent.clear();
553 DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
554 OSL_TRACE( "ChartModel: dispose() called" );
557 void SAL_CALL ChartModel::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
558 throw(uno::RuntimeException)
560 if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
561 return; //behave passive if already disposed or closed
563 m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener );
566 void SAL_CALL ChartModel::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
567 throw(uno::RuntimeException)
569 if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
570 return; //behave passive if already disposed or closed
572 m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener );
573 return;
576 //-----------------------------------------------------------------
577 // util::XCloseBroadcaster (base of XCloseable)
578 //-----------------------------------------------------------------
579 void SAL_CALL ChartModel::addCloseListener( const uno::Reference< util::XCloseListener > & xListener )
580 throw(uno::RuntimeException)
582 m_aLifeTimeManager.g_addCloseListener( xListener );
585 void SAL_CALL ChartModel::removeCloseListener( const uno::Reference< util::XCloseListener > & xListener )
586 throw(uno::RuntimeException)
588 if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
589 return; //behave passive if already disposed or closed
591 m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< util::XCloseListener >*)0), xListener );
592 return;
595 //-----------------------------------------------------------------
596 // util::XCloseable
597 //-----------------------------------------------------------------
598 void SAL_CALL ChartModel::close( sal_Bool bDeliverOwnership )
599 throw( util::CloseVetoException,
600 uno::RuntimeException )
602 //hold no mutex
604 if( !m_aLifeTimeManager.g_close_startTryClose( bDeliverOwnership ) )
605 return;
606 //no mutex is acquired
608 // At the end of this method may we must dispose ourself ...
609 // and may nobody from outside hold a reference to us ...
610 // then it's a good idea to do that by ourself.
611 uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) );
613 //the listeners have had no veto
614 //check wether we self can close
616 util::CloseVetoException aVetoException = util::CloseVetoException(
617 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
618 "the model itself could not be closed" ) )
619 , static_cast< ::cppu::OWeakObject* >(this));
621 if( m_aLifeTimeManager.g_close_isNeedToCancelLongLastingCalls( bDeliverOwnership, aVetoException ) )
623 ////you can empty this block, if you never start longlasting calls or
624 ////if your longlasting calls are per default not cancelable (check how you have constructed your LifeTimeManager)
626 sal_Bool bLongLastingCallsAreCanceled = sal_False;
629 //try to cancel running longlasting calls
630 //// @todo
632 catch( uno::Exception )
634 //// @todo
635 //do not throw anything here!! (without endTryClose)
637 //if not successful canceled
638 if(!bLongLastingCallsAreCanceled)
640 m_aLifeTimeManager.g_close_endTryClose( bDeliverOwnership, sal_True );
641 throw aVetoException;
646 m_aLifeTimeManager.g_close_endTryClose_doClose();
648 // BM @todo: is it ok to call the listeners here?
649 impl_notifyCloseListeners();
652 //-----------------------------------------------------------------
653 // lang::XTypeProvider
654 //-----------------------------------------------------------------
655 uno::Sequence< uno::Type > SAL_CALL ChartModel::getTypes()
656 throw (uno::RuntimeException)
658 uno::Reference< lang::XTypeProvider > xAggTypeProvider;
659 if( (m_xOldModelAgg->queryAggregation( ::getCppuType( & xAggTypeProvider )) >>= xAggTypeProvider)
660 && xAggTypeProvider.is())
662 uno::Sequence< uno::Type > aOwnTypes( impl::ChartModel_Base::getTypes());
663 uno::Sequence< uno::Type > aAggTypes( xAggTypeProvider->getTypes());
664 uno::Sequence< uno::Type > aResult( aOwnTypes.getLength() + aAggTypes.getLength());
665 sal_Int32 i=0;
666 for( ;i<aOwnTypes.getLength(); ++i )
667 aResult[i] = aOwnTypes[i];
668 for( sal_Int32 j=0; i<aResult.getLength(); ++j, ++i)
669 aResult[i] = aAggTypes[j];
670 return aResult;
673 return impl::ChartModel_Base::getTypes();
676 //-----------------------------------------------------------------
677 // document::XDocumentPropertiesSupplier
678 //-----------------------------------------------------------------
679 uno::Reference< document::XDocumentProperties > SAL_CALL
680 ChartModel::getDocumentProperties() throw (uno::RuntimeException)
682 if ( !m_xDocumentProperties.is() )
684 uno::Reference< document::XDocumentProperties > xDocProps(
685 ::comphelper::getProcessServiceFactory()->createInstance(
686 C2U("com.sun.star.document.DocumentProperties") ), uno::UNO_QUERY );
687 m_xDocumentProperties.set(xDocProps);
689 return m_xDocumentProperties;
692 //-----------------------------------------------------------------
693 // chart2::XChartDocument
694 //-----------------------------------------------------------------
696 uno::Reference< chart2::XDiagram > SAL_CALL ChartModel::getFirstDiagram()
697 throw (uno::RuntimeException)
699 MutexGuard aGuard( m_aModelMutex );
700 return m_xDiagram;
703 void SAL_CALL ChartModel::setFirstDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
704 throw (uno::RuntimeException)
706 Reference< chart2::XDiagram > xOldDiagram;
707 Reference< util::XModifyListener > xListener;
709 MutexGuard aGuard( m_aModelMutex );
710 if( xDiagram == m_xDiagram )
711 return;
712 xOldDiagram = m_xDiagram;
713 m_xDiagram = xDiagram;
714 xListener = this;
716 //don't keep the mutex locked while calling out
717 ModifyListenerHelper::removeListener( xOldDiagram, xListener );
718 ModifyListenerHelper::addListener( xDiagram, xListener );
719 setModified( sal_True );
722 Reference< chart2::data::XDataSource > ChartModel::impl_createDefaultData()
724 Reference< chart2::data::XDataSource > xDataSource;
725 if( hasInternalDataProvider() )
727 uno::Reference< lang::XInitialization > xIni(m_xInternalDataProvider,uno::UNO_QUERY);
728 if( xIni.is() )
730 //init internal dataprovider
732 uno::Sequence< uno::Any > aArgs(1);
733 beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True));
734 aArgs[0] <<= aParam;
735 xIni->initialize(aArgs);
737 //create data
738 uno::Sequence< beans::PropertyValue > aArgs( 4 );
739 aArgs[0] = beans::PropertyValue(
740 ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
741 uno::makeAny( C2U("all") ), beans::PropertyState_DIRECT_VALUE );
742 aArgs[1] = beans::PropertyValue(
743 ::rtl::OUString::createFromAscii("HasCategories"), -1,
744 uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
745 aArgs[2] = beans::PropertyValue(
746 ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
747 uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
748 aArgs[3] = beans::PropertyValue(
749 ::rtl::OUString::createFromAscii("DataRowSource"), -1,
750 uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
751 xDataSource = m_xInternalDataProvider->createDataSource( aArgs );
754 return xDataSource;
757 void SAL_CALL ChartModel::createInternalDataProvider( sal_Bool bCloneExistingData )
758 throw (util::CloseVetoException, uno::RuntimeException)
760 // don't lock the mutex, because this call calls out to code that tries to
761 // lock the solar mutex. On the other hand, a paint locks the solar mutex
762 // and calls to the model lock the model's mutex => deadlock
763 // @todo: lock a separate mutex in the InternalData class
764 if( !hasInternalDataProvider() )
766 if( bCloneExistingData )
767 m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( this, true );
768 else
769 m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( Reference<XChartDocument>(), true );
770 m_xDataProvider.set( m_xInternalDataProvider );
772 setModified( sal_True );
775 sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
776 throw (uno::RuntimeException)
778 return m_xDataProvider.is() && m_xInternalDataProvider.is();
781 uno::Reference< chart2::data::XDataProvider > SAL_CALL ChartModel::getDataProvider()
782 throw (uno::RuntimeException)
784 // /--
785 MutexGuard aGuard( m_aModelMutex );
786 return m_xDataProvider;
787 // \--
790 // ____ XDataReceiver ____
792 void SAL_CALL ChartModel::attachDataProvider( const uno::Reference< chart2::data::XDataProvider >& xDataProvider )
793 throw (uno::RuntimeException)
796 // /--
797 MutexGuard aGuard( m_aModelMutex );
798 uno::Reference< beans::XPropertySet > xProp( xDataProvider, uno::UNO_QUERY );
799 if( xProp.is() )
803 sal_Bool bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( Reference< frame::XModel >(this) );
804 xProp->setPropertyValue(C2U("IncludeHiddenCells"), uno::makeAny(bIncludeHiddenCells));
806 catch( const beans::UnknownPropertyException& )
811 m_xDataProvider.set( xDataProvider );
812 m_xInternalDataProvider.clear();
814 //the numberformatter is kept independent of the data provider!
815 // \--
817 setModified( sal_True );
820 void SAL_CALL ChartModel::attachNumberFormatsSupplier( const uno::Reference< util::XNumberFormatsSupplier >& xNewSupplier )
821 throw (uno::RuntimeException)
824 // /--
825 MutexGuard aGuard( m_aModelMutex );
826 if( xNewSupplier==m_xNumberFormatsSupplier )
827 return;
828 if( xNewSupplier==m_xOwnNumberFormatsSupplier )
829 return;
830 if( m_xOwnNumberFormatsSupplier.is() && xNewSupplier.is() )
832 //@todo
833 //merge missing numberformats from own to new formatter
835 else if( !xNewSupplier.is() )
837 if( m_xNumberFormatsSupplier.is() )
839 //@todo
840 //merge missing numberformats from old numberformatter to own numberformatter
841 //create own numberformatter if necessary
845 m_xNumberFormatsSupplier.set( xNewSupplier );
846 m_xOwnNumberFormatsSupplier.clear();
847 // \--
849 setModified( sal_True );
852 void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >& aArguments )
853 throw (lang::IllegalArgumentException,
854 uno::RuntimeException)
857 // /--
858 MutexGuard aGuard( m_aModelMutex );
859 if( !m_xDataProvider.is() )
860 return;
861 lockControllers();
865 Reference< chart2::data::XDataSource > xDataSource( m_xDataProvider->createDataSource( aArguments ) );
866 if( xDataSource.is() )
868 // set new data
869 Reference< chart2::XChartTypeTemplate > xTemplate;
870 Reference< chart2::XDiagram > xDia( getFirstDiagram() );
871 if( xDia.is())
873 // apply new data
874 DiagramHelper::tTemplateWithServiceName aTemplateAndService =
875 DiagramHelper::getTemplateForDiagram(
876 xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY ));
877 xTemplate.set( aTemplateAndService.first );
880 if( !xTemplate.is())
881 xTemplate.set( impl_createDefaultChartTypeTemplate() );
883 if( xTemplate.is())
885 if( xDia.is())
886 xTemplate->changeDiagramData( xDia, xDataSource, aArguments );
887 else
888 setFirstDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments ) );
892 catch( lang::IllegalArgumentException & )
894 throw;
896 catch( uno::Exception & ex )
898 ASSERT_EXCEPTION( ex );
900 unlockControllers();
901 // \--
903 setModified( sal_True );
906 Sequence< OUString > SAL_CALL ChartModel::getUsedRangeRepresentations()
907 throw (uno::RuntimeException)
909 return DataSourceHelper::getUsedDataRanges( Reference< frame::XModel >(this));
912 Reference< chart2::data::XDataSource > SAL_CALL ChartModel::getUsedData()
913 throw (uno::RuntimeException)
915 return DataSourceHelper::getUsedData( Reference< chart2::XChartDocument >(this));
918 Reference< chart2::data::XRangeHighlighter > SAL_CALL ChartModel::getRangeHighlighter()
919 throw (uno::RuntimeException)
921 if( ! m_xRangeHighlighter.is())
923 uno::Reference< view::XSelectionSupplier > xSelSupp( this->getCurrentController(), uno::UNO_QUERY );
924 if( xSelSupp.is() )
925 m_xRangeHighlighter.set( ChartModelHelper::createRangeHighlighter( xSelSupp ));
927 return m_xRangeHighlighter;
930 Reference< chart2::XChartTypeTemplate > ChartModel::impl_createDefaultChartTypeTemplate()
932 Reference< chart2::XChartTypeTemplate > xTemplate;
933 Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY );
934 if( xFact.is() )
935 xTemplate.set( xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY );
936 return xTemplate;
939 void SAL_CALL ChartModel::setChartTypeManager( const uno::Reference< chart2::XChartTypeManager >& xNewManager )
940 throw (uno::RuntimeException)
943 // /--
944 MutexGuard aGuard( m_aModelMutex );
945 m_xChartTypeManager = xNewManager;
946 // \--
948 setModified( sal_True );
951 uno::Reference< chart2::XChartTypeManager > SAL_CALL ChartModel::getChartTypeManager()
952 throw (uno::RuntimeException)
954 // /--
955 MutexGuard aGuard( m_aModelMutex );
956 return m_xChartTypeManager;
957 // \--
960 uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getPageBackground()
961 throw (uno::RuntimeException)
963 // /--
964 MutexGuard aGuard( m_aModelMutex );
965 return m_xPageBackground;
966 // \--
969 // ____ XTitled ____
970 uno::Reference< chart2::XTitle > SAL_CALL ChartModel::getTitleObject()
971 throw (uno::RuntimeException)
973 // /--
974 MutexGuard aGuard( m_aModelMutex );
975 return m_xTitle;
976 // \--
979 void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xTitle )
980 throw (uno::RuntimeException)
983 // /--
984 MutexGuard aGuard( m_aModelMutex );
985 if( m_xTitle.is() )
986 ModifyListenerHelper::removeListener( m_xTitle, this );
987 m_xTitle = xTitle;
988 ModifyListenerHelper::addListener( m_xTitle, this );
989 // \--
991 setModified( sal_True );
994 void ChartModel::impl_createOldModelAgg()
996 if( ! m_xOldModelAgg.is())
998 m_xOldModelAgg.set(
999 m_xContext->getServiceManager()->createInstanceWithContext(
1000 CHART_CHARTAPIWRAPPER_SERVICE_NAME,
1001 m_xContext ), uno::UNO_QUERY_THROW );
1002 m_xOldModelAgg->setDelegator( static_cast< ::cppu::OWeakObject* >( this ));
1006 // ____ XInterface (for old API wrapper) ____
1007 uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType )
1008 throw (uno::RuntimeException)
1010 uno::Any aResult( impl::ChartModel_Base::queryInterface( aType ));
1012 if( ! aResult.hasValue())
1014 // try old API wrapper
1017 impl_createOldModelAgg();
1018 if( m_xOldModelAgg.is())
1019 aResult = m_xOldModelAgg->queryAggregation( aType );
1021 catch( uno::Exception & ex )
1023 ASSERT_EXCEPTION( ex );
1027 return aResult;
1030 // ____ XCloneable ____
1031 Reference< util::XCloneable > SAL_CALL ChartModel::createClone()
1032 throw (uno::RuntimeException)
1034 return Reference< util::XCloneable >( new ChartModel( *this ));
1037 // ____ XVisualObject ____
1038 void SAL_CALL ChartModel::setVisualAreaSize( ::sal_Int64 nAspect, const awt::Size& aSize )
1039 throw (lang::IllegalArgumentException,
1040 embed::WrongStateException,
1041 uno::Exception,
1042 uno::RuntimeException)
1044 if( nAspect == embed::Aspects::MSOLE_CONTENT )
1046 ControllerLockGuard aLockGuard( this );
1047 bool bChanged =
1048 (m_aVisualAreaSize.Width != aSize.Width ||
1049 m_aVisualAreaSize.Height != aSize.Height);
1051 // #i12587# support for shapes in chart
1052 if ( bChanged )
1054 impl_adjustAdditionalShapesPositionAndSize( aSize );
1057 m_aVisualAreaSize = aSize;
1058 if( bChanged )
1059 setModified( sal_True );
1061 else
1063 OSL_ENSURE( false, "setVisualAreaSize: Aspect not implemented yet.");
1067 awt::Size SAL_CALL ChartModel::getVisualAreaSize( ::sal_Int64 nAspect )
1068 throw (lang::IllegalArgumentException,
1069 embed::WrongStateException,
1070 uno::Exception,
1071 uno::RuntimeException)
1073 OSL_ENSURE( nAspect == embed::Aspects::MSOLE_CONTENT,
1074 "No aspects other than content are supported" );
1075 (void)(nAspect); // avoid warning in non-debug builds
1076 // other possible aspects are MSOLE_THUMBNAIL, MSOLE_ICON and MSOLE_DOCPRINT
1078 return m_aVisualAreaSize;
1081 embed::VisualRepresentation SAL_CALL ChartModel::getPreferredVisualRepresentation( ::sal_Int64 nAspect )
1082 throw (lang::IllegalArgumentException,
1083 embed::WrongStateException,
1084 uno::Exception,
1085 uno::RuntimeException)
1087 OSL_ENSURE( nAspect == embed::Aspects::MSOLE_CONTENT,
1088 "No aspects other than content are supported" );
1089 (void)(nAspect); // avoid warning in non-debug builds
1091 embed::VisualRepresentation aResult;
1095 Sequence< sal_Int8 > aMetafile;
1097 //get view from old api wrapper
1098 Reference< datatransfer::XTransferable > xTransferable(
1099 this->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
1100 if( xTransferable.is() )
1102 datatransfer::DataFlavor aDataFlavor( lcl_aGDIMetaFileMIMEType,
1103 C2U( "GDIMetaFile" ),
1104 ::getCppuType( (const uno::Sequence< sal_Int8 >*) 0 ) );
1106 uno::Any aData( xTransferable->getTransferData( aDataFlavor ) );
1107 aData >>= aMetafile;
1110 aResult.Flavor.MimeType = lcl_aGDIMetaFileMIMEType;
1111 aResult.Flavor.DataType = getCppuType( &aMetafile );
1113 aResult.Data <<= aMetafile;
1115 catch( uno::Exception & ex )
1117 ASSERT_EXCEPTION( ex );
1120 return aResult;
1123 ::sal_Int32 SAL_CALL ChartModel::getMapUnit( ::sal_Int64 nAspect )
1124 throw (uno::Exception,
1125 uno::RuntimeException)
1127 OSL_ENSURE( nAspect == embed::Aspects::MSOLE_CONTENT,
1128 "No aspects other than content are supported" );
1129 (void)(nAspect); // avoid warning in non-debug builds
1130 return embed::EmbedMapUnits::ONE_100TH_MM;
1133 // ____ datatransfer::XTransferable ____
1134 uno::Any SAL_CALL ChartModel::getTransferData( const datatransfer::DataFlavor& aFlavor )
1135 throw (datatransfer::UnsupportedFlavorException,
1136 io::IOException,
1137 uno::RuntimeException)
1139 uno::Any aResult;
1140 if( this->isDataFlavorSupported( aFlavor ))
1144 //get view from old api wrapper
1145 Reference< datatransfer::XTransferable > xTransferable(
1146 this->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
1147 if( xTransferable.is() &&
1148 xTransferable->isDataFlavorSupported( aFlavor ))
1150 aResult = xTransferable->getTransferData( aFlavor );
1153 catch( uno::Exception & ex )
1155 ASSERT_EXCEPTION( ex );
1158 else
1160 throw datatransfer::UnsupportedFlavorException(
1161 aFlavor.MimeType, static_cast< ::cppu::OWeakObject* >( this ));
1164 return aResult;
1167 Sequence< datatransfer::DataFlavor > SAL_CALL ChartModel::getTransferDataFlavors()
1168 throw (uno::RuntimeException)
1170 uno::Sequence< datatransfer::DataFlavor > aRet(1);
1172 // aRet[0] = datatransfer::DataFlavor( lcl_aGDIMetaFileMIMEType,
1173 // C2U( "GDIMetaFile" ),
1174 // ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
1175 aRet[0] = datatransfer::DataFlavor( lcl_aGDIMetaFileMIMETypeHighContrast,
1176 C2U( "GDIMetaFile" ),
1177 ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
1179 return aRet;
1182 ::sal_Bool SAL_CALL ChartModel::isDataFlavorSupported( const datatransfer::DataFlavor& aFlavor )
1183 throw (uno::RuntimeException)
1185 // return ( aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMEType) ||
1186 // aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMETypeHighContrast) );
1187 return aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMETypeHighContrast);
1192 namespace
1194 enum eServiceType
1196 SERVICE_DASH_TABLE,
1197 SERVICE_GARDIENT_TABLE,
1198 SERVICE_HATCH_TABLE,
1199 SERVICE_BITMAP_TABLE,
1200 SERVICE_TRANSP_GRADIENT_TABLE,
1201 SERVICE_MARKER_TABLE,
1202 SERVICE_NAMESPACE_MAP
1205 typedef ::std::map< ::rtl::OUString, enum eServiceType > tServiceNameMap;
1206 typedef ::comphelper::MakeMap< ::rtl::OUString, enum eServiceType > tMakeServiceNameMap;
1208 tServiceNameMap & lcl_getStaticServiceNameMap()
1210 static tServiceNameMap aServiceNameMap(
1211 tMakeServiceNameMap
1212 ( C2U( "com.sun.star.drawing.DashTable" ), SERVICE_DASH_TABLE )
1213 ( C2U( "com.sun.star.drawing.GradientTable" ), SERVICE_GARDIENT_TABLE )
1214 ( C2U( "com.sun.star.drawing.HatchTable" ), SERVICE_HATCH_TABLE )
1215 ( C2U( "com.sun.star.drawing.BitmapTable" ), SERVICE_BITMAP_TABLE )
1216 ( C2U( "com.sun.star.drawing.TransparencyGradientTable" ), SERVICE_TRANSP_GRADIENT_TABLE )
1217 ( C2U( "com.sun.star.drawing.MarkerTable" ), SERVICE_MARKER_TABLE )
1218 ( C2U( "com.sun.star.xml.NamespaceMap" ), SERVICE_NAMESPACE_MAP )
1220 return aServiceNameMap;
1223 // ____ XMultiServiceFactory ____
1224 Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString& rServiceSpecifier )
1225 throw( uno::Exception, uno::RuntimeException )
1227 uno::Reference< uno::XInterface > xResult;
1228 tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
1230 tServiceNameMap::const_iterator aIt( rMap.find( rServiceSpecifier ));
1231 if( aIt != rMap.end())
1233 switch( (*aIt).second )
1235 case SERVICE_DASH_TABLE:
1236 case SERVICE_GARDIENT_TABLE:
1237 case SERVICE_HATCH_TABLE:
1238 case SERVICE_BITMAP_TABLE:
1239 case SERVICE_TRANSP_GRADIENT_TABLE:
1240 case SERVICE_MARKER_TABLE:
1242 uno::Reference< lang::XMultiServiceFactory > xFact(
1243 this->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
1244 if ( xFact.is() )
1246 return xFact->createInstance( rServiceSpecifier );
1249 break;
1250 case SERVICE_NAMESPACE_MAP:
1251 return Reference< uno::XInterface >( m_xXMLNamespaceMap );
1254 else
1256 impl_createOldModelAgg();
1257 if( m_xOldModelAgg.is() )
1259 Any aAny = m_xOldModelAgg->queryAggregation( ::getCppuType((const uno::Reference< lang::XMultiServiceFactory >*)0) );
1260 uno::Reference< lang::XMultiServiceFactory > xOldModelFactory;
1261 if( (aAny >>= xOldModelFactory) && xOldModelFactory.is() )
1263 return xOldModelFactory->createInstance( rServiceSpecifier );
1267 return 0;
1270 Reference< uno::XInterface > SAL_CALL ChartModel::createInstanceWithArguments(
1271 const OUString& rServiceSpecifier , const Sequence< Any >& Arguments )
1272 throw( uno::Exception, uno::RuntimeException )
1274 OSL_ENSURE( Arguments.getLength(), "createInstanceWithArguments: Warning: Arguments are ignored" );
1275 (void)(Arguments); // avoid warning in non-debug builds
1276 return createInstance( rServiceSpecifier );
1279 Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames()
1280 throw( uno::RuntimeException )
1282 uno::Sequence< ::rtl::OUString > aResult;
1284 impl_createOldModelAgg();
1285 if( m_xOldModelAgg.is())
1287 Any aAny = m_xOldModelAgg->queryAggregation( ::getCppuType((const uno::Reference< lang::XMultiServiceFactory >*)0) );
1288 uno::Reference< lang::XMultiServiceFactory > xOldModelFactory;
1289 if( (aAny >>= xOldModelFactory) && xOldModelFactory.is() )
1291 return xOldModelFactory->getAvailableServiceNames();
1294 return aResult;
1297 Reference< util::XNumberFormatsSupplier > ChartModel::impl_getNumberFormatsSupplier()
1299 if( !m_xNumberFormatsSupplier.is() )
1301 if( !m_xOwnNumberFormatsSupplier.is() )
1303 Reference< lang::XMultiServiceFactory > xFactory( m_xContext->getServiceManager(), uno::UNO_QUERY );
1304 m_xOwnNumberFormatsSupplier = new SvNumberFormatsSupplierObj( new SvNumberFormatter( xFactory, LANGUAGE_SYSTEM ) );
1305 //pOwnNumberFormatter->ChangeStandardPrec( 15 ); todo?
1307 m_xNumberFormatsSupplier = m_xOwnNumberFormatsSupplier;
1309 return m_xNumberFormatsSupplier;
1312 // ____ XUnoTunnel ___
1313 ::sal_Int64 SAL_CALL ChartModel::getSomething( const Sequence< ::sal_Int8 >& aIdentifier )
1314 throw( uno::RuntimeException)
1316 if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( SvNumberFormatsSupplierObj::getUnoTunnelId().getConstArray(),
1317 aIdentifier.getConstArray(), 16 ) )
1319 Reference< lang::XUnoTunnel > xTunnel( impl_getNumberFormatsSupplier(), uno::UNO_QUERY );
1320 if( xTunnel.is() )
1321 return xTunnel->getSomething( aIdentifier );
1323 return 0;
1326 // ____ XNumberFormatsSupplier ____
1327 uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getNumberFormatSettings()
1328 throw (uno::RuntimeException)
1330 Reference< util::XNumberFormatsSupplier > xSupplier( impl_getNumberFormatsSupplier() );
1331 if( xSupplier.is() )
1332 return xSupplier->getNumberFormatSettings();
1333 return uno::Reference< beans::XPropertySet >();
1336 uno::Reference< util::XNumberFormats > SAL_CALL ChartModel::getNumberFormats()
1337 throw (uno::RuntimeException)
1339 Reference< util::XNumberFormatsSupplier > xSupplier( impl_getNumberFormatsSupplier() );
1340 if( xSupplier.is() )
1341 return xSupplier->getNumberFormats();
1342 return uno::Reference< util::XNumberFormats >();
1345 // ____ XChild ____
1346 Reference< uno::XInterface > SAL_CALL ChartModel::getParent()
1347 throw (uno::RuntimeException)
1349 return Reference< uno::XInterface >(m_xParent,uno::UNO_QUERY);
1352 void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent )
1353 throw (lang::NoSupportException,
1354 uno::RuntimeException)
1356 if( Parent != m_xParent )
1357 m_xParent.set( Parent, uno::UNO_QUERY );
1360 // ____ XUndoManager ____
1361 Reference< chart2::XUndoManager > SAL_CALL ChartModel::getUndoManager()
1362 throw (uno::RuntimeException)
1364 return m_xUndoManager;
1367 // ____ XDataSource ____
1368 uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartModel::getDataSequences()
1369 throw (uno::RuntimeException)
1371 Reference< chart2::data::XDataSource > xSource(
1372 DataSourceHelper::getUsedData( uno::Reference< frame::XModel >(this) ) );
1373 if( xSource.is())
1374 return xSource->getDataSequences();
1376 return uno::Sequence< Reference< chart2::data::XLabeledDataSequence > >();
1379 } // namespace chart