summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2020-07-01 15:48:19 +0200
committerLászló Németh <nemeth@numbertext.org>2020-07-07 10:13:38 +0200
commit23b73bc02536455df75438e19b5c70bacc9aa700 (patch)
treef061a5cf7ed60fb75b9c1977abd01f2e1bdf987e /chart2
parent9a28558a222db9b066283ff78e71d1e5910f2569 (diff)
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@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/main/ChartView.cxx10
-rw-r--r--chart2/source/view/main/VTitle.cxx15
-rw-r--r--chart2/source/view/main/VTitle.hxx3
3 files changed, 23 insertions, 5 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index faa7fbe3511a..a6c09be30b1d 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2139,15 +2139,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;