Kaydet (Commit) 1c80246e authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Tamás Bunth

tdf#112100 Select shape name in Navigator

After the selection of a shape the shape name is selected in the Navigator
tab under the Drawing Objects entry.

It scrolls to the corresponding entry as well in case the scrollbar is
visible.

Change-Id: I298e8fe6bdab01eb20c53e1730812192c46770c5
Reviewed-on: https://gerrit.libreoffice.org/43566Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst 7f454340
......@@ -86,6 +86,7 @@ enum class SfxHintId {
ScKillEditView,
ScKillEditViewNoPaint,
ScHiddenRowsChanged,
ScSelectionChanged,
// SC accessibility hints
ScAccTableChanged,
......
......@@ -141,6 +141,7 @@ public:
void SetManualDoc(const OUString& rName);
bool LoadFile(const OUString& rUrl);
void SelectDoc(const OUString& rName);
bool SelectEntryByName(const ScContentId nRoot, const OUString& rName);
const OUString& GetHiddenTitle() const { return aHiddenTitle; }
......
......@@ -224,6 +224,7 @@ private:
void SetCurrentTableStr( const OUString& rName );
void SetCurrentObject( const OUString& rName );
void SetCurrentDoc( const OUString& rDocName );
void UpdateSelection();
static ScTabViewShell* GetTabViewShell();
static ScNavigatorSettings* GetNavigatorSettings();
......
......@@ -1626,6 +1626,43 @@ void ScContentTree::SelectDoc(const OUString& rName) // rName like shown in
}
}
bool ScContentTree::SelectEntryByName(const ScContentId nRoot, const OUString& rName)
{
SvTreeListEntry* pParent = pRootNodes[ nRoot ];
if( !pParent->HasChildren() )
return false;
SvTreeListEntry* pEntry = FirstChild( pParent );
while( pEntry )
{
if( GetEntryText( pEntry ) == rName )
{
bool bRet = SvTreeListBox::Select( pEntry );
// Scroll to the selected item
if( SvTreeListBox::GetVScroll()->IsVisible() )
{
long nBeforeCount = 0;
SvTreeList* pList = GetModel();
SvTreeListEntry* pRoot = pList->First();
while( pRoot != pParent )
{
++nBeforeCount;
pRoot = pList->Next( pRoot );
}
SvTreeListBox::ScrollToAbsPos( pEntry->GetChildListPos()
+ nBeforeCount );
}
return bRet;
}
pEntry = Next( pEntry );
}
return false;
}
void ScContentTree::ApplyNavigatorSettings()
{
const ScNavigatorSettings* pSettings = ScNavigatorDlg::GetNavigatorSettings();
......
......@@ -50,6 +50,10 @@
#include <algorithm>
#include <com/sun/star/uno/Reference.hxx>
using namespace com::sun::star;
// maximum values for UI
#define SCNAV_MAXCOL (MAXCOLCOUNT)
// macro is sufficient since only used in ctor
......@@ -665,6 +669,9 @@ void ScNavigatorDlg::Notify( SfxBroadcaster&, const SfxHint& rHint )
aLbEntries->ObjectFresh( ScContentId::DRAWING );
aLbEntries->ObjectFresh( ScContentId::GRAPHIC );
break;
case SfxHintId::ScSelectionChanged:
UpdateSelection();
break;
default:
break;
}
......@@ -785,6 +792,32 @@ void ScNavigatorDlg::SetCurrentDoc( const OUString& rDocName ) // activat
{ &aDocItem });
}
void ScNavigatorDlg::UpdateSelection()
{
ScTabViewShell* pViewSh = GetTabViewShell();
if( !pViewSh )
return;
uno::Reference< drawing::XShapes > xShapes = pViewSh->getSelectedXShapes();
if( xShapes )
{
uno::Reference< container::XIndexAccess > xIndexAccess(
xShapes, uno::UNO_QUERY_THROW );
if( xIndexAccess->getCount() > 1 )
return;
uno::Reference< drawing::XShape > xShape;
if( xIndexAccess->getByIndex(0) >>= xShape )
{
uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY_THROW );
OUString sName;
if( ( xProps->getPropertyValue("Name") >>= sName ) && !sName.isEmpty() )
{
aLbEntries->SelectEntryByName( ScContentId::DRAWING, sName );
}
}
}
}
ScTabViewShell* ScNavigatorDlg::GetTabViewShell()
{
return dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
......
......@@ -1720,6 +1720,9 @@ void ScTabViewObj::SelectionChanged()
/*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
}
}
SfxApplication::Get()->Broadcast( SfxHint( SfxHintId::ScSelectionChanged ) );
if ( !mbLeftMousePressed ) // selection still in progress
{
try
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment