summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-01-29 12:45:23 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-29 15:51:30 +0100
commit2781c7a50f3a9bcf48e84a8c5f450b16d576a8e6 (patch)
tree468c5a764c12481ede8ded07215612cb5debea73
parentavoid dangling tmp files in hwp import (diff)
downloadcore-2781c7a50f3a9bcf48e84a8c5f450b16d576a8e6.tar.gz
core-2781c7a50f3a9bcf48e84a8c5f450b16d576a8e6.zip
use more concrete types in chart2, Legend
Change-Id: Ifbf8ddd92eacd4caaf6fdaa061821222e543a1a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129133 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx5
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx16
-rw-r--r--chart2/source/controller/dialogs/res_LegendPosition.cxx3
-rw-r--r--chart2/source/controller/main/ChartController_Insert.cxx1
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx5
-rw-r--r--chart2/source/controller/sidebar/ChartElementsPanel.cxx11
-rw-r--r--chart2/source/inc/Diagram.hxx9
-rw-r--r--chart2/source/inc/Legend.hxx (renamed from chart2/source/model/main/Legend.hxx)11
-rw-r--r--chart2/source/inc/LegendHelper.hxx5
-rw-r--r--chart2/source/inc/ModifyListenerHelper.hxx17
-rw-r--r--chart2/source/inc/ObjectIdentifier.hxx4
-rw-r--r--chart2/source/model/main/Diagram.cxx13
-rw-r--r--chart2/source/model/main/Legend.cxx2
-rw-r--r--chart2/source/tools/LegendHelper.cxx33
-rw-r--r--chart2/source/tools/ObjectIdentifier.cxx21
-rw-r--r--chart2/source/view/main/ChartView.cxx3
-rw-r--r--chart2/source/view/main/VLegend.cxx66
-rw-r--r--chart2/source/view/main/VLegend.hxx7
-rw-r--r--solenv/clang-format/excludelist2
19 files changed, 157 insertions, 77 deletions
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
index 4d85f5c0c493..fe29d1990c99 100644
--- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
@@ -19,6 +19,7 @@
#include "Chart2ModelContact.hxx"
#include <ChartModelHelper.hxx>
+#include <Legend.hxx>
#include <LegendHelper.hxx>
#include <CommonConverters.hxx>
#include <servicenames.hxx>
@@ -229,7 +230,7 @@ awt::Size Chart2ModelContact::GetLegendSize() const
ExplicitValueProvider* pProvider( getExplicitValueProvider() );
if( pProvider )
{
- uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_xChartModel.get() ) );
+ rtl::Reference< Legend > xLegend = LegendHelper::getLegend( *m_xChartModel.get() );
OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) );
aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
}
@@ -242,7 +243,7 @@ awt::Point Chart2ModelContact::GetLegendPosition() const
ExplicitValueProvider* pProvider( getExplicitValueProvider() );
if( pProvider )
{
- uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_xChartModel.get() ) );
+ rtl::Reference< Legend > xLegend = LegendHelper::getLegend( *m_xChartModel.get() );
OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) );
aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
}
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index e75bd16e8e24..d27c5ec6bb93 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -24,6 +24,7 @@
#include <servicenames.hxx>
#include <PropertyHelper.hxx>
#include <TitleHelper.hxx>
+#include <Legend.hxx>
#include <LegendHelper.hxx>
#include <ControllerLockGuard.hxx>
#include <DisposeHelper.hxx>
@@ -464,15 +465,14 @@ void WrappedHasLegendProperty::setPropertyValue( const Any& rOuterValue, const R
try
{
- Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext,bNewValue ));
+ rtl::Reference< Legend > xLegend = LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext,bNewValue );
if(xLegend.is())
{
- Reference< beans::XPropertySet > xLegendProp( xLegend, uno::UNO_QUERY_THROW );
bool bOldValue = true;
- Any aAOld = xLegendProp->getPropertyValue("Show");
+ Any aAOld = xLegend->getPropertyValue("Show");
aAOld >>= bOldValue;
if( bOldValue != bNewValue )
- xLegendProp->setPropertyValue("Show", uno::Any( bNewValue ));
+ xLegend->setPropertyValue("Show", uno::Any( bNewValue ));
}
}
catch (const uno::Exception&)
@@ -486,10 +486,10 @@ Any WrappedHasLegendProperty::getPropertyValue( const Reference< beans::XPropert
Any aRet;
try
{
- Reference< beans::XPropertySet > xLegendProp(
- LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel() ), uno::UNO_QUERY );
- if( xLegendProp.is())
- aRet = xLegendProp->getPropertyValue("Show");
+ rtl::Reference< Legend > xLegend =
+ LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel() );
+ if( xLegend.is())
+ aRet = xLegend->getPropertyValue("Show");
else
aRet <<= false;
}
diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx
index aac0a11368a1..1a890a20f30c 100644
--- a/chart2/source/controller/dialogs/res_LegendPosition.cxx
+++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx
@@ -19,6 +19,7 @@
#include <res_LegendPosition.hxx>
#include <ChartModelHelper.hxx>
+#include <Legend.hxx>
#include <LegendHelper.hxx>
#include <ChartModel.hxx>
#include <Diagram.hxx>
@@ -121,7 +122,7 @@ void LegendPositionResources::writeToModel( const rtl::Reference<::chart::ChartM
{
bool bShowLegend = m_xCbxShow && m_xCbxShow->get_active();
ChartModel& rModel = *xChartModel;
- uno::Reference< beans::XPropertySet > xProp(LegendHelper::getLegend(rModel, m_xCC, bShowLegend), uno::UNO_QUERY);
+ rtl::Reference< Legend > xProp = LegendHelper::getLegend(rModel, m_xCC, bShowLegend);
if( xProp.is() )
{
//show
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx
index f84afc78a2e8..0298b1bed9da 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -50,6 +50,7 @@
#include <ErrorBarItemConverter.hxx>
#include <DataSeriesHelper.hxx>
#include <ObjectNameProvider.hxx>
+#include <Legend.hxx>
#include <LegendHelper.hxx>
#include <com/sun/star/chart2/XRegressionCurve.hpp>
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 850ed40b1d11..c44e9c32f62f 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -34,6 +34,7 @@
#include <chartview/DrawModelWrapper.hxx>
#include "ChartTransferable.hxx"
#include <DrawViewWrapper.hxx>
+#include <Legend.hxx>
#include <LegendHelper.hxx>
#include <AxisHelper.hxx>
#include <RegressionCurveHelper.hxx>
@@ -824,7 +825,7 @@ void ChartController::executeDispatch_ToggleLegend()
UndoGuard aUndoGuard(
SchResId( STR_ACTION_TOGGLE_LEGEND ), m_xUndoManager );
ChartModel& rModel = dynamic_cast<ChartModel&>(*xModel);
- Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(rModel), uno::UNO_QUERY );
+ rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(rModel);
bool bChanged = false;
if( xLegendProp.is())
{
@@ -844,7 +845,7 @@ void ChartController::executeDispatch_ToggleLegend()
}
else
{
- xLegendProp.set( LegendHelper::getLegend(rModel, m_xCC, true), uno::UNO_QUERY );
+ xLegendProp = LegendHelper::getLegend(rModel, m_xCC, true);
if( xLegendProp.is())
bChanged = true;
}
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index 1d495dd209f5..cfa821d3bad8 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -28,6 +28,7 @@
#include <ChartController.hxx>
#include <comphelper/processfactory.hxx>
+#include <Legend.hxx>
#include <LegendHelper.hxx>
#include <ChartModelHelper.hxx>
#include <AxisHelper.hxx>
@@ -76,7 +77,7 @@ bool isLegendVisible(const css::uno::Reference<css::frame::XModel>& xModel)
if (!pModel)
return false;
- Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY );
+ rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel);
if( xLegendProp.is())
{
try
@@ -113,7 +114,7 @@ bool isLegendOverlay(const css::uno::Reference<css::frame::XModel>& xModel)
if (!pModel)
return false;
- Reference< beans::XPropertySet > xLegendProp(LegendHelper::getLegend(*pModel), uno::UNO_QUERY);
+ rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel);
if( xLegendProp.is())
{
try
@@ -138,7 +139,7 @@ void setLegendOverlay(const css::uno::Reference<css::frame::XModel>& xModel, boo
if (!pModel)
return;
- Reference<beans::XPropertySet> xLegendProp(LegendHelper::getLegend(*pModel), uno::UNO_QUERY);
+ rtl::Reference<Legend> xLegendProp = LegendHelper::getLegend(*pModel);
if (!xLegendProp.is())
return;
@@ -239,7 +240,7 @@ sal_Int32 getLegendPos(const css::uno::Reference<css::frame::XModel>& xModel)
if (!pModel)
return -1;
- Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY );
+ rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel);
if (!xLegendProp.is())
return -1;
@@ -266,7 +267,7 @@ void setLegendPos(const css::uno::Reference<css::frame::XModel>& xModel, sal_Int
if (!pModel)
return;
- Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY );
+ rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel);
if (!xLegendProp.is())
return;
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index 5d6dc79a1ee1..16beacd59894 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -39,8 +39,9 @@ namespace com::sun::star::uno { class XComponentContext; }
namespace chart
{
-class Wall;
class BaseCoordinateSystem;
+class Legend;
+class Wall;
namespace impl
{
@@ -144,6 +145,9 @@ public:
const tCoordinateSystemContainerType & getBaseCoordinateSystems() { return m_aCoordSystems; }
+ const rtl::Reference< ::chart::Legend > & getLegend2() const { return m_xLegend; }
+ void setLegend(const rtl::Reference< ::chart::Legend > &);
+
private:
// ____ XModifyListener ____
@@ -171,8 +175,7 @@ private:
css::uno::Reference< css::chart2::XTitle >
m_xTitle;
- css::uno::Reference< css::chart2::XLegend >
- m_xLegend;
+ rtl::Reference< ::chart::Legend > m_xLegend;
css::uno::Reference< css::chart2::XColorScheme >
m_xColorScheme;
diff --git a/chart2/source/model/main/Legend.hxx b/chart2/source/inc/Legend.hxx
index 8748a4592393..728d60d8aa52 100644
--- a/chart2/source/model/main/Legend.hxx
+++ b/chart2/source/inc/Legend.hxx
@@ -18,14 +18,15 @@
*/
#pragma once
-#include <OPropertySet.hxx>
+#include "OPropertySet.hxx"
#include <cppuhelper/basemutex.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/uno3.hxx>
#include <com/sun/star/chart2/XLegend.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <ModifyListenerHelper.hxx>
+#include "ModifyListenerHelper.hxx"
+#include "charttoolsdllapi.hxx"
namespace chart
{
@@ -41,7 +42,7 @@ typedef ::cppu::WeakImplHelper<
Legend_Base;
}
-class Legend final :
+class OOO_DLLPUBLIC_CHARTTOOLS Legend final :
public cppu::BaseMutex,
public impl::Legend_Base,
public ::property::OPropertySet
@@ -60,15 +61,16 @@ public:
/// merge XTypeProvider implementations
DECLARE_XTYPEPROVIDER()
-private:
explicit Legend( const Legend & rOther );
+private:
// ____ OPropertySet ____
virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
+public:
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
@@ -82,6 +84,7 @@ private:
virtual void SAL_CALL removeModifyListener(
const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
+private:
// ____ XModifyListener ____
virtual void SAL_CALL modified(
const css::lang::EventObject& aEvent ) override;
diff --git a/chart2/source/inc/LegendHelper.hxx b/chart2/source/inc/LegendHelper.hxx
index ca2dc0ef8e16..f2bf2e55fefb 100644
--- a/chart2/source/inc/LegendHelper.hxx
+++ b/chart2/source/inc/LegendHelper.hxx
@@ -30,17 +30,18 @@ namespace com::sun::star::uno { class XComponentContext; }
namespace chart
{
class Diagram;
+class Legend;
class OOO_DLLPUBLIC_CHARTTOOLS LegendHelper
{
public:
- static css::uno::Reference< css::chart2::XLegend >
+ static rtl::Reference< ::chart::Legend >
showLegend( ChartModel& rModel
, const css::uno::Reference< css::uno::XComponentContext >& xContext );
static void hideLegend( ChartModel& rModel );
- static css::uno::Reference< css::chart2::XLegend >
+ static rtl::Reference< ::chart::Legend >
getLegend( ChartModel& rModel
, const css::uno::Reference< css::uno::XComponentContext >& xContext = nullptr
, bool bCreate = false );
diff --git a/chart2/source/inc/ModifyListenerHelper.hxx b/chart2/source/inc/ModifyListenerHelper.hxx
index b65530d9f229..abee24032bae 100644
--- a/chart2/source/inc/ModifyListenerHelper.hxx
+++ b/chart2/source/inc/ModifyListenerHelper.hxx
@@ -157,6 +157,14 @@ void addListener(
aFunctor( xObject );
}
}
+template< class T >
+void addListener(
+ const rtl::Reference<T> & xBroadcaster,
+ const css::uno::Reference< css::util::XModifyListener > & xListener )
+{
+ if( xBroadcaster && xListener )
+ xBroadcaster->addModifyListener( xListener );
+}
template< class Container >
void addListenerToAllElements(
@@ -200,6 +208,15 @@ void removeListener(
}
}
+template< class T >
+void removeListener(
+ const rtl::Reference<T> & xBroadcaster,
+ const css::uno::Reference< css::util::XModifyListener > & xListener )
+{
+ if( xBroadcaster && xListener )
+ xBroadcaster->removeModifyListener( xListener );
+}
+
template< class Container >
void removeListenerFromAllElements(
const Container & rContainer,
diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx
index 3410476083d9..94b00e1d5ea6 100644
--- a/chart2/source/inc/ObjectIdentifier.hxx
+++ b/chart2/source/inc/ObjectIdentifier.hxx
@@ -44,6 +44,7 @@ namespace chart
{
class BaseCoordinateSystem;
class Diagram;
+class Legend;
enum ObjectType
{
@@ -107,6 +108,9 @@ public:
static OUString createClassifiedIdentifierForObject(
const css::uno::Reference< css::uno::XInterface >& xObject
, const rtl::Reference<::chart::ChartModel>& xChartModel );
+ static OUString createClassifiedIdentifierForObject(
+ const rtl::Reference< ::chart::Legend >& xObject
+ , const rtl::Reference<::chart::ChartModel>& xChartModel );
static OUString createClassifiedIdentifierForParticle(
const OUString& rParticle );
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index 91b4a6b31c7b..60bcbd5124f7 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -31,6 +31,7 @@
#include <SceneProperties.hxx>
#include <unonames.hxx>
#include <BaseCoordinateSystem.hxx>
+#include <Legend.hxx>
#include <basegfx/numeric/ftools.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -274,7 +275,8 @@ Diagram::Diagram( const Diagram & rOther ) :
if ( rOther.m_xFloor )
m_xFloor = new Wall( *rOther.m_xFloor );
m_xTitle.set( CloneHelper::CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ));
- m_xLegend.set( CloneHelper::CreateRefClone< chart2::XLegend >()( rOther.m_xLegend ));
+ if (rOther.m_xLegend)
+ m_xLegend = new Legend(*rOther.m_xLegend);
if ( m_xWall )
m_xWall->addModifyListener( m_xModifyEventForwarder );
@@ -349,7 +351,14 @@ uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend )
{
- Reference< chart2::XLegend > xOldLegend;
+ auto pLegend = dynamic_cast<Legend*>(xNewLegend.get());
+ assert(!xNewLegend || pLegend);
+ setLegend(rtl::Reference< Legend >(pLegend));
+}
+
+void Diagram::setLegend( const rtl::Reference< Legend >& xNewLegend )
+{
+ rtl::Reference< Legend > xOldLegend;
{
MutexGuard aGuard( m_aMutex );
if( m_xLegend == xNewLegend )
diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx
index 27eae67764ed..741b90039370 100644
--- a/chart2/source/model/main/Legend.cxx
+++ b/chart2/source/model/main/Legend.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "Legend.hxx"
+#include <Legend.hxx>
#include <LinePropertiesHelper.hxx>
#include <FillProperties.hxx>
#include <CharacterProperties.hxx>
diff --git a/chart2/source/tools/LegendHelper.cxx b/chart2/source/tools/LegendHelper.cxx
index 7d040128959c..dddcf67d0c08 100644
--- a/chart2/source/tools/LegendHelper.cxx
+++ b/chart2/source/tools/LegendHelper.cxx
@@ -18,6 +18,7 @@
*/
#include <LegendHelper.hxx>
+#include <Legend.hxx>
#include <ChartModel.hxx>
#include <Diagram.hxx>
#include <com/sun/star/chart/ChartLegendExpansion.hpp>
@@ -32,31 +33,30 @@ using ::com::sun::star::uno::Reference;
namespace chart
{
-Reference< chart2::XLegend > LegendHelper::showLegend( ChartModel& rModel
+rtl::Reference< Legend > LegendHelper::showLegend( ChartModel& rModel
, const uno::Reference< uno::XComponentContext >& xContext )
{
- uno::Reference< chart2::XLegend > xLegend = LegendHelper::getLegend( rModel, xContext, true );
- uno::Reference< beans::XPropertySet > xProp( xLegend, uno::UNO_QUERY );
- if( xProp.is())
+ rtl::Reference< Legend > xLegend = LegendHelper::getLegend( rModel, xContext, true );
+ if( xLegend.is())
{
- xProp->setPropertyValue( "Show", uno::Any(true) );
+ xLegend->setPropertyValue( "Show", uno::Any(true) );
chart2::RelativePosition aRelativePosition;
- if( !(xProp->getPropertyValue( "RelativePosition") >>= aRelativePosition) )
+ if( !(xLegend->getPropertyValue( "RelativePosition") >>= aRelativePosition) )
{
chart2::LegendPosition ePos = chart2::LegendPosition_LINE_END;
- if( !(xProp->getPropertyValue( "AnchorPosition") >>= ePos ) )
- xProp->setPropertyValue( "AnchorPosition", uno::Any( ePos ));
+ if( !(xLegend->getPropertyValue( "AnchorPosition") >>= ePos ) )
+ xLegend->setPropertyValue( "AnchorPosition", uno::Any( ePos ));
css::chart::ChartLegendExpansion eExpansion =
( ePos == chart2::LegendPosition_LINE_END ||
ePos == chart2::LegendPosition_LINE_START )
? css::chart::ChartLegendExpansion_HIGH
: css::chart::ChartLegendExpansion_WIDE;
- if( !(xProp->getPropertyValue( "Expansion") >>= eExpansion ) )
- xProp->setPropertyValue( "Expansion", uno::Any( eExpansion ));
+ if( !(xLegend->getPropertyValue( "Expansion") >>= eExpansion ) )
+ xLegend->setPropertyValue( "Expansion", uno::Any( eExpansion ));
- xProp->setPropertyValue( "RelativePosition", uno::Any());
+ xLegend->setPropertyValue( "RelativePosition", uno::Any());
}
}
@@ -73,23 +73,22 @@ void LegendHelper::hideLegend( ChartModel& rModel )
}
}
-uno::Reference< chart2::XLegend > LegendHelper::getLegend(
+rtl::Reference< Legend > LegendHelper::getLegend(
ChartModel& rModel
, const uno::Reference< uno::XComponentContext >& xContext
, bool bCreate )
{
- uno::Reference< chart2::XLegend > xResult;
+ rtl::Reference< Legend > xResult;
try
{
- uno::Reference< chart2::XDiagram > xDia( rModel.getFirstDiagram());
+ rtl::Reference< Diagram > xDia( rModel.getFirstChartDiagram());
if( xDia.is() )
{
- xResult.set( xDia->getLegend() );
+ xResult = xDia->getLegend2();
if( bCreate && !xResult.is() && xContext.is() )
{
- xResult.set( xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.Legend", xContext ), uno::UNO_QUERY );
+ xResult = new Legend();
xDia->setLegend( xResult );
}
}
diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx
index bfa4796f9598..2f940a06aad1 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -372,6 +372,27 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject(
return aRet;
}
+OUString ObjectIdentifier::createClassifiedIdentifierForObject(
+ const rtl::Reference< Legend >& xLegend
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
+{
+ try
+ {
+ if( xLegend.is() )
+ {
+ return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel ) );
+ }
+ }
+ catch(const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
+
+ return OUString();
+}
+
OUString ObjectIdentifier::createClassifiedIdentifierForParticle(
const OUString& rParticle )
{
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 245181f6a90a..2fee4c3059be 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -33,6 +33,7 @@
#include <VSeriesPlotter.hxx>
#include <CommonConverters.hxx>
#include <TitleHelper.hxx>
+#include <Legend.hxx>
#include <LegendHelper.hxx>
#include "VLegend.hxx"
#include <PropertyMapper.hxx>
@@ -2176,7 +2177,7 @@ std::shared_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType
return apVTitle;
}
-bool lcl_createLegend( const uno::Reference< XLegend > & xLegend
+bool lcl_createLegend( const rtl::Reference< Legend > & xLegend
, const rtl::Reference<SvxShapeGroupAnyD>& xPageShapes
, const uno::Reference< uno::XComponentContext > & xContext
, awt::Rectangle & rRemainingSpace
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index ce2bb99047a4..4d32fe04bc90 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -19,6 +19,7 @@
#include "VLegend.hxx"
#include "VButton.hxx"
+#include <Legend.hxx>
#include <PropertyMapper.hxx>
#include <ChartModel.hxx>
#include <ObjectIdentifier.hxx>
@@ -869,7 +870,7 @@ std::vector<std::shared_ptr<VButton>> lcl_createButtons(
} // anonymous namespace
VLegend::VLegend(
- const Reference< XLegend > & xLegend,
+ const rtl::Reference< Legend > & xLegend,
const Reference< uno::XComponentContext > & xContext,
std::vector< LegendEntryProvider* >&& rLegendEntryProviderList,
const rtl::Reference<SvxShapeGroupAnyD>& xTargetPage,
@@ -907,6 +908,24 @@ bool VLegend::isVisible( const Reference< XLegend > & xLegend )
return bShow;
}
+bool VLegend::isVisible( const rtl::Reference< Legend > & xLegend )
+{
+ if( ! xLegend.is())
+ return false;
+
+ bool bShow = false;
+ try
+ {
+ xLegend->getPropertyValue( "Show") >>= bShow;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return bShow;
+}
+
void VLegend::createShapes(
const awt::Size & rAvailableSpace,
const awt::Size & rPageSize,
@@ -930,36 +949,32 @@ void VLegend::createShapes(
tPropertyValues aLineFillProperties;
tPropertyValues aTextProperties;
- Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY );
css::chart::ChartLegendExpansion eExpansion = css::chart::ChartLegendExpansion_HIGH;
awt::Size aLegendSize( rAvailableSpace );
bool bCustom = false;
LegendPosition eLegendPosition = LegendPosition_LINE_END;
- if (xLegendProp.is())
+ // get Expansion property
+ m_xLegend->getPropertyValue("Expansion") >>= eExpansion;
+ if( eExpansion == css::chart::ChartLegendExpansion_CUSTOM )
{
- // get Expansion property
- xLegendProp->getPropertyValue("Expansion") >>= eExpansion;
- if( eExpansion == css::chart::ChartLegendExpansion_CUSTOM )
+ RelativeSize aRelativeSize;
+ if (m_xLegend->getPropertyValue("RelativeSize") >>= aRelativeSize)
{
- RelativeSize aRelativeSize;
- if (xLegendProp->getPropertyValue("RelativeSize") >>= aRelativeSize)
- {
- aLegendSize.Width = static_cast<sal_Int32>(::rtl::math::approxCeil( aRelativeSize.Primary * rPageSize.Width ));
- aLegendSize.Height = static_cast<sal_Int32>(::rtl::math::approxCeil( aRelativeSize.Secondary * rPageSize.Height ));
- bCustom = true;
- }
- else
- {
- eExpansion = css::chart::ChartLegendExpansion_HIGH;
- }
+ aLegendSize.Width = static_cast<sal_Int32>(::rtl::math::approxCeil( aRelativeSize.Primary * rPageSize.Width ));
+ aLegendSize.Height = static_cast<sal_Int32>(::rtl::math::approxCeil( aRelativeSize.Secondary * rPageSize.Height ));
+ bCustom = true;
+ }
+ else
+ {
+ eExpansion = css::chart::ChartLegendExpansion_HIGH;
}
- xLegendProp->getPropertyValue("AnchorPosition") >>= eLegendPosition;
- lcl_getProperties( xLegendProp, aLineFillProperties, aTextProperties, rPageSize );
}
+ m_xLegend->getPropertyValue("AnchorPosition") >>= eLegendPosition;
+ lcl_getProperties( m_xLegend, aLineFillProperties, aTextProperties, rPageSize );
// create entries
- double fViewFontSize = lcl_CalcViewFontSize( xLegendProp, rPageSize );//todo
+ double fViewFontSize = lcl_CalcViewFontSize( m_xLegend, rPageSize );//todo
// #i109336# Improve auto positioning in chart
sal_Int32 nSymbolHeight = static_cast< sal_Int32 >( fViewFontSize * 0.6 );
sal_Int32 nSymbolWidth = nSymbolHeight;
@@ -985,13 +1000,13 @@ void VLegend::createShapes(
if (pLegendEntryProvider)
{
std::vector<ViewLegendEntry> aNewEntries = pLegendEntryProvider->createLegendEntries(
- aMaxSymbolExtent, eLegendPosition, xLegendProp,
+ aMaxSymbolExtent, eLegendPosition, m_xLegend,
xLegendContainer, m_xContext, mrModel);
aViewEntries.insert( aViewEntries.end(), aNewEntries.begin(), aNewEntries.end() );
}
}
- bool bSymbolsLeftSide = lcl_shouldSymbolsBePlacedOnTheLeftSide( xLegendProp, m_nDefaultWritingMode );
+ bool bSymbolsLeftSide = lcl_shouldSymbolsBePlacedOnTheLeftSide( m_xLegend, m_nDefaultWritingMode );
uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider( mrModel.getDataProvider(), uno::UNO_QUERY );
bool bIsPivotChart = xPivotTableDataProvider.is();
@@ -1055,18 +1070,17 @@ void VLegend::changePosition(
{
// determine position and alignment depending on default position
awt::Size aLegendSize = m_xShape->getSize();
- Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY_THROW );
chart2::RelativePosition aRelativePosition;
bool bDefaultLegendSize = rDefaultLegendSize.Width != 0 || rDefaultLegendSize.Height != 0;
bool bAutoPosition =
- ! (xLegendProp->getPropertyValue( "RelativePosition") >>= aRelativePosition);
+ ! (m_xLegend->getPropertyValue( "RelativePosition") >>= aRelativePosition);
LegendPosition ePos = LegendPosition_LINE_END;
- xLegendProp->getPropertyValue( "AnchorPosition") >>= ePos;
+ m_xLegend->getPropertyValue( "AnchorPosition") >>= ePos;
bool bOverlay = false;
- xLegendProp->getPropertyValue("Overlay") >>= bOverlay;
+ m_xLegend->getPropertyValue("Overlay") >>= bOverlay;
//calculate position
if( bAutoPosition )
{
diff --git a/chart2/source/view/main/VLegend.hxx b/chart2/source/view/main/VLegend.hxx
index c8931ce9f931..7e8435a7c297 100644
--- a/chart2/source/view/main/VLegend.hxx
+++ b/chart2/source/view/main/VLegend.hxx
@@ -35,12 +35,13 @@ namespace com::sun::star::uno { class XComponentContext; }
namespace chart
{
+class Legend;
class LegendEntryProvider;
class VLegend
{
public:
- VLegend( const css::uno::Reference< css::chart2::XLegend > & xLegend,
+ VLegend( const rtl::Reference< ::chart::Legend > & xLegend,
const css::uno::Reference< css::uno::XComponentContext > & xContext,
std::vector< LegendEntryProvider* >&& rLegendEntryProviderList,
const rtl::Reference<SvxShapeGroupAnyD>& xTargetPage,
@@ -68,10 +69,12 @@ public:
static bool isVisible(
const css::uno::Reference< css::chart2::XLegend > & xLegend );
+ static bool isVisible(
+ const rtl::Reference< ::chart::Legend > & xLegend );
private:
rtl::Reference<SvxShapeGroupAnyD> m_xTarget;
- css::uno::Reference< css::chart2::XLegend > m_xLegend;
+ rtl::Reference<::chart::Legend> m_xLegend;
rtl::Reference< SvxShapeGroup > m_xShape;
ChartModel& mrModel;
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 90ff78ab4dc9..1d2c635eed62 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -1036,6 +1036,7 @@ chart2/source/inc/FormattedStringHelper.hxx
chart2/source/inc/InternalData.hxx
chart2/source/inc/InternalDataProvider.hxx
chart2/source/inc/LabeledDataSequence.hxx
+chart2/source/inc/Legend.hxx
chart2/source/inc/LegendHelper.hxx
chart2/source/inc/LifeTime.hxx
chart2/source/inc/LinePropertiesHelper.hxx
@@ -1100,7 +1101,6 @@ chart2/source/model/main/FormattedString.hxx
chart2/source/model/main/GridProperties.cxx
chart2/source/model/main/GridProperties.hxx
chart2/source/model/main/Legend.cxx
-chart2/source/model/main/Legend.hxx
chart2/source/model/main/PageBackground.cxx
chart2/source/model/main/PageBackground.hxx
chart2/source/model/main/PolarCoordinateSystem.cxx