[Libreoffice-commits] core.git: chart2/source

Quan Nguyen (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 18 08:49:50 UTC 2021


 chart2/source/controller/sidebar/ChartElementsPanel.cxx |    4 +---
 chart2/source/inc/TitleHelper.hxx                       |    2 ++
 chart2/source/tools/TitleHelper.cxx                     |   11 +++++++++++
 chart2/source/view/main/ChartView.cxx                   |    2 +-
 chart2/source/view/main/VTitle.cxx                      |   15 +++++++++++++++
 chart2/source/view/main/VTitle.hxx                      |    2 ++
 6 files changed, 32 insertions(+), 4 deletions(-)

New commits:
commit 62dff2844b0bf1d1bcb8eb4d6db529ef4a31bee4
Author:     Quan Nguyen <quannguyenvan1701 at gmail.com>
AuthorDate: Mon Feb 15 07:49:33 2021 +0700
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Feb 18 09:49:06 2021 +0100

    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 at collabora.co.uk>

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;


More information about the Libreoffice-commits mailing list