[Libreoffice-commits] core.git: chart2/source sw/qa
Tünde Tóth (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 29 10:53:32 UTC 2020
chart2/source/view/inc/ShapeFactory.hxx | 2 +-
chart2/source/view/main/ChartView.cxx | 8 +++++++-
chart2/source/view/main/ShapeFactory.cxx | 4 ++--
chart2/source/view/main/VTitle.cxx | 14 +++++++++++---
chart2/source/view/main/VTitle.hxx | 3 ++-
sw/qa/extras/layout/data/tdf134235.docx |binary
sw/qa/extras/layout/layout.cxx | 17 +++++++++++++++++
7 files changed, 40 insertions(+), 8 deletions(-)
New commits:
commit 17f131fcb3f534792a3b2ec6048d03fb54b55eb1
Author: Tünde Tóth <tundeth at gmail.com>
AuthorDate: Thu Jun 25 10:43:58 2020 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Mon Jun 29 12:52:44 2020 +0200
tdf#134235 Chart OOXML import: fix long chart title
Workaround to handle long (sub)titles which resulted
broken charts.
See commit 96a29c12a9d8734c9d2a812f38fc6654b5df9c48
(tdf#101322 Chart OOXML Export: fix missing subtitle).
Change-Id: I22bb4699bdda8dea5f31c715cc1f439085a0718f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97092
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx
index 02faf45b8716..7a698e4b9d87 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -247,7 +247,7 @@ public:
const css::awt::Point& rPosition,
css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString,
const css::uno::Reference< css::beans::XPropertySet > & xTextProperties,
- double nRotation, const OUString& aName );
+ double nRotation, const OUString& aName, sal_Int32 nTextMaxWidth );
css::uno::Reference< css::drawing::XShape >
createInvisibleRectangle(
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index a5e0ab5da984..4b6b1fa9b48f 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2137,10 +2137,16 @@ std::shared_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType
return apVTitle;
//create title
+ awt::Size aTextMaxWidth(rPageSize.Width, rPageSize.Height);
+ 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);
+ }
apVTitle = std::make_shared<VTitle>(xTitle);
OUString aCID = ObjectIdentifier::createClassifiedIdentifierForObject(xTitle, rModel);
apVTitle->init(xPageShapes, xShapeFactory, aCID);
- apVTitle->createShapes(awt::Point(0,0), rPageSize);
+ apVTitle->createShapes(awt::Point(0, 0), rPageSize, aTextMaxWidth);
awt::Size aTitleUnrotatedSize = apVTitle->getUnrotatedSize();
awt::Size aTitleSize = apVTitle->getFinalSize();
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 26a598931c29..23953def50d7 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -2374,7 +2374,7 @@ uno::Reference< drawing::XShape >
uno::Sequence< uno::Reference< chart2::XFormattedString > >& xFormattedString,
const uno::Reference<
beans::XPropertySet > & xTextProperties,
- double nRotation, const OUString& aName )
+ double nRotation, const OUString& aName, sal_Int32 nTextMaxWidth )
{
//create shape and add to page
uno::Reference< drawing::XShape > xShape(
@@ -2407,7 +2407,7 @@ uno::Reference< drawing::XShape >
aValueMap.insert( { "TextVerticalAdjust", uno::Any(drawing::TextVerticalAdjust_CENTER) } ); //drawing::TextVerticalAdjust
aValueMap.insert( { "TextAutoGrowHeight", uno::Any(true) } ); // sal_Bool
aValueMap.insert( { "TextAutoGrowWidth", uno::Any(true) } ); // sal_Bool
- aValueMap.insert( { "TextMaximumFrameWidth", uno::Any(rSize.Width) } ); // sal_Int32
+ aValueMap.insert({ "TextMaximumFrameWidth", uno::Any(nTextMaxWidth) }); // sal_Int32
//set name/classified ObjectID (CID)
if( !aName.isEmpty() )
diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx
index 39989f191aa0..53e214f76999 100644
--- a/chart2/source/view/main/VTitle.cxx
+++ b/chart2/source/view/main/VTitle.cxx
@@ -99,7 +99,8 @@ void VTitle::changePosition( const awt::Point& rPos )
void VTitle::createShapes(
const awt::Point& rPos
- , const awt::Size& rReferenceSize )
+ , const awt::Size& rReferenceSize
+ , const awt::Size& rTextMaxWidth )
{
if(!m_xTitle.is())
return;
@@ -124,9 +125,16 @@ void VTitle::createShapes(
TOOLS_WARN_EXCEPTION("chart2", "" );
}
+ sal_Int32 nTextMaxWidth;
+ if (m_fRotationAngleDegree <= 15.0 || m_fRotationAngleDegree >= 345.0
+ || (m_fRotationAngleDegree >= 165.0 && m_fRotationAngleDegree <= 195.0))
+ nTextMaxWidth = rTextMaxWidth.Width;
+ else
+ nTextMaxWidth = rTextMaxWidth.Height;
+
ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
- m_xShape =pShapeFactory->createText( m_xTarget, rReferenceSize, rPos, aStringList,
- xTitleProperties, m_fRotationAngleDegree, m_aCID );
+ m_xShape =pShapeFactory->createText( m_xTarget, rReferenceSize, rPos, aStringList, xTitleProperties,
+ m_fRotationAngleDegree, m_aCID, nTextMaxWidth );
}
} //namespace chart
diff --git a/chart2/source/view/main/VTitle.hxx b/chart2/source/view/main/VTitle.hxx
index 45b9a5421324..261458025956 100644
--- a/chart2/source/view/main/VTitle.hxx
+++ b/chart2/source/view/main/VTitle.hxx
@@ -44,7 +44,8 @@ public:
, const OUString& rCID );
void createShapes( const css::awt::Point& rPos
- , const css::awt::Size& rReferenceSize );
+ , const css::awt::Size& rReferenceSize
+ , const css::awt::Size& nTextMaxWidth );
double getRotationAnglePi() const;
css::awt::Size getUnrotatedSize() const;
diff --git a/sw/qa/extras/layout/data/tdf134235.docx b/sw/qa/extras/layout/data/tdf134235.docx
new file mode 100644
index 000000000000..af0cb0d3de43
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf134235.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index a44d0396cf3d..e5c2784c17cb 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2776,6 +2776,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf132956)
"Category 1");
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf134235)
+{
+ SwDoc* pDoc = createDoc("tdf134235.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 chart title flowed out of chart area.
+ assertXPath(pXmlDoc, "//textarray", 14);
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116925)
{
SwDoc* pDoc = createDoc("tdf116925.docx");
More information about the Libreoffice-commits
mailing list