summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorFeyza Yavuz <feyzaayavuz@gmail.com>2016-05-01 17:28:07 +0300
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-05-08 20:20:40 +0000
commit0ab7ad3bb0138c2614f66dba8af39cabe760f910 (patch)
treebf0e975fe8255c2129c297dfd8a5f7b9cfdd6abc /chart2
parentdc464bdb08cf6a3a3b118245b6eecbda5e94fb42 (diff)
tdf#92768 Support hiding title objects
Change-Id: I879fc3d81a8fe8ca2f928305f5dc7fd9ebcfd294 Reviewed-on: https://gerrit.libreoffice.org/24564 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/sidebar/ChartElementsPanel.cxx13
-rw-r--r--chart2/source/inc/TitleHelper.hxx11
-rw-r--r--chart2/source/tools/TitleHelper.cxx31
3 files changed, 52 insertions, 3 deletions
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index b86cb14d250f..1e52f24a399d 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -116,7 +116,14 @@ void setLegendVisible(const css::uno::Reference<css::frame::XModel>& xModel, boo
bool isTitleVisisble(const css::uno::Reference<css::frame::XModel>& xModel, TitleHelper::eTitleType eTitle)
{
- return TitleHelper::getTitle(eTitle, xModel).is();
+ css::uno::Reference<css::uno::XInterface> xTitle = TitleHelper::getTitle(eTitle, xModel);
+ if (!xTitle.is())
+ return false;
+
+ css::uno::Reference<css::beans::XPropertySet> xPropSet(xTitle, css::uno::UNO_QUERY_THROW);
+ css::uno::Any aAny = xPropSet->getPropertyValue("Visible");
+ bool bVisible = aAny.get<bool>();
+ return bVisible;
}
bool isGridVisible(const css::uno::Reference<css::frame::XModel>& xModel, GridType eType)
@@ -581,11 +588,11 @@ void ChartElementsPanel::setTitleVisible(TitleHelper::eTitleType eTitle, bool bV
if (bVisible)
{
OUString aText = eTitle == TitleHelper::SUB_TITLE ? maTextSubTitle : maTextTitle;
- TitleHelper::createTitle(eTitle, aText, mxModel, comphelper::getProcessComponentContext());
+ TitleHelper::createOrShowTitle(eTitle, aText, mxModel, comphelper::getProcessComponentContext());
}
else
{
- TitleHelper::removeTitle(eTitle, mxModel);
+ TitleHelper::hideTitle(eTitle, mxModel);
}
}
diff --git a/chart2/source/inc/TitleHelper.hxx b/chart2/source/inc/TitleHelper.hxx
index 523575244ba8..89e1a7bbaee1 100644
--- a/chart2/source/inc/TitleHelper.hxx
+++ b/chart2/source/inc/TitleHelper.hxx
@@ -66,10 +66,21 @@ public:
, const css::uno::Reference< css::frame::XModel >& xModel
, const css::uno::Reference< css::uno::XComponentContext > & xContext
, ReferenceSizeProvider * pRefSizeProvider = nullptr );
+ static css::uno::Reference<
+ css::chart2::XTitle >
+ createOrShowTitle( eTitleType nTitleIndex
+ , const OUString& rTitleText
+ , const css::uno::Reference< css::frame::XModel >& xModel
+ , const css::uno::Reference< css::uno::XComponentContext > & xContext
+ , ReferenceSizeProvider * pRefSizeProvider = nullptr );
static void removeTitle( eTitleType nTitleIndex
, const css::uno::Reference< css::frame::XModel >& xModel );
+ static void hideTitle( eTitleType nTitleIndex
+ , const css::uno::Reference< css::frame::XModel >& xModel );
+
+
static OUString getCompleteString( const css::uno::Reference< css::chart2::XTitle >& xTitle );
static void setCompleteString( const OUString& rNewText
, const css::uno::Reference< css::chart2::XTitle >& xTitle
diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx
index d2adced63854..7a3290b86f6d 100644
--- a/chart2/source/tools/TitleHelper.cxx
+++ b/chart2/source/tools/TitleHelper.cxx
@@ -170,6 +170,26 @@ uno::Reference< XTitle > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIn
return nullptr;
}
+uno::Reference< XTitle > TitleHelper::createOrShowTitle(
+ TitleHelper::eTitleType eTitleType
+ , const OUString& rTitleText
+ , const uno::Reference< frame::XModel >& xModel
+ , const uno::Reference< uno::XComponentContext > & xContext
+ , ReferenceSizeProvider * pRefSizeProvider )
+{
+ uno::Reference< chart2::XTitle > xTitled( TitleHelper::getTitle( eTitleType, xModel ) );
+ if( xTitled.is())
+ {
+ css::uno::Reference<css::beans::XPropertySet> xProps(xTitled, css::uno::UNO_QUERY_THROW);
+ xProps->setPropertyValue("Visible",css::uno::makeAny(true));
+ return xTitled;
+ }
+ else
+ {
+ return createTitle(eTitleType, rTitleText, xModel, xContext, pRefSizeProvider);
+ }
+}
+
uno::Reference< XTitle > TitleHelper::createTitle(
TitleHelper::eTitleType eTitleType
, const OUString& rTitleText
@@ -373,6 +393,17 @@ void TitleHelper::removeTitle( TitleHelper::eTitleType nTitleIndex
}
}
+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));
+ }
+}
+
bool TitleHelper::getTitleType( eTitleType& rType
, const css::uno::Reference< css::chart2::XTitle >& xTitle
, ChartModel& rModel )