summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-03-16 09:32:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-03-21 08:44:53 +0000
commitdf12a23157f4515ba5e78c0bd293dfd1609de668 (patch)
treeda9345306eb70127d8850e29abe93fb067093ee3
parenttdf#154232 signal_drag_begin callback can delete current GtkTargetList (diff)
downloadcore-df12a23157f4515ba5e78c0bd293dfd1609de668.tar.gz
core-df12a23157f4515ba5e78c0bd293dfd1609de668.zip
move getVertical/setVertical inside chart2::Diagram
Change-Id: Ide512e20fea94b1d7d038290d1c833f1d8cf42ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149164 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx6
-rw-r--r--chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx2
-rw-r--r--chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx2
-rw-r--r--chart2/source/inc/Diagram.hxx15
-rw-r--r--chart2/source/inc/DiagramHelper.hxx16
-rw-r--r--chart2/source/model/main/Diagram.cxx85
-rw-r--r--chart2/source/model/template/BarChartTypeTemplate.cxx6
-rw-r--r--chart2/source/model/template/StockChartTypeTemplate.cxx2
-rw-r--r--chart2/source/tools/DiagramHelper.cxx94
-rw-r--r--chart2/source/tools/TitleHelper.cxx4
-rw-r--r--chart2/source/view/main/ChartView.cxx4
11 files changed, 113 insertions, 123 deletions
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index 657751ed3c23..7cc7c57e2862 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -1385,9 +1385,9 @@ void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Re
bool bFound = false;
bool bAmbiguous = false;
- bool bOldVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ bool bOldVertical = xDiagram->getVertical( bFound, bAmbiguous );
if( bFound && ( bOldVertical != bNewVertical || bAmbiguous ) )
- DiagramHelper::setVertical( xDiagram, bNewVertical );
+ xDiagram->setVertical( bNewVertical );
}
Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
@@ -1397,7 +1397,7 @@ Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XProperty
{
bool bFound = false;
bool bAmbiguous = false;
- bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ bool bVertical = xDiagram->getVertical( bFound, bAmbiguous );
if( bFound )
m_aOuterValue <<= bVertical;
}
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index b0155174cd94..f415cd194386 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -242,7 +242,7 @@ DataPointItemConverter::DataPointItemConverter(
rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) );
bool bFound = false;
bool bAmbiguous = false;
- bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ bool bSwapXAndY = xDiagram->getVertical( bFound, bAmbiguous );
m_aAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements( xChartType, bSwapXAndY, xSeries );
m_bForbidPercentValue = ChartTypeHelper::getAxisType( xChartType, 0 ) != AxisType::CATEGORY;
diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
index 929f1c7c48b9..b4097d21da41 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -215,7 +215,7 @@ TextLabelItemConverter::TextLabelItemConverter(
rtl::Reference< ChartType > xChartType(xDiagram->getChartTypeOfSeries(xSeries));
bool bFound = false;
bool bAmbiguous = false;
- bool bSwapXAndY = DiagramHelper::getVertical(xDiagram, bFound, bAmbiguous);
+ bool bSwapXAndY = xDiagram->getVertical(bFound, bAmbiguous);
maAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements(xChartType, bSwapXAndY, xSeries);
mbForbidPercentValue = ChartTypeHelper::getAxisType(xChartType, 0) != AxisType::CATEGORY;
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index 9ff0f94bb020..c24d10af9d83 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -300,6 +300,21 @@ public:
*/
void setStackMode(StackMode eStackMode);
+
+ /** Sets the "SwapXAndYAxis" property at all coordinate systems found in the
+ given diagram.
+
+ "vertical==true" for bar charts, "vertical==false" for column charts
+ */
+ void setVertical( bool bVertical );
+
+ /** Gets the "SwapXAndYAxis" property at all coordinate systems found in the
+ given diagram.
+
+ "vertical==true" for bar charts, "vertical==false" for column charts
+ */
+ bool getVertical( bool& rbOutFoundResult, bool& rbOutAmbiguousResult );
+
private:
// ____ XModifyListener ____
virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx
index 35f1de7e9eaf..bf46ed08025a 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -72,22 +72,6 @@ public:
const rtl::Reference< ::chart::Diagram > & xDiagram,
const rtl::Reference< ::chart::ChartTypeManager > & xChartTypeManager);
- /** Sets the "SwapXAndYAxis" property at all coordinate systems found in the
- given diagram.
-
- "vertical==true" for bar charts, "vertical==false" for column charts
- */
- static void setVertical( const rtl::Reference< ::chart::Diagram > & xDiagram,
- bool bVertical );
-
- /** Gets the "SwapXAndYAxis" property at all coordinate systems found in the
- given diagram.
-
- "vertical==true" for bar charts, "vertical==false" for column charts
- */
- static bool getVertical( const rtl::Reference< ::chart::Diagram > & xDiagram,
- bool& rbOutFoundResult, bool& rbOutAmbiguousResult );
-
/** 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/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index d2068529f93d..5d6f84adbb86 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -55,6 +55,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <o3tl/safeint.hxx>
+#include <rtl/math.hxx>
#include <algorithm>
#include <utility>
@@ -1536,6 +1537,90 @@ StackMode Diagram::getStackMode( bool& rbFound, bool& rbAmbiguous )
return eGlobalStackMode;
}
+void Diagram::setVertical( bool bVertical /* = true */ )
+{
+ try
+ {
+ uno::Any aValue;
+ aValue <<= bVertical;
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ bool bChanged = false;
+ bool bOldSwap = false;
+ if( !(xCooSys->getPropertyValue("SwapXAndYAxis") >>= bOldSwap)
+ || bVertical != bOldSwap )
+ bChanged = true;
+
+ if( bChanged )
+ xCooSys->setPropertyValue("SwapXAndYAxis", aValue);
+
+ const sal_Int32 nDimensionCount = xCooSys->getDimension();
+ sal_Int32 nDimIndex = 0;
+ for (nDimIndex=0; nDimIndex < nDimensionCount; ++nDimIndex)
+ {
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nDimIndex);
+ for (sal_Int32 nI = 0; nI <= nMaximumScaleIndex; ++nI)
+ {
+ rtl::Reference<Axis> xAxis = xCooSys->getAxisByDimension2(nDimIndex,nI);
+ if (!xAxis.is())
+ continue;
+
+ //adapt title rotation only when axis swapping has changed
+ if (!bChanged)
+ continue;
+
+ Reference< beans::XPropertySet > xTitleProps( xAxis->getTitleObject(), uno::UNO_QUERY );
+ if (!xTitleProps.is())
+ continue;
+
+ double fAngleDegree = 0.0;
+ xTitleProps->getPropertyValue("TextRotation") >>= fAngleDegree;
+ if (fAngleDegree != 0.0 &&
+ !rtl::math::approxEqual(fAngleDegree, 90.0))
+ continue;
+
+ double fNewAngleDegree = 0.0;
+ if( !bVertical && nDimIndex == 1 )
+ fNewAngleDegree = 90.0;
+ else if( bVertical && nDimIndex == 0 )
+ fNewAngleDegree = 90.0;
+
+ xTitleProps->setPropertyValue("TextRotation", uno::Any(fNewAngleDegree));
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+bool Diagram::getVertical( bool& rbFound, bool& rbAmbiguous )
+{
+ bool bValue = false;
+ rbFound = false;
+ rbAmbiguous = false;
+
+ for (rtl::Reference<BaseCoordinateSystem> const & coords : getBaseCoordinateSystems())
+ {
+ bool bCurrent = false;
+ if (coords->getPropertyValue("SwapXAndYAxis") >>= bCurrent)
+ {
+ if (!rbFound)
+ {
+ bValue = bCurrent;
+ rbFound = true;
+ }
+ else if (bCurrent != bValue)
+ {
+ // ambiguous -> choose always first found
+ rbAmbiguous = true;
+ }
+ }
+ }
+ return bValue;
+}
} // namespace chart
diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx
index 9cadbadb8980..54f4f155186b 100644
--- a/chart2/source/model/template/BarChartTypeTemplate.cxx
+++ b/chart2/source/model/template/BarChartTypeTemplate.cxx
@@ -170,7 +170,7 @@ bool BarChartTypeTemplate::matchesTemplate2(
{
bool bFound = false;
bool bAmbiguous = false;
- bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ bool bVertical = xDiagram->getVertical( bFound, bAmbiguous );
if( m_eBarDirection == HORIZONTAL )
bResult = bVertical;
else if( m_eBarDirection == VERTICAL )
@@ -272,7 +272,7 @@ void BarChartTypeTemplate::resetStyles2(
}
}
- DiagramHelper::setVertical( xDiagram, false );
+ xDiagram->setVertical( false );
}
void BarChartTypeTemplate::createCoordinateSystems(
@@ -280,7 +280,7 @@ void BarChartTypeTemplate::createCoordinateSystems(
{
ChartTypeTemplate::createCoordinateSystems( xDiagram );
- DiagramHelper::setVertical( xDiagram, m_eBarDirection == HORIZONTAL );
+ xDiagram->setVertical( m_eBarDirection == HORIZONTAL );
}
IMPLEMENT_FORWARD_XINTERFACE2( BarChartTypeTemplate, ChartTypeTemplate, OPropertySet )
diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx
index 24662ebdd57a..e05981bebbeb 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.cxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.cxx
@@ -238,7 +238,7 @@ void StockChartTypeTemplate::resetStyles2(
}
}
- DiagramHelper::setVertical( xDiagram, false );
+ xDiagram->setVertical( false );
}
rtl::Reference< ChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 40dc56c2dfbe..299caca7cb81 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -113,100 +113,6 @@ DiagramHelper::tTemplateWithServiceName
return aResult;
}
-void DiagramHelper::setVertical(
- const rtl::Reference< Diagram > & xDiagram,
- bool bVertical /* = true */ )
-{
- try
- {
- if (!xDiagram.is())
- return;
-
- uno::Any aValue;
- aValue <<= bVertical;
- for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : xDiagram->getBaseCoordinateSystems() )
- {
- bool bChanged = false;
- bool bOldSwap = false;
- if( !(xCooSys->getPropertyValue("SwapXAndYAxis") >>= bOldSwap)
- || bVertical != bOldSwap )
- bChanged = true;
-
- if( bChanged )
- xCooSys->setPropertyValue("SwapXAndYAxis", aValue);
-
- const sal_Int32 nDimensionCount = xCooSys->getDimension();
- sal_Int32 nDimIndex = 0;
- for (nDimIndex=0; nDimIndex < nDimensionCount; ++nDimIndex)
- {
- const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nDimIndex);
- for (sal_Int32 nI = 0; nI <= nMaximumScaleIndex; ++nI)
- {
- rtl::Reference<Axis> xAxis = xCooSys->getAxisByDimension2(nDimIndex,nI);
- if (!xAxis.is())
- continue;
-
- //adapt title rotation only when axis swapping has changed
- if (!bChanged)
- continue;
-
- Reference< beans::XPropertySet > xTitleProps( xAxis->getTitleObject(), uno::UNO_QUERY );
- if (!xTitleProps.is())
- continue;
-
- double fAngleDegree = 0.0;
- xTitleProps->getPropertyValue("TextRotation") >>= fAngleDegree;
- if (fAngleDegree != 0.0 &&
- !rtl::math::approxEqual(fAngleDegree, 90.0))
- continue;
-
- double fNewAngleDegree = 0.0;
- if( !bVertical && nDimIndex == 1 )
- fNewAngleDegree = 90.0;
- else if( bVertical && nDimIndex == 0 )
- fNewAngleDegree = 90.0;
-
- xTitleProps->setPropertyValue("TextRotation", uno::Any(fNewAngleDegree));
- }
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-bool DiagramHelper::getVertical( const rtl::Reference< Diagram > & xDiagram,
- bool& rbFound, bool& rbAmbiguous )
-{
- bool bValue = false;
- rbFound = false;
- rbAmbiguous = false;
-
- if (!xDiagram.is())
- return false;
-
- for (rtl::Reference<BaseCoordinateSystem> const & coords : xDiagram->getBaseCoordinateSystems())
- {
- bool bCurrent = false;
- if (coords->getPropertyValue("SwapXAndYAxis") >>= bCurrent)
- {
- if (!rbFound)
- {
- bValue = bCurrent;
- rbFound = true;
- }
- else if (bCurrent != bValue)
- {
- // ambiguous -> choose always first found
- rbAmbiguous = true;
- }
- }
- }
- return bValue;
-}
-
StackMode DiagramHelper::getStackModeFromChartType(
const rtl::Reference< ChartType > & xChartType,
bool& rbFound, bool& rbAmbiguous,
diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx
index 0a7b76c6e5dd..cbc3543dc78e 100644
--- a/chart2/source/tools/TitleHelper.cxx
+++ b/chart2/source/tools/TitleHelper.cxx
@@ -50,7 +50,7 @@ uno::Reference< XTitled > lcl_getTitleParentFromDiagram(
nTitleIndex == TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION )
{
bool bDummy = false;
- bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy );
+ bool bIsVertical = xDiagram && xDiagram->getVertical( bDummy, bDummy );
if( nTitleIndex == TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION )
nTitleIndex = bIsVertical ? TitleHelper::X_AXIS_TITLE : TitleHelper::Y_AXIS_TITLE;
@@ -269,7 +269,7 @@ uno::Reference< XTitle > TitleHelper::createTitle(
try
{
bool bDummy = false;
- bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy );
+ bool bIsVertical = xDiagram->getVertical( bDummy, bDummy );
if( (!bIsVertical && eTitleType == TitleHelper::Y_AXIS_TITLE)
|| (bIsVertical && eTitleType == TitleHelper::X_AXIS_TITLE)
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 2e1eb7b7a398..db742930ce29 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1931,7 +1931,7 @@ void ChartView::createShapes2D( const awt::Size& rPageSize )
return;
bool bDummy = false;
- bool bIsVertical = DiagramHelper::getVertical(xDiagram, bDummy, bDummy);
+ bool bIsVertical = xDiagram && xDiagram->getVertical(bDummy, bDummy);
if (getAvailablePosAndSizeForDiagram(aParam, rPageSize, xDiagram))
{
@@ -2021,7 +2021,7 @@ bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::
return false;
bool bDummy = false;
- bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy );
+ bool bIsVertical = xDiagram && xDiagram->getVertical( bDummy, bDummy );
if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension ) )
rParam.mpVTitleSecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, mxRootShape, mrChartModel