[Libreoffice-commits] core.git: sd/source
Fernando Pirani
feremp.i+lodev at gmail.com
Thu Dec 24 03:32:29 PST 2015
sd/source/ui/dlg/sdtreelb.cxx | 2
sd/source/ui/docshell/docshel4.cxx | 106 +++++--------------------------------
sd/source/ui/inc/DrawDocShell.hxx | 5 -
3 files changed, 19 insertions(+), 94 deletions(-)
New commits:
commit 9a383588ada2146775dbe19405d5dda28be8d940
Author: Fernando Pirani <feremp.i+lodev at gmail.com>
Date: Tue Aug 4 07:51:32 2015 -0300
tdf#84846 Merge identical GotoTreeBookmark into GetObjectIsMarked
Removed some duplicate code.
All current behavior should stay the same.
Merged GotoTreeBookmark into the almost identical GetObjectIsMarked:
> Added a bool parameter to control the behavior of GetObjectIsMarked
> There was only 1 call to GotoTreeBookmark in the whole code.
Replaced it with a call to GetObjectIsMarked
Change-Id: I3594512d0ff425ab2bd5636845d0e703dee85d52
Reviewed-on: https://gerrit.libreoffice.org/17505
Reviewed-by: jan iversen <jani at documentfoundation.org>
Tested-by: jan iversen <jani at documentfoundation.org>
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 4fd673a..e7cd06b 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -1109,7 +1109,7 @@ void SdPageObjsTLB::KeyInput( const KeyEvent& rKEvt )
sd::DrawDocShell* pSdDrawDocShell = SdNavigatorWin::GetDrawDocShell(mpDoc);
if (pSdDrawDocShell)
{
- pSdDrawDocShell->GotoTreeBookmark(aStr);
+ pSdDrawDocShell->GetObjectIsmarked(aStr, true);
bMarked = pSdDrawDocShell->GetObjectIsmarked(aStr);
}
pNewEntry->SetMarked(bMarked);
diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
index 0ab60d2..6b9ce0b 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -618,7 +618,7 @@ bool DrawDocShell::ConvertTo( SfxMedium& rMedium )
}
}
- return bRet;
+ return bRet;
}
/**
@@ -845,15 +845,16 @@ bool DrawDocShell::IsMarked( SdrObject* pObject )
bisMarked = pDrViewSh->GetView()->IsObjMarked(pObject);
}
}
- return bisMarked;
+ return bisMarked;
}
-// If object is marked return true else return false.
-bool DrawDocShell::GetObjectIsmarked(const OUString& rBookmark)
+// If object is marked return true else return false. Optionally realize multi-selection of objects.
+bool DrawDocShell::GetObjectIsmarked(const OUString& rBookmark, bool bRealizeMultiSelectionOfObjects /* = false */)
{
OSL_TRACE("GotoBookmark %s",
OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
bool bUnMark = false;
+ bool bFound = false;
if (mpViewShell && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr)
{
@@ -885,6 +886,7 @@ bool DrawDocShell::GetObjectIsmarked(const OUString& rBookmark)
/********************
* Skip to the page *
********************/
+ bFound = true;
SdPage* pPage = static_cast<SdPage*>( mpDoc->GetPage(nPgNum) );
PageKind eNewPageKind = pPage->GetPageKind();
@@ -918,99 +920,23 @@ bool DrawDocShell::GetObjectIsmarked(const OUString& rBookmark)
// Show and select object
pDrViewSh->MakeVisible(pObj->GetLogicRect(),
*pDrViewSh->GetActiveWindow());
-
bUnMark = pDrViewSh->GetView()->IsObjMarked(pObj);
+ if (bRealizeMultiSelectionOfObjects)
+ {
+ pDrViewSh->GetView()->MarkObj(pObj, pDrViewSh->GetView()->GetSdrPageView(), bUnMark);
+ }
}
}
- }
-
- return ( bUnMark);
-}
-
-// realize multi-selection of objects
-bool DrawDocShell::GotoTreeBookmark(const OUString& rBookmark)
-{
- OSL_TRACE("GotoBookmark %s",
- OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
- bool bFound = false;
-
- if (mpViewShell && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr)
- {
- DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>( mpViewShell );
-
- OUString aBookmark( rBookmark );
-
- if( rBookmark.startsWith("#") )
- aBookmark = rBookmark.copy( 1 );
-
- // is the bookmark a page ?
- bool bIsMasterPage;
- sal_uInt16 nPgNum = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
- SdrObject* pObj = nullptr;
-
- if (nPgNum == SDRPAGE_NOTFOUND)
+ if (bRealizeMultiSelectionOfObjects)
{
- // is the bookmark an object ?
- pObj = mpDoc->GetObj(aBookmark);
-
- if (pObj)
- {
- nPgNum = pObj->GetPage()->GetPageNum();
- }
+ SfxBindings& rBindings = ( ( mpViewShell && mpViewShell->GetViewFrame() ) ?
+ mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->GetBindings();
+ rBindings.Invalidate(SID_NAVIGATOR_STATE, true);
+ rBindings.Invalidate(SID_NAVIGATOR_PAGENAME);
}
-
- if (nPgNum != SDRPAGE_NOTFOUND)
- {
- /********************
- * Skip to the page *
- ********************/
- bFound = true;
- SdPage* pPage = static_cast<SdPage*>( mpDoc->GetPage(nPgNum) );
-
- PageKind eNewPageKind = pPage->GetPageKind();
-
- if (eNewPageKind != pDrViewSh->GetPageKind())
- {
- // change workspace
- GetFrameView()->SetPageKind(eNewPageKind);
- ( ( mpViewShell && mpViewShell->GetViewFrame() ) ?
- mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->
- GetDispatcher()->Execute( SID_VIEWSHELL0, SfxCallMode::SYNCHRON | SfxCallMode::RECORD );
-
- // The current ViewShell changed
- pDrViewSh = static_cast<DrawViewShell*>( mpViewShell );
- }
-
- setEditMode(pDrViewSh, bIsMasterPage);
-
- // Jump to the page. This is done by using the API because this
- // takes care of all the little things to be done. Especially
- // writing the view data to the frame view (see bug #107803#).
- SdUnoDrawView* pUnoDrawView = new SdUnoDrawView (
- *pDrViewSh,
- *pDrViewSh->GetView());
- css::uno::Reference<css::drawing::XDrawPage> xDrawPage( pPage->getUnoPage(), css::uno::UNO_QUERY);
- pUnoDrawView->setCurrentPage (xDrawPage);
- delete pUnoDrawView;
-
- if (pObj)
- {
- // Show and select object
- pDrViewSh->MakeVisible(pObj->GetLogicRect(),
- *pDrViewSh->GetActiveWindow());
- bool bUnMark = pDrViewSh->GetView()->IsObjMarked(pObj);
- pDrViewSh->GetView()->MarkObj(pObj, pDrViewSh->GetView()->GetSdrPageView(), bUnMark);
- }
- }
-
- SfxBindings& rBindings = ( ( mpViewShell && mpViewShell->GetViewFrame() ) ?
- mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->GetBindings();
-
- rBindings.Invalidate(SID_NAVIGATOR_STATE, true);
- rBindings.Invalidate(SID_NAVIGATOR_PAGENAME);
}
- return (bFound);
+ return bRealizeMultiSelectionOfObjects ? bFound : bUnMark;
}
/**
diff --git a/sd/source/ui/inc/DrawDocShell.hxx b/sd/source/ui/inc/DrawDocShell.hxx
index b43f84b..8aa9b3b 100644
--- a/sd/source/ui/inc/DrawDocShell.hxx
+++ b/sd/source/ui/inc/DrawDocShell.hxx
@@ -132,10 +132,9 @@ public:
bool GotoBookmark(const OUString& rBookmark);
- //realize multi-selection of objects
- bool GotoTreeBookmark(const OUString& rBookmark);
bool IsMarked( SdrObject* pObject );
- bool GetObjectIsmarked(const OUString& rBookmark);
+ // Optionally realize multi-selection of objects
+ bool GetObjectIsmarked(const OUString& rBookmark, bool bRealizeMultiSelectionOfObjects = false);
Bitmap GetPagePreviewBitmap(SdPage* pPage, sal_uInt16 nMaxEdgePixel);
/** checks, if the given name is a valid new name for a slide
More information about the Libreoffice-commits
mailing list