sd/source/ui/slidesorter/controller/SlsClipboard.cxx | 44 +++++++++++++++ sd/source/ui/slidesorter/controller/SlsSlotManager.cxx | 5 + sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx | 6 ++ sd/source/ui/view/drviewse.cxx | 16 +++++ sd/source/ui/view/sdview3.cxx | 15 ++++- sfx2/source/control/unoctitm.cxx | 1 6 files changed, 86 insertions(+), 1 deletion(-)
New commits: commit 7dddd449068d69ec2f47bfca2487f01fa7067fd0 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Tue Apr 15 21:19:43 2025 +0530 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Apr 17 10:04:58 2025 +0200 sd: copy slides from instance to another in core this works between multiple instances (ie: multi users) in online now its will be possible to copy slides from one presentation to another in core to test with multiple instance: ./instdir/program/soffice -env:UserInstallation=file:///tmp/test1 & ./instdir/program/soffice -env:UserInstallation=file:///tmp/test2 & Co-authored-by: Pranam Lashkari <lpra...@collabora.com> Co-authored-by: Caolán McNamara <caolan.mcnam...@collabora.com> Change-Id: I95b4d332968fd8895b1d950ea620ea37a85524c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184232 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit cdaf9a06f5467f0f0167885a3e44ecc3cdd87b76) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184262 Tested-by: Jenkins diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index 834371579a03..8df0ca101768 100644 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -58,6 +58,8 @@ #include <app.hrc> #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/embed/XStorage.hpp> #include <sfx2/request.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/bindings.hxx> @@ -67,6 +69,10 @@ #include <rtl/ustring.hxx> #include <vcl/svapp.hxx> +#include <comphelper/storagehelper.hxx> + +using namespace ::com::sun::star; + namespace sd::slidesorter::controller { namespace { @@ -907,6 +913,44 @@ sal_Int8 Clipboard::ExecuteOrAcceptShapeDrop ( return nResult; } +bool Clipboard::PasteSlidesFromSystemClipboard() +{ + ViewShellBase* pBase = mrSlideSorter.GetViewShellBase(); + std::shared_ptr<DrawViewShell> pDrawViewShell( + std::dynamic_pointer_cast<DrawViewShell>(pBase->GetMainViewShell())); + TransferableDataHelper aDataHelper( + TransferableDataHelper::CreateFromSystemClipboard(pDrawViewShell->GetActiveWindow())); + + SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); + assert(pDocument); + OUString aDocShellID = SfxObjectShell::CreateShellID(pDocument->GetDocSh()); + auto xStm = aDataHelper.GetInputStream(SotClipboardFormatId::EMBED_SOURCE, aDocShellID); + + if (xStm.is()) + { + uno::Reference<embed::XStorage> xStore( + ::comphelper::OStorageHelper::GetStorageFromInputStream(xStm)); + ::sd::DrawDocShellRef xDocShRef(new ::sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, true, + pDocument->GetDocumentType())); + SfxMedium* pMedium = new SfxMedium(xStore, OUString()); + xDocShRef->DoLoad(pMedium); + std::vector<OUString> aBookmarkList; + std::vector<OUString> aExchangeList; + + auto insertPos = mrSlideSorter.GetModel().GetCoreIndex( + mrSlideSorter.GetController().GetClipboard().GetInsertionPosition()); + pDocument->InsertFileAsPage(aBookmarkList, &aExchangeList, false /*bLink*/, + insertPos /*nPos*/, xDocShRef.get()); + + std::vector<OUString> aObjectBookmarkList; + pDocument->InsertBookmarkAsObject(aObjectBookmarkList, aExchangeList, xDocShRef.get(), + nullptr, false); + + return true; + } + return false; +} + } // end of namespace ::sd::slidesorter::controller /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index 7c749e318692..a9051bc41059 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -368,6 +368,11 @@ void SlotManager::FuSupport (SfxRequest& rRequest) case SID_PASTE_SLIDE: { SdTransferable* pTransferClip = SdModule::get()->pTransferClip; + if (!pTransferClip) + { + if (mrSlideSorter.GetController().GetClipboard().PasteSlidesFromSystemClipboard()) + return; + } if( pTransferClip ) { SfxObjectShell* pTransferDocShell = pTransferClip->GetDocShell().get(); diff --git a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx index 91e3be740d1c..46833f7f3f2f 100644 --- a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx @@ -121,6 +121,7 @@ private: vcl::Window* pWindow, bool bDrag); +public: /** Determine the position of where to insert the pages in the current transferable of the sd module. @return @@ -129,6 +130,11 @@ private: */ sal_Int32 GetInsertionPosition (); + /** Paste the slides copied from another instance of the LibreOffice + */ + bool PasteSlidesFromSystemClipboard(); + +private: /** Paste the pages of the transferable of the sd module at the given position. @param nInsertPosition diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index cb8b10cd1b53..d05a0bf9aa13 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -100,6 +100,10 @@ #include <officecfg/Office/Draw.hxx> #include <officecfg/Office/Impress.hxx> #include <sfx2/lokhelper.hxx> +#include <SlideSorter.hxx> +#include <SlideSorterViewShell.hxx> +#include <controller/SlideSorterController.hxx> +#include <controller/SlsClipboard.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -950,6 +954,18 @@ void DrawViewShell::FuSupport(SfxRequest& rReq) } break; + case SID_PASTE_SLIDE: + case SID_COPY_SLIDE: + { + sd::slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase()) + ->GetSlideSorter() + .GetController() + .FuSupport(rReq); + Cancel(); + rReq.Done(); + } + break; + case SID_UNICODE_NOTATION_TOGGLE: { if( mpDrawView->IsTextEdit() ) diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index 1c3050fb753c..db7bd84ec27f 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -71,7 +71,10 @@ #include <svx/sdrhittesthelper.hxx> #include <svx/xbtmpit.hxx> #include <memory> - +#include <SlideSorter.hxx> +#include <SlideSorterViewShell.hxx> +#include <controller/SlideSorterController.hxx> +#include <controller/SlsClipboard.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::lang; @@ -700,6 +703,16 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, } } + if (!bReturn && CHECK_FORMAT_TRANS(SotClipboardFormatId::EMBED_SOURCE)) + { + sd::slidesorter::SlideSorter& xSlideSorter + = ::sd::slidesorter::SlideSorterViewShell::GetSlideSorter( + mrDoc.GetDocSh()->GetViewShell()->GetViewShellBase()) + ->GetSlideSorter(); + if (xSlideSorter.GetController().GetClipboard().PasteSlidesFromSystemClipboard()) + return true; + } + if(!bReturn && CHECK_FORMAT_TRANS( SotClipboardFormatId::DRAWING )) { if (std::unique_ptr<SvStream> xStm = rDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING )) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 8dcb14d2b1ee..029cb676cbb6 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1244,6 +1244,7 @@ const std::map<std::u16string_view, KitUnoCommand>& GetKitUnoCommandList() { u"Cut", { PayloadType::EnabledPayload, true } }, { u"Copy", { PayloadType::EnabledPayload, true } }, + { u"CopySlide", { PayloadType::EnabledPayload, true } }, { u"Paste", { PayloadType::EnabledPayload, true } }, { u"SelectAll", { PayloadType::EnabledPayload, true } }, { u"InsertAnnotation", { PayloadType::EnabledPayload, true } },