summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2020-06-25 10:43:58 +0200
committerLászló Németh <nemeth@numbertext.org>2020-06-29 12:52:44 +0200
commit17f131fcb3f534792a3b2ec6048d03fb54b55eb1 (patch)
treefba5ac3d4f57c353fe89f157133e1da12a1cae9d /chart2/source
parent51a4c85bf9228a3750b61cb54e64c8134314a35e (diff)
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@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/view/inc/ShapeFactory.hxx2
-rw-r--r--chart2/source/view/main/ChartView.cxx8
-rw-r--r--chart2/source/view/main/ShapeFactory.cxx4
-rw-r--r--chart2/source/view/main/VTitle.cxx14
-rw-r--r--chart2/source/view/main/VTitle.hxx3
5 files changed, 23 insertions, 8 deletions
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;