summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-12-14 16:25:25 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-12-15 10:36:49 +0000
commitade49eb1b9f99595f4c8864e7c13acebf9fac030 (patch)
tree515bf7227c1844123f10d7ede4b5040779be0ce5 /svx
parent6d8b5629d3728aa48751e0a1b690f756b9d546f4 (diff)
Resolves: tdf#92051 add tooltips to section/table statusbar
Change-Id: I649eabbe266085fdbc0ca9c4a5506c0c2a270721 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144199 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/Library_svx.mk1
-rw-r--r--svx/sdi/svx.sdi2
-rw-r--r--svx/source/items/statusitem.cxx134
-rw-r--r--svx/source/stbctrls/pszctrl.cxx43
4 files changed, 179 insertions, 1 deletions
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index 092a4613f374..29f8d16454c7 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -200,6 +200,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/items/postattr \
svx/source/items/rotmodit \
svx/source/items/SmartTagItem \
+ svx/source/items/statusitem \
svx/source/items/svxerr \
svx/source/items/viewlayoutitem \
svx/source/items/zoomslideritem \
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index bc1d9e5c429f..d1f02f5b1d3b 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -10378,7 +10378,7 @@ SfxVoidItem DecrementIndent SID_DEC_INDENT
]
-SfxStringItem StateTableCell SID_TABLE_CELL
+SvxStatusItem StateTableCell SID_TABLE_CELL
[
AutoUpdate = FALSE,
diff --git a/svx/source/items/statusitem.cxx b/svx/source/items/statusitem.cxx
new file mode 100644
index 000000000000..3b326f39ebe0
--- /dev/null
+++ b/svx/source/items/statusitem.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/propertyvalue.hxx>
+#include <svl/memberid.h>
+#include <svx/statusitem.hxx>
+
+constexpr OUStringLiteral STATUS_PARAM_VALUE = u"Value";
+constexpr OUStringLiteral STATUS_PARAM_TYPE = u"Type";
+constexpr int STATUS_PARAMS = 2;
+
+SvxStatusItem::SvxStatusItem(TypedWhichId<SvxStatusItem> nWhich, const OUString& rString,
+ StatusCategory eCategory)
+ : SfxStringItem(nWhich, rString)
+ , m_eCategory(eCategory)
+{
+}
+
+bool SvxStatusItem::operator==(const SfxPoolItem& rItem) const
+{
+ return SfxStringItem::operator==(rItem)
+ && static_cast<const SvxStatusItem&>(rItem).m_eCategory == m_eCategory;
+}
+
+bool SvxStatusItem::QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+
+ switch (nMemberId)
+ {
+ case 0:
+ {
+ css::uno::Sequence<css::beans::PropertyValue> aSeq{
+ comphelper::makePropertyValue(STATUS_PARAM_VALUE, GetValue()),
+ comphelper::makePropertyValue(STATUS_PARAM_TYPE,
+ static_cast<sal_Int16>(m_eCategory))
+ };
+ assert(aSeq.getLength() == STATUS_PARAMS);
+ rVal <<= aSeq;
+ break;
+ }
+ case MID_VALUE:
+ rVal <<= GetValue();
+ break;
+ case MID_TYPE:
+ rVal <<= static_cast<sal_Int16>(m_eCategory);
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+bool SvxStatusItem::PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId)
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ bool bRet;
+ switch (nMemberId)
+ {
+ case 0:
+ {
+ css::uno::Sequence<css::beans::PropertyValue> aSeq;
+ if ((rVal >>= aSeq) && (aSeq.getLength() == STATUS_PARAMS))
+ {
+ OUString sValueTmp;
+ sal_Int16 nTypeTmp(0);
+ bool bAllConverted(true);
+ sal_Int16 nConvertedCount(0);
+ for (const auto& rProp : std::as_const(aSeq))
+ {
+ if (rProp.Name == STATUS_PARAM_VALUE)
+ {
+ bAllConverted &= (rProp.Value >>= sValueTmp);
+ ++nConvertedCount;
+ }
+ else if (rProp.Name == STATUS_PARAM_TYPE)
+ {
+ bAllConverted &= (rProp.Value >>= nTypeTmp);
+ ++nConvertedCount;
+ }
+ }
+
+ if (bAllConverted && nConvertedCount == STATUS_PARAMS)
+ {
+ SetValue(sValueTmp);
+ m_eCategory = static_cast<StatusCategory>(nTypeTmp);
+ return true;
+ }
+ }
+ return false;
+ }
+ case MID_TYPE:
+ {
+ sal_Int16 nCategory;
+ bRet = (rVal >>= nCategory);
+ if (bRet)
+ m_eCategory = static_cast<StatusCategory>(nCategory);
+ break;
+ }
+ case MID_VALUE:
+ {
+ OUString aStr;
+ bRet = (rVal >>= aStr);
+ if (bRet)
+ SetValue(aStr);
+ break;
+ }
+ default:
+ return false;
+ }
+
+ return bRet;
+}
+
+SvxStatusItem* SvxStatusItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxStatusItem(*this);
+}
+
+SfxPoolItem* SvxStatusItem::CreateDefault()
+{
+ return new SvxStatusItem(TypedWhichId<SvxStatusItem>(0), OUString(), StatusCategory::NONE);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx
index 5eddc1981727..cd103e258600 100644
--- a/svx/source/stbctrls/pszctrl.cxx
+++ b/svx/source/stbctrls/pszctrl.cxx
@@ -32,6 +32,9 @@
#include <svl/stritem.hxx>
#include <svl/ptitem.hxx>
#include <sfx2/module.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/statusitem.hxx>
+#include <svx/strings.hrc>
#include <svl/intitem.hxx>
#include <sal/log.hxx>
@@ -321,8 +324,48 @@ void SvxPosSizeStatusBarControl::StateChangedAtStatusBarControl( sal_uInt16 nSID
pImpl->bSize = true;
pImpl->bTable = false;
}
+ else if ( auto pStatusItem = dynamic_cast<const SvxStatusItem*>( pState) )
+ {
+ // show string (table cell or different)
+ pImpl->aStr = pStatusItem->GetValue();
+ pImpl->bTable = true;
+ pImpl->bPos = false;
+ pImpl->bSize = false;
+ if (!pImpl->aStr.isEmpty())
+ {
+ OUString sTip;
+ switch (pStatusItem->GetCategory())
+ {
+ case StatusCategory::TableCell:
+ sTip = SvxResId(RID_SVXSTR_TABLECELL_HINT);
+ break;
+ case StatusCategory::Section:
+ sTip = SvxResId(RID_SVXSTR_SECTION_HINT);
+ break;
+ case StatusCategory::TableOfContents:
+ sTip = SvxResId(RID_SVXSTR_TOC_HINT);
+ break;
+ case StatusCategory::Numbering:
+ sTip = SvxResId(RID_SVXSTR_NUMBERING_HINT);
+ break;
+ case StatusCategory::ListStyle:
+ sTip = SvxResId(RID_SVXSTR_LIST_STYLE_HINT);
+ break;
+ case StatusCategory::Formula:
+ sTip = SvxResId(RID_SVXSTR_FORMULA_HINT);
+ break;
+ case StatusCategory::RowColumn:
+ sTip = SvxResId(RID_SVXSTR_ROW_COLUMN_HINT);
+ break;
+ case StatusCategory::NONE:
+ break;
+ }
+ GetStatusBar().SetQuickHelpText(GetId(), sTip);
+ }
+ }
else if ( auto pStringItem = dynamic_cast<const SfxStringItem*>( pState) )
{
+ SAL_WARN( "svx.stbcrtls", "this should be a SvxStatusItem not a SfxStringItem" );
// show string (table cell or different)
pImpl->aStr = pStringItem->GetValue();
pImpl->bTable = true;