summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2020-11-23 15:05:24 +0100
committerLászló Németh <nemeth@numbertext.org>2020-11-24 10:44:54 +0100
commit21620f9d2f50e66dffc45a5afb539edb8d54434c (patch)
treecb1f5ebdefb9053ac987b058f42c6094420249bc /oox
parent3be5e428d669accd841949662d601a6f6e1cdb3f (diff)
tdf#138194 Chart OOXML import: set text break to true
of rotated category axis label, if the rotation is 90 or 270 degree and the inner size of the chart is not fixed. Change-Id: I02e1fd940af8a277435aa46d4ad93a42b6723710 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106422 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/chart/axisconverter.hxx2
-rw-r--r--oox/inc/drawingml/chart/objectformatter.hxx5
-rw-r--r--oox/source/drawingml/chart/axisconverter.cxx22
-rw-r--r--oox/source/drawingml/chart/objectformatter.cxx20
-rw-r--r--oox/source/drawingml/chart/plotareaconverter.cxx22
5 files changed, 32 insertions, 39 deletions
diff --git a/oox/inc/drawingml/chart/axisconverter.hxx b/oox/inc/drawingml/chart/axisconverter.hxx
index 6cebc008c3fd..6efa3af6262e 100644
--- a/oox/inc/drawingml/chart/axisconverter.hxx
+++ b/oox/inc/drawingml/chart/axisconverter.hxx
@@ -60,7 +60,7 @@ public:
void convertFromModel(
const css::uno::Reference<css::chart2::XCoordinateSystem>& rxCoordSystem,
RefVector<TypeGroupConverter>& rTypeGroups, const AxisModel* pCrossingAxis,
- sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx );
+ sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx, bool bUseFixedInnerSize );
};
diff --git a/oox/inc/drawingml/chart/objectformatter.hxx b/oox/inc/drawingml/chart/objectformatter.hxx
index 06cece4fe02c..9498f0484d50 100644
--- a/oox/inc/drawingml/chart/objectformatter.hxx
+++ b/oox/inc/drawingml/chart/objectformatter.hxx
@@ -142,11 +142,6 @@ public:
/** Returns true, if the passed shape properties have automatic fill mode. */
static bool isAutomaticFill( const ModelRef< Shape >& rxShapeProp );
- /** Returns true, if the X Axis label rotation is 0 degree. */
- static bool getTextRotation(
- const ModelRef< TextBody >& rxTextProp,
- sal_Int32 nDefaultRotation = 0 );
-
private:
std::shared_ptr< ObjectFormatterData > mxData;
};
diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx
index fa506e5a04dc..8f062d001eeb 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -137,9 +137,10 @@ AxisConverter::~AxisConverter()
{
}
-void AxisConverter::convertFromModel(
- const Reference< XCoordinateSystem >& rxCoordSystem,
- RefVector<TypeGroupConverter>& rTypeGroups, const AxisModel* pCrossingAxis, sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx )
+void AxisConverter::convertFromModel(const Reference<XCoordinateSystem>& rxCoordSystem,
+ RefVector<TypeGroupConverter>& rTypeGroups,
+ const AxisModel* pCrossingAxis, sal_Int32 nAxesSetIdx,
+ sal_Int32 nAxisIdx, bool bUseFixedInnerSize)
{
if (rTypeGroups.empty())
return;
@@ -269,10 +270,17 @@ void AxisConverter::convertFromModel(
}
else
{
- // do not overlap text unless all labels are visible
- aAxisProp.setProperty( PROP_TextOverlap, mrModel.mnTickLabelSkip == 1 );
- // do not break text into several lines unless the rotation is 0 degree
- aAxisProp.setProperty( PROP_TextBreak, ObjectFormatter::getTextRotation( mrModel.mxTextProp ) );
+ aAxisProp.setProperty(PROP_TextOverlap, true);
+ /* do not break text into several lines unless the rotation is 0 degree,
+ or the rotation is 90 degree and the inner size of the chart is not fixed,
+ or the rotation is 270 degree and the inner size of the chart is not fixed */
+ bool bTextBreak = true;
+ double fRotationAngle = 0.0;
+ if (aAxisProp.getProperty(fRotationAngle, PROP_TextRotation)
+ && fRotationAngle != 0.0)
+ bTextBreak = !bUseFixedInnerSize
+ && (fRotationAngle == 90.0 || fRotationAngle == 270.0);
+ aAxisProp.setProperty(PROP_TextBreak, bTextBreak);
// do not stagger labels in two lines
aAxisProp.setProperty( PROP_ArrangeOrder, cssc::ChartAxisArrangeOrderType_SIDE_BY_SIDE );
//! TODO #i58731# show n-th category
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index fd580742c97a..d3b274e1fa3d 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -1139,26 +1139,6 @@ bool ObjectFormatter::isAutomaticFill( const ModelRef< Shape >& rxShapeProp )
return !rxShapeProp || !rxShapeProp->getFillProperties().moFillType.has();
}
-bool ObjectFormatter::getTextRotation( const ModelRef< TextBody >& rxTextProp, sal_Int32 nDefaultRotation )
-{
- if( rxTextProp.is() )
- {
- double fAnglevalue = static_cast< double >( rxTextProp->getTextProperties().moRotation.get( nDefaultRotation ) );
- if( fAnglevalue < -5400000.0 || fAnglevalue > 5400000.0 || fAnglevalue == 0.0 )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return true;
- }
-}
-
} // namespace oox
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx
index 8a8a721a1fe9..80ea37c57d30 100644
--- a/oox/source/drawingml/chart/plotareaconverter.cxx
+++ b/oox/source/drawingml/chart/plotareaconverter.cxx
@@ -70,7 +70,8 @@ public:
const Reference< XDiagram >& rxDiagram,
View3DModel& rView3DModel,
sal_Int32 nAxesSetIdx,
- bool bSupportsVaryColorsByPoint );
+ bool bSupportsVaryColorsByPoint,
+ bool bUseFixedInnerSize );
/** Returns the automatic chart title if the axes set contains only one series. */
const OUString& getAutomaticTitle() const { return maAutoTitle; }
@@ -105,7 +106,8 @@ ModelRef< AxisModel > lclGetOrCreateAxis( const AxesSetModel::AxisMap& rFromAxes
}
void AxesSetConverter::convertFromModel( const Reference< XDiagram >& rxDiagram,
- View3DModel& rView3DModel, sal_Int32 nAxesSetIdx, bool bSupportsVaryColorsByPoint )
+ View3DModel& rView3DModel, sal_Int32 nAxesSetIdx,
+ bool bSupportsVaryColorsByPoint, bool bUseFixedInnerSize)
{
// create type group converter objects for all type groups
typedef RefVector< TypeGroupConverter > TypeGroupConvVector;
@@ -165,15 +167,18 @@ void AxesSetConverter::convertFromModel( const Reference< XDiagram >& rxDiagram,
ModelRef< AxisModel > xYAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Y_AXIS, C_TOKEN( valAx ), bMSO2007Doc );
AxisConverter aXAxisConv( *this, *xXAxis );
- aXAxisConv.convertFromModel( xCoordSystem, aTypeGroups, xYAxis.get(), nAxesSetIdx, API_X_AXIS );
+ aXAxisConv.convertFromModel(xCoordSystem, aTypeGroups, xYAxis.get(), nAxesSetIdx,
+ API_X_AXIS, bUseFixedInnerSize);
AxisConverter aYAxisConv( *this, *xYAxis );
- aYAxisConv.convertFromModel( xCoordSystem, aTypeGroups, xXAxis.get(), nAxesSetIdx, API_Y_AXIS );
+ aYAxisConv.convertFromModel(xCoordSystem, aTypeGroups, xXAxis.get(), nAxesSetIdx,
+ API_Y_AXIS, bUseFixedInnerSize);
if( rFirstTypeGroup.isDeep3dChart() )
{
ModelRef< AxisModel > xZAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Z_AXIS, C_TOKEN( serAx ), bMSO2007Doc );
AxisConverter aZAxisConv( *this, *xZAxis );
- aZAxisConv.convertFromModel( xCoordSystem, aTypeGroups, nullptr, nAxesSetIdx, API_Z_AXIS );
+ aZAxisConv.convertFromModel(xCoordSystem, aTypeGroups, nullptr, nAxesSetIdx,
+ API_Z_AXIS, bUseFixedInnerSize);
}
// convert all chart type groups, this converts all series data and formatting
@@ -420,10 +425,15 @@ void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel )
&& aAxesSets[0]->maAxes[ API_Y_AXIS ]->mnAxisId != rValAxisIds[0] ) ? 1 : 0;
sal_Int32 nAxesSetIdx = nStartAxesSetIdx;
+ bool bUseFixedInnerSize = false;
+ if (mrModel.mxLayout && !mrModel.mxLayout->mbAutoLayout)
+ bUseFixedInnerSize = mrModel.mxLayout->mnTarget == XML_inner;
+
for (auto const& axesSet : aAxesSets)
{
AxesSetConverter aAxesSetConv(*this, *axesSet);
- aAxesSetConv.convertFromModel( xDiagram, rView3DModel, nAxesSetIdx, bSupportsVaryColorsByPoint );
+ aAxesSetConv.convertFromModel(xDiagram, rView3DModel, nAxesSetIdx,
+ bSupportsVaryColorsByPoint, bUseFixedInnerSize);
if(nAxesSetIdx == nStartAxesSetIdx)
{
maAutoTitle = aAxesSetConv.getAutomaticTitle();