diff options
Diffstat (limited to 'chart2/source/model/main/ChartModel_Persistence.cxx')
-rw-r--r-- | chart2/source/model/main/ChartModel_Persistence.cxx | 108 |
1 files changed, 46 insertions, 62 deletions
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index 458d23b6283a..4fb17e9f1001 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -27,8 +27,10 @@ #include <DataSourceHelper.hxx> #include <AxisHelper.hxx> #include <ThreeDHelper.hxx> -#include <DiagramHelper.hxx> +#include <Diagram.hxx> #include <BaseCoordinateSystem.hxx> +#include <Legend.hxx> +#include <XMLFilter.hxx> #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/container/XNameAccess.hpp> @@ -44,8 +46,6 @@ #include <com/sun/star/io/IOException.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/io/TempFile.hpp> -#include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/ucb/CommandFailedException.hpp> #include <com/sun/star/ucb/ContentCreationException.hpp> @@ -53,12 +53,14 @@ #include <ucbhelper/content.hxx> #include <unotools/ucbstreamhelper.hxx> +#include <unotools/tempfile.hxx> +#include <utility> #include <vcl/cvtgrf.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/storagehelper.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <sfx2/objsh.hxx> @@ -74,8 +76,8 @@ namespace { struct lcl_PropNameEquals { - explicit lcl_PropNameEquals( const OUString & rStrToCompareWith ) : - m_aStr( rStrToCompareWith ) + explicit lcl_PropNameEquals( OUString aStrToCompareWith ) : + m_aStr(std::move( aStrToCompareWith )) {} bool operator() ( const beans::PropertyValue & rProp ) { @@ -198,10 +200,7 @@ Reference< document::XFilter > ChartModel::impl_createFilter( if( ! xFilter.is()) { SAL_WARN("chart2", "No FilterName passed in MediaDescriptor" ); - xFilter.set( - m_xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.comp.chart2.XMLFilter", m_xContext ), - uno::UNO_QUERY_THROW ); + xFilter = new XMLFilter(m_xContext); } return xFilter; @@ -302,8 +301,7 @@ void SAL_CALL ChartModel::storeToURL( { if( m_xContext.is() && aMediaDescriptorHelper.ISSET_OutputStream ) { - Reference< io::XStream > xStream( - io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW ); + rtl::Reference< utl::TempFileFastService > xStream = new utl::TempFileFastService; Reference< io::XInputStream > xInputStream( xStream->getInputStream()); Reference< embed::XStorage > xStorage( @@ -312,8 +310,7 @@ void SAL_CALL ChartModel::storeToURL( { impl_store( aReducedMediaDescriptor, xStorage ); - Reference< io::XSeekable > xSeekable( xStream, uno::UNO_QUERY_THROW ); - xSeekable->seek( 0 ); + xStream->seek( 0 ); ::comphelper::OStorageHelper::CopyInputToOutput( xInputStream, aMediaDescriptorHelper.OutputStream ); } } @@ -387,7 +384,7 @@ void ChartModel::insertDefaultChart() try { // create default chart - Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() ); + rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() ); if( xTemplate.is()) { try @@ -402,7 +399,7 @@ void ChartModel::insertDefaultChart() beans::PropertyState_DIRECT_VALUE ) }; } - Reference< chart2::XDiagram > xDiagram( xTemplate->createDiagramByDataSource( xDataSource, aParam ) ); + rtl::Reference< Diagram > xDiagram( xTemplate->createDiagramByDataSource2( xDataSource, aParam ) ); setFirstDiagram( xDiagram ); @@ -412,30 +409,23 @@ void ChartModel::insertDefaultChart() AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) ); // create and attach legend - Reference< chart2::XLegend > xLegend( - m_xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.chart2.Legend", m_xContext ), uno::UNO_QUERY_THROW ); - Reference< beans::XPropertySet > xLegendProperties( xLegend, uno::UNO_QUERY ); - if( xLegendProperties.is() ) - { - xLegendProperties->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE )); - xLegendProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE )); - xLegendProperties->setPropertyValue( "LineColor", uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30 - xLegendProperties->setPropertyValue( "FillColor", uno::Any( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10 + rtl::Reference< Legend > xLegend = new Legend(); + xLegend->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE )); + xLegend->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE )); + xLegend->setPropertyValue( "LineColor", uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30 + xLegend->setPropertyValue( "FillColor", uno::Any( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10 - if( bIsRTL ) - xLegendProperties->setPropertyValue( "AnchorPosition", uno::Any( chart2::LegendPosition_LINE_START )); - } + if( bIsRTL ) + xLegend->setPropertyValue( "AnchorPosition", uno::Any( chart2::LegendPosition_LINE_START )); if(xDiagram.is()) xDiagram->setLegend( xLegend ); // set simple 3D look - Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY ); - if( xDiagramProperties.is() ) + if( xDiagram.is() ) { - xDiagramProperties->setPropertyValue( "RightAngledAxes", uno::Any( true )); - xDiagramProperties->setPropertyValue( "D3DScenePerspective", uno::Any( drawing::ProjectionMode_PARALLEL )); - ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme::ThreeDLookScheme_Realistic ); + xDiagram->setPropertyValue( "RightAngledAxes", uno::Any( true )); + xDiagram->setPropertyValue( "D3DScenePerspective", uno::Any( drawing::ProjectionMode_PARALLEL )); + xDiagram->setScheme( ThreeDLookScheme::ThreeDLookScheme_Realistic ); } //set some new 'defaults' for wall and floor @@ -645,16 +635,11 @@ void ChartModel::impl_notifyModifiedListeners() //always notify the view first! ChartViewHelper::setViewToDirtyState( this ); - ::comphelper::OInterfaceContainerHelper2* pIC = m_aLifeTimeManager.m_aListenerContainer - .getContainer( cppu::UnoType<util::XModifyListener>::get()); - if( pIC ) + std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex); + if( m_aLifeTimeManager.m_aModifyListeners.getLength(aGuard) ) { lang::EventObject aEvent( static_cast< lang::XComponent*>(this) ); - ::comphelper::OInterfaceIteratorHelper2 aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - static_cast< util::XModifyListener* >( aIt.next() )->modified( aEvent ); - } + m_aLifeTimeManager.m_aModifyListeners.notifyEach(aGuard, &util::XModifyListener::modified, aEvent); } } @@ -683,7 +668,8 @@ void SAL_CALL ChartModel::setModified( sal_Bool bModified ) if( m_nControllerLockCount > 0 ) { - m_bUpdateNotificationsPending = true; + if (bModified) + m_bUpdateNotificationsPending = true; // Maybe !bModified should reset it? return;//don't call listeners if controllers are locked } aGuard.clear(); @@ -699,8 +685,8 @@ void SAL_CALL ChartModel::addModifyListener( if( m_aLifeTimeManager.impl_isDisposedOrClosed() ) return; //behave passive if already disposed or closed - m_aLifeTimeManager.m_aListenerContainer.addInterface( - cppu::UnoType<util::XModifyListener>::get(), xListener ); + std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aModifyListeners.addInterface( aGuard, xListener ); } void SAL_CALL ChartModel::removeModifyListener( @@ -709,8 +695,8 @@ void SAL_CALL ChartModel::removeModifyListener( if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) ) return; //behave passive if already disposed or closed - m_aLifeTimeManager.m_aListenerContainer.removeInterface( - cppu::UnoType<util::XModifyListener>::get(), xListener ); + std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aModifyListeners.removeInterface( aGuard, xListener ); } // util::XModifyListener @@ -728,9 +714,9 @@ void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject) Reference<chart2::data::XDataSource> xDataSource(xDataProvider->createDataSource(aArguments)); rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = getTypeManager(); - Reference<chart2::XDiagram> xDiagram(getFirstDiagram()); + rtl::Reference<Diagram> xDiagram(getFirstChartDiagram()); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram(xDiagram, xChartTypeManager); + Diagram::tTemplateWithServiceName aTemplateAndService = xDiagram->getTemplate(xChartTypeManager); aTemplateAndService.xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments); } catch (const uno::Exception &) @@ -779,16 +765,14 @@ Reference< embed::XStorage > SAL_CALL ChartModel::getDocumentStorage() void ChartModel::impl_notifyStorageChangeListeners() { - ::comphelper::OInterfaceContainerHelper2* pIC = m_aLifeTimeManager.m_aListenerContainer - .getContainer( cppu::UnoType<document::XStorageChangeListener>::get()); - if( pIC ) + std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex); + if( m_aLifeTimeManager.m_aStorageChangeListeners.getLength(aGuard) ) { - ::comphelper::OInterfaceIteratorHelper2 aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - static_cast< document::XStorageChangeListener* >( aIt.next() ) - ->notifyStorageChange( static_cast< ::cppu::OWeakObject* >( this ), m_xStorage ); - } + m_aLifeTimeManager.m_aStorageChangeListeners.forEach(aGuard, + [this](const uno::Reference<document::XStorageChangeListener>& l) + { + l->notifyStorageChange( static_cast< ::cppu::OWeakObject* >( this ), m_xStorage ); + }); } } @@ -797,8 +781,8 @@ void SAL_CALL ChartModel::addStorageChangeListener( const Reference< document::X if( m_aLifeTimeManager.impl_isDisposedOrClosed() ) return; //behave passive if already disposed or closed - m_aLifeTimeManager.m_aListenerContainer.addInterface( - cppu::UnoType<document::XStorageChangeListener>::get(), xListener ); + std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aStorageChangeListeners.addInterface( aGuard, xListener ); } void SAL_CALL ChartModel::removeStorageChangeListener( const Reference< document::XStorageChangeListener >& xListener ) @@ -806,8 +790,8 @@ void SAL_CALL ChartModel::removeStorageChangeListener( const Reference< document if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) ) return; //behave passive if already disposed or closed - m_aLifeTimeManager.m_aListenerContainer.removeInterface( - cppu::UnoType<document::XStorageChangeListener>::get(), xListener ); + std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aStorageChangeListeners.removeInterface(aGuard, xListener ); } } // namespace chart |