diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-10-15 07:55:26 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-11-19 13:47:36 +0100 |
commit | 401f01caf5b357ac6c15b37a89c0a9aaeb46f4e4 (patch) | |
tree | 587823c8639fe4c5166ccd8a70b6a5335242677f /chart2/source/controller/chartapiwrapper | |
parent | cf90715b35b11286d800c0e1d57ce3a62303e883 (diff) |
use ChartModel instead of XModel in a few places
This allows us easier implementation of some advanced features. Mainly
the 4D chartting will now be able to work without several ugly layers of
UNO.
Change-Id: I74d07229eaef921c508f3bab8fae6d6075ad737a
Diffstat (limited to 'chart2/source/controller/chartapiwrapper')
7 files changed, 44 insertions, 27 deletions
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index 80132a8286ee..969f830f940e 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -29,6 +29,8 @@ #include "AxisHelper.hxx" #include "DiagramHelper.hxx" +#include "ChartModel.hxx" + using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -44,6 +46,7 @@ Chart2ModelContact::Chart2ModelContact( const Reference< uno::XComponentContext > & xContext ) : m_xContext( xContext ), m_xChartModel( 0 ), + mpModel( NULL ), m_xChartView(0) { } @@ -58,6 +61,7 @@ void Chart2ModelContact::setModel( const ::com::sun::star::uno::Reference< { this->clear(); m_xChartModel = xChartModel; + mpModel = dynamic_cast<ChartModel*>(xChartModel.get()); uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartModel, uno::UNO_QUERY ); if( xTableFactory.is() ) { @@ -78,6 +82,7 @@ void Chart2ModelContact::clear() { m_xChartModel = uno::WeakReference< frame::XModel >(0); m_xChartView.clear(); + mpModel = NULL; } Reference< frame::XModel > Chart2ModelContact::getChartModel() const @@ -85,6 +90,11 @@ Reference< frame::XModel > Chart2ModelContact::getChartModel() const return Reference< frame::XModel >( m_xChartModel.get(), uno::UNO_QUERY ); } +ChartModel* Chart2ModelContact::getModel() const +{ + return mpModel; +} + Reference< chart2::XChartDocument > Chart2ModelContact::getChart2Document() const { return Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY ); @@ -175,7 +185,7 @@ awt::Size Chart2ModelContact::GetPageSize() const awt::Rectangle Chart2ModelContact::SubstractAxisTitleSizes( const awt::Rectangle& rPositionRect ) { awt::Rectangle aRect = ExplicitValueProvider::substractAxisTitleSizes( - m_xChartModel, getChartView(), rPositionRect ); + *mpModel, getChartView(), rPositionRect ); return aRect; } @@ -185,7 +195,7 @@ awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingTitle() const //add axis title sizes to the diagram size aRect = ExplicitValueProvider::addAxisTitleSizes( - m_xChartModel, getChartView(), aRect ); + *mpModel, getChartView(), aRect ); return aRect; } @@ -228,8 +238,8 @@ awt::Size Chart2ModelContact::GetLegendSize() const ExplicitValueProvider* pProvider( getExplicitValueProvider() ); if( pProvider ) { - uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( m_xChartModel ) ); - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) ); + uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *mpModel ) ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, *mpModel ) ); aSize = ToSize( pProvider->getRectangleOfObject( aCID ) ); } return aSize; @@ -241,8 +251,8 @@ awt::Point Chart2ModelContact::GetLegendPosition() const ExplicitValueProvider* pProvider( getExplicitValueProvider() ); if( pProvider ) { - uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( m_xChartModel ) ); - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) ); + uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *mpModel ) ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, *mpModel ) ); aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) ); } return aPoint; diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index 992cf384ffa1..c73da310cda4 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -38,6 +38,7 @@ namespace chart { class ExplicitValueProvider; +class ChartModel; namespace wrapper { @@ -57,6 +58,8 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getChartModel() const; + ChartModel* getModel() const; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > getChart2Document() const; ::com::sun::star::uno::Reference< @@ -145,6 +148,8 @@ private: //member ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xChartModel; + ChartModel* mpModel; + mutable ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > m_xChartView; diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 0ca43ba6305f..35afa7c20d37 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -530,7 +530,7 @@ void SAL_CALL ChartDataWrapper::setAnyColumnDescriptions( const Sequence< Sequen void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException) { Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); - ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + ControllerLockGuardUNO aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); lcl_DateCategoriesOperator aOperator( rDates ); applyData( aOperator ); DiagramHelper::switchToDateCategories( xChartDoc ); @@ -682,7 +682,7 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) ); // /-- locked controllers - ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + ControllerLockGuardUNO aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); // create and attach new data source switchToInternalDataProvider(); diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index fc2d7c2cc64d..de42006c6273 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -31,6 +31,8 @@ #include "chartview/DrawModelWrapper.hxx" #include "Chart2ModelContact.hxx" +#include "ChartModel.hxx" + #include "DiagramHelper.hxx" #include "DataSourceHelper.hxx" #include "ChartModelHelper.hxx" @@ -501,7 +503,7 @@ void WrappedHasLegendProperty::setPropertyValue( const Any& rOuterValue, const R try { - Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext,bNewValue )); + Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_spChart2ModelContact->getModel(), m_spChart2ModelContact->m_xContext,bNewValue )); if(xLegend.is()) { Reference< beans::XPropertySet > xLegendProp( xLegend, uno::UNO_QUERY_THROW ); @@ -525,7 +527,7 @@ Any WrappedHasLegendProperty::getPropertyValue( const Reference< beans::XPropert try { Reference< beans::XPropertySet > xLegendProp( - LegendHelper::getLegend( m_spChart2ModelContact->getChartModel() ), uno::UNO_QUERY ); + LegendHelper::getLegend( *m_spChart2ModelContact->getModel() ), uno::UNO_QUERY ); if( xLegendProp.is()) aRet = xLegendProp->getPropertyValue("Show"); else @@ -722,7 +724,7 @@ Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getTitle() { if( !m_xTitle.is() ) { - ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY )); + ControllerLockGuardUNO aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY )); m_xTitle = new TitleWrapper( TitleHelper::MAIN_TITLE, m_spChart2ModelContact ); } return m_xTitle; @@ -733,7 +735,7 @@ Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getSubTitle() { if( !m_xSubTitle.is() ) { - ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY )); + ControllerLockGuardUNO aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY )); m_xSubTitle = new TitleWrapper( TitleHelper::SUB_TITLE, m_spChart2ModelContact ); } return m_xSubTitle; @@ -833,7 +835,7 @@ void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& x return; // /-- locked controllers - ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY )); + ControllerLockGuardUNO aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY )); m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact, xNewData ) ); // \-- locked controllers } @@ -1022,7 +1024,7 @@ void ChartDocumentWrapper::impl_resetAddIn() void ChartDocumentWrapper::setBaseDiagram( const OUString& rBaseDiagram ) { - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); m_aBaseDiagram = rBaseDiagram; uno::Reference< XDiagram > xDiagram( ChartDocumentWrapper::createInstance( rBaseDiagram ), uno::UNO_QUERY ); @@ -1045,7 +1047,7 @@ void ChartDocumentWrapper::setAddIn( const Reference< util::XRefreshable >& xAdd if( m_xAddIn == xAddIn ) return; - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); impl_resetAddIn(); m_xAddIn = xAddIn; // initialize AddIn with this as chart document @@ -1291,7 +1293,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { // locked controllers Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY ); - ControllerLockGuard aCtrlLockGuard( xModel ); + ControllerLockGuardUNO aCtrlLockGuard( xModel ); Reference< chart2::XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel ); ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); Reference< lang::XMultiServiceFactory > xTemplateManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); @@ -1307,7 +1309,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( else { // locked controllers - ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + ControllerLockGuardUNO aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); xDia.set( xTemplate->createDiagramByDataSource( uno::Reference< chart2::data::XDataSource >(), uno::Sequence< beans::PropertyValue >())); diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 9836d2929589..c54a2dc56752 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -705,7 +705,7 @@ awt::Point SAL_CALL DiagramWrapper::getPosition() void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException) { - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); if( xProp.is() ) { @@ -738,7 +738,7 @@ void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException) { - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); if( xProp.is() ) { @@ -772,7 +772,7 @@ OUString SAL_CALL DiagramWrapper::getShapeType() void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning() throw (uno::RuntimeException) { - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) { @@ -794,7 +794,7 @@ void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning() throw (uno::Runti } void SAL_CALL DiagramWrapper::setDiagramPositionExcludingAxes( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) { - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect ); uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) @@ -822,7 +822,7 @@ awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionExcludingAxes( } void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxes( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) { - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect ); uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) @@ -834,7 +834,7 @@ awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( } void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) { - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); awt::Rectangle aRect( m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) ); DiagramWrapper::setDiagramPositionIncludingAxes( aRect ); } @@ -1646,7 +1646,7 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con try { // locked controllers - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY ); xProp->setPropertyValue( "NumberOfLines", uno::makeAny(nNewValue) ); xTemplate->changeDiagram( xDiagram ); @@ -1966,7 +1966,7 @@ void WrappedIncludeHiddenCellsProperty::setPropertyValue( const Any& rOuterValue if( ! (rOuterValue >>= bNewValue) ) throw lang::IllegalArgumentException( "Property Dim3D requires boolean value", 0, 0 ); - ChartModelHelper::setIncludeHiddenCells( bNewValue, m_spChart2ModelContact->getChartModel() ); + ChartModelHelper::setIncludeHiddenCells( bNewValue, *m_spChart2ModelContact->getModel() ); } // ____ XDiagramProvider ____ diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx index ecbe98db34bc..9ca382f98f1b 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -204,7 +204,7 @@ TitleWrapper::TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType, m_aEventListenerContainer( m_aMutex ), m_eTitleType(eTitleType) { - ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY )); + ControllerLockGuardUNO aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY )); if( !getTitleObject().is() ) //#i83831# create an empty title at the model, thus references to properties can be mapped mapped correctly TitleHelper::createTitle( m_eTitleType, OUString(), m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext ); } diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx index 181d3a3b3820..8cdf63006ca8 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx @@ -98,7 +98,7 @@ void WrappedStockProperty::setPropertyValue( const ::com::sun::star::uno::Any& r try { // locked controllers - ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); xTemplate->changeDiagram( xDiagram ); } catch( const uno::Exception & ex ) |