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>
This commit is contained in:
Caolán McNamara
2022-12-14 16:25:25 +00:00
parent 6d8b5629d3
commit ade49eb1b9
15 changed files with 279 additions and 12 deletions

View File

@@ -0,0 +1,46 @@
/* -*- 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/.
*/
#pragma once
#include <svl/stritem.hxx>
#include <svx/svxdllapi.h>
enum class StatusCategory : sal_Int16
{
NONE,
TableCell,
Section,
TableOfContents,
Numbering,
ListStyle,
Formula,
RowColumn
};
class SVX_DLLPUBLIC SvxStatusItem final : public SfxStringItem
{
private:
StatusCategory m_eCategory;
public:
SvxStatusItem(TypedWhichId<SvxStatusItem> nWhich, const OUString& rString,
StatusCategory eStatusCategory);
StatusCategory GetCategory() const { return m_eCategory; }
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
virtual bool operator==(const SfxPoolItem& rItem) const override;
virtual SvxStatusItem* Clone(SfxItemPool* pPool = nullptr) const override;
static SfxPoolItem* CreateDefault();
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

View File

@@ -1326,6 +1326,13 @@
#define RID_SVXSTR_DOC_LOAD NC_("RID_SVXSTR_DOC_LOAD", "Loading document...")
#define RID_SVXSTR_FIT_SLIDE NC_("RID_SVXSTR_FIT_SLIDE", "Fit slide to current window.")
#define RID_SVXSTR_WARN_MISSING_SMARTART NC_("RID_SVXSTR_WARN_MISSING_SMARTART", "Could not load all SmartArt objects. Saving in Microsoft Office 2010 or later would avoid this issue.")
#define RID_SVXSTR_TABLECELL_HINT NC_("RID_SVXSTR_TABLECELL_HINT", "Table cell address. Click to open Table Properties dialog.")
#define RID_SVXSTR_SECTION_HINT NC_("RID_SVXSTR_SECTION_HINT", "Section name. Click to open Edit Sections dialog.")
#define RID_SVXSTR_TOC_HINT NC_("RID_SVXSTR_TOC_HINT", "Table of Contents. Click to open Table of Contents dialog.")
#define RID_SVXSTR_NUMBERING_HINT NC_("RID_SVXSTR_NUMBERING_HINT", "Numbering Level. Click to open Numbering dialog.")
#define RID_SVXSTR_LIST_STYLE_HINT NC_("RID_SVXSTR_LIST_STYLE_HINT", "List Style and Level.")
#define RID_SVXSTR_FORMULA_HINT NC_("RID_SVXSTR_FORMULA_HINT", "Formula")
#define RID_SVXSTR_ROW_COLUMN_HINT NC_("RID_SVXSTR_ROW_COLUMN_HINT", "Row and Column")
#define RID_SVXSTR_ZOOMTOOL_HINT NC_("RID_SVXSTR_ZOOMTOOL_HINT", "Zoom factor. Right-click to change zoom factor or click to open Zoom dialog.")
#define RID_SVXSTR_ZOOM_IN NC_("RID_SVXSTR_ZOOM_IN", "Zoom In")
#define RID_SVXSTR_ZOOM_OUT NC_("RID_SVXSTR_ZOOM_OUT", "Zoom Out")

View File

@@ -63,6 +63,7 @@ class SvxPostItTextItem;
class SvxRulerItem;
class SvxSetItem;
class SvxSizeItem;
class SvxStatusItem;
class SvxSmartTagItem;
class SvxViewLayoutItem;
class SvxZoomSliderItem;
@@ -355,7 +356,7 @@ class XFillGradientItem;
#define SID_ATTR_ZOOM_USER TypedWhichId<SfxUInt16Item>( SID_SVX_START + 222 )
#define SID_ATTR_POSITION TypedWhichId<SfxPointItem>( SID_SVX_START + 223 )
#define SID_ATTR_SIZE TypedWhichId<SvxSizeItem>( SID_SVX_START + 224 )
#define SID_TABLE_CELL ( SID_SVX_START + 225 )
#define SID_TABLE_CELL TypedWhichId<SvxStatusItem>( SID_SVX_START + 225 )
#define SID_ATTR_ALIGN_MARGIN ( SID_SVX_START + 228 )
#define SID_ATTR_ALIGN_STACKED ( SID_SVX_START + 229 )
#define SID_ATTR_ALIGN_LINEBREAK ( SID_SVX_START + 230 )

View File

@@ -27,6 +27,7 @@
#include <svx/hlnkitem.hxx>
#include <svl/srchitem.hxx>
#include <svx/postattr.hxx>
#include <svx/statusitem.hxx>
#include <editeng/postitem.hxx>
#include <sfx2/tplpitem.hxx>
#include <sfx2/zoomitem.hxx>

View File

@@ -34,6 +34,7 @@
#include <vcl/EnumContext.hxx>
#include <vcl/svapp.hxx>
#include <svx/clipfmtitem.hxx>
#include <svx/statusitem.hxx>
#include <cellsh.hxx>
#include <sc.hrc>
@@ -874,7 +875,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
// calculations etc. with date/time/Fail/position&size together
// #i34458# The SfxStringItem belongs only into SID_TABLE_CELL. It no longer has to be
// #i34458# The SvxStatusItem belongs only into SID_TABLE_CELL. It no longer has to be
// duplicated in SID_ATTR_POSITION or SID_ATTR_SIZE for SvxPosSizeStatusBarControl.
case SID_TABLE_CELL:
{
@@ -883,7 +884,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
// In interpreter may happen via rescheduled Basic
if ( rDoc.IsInInterpreter() )
rSet.Put( SfxStringItem( nWhich, "..." ) );
rSet.Put( SvxStatusItem( SID_TABLE_CELL, "...", StatusCategory::Formula ) );
else
{
FormulaError nErrCode = FormulaError::NONE;
@@ -893,7 +894,9 @@ void ScCellShell::GetState(SfxItemSet &rSet)
OUString aFuncStr;
if ( pTabViewShell->GetFunction( aFuncStr, nErrCode ) )
rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
{
rSet.Put( SvxStatusItem( SID_TABLE_CELL, aFuncStr, StatusCategory::Formula ) );
}
}
}
break;

View File

@@ -109,6 +109,13 @@
item SfxScriptOrganizer SfxScriptOrganizerItem;
item String SvxClipboardFormatItem; //! Dummy
struct Status
{
String Value MID_VALUE;
INT16 Status MID_TYPE;
};
item Status SvxStatusItem;
struct SvxZoom
{
UINT16 Value MID_VALUE;

View File

@@ -22,11 +22,12 @@
#include <tools/debug.hxx>
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
#include <svl/itempool.hxx>
#include <svl/itemset.hxx>
#include <svl/stritem.hxx>
#include <svl/visitem.hxx>
#include <svtools/javacontext.hxx>
#include <svtools/javainteractionhandler.hxx>
#include <svl/itempool.hxx>
#include <tools/urlobj.hxx>
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/awt/Point.hpp>
@@ -1167,7 +1168,6 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra
else if (aEvent.FeatureURL.Path == "StatusDocPos" ||
aEvent.FeatureURL.Path == "RowColSelCount" ||
aEvent.FeatureURL.Path == "StatusPageStyle" ||
aEvent.FeatureURL.Path == "StateTableCell" ||
aEvent.FeatureURL.Path == "StateWordCount" ||
aEvent.FeatureURL.Path == "PageStyleName" ||
aEvent.FeatureURL.Path == "PageStatus" ||
@@ -1182,6 +1182,14 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra
aBuffer.append(aString);
}
}
else if (aEvent.FeatureURL.Path == "StateTableCell")
{
if (aEvent.IsEnabled)
{
if (const SfxStringItem* pSvxStatusItem = dynamic_cast<const SfxStringItem*>(pState))
aBuffer.append(pSvxStatusItem->GetValue());
}
}
else if (aEvent.FeatureURL.Path == "InsertMode" ||
aEvent.FeatureURL.Path == "WrapText" ||
aEvent.FeatureURL.Path == "NumberFormatCurrency" ||

View File

@@ -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 \

View File

@@ -10378,7 +10378,7 @@ SfxVoidItem DecrementIndent SID_DEC_INDENT
]
SfxStringItem StateTableCell SID_TABLE_CELL
SvxStatusItem StateTableCell SID_TABLE_CELL
[
AutoUpdate = FALSE,

View File

@@ -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: */

View File

@@ -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;

View File

@@ -55,6 +55,7 @@
#include <svl/ptitem.hxx>
#include <editeng/sizeitem.hxx>
#include <editeng/langitem.hxx>
#include <svx/statusitem.hxx>
#include <svx/svdview.hxx>
#include <svx/svdhdl.hxx>
#include <svx/svdoutl.hxx>
@@ -4204,7 +4205,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
rBnd.Invalidate(SID_ATTR_POSITION);
}
rBnd.Invalidate(SID_ATTR_SIZE);
const SfxStringItem aCell( SID_TABLE_CELL, OUString() );
const SvxStatusItem aCell( SID_TABLE_CELL, OUString(), StatusCategory::NONE );
rBnd.SetState( aCell );
}
}

View File

@@ -30,6 +30,7 @@
#include <sfx2/objitem.hxx>
#include <sfx2/objsh.hxx>
#include <svx/rulritem.hxx>
#include <svx/statusitem.hxx>
#include <sfx2/zoomitem.hxx>
#include <svx/viewlayoutitem.hxx>
#include <svx/zoomslideritem.hxx>

View File

@@ -45,6 +45,7 @@
#include <sfx2/request.hxx>
#include <sfx2/docfile.hxx>
#include <svx/srchdlg.hxx>
#include <svx/statusitem.hxx>
#include <svl/srchitem.hxx>
#include <sfx2/sfxhtml.hxx>
#include <swtypes.hxx>
@@ -426,7 +427,7 @@ void SwSrcView::GetState(SfxItemSet& rSet)
aPos += " : " +
SwResId(STR_SRCVIEW_COL);
aPos += OUString::number( aSel.GetEnd().GetIndex()+1 );
SfxStringItem aItem( nWhich, aPos );
SvxStatusItem aItem( SID_TABLE_CELL, aPos, StatusCategory::RowColumn );
rSet.Put( aItem );
}
break;

View File

@@ -46,9 +46,10 @@
#include <sfx2/sfxdlg.hxx>
#include <sfx2/filedlghelper.hxx>
#include <editeng/langitem.hxx>
#include <svx/linkwarn.hxx>
#include <svx/statusitem.hxx>
#include <svx/viewlayoutitem.hxx>
#include <svx/zoomslideritem.hxx>
#include <svx/linkwarn.hxx>
#include <sfx2/htmlmode.hxx>
#include <vcl/svapp.hxx>
#include <sfx2/app.hxx>
@@ -1963,12 +1964,14 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
}
else
{
StatusCategory eCategory(StatusCategory::NONE);
OUString sStr;
if( rShell.IsCursorInTable() )
{
// table name + cell coordinate
sStr = rShell.GetTableFormat()->GetName() + ":";
sStr += rShell.GetBoxNms();
eCategory = StatusCategory::TableCell;
}
else
{
@@ -1982,17 +1985,22 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
{
const SwTOXBase* pTOX = m_pWrtShell->GetCurTOX();
if( pTOX )
{
sStr = pTOX->GetTOXName();
eCategory = StatusCategory::TableOfContents;
}
else
{
OSL_ENSURE( false,
"Unknown kind of section" );
sStr = pCurrSect->GetSectionName();
eCategory = StatusCategory::Section;
}
}
break;
default:
sStr = pCurrSect->GetSectionName();
eCategory = StatusCategory::Section;
break;
}
}
@@ -2019,6 +2027,8 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
{
if(!sStr.isEmpty())
sStr += sStatusDelim;
if (eCategory == StatusCategory::NONE)
eCategory = StatusCategory::ListStyle;
sStr += rNumStyle;
}
}
@@ -2026,7 +2036,8 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
if (!sStr.isEmpty())
sStr += sStatusDelim;
sStr += SwResId(STR_NUM_LEVEL) + OUString::number( nNumLevel + 1 );
if (eCategory == StatusCategory::NONE)
eCategory = StatusCategory::Numbering;
}
}
const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
@@ -2042,6 +2053,8 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
else
sStr += SwResId(STR_NUM_OUTLINE);
sStr += OUString::number( nOutlineLevel);
if (eCategory == StatusCategory::NONE)
eCategory = StatusCategory::Numbering;
}
if( rShell.HasReadonlySel() )
@@ -2051,7 +2064,7 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
sStr = SwResId(SW_STR_READONLY) + sStr;
}
if (!sStr.isEmpty())
rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
rSet.Put( SvxStatusItem( SID_TABLE_CELL, sStr, eCategory ));
}
break;
case FN_STAT_SELMODE: