tdf#155393 SdNavigator: Enhancement to navigate in Notes view

Change-Id: Icea71217fa5ffadc637bd7d9b8cae2fa18ec93bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152075
Tested-by: Jenkins
Reviewed-by: Stéphane Guillou <stephane.guillou@libreoffice.org>
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx
index 2bdfaef..ca6bc10 100644
--- a/sd/source/ui/dlg/navigatr.cxx
+++ b/sd/source/ui/dlg/navigatr.cxx
@@ -778,6 +778,7 @@ void SdNavigatorControllerItem::StateChangedAtToolBoxControl( sal_uInt16 nSId,
                static_cast<::sd::DrawViewShell *>(pDrawDocShell->GetViewShell());
        if (pDrawViewShell)
        {
            pNavigatorWin->FreshTree(pDrawDocShell->GetDoc());
            bool bEditModePage(pDrawViewShell->GetEditMode() == EditMode::Page);
            pNavigatorWin->mxToolbox->set_sensitive(bEditModePage);
            pNavigatorWin->mxLbDocs->set_sensitive(bEditModePage);
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index e39099a..45b078d 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -56,9 +56,21 @@
#include <vcl/commandevent.hxx>

#include <svx/svdview.hxx>
#include <DrawViewShell.hxx>

using namespace com::sun::star;

namespace {

sd::DrawViewShell* lcl_getDrawViewShell(const SdDrawDocument* pDoc)
{
    if (!pDoc || !pDoc->GetDocSh())
        return nullptr;
    return static_cast<sd::DrawViewShell*>(pDoc->GetDocSh()->GetViewShell());
}

}

bool SdPageObjsTLV::bIsInDrag = false;

bool SdPageObjsTLV::IsInDrag()
@@ -251,6 +263,13 @@ bool SdPageObjsTLV::IsEqualToDoc( const SdDrawDocument* pInDoc )
    if( !m_pDoc )
        return false;

    sd::DrawViewShell* pDrawViewShell = lcl_getDrawViewShell(m_pDoc);
    if (!pDrawViewShell)
        return false;
    PageKind eDrawViewShellPageKind = pDrawViewShell->GetPageKind();
    if (eDrawViewShellPageKind != PageKind::Standard && eDrawViewShellPageKind != PageKind::Notes)
        return false;

    std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
    if (!m_xTreeView->get_iter_first(*xEntry))
        xEntry.reset();
@@ -262,7 +281,7 @@ bool SdPageObjsTLV::IsEqualToDoc( const SdDrawDocument* pInDoc )
    while( nPage < nMaxPages )
    {
        const SdPage* pPage = static_cast<const SdPage*>( m_pDoc->GetPage( nPage ) );
        if( pPage->GetPageKind() == PageKind::Standard )
        if (pPage->GetPageKind() == eDrawViewShellPageKind)
        {
            bool bRet = IsEqualToShapeList(xEntry, *pPage, pPage->GetName());
            if (!bRet)
@@ -1247,11 +1266,21 @@ void SdPageObjsTLV::Fill(const SdDrawDocument* pInDoc, bool bAllPages, const OUS
    sal_uInt16 nPage = 0;
    const sal_uInt16 nMaxPages = m_pDoc->GetPageCount();

    sd::DrawViewShell* pDrawViewShell = lcl_getDrawViewShell(m_pDoc);
    if (!pDrawViewShell)
        return;
    PageKind eDrawViewShellPageKind = pDrawViewShell->GetPageKind();

    while( nPage < nMaxPages )
    {
        const SdPage* pPage = static_cast<const SdPage*>( m_pDoc->GetPage( nPage ) );
        if(  (m_bShowAllPages || pPage->GetPageKind() == PageKind::Standard)
             && (pPage->GetPageKind() != PageKind::Handout)   ) //#94954# never list the normal handout page ( handout-masterpage is used instead )
        PageKind ePagePageKind = pPage->GetPageKind();
        if ((m_bShowAllPages ||
             (ePagePageKind == PageKind::Standard &&
              eDrawViewShellPageKind == PageKind::Standard) ||
             (ePagePageKind == PageKind::Notes &&
              eDrawViewShellPageKind == PageKind::Notes)) &&
                ePagePageKind != PageKind::Handout) //#94954# never list the normal handout page ( handout-masterpage is used instead )
        {
            bool bPageExcluded = pPage->IsExcluded();