chart2/source/view/inc/ShapeFactory.hxx | 2 +- chart2/source/view/main/ChartView.cxx | 12 ++++++++++-- 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, 43 insertions(+), 9 deletions(-)
New commits: commit 6598665a14a5c5e2dea345c4c313a5499d1decf6 Author: Tünde Tóth <[email protected]> AuthorDate: Thu Jun 25 10:43:58 2020 +0200 Commit: Gabor Kelemen <[email protected]> CommitDate: Tue Jul 28 15:27:11 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). Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97092 Tested-by: László Németh <[email protected]> Reviewed-by: László Németh <[email protected]> (cherry picked from commit 17f131fcb3f534792a3b2ec6048d03fb54b55eb1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97384 Tested-by: Jenkins Reviewed-by: Tünde Tóth <[email protected]> (cherry picked from commit 4d2f76e59b9b6d459a623366912eac00864a956d) Change-Id: I22bb4699bdda8dea5f31c715cc1f439085a0718f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99597 Tested-by: Gabor Kelemen <[email protected]> Reviewed-by: Gabor Kelemen <[email protected]> diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index 50f4b39b8532..72182814a933 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 f0f84a9783f2..44fcd27c1f33 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2159,10 +2159,18 @@ std::shared_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType return apVTitle; //create title - apVTitle.reset(new VTitle(xTitle)); + + 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 f6219c650151..8716550d1810 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2373,7 +2373,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( @@ -2406,7 +2406,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 d0633263f8af..463dc5e7ba14 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& rReferenceSize + , const awt::Size& rTextMaxWidth ) { if(!m_xTitle.is()) return; @@ -125,9 +126,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 55a6f5e0de8b..f229dda68e3e 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 fc3115da74c6..cf7cc4965667 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2676,6 +2676,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; + xmlDocPtr 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"); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
