[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - chart2/source sw/qa
Tünde Tóth (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jan 5 15:15:07 UTC 2021
chart2/source/view/main/ChartView.cxx | 10 +++++++++-
chart2/source/view/main/VTitle.cxx | 15 ++++++++++++---
chart2/source/view/main/VTitle.hxx | 3 ++-
sw/qa/extras/layout/data/tdf134146.docx |binary
sw/qa/extras/layout/layout.cxx | 17 +++++++++++++++++
5 files changed, 40 insertions(+), 5 deletions(-)
New commits:
commit 4426363f9281a7bab350c2d7a0bab98a9b3923c3
Author: Tünde Tóth <tundeth at gmail.com>
AuthorDate: Wed Jul 1 15:48:19 2020 +0200
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Tue Jan 5 16:14:31 2021 +0100
tdf#134146 Chart OOXML import: break long horizontal Y axis title
Workaround to handle long (near) horizontal Y axis titles,
like MSO does.
See commit 17f131fcb3f534792a3b2ec6048d03fb54b55eb1
(tdf#134235 Chart OOXML import: fix long chart title).
Change-Id: I215aaa8e2ca18920e2b7ca5761c5bed7e8d19663
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97631
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 23b73bc02536455df75438e19b5c70bacc9aa700)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108721
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 4b6b1fa9b48f..bfc35bbe24e4 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2138,15 +2138,23 @@ std::shared_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType
//create title
awt::Size aTextMaxWidth(rPageSize.Width, rPageSize.Height);
+ bool bYAxisTitle = false;
if (eType == TitleHelper::MAIN_TITLE || eType == TitleHelper::SUB_TITLE)
{
aTextMaxWidth.Width = static_cast<sal_Int32>(rPageSize.Width * 0.8);
aTextMaxWidth.Height = static_cast<sal_Int32>(rPageSize.Height * 0.5);
}
+ else if (eType == TitleHelper::Y_AXIS_TITLE || eType == TitleHelper::SECONDARY_Y_AXIS_TITLE
+ || eType == TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION)
+ {
+ aTextMaxWidth.Width = static_cast<sal_Int32>(rPageSize.Width * 0.2);
+ aTextMaxWidth.Height = static_cast<sal_Int32>(rPageSize.Height * 0.8);
+ bYAxisTitle = true;
+ }
apVTitle = std::make_shared<VTitle>(xTitle);
OUString aCID = ObjectIdentifier::createClassifiedIdentifierForObject(xTitle, rModel);
apVTitle->init(xPageShapes, xShapeFactory, aCID);
- apVTitle->createShapes(awt::Point(0, 0), rPageSize, aTextMaxWidth);
+ apVTitle->createShapes(awt::Point(0, 0), rPageSize, aTextMaxWidth, bYAxisTitle);
awt::Size aTitleUnrotatedSize = apVTitle->getUnrotatedSize();
awt::Size aTitleSize = apVTitle->getFinalSize();
diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx
index 53e214f76999..f0befe954659 100644
--- a/chart2/source/view/main/VTitle.cxx
+++ b/chart2/source/view/main/VTitle.cxx
@@ -100,7 +100,8 @@ void VTitle::changePosition( const awt::Point& rPos )
void VTitle::createShapes(
const awt::Point& rPos
, const awt::Size& rReferenceSize
- , const awt::Size& rTextMaxWidth )
+ , const awt::Size& rTextMaxWidth
+ , bool bYAxisTitle )
{
if(!m_xTitle.is())
return;
@@ -126,8 +127,16 @@ void VTitle::createShapes(
}
sal_Int32 nTextMaxWidth;
- if (m_fRotationAngleDegree <= 15.0 || m_fRotationAngleDegree >= 345.0
- || (m_fRotationAngleDegree >= 165.0 && m_fRotationAngleDegree <= 195.0))
+ if (bYAxisTitle)
+ {
+ if (m_fRotationAngleDegree < 75.0 || m_fRotationAngleDegree > 285.0
+ || (m_fRotationAngleDegree > 105.0 && m_fRotationAngleDegree < 255.0))
+ nTextMaxWidth = rTextMaxWidth.Width;
+ else
+ nTextMaxWidth = rTextMaxWidth.Height;
+ }
+ else if (m_fRotationAngleDegree <= 15.0 || m_fRotationAngleDegree >= 345.0
+ || (m_fRotationAngleDegree >= 165.0 && m_fRotationAngleDegree <= 195.0))
nTextMaxWidth = rTextMaxWidth.Width;
else
nTextMaxWidth = rTextMaxWidth.Height;
diff --git a/chart2/source/view/main/VTitle.hxx b/chart2/source/view/main/VTitle.hxx
index 261458025956..9fb0e905fa8a 100644
--- a/chart2/source/view/main/VTitle.hxx
+++ b/chart2/source/view/main/VTitle.hxx
@@ -45,7 +45,8 @@ public:
void createShapes( const css::awt::Point& rPos
, const css::awt::Size& rReferenceSize
- , const css::awt::Size& nTextMaxWidth );
+ , const css::awt::Size& nTextMaxWidth
+ , bool bYAxisTitle );
double getRotationAnglePi() const;
css::awt::Size getUnrotatedSize() const;
diff --git a/sw/qa/extras/layout/data/tdf134146.docx b/sw/qa/extras/layout/data/tdf134146.docx
new file mode 100644
index 000000000000..9fe1bc06196f
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf134146.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index acf877c323bf..b0ac08cac4c1 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2965,6 +2965,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf134235)
assertXPath(pXmlDoc, "//textarray", 14);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf134146)
+{
+ SwDoc* pDoc = createDoc("tdf134146.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: 14
+ // - Actual : 13
+ // i.e. the Y axis title didn't break to multilple lines.
+ assertXPath(pXmlDoc, "//textarray", 14);
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116925)
{
SwDoc* pDoc = createDoc("tdf116925.docx");
More information about the Libreoffice-commits
mailing list