diff options
author | Kurt Zenker <kz@openoffice.org> | 2011-04-13 18:08:13 +0200 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2011-04-13 18:08:13 +0200 |
commit | 28fb3a91b6b35af9fb34b522ae8eb7bba5cda6b0 (patch) | |
tree | ba375ce276e82f042229e67f5339e23e53fb845b /sd/source/ui/dlg/sdtreelb.cxx | |
parent | 2e75597469946098faac5353ad724c3e16a34439 (diff) | |
parent | 8dbc86aa82fb73668816f228779b2094de546aa0 (diff) |
CWS-TOOLING: integrate CWS impress211_OOO340
Diffstat (limited to 'sd/source/ui/dlg/sdtreelb.cxx')
-rwxr-xr-x | sd/source/ui/dlg/sdtreelb.cxx | 126 |
1 files changed, 100 insertions, 26 deletions
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index 263f221332d6..c8c794a40041 100755 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -53,11 +53,16 @@ #include "strings.hrc" #endif #include "res_bmp.hrc" +#include "ViewShell.hxx" +#include "DrawController.hxx" +#include "ViewShellBase.hxx" #include <com/sun/star/embed/XEmbedPersist.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/frame/XFramesSupplier.hpp> #include <svtools/embedtransfer.hxx> +#include <comphelper/processfactory.hxx> #include <tools/diagnose_ex.h> -#include <ViewShell.hxx> using namespace com::sun::star; @@ -153,6 +158,7 @@ sal_Bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const ::com::sun::star: void SdPageObjsTLB::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction ) { mrParent.OnDragFinished( nDropAction ); + SdTransferable::DragFinished(nDropAction); } // ----------------------------------------------------------------------------- @@ -234,6 +240,9 @@ sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId (void) return mnListBoxDropFormatId; } + + + /************************************************************************* |* |* Ctor1 SdPageObjsTLB @@ -1049,6 +1058,11 @@ void SdPageObjsTLB::DoDrag() if( eDragType == NAVIGATOR_DRAGTYPE_LINK ) nDNDActions = DND_ACTION_LINK; // #93240# Either COPY *or* LINK, never both! + else if (mpDoc->GetSdPageCount(PK_STANDARD) == 1) + { + // Can not move away the last slide in a document. + nDNDActions = DND_ACTION_COPY; + } SvTreeListBox::ReleaseMouse(); @@ -1066,16 +1080,15 @@ void SdPageObjsTLB::DoDrag() // object is destroyed by internal reference mechanism SdTransferable* pTransferable = new SdPageObjsTLB::SdPageObjsTransferable( *this, aBookmark, *pDocShell, eDragType, aTreeListBoxData); - OSL_TRACE("created new SdPageObjsTransferable at %x", pTransferable); // Get the view. - sd::View* pView = NULL; - if (pDocShell != NULL) + ::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell); + if (pViewShell == NULL) { - ::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); - if (pViewShell != NULL) - pView = pViewShell->GetView(); + OSL_ASSERT(pViewShell!=NULL); + return; } + sd::View* pView = pViewShell->GetView(); if (pView == NULL) { OSL_ASSERT(pView!=NULL); @@ -1086,27 +1099,32 @@ void SdPageObjsTLB::DoDrag() void* pUserData = GetCurEntry()->GetUserData(); if (pUserData != NULL && pUserData != (void*)1) pObject = reinterpret_cast<SdrObject*>(pUserData); - if (pObject == NULL) - return; + if (pObject != NULL) + { + // For shapes without a user supplied name (the automatically + // created name does not count), a different drag and drop technique + // is used. + if (GetObjectName(pObject, false).Len() == 0) + { + AddShapeToTransferable(*pTransferable, *pObject); + pTransferable->SetView(pView); + SD_MOD()->pTransferDrag = pTransferable; + } - // For shapes without a user supplied name (the automatically - // created name does not count), a different drag and drop technique - // is used. - if (GetObjectName(pObject, false).Len() == 0) + // Unnamed shapes have to be selected to be recognized by the + // current drop implementation. In order to have a consistent + // behaviour for all shapes, every shape that is to be dragged is + // selected first. + SdrPageView* pPageView = pView->GetSdrPageView(); + pView->UnmarkAllObj(pPageView); + pView->MarkObj(pObject, pPageView); + } + else { - AddShapeToTransferable(*pTransferable, *pObject); pTransferable->SetView(pView); SD_MOD()->pTransferDrag = pTransferable; } - // Unnamed shapes have to be selected to be recognized by the - // current drop implementation. In order to have a consistent - // behaviour for all shapes, every shape that is to be dragged is - // selected first. - SdrPageView* pPageView = pView->GetSdrPageView(); - pView->UnmarkAllObj(pPageView); - pView->MarkObj(pObject, pPageView); - pTransferable->StartDrag( this, nDNDActions ); } } @@ -1337,8 +1355,6 @@ SvLBoxEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation) if (pEntry == NULL) return NULL; - OSL_TRACE("entry is %s", - ::rtl::OUStringToOString(GetEntryText(pEntry), RTL_TEXTENCODING_UTF8).getStr()); if (GetParent(pEntry) == NULL) { // Use page entry as insertion position. @@ -1361,8 +1377,6 @@ SvLBoxEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation) else break; } - OSL_TRACE("returning %s", - ::rtl::OUStringToOString(GetEntryText(pEntry), RTL_TEXTENCODING_UTF8).getStr()); } return pEntry; @@ -1441,6 +1455,66 @@ void SdPageObjsTLB::AddShapeToTransferable ( +::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell) +{ + { + ::sd::ViewShell* pViewShell = rDocShell.GetViewShell(); + if (pViewShell != NULL) + return pViewShell; + } + + try + { + // Get a component enumeration from the desktop and search it for documents. + uno::Reference<lang::XMultiServiceFactory> xFactory ( + ::comphelper::getProcessServiceFactory ()); + if ( ! xFactory.is()) + return NULL; + + uno::Reference<frame::XDesktop> xDesktop (xFactory->createInstance ( + ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), uno::UNO_QUERY); + if ( ! xDesktop.is()) + return NULL; + + uno::Reference<frame::XFramesSupplier> xFrameSupplier (xDesktop, uno::UNO_QUERY); + if ( ! xFrameSupplier.is()) + return NULL; + + uno::Reference<container::XIndexAccess> xFrameAccess (xFrameSupplier->getFrames(), uno::UNO_QUERY); + if ( ! xFrameAccess.is()) + return NULL; + + for (sal_Int32 nIndex=0,nCount=xFrameAccess->getCount(); nIndex<nCount; ++nIndex) + { + uno::Reference<frame::XFrame> xFrame; + if ( ! (xFrameAccess->getByIndex(nIndex) >>= xFrame)) + continue; + + ::sd::DrawController* pController = dynamic_cast<sd::DrawController*>(xFrame->getController().get()); + if (pController == NULL) + continue; + ::sd::ViewShellBase* pBase = pController->GetViewShellBase(); + if (pBase == NULL) + continue; + if (pBase->GetDocShell() != &rDocShell) + continue; + + const ::boost::shared_ptr<sd::ViewShell> pViewShell (pBase->GetMainViewShell()); + if (pViewShell) + return pViewShell.get(); + } + } + catch (uno::Exception e) + { + // When there is an exception then simply use the default value of + // bIsEnabled and disable the controls. + } + return NULL; +} + + + + //===== IconProvider ========================================================== SdPageObjsTLB::IconProvider::IconProvider (void) |