summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2020-11-23 15:05:24 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2020-11-24 15:01:15 +0100
commit189a12a1d4d96b8656bd1a0588e1bb7ddd167f40 (patch)
treeca50690c4f3c9eab211286b4cac9078e6e16cd4a
parent3e8cdf07e8c987ebf43a1271ae26ac38f13c7e33 (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> (cherry picked from commit 21620f9d2f50e66dffc45a5afb539edb8d54434c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106446 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--compilerplugins/clang/constantparam.booleans.results4
-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
-rw-r--r--sw/qa/extras/layout/data/xaxis-labelbreak.docxbin0 -> 27222 bytes
-rw-r--r--sw/qa/extras/layout/layout2.cxx17
8 files changed, 49 insertions, 43 deletions
diff --git a/compilerplugins/clang/constantparam.booleans.results b/compilerplugins/clang/constantparam.booleans.results
index bf25ffeb07a3..1a183059a193 100644
--- a/compilerplugins/clang/constantparam.booleans.results
+++ b/compilerplugins/clang/constantparam.booleans.results
@@ -1930,10 +1930,6 @@ o3tl/qa/cow_wrapper_clients.hxx:41
void o3tltests::cow_wrapper_client1::cow_wrapper_client1(int)
int nVal
1
-oox/inc/drawingml/chart/objectformatter.hxx:146
- _Bool oox::drawingml::chart::ObjectFormatter::getTextRotation(const class oox::drawingml::chart::ModelRef<class oox::drawingml::TextBody> &,int)
- int nDefaultRotation
- 0
oox/inc/drawingml/chart/typegroupconverter.hxx:153
void oox::drawingml::chart::TypeGroupConverter::convertLineSmooth(class oox::PropertySet &,_Bool) const
_Bool bOoxSmooth
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();
diff --git a/sw/qa/extras/layout/data/xaxis-labelbreak.docx b/sw/qa/extras/layout/data/xaxis-labelbreak.docx
new file mode 100644
index 000000000000..6f34a8919961
--- /dev/null
+++ b/sw/qa/extras/layout/data/xaxis-labelbreak.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 7fd1ec915c16..4223724a2ab5 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -700,6 +700,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHorizontal_multilevel)
CPPUNIT_ASSERT_DOUBLES_EQUAL(7945, nYposition, 20);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194)
+{
+ SwDoc* pDoc = createDoc("xaxis-labelbreak.docx");
+ SwDocShell* pShell = pDoc->GetDocShell();
+
+ // Dump the rendering of the first page as an XML file.
+ std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+ xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 8
+ // - Actual : 7
+ // i.e. the X axis label flowed out of chart area.
+ assertXPath(pXmlDoc, "//textarray", 8);
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124796)
{
SwDoc* pDoc = createDoc("tdf124796.odt");