From 89ae9990f2c2b520445b2a27b8675c50872394f9 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Thu, 10 Feb 2011 09:09:49 +0100 Subject: impress211: #i115688# Forwarding result of ::Window::Notify(). --- sd/source/ui/view/sdwindow.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx index ed5dda39037c..0ddcec80c480 100755 --- a/sd/source/ui/view/sdwindow.cxx +++ b/sd/source/ui/view/sdwindow.cxx @@ -359,7 +359,7 @@ long Window::Notify( NotifyEvent& rNEvt ) nResult = mpViewShell->Notify(rNEvt, this); } if( !nResult ) - ::Window::Notify( rNEvt ); + nResult = ::Window::Notify( rNEvt ); return nResult; } -- cgit From 5b5932190f97f3f2c59578b16f1d643bf269ca35 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Thu, 17 Feb 2011 10:24:49 +0100 Subject: impress211: #i114732# Revoke comphelper notification client only when it was previously registered. --- sd/source/ui/accessibility/AccessibleTreeNode.cxx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sd/source/ui/accessibility/AccessibleTreeNode.cxx b/sd/source/ui/accessibility/AccessibleTreeNode.cxx index ced9852b74c3..137ae572ead8 100755 --- a/sd/source/ui/accessibility/AccessibleTreeNode.cxx +++ b/sd/source/ui/accessibility/AccessibleTreeNode.cxx @@ -134,8 +134,11 @@ void SAL_CALL AccessibleTreeNode::disposing (void) // probably are by now more or less dead and we must not call them to // unregister. - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); - mnClientId = 0; + if (mnClientId != 0) + { + comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); + mnClientId = 0; + } } @@ -361,9 +364,10 @@ void SAL_CALL AccessibleTreeNode::addEventListener( } else { - if ( ! mnClientId) + if (mnClientId == 0) mnClientId = comphelper::AccessibleEventNotifier::registerClient(); - comphelper::AccessibleEventNotifier::addEventListener(mnClientId, rxListener); + if (mnClientId != 0) + comphelper::AccessibleEventNotifier::addEventListener(mnClientId, rxListener); } } } @@ -387,8 +391,11 @@ void SAL_CALL AccessibleTreeNode::removeEventListener( // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), // and at least to us not firing any events anymore, in case somebody calls // NotifyAccessibleEvent, again - comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); - mnClientId = 0; + if (mnClientId != 0) + { + comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); + mnClientId = 0; + } } } } -- cgit From 7c580a86a804f5bf61b2d9d888f13d981f221989 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Mon, 7 Mar 2011 10:55:11 +0100 Subject: impress211: #i116339# Added call to Reschedule to compensate for missing yield. --- sd/source/ui/slideshow/slideshowimpl.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx index 67ac7e94cadb..cbfe02127d05 100755 --- a/sd/source/ui/slideshow/slideshowimpl.cxx +++ b/sd/source/ui/slideshow/slideshowimpl.cxx @@ -1913,6 +1913,7 @@ IMPL_LINK( SlideshowImpl, PostYieldListener, void*, EMPTYARG ) Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener)); if (mbDisposed) return 0; + Application::Reschedule(true); return updateSlideShow(); } -- cgit From 971211f8e19173684b99e41f7229f7f33f680307 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Tue, 8 Mar 2011 17:22:13 +0100 Subject: impress211: #i88880# Fixed dragging of slides from navigator to slide sorter. --- sd/source/ui/app/sdxfer.cxx | 47 ++++++ sd/source/ui/dlg/sdtreelb.cxx | 126 ++++++++++++--- sd/source/ui/inc/sdtreelb.hxx | 16 +- sd/source/ui/inc/sdxfer.hxx | 32 +++- .../controller/SlideSorterController.cxx | 5 +- .../ui/slidesorter/controller/SlsClipboard.cxx | 178 ++++++++++++++++++--- .../controller/SlsDragAndDropContext.cxx | 19 ++- .../controller/SlsInsertionIndicatorHandler.cxx | 2 +- .../controller/SlsSelectionFunction.cxx | 2 +- .../ui/slidesorter/controller/SlsTransferable.cxx | 101 ------------ .../slidesorter/controller/SlsTransferableData.cxx | 145 +++++++++++++++++ sd/source/ui/slidesorter/controller/makefile.mk | 2 +- .../ui/slidesorter/inc/controller/SlsClipboard.hxx | 23 ++- .../controller/SlsInsertionIndicatorHandler.hxx | 4 +- .../slidesorter/inc/controller/SlsTransferable.hxx | 87 ---------- .../inc/controller/SlsTransferableData.hxx | 98 ++++++++++++ .../ui/slidesorter/inc/view/SlideSorterView.hxx | 2 + .../inc/view/SlsInsertionIndicatorOverlay.hxx | 9 +- sd/source/ui/slidesorter/view/SlideSorterView.cxx | 12 +- .../view/SlsInsertionIndicatorOverlay.cxx | 12 +- 20 files changed, 659 insertions(+), 263 deletions(-) mode change 100644 => 100755 sd/source/ui/app/sdxfer.cxx mode change 100644 => 100755 sd/source/ui/inc/sdxfer.hxx delete mode 100755 sd/source/ui/slidesorter/controller/SlsTransferable.cxx create mode 100755 sd/source/ui/slidesorter/controller/SlsTransferableData.cxx delete mode 100644 sd/source/ui/slidesorter/inc/controller/SlsTransferable.hxx create mode 100644 sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx old mode 100644 new mode 100755 index ddbc0698a341..1fda5da7da5c --- a/sd/source/ui/app/sdxfer.cxx +++ b/sd/source/ui/app/sdxfer.cxx @@ -123,6 +123,7 @@ SdTransferable::SdTransferable( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, , mbPageTransferable( FALSE ) , mbPageTransferablePersistent( FALSE ) , mbIsUnoObj( false ) +, maUserData() { if( mpSourceDoc ) StartListening( *mpSourceDoc ); @@ -798,6 +799,52 @@ sal_Int64 SAL_CALL SdTransferable::getSomething( const ::com::sun::star::uno::Se return nRet; } + + + +SdDrawDocument* SdTransferable::GetSourceDoc (void) const +{ + return mpSourceDoc; +} + + + + +void SdTransferable::AddUserData (const ::boost::shared_ptr& rpData) +{ + maUserData.push_back(rpData); +} + + + + +void SdTransferable::RemoveUserData (const ::boost::shared_ptr& rpData) +{ + maUserData.erase(::std::find(maUserData.begin(), maUserData.end(), rpData)); +} + + + + +sal_Int32 SdTransferable::GetUserDataCount (void) const +{ + return maUserData.size(); +} + + + + +::boost::shared_ptr SdTransferable::GetUserData (const sal_Int32 nIndex) const +{ + if (nIndex>=0 && nIndex(); +} + + + + // ----------------------------------------------------------------------------- const ::com::sun::star::uno::Sequence< sal_Int8 >& SdTransferable::getUnoTunnelId() diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index c0a72d539add..d561dbac588c 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 +#include +#include #include +#include #include -#include 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(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 xFactory ( + ::comphelper::getProcessServiceFactory ()); + if ( ! xFactory.is()) + return NULL; + + uno::Reference xDesktop (xFactory->createInstance ( + ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), uno::UNO_QUERY); + if ( ! xDesktop.is()) + return NULL; + + uno::Reference xFrameSupplier (xDesktop, uno::UNO_QUERY); + if ( ! xFrameSupplier.is()) + return NULL; + + uno::Reference xFrameAccess (xFrameSupplier->getFrames(), uno::UNO_QUERY); + if ( ! xFrameAccess.is()) + return NULL; + + for (sal_Int32 nIndex=0,nCount=xFrameAccess->getCount(); nIndex xFrame; + if ( ! (xFrameAccess->getByIndex(nIndex) >>= xFrame)) + continue; + + ::sd::DrawController* pController = dynamic_cast(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 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) diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx index 1aea2d34156e..002e58803ea4 100755 --- a/sd/source/ui/inc/sdtreelb.hxx +++ b/sd/source/ui/inc/sdtreelb.hxx @@ -40,6 +40,8 @@ #include #include #include "sdxfer.hxx" +#include +#include class SdDrawDocument; class SfxMedium; @@ -51,6 +53,8 @@ class SdPage; class SvLBoxEntry; namespace sd { +class ViewShell; + class DrawDocShell; #ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED #define SV_DECL_DRAW_DOC_SHELL_DEFINED @@ -104,7 +108,6 @@ public: ::sd::DrawDocShell& mrDocShell; NavigatorDragType meDragType; const ::com::sun::star::uno::Any maTreeListBoxData; - SD_DLLPRIVATE virtual ~SdPageObjsTransferable(); SD_DLLPRIVATE virtual void AddSupportedFormats(); @@ -219,6 +222,17 @@ public: using SvLBox::ExecuteDrop; using SvTreeListBox::SelectEntry; + + /** Return the view shell that is linked to the given doc shell. + Call this method when the there is a chance that the doc shell + has been disconnected from the view shell (but not the other + way round.) + @return + May return when the link between view shell and + doc shell has been severed. + */ + static ::sd::ViewShell* GetViewShellForDocShell (::sd::DrawDocShell &rDocShell); + private: /** This flag controls whether all shapes are shown as children of pages and group shapes or only the named shapes. diff --git a/sd/source/ui/inc/sdxfer.hxx b/sd/source/ui/inc/sdxfer.hxx old mode 100644 new mode 100755 index d79e5d653ab4..e73e4a3f0ad8 --- a/sd/source/ui/inc/sdxfer.hxx +++ b/sd/source/ui/inc/sdxfer.hxx @@ -89,12 +89,41 @@ public: // SfxListener virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + virtual void DragFinished( sal_Int8 nDropAction ); + SdDrawDocument* GetSourceDoc (void) const; + + /** User data objects can be used to store information temporarily + at the transferable. The slide sorter uses this to store + previews of the slides that are referenced by the + transferable. + */ + class UserData {public:virtual~UserData(){}}; + + /** Add a user data object. When it was added before (and not + removed) then this call is ignored. + */ + void AddUserData (const ::boost::shared_ptr& rpData); + + /** Remove a previously added user data object. When the object + was never added or removed before then this call is ignored. + */ + void RemoveUserData (const ::boost::shared_ptr& rpData); + + /** Return the number of user data objects. + */ + sal_Int32 GetUserDataCount (void) const; + + /** Return the specified user data object. When the index is not + valid, ie not in the range [0,count) then an empty pointer is + returned. + */ + ::boost::shared_ptr GetUserData (const sal_Int32 nIndex) const; + protected: virtual void AddSupportedFormats(); virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); - virtual void DragFinished( sal_Int8 nDropAction ); virtual void ObjectReleased(); virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException ); @@ -124,6 +153,7 @@ private: BOOL mbPageTransferable : 1; BOOL mbPageTransferablePersistent : 1; bool mbIsUnoObj : 1; + ::std::vector > maUserData; // not available SdTransferable(); diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx index 8018c71e2b88..50e2a7c22ac6 100644 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx @@ -43,7 +43,7 @@ #include "controller/SlsScrollBarManager.hxx" #include "controller/SlsSelectionManager.hxx" #include "controller/SlsSlotManager.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsTransferableData.hxx" #include "controller/SlsVisibleAreaManager.hxx" #include "model/SlideSorterModel.hxx" #include "model/SlsPageEnumerationProvider.hxx" @@ -422,8 +422,7 @@ bool SlideSorterController::Command ( // indicator so that the user knows where a page insertion // would take place. mpInsertionIndicatorHandler->Start(false); - mpInsertionIndicatorHandler->UpdateIndicatorIcon( - dynamic_cast(SD_MOD()->pTransferClip)); + mpInsertionIndicatorHandler->UpdateIndicatorIcon(SD_MOD()->pTransferClip); mpInsertionIndicatorHandler->UpdatePosition( pWindow->PixelToLogic(rEvent.GetMousePosPixel()), InsertionIndicatorHandler::MoveMode); diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index 68ae50e091e7..46382032ef71 100755 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -44,11 +44,12 @@ #include "controller/SlsScrollBarManager.hxx" #include "controller/SlsFocusManager.hxx" #include "controller/SlsSelectionManager.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsTransferableData.hxx" #include "controller/SlsSelectionObserver.hxx" #include "cache/SlsPageCache.hxx" #include "ViewShellBase.hxx" +#include "View.hxx" #include "DrawViewShell.hxx" #include "Window.hxx" #include "fupoor.hxx" @@ -69,6 +70,7 @@ #include "drawdoc.hxx" #include "DrawDocShell.hxx" #include "sdpage.hxx" +#include "sdtreelb.hxx" #include #include @@ -82,9 +84,12 @@ #include #include #include +#include + namespace sd { namespace slidesorter { namespace controller { + class Clipboard::UndoContext { public: @@ -412,7 +417,7 @@ void Clipboard::CreateSlideTransferable ( // previews are included into the transferable so that an insertion // indicator can be rendered. aSelectedPages.Rewind(); - ::std::vector aRepresentatives; + ::std::vector aRepresentatives; aRepresentatives.reserve(3); ::boost::shared_ptr pPreviewCache ( mrSlideSorter.GetView().GetPreviewCache()); @@ -422,7 +427,7 @@ void Clipboard::CreateSlideTransferable ( if ( ! pDescriptor || pDescriptor->GetPage()==NULL) continue; Bitmap aPreview (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage(), false)); - aRepresentatives.push_back(Transferable::Representative( + aRepresentatives.push_back(TransferableData::Representative( aPreview, pDescriptor->HasState(model::PageDescriptor::ST_Excluded))); if (aRepresentatives.size() >= 3) @@ -433,7 +438,7 @@ void Clipboard::CreateSlideTransferable ( { mrSlideSorter.GetView().BrkAction(); SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); - SdTransferable* pTransferable = new Transferable ( + SdTransferable* pTransferable = TransferableData::CreateTransferable ( pDocument, NULL, FALSE, @@ -491,6 +496,95 @@ void Clipboard::CreateSlideTransferable ( +::boost::shared_ptr Clipboard::CreateTransferableUserData (SdTransferable* pTransferable) +{ + do + { + SdPageObjsTLB::SdPageObjsTransferable* pTreeListBoxTransferable + = dynamic_cast(pTransferable); + if (pTreeListBoxTransferable == NULL) + break; + + // Find view shell for the document of the transferable. + ::sd::ViewShell* pViewShell + = SdPageObjsTLB::GetViewShellForDocShell(pTreeListBoxTransferable->GetDocShell()); + if (pViewShell == NULL) + break; + + // Find slide sorter for the document of the transferable. + SlideSorterViewShell* pSlideSorterViewShell + = SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase()); + if (pSlideSorterViewShell == NULL) + break; + SlideSorter& rSlideSorter (pSlideSorterViewShell->GetSlideSorter()); + + // Get bookmark from transferable. + TransferableDataHelper aDataHelper (pTransferable); + INetBookmark aINetBookmark; + if ( ! aDataHelper.GetINetBookmark(SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark)) + break; + const rtl::OUString sURL (aINetBookmark.GetURL()); + const sal_Int32 nIndex (sURL.indexOf((sal_Unicode)'#')); + if (nIndex == -1) + break; + String sBookmark (sURL.copy(nIndex+1)); + + // Make sure that the bookmark points to a page. + SdDrawDocument* pTransferableDocument = rSlideSorter.GetModel().GetDocument(); + if (pTransferableDocument == NULL) + break; + BOOL bIsMasterPage; + const USHORT nPageIndex (pTransferableDocument->GetPageByName(sBookmark, bIsMasterPage)); + if (nPageIndex == SDRPAGE_NOTFOUND) + break; + + // Create preview. + ::std::vector aRepresentatives; + aRepresentatives.reserve(1); + ::boost::shared_ptr pPreviewCache ( + rSlideSorter.GetView().GetPreviewCache()); + model::SharedPageDescriptor pDescriptor (rSlideSorter.GetModel().GetPageDescriptor((nPageIndex-1)/2)); + if ( ! pDescriptor || pDescriptor->GetPage()==NULL) + break; + Bitmap aPreview (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage(), false)); + aRepresentatives.push_back(TransferableData::Representative( + aPreview, + pDescriptor->HasState(model::PageDescriptor::ST_Excluded))); + + // Remember the page in maPagesToRemove so that it can be removed + // when drag and drop action is "move". + Clipboard& rOtherClipboard (pSlideSorterViewShell->GetSlideSorter().GetController().GetClipboard()); + rOtherClipboard.maPagesToRemove.clear(); + rOtherClipboard.maPagesToRemove.push_back(pDescriptor->GetPage()); + + // Create the new transferable. + ::boost::shared_ptr pNewTransferable ( + new TransferableData( + pSlideSorterViewShell, + aRepresentatives)); + pTransferable->SetWorkDocument( dynamic_cast( + pTreeListBoxTransferable->GetSourceDoc()->AllocModel())); + // pTransferable->SetView(&mrSlideSorter.GetView()); + + // Set page bookmark list. + List aPageBookmarks; + aPageBookmarks.Insert(new String(sBookmark)); + pTransferable->SetPageBookmarks(aPageBookmarks, false); + + // Replace the view referenced by the transferable with the + // corresponding slide sorter view. + pTransferable->SetView(&pSlideSorterViewShell->GetSlideSorter().GetView()); + + return pNewTransferable; + } + while (false); + + return ::boost::shared_ptr(); +} + + + + void Clipboard::StartDrag ( const Point& rPosition, ::Window* pWindow) @@ -511,8 +605,6 @@ void Clipboard::StartDrag ( void Clipboard::DragFinished (sal_Int8 nDropAction) { SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; - if (pDragTransferable != NULL) - pDragTransferable->SetView (NULL); if (mnDragFinishedUserEventId == 0) { @@ -590,11 +682,12 @@ sal_Int8 Clipboard::AcceptDrop ( { sal_Int8 nAction (DND_ACTION_NONE); - const Clipboard::DropType eDropType (IsDropAccepted()); + const Clipboard::DropType eDropType (IsDropAccepted(rTargetHelper)); switch (eDropType) { case DT_PAGE: + case DT_PAGE_FROM_NAVIGATOR: { // Accept a drop. nAction = rEvent.mnAction; @@ -602,7 +695,7 @@ sal_Int8 Clipboard::AcceptDrop ( // Use the copy action when the drop action is the default, i.e. not // explicitly set to move or link, and when the source and // target models are not the same. - const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; + SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; if (pDragTransferable != NULL && pDragTransferable->IsPageTransferable() && ((rEvent.maDragEvent.DropAction @@ -612,13 +705,12 @@ sal_Int8 Clipboard::AcceptDrop ( { nAction = DND_ACTION_COPY; } - else if (mrController.GetInsertionIndicatorHandler()->IsInsertionTrivial(nAction)) + else if (IsInsertionTrivial(pDragTransferable, nAction)) { nAction = DND_ACTION_NONE; } // Show the insertion marker and the substitution for a drop. - Point aPosition = pTargetWindow->PixelToLogic (rEvent.maPosPixel); SelectionFunction* pSelectionFunction = dynamic_cast( mrSlideSorter.GetViewShell()->GetCurrentFunction().get()); if (pSelectionFunction != NULL) @@ -641,6 +733,7 @@ sal_Int8 Clipboard::AcceptDrop ( break; default: + case DT_NONE: nAction = DND_ACTION_NONE; break; } @@ -660,12 +753,14 @@ sal_Int8 Clipboard::ExecuteDrop ( { sal_Int8 nResult = DND_ACTION_NONE; mpUndoContext.reset(); + const Clipboard::DropType eDropType (IsDropAccepted(rTargetHelper)); - switch (IsDropAccepted()) + switch (eDropType) { case DT_PAGE: + case DT_PAGE_FROM_NAVIGATOR: { - const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; + SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; const Point aEventModelPosition ( pTargetWindow->PixelToLogic (rEvent.maPosPixel)); const sal_Int32 nXOffset (labs (pDragTransferable->GetStartPos().X() @@ -684,7 +779,7 @@ sal_Int8 Clipboard::ExecuteDrop ( // Do not process the insertion when it is trivial, // i.e. would insert pages at their original place. - if (pInsertionIndicatorHandler->IsInsertionTrivial(rEvent.mnAction)) + if (IsInsertionTrivial(pDragTransferable, rEvent.mnAction)) bContinue = false; // Tell the insertion indicator handler to hide before the model @@ -713,6 +808,19 @@ sal_Int8 Clipboard::ExecuteDrop ( // well as the ones above. } + // When the pages originated in another slide sorter then + // only that is notified automatically about the drag + // operation being finished. Because the target slide sorter + // has be notified, too, add a callback for that. + ::boost::shared_ptr pSlideSorterTransferable ( + TransferableData::GetFromTransferable(pDragTransferable)); + BOOST_ASSERT(pSlideSorterTransferable); + if (pSlideSorterTransferable + && pSlideSorterTransferable->GetSourceViewShell() != mrSlideSorter.GetViewShell()) + { + DragFinished(nResult); + } + // Notify the receiving selection function that drag-and-drop is // finished and the substitution handler can be released. ::rtl::Reference pFunction ( @@ -732,7 +840,9 @@ sal_Int8 Clipboard::ExecuteDrop ( nPage, nLayer); break; + default: + case DT_NONE: break; } @@ -742,6 +852,21 @@ sal_Int8 Clipboard::ExecuteDrop ( +bool Clipboard::IsInsertionTrivial ( + SdTransferable* pTransferable, + const sal_Int8 nDndAction) const +{ + ::boost::shared_ptr pSlideSorterTransferable ( + TransferableData::GetFromTransferable(pTransferable)); + if (pSlideSorterTransferable + && pSlideSorterTransferable->GetSourceViewShell() != mrSlideSorter.GetViewShell()) + return false; + return mrController.GetInsertionIndicatorHandler()->IsInsertionTrivial(nDndAction); +} + + + + void Clipboard::Abort (void) { if (mpSelectionObserverContext) @@ -797,25 +922,26 @@ USHORT Clipboard::InsertSlides ( -Clipboard::DropType Clipboard::IsDropAccepted (void) const +Clipboard::DropType Clipboard::IsDropAccepted (DropTargetHelper& rTargetHelper) const { - DropType eResult (DT_NONE); - const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; - if (pDragTransferable != NULL) + if (pDragTransferable == NULL) + return DT_NONE; + + if (pDragTransferable->IsPageTransferable()) { - if (pDragTransferable->IsPageTransferable()) - { - if (mrSlideSorter.GetModel().GetEditMode() != EM_MASTERPAGE) - eResult = DT_PAGE; - } + if (mrSlideSorter.GetModel().GetEditMode() != EM_MASTERPAGE) + return DT_PAGE; else - { - eResult = DT_SHAPE; - } + return DT_NONE; } - return eResult; + const SdPageObjsTLB::SdPageObjsTransferable* pPageObjsTransferable + = dynamic_cast(pDragTransferable); + if (pPageObjsTransferable != NULL) + return DT_PAGE_FROM_NAVIGATOR; + + return DT_SHAPE; } diff --git a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx index 88b294f3202f..95392b8ccb37 100644 --- a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx +++ b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx @@ -39,10 +39,12 @@ #include "controller/SlsProperties.hxx" #include "controller/SlsSelectionFunction.hxx" #include "controller/SlsSelectionManager.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsClipboard.hxx" +#include "controller/SlsTransferableData.hxx" #include "DrawDocShell.hxx" #include "drawdoc.hxx" #include "app.hrc" +#include "sdtreelb.hxx" #include #include @@ -58,8 +60,19 @@ DragAndDropContext::DragAndDropContext (SlideSorter& rSlideSorter) if (rSlideSorter.GetModel().GetEditMode() != EM_PAGE) return; - rSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdateIndicatorIcon( - dynamic_cast(SD_MOD()->pTransferDrag)); + // For poperly handling transferables created by the navigator we + // need additional information. For this a user data object is + // created that contains the necessary information. + SdTransferable* pTransferable = SD_MOD()->pTransferDrag; + SdPageObjsTLB::SdPageObjsTransferable* pTreeListBoxTransferable + = dynamic_cast(pTransferable); + if (pTreeListBoxTransferable!=NULL && !TransferableData::GetFromTransferable(pTransferable)) + { + pTransferable->AddUserData( + rSlideSorter.GetController().GetClipboard().CreateTransferableUserData(pTransferable)); + } + + rSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdateIndicatorIcon(pTransferable); } diff --git a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx index 882adab932a8..d663d106f6bf 100644 --- a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx +++ b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx @@ -120,7 +120,7 @@ void InsertionIndicatorHandler::ForceEnd (void) -void InsertionIndicatorHandler::UpdateIndicatorIcon (const Transferable* pTransferable) +void InsertionIndicatorHandler::UpdateIndicatorIcon (const SdTransferable* pTransferable) { mpInsertionIndicatorOverlay->Create(pTransferable); maIconSize = mpInsertionIndicatorOverlay->GetSize(); diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx index 1d4d075fc3ce..4c92f8965e34 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx @@ -32,7 +32,7 @@ #include "SlideSorter.hxx" #include "SlideSorterViewShell.hxx" #include "SlsDragAndDropContext.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsTransferableData.hxx" #include "controller/SlideSorterController.hxx" #include "controller/SlsPageSelector.hxx" #include "controller/SlsFocusManager.hxx" diff --git a/sd/source/ui/slidesorter/controller/SlsTransferable.cxx b/sd/source/ui/slidesorter/controller/SlsTransferable.cxx deleted file mode 100755 index efda2eb1e4eb..000000000000 --- a/sd/source/ui/slidesorter/controller/SlsTransferable.cxx +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "controller/SlsTransferable.hxx" - -#include "SlideSorterViewShell.hxx" -#include "View.hxx" - -namespace sd { namespace slidesorter { namespace controller { - -Transferable::Transferable ( - SdDrawDocument* pSrcDoc, - ::sd::View* pWorkView, - BOOL bInitOnGetData, - SlideSorterViewShell* pViewShell, - const ::std::vector& rRepresentatives) - : SdTransferable (pSrcDoc, pWorkView, bInitOnGetData), - mpViewShell(pViewShell), - maRepresentatives(rRepresentatives) -{ - if (mpViewShell != NULL) - StartListening(*mpViewShell); -} - - - - -Transferable::~Transferable (void) -{ - if (mpViewShell != NULL) - EndListening(*mpViewShell); -} - - - - -void Transferable::DragFinished (sal_Int8 nDropAction) -{ - if (mpViewShell != NULL) - mpViewShell->DragFinished(nDropAction); -} - - - - -void Transferable::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) -{ - if (rHint.ISA(SfxSimpleHint) && mpViewShell!=NULL) - { - SfxSimpleHint& rSimpleHint (*PTR_CAST(SfxSimpleHint, &rHint)); - if (rSimpleHint.GetId() == SFX_HINT_DYING) - { - // This hint may come either from the ViewShell or from the - // document (registered by SdTransferable). We do not know - // which but both are sufficient to disconnect from the - // ViewShell. - EndListening(*mpViewShell); - mpViewShell = NULL; - } - } - - SdTransferable::Notify(rBroadcaster, rHint); -} - - - - -const ::std::vector& Transferable::GetRepresentatives (void) const -{ - return maRepresentatives; -} - - -} } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx b/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx new file mode 100755 index 000000000000..1fddcd6e4ba5 --- /dev/null +++ b/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sd.hxx" + +#include "controller/SlsTransferableData.hxx" + +#include "SlideSorterViewShell.hxx" +#include "View.hxx" + +namespace sd { namespace slidesorter { namespace controller { + +SdTransferable* TransferableData::CreateTransferable ( + SdDrawDocument* pSrcDoc, + ::sd::View* pWorkView, + BOOL bInitOnGetData, + SlideSorterViewShell* pViewShell, + const ::std::vector& rRepresentatives) +{ + SdTransferable* pTransferable = new SdTransferable (pSrcDoc, pWorkView, bInitOnGetData); + ::boost::shared_ptr pData (new TransferableData(pViewShell, rRepresentatives)); + pTransferable->AddUserData(pData); + return pTransferable; +} + + + + +::boost::shared_ptr TransferableData::GetFromTransferable (const SdTransferable* pTransferable) +{ + ::boost::shared_ptr pData; + for (sal_Int32 nIndex=0,nCount=pTransferable->GetUserDataCount(); nIndex(pTransferable->GetUserData(nIndex)); + if (pData) + return pData; + } + return ::boost::shared_ptr(); +} + + + + +TransferableData::TransferableData ( + SlideSorterViewShell* pViewShell, + const ::std::vector& rRepresentatives) + : mpViewShell(pViewShell), + maRepresentatives(rRepresentatives) +{ + if (mpViewShell != NULL) + StartListening(*mpViewShell); +} + + + + +TransferableData::~TransferableData (void) +{ + if (mpViewShell != NULL) + EndListening(*mpViewShell); +} + + + + +void TransferableData::DragFinished (sal_Int8 nDropAction) +{ + if (mpViewShell != NULL) + mpViewShell->DragFinished(nDropAction); + /* + for (CallbackContainer::const_iterator + iCallback(maDragFinishCallbacks.begin()), + iEnd(maDragFinishCallbacks.end()); + iCallback!=iEnd; + ++iCallback) + { + if (*iCallback) + (*iCallback)(nDropAction); + } + maDragFinishCallbacks.clear(); + */ +} + + + + +void TransferableData::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) +{ + if (rHint.ISA(SfxSimpleHint) && mpViewShell!=NULL) + { + SfxSimpleHint& rSimpleHint (*PTR_CAST(SfxSimpleHint, &rHint)); + if (rSimpleHint.GetId() == SFX_HINT_DYING) + { + // This hint may come either from the ViewShell or from the + // document (registered by SdTransferable). We do not know + // which but both are sufficient to disconnect from the + // ViewShell. + EndListening(*mpViewShell); + mpViewShell = NULL; + } + } +} + + + + +const ::std::vector& TransferableData::GetRepresentatives (void) const +{ + return maRepresentatives; +} + + + + +SlideSorterViewShell* TransferableData::GetSourceViewShell (void) const +{ + return mpViewShell; +} + +} } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/controller/makefile.mk b/sd/source/ui/slidesorter/controller/makefile.mk index 460ef16ed3f1..18479cc86aa0 100755 --- a/sd/source/ui/slidesorter/controller/makefile.mk +++ b/sd/source/ui/slidesorter/controller/makefile.mk @@ -60,7 +60,7 @@ SLOFILES = \ $(SLO)$/SlsSelectionManager.obj \ $(SLO)$/SlsSelectionObserver.obj \ $(SLO)$/SlsSlotManager.obj \ - $(SLO)$/SlsTransferable.obj \ + $(SLO)$/SlsTransferableData.obj \ $(SLO)$/SlsVisibleAreaManager.obj # --- Tagets ------------------------------------------------------- diff --git a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx index 9b7b1f5ec2d3..d610ecb5602d 100755 --- a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx @@ -30,6 +30,8 @@ #include "ViewClipboard.hxx" #include "controller/SlsSelectionObserver.hxx" +#include "sdxfer.hxx" + #include #include #include @@ -58,6 +60,8 @@ namespace sd { namespace slidesorter { namespace model { class PageDescriptor; } } } +namespace { class NavigatorDropEvent; } + namespace sd { namespace slidesorter { namespace controller { class SlideSorterController; @@ -69,6 +73,12 @@ public: Clipboard (SlideSorter& rSlideSorter); ~Clipboard (void); + /** Create a slide sorter transferable from the given sd + transferable. The returned transferable is set up with all + information necessary so that it can be dropped on a slide sorter. + */ + ::boost::shared_ptr CreateTransferableUserData (SdTransferable* pTransferable); + void HandleSlotCall (SfxRequest& rRequest); void DoCut (::Window* pWindow = 0); @@ -189,8 +199,8 @@ private: transferable is not accepted. The reason is the missing implementation of proper handling master pages copy-and-paste. */ - enum DropType { DT_PAGE, DT_SHAPE, DT_NONE }; - DropType IsDropAccepted (void) const; + enum DropType { DT_PAGE, DT_PAGE_FROM_NAVIGATOR, DT_SHAPE, DT_NONE }; + DropType IsDropAccepted (DropTargetHelper& rTargetHelper) const; /** This method contains the code for AcceptDrop() and ExecuteDrop() shapes. There are only minor differences for the two cases at this level. @@ -221,10 +231,19 @@ private: USHORT nPage, USHORT nLayer); + /** Return whether the insertion defined by the transferable is + trivial, ie would not change either source nor target document. + */ + bool IsInsertionTrivial ( + SdTransferable* pTransferable, + const sal_Int8 nDndAction) const; + /** Asynchronous part of DragFinished. The argument is the sal_Int8 nDropAction, disguised as void*. */ DECL_LINK(ProcessDragFinished, void*); + + DECL_LINK(ExecuteNavigatorDrop, NavigatorDropEvent*); }; } } } // end of namespace ::sd::slidesorter::controller diff --git a/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx b/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx index e257c5729b10..1492e707d42d 100644 --- a/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx @@ -31,6 +31,8 @@ #include "view/SlsInsertAnimator.hxx" #include "view/SlsLayouter.hxx" +#include "sdxfer.hxx" + namespace sd { namespace slidesorter { class SlideSorter; } } namespace sd { namespace slidesorter { namespace model { @@ -83,7 +85,7 @@ public: /** Update the indicator icon from the current transferable (from the clipboard or an active drag and drop operation.) */ - void UpdateIndicatorIcon (const Transferable* pTransferable); + void UpdateIndicatorIcon (const SdTransferable* pTransferable); /** Set the position of the insertion marker to the given coordinates. */ diff --git a/sd/source/ui/slidesorter/inc/controller/SlsTransferable.hxx b/sd/source/ui/slidesorter/inc/controller/SlsTransferable.hxx deleted file mode 100644 index 289fb1f5f072..000000000000 --- a/sd/source/ui/slidesorter/inc/controller/SlsTransferable.hxx +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_SLIDESORTER_TRANSFERABLE_HXX -#define SD_SLIDESORTER_TRANSFERABLE_HXX - -#include "sdxfer.hxx" - -class SdDrawDocument; -namespace sd { namespace slidesorter { -class SlideSorterViewShell; -} } - -namespace sd { namespace slidesorter { namespace controller { - - -/** This class exists to have DragFinished call the correct object: the - SlideSorterViewShell instead of the old SlideView. -*/ -class Transferable - : public SdTransferable -{ -public: - class Representative - { - public: - Representative (const Bitmap& rBitmap, const bool bIsExcluded) - : maBitmap(rBitmap), mbIsExcluded(bIsExcluded) {} - Representative (const Representative& rOther) - : maBitmap(rOther.maBitmap), mbIsExcluded(rOther.mbIsExcluded) {} - Representative operator= (Representative& rOther) - { if (&rOther != this) {maBitmap = rOther.maBitmap; mbIsExcluded = rOther.mbIsExcluded; } - return *this; - } - - Bitmap maBitmap; - bool mbIsExcluded; - }; - - - Transferable ( - SdDrawDocument* pSrcDoc, - ::sd::View* pWorkView, - BOOL bInitOnGetData, - SlideSorterViewShell* pViewShell, - const ::std::vector& rRepresentatives); - - virtual ~Transferable (void); - - virtual void DragFinished (sal_Int8 nDropAction); - - const ::std::vector& GetRepresentatives (void) const; - -private: - SlideSorterViewShell* mpViewShell; - const ::std::vector maRepresentatives; - - virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint); -}; - -} } } // end of namespace ::sd::slidesorter::controller - -#endif diff --git a/sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx b/sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx new file mode 100644 index 000000000000..563c31b213fb --- /dev/null +++ b/sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_SLIDESORTER_TRANSFERABLE_DATA_HXX +#define SD_SLIDESORTER_TRANSFERABLE_DATA_HXX + +#include "sdxfer.hxx" +#include +#include + +class SdDrawDocument; +namespace sd { namespace slidesorter { +class SlideSorterViewShell; +} } + +namespace sd { namespace slidesorter { namespace controller { + +/** Represent previews and other information so that they can be + attached to an existing transferable. +*/ +class TransferableData + : public SdTransferable::UserData, + public SfxListener +{ +public: + class Representative + { + public: + Representative (const Bitmap& rBitmap, const bool bIsExcluded) + : maBitmap(rBitmap), mbIsExcluded(bIsExcluded) {} + Representative (const Representative& rOther) + : maBitmap(rOther.maBitmap), mbIsExcluded(rOther.mbIsExcluded) {} + Representative operator= (Representative& rOther) + { if (&rOther != this) {maBitmap = rOther.maBitmap; mbIsExcluded = rOther.mbIsExcluded; } + return *this; + } + + Bitmap maBitmap; + bool mbIsExcluded; + }; + + static SdTransferable* CreateTransferable ( + SdDrawDocument* pSrcDoc, + ::sd::View* pWorkView, + BOOL bInitOnGetData, + SlideSorterViewShell* pViewShell, + const ::std::vector& rRepresentatives); + + static ::boost::shared_ptr GetFromTransferable (const SdTransferable* pTransferable); + + TransferableData ( + SlideSorterViewShell* pViewShell, + const ::std::vector& rRepresentatives); + ~TransferableData (void); + + virtual void DragFinished (sal_Int8 nDropAction); + + const ::std::vector& GetRepresentatives (void) const; + + /** Return the view shell for which the transferable was created. + */ + SlideSorterViewShell* GetSourceViewShell (void) const; + +private: + SlideSorterViewShell* mpViewShell; + const ::std::vector maRepresentatives; + typedef ::std::vector > CallbackContainer; + + virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint); +}; + +} } } // end of namespace ::sd::slidesorter::controller + +#endif diff --git a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx index f28287b15a0e..8840f3732367 100644 --- a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx @@ -258,6 +258,8 @@ public: ButtonBar& GetButtonBar (void) const; ToolTip& GetToolTip (void) const; + virtual void DragFinished (sal_Int8 nDropAction); + protected: virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint); diff --git a/sd/source/ui/slidesorter/inc/view/SlsInsertionIndicatorOverlay.hxx b/sd/source/ui/slidesorter/inc/view/SlsInsertionIndicatorOverlay.hxx index a9a640d978cf..a48d5fe9986a 100644 --- a/sd/source/ui/slidesorter/inc/view/SlsInsertionIndicatorOverlay.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlsInsertionIndicatorOverlay.hxx @@ -30,7 +30,8 @@ #include "model/SlsSharedPageDescriptor.hxx" #include "view/SlsILayerPainter.hxx" -#include "controller/SlsTransferable.hxx" +#include "controller/SlsTransferableData.hxx" +#include "sdxfer.hxx" #include #include @@ -71,7 +72,7 @@ public: virtual void SetLayerInvalidator (const SharedILayerInvalidator& rpInvalidator); - void Create (const controller::Transferable* pTransferable); + void Create (const SdTransferable* pTransferable); /** Given a position in model coordinates this method calculates the insertion marker both as an index in the document and as a location @@ -110,7 +111,7 @@ private: OutputDevice& rContent, const Size aPreviewSize, const sal_Int32 nOffset, - const ::std::vector& rPages) const; + const ::std::vector& rPages) const; void PaintPageCount ( OutputDevice& rDevice, const sal_Int32 nSelectionCount, @@ -120,7 +121,7 @@ private: scaled down previews of some of the selected pages. */ void Create ( - const ::std::vector& rPages, + const ::std::vector& rPages, const sal_Int32 nSelectionCount); }; diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx index f3637e55e63c..029dca7fca22 100644 --- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx +++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx @@ -43,6 +43,7 @@ #include "view/SlsToolTip.hxx" #include "controller/SlideSorterController.hxx" #include "controller/SlsProperties.hxx" +#include "controller/SlsClipboard.hxx" #include "model/SlideSorterModel.hxx" #include "model/SlsPageEnumerationProvider.hxx" #include "model/SlsPageDescriptor.hxx" @@ -177,7 +178,6 @@ SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter) // Hide the page that contains the page objects. SetPageVisible (FALSE); - // Register the background painter on level 1 to avoid the creation of a // background buffer. mpLayeredDevice->RegisterPainter(mpBackgroundPainter, 1); @@ -901,6 +901,16 @@ ToolTip& SlideSorterView::GetToolTip (void) const +void SlideSorterView::DragFinished (sal_Int8 nDropAction) +{ + mrSlideSorter.GetController().GetClipboard().DragFinished(nDropAction); + + View::DragFinished(nDropAction); +} + + + + void SlideSorterView::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) { ::sd::DrawDocShell* pDocShell = mrModel.GetDocument()->GetDocSh(); diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx index abaa5a43b215..6b5620655dbe 100644 --- a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx +++ b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx @@ -103,11 +103,15 @@ InsertionIndicatorOverlay::~InsertionIndicatorOverlay (void) -void InsertionIndicatorOverlay::Create (const controller::Transferable* pTransferable) +void InsertionIndicatorOverlay::Create (const SdTransferable* pTransferable) { if (pTransferable == NULL) return; + ::boost::shared_ptr pData ( + controller::TransferableData::GetFromTransferable(pTransferable)); + if ( ! pData) + return; sal_Int32 nSelectionCount (0); if (pTransferable->HasPageBookmarks()) nSelectionCount = pTransferable->GetPageBookmarks().Count(); @@ -121,14 +125,14 @@ void InsertionIndicatorOverlay::Create (const controller::Transferable* pTransfe nSelectionCount = pDataDocument->GetSdPageCount(PK_STANDARD); } } - Create(pTransferable->GetRepresentatives(), nSelectionCount); + Create(pData->GetRepresentatives(), nSelectionCount); } void InsertionIndicatorOverlay::Create ( - const ::std::vector& rRepresentatives, + const ::std::vector& rRepresentatives, const sal_Int32 nSelectionCount) { view::Layouter& rLayouter (mrSlideSorter.GetView().GetLayouter()); @@ -196,7 +200,7 @@ Point InsertionIndicatorOverlay::PaintRepresentatives ( OutputDevice& rContent, const Size aPreviewSize, const sal_Int32 nOffset, - const ::std::vector& rRepresentatives) const + const ::std::vector& rRepresentatives) const { const Point aOffset (0,rRepresentatives.size()==1 ? -nOffset : 0); -- cgit From 7fbb985bf869c69e98adf330eaa576e818bcd94e Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Wed, 9 Mar 2011 11:16:39 +0100 Subject: impress211: #i110990# Fixed slide show spanning multiple displays on Windows. --- sd/source/ui/dlg/present.cxx | 22 ++++++++++++++++++---- sd/source/ui/slideshow/slideshow.cxx | 22 ---------------------- 2 files changed, 18 insertions(+), 26 deletions(-) mode change 100644 => 100755 sd/source/ui/dlg/present.cxx diff --git a/sd/source/ui/dlg/present.cxx b/sd/source/ui/dlg/present.cxx old mode 100644 new mode 100755 index 473d2f4b452b..402ae8fd8a4d --- a/sd/source/ui/dlg/present.cxx +++ b/sd/source/ui/dlg/present.cxx @@ -214,6 +214,9 @@ void SdStartPresentationDlg::InitMonitorSettings() { } + sal_Int32 nSelected (nPrimaryIndex); + const sal_Int32 nDefaultValue ( + ( ( const SfxInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_DISPLAY ) ).GetValue()); const String sPlaceHolder( RTL_CONSTASCII_USTRINGPARAM( "%1" ) ); for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ ) { @@ -221,16 +224,27 @@ void SdStartPresentationDlg::InitMonitorSettings() const String aNumber( String::CreateFromInt32( nDisplay + 1 ) ); aName.SearchAndReplace( sPlaceHolder, aNumber ); maLBMonitor.InsertEntry( aName ); + + // Store display index together with name. + const USHORT nEntryIndex (maLBMonitor.GetEntryCount()-1); + maLBMonitor.SetEntryData(nEntryIndex, (void*)nDisplay); + + // Remember to select the default display. + if (nDefaultValue == nDisplay) + nSelected = nEntryIndex; } if( !bMultiscreen ) + { maLBMonitor.InsertEntry( msAllMonitors ); + const USHORT nEntryIndex (maLBMonitor.GetEntryCount()-1); + maLBMonitor.SetEntryData(nEntryIndex, (void*)-1); + if (nDefaultValue == -1) + nSelected = nEntryIndex; + } - sal_Int32 nSelected = ( ( const SfxInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_DISPLAY ) ).GetValue(); if( nSelected <= 0 ) nSelected = nPrimaryIndex; - else - nSelected--; maLBMonitor.SelectEntryPos( (USHORT)nSelected ); } @@ -262,7 +276,7 @@ void SdStartPresentationDlg::GetAttr( SfxItemSet& rAttr ) USHORT nPos = maLBMonitor.GetSelectEntryPos(); if( nPos != LISTBOX_ENTRY_NOTFOUND ) - rAttr.Put( SfxInt32Item ( ATTR_PRESENT_DISPLAY, nPos + 1 ) ); + rAttr.Put( SfxInt32Item ( ATTR_PRESENT_DISPLAY, (sal_Int32)maLBMonitor.GetEntryData(nPos)) ); nPos = aLbCustomshow.GetSelectEntryPos(); if( nPos != LISTBOX_ENTRY_NOTFOUND ) diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx index 70777d8a06db..aa25d77691f7 100755 --- a/sd/source/ui/slideshow/slideshow.cxx +++ b/sd/source/ui/slideshow/slideshow.cxx @@ -1228,28 +1228,6 @@ sal_Int32 SlideShow::GetDisplay() if( pOptions ) nDisplay = pOptions->GetDisplay(); - if (nDisplay <= 0 ) - { - try - { - Reference xFactory( - ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW); - Reference xMonitorProperties( - xFactory->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess"))), - UNO_QUERY_THROW); - const OUString sPropertyName (RTL_CONSTASCII_USTRINGPARAM("DefaultDisplay")); - xMonitorProperties->getPropertyValue(sPropertyName) >>= nDisplay; - } - catch( Exception& ) - { - } - } - else - { - nDisplay--; - } - return nDisplay; } -- cgit From bd721abf9422a7658614c73c37378325d800c22d Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 9 Mar 2011 13:46:28 +0100 Subject: impress211: fix some warnings, types --- sd/source/ui/app/sdxfer.cxx | 2 +- sd/source/ui/dlg/present.cxx | 4 ++-- sd/source/ui/slidesorter/controller/SlsClipboard.cxx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx index a2caf97e460d..084f2e9c2629 100755 --- a/sd/source/ui/app/sdxfer.cxx +++ b/sd/source/ui/app/sdxfer.cxx @@ -836,7 +836,7 @@ sal_Int32 SdTransferable::GetUserDataCount (void) const ::boost::shared_ptr SdTransferable::GetUserData (const sal_Int32 nIndex) const { - if (nIndex>=0 && nIndex=0 && nIndex(); diff --git a/sd/source/ui/dlg/present.cxx b/sd/source/ui/dlg/present.cxx index c07817c5ff9c..566891bacbb8 100755 --- a/sd/source/ui/dlg/present.cxx +++ b/sd/source/ui/dlg/present.cxx @@ -232,7 +232,7 @@ void SdStartPresentationDlg::InitMonitorSettings() maLBMonitor.InsertEntry( aName ); // Store display index together with name. - const USHORT nEntryIndex (maLBMonitor.GetEntryCount()-1); + const sal_uInt32 nEntryIndex (maLBMonitor.GetEntryCount()-1); maLBMonitor.SetEntryData(nEntryIndex, (void*)nDisplay); // Remember to select the default display. @@ -243,7 +243,7 @@ void SdStartPresentationDlg::InitMonitorSettings() if( !bMultiscreen ) { maLBMonitor.InsertEntry( msAllMonitors ); - const USHORT nEntryIndex (maLBMonitor.GetEntryCount()-1); + const sal_uInt32 nEntryIndex (maLBMonitor.GetEntryCount()-1); maLBMonitor.SetEntryData(nEntryIndex, (void*)-1); if (nDefaultValue == -1) nSelected = nEntryIndex; diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index 1547913207c0..9072849d9688 100755 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -533,8 +533,8 @@ void Clipboard::CreateSlideTransferable ( SdDrawDocument* pTransferableDocument = rSlideSorter.GetModel().GetDocument(); if (pTransferableDocument == NULL) break; - BOOL bIsMasterPage; - const USHORT nPageIndex (pTransferableDocument->GetPageByName(sBookmark, bIsMasterPage)); + sal_Bool bIsMasterPage = sal_False; + const sal_uInt16 nPageIndex (pTransferableDocument->GetPageByName(sBookmark, bIsMasterPage)); if (nPageIndex == SDRPAGE_NOTFOUND) break; @@ -604,7 +604,7 @@ void Clipboard::StartDrag ( void Clipboard::DragFinished (sal_Int8 nDropAction) { - SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; + // SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; if (mnDragFinishedUserEventId == 0) { -- cgit From 53eddc13d92317035bd72e4a501ab7f0c8e911d4 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 9 Mar 2011 13:50:30 +0100 Subject: impress211: fix a warning --- sd/source/ui/slidesorter/controller/SlsClipboard.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index 9072849d9688..4545e371ea37 100755 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -922,7 +922,7 @@ sal_uInt16 Clipboard::InsertSlides ( -Clipboard::DropType Clipboard::IsDropAccepted (DropTargetHelper& rTargetHelper) const +Clipboard::DropType Clipboard::IsDropAccepted (DropTargetHelper&) const { const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; if (pDragTransferable == NULL) -- cgit From df0481515fe49217975d4d62f8ef3e6904322c64 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 9 Mar 2011 13:57:56 +0100 Subject: impress211: fix a warning --- sd/source/ui/slidesorter/controller/SlsTransferableData.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx b/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx index ef554892ff0e..682b4c7f741c 100755 --- a/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx +++ b/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx @@ -109,7 +109,7 @@ void TransferableData::DragFinished (sal_Int8 nDropAction) -void TransferableData::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) +void TransferableData::Notify (SfxBroadcaster&, const SfxHint& rHint) { if (rHint.ISA(SfxSimpleHint) && mpViewShell!=NULL) { -- cgit From 68d87365e174de523492a14855c5486278b88d80 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Fri, 11 Mar 2011 15:22:17 +0100 Subject: impress211: #i110990# Fixed remaining problems with display ids and indices. --- sd/source/ui/dlg/present.cxx | 34 ++++++++++++++++++++------------- sd/source/ui/slideshow/slideshow.cxx | 37 +++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/sd/source/ui/dlg/present.cxx b/sd/source/ui/dlg/present.cxx index 566891bacbb8..0e8173741554 100755 --- a/sd/source/ui/dlg/present.cxx +++ b/sd/source/ui/dlg/present.cxx @@ -207,26 +207,27 @@ void SdStartPresentationDlg::InitMonitorSettings() else { sal_Bool bMultiscreen = false; - sal_Int32 nPrimaryIndex = 0; + sal_Int32 nDefaultDisplay (0); Reference< XPropertySet > xMonProps( xMultiMon, UNO_QUERY ); if( xMonProps.is() ) try { const OUString sPropName1( RTL_CONSTASCII_USTRINGPARAM( "MultiDisplay" ) ); xMonProps->getPropertyValue( sPropName1 ) >>= bMultiscreen; const OUString sPropName2( RTL_CONSTASCII_USTRINGPARAM( "DefaultDisplay" ) ); - xMonProps->getPropertyValue( sPropName2 ) >>= nPrimaryIndex; + xMonProps->getPropertyValue( sPropName2 ) >>= nDefaultDisplay; } catch( Exception& ) { } - sal_Int32 nSelected (nPrimaryIndex); - const sal_Int32 nDefaultValue ( + sal_Int32 nSelectedIndex (-1); + sal_Int32 nDefaultDisplayIndex (-1); + const sal_Int32 nDefaultSelectedDisplay ( ( ( const SfxInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_DISPLAY ) ).GetValue()); const String sPlaceHolder( RTL_CONSTASCII_USTRINGPARAM( "%1" ) ); for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ ) { - String aName( nDisplay == nPrimaryIndex ? msPrimaryMonitor : msMonitor ); + String aName( nDisplay == nDefaultDisplay ? msPrimaryMonitor : msMonitor ); const String aNumber( String::CreateFromInt32( nDisplay + 1 ) ); aName.SearchAndReplace( sPlaceHolder, aNumber ); maLBMonitor.InsertEntry( aName ); @@ -235,9 +236,13 @@ void SdStartPresentationDlg::InitMonitorSettings() const sal_uInt32 nEntryIndex (maLBMonitor.GetEntryCount()-1); maLBMonitor.SetEntryData(nEntryIndex, (void*)nDisplay); - // Remember to select the default display. - if (nDefaultValue == nDisplay) - nSelected = nEntryIndex; + // Remember the index of the default selection. + if (nDefaultSelectedDisplay == nDisplay) + nSelectedIndex = nEntryIndex; + + // Remember index of the default display. + if (nDisplay == nDefaultDisplay) + nDefaultDisplayIndex = nEntryIndex; } if( !bMultiscreen ) @@ -245,14 +250,17 @@ void SdStartPresentationDlg::InitMonitorSettings() maLBMonitor.InsertEntry( msAllMonitors ); const sal_uInt32 nEntryIndex (maLBMonitor.GetEntryCount()-1); maLBMonitor.SetEntryData(nEntryIndex, (void*)-1); - if (nDefaultValue == -1) - nSelected = nEntryIndex; + if (nDefaultSelectedDisplay == -1) + nSelectedIndex = nEntryIndex; } - if( nSelected <= 0 ) - nSelected = nPrimaryIndex; + if (nSelectedIndex < 0) + if (nDefaultSelectedDisplay < 0) + nSelectedIndex = 0; + else + nSelectedIndex = nDefaultDisplayIndex; - maLBMonitor.SelectEntryPos( (sal_uInt16)nSelected ); + maLBMonitor.SelectEntryPos((sal_uInt16)nSelectedIndex); } } catch( Exception& ) diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx index c37d34d0f5df..0f01f0658cbb 100755 --- a/sd/source/ui/slideshow/slideshow.cxx +++ b/sd/source/ui/slideshow/slideshow.cxx @@ -109,6 +109,26 @@ namespace { private: ::boost::shared_ptr mpRestarter; }; + + /** Return the default display id (or -1 when that can not be + determined.) + */ + sal_Int32 GetDefaultDisplay (void) + { + try + { + Reference< XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); + Reference< XPropertySet > xMonProps(xFactory->createInstance(OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess" ) ) ), UNO_QUERY_THROW ); + const OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "DefaultDisplay" ) ); + sal_Int32 nPrimaryIndex (-1); + if (xMonProps->getPropertyValue( sPropertyName ) >>= nPrimaryIndex) + return nPrimaryIndex; + } + catch( Exception& ) + { + } + return -1; + } } @@ -553,6 +573,14 @@ void SAL_CALL SlideShow::setPropertyValue( const OUString& aPropertyName, const sal_Int32 nDisplay = 0; if( aValue >>= nDisplay ) { + // Convert value to true display id. + if (nDisplay == 0) + nDisplay = GetDefaultDisplay(); + else if (nDisplay < 0) + nDisplay = -1; + else + --nDisplay; + bIllegalArgument = false; SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS); @@ -632,7 +660,14 @@ Any SAL_CALL SlideShow::getPropertyValue( const OUString& PropertyName ) throw(U case ATTR_PRESENT_DISPLAY: { SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS); - return Any( pOptions->GetDisplay() ); + const sal_Int32 nDisplay (pOptions->GetDisplay()); + // Convert true display id to the previously used schema. + if (nDisplay == GetDefaultDisplay()) + return Any(sal_Int32(0)); + else if (nDisplay < 0) + return Any(sal_Int32(-1)); + else + return Any(nDisplay+1); } default: -- cgit From 8dbc86aa82fb73668816f228779b2094de546aa0 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Thu, 31 Mar 2011 16:12:22 +0200 Subject: impress211: #i110990# Fixed 64bit compiler problem. --- sd/source/ui/dlg/present.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 sd/source/ui/dlg/present.cxx diff --git a/sd/source/ui/dlg/present.cxx b/sd/source/ui/dlg/present.cxx old mode 100755 new mode 100644 index 0e8173741554..51f49bc03032 --- a/sd/source/ui/dlg/present.cxx +++ b/sd/source/ui/dlg/present.cxx @@ -290,7 +290,7 @@ void SdStartPresentationDlg::GetAttr( SfxItemSet& rAttr ) sal_uInt16 nPos = maLBMonitor.GetSelectEntryPos(); if( nPos != LISTBOX_ENTRY_NOTFOUND ) - rAttr.Put( SfxInt32Item ( ATTR_PRESENT_DISPLAY, (sal_Int32)maLBMonitor.GetEntryData(nPos)) ); + rAttr.Put( SfxInt32Item ( ATTR_PRESENT_DISPLAY, (sal_Int32)(sal_IntPtr)maLBMonitor.GetEntryData(nPos)) ); nPos = aLbCustomshow.GetSelectEntryPos(); if( nPos != LISTBOX_ENTRY_NOTFOUND ) -- cgit