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 "MediaDescriptorHelper.hxx"
23 #include "ChartViewHelper.hxx"
24 #include "ChartModelHelper.hxx"
25 #include "AxisHelper.hxx"
26 #include "ThreeDHelper.hxx"
28 #include <com/sun/star/chart2/LegendPosition.hpp>
29 #include <com/sun/star/container/XNameAccess.hpp>
30 #include <com/sun/star/document/XExporter.hpp>
31 #include <com/sun/star/document/XImporter.hpp>
32 #include <com/sun/star/document/XFilter.hpp>
33 #include <com/sun/star/drawing/FillStyle.hpp>
34 #include <com/sun/star/drawing/LineStyle.hpp>
35 #include <com/sun/star/drawing/ProjectionMode.hpp>
36 #include <com/sun/star/embed/ElementModes.hpp>
37 #include <com/sun/star/embed/XStorage.hpp>
38 #include <com/sun/star/embed/StorageFactory.hpp>
39 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
40 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
41 #include <com/sun/star/uno/XComponentContext.hpp>
42 #include <com/sun/star/io/TempFile.hpp>
43 #include <com/sun/star/io/XSeekable.hpp>
44 #include <com/sun/star/ucb/CommandFailedException.hpp>
46 #include <ucbhelper/content.hxx>
47 #include <unotools/ucbstreamhelper.hxx>
48 #include <vcl/cvtgrf.hxx>
49 #include <comphelper/processfactory.hxx>
50 #include <comphelper/storagehelper.hxx>
51 #include <vcl/svapp.hxx>
52 #include <vcl/settings.hxx>
57 using namespace ::com::sun::star
;
59 using ::com::sun::star::uno::Reference
;
60 using ::com::sun::star::uno::Sequence
;
61 using ::osl::MutexGuard
;
65 struct lcl_PropNameEquals
: public ::std::unary_function
< beans::PropertyValue
, bool >
67 lcl_PropNameEquals( const OUString
& rStrToCompareWith
) :
68 m_aStr( rStrToCompareWith
)
70 bool operator() ( const beans::PropertyValue
& rProp
)
72 return rProp
.Name
.equals( m_aStr
);
78 template< typename T
>
80 const Sequence
< beans::PropertyValue
> & rMediaDescriptor
,
81 const OUString
& rPropName
)
84 if( rMediaDescriptor
.getLength())
86 OUString
aPropName( rPropName
);
87 const beans::PropertyValue
* pIt
= rMediaDescriptor
.getConstArray();
88 const beans::PropertyValue
* pEndIt
= pIt
+ + rMediaDescriptor
.getLength();
89 pIt
= ::std::find_if( pIt
, pEndIt
, lcl_PropNameEquals( aPropName
));
91 (*pIt
).Value
>>= aResult
;
96 void lcl_addStorageToMediaDescriptor(
97 Sequence
< beans::PropertyValue
> & rOutMD
,
98 const Reference
< embed::XStorage
> & xStorage
)
100 rOutMD
.realloc( rOutMD
.getLength() + 1 );
101 rOutMD
[rOutMD
.getLength() - 1] = beans::PropertyValue(
102 "Storage", -1, uno::makeAny( xStorage
), beans::PropertyState_DIRECT_VALUE
);
105 Reference
< embed::XStorage
> lcl_createStorage(
106 const OUString
& rURL
,
107 const Reference
< uno::XComponentContext
> & xContext
,
108 const Sequence
< beans::PropertyValue
> & rMediaDescriptor
)
110 // create new storage
111 Reference
< embed::XStorage
> xStorage
;
117 Reference
< io::XStream
> xStream(
118 ::ucbhelper::Content( rURL
, Reference
< ::com::sun::star::ucb::XCommandEnvironment
>(), comphelper::getProcessComponentContext()).openStream(),
121 Reference
< lang::XSingleServiceFactory
> xStorageFact( embed::StorageFactory::create( xContext
) );
122 Sequence
< uno::Any
> aStorageArgs( 3 );
123 aStorageArgs
[0] <<= xStream
;
124 aStorageArgs
[1] <<= embed::ElementModes::READWRITE
;
125 aStorageArgs
[2] <<= rMediaDescriptor
;
127 xStorageFact
->createInstanceWithArguments( aStorageArgs
), uno::UNO_QUERY_THROW
);
128 OSL_ENSURE( xStorage
.is(), "No Storage" );
130 catch(const css::ucb::ContentCreationException
& rEx
)
132 ASSERT_EXCEPTION( rEx
);
134 catch(const css::ucb::CommandFailedException
& rEx
)
136 ASSERT_EXCEPTION( rEx
);
142 } // anonymous namespace
147 Reference
< document::XFilter
> ChartModel::impl_createFilter(
148 const Sequence
< beans::PropertyValue
> & rMediaDescriptor
)
150 Reference
< document::XFilter
> xFilter
;
152 // find FilterName in MediaDescriptor
153 OUString
aFilterName(
154 lcl_getProperty
< OUString
>( rMediaDescriptor
, "FilterName" ) );
156 // if FilterName was found, get Filter from factory
157 if( !aFilterName
.isEmpty() )
161 Reference
< container::XNameAccess
> xFilterFact(
162 m_xContext
->getServiceManager()->createInstanceWithContext(
163 "com.sun.star.document.FilterFactory", m_xContext
),
164 uno::UNO_QUERY_THROW
);
165 uno::Any
aFilterProps( xFilterFact
->getByName( aFilterName
));
166 Sequence
< beans::PropertyValue
> aProps
;
168 if( aFilterProps
.hasValue() &&
169 (aFilterProps
>>= aProps
))
171 OUString
aFilterServiceName(
172 lcl_getProperty
< OUString
>( aProps
, "FilterService" ) );
174 if( !aFilterServiceName
.isEmpty())
177 m_xContext
->getServiceManager()->createInstanceWithContext(
178 aFilterServiceName
, m_xContext
), uno::UNO_QUERY_THROW
);
179 SAL_INFO("chart2", "Filter found for service " << aFilterServiceName
);
183 catch( const uno::Exception
& ex
)
185 ASSERT_EXCEPTION( ex
);
187 OSL_ENSURE( xFilter
.is(), "Filter not found via factory" );
190 // fall-back: create XML-Filter
193 OSL_TRACE( "No FilterName passed in MediaDescriptor" );
195 m_xContext
->getServiceManager()->createInstanceWithContext(
196 "com.sun.star.comp.chart2.XMLFilter", m_xContext
),
197 uno::UNO_QUERY_THROW
);
205 void SAL_CALL
ChartModel::storeSelf( const Sequence
< beans::PropertyValue
>& rMediaDescriptor
)
206 throw (lang::IllegalArgumentException
,
208 uno::RuntimeException
, std::exception
)
210 // only some parameters are allowed (see also SfxBaseModel)
211 // "VersionComment", "Author", "InteractionHandler", "StatusIndicator"
212 // However, they are ignored here. They would become interesting when
213 // charts support a standalone format again.
214 impl_store( rMediaDescriptor
, m_xStorage
);
217 // frame::XStorable (base of XStorable2)
218 sal_Bool SAL_CALL
ChartModel::hasLocation()
219 throw(uno::RuntimeException
, std::exception
)
222 return !m_aResource
.isEmpty();
225 OUString SAL_CALL
ChartModel::getLocation()
226 throw(uno::RuntimeException
, std::exception
)
228 return impl_g_getLocation();
231 sal_Bool SAL_CALL
ChartModel::isReadonly()
232 throw(uno::RuntimeException
, std::exception
)
238 void SAL_CALL
ChartModel::store()
239 throw(io::IOException
,
240 uno::RuntimeException
, std::exception
)
242 apphelper::LifeTimeGuard
aGuard(m_aLifeTimeManager
);
243 if(!aGuard
.startApiCall(true)) //start LongLastingCall
244 return; //behave passive if already disposed or closed or throw exception @todo?
246 OUString aLocation
= m_aResource
;
248 if( aLocation
.isEmpty() )
249 throw io::IOException( "no location specified", static_cast< ::cppu::OWeakObject
* >(this));
250 //@todo check whether aLocation is something like private:factory...
252 throw io::IOException( "document is read only", static_cast< ::cppu::OWeakObject
* >(this));
257 impl_store( m_aMediaDescriptor
, m_xStorage
);
260 void SAL_CALL
ChartModel::storeAsURL(
261 const OUString
& rURL
,
262 const uno::Sequence
< beans::PropertyValue
>& rMediaDescriptor
)
263 throw(io::IOException
, uno::RuntimeException
, std::exception
)
265 apphelper::LifeTimeGuard
aGuard(m_aLifeTimeManager
);
266 if(!aGuard
.startApiCall(true)) //start LongLastingCall
267 return; //behave passive if already disposed or closed or throw exception @todo?
269 apphelper::MediaDescriptorHelper
aMediaDescriptorHelper(rMediaDescriptor
);
270 uno::Sequence
< beans::PropertyValue
> aReducedMediaDescriptor(
271 aMediaDescriptorHelper
.getReducedForModel() );
276 // create new storage
277 Reference
< embed::XStorage
> xStorage( lcl_createStorage( rURL
, m_xContext
, aReducedMediaDescriptor
));
281 impl_store( aReducedMediaDescriptor
, xStorage
);
282 attachResource( rURL
, aReducedMediaDescriptor
);
286 void SAL_CALL
ChartModel::storeToURL(
287 const OUString
& rURL
,
288 const uno::Sequence
< beans::PropertyValue
>& rMediaDescriptor
)
289 throw(io::IOException
,
290 uno::RuntimeException
, std::exception
)
292 apphelper::LifeTimeGuard
aGuard(m_aLifeTimeManager
);
293 if(!aGuard
.startApiCall(true)) //start LongLastingCall
294 return; //behave passive if already disposed or closed or throw exception @todo?
295 //do not change the internal state of the document here
299 apphelper::MediaDescriptorHelper
aMediaDescriptorHelper(rMediaDescriptor
);
300 uno::Sequence
< beans::PropertyValue
> aReducedMediaDescriptor(
301 aMediaDescriptorHelper
.getReducedForModel() );
303 if ( rURL
== "private:stream" )
307 if( m_xContext
.is() && aMediaDescriptorHelper
.ISSET_OutputStream
)
309 Reference
< io::XStream
> xStream(
310 io::TempFile::create(m_xContext
), uno::UNO_QUERY_THROW
);
311 Reference
< io::XInputStream
> xInputStream( xStream
->getInputStream());
313 Reference
< embed::XStorage
> xStorage(
314 ::comphelper::OStorageHelper::GetStorageFromStream( xStream
, embed::ElementModes::READWRITE
, m_xContext
));
317 impl_store( aReducedMediaDescriptor
, xStorage
);
319 Reference
< io::XSeekable
> xSeekable( xStream
, uno::UNO_QUERY_THROW
);
320 xSeekable
->seek( 0 );
321 ::comphelper::OStorageHelper::CopyInputToOutput( xInputStream
, aMediaDescriptorHelper
.OutputStream
);
325 catch( const uno::Exception
& ex
)
327 ASSERT_EXCEPTION( ex
);
332 // create new storage
333 Reference
< embed::XStorage
> xStorage( lcl_createStorage( rURL
, m_xContext
, aReducedMediaDescriptor
));
336 impl_store( aReducedMediaDescriptor
, xStorage
);
340 void ChartModel::impl_store(
341 const Sequence
< beans::PropertyValue
>& rMediaDescriptor
,
342 const Reference
< embed::XStorage
> & xStorage
)
344 Reference
< document::XFilter
> xFilter( impl_createFilter( rMediaDescriptor
));
345 if( xFilter
.is() && xStorage
.is())
347 Sequence
< beans::PropertyValue
> aMD( rMediaDescriptor
);
348 lcl_addStorageToMediaDescriptor( aMD
, xStorage
);
351 Reference
< document::XExporter
> xExporter( xFilter
, uno::UNO_QUERY_THROW
);
352 xExporter
->setSourceDocument( Reference
< lang::XComponent
>( this ));
353 xFilter
->filter( aMD
);
355 catch( const uno::Exception
& ex
)
357 ASSERT_EXCEPTION( ex
);
362 OSL_FAIL( "No filter" );
365 setModified( sal_False
);
368 //for data change notification during chart is not loaded:
369 //notify parent data provider after saving thus the parent document can store
370 //the ranges for which a load and update of the chart will be necessary
371 Reference
< beans::XPropertySet
> xPropSet( m_xParent
, uno::UNO_QUERY
);
372 if ( !hasInternalDataProvider() && xPropSet
.is() )
374 apphelper::MediaDescriptorHelper
aMDHelper(rMediaDescriptor
);
377 xPropSet
->setPropertyValue(
379 uno::makeAny( aMDHelper
.HierarchicalDocumentName
) );
381 catch ( const uno::Exception
& )
387 void ChartModel::insertDefaultChart()
390 createInternalDataProvider( sal_False
);
393 // create default chart
394 Reference
< chart2::XChartTypeTemplate
> xTemplate( impl_createDefaultChartTypeTemplate() );
399 Reference
< chart2::data::XDataSource
> xDataSource( impl_createDefaultData() );
400 Sequence
< beans::PropertyValue
> aParam
;
402 bool bSupportsCategories
= xTemplate
->supportsCategories();
403 if( bSupportsCategories
)
406 aParam
[0] = beans::PropertyValue( "HasCategories", -1, uno::makeAny( true ),
407 beans::PropertyState_DIRECT_VALUE
);
410 Reference
< chart2::XDiagram
> xDiagram( xTemplate
->createDiagramByDataSource( xDataSource
, aParam
) );
412 setFirstDiagram( xDiagram
);
414 bool bIsRTL
= AllSettings::GetMathLayoutRTL();
415 //reverse x axis for rtl charts
417 AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram
, 0 ) );
419 // create and attach legend
420 Reference
< chart2::XLegend
> xLegend(
421 m_xContext
->getServiceManager()->createInstanceWithContext(
422 "com.sun.star.chart2.Legend", m_xContext
), uno::UNO_QUERY_THROW
);
423 Reference
< beans::XPropertySet
> xLegendProperties( xLegend
, uno::UNO_QUERY
);
424 if( xLegendProperties
.is() )
426 xLegendProperties
->setPropertyValue( "FillStyle", uno::makeAny( drawing::FillStyle_NONE
));
427 xLegendProperties
->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_NONE
));
428 xLegendProperties
->setPropertyValue( "LineColor", uno::makeAny( static_cast< sal_Int32
>( 0xb3b3b3 ) )); // gray30
429 xLegendProperties
->setPropertyValue( "FillColor", uno::makeAny( static_cast< sal_Int32
>( 0xe6e6e6 ) ) ); // gray10
432 xLegendProperties
->setPropertyValue( "AnchorPosition", uno::makeAny( chart2::LegendPosition_LINE_START
));
435 xDiagram
->setLegend( xLegend
);
437 // set simple 3D look
438 Reference
< beans::XPropertySet
> xDiagramProperties( xDiagram
, uno::UNO_QUERY
);
439 if( xDiagramProperties
.is() )
441 xDiagramProperties
->setPropertyValue( "RightAngledAxes", uno::makeAny( sal_True
));
442 xDiagramProperties
->setPropertyValue( "D3DScenePerspective", uno::makeAny( drawing::ProjectionMode_PARALLEL
));
443 ThreeDHelper::setScheme( xDiagram
, ThreeDLookScheme_Realistic
);
446 //set some new 'defaults' for wall and floor
449 Reference
< beans::XPropertySet
> xWall( xDiagram
->getWall() );
452 xWall
->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_SOLID
) );
453 xWall
->setPropertyValue( "FillStyle", uno::makeAny( drawing::FillStyle_NONE
) );
454 xWall
->setPropertyValue( "LineColor", uno::makeAny( static_cast< sal_Int32
>( 0xb3b3b3 ) ) ); // gray30
455 xWall
->setPropertyValue( "FillColor", uno::makeAny( static_cast< sal_Int32
>( 0xe6e6e6 ) ) ); // gray10
457 Reference
< beans::XPropertySet
> xFloor( xDiagram
->getFloor() );
460 xFloor
->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_NONE
) );
461 xFloor
->setPropertyValue( "FillStyle", uno::makeAny( drawing::FillStyle_SOLID
) );
462 xFloor
->setPropertyValue( "LineColor", uno::makeAny( static_cast< sal_Int32
>( 0xb3b3b3 ) ) ); // gray30
463 xFloor
->setPropertyValue( "FillColor", uno::makeAny( static_cast< sal_Int32
>( 0xcccccc ) ) ); // gray20
468 catch( const uno::Exception
& ex
)
470 ASSERT_EXCEPTION( ex
);
473 ChartModelHelper::setIncludeHiddenCells( false, *this );
475 catch( const uno::Exception
& ex
)
477 ASSERT_EXCEPTION( ex
);
479 setModified( sal_False
);
484 void SAL_CALL
ChartModel::initNew()
485 throw (frame::DoubleInitializationException
,
488 uno::RuntimeException
, std::exception
)
492 void SAL_CALL
ChartModel::load(
493 const Sequence
< beans::PropertyValue
>& rMediaDescriptor
)
494 throw (frame::DoubleInitializationException
,
497 uno::RuntimeException
, std::exception
)
499 Reference
< embed::XStorage
> xStorage
;
503 apphelper::MediaDescriptorHelper
aMDHelper( rMediaDescriptor
);
504 if( aMDHelper
.ISSET_Storage
)
506 xStorage
= aMDHelper
.Storage
;
508 else if( aMDHelper
.ISSET_Stream
||
509 aMDHelper
.ISSET_InputStream
)
511 if( aMDHelper
.ISSET_FilterName
&&
512 (aMDHelper
.FilterName
== "StarChart 5.0" ||
513 aMDHelper
.FilterName
== "StarChart 4.0" ||
514 aMDHelper
.FilterName
== "StarChart 3.0" ))
516 attachResource( aMDHelper
.URL
, rMediaDescriptor
);
517 impl_load( rMediaDescriptor
, 0 ); // cannot create a storage from binary streams, but I do not need the storage here anyhow
522 Reference
< lang::XSingleServiceFactory
> xStorageFact( embed::StorageFactory::create(m_xContext
) );
524 if( aMDHelper
.ISSET_Stream
)
526 // convert XStream to XStorage via the storage factory
527 Sequence
< uno::Any
> aStorageArgs( 2 );
528 aStorageArgs
[0] <<= aMDHelper
.Stream
;
529 // todo: check if stream is read-only
530 aStorageArgs
[1] <<= (embed::ElementModes::READ
); //WRITE | embed::ElementModes::NOCREATE);
532 xStorage
.set( xStorageFact
->createInstanceWithArguments( aStorageArgs
),
533 uno::UNO_QUERY_THROW
);
537 OSL_ASSERT( aMDHelper
.ISSET_InputStream
);
538 // convert XInputStream to XStorage via the storage factory
539 Sequence
< uno::Any
> aStorageArgs( 2 );
540 aStorageArgs
[0] <<= aMDHelper
.InputStream
;
541 aStorageArgs
[1] <<= (embed::ElementModes::READ
);
543 xStorage
.set( xStorageFact
->createInstanceWithArguments( aStorageArgs
),
544 uno::UNO_QUERY_THROW
);
548 if( aMDHelper
.ISSET_URL
)
549 aURL
= aMDHelper
.URL
;
551 catch( const uno::Exception
& ex
)
553 ASSERT_EXCEPTION( ex
);
558 attachResource( aURL
, rMediaDescriptor
);
559 impl_load( rMediaDescriptor
, xStorage
);
563 void ChartModel::impl_load(
564 const Sequence
< beans::PropertyValue
>& rMediaDescriptor
,
565 const Reference
< embed::XStorage
>& xStorage
)
568 MutexGuard
aGuard( m_aModelMutex
);
572 Reference
< document::XFilter
> xFilter( impl_createFilter( rMediaDescriptor
));
576 Reference
< document::XImporter
> xImporter( xFilter
, uno::UNO_QUERY_THROW
);
577 xImporter
->setTargetDocument( this );
578 Sequence
< beans::PropertyValue
> aMD( rMediaDescriptor
);
579 lcl_addStorageToMediaDescriptor( aMD
, xStorage
);
581 xFilter
->filter( aMD
);
586 OSL_FAIL( "loadFromStorage cannot create filter" );
590 impl_loadGraphics( xStorage
);
592 setModified( sal_False
);
594 // switchToStorage without notifying listeners (which shouldn't exist at
595 // this time, anyway)
596 m_xStorage
= xStorage
;
599 MutexGuard
aGuard( m_aModelMutex
);
604 void ChartModel::impl_loadGraphics(
605 const Reference
< embed::XStorage
>& xStorage
)
609 const Reference
< embed::XStorage
>& xGraphicsStorage(
610 xStorage
->openStorageElement( "Pictures",
611 embed::ElementModes::READ
) );
613 if( xGraphicsStorage
.is() )
615 const uno::Sequence
< OUString
> aElementNames(
616 xGraphicsStorage
->getElementNames() );
618 for( int i
= 0; i
< aElementNames
.getLength(); ++i
)
620 if( xGraphicsStorage
->isStreamElement( aElementNames
[ i
] ) )
622 uno::Reference
< io::XStream
> xElementStream(
623 xGraphicsStorage
->openStreamElement(
625 embed::ElementModes::READ
) );
627 if( xElementStream
.is() )
629 boost::scoped_ptr
< SvStream
> apIStm(
630 ::utl::UcbStreamHelper::CreateStream(
631 xElementStream
, true ) );
637 if( !GraphicConverter::Import(
641 m_aGraphicObjectVector
.push_back( aGraphic
);
649 catch ( const uno::Exception
& )
655 void SAL_CALL
ChartModel::impl_notifyModifiedListeners()
656 throw( uno::RuntimeException
)
659 MutexGuard
aGuard( m_aModelMutex
);
660 m_bUpdateNotificationsPending
= false;
663 //always notify the view first!
664 ChartViewHelper::setViewToDirtyState( this );
666 ::cppu::OInterfaceContainerHelper
* pIC
= m_aLifeTimeManager
.m_aListenerContainer
667 .getContainer( cppu::UnoType
<util::XModifyListener
>::get());
670 lang::EventObject
aEvent( static_cast< lang::XComponent
*>(this) );
671 ::cppu::OInterfaceIteratorHelper
aIt( *pIC
);
672 while( aIt
.hasMoreElements() )
674 uno::Reference
< util::XModifyListener
> xListener( aIt
.next(), uno::UNO_QUERY
);
676 xListener
->modified( aEvent
);
681 sal_Bool SAL_CALL
ChartModel::isModified()
682 throw(uno::RuntimeException
, std::exception
)
688 void SAL_CALL
ChartModel::setModified( sal_Bool bModified
)
689 throw(beans::PropertyVetoException
,
690 uno::RuntimeException
, std::exception
)
692 apphelper::LifeTimeGuard
aGuard(m_aLifeTimeManager
);
693 if(!aGuard
.startApiCall())//@todo ? is this a long lasting call??
694 return; //behave passive if already disposed or closed or throw exception @todo?
695 m_bModified
= bModified
;
697 if( m_nControllerLockCount
> 0 )
699 m_bUpdateNotificationsPending
= true;
700 return;//don't call listeners if controllers are locked
705 impl_notifyModifiedListeners();
708 // util::XModifyBroadcaster (base of XModifiable)
709 void SAL_CALL
ChartModel::addModifyListener(
710 const uno::Reference
< util::XModifyListener
>& xListener
)
711 throw(uno::RuntimeException
, std::exception
)
713 if( m_aLifeTimeManager
.impl_isDisposedOrClosed() )
714 return; //behave passive if already disposed or closed
716 m_aLifeTimeManager
.m_aListenerContainer
.addInterface(
717 cppu::UnoType
<util::XModifyListener
>::get(), xListener
);
720 void SAL_CALL
ChartModel::removeModifyListener(
721 const uno::Reference
< util::XModifyListener
>& xListener
)
722 throw(uno::RuntimeException
, std::exception
)
724 if( m_aLifeTimeManager
.impl_isDisposedOrClosed(false) )
725 return; //behave passive if already disposed or closed
727 m_aLifeTimeManager
.m_aListenerContainer
.removeInterface(
728 cppu::UnoType
<util::XModifyListener
>::get(), xListener
);
731 // util::XModifyListener
732 void SAL_CALL
ChartModel::modified( const lang::EventObject
& )
733 throw (uno::RuntimeException
, std::exception
)
736 setModified( sal_True
);
739 // lang::XEventListener (base of util::XModifyListener)
740 void SAL_CALL
ChartModel::disposing( const lang::EventObject
& )
741 throw (uno::RuntimeException
, std::exception
)
743 // child was disposed -- should not happen from outside
746 // document::XStorageBasedDocument
747 void SAL_CALL
ChartModel::loadFromStorage(
748 const Reference
< embed::XStorage
>& xStorage
,
749 const Sequence
< beans::PropertyValue
>& rMediaDescriptor
)
750 throw (lang::IllegalArgumentException
,
751 frame::DoubleInitializationException
,
754 uno::RuntimeException
, std::exception
)
756 attachResource( OUString(), rMediaDescriptor
);
757 impl_load( rMediaDescriptor
, xStorage
);
760 void SAL_CALL
ChartModel::storeToStorage(
761 const Reference
< embed::XStorage
>& xStorage
,
762 const Sequence
< beans::PropertyValue
>& rMediaDescriptor
)
763 throw (lang::IllegalArgumentException
,
766 uno::RuntimeException
, std::exception
)
768 impl_store( rMediaDescriptor
, xStorage
);
771 void SAL_CALL
ChartModel::switchToStorage( const Reference
< embed::XStorage
>& xStorage
)
772 throw (lang::IllegalArgumentException
,
775 uno::RuntimeException
, std::exception
)
777 m_xStorage
= xStorage
;
778 impl_notifyStorageChangeListeners();
781 Reference
< embed::XStorage
> SAL_CALL
ChartModel::getDocumentStorage()
782 throw (io::IOException
,
784 uno::RuntimeException
, std::exception
)
789 void SAL_CALL
ChartModel::impl_notifyStorageChangeListeners()
790 throw( uno::RuntimeException
)
792 ::cppu::OInterfaceContainerHelper
* pIC
= m_aLifeTimeManager
.m_aListenerContainer
793 .getContainer( cppu::UnoType
<document::XStorageChangeListener
>::get());
796 ::cppu::OInterfaceIteratorHelper
aIt( *pIC
);
797 while( aIt
.hasMoreElements() )
799 uno::Reference
< document::XStorageChangeListener
> xListener( aIt
.next(), uno::UNO_QUERY
);
801 xListener
->notifyStorageChange( static_cast< ::cppu::OWeakObject
* >( this ), m_xStorage
);
806 void SAL_CALL
ChartModel::addStorageChangeListener( const Reference
< document::XStorageChangeListener
>& xListener
)
807 throw (uno::RuntimeException
, std::exception
)
809 if( m_aLifeTimeManager
.impl_isDisposedOrClosed() )
810 return; //behave passive if already disposed or closed
812 m_aLifeTimeManager
.m_aListenerContainer
.addInterface(
813 cppu::UnoType
<document::XStorageChangeListener
>::get(), xListener
);
816 void SAL_CALL
ChartModel::removeStorageChangeListener( const Reference
< document::XStorageChangeListener
>& xListener
)
817 throw (uno::RuntimeException
, std::exception
)
819 if( m_aLifeTimeManager
.impl_isDisposedOrClosed(false) )
820 return; //behave passive if already disposed or closed
822 m_aLifeTimeManager
.m_aListenerContainer
.removeInterface(
823 cppu::UnoType
<document::XStorageChangeListener
>::get(), xListener
);
828 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */