summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-01-19 14:07:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-19 17:09:21 +0100
commit4683eaa6f92db03bd0a6ecd401ded51131db7ae6 (patch)
tree273021d33674a9267f1c1f3164391518be036b93
parent93133585b5b52e38defc3162eeb1e7704dceafcb (diff)
use more concrete types in chart2, ChartTypeTemplate
and return data using a little struct rather than std::pair, to make the call sites read a little better. Change-Id: Ieb6fc24e053f50823789167ed0112aa04a083725 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128613 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx4
-rw-r--r--chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx23
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx15
-rw-r--r--chart2/source/controller/dialogs/ChartTypeDialogController.cxx15
-rw-r--r--chart2/source/controller/dialogs/DataBrowserModel.cxx5
-rw-r--r--chart2/source/controller/dialogs/DialogModel.cxx3
-rw-r--r--chart2/source/controller/dialogs/DialogModel.hxx4
-rw-r--r--chart2/source/controller/dialogs/dlg_CreationWizard.cxx1
-rw-r--r--chart2/source/controller/dialogs/dlg_DataSource.cxx9
-rw-r--r--chart2/source/controller/dialogs/tp_ChartType.cxx11
-rw-r--r--chart2/source/controller/dialogs/tp_ChartType.hxx2
-rw-r--r--chart2/source/controller/dialogs/tp_DataSource.cxx1
-rw-r--r--chart2/source/controller/dialogs/tp_RangeChooser.cxx3
-rw-r--r--chart2/source/controller/dialogs/tp_RangeChooser.hxx4
-rw-r--r--chart2/source/controller/sidebar/ChartTypePanel.cxx18
-rw-r--r--chart2/source/controller/sidebar/ChartTypePanel.hxx3
-rw-r--r--chart2/source/inc/ChartTypeDialogController.hxx9
-rw-r--r--chart2/source/inc/ChartTypeTemplateProvider.hxx11
-rw-r--r--chart2/source/inc/DiagramHelper.hxx9
-rw-r--r--chart2/source/model/main/ChartModel_Persistence.cxx4
-rw-r--r--chart2/source/model/main/Diagram.cxx5
-rw-r--r--chart2/source/tools/DiagramHelper.cxx9
22 files changed, 93 insertions, 75 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index c3245ea30a2f..bc5557b61a17 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -1193,8 +1193,8 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
rtl::Reference< ::chart::ChartTypeManager > xTemplateManager = xChartDoc->getTypeManager();
DiagramHelper::tTemplateWithServiceName aTemplateWithService(
DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
- if( aTemplateWithService.first.is())
- aTemplateWithService.first->resetStyles( xDiagram );//#i109371#
+ if( aTemplateWithService.xChartTypeTemplate.is())
+ aTemplateWithService.xChartTypeTemplate->resetStyles( xDiagram );//#i109371#
xTemplate->changeDiagram( xDiagram );
if( AllSettings::GetMathLayoutRTL() )
AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index c977301a78ac..d9deba9857d4 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -44,6 +44,7 @@
#include <comphelper/sequence.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
@@ -605,7 +606,7 @@ OUString SAL_CALL DiagramWrapper::getDiagramType()
DiagramHelper::tTemplateWithServiceName aTemplateAndService =
DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
- aRet = lcl_getDiagramType( aTemplateAndService.second );
+ aRet = lcl_getDiagramType( aTemplateAndService.sServiceName );
}
if( aRet.isEmpty())
@@ -1467,11 +1468,11 @@ bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any& rInnerValue ) con
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager();
DiagramHelper::tTemplateWithServiceName aTemplateAndService =
DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
- if( aTemplateAndService.second == "com.sun.star.chart2.template.ColumnWithLine" )
+ if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" )
{
try
{
- uno::Reference< beans::XPropertySet > xProp( aTemplateAndService.first, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(aTemplateAndService.xChartTypeTemplate.get()), uno::UNO_QUERY );
xProp->getPropertyValue( m_aOuterName ) >>= nNumberOfLines;
bHasDetectableInnerValue = true;
}
@@ -1505,16 +1506,16 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con
DiagramHelper::tTemplateWithServiceName aTemplateAndService =
DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
- uno::Reference< chart2::XChartTypeTemplate > xTemplate;
- if( aTemplateAndService.second == "com.sun.star.chart2.template.ColumnWithLine" )
+ rtl::Reference< ChartTypeTemplate > xTemplate;
+ if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" )
{
if( nNewValue != 0 )
{
- xTemplate.set( aTemplateAndService.first );
+ xTemplate = aTemplateAndService.xChartTypeTemplate;
try
{
sal_Int32 nOldValue = 0;
- uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY );
xProp->getPropertyValue( m_aOuterName ) >>= nOldValue;
if( nOldValue == nNewValue )
return;
@@ -1526,14 +1527,14 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con
}
else
{
- xTemplate.set( xChartTypeManager->createInstance("com.sun.star.chart2.template.Column"), uno::UNO_QUERY );
+ xTemplate = xChartTypeManager->createTemplate("com.sun.star.chart2.template.Column");
}
}
- else if( aTemplateAndService.second == "com.sun.star.chart2.template.Column" )
+ else if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.Column" )
{
if( nNewValue == 0 )
return;
- xTemplate.set( xChartTypeManager->createInstance( "com.sun.star.chart2.template.ColumnWithLine" ), uno::UNO_QUERY );
+ xTemplate = xChartTypeManager->createTemplate( "com.sun.star.chart2.template.ColumnWithLine" );
}
if(!xTemplate.is())
@@ -1543,7 +1544,7 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con
{
// locked controllers
ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() );
- uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY );
xProp->setPropertyValue( "NumberOfLines", uno::Any(nNewValue) );
xTemplate->changeDiagram( xDiagram );
}
diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
index 9074ec92a6c4..3a8068ec984a 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <tools/diagnose_ex.h>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
@@ -87,7 +88,7 @@ void WrappedStockProperty::setPropertyValue( const css::uno::Any& rOuterValue, c
DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
uno::Reference< chart2::XChartTypeTemplate > xTemplate =
- getNewTemplate( bNewValue, aTemplateAndService.second, xChartTypeManager );
+ getNewTemplate( bNewValue, aTemplateAndService.sServiceName, xChartTypeManager );
if(!xTemplate.is())
return;
@@ -142,10 +143,10 @@ css::uno::Any WrappedVolumeProperty::getPropertyValue( const css::uno::Reference
DiagramHelper::tTemplateWithServiceName aTemplateAndService =
DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
- if( aTemplateAndService.second == "com.sun.star.chart2.template.StockVolumeLowHighClose"
- || aTemplateAndService.second == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
+ if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeLowHighClose"
+ || aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
m_aOuterValue <<= true;
- else if( !aTemplateAndService.second.isEmpty() || !m_aOuterValue.hasValue() )
+ else if( !aTemplateAndService.sServiceName.isEmpty() || !m_aOuterValue.hasValue() )
m_aOuterValue <<= false;
}
else if(!m_aOuterValue.hasValue())
@@ -211,10 +212,10 @@ css::uno::Any WrappedUpDownProperty::getPropertyValue( const css::uno::Reference
DiagramHelper::tTemplateWithServiceName aTemplateAndService =
DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
- if( aTemplateAndService.second == "com.sun.star.chart2.template.StockOpenLowHighClose"
- || aTemplateAndService.second == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
+ if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockOpenLowHighClose"
+ || aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
m_aOuterValue <<= true;
- else if( !aTemplateAndService.second.isEmpty() || !m_aOuterValue.hasValue() )
+ else if( !aTemplateAndService.sServiceName.isEmpty() || !m_aOuterValue.hasValue() )
m_aOuterValue <<= false;
}
else if(!m_aOuterValue.hasValue())
diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
index 3bfc11cb2bd9..4e73b52bd2b7 100644
--- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
+++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
@@ -19,6 +19,7 @@
#include <ChartTypeDialogController.hxx>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <ResId.hxx>
#include <strings.hrc>
#include <bitmaps.hlst>
@@ -252,19 +253,19 @@ OUString ChartTypeDialogController::getServiceNameForParameter( const ChartTypeP
}
return OUString();
}
-uno::Reference< XChartTypeTemplate > ChartTypeDialogController::getCurrentTemplate(
+rtl::Reference< ChartTypeTemplate > ChartTypeDialogController::getCurrentTemplate(
const ChartTypeParameter& rParameter
- , const uno::Reference< lang::XMultiServiceFactory >& xTemplateManager ) const
+ , const rtl::Reference< ChartTypeManager >& xTemplateManager ) const
{
- uno::Reference< XChartTypeTemplate > xTemplate;
+ rtl::Reference< ChartTypeTemplate > xTemplate;
OUString aServiceName( getServiceNameForParameter( rParameter ) );
if(!aServiceName.isEmpty())
{
- xTemplate.set( xTemplateManager->createInstance( aServiceName ), uno::UNO_QUERY );
+ xTemplate = xTemplateManager->createTemplate( aServiceName );
if(xTemplate.is())
{
- uno::Reference< beans::XPropertySet > xTemplateProps( xTemplate, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xTemplateProps( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY );
if(xTemplateProps.is())
{
try
@@ -315,8 +316,8 @@ void ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParame
rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xChartModel );
DiagramHelper::tTemplateWithServiceName aTemplateWithService(
DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
- if( aTemplateWithService.first.is())
- aTemplateWithService.first->resetStyles( xDiagram );
+ if( aTemplateWithService.xChartTypeTemplate.is())
+ aTemplateWithService.xChartTypeTemplate->resetStyles( xDiagram );
xTemplate->changeDiagram( xDiagram );
if( AllSettings::GetMathLayoutRTL() )
AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index e3687df5d1dc..f11d2cf856da 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -27,6 +27,7 @@
#include <StatisticsHelper.hxx>
#include <ChartTypeHelper.hxx>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <chartview/ExplicitValueProvider.hxx>
#include <ExplicitCategoriesProvider.hxx>
@@ -772,8 +773,8 @@ void DataBrowserModel::updateFromModel()
rtl::Reference< ::chart::ChartTypeManager > xTemplateManager = dynamic_cast<::chart::ChartTypeManager*>( m_xChartDocument->getChartTypeManager().get() );
DiagramHelper::tTemplateWithServiceName aTemplateAndService =
DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager );
- if( aTemplateAndService.first.is())
- m_apDialogModel->setTemplate( aTemplateAndService.first );
+ if( aTemplateAndService.xChartTypeTemplate.is())
+ m_apDialogModel->setTemplate( aTemplateAndService.xChartTypeTemplate );
sal_Int32 nHeaderStart = 0;
sal_Int32 nHeaderEnd = 0;
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx
index 9c735a489b5e..efb2244c98c9 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -26,6 +26,7 @@
#include <ResId.hxx>
#include <ControllerLockGuard.hxx>
#include <ChartTypeHelper.hxx>
+#include <ChartTypeTemplate.hxx>
#include <ThreeDHelper.hxx>
#include <ChartModel.hxx>
@@ -430,7 +431,7 @@ DialogModel::~DialogModel()
}
void DialogModel::setTemplate(
- const Reference< XChartTypeTemplate > & xTemplate )
+ const rtl::Reference< ChartTypeTemplate > & xTemplate )
{
m_xTemplate = xTemplate;
}
diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx
index 99ce73949cd0..be7f78a59e78 100644
--- a/chart2/source/controller/dialogs/DialogModel.hxx
+++ b/chart2/source/controller/dialogs/DialogModel.hxx
@@ -20,6 +20,7 @@
#include <TimerTriggeredControllerLock.hxx>
#include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
#include <map>
#include <memory>
@@ -48,6 +49,7 @@ namespace chart
{
class RangeSelectionHelper;
+class ChartTypeTemplate;
struct DialogModelTimeBasedInfo
{
@@ -76,7 +78,7 @@ public:
tRolesWithRanges;
void setTemplate(
- const css::uno::Reference< css::chart2::XChartTypeTemplate > & xTemplate );
+ const rtl::Reference< ::chart::ChartTypeTemplate > & xTemplate );
std::shared_ptr< RangeSelectionHelper > const &
getRangeSelectionHelper() const;
diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
index e35dfb8a166e..66701c4b8ab6 100644
--- a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
+++ b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
@@ -28,6 +28,7 @@
#include "tp_Wizard_TitlesAndObjects.hxx"
#include "tp_DataSource.hxx"
#include <ChartTypeTemplateProvider.hxx>
+#include <ChartTypeTemplate.hxx>
#include "DialogModel.hxx"
using namespace css;
diff --git a/chart2/source/controller/dialogs/dlg_DataSource.cxx b/chart2/source/controller/dialogs/dlg_DataSource.cxx
index 224e16261046..2f375ae1be5b 100644
--- a/chart2/source/controller/dialogs/dlg_DataSource.cxx
+++ b/chart2/source/controller/dialogs/dlg_DataSource.cxx
@@ -23,6 +23,7 @@
#include <dlg_DataSource.hxx>
#include <ChartTypeTemplateProvider.hxx>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <DiagramHelper.hxx>
#include "DialogModel.hxx"
@@ -47,10 +48,10 @@ public:
const Reference< chart2::XChartDocument > & xDoc );
// ____ ChartTypeTemplateProvider ____
- virtual Reference< chart2::XChartTypeTemplate > getCurrentTemplate() const override;
+ virtual rtl::Reference< ::chart::ChartTypeTemplate > getCurrentTemplate() const override;
private:
- Reference< chart2::XChartTypeTemplate > m_xTemplate;
+ rtl::Reference< ::chart::ChartTypeTemplate > m_xTemplate;
};
}
@@ -68,11 +69,11 @@ DocumentChartTypeTemplateProvider::DocumentChartTypeTemplateProvider(
DiagramHelper::getTemplateForDiagram(
xDia,
dynamic_cast<::chart::ChartTypeManager*>(xDoc->getChartTypeManager().get()) ));
- m_xTemplate.set( aResult.first );
+ m_xTemplate = aResult.xChartTypeTemplate;
}
}
-Reference< chart2::XChartTypeTemplate > DocumentChartTypeTemplateProvider::getCurrentTemplate() const
+rtl::Reference< ::chart::ChartTypeTemplate > DocumentChartTypeTemplateProvider::getCurrentTemplate() const
{
return m_xTemplate;
}
diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx
index fb03e1151f57..bc381e4514bc 100644
--- a/chart2/source/controller/dialogs/tp_ChartType.cxx
+++ b/chart2/source/controller/dialogs/tp_ChartType.cxx
@@ -23,6 +23,7 @@
#include <ResId.hxx>
#include <ChartModelHelper.hxx>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <DiagramHelper.hxx>
#include <Diagram.hxx>
#include <unonames.hxx>
@@ -260,7 +261,7 @@ void ChartTypeTabPage::selectMainType()
}
fillAllControls( aParameter );
- uno::Reference< beans::XPropertySet > xTemplateProps( getCurrentTemplate(), uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xTemplateProps( static_cast<cppu::OWeakObject*>(getCurrentTemplate().get()), uno::UNO_QUERY );
m_pCurrentMainType->fillExtraControls(m_xChartModel,xTemplateProps);
}
@@ -306,7 +307,7 @@ void ChartTypeTabPage::initializePage()
rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
DiagramHelper::tTemplateWithServiceName aTemplate =
DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager );
- OUString aServiceName( aTemplate.second );
+ OUString aServiceName( aTemplate.sServiceName );
bool bFound = false;
@@ -319,7 +320,7 @@ void ChartTypeTabPage::initializePage()
m_xMainTypeList->select(nM);
showAllControls(*elem);
- uno::Reference< beans::XPropertySet > xTemplateProps( aTemplate.first, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xTemplateProps( static_cast<cppu::OWeakObject*>(aTemplate.xChartTypeTemplate.get()), uno::UNO_QUERY );
ChartTypeParameter aParameter = elem->getChartTypeParameterForService( aServiceName, xTemplateProps );
m_pCurrentMainType = getSelectedMainType();
@@ -363,13 +364,13 @@ bool ChartTypeTabPage::commitPage( ::vcl::WizardTypes::CommitPageReason /*eReaso
return true; // return false if this page should not be left
}
-uno::Reference< XChartTypeTemplate > ChartTypeTabPage::getCurrentTemplate() const
+rtl::Reference< ChartTypeTemplate > ChartTypeTabPage::getCurrentTemplate() const
{
if( m_pCurrentMainType && m_xChartModel.is() )
{
ChartTypeParameter aParameter( getCurrentParamter() );
m_pCurrentMainType->adjustParameterToSubType( aParameter );
- uno::Reference< lang::XMultiServiceFactory > xTemplateManager( m_xChartModel->getChartTypeManager(), uno::UNO_QUERY );
+ rtl::Reference< ChartTypeManager > xTemplateManager = dynamic_cast<ChartTypeManager*>(m_xChartModel->getChartTypeManager().get());
return m_pCurrentMainType->getCurrentTemplate( aParameter, xTemplateManager );
}
return nullptr;
diff --git a/chart2/source/controller/dialogs/tp_ChartType.hxx b/chart2/source/controller/dialogs/tp_ChartType.hxx
index e7f8e1980bd8..7982a473f489 100644
--- a/chart2/source/controller/dialogs/tp_ChartType.hxx
+++ b/chart2/source/controller/dialogs/tp_ChartType.hxx
@@ -52,7 +52,7 @@ public:
virtual void initializePage() override;
virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason eReason ) override;
- virtual css::uno::Reference< css::chart2::XChartTypeTemplate > getCurrentTemplate() const override;
+ virtual rtl::Reference< ::chart::ChartTypeTemplate > getCurrentTemplate() const override;
private:
ChartTypeDialogController* getSelectedMainType();
diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx
index bcd48c2590df..c22e169d520d 100644
--- a/chart2/source/controller/dialogs/tp_DataSource.cxx
+++ b/chart2/source/controller/dialogs/tp_DataSource.cxx
@@ -21,6 +21,7 @@
#include <strings.hrc>
#include <ResId.hxx>
#include <ChartTypeTemplateProvider.hxx>
+#include <ChartTypeTemplate.hxx>
#include <RangeSelectionHelper.hxx>
#include <DataSeriesHelper.hxx>
#include <ControllerLockGuard.hxx>
diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx
index bfb214c71593..05f137f5a7be 100644
--- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx
+++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx
@@ -20,6 +20,7 @@
#include "tp_RangeChooser.hxx"
#include <DataSourceHelper.hxx>
#include <ChartTypeTemplateProvider.hxx>
+#include <ChartTypeTemplate.hxx>
#include "DialogModel.hxx"
#include <RangeSelectionHelper.hxx>
#include <TabPageNotifiable.hxx>
@@ -191,7 +192,7 @@ void RangeChooserTabPage::changeDialogModelAccordingToControls()
if( !m_xCurrentChartTypeTemplate.is() )
{
if(m_pTemplateProvider)
- m_xCurrentChartTypeTemplate.set( m_pTemplateProvider->getCurrentTemplate());
+ m_xCurrentChartTypeTemplate = m_pTemplateProvider->getCurrentTemplate();
if( !m_xCurrentChartTypeTemplate.is())
{
OSL_FAIL( "Need a template to change data source" );
diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.hxx b/chart2/source/controller/dialogs/tp_RangeChooser.hxx
index 7d4e1a4183c2..e372b3f159b1 100644
--- a/chart2/source/controller/dialogs/tp_RangeChooser.hxx
+++ b/chart2/source/controller/dialogs/tp_RangeChooser.hxx
@@ -28,7 +28,7 @@ namespace com::sun::star::chart2 { class XChartTypeTemplate; }
namespace chart
{
-
+class ChartTypeTemplate;
class ChartTypeTemplateProvider;
class DialogModel;
@@ -72,7 +72,7 @@ private:
bool m_bIsDirty;
OUString m_aLastValidRangeString;
- css::uno::Reference< css::chart2::XChartTypeTemplate > m_xCurrentChartTypeTemplate;
+ rtl::Reference< ::chart::ChartTypeTemplate > m_xCurrentChartTypeTemplate;
ChartTypeTemplateProvider* m_pTemplateProvider;
DialogModel & m_rDialogModel;
diff --git a/chart2/source/controller/sidebar/ChartTypePanel.cxx b/chart2/source/controller/sidebar/ChartTypePanel.cxx
index ed2eb2a49583..7309c17f5a21 100644
--- a/chart2/source/controller/sidebar/ChartTypePanel.cxx
+++ b/chart2/source/controller/sidebar/ChartTypePanel.cxx
@@ -25,6 +25,7 @@
#include <ChartResourceGroups.hxx>
#include <ChartTypeDialogController.hxx>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <DiagramHelper.hxx>
#include <Diagram.hxx>
#include <unonames.hxx>
@@ -163,7 +164,7 @@ void ChartTypePanel::Initialize()
rtl::Reference<Diagram> xDiagram(ChartModelHelper::findDiagram(m_xChartModel));
DiagramHelper::tTemplateWithServiceName aTemplate
= DiagramHelper::getTemplateForDiagram(xDiagram, xTemplateManager);
- OUString aServiceName(aTemplate.second);
+ OUString aServiceName(aTemplate.sServiceName);
bool bFound = false;
@@ -176,7 +177,9 @@ void ChartTypePanel::Initialize()
m_xMainTypeList->set_active(nM);
showAllControls(*elem);
- uno::Reference<beans::XPropertySet> xTemplateProps(aTemplate.first, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xTemplateProps(
+ static_cast<cppu::OWeakObject*>(aTemplate.xChartTypeTemplate.get()),
+ uno::UNO_QUERY);
ChartTypeParameter aParameter
= elem->getChartTypeParameterForService(aServiceName, xTemplateProps);
m_pCurrentMainType = getSelectedMainType();
@@ -227,7 +230,7 @@ void ChartTypePanel::updateData()
rtl::Reference<Diagram> xDiagram(ChartModelHelper::findDiagram(xModel));
DiagramHelper::tTemplateWithServiceName aTemplate
= DiagramHelper::getTemplateForDiagram(xDiagram, xTemplateManager);
- OUString aServiceName(aTemplate.second);
+ OUString aServiceName(aTemplate.sServiceName);
sal_uInt16 nM = 0;
for (auto const& elem : m_aChartTypeDialogControllerList)
@@ -287,14 +290,14 @@ void ChartTypePanel::updateModel(css::uno::Reference<css::frame::XModel> xModel)
doUpdateModel(xModel);
}
-uno::Reference<css::chart2::XChartTypeTemplate> ChartTypePanel::getCurrentTemplate() const
+rtl::Reference<::chart::ChartTypeTemplate> ChartTypePanel::getCurrentTemplate() const
{
if (m_pCurrentMainType && m_xChartModel.is())
{
ChartTypeParameter aParameter(getCurrentParameter());
m_pCurrentMainType->adjustParameterToSubType(aParameter);
- uno::Reference<lang::XMultiServiceFactory> xTemplateManager(
- m_xChartModel->getChartTypeManager(), uno::UNO_QUERY);
+ rtl::Reference<ChartTypeManager> xTemplateManager
+ = dynamic_cast<ChartTypeManager*>(m_xChartModel->getChartTypeManager().get());
return m_pCurrentMainType->getCurrentTemplate(aParameter, xTemplateManager);
}
return nullptr;
@@ -433,7 +436,8 @@ void ChartTypePanel::selectMainType()
}
fillAllControls(aParameter);
- uno::Reference<beans::XPropertySet> xTemplateProps(getCurrentTemplate(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xTemplateProps(
+ static_cast<cppu::OWeakObject*>(getCurrentTemplate().get()), uno::UNO_QUERY);
m_pCurrentMainType->fillExtraControls(m_xChartModel, xTemplateProps);
}
} // end of namespace ::chart::sidebar
diff --git a/chart2/source/controller/sidebar/ChartTypePanel.hxx b/chart2/source/controller/sidebar/ChartTypePanel.hxx
index 9610ce3520e9..c5e1df11dab8 100644
--- a/chart2/source/controller/sidebar/ChartTypePanel.hxx
+++ b/chart2/source/controller/sidebar/ChartTypePanel.hxx
@@ -71,8 +71,7 @@ public:
virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) override;
- virtual css::uno::Reference<css::chart2::XChartTypeTemplate>
- getCurrentTemplate() const override;
+ virtual rtl::Reference<::chart::ChartTypeTemplate> getCurrentTemplate() const override;
private:
ChartTypeDialogController* getSelectedMainType();
diff --git a/chart2/source/inc/ChartTypeDialogController.hxx b/chart2/source/inc/ChartTypeDialogController.hxx
index 432401ec1ca3..a91e664d224e 100644
--- a/chart2/source/inc/ChartTypeDialogController.hxx
+++ b/chart2/source/inc/ChartTypeDialogController.hxx
@@ -50,6 +50,9 @@ class ValueSet;
namespace chart
{
+class ChartTypeTemplate;
+class ChartTypeManager;
+
enum GlobalStackMode
{
GlobalStackMode_NONE,
@@ -132,9 +135,9 @@ public:
OUString getServiceNameForParameter(const ChartTypeParameter& rParameter) const;
void commitToModel(const ChartTypeParameter& rParameter,
const css::uno::Reference<css::chart2::XChartDocument>& xChartModel);
- css::uno::Reference<css::chart2::XChartTypeTemplate> getCurrentTemplate(
- const ChartTypeParameter& rParameter,
- const css::uno::Reference<css::lang::XMultiServiceFactory>& xTemplateManager) const;
+ rtl::Reference<::chart::ChartTypeTemplate>
+ getCurrentTemplate(const ChartTypeParameter& rParameter,
+ const rtl::Reference<::chart::ChartTypeManager>& xTemplateManager) const;
protected:
bool bSupportsXAxisWithValues;
diff --git a/chart2/source/inc/ChartTypeTemplateProvider.hxx b/chart2/source/inc/ChartTypeTemplateProvider.hxx
index 95881b6c70e5..400b1c8e2819 100644
--- a/chart2/source/inc/ChartTypeTemplateProvider.hxx
+++ b/chart2/source/inc/ChartTypeTemplateProvider.hxx
@@ -19,19 +19,16 @@
#pragma once
-#include <com/sun/star/uno/Reference.hxx>
-
-namespace com::sun::star::chart2
-{
-class XChartTypeTemplate;
-}
+#include <rtl/ref.hxx>
namespace chart
{
+class ChartTypeTemplate;
+
class ChartTypeTemplateProvider
{
public:
- virtual css::uno::Reference<css::chart2::XChartTypeTemplate> getCurrentTemplate() const = 0;
+ virtual rtl::Reference<::chart::ChartTypeTemplate> getCurrentTemplate() const = 0;
virtual ~ChartTypeTemplateProvider() {}
};
diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx
index e1a0fcdfa978..57372a1c072e 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -41,6 +41,7 @@ namespace com::sun::star::util { class XNumberFormatsSupplier; }
namespace chart
{
class ChartTypeManager;
+class ChartTypeTemplate;
enum DiagramPositioningMode
{
@@ -52,10 +53,10 @@ enum DiagramPositioningMode
class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper
{
public:
- typedef std::pair<
- css::uno::Reference< css::chart2::XChartTypeTemplate >,
- OUString >
- tTemplateWithServiceName;
+ struct tTemplateWithServiceName {
+ rtl::Reference< ::chart::ChartTypeTemplate > xChartTypeTemplate;
+ OUString sServiceName;
+ };
/** tries to find a template in the chart-type manager that matches the
given diagram.
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index 2bd9327babe5..cffa42b1aa43 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -23,6 +23,7 @@
#include <ChartViewHelper.hxx>
#include <ChartModelHelper.hxx>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <DataSourceHelper.hxx>
#include <AxisHelper.hxx>
#include <ThreeDHelper.hxx>
@@ -729,8 +730,7 @@ void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
Reference<chart2::XDiagram> xDiagram(getFirstDiagram());
DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram(xDiagram, xChartTypeManager);
- css::uno::Reference<css::chart2::XChartTypeTemplate> xChartTypeTemplate(aTemplateAndService.first);
- xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments);
+ aTemplateAndService.xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments);
}
catch (const uno::Exception &)
{
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index 15082ccf42c2..43886428c62f 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -19,6 +19,7 @@
#include <Diagram.hxx>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <PropertyHelper.hxx>
#include "Wall.hxx"
#include <ModifyListenerHelper.hxx>
@@ -403,9 +404,9 @@ void SAL_CALL Diagram::setDiagramData(
{
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = new ::chart::ChartTypeManager( m_xContext );
DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager );
- uno::Reference< chart2::XChartTypeTemplate > xTemplate( aTemplateAndService.first );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( aTemplateAndService.xChartTypeTemplate );
if( !xTemplate.is() )
- xTemplate.set( xChartTypeManager->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
+ xTemplate = xChartTypeManager->createTemplate( "com.sun.star.chart2.template.Column" );
if(!xTemplate.is())
return;
xTemplate->changeDiagramData( this, xDataSource, aArguments );
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 531e1c07ac72..d985df9dc3af 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -23,6 +23,7 @@
#include <AxisHelper.hxx>
#include <ChartTypeHelper.hxx>
#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <ChartModel.hxx>
#include <ChartModelHelper.hxx>
#include <ExplicitCategoriesProvider.hxx>
@@ -93,13 +94,13 @@ DiagramHelper::tTemplateWithServiceName
{
try
{
- Reference< XChartTypeTemplate > xTempl(
- xChartTypeManager->createInstance( aServiceNames[ i ] ), uno::UNO_QUERY_THROW );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTempl =
+ xChartTypeManager->createTemplate( aServiceNames[ i ] );
if (xTempl.is() && xTempl->matchesTemplate(xDiagram, true))
{
- aResult.first = xTempl;
- aResult.second = aServiceNames[ i ];
+ aResult.xChartTypeTemplate = xTempl;
+ aResult.sServiceName = aServiceNames[ i ];
bTemplateFound = true;
}
}