diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-02-23 12:30:02 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-02-23 19:43:16 +0100 |
commit | 1f159a4df7dcf9c4b1a35d16aee2303b8fa34b27 (patch) | |
tree | fcdc16306b256bb3b48f189b08cd213358eaee71 /sd/source | |
parent | aae1b8f47f7fd4d88e4ded348ee3afdbb5208855 (diff) |
tdf#115873 sd navigator: adapt IsEqualToDoc() to Fill() further
SdPageObjsTLB::Fill() populates the navigator tree list box,
SdPageObjsTLB::IsEqualToDoc() determintes if it has to be refreshed or
not.
Commit f3c68cdf8f6a0273c62b493552f78af0138a44e8 (tdf#115873 sd
navigator: allow selecting but not focusing on objects, 2018-02-21)
already brought IsEqualToDoc() closer to Fill() with using the same
iteration mode for the SdrObjects, but that's not enough.
Fill() uses flat iteration, then checks for group shapes explicitly and
visits them recursively. Change IsEqualToDoc() to do the same, this way
selecting "Rectangle 3" in the testcase won't result in a jump back to
"Slide 1" (as an effect of IsEqualToDoc() returning false for an up to
date tree list box).
Change-Id: If2543cbc282af06ba43d4804e7ed455c8b9828cd
Reviewed-on: https://gerrit.libreoffice.org/50234
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/dlg/sdtreelb.cxx | 82 | ||||
-rw-r--r-- | sd/source/ui/inc/sdtreelb.hxx | 3 |
2 files changed, 51 insertions, 34 deletions
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index 71ac14cd518a..42e34374fc02 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -629,6 +629,52 @@ void SdPageObjsTLB::SetShowAllShapes ( } } +bool SdPageObjsTLB::IsEqualToShapeList(SvTreeListEntry*& pEntry, const SdrObjList& rList, + const OUString& rListName) +{ + if (!pEntry) + return false; + OUString aName = GetEntryText(pEntry); + + if (rListName != aName) + return false; + + pEntry = Next(pEntry); + + SdrObjListIter aIter(rList, + !rList.HasObjectNavigationOrder() /* use navigation order, if available */, + SdrIterMode::Flat); + + while (aIter.IsMore()) + { + SdrObject* pObj = aIter.Next(); + + const OUString aObjectName(GetObjectName(pObj)); + + if (!aObjectName.isEmpty()) + { + if (!pEntry) + return false; + + aName = GetEntryText(pEntry); + + if (aObjectName != aName) + return false; + + if (pObj->IsGroupObject()) + { + bool bRet = IsEqualToShapeList(pEntry, *pObj->GetSubList(), aObjectName); + if (!bRet) + return false; + } + else + pEntry = Next(pEntry); + } + } + + return true; +} + /** * Checks if the pages (PageKind::Standard) of a doc and the objects on the pages * are identical to the TreeLB. @@ -643,9 +689,7 @@ bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc ) if( !mpDoc ) return false; - SdrObject* pObj = nullptr; SvTreeListEntry* pEntry = First(); - OUString aName; // compare all pages including the objects sal_uInt16 nPage = 0; @@ -656,39 +700,9 @@ bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc ) const SdPage* pPage = static_cast<const SdPage*>( mpDoc->GetPage( nPage ) ); if( pPage->GetPageKind() == PageKind::Standard ) { - if( !pEntry ) - return false; - aName = GetEntryText( pEntry ); - - if( pPage->GetName() != aName ) + bool bRet = IsEqualToShapeList(pEntry, *pPage, pPage->GetName()); + if (!bRet) return false; - - pEntry = Next( pEntry ); - - SdrObjListIter aIter( - *pPage, - !pPage->HasObjectNavigationOrder() /* use navigation order, if available */, - SdrIterMode::Flat ); - - while( aIter.IsMore() ) - { - pObj = aIter.Next(); - - const OUString aObjectName( GetObjectName( pObj ) ); - - if( !aObjectName.isEmpty() ) - { - if( !pEntry ) - return false; - - aName = GetEntryText( pEntry ); - - if( aObjectName != aName ) - return false; - - pEntry = Next( pEntry ); - } - } } nPage++; } diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx index 7f51a9aeb261..b358e376672b 100644 --- a/sd/source/ui/inc/sdtreelb.hxx +++ b/sd/source/ui/inc/sdtreelb.hxx @@ -205,6 +205,9 @@ public: bool GetShowAllShapes() const { return mbShowAllShapes;} bool IsNavigationGrabsFocus() const { return mbNavigationGrabsFocus; } bool IsEqualToDoc( const SdDrawDocument* pInDoc ); + /// Visits rList recursively and tries to advance pEntry accordingly. + bool IsEqualToShapeList(SvTreeListEntry*& pEntry, const SdrObjList& rList, + const OUString& rListName); bool HasSelectedChildren( const OUString& rName ); bool SelectEntry( const OUString& rName ); OUString GetSelectedEntry(); |