summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorQuan Nguyen <quannguyenvan1701@gmail.com>2021-02-15 07:49:33 +0700
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-18 09:49:06 +0100
commit62dff2844b0bf1d1bcb8eb4d6db529ef4a31bee4 (patch)
tree69d3149e3d8fc514ac0792edfc835c92404ed1f5 /chart2
parentad4d715ca69d6f09fb2d8a713c79edb999ad2316 (diff)
tdf#92768 Add rendering support for hiding title object in chart2
Change-Id: Ice6335d52d53dcbaa8711f9669597bf5321ecd7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110889 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/sidebar/ChartElementsPanel.cxx4
-rw-r--r--chart2/source/inc/TitleHelper.hxx2
-rw-r--r--chart2/source/tools/TitleHelper.cxx11
-rw-r--r--chart2/source/view/main/ChartView.cxx2
-rw-r--r--chart2/source/view/main/VTitle.cxx15
-rw-r--r--chart2/source/view/main/VTitle.hxx2
6 files changed, 32 insertions, 4 deletions
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index b14705cc8080..5212186da371 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -665,9 +665,7 @@ void ChartElementsPanel::setTitleVisible(TitleHelper::eTitleType eTitle, bool bV
}
else
{
- // TODO tdf#92768 use TitleHelper::hideTitle() here once there is
- // rendering support for the property "Visible"
- TitleHelper::removeTitle(eTitle, mxModel);
+ TitleHelper::hideTitle(eTitle, mxModel);
}
}
diff --git a/chart2/source/inc/TitleHelper.hxx b/chart2/source/inc/TitleHelper.hxx
index 0628252f5fd6..c85b5ce1a3ff 100644
--- a/chart2/source/inc/TitleHelper.hxx
+++ b/chart2/source/inc/TitleHelper.hxx
@@ -89,6 +89,8 @@ public:
static bool getTitleType( eTitleType& rType
, const css::uno::Reference< css::chart2::XTitle >& xTitle
, const css::uno::Reference< css::frame::XModel >& xModel );
+ static void hideTitle( eTitleType nTitleIndex,
+ const css::uno::Reference< css::frame::XModel > & xModel);
};
} //namespace chart
diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx
index 600ebedd2d3b..bc11c4f99c32 100644
--- a/chart2/source/tools/TitleHelper.cxx
+++ b/chart2/source/tools/TitleHelper.cxx
@@ -436,6 +436,17 @@ bool TitleHelper::getTitleType( eTitleType& rType
return false;
}
+void TitleHelper::hideTitle( TitleHelper::eTitleType nTitleIndex
+ , const css::uno::Reference< css::frame::XModel >& xModel)
+{
+ uno::Reference< chart2::XTitle > xTitled( TitleHelper::getTitle( nTitleIndex, xModel ) );
+ if( xTitled.is())
+ {
+ css::uno::Reference<css::beans::XPropertySet> xProps(xTitled, css::uno::UNO_QUERY_THROW);
+ xProps->setPropertyValue("Visible",css::uno::makeAny(false));
+ }
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index c88144137721..93bf35672123 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2131,7 +2131,7 @@ std::shared_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType
uno::Reference< XTitle > xTitle( TitleHelper::getTitle( eType, rModel ) );
OUString aCompleteString = TitleHelper::getCompleteString(xTitle);
- if (aCompleteString.isEmpty())
+ if (aCompleteString.isEmpty() || !VTitle::isVisible(xTitle))
return apVTitle;
//create title
diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx
index f0befe954659..ad2e857101fb 100644
--- a/chart2/source/view/main/VTitle.cxx
+++ b/chart2/source/view/main/VTitle.cxx
@@ -97,6 +97,21 @@ void VTitle::changePosition( const awt::Point& rPos )
}
}
+bool VTitle::isVisible(const uno::Reference< XTitle >& xTitle) {
+ if (!xTitle.is()) {
+ return false;
+ }
+ bool bShow = true;
+ try {
+ uno::Reference< beans::XPropertySet > xTitleProps(xTitle, uno::UNO_QUERY_THROW);
+ xTitleProps->getPropertyValue("Visible") >>= bShow;
+ } catch (const uno::Exception &) {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return bShow;
+}
+
+
void VTitle::createShapes(
const awt::Point& rPos
, const awt::Size& rReferenceSize
diff --git a/chart2/source/view/main/VTitle.hxx b/chart2/source/view/main/VTitle.hxx
index 6d330076dedf..cdfd0a89cdc4 100644
--- a/chart2/source/view/main/VTitle.hxx
+++ b/chart2/source/view/main/VTitle.hxx
@@ -51,6 +51,8 @@ public:
css::awt::Size getUnrotatedSize() const;
css::awt::Size getFinalSize() const;
void changePosition( const css::awt::Point& rPos );
+ static bool isVisible(
+ const css::uno::Reference< css::chart2::XTitle > & xTitle);
private:
css::uno::Reference< css::drawing::XShapes > m_xTarget;