summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-03-16 09:38:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-03-21 14:24:53 +0000
commitcde0f27c84599d0d9894148e510254749f7e2784 (patch)
treea39d0de78ddf10a51311be3d7704e96ea6a24596
parentd82a734c07b85cbd7861699b7fa6d3ebbb3122f2 (diff)
move getTemplate inside chart2::Diagram
Change-Id: I05da4e4a9acb2683633eda42cf18d740913c2e37 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149180 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.cxx12
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx12
-rw-r--r--chart2/source/controller/dialogs/ChartTypeDialogController.cxx4
-rw-r--r--chart2/source/controller/dialogs/DataBrowserModel.cxx4
-rw-r--r--chart2/source/controller/dialogs/dlg_DataSource.cxx6
-rw-r--r--chart2/source/controller/dialogs/tp_ChartType.cxx4
-rw-r--r--chart2/source/controller/sidebar/ChartTypePanel.cxx10
-rw-r--r--chart2/source/inc/Diagram.hxx18
-rw-r--r--chart2/source/inc/DiagramHelper.hxx17
-rw-r--r--chart2/source/model/main/ChartModel_Persistence.cxx2
-rw-r--r--chart2/source/model/main/Diagram.cxx39
-rw-r--r--chart2/source/tools/DiagramHelper.cxx38
13 files changed, 85 insertions, 85 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index 5ce060e9891f..fbb12b5d4a51 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -1192,8 +1192,8 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xChartDoc );
ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram );
rtl::Reference< ::chart::ChartTypeManager > xTemplateManager = xChartDoc->getTypeManager();
- DiagramHelper::tTemplateWithServiceName aTemplateWithService(
- DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
+ Diagram::tTemplateWithServiceName aTemplateWithService(
+ xDiagram->getTemplate( xTemplateManager ));
if( aTemplateWithService.xChartTypeTemplate.is())
aTemplateWithService.xChartTypeTemplate->resetStyles2( xDiagram );//#i109371#
xTemplate->changeDiagram( xDiagram );
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index 7cc7c57e2862..8ef1429d7565 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -588,8 +588,8 @@ OUString SAL_CALL DiagramWrapper::getDiagramType()
}
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager();
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
+ Diagram::tTemplateWithServiceName aTemplateAndService =
+ xDiagram->getTemplate( xChartTypeManager );
aRet = lcl_getDiagramType( aTemplateAndService.sServiceName );
}
@@ -1455,8 +1455,8 @@ bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any& rInnerValue ) con
if( !aSeriesVector.empty() )
{
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager();
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
+ Diagram::tTemplateWithServiceName aTemplateAndService =
+ xDiagram->getTemplate( xChartTypeManager );
if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" )
{
try
@@ -1494,8 +1494,8 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con
return;
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager();
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
+ Diagram::tTemplateWithServiceName aTemplateAndService =
+ xDiagram->getTemplate( xChartTypeManager );
rtl::Reference< ChartTypeTemplate > xTemplate;
if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" )
diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
index 83566cf89230..837afa34c0a3 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
@@ -86,8 +86,8 @@ void WrappedStockProperty::setPropertyValue( const css::uno::Any& rOuterValue, c
return;
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager();
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
+ Diagram::tTemplateWithServiceName aTemplateAndService =
+ xDiagram->getTemplate( xChartTypeManager );
rtl::Reference< ::chart::ChartTypeTemplate > xTemplate =
getNewTemplate( bNewValue, aTemplateAndService.sServiceName, xChartTypeManager );
@@ -142,8 +142,8 @@ css::uno::Any WrappedVolumeProperty::getPropertyValue( const css::uno::Reference
if( !aSeriesVector.empty() )
{
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager();
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
+ Diagram::tTemplateWithServiceName aTemplateAndService =
+ xDiagram->getTemplate( xChartTypeManager );
if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeLowHighClose"
|| aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
@@ -211,8 +211,8 @@ css::uno::Any WrappedUpDownProperty::getPropertyValue( const css::uno::Reference
if( !aSeriesVector.empty() )
{
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager();
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
+ Diagram::tTemplateWithServiceName aTemplateAndService =
+ xDiagram->getTemplate( xChartTypeManager );
if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockOpenLowHighClose"
|| aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
index 72c51a30d6d0..d1c6a725decb 100644
--- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
+++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
@@ -315,8 +315,8 @@ void ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParame
// locked controllers
ControllerLockGuardUNO aCtrlLockGuard( xChartModel );
rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xChartModel );
- DiagramHelper::tTemplateWithServiceName aTemplateWithService(
- DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
+ Diagram::tTemplateWithServiceName aTemplateWithService(
+ xDiagram->getTemplate( xTemplateManager ));
if( aTemplateWithService.xChartTypeTemplate.is())
aTemplateWithService.xChartTypeTemplate->resetStyles2( xDiagram );
xTemplate->changeDiagram( xDiagram );
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index d26db62f76b9..f406935b1f21 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -755,8 +755,8 @@ void DataBrowserModel::updateFromModel()
// set template at DialogModel
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = m_xChartDocument->getTypeManager();
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
+ Diagram::tTemplateWithServiceName aTemplateAndService =
+ xDiagram->getTemplate( xChartTypeManager );
if( aTemplateAndService.xChartTypeTemplate.is())
m_apDialogModel->setTemplate( aTemplateAndService.xChartTypeTemplate );
diff --git a/chart2/source/controller/dialogs/dlg_DataSource.cxx b/chart2/source/controller/dialogs/dlg_DataSource.cxx
index dc1296af70b0..87af01aaa33a 100644
--- a/chart2/source/controller/dialogs/dlg_DataSource.cxx
+++ b/chart2/source/controller/dialogs/dlg_DataSource.cxx
@@ -65,10 +65,8 @@ DocumentChartTypeTemplateProvider::DocumentChartTypeTemplateProvider(
rtl::Reference< Diagram > xDia( xDoc->getFirstChartDiagram());
if( xDia.is())
{
- DiagramHelper::tTemplateWithServiceName aResult(
- DiagramHelper::getTemplateForDiagram(
- xDia,
- xDoc->getTypeManager() ));
+ Diagram::tTemplateWithServiceName aResult(
+ xDia->getTemplate( xDoc->getTypeManager() ));
m_xTemplate = aResult.xChartTypeTemplate;
}
}
diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx
index 3a8859820c92..0e523eb03d65 100644
--- a/chart2/source/controller/dialogs/tp_ChartType.cxx
+++ b/chart2/source/controller/dialogs/tp_ChartType.cxx
@@ -305,8 +305,8 @@ void ChartTypeTabPage::initializePage()
return;
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = m_xChartModel->getTypeManager();
rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel );
- DiagramHelper::tTemplateWithServiceName aTemplate =
- DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
+ Diagram::tTemplateWithServiceName aTemplate =
+ xDiagram->getTemplate( xChartTypeManager );
OUString aServiceName( aTemplate.sServiceName );
bool bFound = false;
diff --git a/chart2/source/controller/sidebar/ChartTypePanel.cxx b/chart2/source/controller/sidebar/ChartTypePanel.cxx
index 6d524bc16191..42aac80f9152 100644
--- a/chart2/source/controller/sidebar/ChartTypePanel.cxx
+++ b/chart2/source/controller/sidebar/ChartTypePanel.cxx
@@ -158,8 +158,9 @@ void ChartTypePanel::Initialize()
return;
rtl::Reference<::chart::ChartTypeManager> xChartTypeManager = m_xChartModel->getTypeManager();
rtl::Reference<Diagram> xDiagram = ChartModelHelper::findDiagram(m_xChartModel);
- DiagramHelper::tTemplateWithServiceName aTemplate
- = DiagramHelper::getTemplateForDiagram(xDiagram, xChartTypeManager);
+ Diagram::tTemplateWithServiceName aTemplate;
+ if (xDiagram)
+ aTemplate = xDiagram->getTemplate(xChartTypeManager);
OUString aServiceName(aTemplate.sServiceName);
bool bFound = false;
@@ -222,8 +223,9 @@ void ChartTypePanel::updateData()
return;
rtl::Reference<::chart::ChartTypeManager> xChartTypeManager = m_xChartModel->getTypeManager();
rtl::Reference<Diagram> xDiagram = ChartModelHelper::findDiagram(m_xChartModel);
- DiagramHelper::tTemplateWithServiceName aTemplate
- = DiagramHelper::getTemplateForDiagram(xDiagram, xChartTypeManager);
+ Diagram::tTemplateWithServiceName aTemplate;
+ if (xDiagram)
+ aTemplate = xDiagram->getTemplate(xChartTypeManager);
OUString aServiceName(aTemplate.sServiceName);
//sal_uInt16 nM = 0;
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index c24d10af9d83..71816aa67f7e 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -42,6 +42,8 @@ namespace chart
class Axis;
class BaseCoordinateSystem;
class ChartType;
+class ChartTypeManager;
+class ChartTypeTemplate;
class DataSeries;
class Legend;
class DataTable;
@@ -315,6 +317,22 @@ public:
*/
bool getVertical( bool& rbOutFoundResult, bool& rbOutAmbiguousResult );
+ struct tTemplateWithServiceName {
+ rtl::Reference< ::chart::ChartTypeTemplate > xChartTypeTemplate;
+ OUString sServiceName;
+ };
+
+ /** tries to find a template in the chart-type manager that matches this
+ diagram.
+
+ @return
+ A pair containing a template with the correct properties set as
+ first entry and the service name of the templates second entry. If
+ no template was found both elements are empty.
+ */
+ tTemplateWithServiceName
+ getTemplate(const rtl::Reference< ::chart::ChartTypeManager > & xChartTypeManager);
+
private:
// ____ XModifyListener ____
virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx
index bf46ed08025a..073d228e849c 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -54,23 +54,6 @@ class LabeledDataSequence;
class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper
{
public:
- struct tTemplateWithServiceName {
- rtl::Reference< ::chart::ChartTypeTemplate > xChartTypeTemplate;
- OUString sServiceName;
- };
-
- /** tries to find a template in the chart-type manager that matches the
- given diagram.
-
- @return
- A pair containing a template with the correct properties set as
- first entry and the service name of the templates second entry. If
- no template was found both elements are empty.
- */
- static tTemplateWithServiceName
- getTemplateForDiagram(
- const rtl::Reference< ::chart::Diagram > & xDiagram,
- const rtl::Reference< ::chart::ChartTypeManager > & xChartTypeManager);
/** Retrieves the stackmode of the first DataSeries or none. If the series have differing stack
modes, rbAmbiguous is set to true. If no series is there rbFound is set to false.
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index 986c5640c3d5..a98d090a8958 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -718,7 +718,7 @@ void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = getTypeManager();
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 &)
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index 5d6f84adbb86..6b8f3b864f00 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -401,7 +401,7 @@ void SAL_CALL Diagram::setDiagramData(
const Sequence< beans::PropertyValue >& aArguments )
{
rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = new ::chart::ChartTypeManager( m_xContext );
- DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager );
+ Diagram::tTemplateWithServiceName aTemplateAndService = getTemplate( xChartTypeManager );
rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( aTemplateAndService.xChartTypeTemplate );
if( !xTemplate.is() )
xTemplate = xChartTypeManager->createTemplate( "com.sun.star.chart2.template.Column" );
@@ -1622,6 +1622,43 @@ bool Diagram::getVertical( bool& rbFound, bool& rbAmbiguous )
return bValue;
}
+Diagram::tTemplateWithServiceName
+ Diagram::getTemplate(
+ const rtl::Reference< ::chart::ChartTypeManager > & xChartTypeManager )
+{
+ tTemplateWithServiceName aResult;
+
+ if( !xChartTypeManager )
+ return aResult;
+
+ Sequence< OUString > aServiceNames( xChartTypeManager->getAvailableServiceNames());
+ const sal_Int32 nLength = aServiceNames.getLength();
+
+ bool bTemplateFound = false;
+
+ for( sal_Int32 i = 0; ! bTemplateFound && i < nLength; ++i )
+ {
+ try
+ {
+ rtl::Reference< ::chart::ChartTypeTemplate > xTempl =
+ xChartTypeManager->createTemplate( aServiceNames[ i ] );
+
+ if (xTempl.is() && xTempl->matchesTemplate2(this, true))
+ {
+ aResult.xChartTypeTemplate = xTempl;
+ aResult.sServiceName = aServiceNames[ i ];
+ bTemplateFound = true;
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return aResult;
+}
+
} // namespace chart
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 299caca7cb81..1cf14279bbb4 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -75,44 +75,6 @@ using ::com::sun::star::chart2::XAnyDescriptionAccess;
namespace chart
{
-DiagramHelper::tTemplateWithServiceName
- DiagramHelper::getTemplateForDiagram(
- const rtl::Reference< Diagram > & xDiagram,
- const rtl::Reference< ::chart::ChartTypeManager > & xChartTypeManager )
-{
- DiagramHelper::tTemplateWithServiceName aResult;
-
- if( ! (xChartTypeManager.is() && xDiagram.is()))
- return aResult;
-
- Sequence< OUString > aServiceNames( xChartTypeManager->getAvailableServiceNames());
- const sal_Int32 nLength = aServiceNames.getLength();
-
- bool bTemplateFound = false;
-
- for( sal_Int32 i = 0; ! bTemplateFound && i < nLength; ++i )
- {
- try
- {
- rtl::Reference< ::chart::ChartTypeTemplate > xTempl =
- xChartTypeManager->createTemplate( aServiceNames[ i ] );
-
- if (xTempl.is() && xTempl->matchesTemplate2(xDiagram, true))
- {
- aResult.xChartTypeTemplate = xTempl;
- aResult.sServiceName = aServiceNames[ i ];
- bTemplateFound = true;
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
- }
-
- return aResult;
-}
-
StackMode DiagramHelper::getStackModeFromChartType(
const rtl::Reference< ChartType > & xChartType,
bool& rbFound, bool& rbAmbiguous,