1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "ChartModel.hxx"
21 #include "servicenames.hxx"
22 #include "MediaDescriptorHelper.hxx"
24 #include "NoWarningThisInCTOR.hxx"
25 #include "DataSourceHelper.hxx"
26 #include "ChartModelHelper.hxx"
27 #include "DiagramHelper.hxx"
28 #include "DisposeHelper.hxx"
29 #include "ControllerLockGuard.hxx"
30 #include "ObjectIdentifier.hxx"
31 #include "PageBackground.hxx"
32 #include "CloneHelper.hxx"
33 #include "NameContainer.hxx"
34 #include "UndoManager.hxx"
36 #include <com/sun/star/chart/ChartDataRowSource.hpp>
38 #include <comphelper/InlineContainer.hxx>
39 #include <comphelper/processfactory.hxx>
41 // header for class SvNumberFormatsSupplierObj
42 #include <svl/numuno.hxx>
43 #include <com/sun/star/lang/DisposedException.hpp>
44 #include <com/sun/star/lang/XInitialization.hpp>
45 #include <com/sun/star/view/XSelectionSupplier.hpp>
46 #include <com/sun/star/embed/XEmbedObjectCreator.hpp>
47 #include <com/sun/star/embed/XEmbedPersist.hpp>
48 #include <com/sun/star/embed/EmbedStates.hpp>
49 #include <com/sun/star/embed/XComponentSupplier.hpp>
50 #include <com/sun/star/embed/XStorage.hpp>
51 #include <com/sun/star/embed/EmbedMapUnits.hpp>
52 #include <com/sun/star/embed/Aspects.hpp>
53 #include <com/sun/star/awt/Gradient.hpp>
54 #include <com/sun/star/awt/XWindow.hpp>
55 #include <com/sun/star/awt/PosSize.hpp>
56 #include <com/sun/star/datatransfer/XTransferable.hpp>
57 #include <com/sun/star/drawing/Hatch.hpp>
58 #include <com/sun/star/drawing/LineDash.hpp>
59 #include <com/sun/star/drawing/XShapes.hpp>
60 #include <com/sun/star/document/DocumentProperties.hpp>
62 // header for class SvNumberFormatter
63 #include <svl/zforlist.hxx>
65 using ::com::sun::star::uno::Sequence
;
66 using ::com::sun::star::uno::Reference
;
67 using ::com::sun::star::uno::RuntimeException
;
68 using ::com::sun::star::uno::Any
;
69 using ::osl::MutexGuard
;
71 using namespace ::com::sun::star
;
72 using namespace ::apphelper
;
73 using namespace ::chart::CloneHelper
;
77 const OUString
lcl_aGDIMetaFileMIMEType(
78 "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"");
79 const OUString
lcl_aGDIMetaFileMIMETypeHighContrast(
80 "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"");
82 } // anonymous namespace
84 //-----------------------------------------------------------------
85 // ChartModel Constructor and Destructor
86 //-----------------------------------------------------------------
91 ChartModel::ChartModel(uno::Reference
<uno::XComponentContext
> const & xContext
)
92 : m_aLifeTimeManager( this, this )
93 , m_bReadOnly( sal_False
)
94 , m_bModified( sal_False
)
96 , m_bUpdateNotificationsPending(false)
97 , m_pUndoManager( NULL
)
98 , m_aControllers( m_aModelMutex
)
99 , m_nControllerLockCount(0)
100 , m_xContext( xContext
)
101 , m_aVisualAreaSize( ChartModelHelper::getDefaultPageSize() )
102 , m_xDataProvider( 0 )
103 , m_xInternalDataProvider( 0 )
104 , m_xPageBackground( new PageBackground( m_xContext
) )
105 , m_xXMLNamespaceMap( createNameContainer( ::getCppuType( (const OUString
*) 0 ),
106 "com.sun.star.xml.NamespaceMap", "com.sun.star.comp.chart.XMLNameSpaceMap" ), uno::UNO_QUERY
)
108 OSL_TRACE( "ChartModel: CTOR called" );
110 osl_atomic_increment(&m_refCount
);
113 m_xContext
->getServiceManager()->createInstanceWithContext(
114 CHART_CHARTAPIWRAPPER_SERVICE_NAME
,
115 m_xContext
), uno::UNO_QUERY_THROW
);
116 m_xOldModelAgg
->setDelegator( *this );
120 ModifyListenerHelper::addListener( m_xPageBackground
, this );
121 m_xChartTypeManager
.set( xContext
->getServiceManager()->createInstanceWithContext(
122 "com.sun.star.chart2.ChartTypeManager", m_xContext
), uno::UNO_QUERY
);
124 osl_atomic_decrement(&m_refCount
);
127 ChartModel::ChartModel( const ChartModel
& rOther
)
128 : impl::ChartModel_Base()
129 , m_aLifeTimeManager( this, this )
130 , m_bReadOnly( rOther
.m_bReadOnly
)
131 , m_bModified( rOther
.m_bModified
)
133 , m_bUpdateNotificationsPending(false)
134 , m_aResource( rOther
.m_aResource
)
135 , m_aMediaDescriptor( rOther
.m_aMediaDescriptor
)
136 , m_aControllers( m_aModelMutex
)
137 , m_nControllerLockCount(0)
138 , m_xContext( rOther
.m_xContext
)
139 // @note: the old model aggregate must not be shared with other models if it
140 // is, you get mutex deadlocks
141 , m_xOldModelAgg( 0 ) //rOther.m_xOldModelAgg )
142 , m_xStorage( 0 ) //rOther.m_xStorage )
143 , m_aVisualAreaSize( rOther
.m_aVisualAreaSize
)
144 , m_aGraphicObjectVector( rOther
.m_aGraphicObjectVector
)
145 , m_xDataProvider( rOther
.m_xDataProvider
)
146 , m_xInternalDataProvider( rOther
.m_xInternalDataProvider
)
148 OSL_TRACE( "ChartModel: Copy-CTOR called" );
150 osl_atomic_increment(&m_refCount
);
153 m_xContext
->getServiceManager()->createInstanceWithContext(
154 CHART_CHARTAPIWRAPPER_SERVICE_NAME
,
155 m_xContext
), uno::UNO_QUERY_THROW
);
156 m_xOldModelAgg
->setDelegator( *this );
158 Reference
< util::XModifyListener
> xListener
;
159 Reference
< chart2::XTitle
> xNewTitle
= CreateRefClone
< Reference
< chart2::XTitle
> >()( rOther
.m_xTitle
);
160 Reference
< chart2::XDiagram
> xNewDiagram
= CreateRefClone
< Reference
< chart2::XDiagram
> >()( rOther
.m_xDiagram
);
161 Reference
< beans::XPropertySet
> xNewPageBackground
= CreateRefClone
< Reference
< beans::XPropertySet
> >()( rOther
.m_xPageBackground
);
162 Reference
< chart2::XChartTypeManager
> xChartTypeManager
= CreateRefClone
< Reference
< chart2::XChartTypeManager
> >()( rOther
.m_xChartTypeManager
);
163 Reference
< container::XNameAccess
> xXMLNamespaceMap
= CreateRefClone
< Reference
< container::XNameAccess
> >()( rOther
.m_xXMLNamespaceMap
);
166 MutexGuard
aGuard( m_aModelMutex
);
168 m_xTitle
= xNewTitle
;
169 m_xDiagram
= xNewDiagram
;
170 m_xPageBackground
= xNewPageBackground
;
171 m_xChartTypeManager
= xChartTypeManager
;
172 m_xXMLNamespaceMap
= xXMLNamespaceMap
;
175 ModifyListenerHelper::addListener( xNewTitle
, xListener
);
176 ModifyListenerHelper::addListener( xNewDiagram
, xListener
);
177 ModifyListenerHelper::addListener( xNewPageBackground
, xListener
);
180 osl_atomic_decrement(&m_refCount
);
183 ChartModel::~ChartModel()
185 OSL_TRACE( "ChartModel: DTOR called" );
186 if( m_xOldModelAgg
.is())
187 m_xOldModelAgg
->setDelegator( NULL
);
190 void SAL_CALL
ChartModel::initialize( const Sequence
< Any
>& /*rArguments*/ )
191 throw (uno::Exception
, uno::RuntimeException
)
193 //#i113722# avoid duplicate creation
195 //maybe additional todo?:
196 //support argument "EmbeddedObject"?
197 //support argument "EmbeddedScriptSupport"?
198 //support argument "DocumentRecoverySupport"?
201 //-----------------------------------------------------------------
203 //-----------------------------------------------------------------
205 OUString
ChartModel::impl_g_getLocation()
208 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
209 if(!aGuard
.startApiCall())
210 return OUString(); //behave passive if already disposed or closed or throw exception @todo?
215 sal_Bool
ChartModel::impl_isControllerConnected( const uno::Reference
< frame::XController
>& xController
)
219 uno::Sequence
< uno::Reference
<uno::XInterface
> > aSeq
= m_aControllers
.getElements();
220 for( sal_Int32 nN
= aSeq
.getLength(); nN
--; )
222 if( aSeq
[nN
] == xController
)
226 catch (const uno::Exception
&)
232 uno::Reference
< frame::XController
> ChartModel::impl_getCurrentController() throw(uno::RuntimeException
)
234 //@todo? hold only weak references to controllers
236 // get the last active controller of this model
237 if( m_xCurrentController
.is() )
238 return m_xCurrentController
;
240 // get the first controller of this model
241 if( m_aControllers
.getLength() )
243 uno::Reference
<uno::XInterface
> xI
= m_aControllers
.getElements()[0];
244 return uno::Reference
<frame::XController
>( xI
, uno::UNO_QUERY
);
247 //return nothing if no controllers are connected at all
248 return uno::Reference
< frame::XController
> ();
251 void SAL_CALL
ChartModel::impl_notifyCloseListeners()
252 throw( uno::RuntimeException
)
254 ::cppu::OInterfaceContainerHelper
* pIC
= m_aLifeTimeManager
.m_aListenerContainer
255 .getContainer( ::getCppuType((const uno::Reference
< util::XCloseListener
>*)0) );
258 lang::EventObject
aEvent( static_cast< lang::XComponent
*>(this) );
259 ::cppu::OInterfaceIteratorHelper
aIt( *pIC
);
260 while( aIt
.hasMoreElements() )
262 uno::Reference
< util::XCloseListener
> xListener( aIt
.next(), uno::UNO_QUERY
);
264 xListener
->notifyClosing( aEvent
);
269 void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size
& aVisualAreaSize
)
271 uno::Reference
< beans::XPropertySet
> xProperties( static_cast< ::cppu::OWeakObject
* >( this ), uno::UNO_QUERY
);
272 if ( xProperties
.is() )
274 uno::Reference
< drawing::XShapes
> xShapes
;
275 xProperties
->getPropertyValue( "AdditionalShapes" ) >>= xShapes
;
278 sal_Int32 nCount
= xShapes
->getCount();
279 for ( sal_Int32 i
= 0; i
< nCount
; ++i
)
281 Reference
< drawing::XShape
> xShape
;
282 if ( xShapes
->getByIndex( i
) >>= xShape
)
286 awt::Point
aPos( xShape
->getPosition() );
287 awt::Size
aSize( xShape
->getSize() );
289 double fWidth
= static_cast< double >( aVisualAreaSize
.Width
) / m_aVisualAreaSize
.Width
;
290 double fHeight
= static_cast< double >( aVisualAreaSize
.Height
) / m_aVisualAreaSize
.Height
;
292 aPos
.X
= static_cast< long >( aPos
.X
* fWidth
);
293 aPos
.Y
= static_cast< long >( aPos
.Y
* fHeight
);
294 aSize
.Width
= static_cast< long >( aSize
.Width
* fWidth
);
295 aSize
.Height
= static_cast< long >( aSize
.Height
* fHeight
);
297 xShape
->setPosition( aPos
);
298 xShape
->setSize( aSize
);
306 //-----------------------------------------------------------------
307 // lang::XServiceInfo
308 //-----------------------------------------------------------------
310 APPHELPER_XSERVICEINFO_IMPL(ChartModel
,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME
)
312 uno::Sequence
< OUString
> ChartModel::getSupportedServiceNames_Static()
314 uno::Sequence
< OUString
> aSNS( 3 );
315 aSNS
[0] = CHART_MODEL_SERVICE_NAME
;
316 aSNS
[1] = "com.sun.star.document.OfficeDocument";
317 aSNS
[2] = "com.sun.star.chart.ChartDocument";
318 //// @todo : add additional services if you support any further
322 //-----------------------------------------------------------------
323 // frame::XModel (required interface)
324 //-----------------------------------------------------------------
326 sal_Bool SAL_CALL
ChartModel::attachResource( const OUString
& rURL
327 , const uno::Sequence
< beans::PropertyValue
>& rMediaDescriptor
)
328 throw(uno::RuntimeException
)
331 The method attachResource() is used by the frame loader implementations
332 to inform the model about its URL and MediaDescriptor.
335 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
336 if(!aGuard
.startApiCall())
337 return sal_False
; //behave passive if already disposed or closed or throw exception @todo?
340 if(!m_aResource
.isEmpty())//we have a resource already //@todo? or is setting a new resource allowed?
343 m_aMediaDescriptor
= rMediaDescriptor
;
345 //@todo ? check rURL ??
346 //@todo ? evaluate m_aMediaDescriptor;
347 //@todo ? ... ??? --> nothing, this method is only for setting information
352 OUString SAL_CALL
ChartModel::getURL() throw(uno::RuntimeException
)
354 return impl_g_getLocation();
357 uno::Sequence
< beans::PropertyValue
> SAL_CALL
ChartModel::getArgs() throw(uno::RuntimeException
)
360 The method getArgs() returns a sequence of property values
361 that report the resource description according to com.sun.star.document.MediaDescriptor,
362 specified on loading or saving with storeAsURL.
365 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
366 if(!aGuard
.startApiCall())
367 return uno::Sequence
< beans::PropertyValue
>(); //behave passive if already disposed or closed or throw exception @todo?
370 return m_aMediaDescriptor
;
373 void SAL_CALL
ChartModel::connectController( const uno::Reference
< frame::XController
>& xController
)
374 throw(uno::RuntimeException
)
376 //@todo? this method is declared as oneway -> ...?
378 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
379 if(!aGuard
.startApiCall())
380 return ; //behave passive if already disposed or closed
384 m_aControllers
.addInterface(xController
);
387 void SAL_CALL
ChartModel::disconnectController( const uno::Reference
< frame::XController
>& xController
)
388 throw(uno::RuntimeException
)
390 //@todo? this method is declared as oneway -> ...?
392 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
393 if(!aGuard
.startApiCall())
394 return; //behave passive if already disposed or closed
396 //--remove controller
397 m_aControllers
.removeInterface(xController
);
399 //case: current controller is disconnected:
400 if( m_xCurrentController
== xController
)
401 m_xCurrentController
.clear();
403 DisposeHelper::DisposeAndClear( m_xRangeHighlighter
);
406 void SAL_CALL
ChartModel::lockControllers() throw(uno::RuntimeException
)
409 suspends some notifications to the controllers which are used for display updates.
411 The calls to lockControllers() and unlockControllers() may be nested
412 and even overlapping, but they must be in pairs. While there is at least one lock
413 remaining, some notifications for display updates are not broadcasted.
416 //@todo? this method is declared as oneway -> ...?
418 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
419 if(!aGuard
.startApiCall())
420 return; //behave passive if already disposed or closed or throw exception @todo?
421 ++m_nControllerLockCount
;
424 void SAL_CALL
ChartModel::unlockControllers() throw(uno::RuntimeException
)
427 resumes the notifications which were suspended by lockControllers() .
429 The calls to lockControllers() and unlockControllers() may be nested
430 and even overlapping, but they must be in pairs. While there is at least one lock
431 remaining, some notifications for display updates are not broadcasted.
434 //@todo? this method is declared as oneway -> ...?
436 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
437 if(!aGuard
.startApiCall())
438 return; //behave passive if already disposed or closed or throw exception @todo?
439 if( m_nControllerLockCount
== 0 )
441 OSL_TRACE( "ChartModel: unlockControllers called with m_nControllerLockCount == 0" );
444 --m_nControllerLockCount
;
445 if( m_nControllerLockCount
== 0 && m_bUpdateNotificationsPending
)
448 impl_notifyModifiedListeners();
452 sal_Bool SAL_CALL
ChartModel::hasControllersLocked() throw(uno::RuntimeException
)
454 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
455 if(!aGuard
.startApiCall())
456 return sal_False
; //behave passive if already disposed or closed or throw exception @todo?
457 return ( m_nControllerLockCount
!= 0 ) ;
460 uno::Reference
< frame::XController
> SAL_CALL
ChartModel::getCurrentController() throw(uno::RuntimeException
)
462 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
463 if(!aGuard
.startApiCall())
464 throw lang::DisposedException(
465 "getCurrentController was called on an already disposed or closed model",
466 static_cast< ::cppu::OWeakObject
* >(this) );
468 return impl_getCurrentController();
471 void SAL_CALL
ChartModel::setCurrentController( const uno::Reference
< frame::XController
>& xController
)
472 throw(container::NoSuchElementException
, uno::RuntimeException
)
474 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
475 if(!aGuard
.startApiCall())
476 throw lang::DisposedException(
477 "setCurrentController was called on an already disposed or closed model",
478 static_cast< ::cppu::OWeakObject
* >(this) );
480 //OSL_ENSURE( impl_isControllerConnected(xController), "setCurrentController is called with a Controller which is not connected" );
481 if(!impl_isControllerConnected(xController
))
482 throw container::NoSuchElementException(
483 "setCurrentController is called with a Controller which is not connected",
484 static_cast< ::cppu::OWeakObject
* >(this) );
486 m_xCurrentController
= xController
;
488 DisposeHelper::DisposeAndClear( m_xRangeHighlighter
);
491 uno::Reference
< uno::XInterface
> SAL_CALL
ChartModel::getCurrentSelection() throw(uno::RuntimeException
)
493 LifeTimeGuard
aGuard(m_aLifeTimeManager
);
494 if(!aGuard
.startApiCall())
495 throw lang::DisposedException(
496 "getCurrentSelection was called on an already disposed or closed model",
497 static_cast< ::cppu::OWeakObject
* >(this) );
500 uno::Reference
< uno::XInterface
> xReturn
;
501 uno::Reference
< frame::XController
> xController
= impl_getCurrentController();
504 if( xController
.is() )
506 uno::Reference
< view::XSelectionSupplier
> xSelectionSupl( xController
, uno::UNO_QUERY
);
507 if ( xSelectionSupl
.is() )
509 uno::Any aSel
= xSelectionSupl
->getSelection();
511 if( aSel
>>= aObjectCID
)
512 xReturn
.set( ObjectIdentifier::getObjectPropertySet( aObjectCID
, Reference
< XChartDocument
>(this)));
519 //-----------------------------------------------------------------
520 // lang::XComponent (base of XModel)
521 //-----------------------------------------------------------------
522 void SAL_CALL
ChartModel::dispose() throw(uno::RuntimeException
)
524 Reference
< XInterface
> xKeepAlive( *this );
526 //This object should release all resources and references in the
527 //easiest possible manner
528 //This object must notify all registered listeners using the method
529 //<member>XEventListener::disposing</member>
532 if( !m_aLifeTimeManager
.dispose() )
535 //--release all resources and references
538 if ( m_xDiagram
.is() )
539 ModifyListenerHelper::removeListener( m_xDiagram
, this );
541 m_xDataProvider
.clear();
542 m_xInternalDataProvider
.clear();
543 m_xNumberFormatsSupplier
.clear();
544 DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier
);
545 DisposeHelper::DisposeAndClear( m_xChartTypeManager
);
546 DisposeHelper::DisposeAndClear( m_xDiagram
);
547 DisposeHelper::DisposeAndClear( m_xTitle
);
548 DisposeHelper::DisposeAndClear( m_xPageBackground
);
549 DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap
);
552 // just clear, don't dispose - we're not the owner
554 if ( m_pUndoManager
.is() )
555 m_pUndoManager
->disposing();
556 m_pUndoManager
.clear();
557 // that's important, since the UndoManager implementation delegates its ref counting to ourself.
559 m_aControllers
.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject
* >( this )));
560 m_xCurrentController
.clear();
562 DisposeHelper::DisposeAndClear( m_xRangeHighlighter
);
564 if( m_xOldModelAgg
.is())
565 m_xOldModelAgg
->setDelegator( NULL
);
567 OSL_TRACE( "ChartModel: dispose() called" );
570 void SAL_CALL
ChartModel::addEventListener( const uno::Reference
< lang::XEventListener
> & xListener
)
571 throw(uno::RuntimeException
)
573 if( m_aLifeTimeManager
.impl_isDisposedOrClosed() )
574 return; //behave passive if already disposed or closed
576 m_aLifeTimeManager
.m_aListenerContainer
.addInterface( ::getCppuType((const uno::Reference
< lang::XEventListener
>*)0), xListener
);
579 void SAL_CALL
ChartModel::removeEventListener( const uno::Reference
< lang::XEventListener
> & xListener
)
580 throw(uno::RuntimeException
)
582 if( m_aLifeTimeManager
.impl_isDisposedOrClosed(false) )
583 return; //behave passive if already disposed or closed
585 m_aLifeTimeManager
.m_aListenerContainer
.removeInterface( ::getCppuType((const uno::Reference
< lang::XEventListener
>*)0), xListener
);
589 //-----------------------------------------------------------------
590 // util::XCloseBroadcaster (base of XCloseable)
591 //-----------------------------------------------------------------
592 void SAL_CALL
ChartModel::addCloseListener( const uno::Reference
< util::XCloseListener
> & xListener
)
593 throw(uno::RuntimeException
)
595 m_aLifeTimeManager
.g_addCloseListener( xListener
);
598 void SAL_CALL
ChartModel::removeCloseListener( const uno::Reference
< util::XCloseListener
> & xListener
)
599 throw(uno::RuntimeException
)
601 if( m_aLifeTimeManager
.impl_isDisposedOrClosed(false) )
602 return; //behave passive if already disposed or closed
604 m_aLifeTimeManager
.m_aListenerContainer
.removeInterface( ::getCppuType((const uno::Reference
< util::XCloseListener
>*)0), xListener
);
608 //-----------------------------------------------------------------
610 //-----------------------------------------------------------------
611 void SAL_CALL
ChartModel::close( sal_Bool bDeliverOwnership
)
612 throw( util::CloseVetoException
,
613 uno::RuntimeException
)
617 if( !m_aLifeTimeManager
.g_close_startTryClose( bDeliverOwnership
) )
619 //no mutex is acquired
621 // At the end of this method may we must dispose ourself ...
622 // and may nobody from outside hold a reference to us ...
623 // then it's a good idea to do that by ourself.
624 uno::Reference
< uno::XInterface
> xSelfHold( static_cast< ::cppu::OWeakObject
* >(this) );
626 //the listeners have had no veto
627 //check whether we self can close
629 util::CloseVetoException aVetoException
= util::CloseVetoException(
630 "the model itself could not be closed",
631 static_cast< ::cppu::OWeakObject
* >(this) );
633 if( m_aLifeTimeManager
.g_close_isNeedToCancelLongLastingCalls( bDeliverOwnership
, aVetoException
) )
635 ////you can empty this block, if you never start longlasting calls or
636 ////if your longlasting calls are per default not cancelable (check how you have constructed your LifeTimeManager)
638 sal_Bool bLongLastingCallsAreCanceled
= sal_False
;
641 //try to cancel running longlasting calls
644 catch (const uno::Exception
&)
647 //do not throw anything here!! (without endTryClose)
649 //if not successful canceled
650 if(!bLongLastingCallsAreCanceled
)
652 m_aLifeTimeManager
.g_close_endTryClose( bDeliverOwnership
, sal_True
);
653 throw aVetoException
;
658 m_aLifeTimeManager
.g_close_endTryClose_doClose();
660 // BM @todo: is it ok to call the listeners here?
661 impl_notifyCloseListeners();
664 //-----------------------------------------------------------------
665 // lang::XTypeProvider
666 //-----------------------------------------------------------------
667 uno::Sequence
< uno::Type
> SAL_CALL
ChartModel::getTypes()
668 throw (uno::RuntimeException
)
670 uno::Reference
< lang::XTypeProvider
> xAggTypeProvider
;
671 if( (m_xOldModelAgg
->queryAggregation( ::getCppuType( & xAggTypeProvider
)) >>= xAggTypeProvider
)
672 && xAggTypeProvider
.is())
674 uno::Sequence
< uno::Type
> aOwnTypes( impl::ChartModel_Base::getTypes());
675 uno::Sequence
< uno::Type
> aAggTypes( xAggTypeProvider
->getTypes());
676 uno::Sequence
< uno::Type
> aResult( aOwnTypes
.getLength() + aAggTypes
.getLength());
678 for( ;i
<aOwnTypes
.getLength(); ++i
)
679 aResult
[i
] = aOwnTypes
[i
];
680 for( sal_Int32 j
=0; i
<aResult
.getLength(); ++j
, ++i
)
681 aResult
[i
] = aAggTypes
[j
];
685 return impl::ChartModel_Base::getTypes();
688 //-----------------------------------------------------------------
689 // document::XDocumentPropertiesSupplier
690 //-----------------------------------------------------------------
691 uno::Reference
< document::XDocumentProperties
> SAL_CALL
692 ChartModel::getDocumentProperties() throw (uno::RuntimeException
)
694 ::osl::MutexGuard
aGuard( m_aModelMutex
);
695 if ( !m_xDocumentProperties
.is() )
697 m_xDocumentProperties
.set( document::DocumentProperties::create( ::comphelper::getProcessComponentContext() ) );
699 return m_xDocumentProperties
;
702 //-----------------------------------------------------------------
703 // document::XDocumentPropertiesSupplier
704 //-----------------------------------------------------------------
705 Reference
< document::XUndoManager
> SAL_CALL
ChartModel::getUndoManager( ) throw (RuntimeException
)
707 ::osl::MutexGuard
aGuard( m_aModelMutex
);
708 if ( !m_pUndoManager
.is() )
709 m_pUndoManager
.set( new UndoManager( *this, m_aModelMutex
) );
710 return m_pUndoManager
.get();
713 //-----------------------------------------------------------------
714 // chart2::XChartDocument
715 //-----------------------------------------------------------------
717 uno::Reference
< chart2::XDiagram
> SAL_CALL
ChartModel::getFirstDiagram()
718 throw (uno::RuntimeException
)
720 MutexGuard
aGuard( m_aModelMutex
);
724 void SAL_CALL
ChartModel::setFirstDiagram( const uno::Reference
< chart2::XDiagram
>& xDiagram
)
725 throw (uno::RuntimeException
)
727 Reference
< chart2::XDiagram
> xOldDiagram
;
728 Reference
< util::XModifyListener
> xListener
;
730 MutexGuard
aGuard( m_aModelMutex
);
731 if( xDiagram
== m_xDiagram
)
733 xOldDiagram
= m_xDiagram
;
734 m_xDiagram
= xDiagram
;
737 //don't keep the mutex locked while calling out
738 ModifyListenerHelper::removeListener( xOldDiagram
, xListener
);
739 ModifyListenerHelper::addListener( xDiagram
, xListener
);
740 setModified( sal_True
);
743 Reference
< chart2::data::XDataSource
> ChartModel::impl_createDefaultData()
745 Reference
< chart2::data::XDataSource
> xDataSource
;
746 if( hasInternalDataProvider() )
748 uno::Reference
< lang::XInitialization
> xIni(m_xInternalDataProvider
,uno::UNO_QUERY
);
751 //init internal dataprovider
753 uno::Sequence
< uno::Any
> aArgs(1);
754 beans::NamedValue
aParam( "CreateDefaultData" ,uno::makeAny(sal_True
) );
756 xIni
->initialize(aArgs
);
759 uno::Sequence
< beans::PropertyValue
> aArgs( 4 );
760 aArgs
[0] = beans::PropertyValue(
761 OUString( "CellRangeRepresentation" ), -1,
762 uno::makeAny( OUString("all") ), beans::PropertyState_DIRECT_VALUE
);
763 aArgs
[1] = beans::PropertyValue(
766 uno::makeAny( true ),
767 beans::PropertyState_DIRECT_VALUE
);
768 aArgs
[2] = beans::PropertyValue(
771 uno::makeAny( true ),
772 beans::PropertyState_DIRECT_VALUE
);
773 aArgs
[3] = beans::PropertyValue(
776 uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS
),
777 beans::PropertyState_DIRECT_VALUE
);
778 xDataSource
= m_xInternalDataProvider
->createDataSource( aArgs
);
784 void SAL_CALL
ChartModel::createInternalDataProvider( sal_Bool bCloneExistingData
)
785 throw (util::CloseVetoException
, uno::RuntimeException
)
787 // don't lock the mutex, because this call calls out to code that tries to
788 // lock the solar mutex. On the other hand, a paint locks the solar mutex
789 // and calls to the model lock the model's mutex => deadlock
790 // @todo: lock a separate mutex in the InternalData class
791 if( !hasInternalDataProvider() )
793 if( bCloneExistingData
)
794 m_xInternalDataProvider
= ChartModelHelper::createInternalDataProvider( this, true );
796 m_xInternalDataProvider
= ChartModelHelper::createInternalDataProvider( Reference
<XChartDocument
>(), true );
797 m_xDataProvider
.set( m_xInternalDataProvider
);
799 setModified( sal_True
);
802 sal_Bool SAL_CALL
ChartModel::hasInternalDataProvider()
803 throw (uno::RuntimeException
)
805 return m_xDataProvider
.is() && m_xInternalDataProvider
.is();
808 uno::Reference
< chart2::data::XDataProvider
> SAL_CALL
ChartModel::getDataProvider()
809 throw (uno::RuntimeException
)
811 MutexGuard
aGuard( m_aModelMutex
);
812 return m_xDataProvider
;
815 // ____ XDataReceiver ____
817 void SAL_CALL
ChartModel::attachDataProvider( const uno::Reference
< chart2::data::XDataProvider
>& xDataProvider
)
818 throw (uno::RuntimeException
)
821 MutexGuard
aGuard( m_aModelMutex
);
822 uno::Reference
< beans::XPropertySet
> xProp( xDataProvider
, uno::UNO_QUERY
);
827 sal_Bool bIncludeHiddenCells
= ChartModelHelper::isIncludeHiddenCells( Reference
< frame::XModel
>(this) );
828 xProp
->setPropertyValue("IncludeHiddenCells", uno::makeAny(bIncludeHiddenCells
));
830 catch (const beans::UnknownPropertyException
&)
835 m_xDataProvider
.set( xDataProvider
);
836 m_xInternalDataProvider
.clear();
838 //the numberformatter is kept independent of the data provider!
840 setModified( sal_True
);
843 void SAL_CALL
ChartModel::attachNumberFormatsSupplier( const uno::Reference
< util::XNumberFormatsSupplier
>& xNewSupplier
)
844 throw (uno::RuntimeException
)
847 MutexGuard
aGuard( m_aModelMutex
);
848 if( xNewSupplier
==m_xNumberFormatsSupplier
)
850 if( xNewSupplier
==m_xOwnNumberFormatsSupplier
)
852 if( m_xOwnNumberFormatsSupplier
.is() && xNewSupplier
.is() )
855 //merge missing numberformats from own to new formatter
857 else if( !xNewSupplier
.is() )
859 if( m_xNumberFormatsSupplier
.is() )
862 //merge missing numberformats from old numberformatter to own numberformatter
863 //create own numberformatter if necessary
867 m_xNumberFormatsSupplier
.set( xNewSupplier
);
868 m_xOwnNumberFormatsSupplier
.clear();
870 setModified( sal_True
);
873 void SAL_CALL
ChartModel::setArguments( const Sequence
< beans::PropertyValue
>& aArguments
)
874 throw (lang::IllegalArgumentException
,
875 uno::RuntimeException
)
878 MutexGuard
aGuard( m_aModelMutex
);
879 if( !m_xDataProvider
.is() )
885 Reference
< chart2::data::XDataSource
> xDataSource( m_xDataProvider
->createDataSource( aArguments
) );
886 if( xDataSource
.is() )
888 Reference
< chart2::XDiagram
> xDia( getFirstDiagram() );
891 Reference
< chart2::XChartTypeTemplate
> xTemplate( impl_createDefaultChartTypeTemplate() );
893 setFirstDiagram( xTemplate
->createDiagramByDataSource( xDataSource
, aArguments
) );
896 xDia
->setDiagramData( xDataSource
, aArguments
);
899 catch (const lang::IllegalArgumentException
&)
903 catch (const uno::Exception
& ex
)
905 ASSERT_EXCEPTION( ex
);
909 setModified( sal_True
);
912 Sequence
< OUString
> SAL_CALL
ChartModel::getUsedRangeRepresentations()
913 throw (uno::RuntimeException
)
915 return DataSourceHelper::getUsedDataRanges( Reference
< frame::XModel
>(this));
918 Reference
< chart2::data::XDataSource
> SAL_CALL
ChartModel::getUsedData()
919 throw (uno::RuntimeException
)
921 return DataSourceHelper::getUsedData( Reference
< chart2::XChartDocument
>(this));
924 Reference
< chart2::data::XRangeHighlighter
> SAL_CALL
ChartModel::getRangeHighlighter()
925 throw (uno::RuntimeException
)
927 if( ! m_xRangeHighlighter
.is())
929 uno::Reference
< view::XSelectionSupplier
> xSelSupp( this->getCurrentController(), uno::UNO_QUERY
);
931 m_xRangeHighlighter
.set( ChartModelHelper::createRangeHighlighter( xSelSupp
));
933 return m_xRangeHighlighter
;
936 Reference
< chart2::XChartTypeTemplate
> ChartModel::impl_createDefaultChartTypeTemplate()
938 Reference
< chart2::XChartTypeTemplate
> xTemplate
;
939 Reference
< lang::XMultiServiceFactory
> xFact( m_xChartTypeManager
, uno::UNO_QUERY
);
941 xTemplate
.set( xFact
->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY
);
945 void SAL_CALL
ChartModel::setChartTypeManager( const uno::Reference
< chart2::XChartTypeManager
>& xNewManager
)
946 throw (uno::RuntimeException
)
949 MutexGuard
aGuard( m_aModelMutex
);
950 m_xChartTypeManager
= xNewManager
;
952 setModified( sal_True
);
955 uno::Reference
< chart2::XChartTypeManager
> SAL_CALL
ChartModel::getChartTypeManager()
956 throw (uno::RuntimeException
)
958 MutexGuard
aGuard( m_aModelMutex
);
959 return m_xChartTypeManager
;
962 uno::Reference
< beans::XPropertySet
> SAL_CALL
ChartModel::getPageBackground()
963 throw (uno::RuntimeException
)
965 MutexGuard
aGuard( m_aModelMutex
);
966 return m_xPageBackground
;
970 uno::Reference
< chart2::XTitle
> SAL_CALL
ChartModel::getTitleObject()
971 throw (uno::RuntimeException
)
973 MutexGuard
aGuard( m_aModelMutex
);
977 void SAL_CALL
ChartModel::setTitleObject( const uno::Reference
< chart2::XTitle
>& xTitle
)
978 throw (uno::RuntimeException
)
981 MutexGuard
aGuard( m_aModelMutex
);
983 ModifyListenerHelper::removeListener( m_xTitle
, this );
985 ModifyListenerHelper::addListener( m_xTitle
, this );
987 setModified( sal_True
);
990 // ____ XInterface (for old API wrapper) ____
991 uno::Any SAL_CALL
ChartModel::queryInterface( const uno::Type
& aType
)
992 throw (uno::RuntimeException
)
994 uno::Any
aResult( impl::ChartModel_Base::queryInterface( aType
));
996 if( ! aResult
.hasValue())
998 // try old API wrapper
1001 if( m_xOldModelAgg
.is())
1002 aResult
= m_xOldModelAgg
->queryAggregation( aType
);
1004 catch (const uno::Exception
& ex
)
1006 ASSERT_EXCEPTION( ex
);
1013 // ____ XCloneable ____
1014 Reference
< util::XCloneable
> SAL_CALL
ChartModel::createClone()
1015 throw (uno::RuntimeException
)
1017 return Reference
< util::XCloneable
>( new ChartModel( *this ));
1020 // ____ XVisualObject ____
1021 void SAL_CALL
ChartModel::setVisualAreaSize( ::sal_Int64 nAspect
, const awt::Size
& aSize
)
1022 throw (lang::IllegalArgumentException
,
1023 embed::WrongStateException
,
1025 uno::RuntimeException
)
1027 if( nAspect
== embed::Aspects::MSOLE_CONTENT
)
1029 ControllerLockGuard
aLockGuard( this );
1031 (m_aVisualAreaSize
.Width
!= aSize
.Width
||
1032 m_aVisualAreaSize
.Height
!= aSize
.Height
);
1034 // #i12587# support for shapes in chart
1037 impl_adjustAdditionalShapesPositionAndSize( aSize
);
1040 m_aVisualAreaSize
= aSize
;
1042 setModified( sal_True
);
1046 OSL_FAIL( "setVisualAreaSize: Aspect not implemented yet.");
1050 awt::Size SAL_CALL
ChartModel::getVisualAreaSize( ::sal_Int64 nAspect
)
1051 throw (lang::IllegalArgumentException
,
1052 embed::WrongStateException
,
1054 uno::RuntimeException
)
1056 OSL_ENSURE( nAspect
== embed::Aspects::MSOLE_CONTENT
,
1057 "No aspects other than content are supported" );
1058 (void)(nAspect
); // avoid warning in non-debug builds
1059 // other possible aspects are MSOLE_THUMBNAIL, MSOLE_ICON and MSOLE_DOCPRINT
1061 return m_aVisualAreaSize
;
1064 embed::VisualRepresentation SAL_CALL
ChartModel::getPreferredVisualRepresentation( ::sal_Int64 nAspect
)
1065 throw (lang::IllegalArgumentException
,
1066 embed::WrongStateException
,
1068 uno::RuntimeException
)
1070 OSL_ENSURE( nAspect
== embed::Aspects::MSOLE_CONTENT
,
1071 "No aspects other than content are supported" );
1072 (void)(nAspect
); // avoid warning in non-debug builds
1074 embed::VisualRepresentation aResult
;
1078 Sequence
< sal_Int8
> aMetafile
;
1080 //get view from old api wrapper
1081 Reference
< datatransfer::XTransferable
> xTransferable(
1082 this->createInstance( CHART_VIEW_SERVICE_NAME
), uno::UNO_QUERY
);
1083 if( xTransferable
.is() )
1085 datatransfer::DataFlavor
aDataFlavor( lcl_aGDIMetaFileMIMEType
,
1087 ::getCppuType( (const uno::Sequence
< sal_Int8
>*) 0 ) );
1089 uno::Any
aData( xTransferable
->getTransferData( aDataFlavor
) );
1090 aData
>>= aMetafile
;
1093 aResult
.Flavor
.MimeType
= lcl_aGDIMetaFileMIMEType
;
1094 aResult
.Flavor
.DataType
= getCppuType( &aMetafile
);
1096 aResult
.Data
<<= aMetafile
;
1098 catch (const uno::Exception
& ex
)
1100 ASSERT_EXCEPTION( ex
);
1106 ::sal_Int32 SAL_CALL
ChartModel::getMapUnit( ::sal_Int64 nAspect
)
1107 throw (uno::Exception
,
1108 uno::RuntimeException
)
1110 OSL_ENSURE( nAspect
== embed::Aspects::MSOLE_CONTENT
,
1111 "No aspects other than content are supported" );
1112 (void)(nAspect
); // avoid warning in non-debug builds
1113 return embed::EmbedMapUnits::ONE_100TH_MM
;
1116 // ____ datatransfer::XTransferable ____
1117 uno::Any SAL_CALL
ChartModel::getTransferData( const datatransfer::DataFlavor
& aFlavor
)
1118 throw (datatransfer::UnsupportedFlavorException
,
1120 uno::RuntimeException
)
1123 if( this->isDataFlavorSupported( aFlavor
))
1127 //get view from old api wrapper
1128 Reference
< datatransfer::XTransferable
> xTransferable(
1129 this->createInstance( CHART_VIEW_SERVICE_NAME
), uno::UNO_QUERY
);
1130 if( xTransferable
.is() &&
1131 xTransferable
->isDataFlavorSupported( aFlavor
))
1133 aResult
= xTransferable
->getTransferData( aFlavor
);
1136 catch (const uno::Exception
& ex
)
1138 ASSERT_EXCEPTION( ex
);
1143 throw datatransfer::UnsupportedFlavorException(
1144 aFlavor
.MimeType
, static_cast< ::cppu::OWeakObject
* >( this ));
1150 Sequence
< datatransfer::DataFlavor
> SAL_CALL
ChartModel::getTransferDataFlavors()
1151 throw (uno::RuntimeException
)
1153 uno::Sequence
< datatransfer::DataFlavor
> aRet(1);
1155 aRet
[0] = datatransfer::DataFlavor( lcl_aGDIMetaFileMIMETypeHighContrast
,
1157 ::getCppuType( (const uno::Sequence
< sal_Int8
>*) NULL
) );
1162 ::sal_Bool SAL_CALL
ChartModel::isDataFlavorSupported( const datatransfer::DataFlavor
& aFlavor
)
1163 throw (uno::RuntimeException
)
1165 return aFlavor
.MimeType
.equals(lcl_aGDIMetaFileMIMETypeHighContrast
);
1175 SERVICE_GARDIENT_TABLE
,
1176 SERVICE_HATCH_TABLE
,
1177 SERVICE_BITMAP_TABLE
,
1178 SERVICE_TRANSP_GRADIENT_TABLE
,
1179 SERVICE_MARKER_TABLE
,
1180 SERVICE_NAMESPACE_MAP
1183 typedef ::std::map
< OUString
, enum eServiceType
> tServiceNameMap
;
1184 typedef ::comphelper::MakeMap
< OUString
, enum eServiceType
> tMakeServiceNameMap
;
1186 tServiceNameMap
& lcl_getStaticServiceNameMap()
1188 static tServiceNameMap
aServiceNameMap(
1190 ( "com.sun.star.drawing.DashTable", SERVICE_DASH_TABLE
)
1191 ( "com.sun.star.drawing.GradientTable", SERVICE_GARDIENT_TABLE
)
1192 ( "com.sun.star.drawing.HatchTable", SERVICE_HATCH_TABLE
)
1193 ( "com.sun.star.drawing.BitmapTable", SERVICE_BITMAP_TABLE
)
1194 ( "com.sun.star.drawing.TransparencyGradientTable", SERVICE_TRANSP_GRADIENT_TABLE
)
1195 ( "com.sun.star.drawing.MarkerTable", SERVICE_MARKER_TABLE
)
1196 ( "com.sun.star.xml.NamespaceMap", SERVICE_NAMESPACE_MAP
)
1198 return aServiceNameMap
;
1201 // ____ XMultiServiceFactory ____
1202 Reference
< uno::XInterface
> SAL_CALL
ChartModel::createInstance( const OUString
& rServiceSpecifier
)
1203 throw( uno::Exception
, uno::RuntimeException
)
1205 uno::Reference
< uno::XInterface
> xResult
;
1206 tServiceNameMap
& rMap
= lcl_getStaticServiceNameMap();
1208 tServiceNameMap::const_iterator
aIt( rMap
.find( rServiceSpecifier
));
1209 if( aIt
!= rMap
.end())
1211 switch( (*aIt
).second
)
1213 case SERVICE_DASH_TABLE
:
1214 case SERVICE_GARDIENT_TABLE
:
1215 case SERVICE_HATCH_TABLE
:
1216 case SERVICE_BITMAP_TABLE
:
1217 case SERVICE_TRANSP_GRADIENT_TABLE
:
1218 case SERVICE_MARKER_TABLE
:
1220 uno::Reference
< lang::XMultiServiceFactory
> xFact(
1221 this->createInstance( CHART_VIEW_SERVICE_NAME
), uno::UNO_QUERY
);
1224 return xFact
->createInstance( rServiceSpecifier
);
1228 case SERVICE_NAMESPACE_MAP
:
1229 return Reference
< uno::XInterface
>( m_xXMLNamespaceMap
);
1234 if( m_xOldModelAgg
.is() )
1236 Any aAny
= m_xOldModelAgg
->queryAggregation( ::getCppuType((const uno::Reference
< lang::XMultiServiceFactory
>*)0) );
1237 uno::Reference
< lang::XMultiServiceFactory
> xOldModelFactory
;
1238 if( (aAny
>>= xOldModelFactory
) && xOldModelFactory
.is() )
1240 return xOldModelFactory
->createInstance( rServiceSpecifier
);
1247 Reference
< uno::XInterface
> SAL_CALL
ChartModel::createInstanceWithArguments(
1248 const OUString
& rServiceSpecifier
, const Sequence
< Any
>& Arguments
)
1249 throw( uno::Exception
, uno::RuntimeException
)
1251 OSL_ENSURE( Arguments
.getLength(), "createInstanceWithArguments: Warning: Arguments are ignored" );
1252 (void)(Arguments
); // avoid warning in non-debug builds
1253 return createInstance( rServiceSpecifier
);
1256 Sequence
< OUString
> SAL_CALL
ChartModel::getAvailableServiceNames()
1257 throw( uno::RuntimeException
)
1259 uno::Sequence
< OUString
> aResult
;
1261 if( m_xOldModelAgg
.is())
1263 Any aAny
= m_xOldModelAgg
->queryAggregation( ::getCppuType((const uno::Reference
< lang::XMultiServiceFactory
>*)0) );
1264 uno::Reference
< lang::XMultiServiceFactory
> xOldModelFactory
;
1265 if( (aAny
>>= xOldModelFactory
) && xOldModelFactory
.is() )
1267 return xOldModelFactory
->getAvailableServiceNames();
1273 Reference
< util::XNumberFormatsSupplier
> ChartModel::impl_getNumberFormatsSupplier()
1275 if( !m_xNumberFormatsSupplier
.is() )
1277 if( !m_xOwnNumberFormatsSupplier
.is() )
1279 m_apSvNumberFormatter
.reset( new SvNumberFormatter( m_xContext
, LANGUAGE_SYSTEM
) );
1280 m_xOwnNumberFormatsSupplier
= new SvNumberFormatsSupplierObj( m_apSvNumberFormatter
.get() );
1281 //pOwnNumberFormatter->ChangeStandardPrec( 15 ); todo?
1283 m_xNumberFormatsSupplier
= m_xOwnNumberFormatsSupplier
;
1285 return m_xNumberFormatsSupplier
;
1288 // ____ XUnoTunnel ___
1289 ::sal_Int64 SAL_CALL
ChartModel::getSomething( const Sequence
< ::sal_Int8
>& aIdentifier
)
1290 throw( uno::RuntimeException
)
1292 if( aIdentifier
.getLength() == 16 && 0 == memcmp( SvNumberFormatsSupplierObj::getUnoTunnelId().getConstArray(),
1293 aIdentifier
.getConstArray(), 16 ) )
1295 Reference
< lang::XUnoTunnel
> xTunnel( impl_getNumberFormatsSupplier(), uno::UNO_QUERY
);
1297 return xTunnel
->getSomething( aIdentifier
);
1302 // ____ XNumberFormatsSupplier ____
1303 uno::Reference
< beans::XPropertySet
> SAL_CALL
ChartModel::getNumberFormatSettings()
1304 throw (uno::RuntimeException
)
1306 Reference
< util::XNumberFormatsSupplier
> xSupplier( impl_getNumberFormatsSupplier() );
1307 if( xSupplier
.is() )
1308 return xSupplier
->getNumberFormatSettings();
1309 return uno::Reference
< beans::XPropertySet
>();
1312 uno::Reference
< util::XNumberFormats
> SAL_CALL
ChartModel::getNumberFormats()
1313 throw (uno::RuntimeException
)
1315 Reference
< util::XNumberFormatsSupplier
> xSupplier( impl_getNumberFormatsSupplier() );
1316 if( xSupplier
.is() )
1317 return xSupplier
->getNumberFormats();
1318 return uno::Reference
< util::XNumberFormats
>();
1322 Reference
< uno::XInterface
> SAL_CALL
ChartModel::getParent()
1323 throw (uno::RuntimeException
)
1325 return Reference
< uno::XInterface
>(m_xParent
,uno::UNO_QUERY
);
1328 void SAL_CALL
ChartModel::setParent( const Reference
< uno::XInterface
>& Parent
)
1329 throw (lang::NoSupportException
,
1330 uno::RuntimeException
)
1332 if( Parent
!= m_xParent
)
1333 m_xParent
.set( Parent
, uno::UNO_QUERY
);
1336 // ____ XDataSource ____
1337 uno::Sequence
< Reference
< chart2::data::XLabeledDataSequence
> > SAL_CALL
ChartModel::getDataSequences()
1338 throw (uno::RuntimeException
)
1340 Reference
< chart2::data::XDataSource
> xSource(
1341 DataSourceHelper::getUsedData( uno::Reference
< frame::XModel
>(this) ) );
1343 return xSource
->getDataSequences();
1345 return uno::Sequence
< Reference
< chart2::data::XLabeledDataSequence
> >();
1349 OUString SAL_CALL
ChartModel::dump()
1350 throw (uno::RuntimeException
)
1352 uno::Reference
< qa::XDumper
> xDumper(
1353 this->createInstance( CHART_VIEW_SERVICE_NAME
), uno::UNO_QUERY
);
1355 return xDumper
->dump();
1360 } // namespace chart
1362 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */