LibreOffice Module sd (master) 1
sdview2.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <View.hxx>
21
22#include <vector>
23#include <com/sun/star/embed/XEmbedPersist.hpp>
24#include <com/sun/star/embed/XEmbeddedObject.hpp>
26#include <tools/urlobj.hxx>
27#include <svx/svdoole2.hxx>
28#include <svx/svxdlg.hxx>
29#include <sfx2/docfile.hxx>
30#include <svx/svdundo.hxx>
31#include <svx/svdpagv.hxx>
32#include <svl/urlbmk.hxx>
33#include <editeng/outliner.hxx>
34#include <svx/xflclit.hxx>
35#include <sot/formats.hxx>
36#include <editeng/editeng.hxx>
37
39#include <tools/debug.hxx>
40
41#include <anminfo.hxx>
42#include <strings.hrc>
43#include <sdxfer.hxx>
44#include <sdresid.hxx>
45#include <sdmod.hxx>
46#include <sdtreelb.hxx>
47#include <DrawViewShell.hxx>
48#include <DrawDocShell.hxx>
49#include <fudraw.hxx>
50#include <drawdoc.hxx>
51#include <Window.hxx>
52#include <sdpage.hxx>
53#include <unoaprms.hxx>
54#include <helpids.h>
55#include <vcl/svapp.hxx>
56
57#include <slideshow.hxx>
58#include <memory>
59
60namespace sd {
61
62using namespace ::com::sun::star;
63
64namespace {
65
66struct SdNavigatorDropEvent : public ExecuteDropEvent
67{
69
70 SdNavigatorDropEvent (
71 const ExecuteDropEvent& rEvt,
72 ::sd::Window* pTargetWindow )
73 : ExecuteDropEvent( rEvt ),
74 mpTargetWindow( pTargetWindow )
75 {}
76};
77
78}
79
80css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDataObject()
81{
82 // since SdTransferable::CopyToClipboard is called, this
83 // dynamically created object is destroyed automatically
84 rtl::Reference<SdTransferable> pTransferable = new SdTransferable( &mrDoc, nullptr, false );
85
86 SD_MOD()->pTransferClip = pTransferable.get();
87
88 mrDoc.CreatingDataObj( pTransferable.get() );
89 pTransferable->SetWorkDocument( static_cast<SdDrawDocument*>(CreateMarkedObjModel().release()) );
90 mrDoc.CreatingDataObj( nullptr );
91
92 // #112978# need to use GetAllMarkedBoundRect instead of GetAllMarkedRect to get
93 // fat lines correctly
94 const ::tools::Rectangle aMarkRect( GetAllMarkedBoundRect() );
95 std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
96 SdrOle2Obj* pSdrOleObj = nullptr;
97 SdrPageView* pPgView = GetSdrPageView();
98 SdPage* pOldPage = pPgView ? static_cast<SdPage*>( pPgView->GetPage() ) : nullptr;
99 SdPage* pNewPage = const_cast<SdPage*>(static_cast<const SdPage*>( pTransferable->GetWorkDocument()->GetPage( 0 ) ));
100
101 if( pOldPage )
102 {
103 pNewPage->SetSize( pOldPage->GetSize() );
104 pNewPage->SetLayoutName( pOldPage->GetLayoutName() );
105 }
106
107 if( GetMarkedObjectCount() == 1 )
108 {
110
111 if( auto pOle2Obj = dynamic_cast<SdrOle2Obj *>( pObj ) )
112 if( pOle2Obj->GetObjRef() )
113 {
114 // If object has no persistence it must be copied as part of the document
115 try
116 {
117 uno::Reference< embed::XEmbedPersist > xPersObj( pOle2Obj->GetObjRef(), uno::UNO_QUERY );
118 if ( xPersObj.is() && xPersObj->hasEntry() )
119 pSdrOleObj = pOle2Obj;
120 }
121 catch( uno::Exception& )
122 {}
123 }
124 }
125
126 if( pSdrOleObj )
127 SvEmbedTransferHelper::FillTransferableObjectDescriptor( *pObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
128 else
129 pTransferable->GetWorkDocument()->GetDocSh()->FillTransferableObjectDescriptor( *pObjDesc );
130
131 if( mpDocSh )
132 pObjDesc->maDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
133
134 pObjDesc->maSize = aMarkRect.GetSize();
135
136 pTransferable->SetStartPos( aMarkRect.TopLeft() );
137 pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
138 pTransferable->CopyToClipboard( mpViewSh->GetActiveWindow() );
139
140 return pTransferable;
141}
142
143css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObject( View* pWorkView, vcl::Window& rWindow, const Point& rDragPos )
144{
145 rtl::Reference<SdTransferable> pTransferable = new SdTransferable( &mrDoc, pWorkView, false );
146
147 SD_MOD()->pTransferDrag = pTransferable.get();
148
149 std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
150 OUString aDisplayName;
151 SdrOle2Obj* pSdrOleObj = nullptr;
152
153 if( GetMarkedObjectCount() == 1 )
154 {
156
157 if( auto pOle2Obj = dynamic_cast<SdrOle2Obj *>( pObj ) )
158 if( pOle2Obj->GetObjRef() )
159 {
160 // If object has no persistence it must be copied as part of the document
161 try
162 {
163 uno::Reference< embed::XEmbedPersist > xPersObj( pOle2Obj->GetObjRef(), uno::UNO_QUERY );
164 if ( xPersObj.is() && xPersObj->hasEntry() )
165 pSdrOleObj = pOle2Obj;
166 }
167 catch( uno::Exception& )
168 {}
169 }
170 }
171
172 if( mpDocSh )
173 aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
174
175 if( pSdrOleObj )
176 SvEmbedTransferHelper::FillTransferableObjectDescriptor( *pObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
177 else if (mpDocSh)
179
180 pObjDesc->maSize = GetAllMarkedRect().GetSize();
181 pObjDesc->maDragStartPos = rDragPos;
182 pObjDesc->maDisplayName = aDisplayName;
183
184 pTransferable->SetStartPos( rDragPos );
185 pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
186 pTransferable->StartDrag( &rWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
187
188 return pTransferable;
189}
190
191css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDataObject( View* pWorkView )
192{
193 rtl::Reference<SdTransferable> pTransferable = new SdTransferable( &mrDoc, pWorkView, true );
194 std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
195 const ::tools::Rectangle aMarkRect( GetAllMarkedRect() );
196
197 SD_MOD()->pTransferSelection = pTransferable.get();
198
199 if( mpDocSh )
200 {
202 pObjDesc->maDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
203 }
204
205 pObjDesc->maSize = aMarkRect.GetSize();
206
207 pTransferable->SetStartPos( aMarkRect.TopLeft() );
208 pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
209 pTransferable->CopyToPrimarySelection();
210
211 return pTransferable;
212}
213
215{
216 if (!mpViewSh)
217 return;
219 return;
220 if (GetMarkedObjectList().GetMarkCount())
222 else
224}
225
227{
228 if (!mpViewSh)
229 return;
231 return;
232 if (SD_MOD()->pTransferSelection && SD_MOD()->pTransferSelection->GetView() == this)
233 {
235 SD_MOD()->pTransferSelection = nullptr;
236 }
237}
238
240{
242
243 if( pOLV )
244 const_cast<OutlinerView*>(pOLV)->Cut();
245 else if( AreObjectsMarked() )
246 {
247 OUString aStr(SdResId(STR_UNDO_CUT));
248
249 DoCopy();
251 DeleteMarked();
252 EndUndo();
253 }
254}
255
257{
259
260 if( pOLV )
261 const_cast<OutlinerView*>(pOLV)->Copy();
262 else if( AreObjectsMarked() )
263 {
264 BrkAction();
266 }
267}
268
270{
272 if( !aDataHelper.GetTransferable().is() )
273 return; // empty clipboard?
274
276
277 if( pOLV && EditEngine::HasValidData( aDataHelper.GetTransferable() ) )
278 {
279 const_cast< OutlinerView* >(pOLV)->PasteSpecial();
280
282 SdPage* pPage = static_cast<SdPage*>( pObj ? pObj->getSdrPageFromSdrObject() : nullptr );
283 ::Outliner* pOutliner = pOLV->GetOutliner();
284
285 if( pOutliner)
286 {
287 if( pObj && pPage && pPage->GetPresObjKind(pObj) == PresObjKind::Title )
288 {
289 // remove all hard linebreaks from the title
290 if (pOutliner->GetParagraphCount() > 1)
291 {
292 bool bOldUpdateMode = pOutliner->SetUpdateLayout( false );
293
294 const EditEngine& rEdit = pOutliner->GetEditEngine();
295 const sal_Int32 nParaCount = rEdit.GetParagraphCount();
296
297 for( sal_Int32 nPara = nParaCount - 2; nPara >= 0; nPara-- )
298 {
299 const sal_Int32 nParaLen = rEdit.GetTextLen( nPara );
300 pOutliner->QuickDelete( ESelection( nPara, nParaLen, nPara+1, 0 ) );
301 pOutliner->QuickInsertLineBreak( ESelection( nPara, nParaLen, nPara, nParaLen ) );
302 }
303
304 DBG_ASSERT( rEdit.GetParagraphCount() <= 1, "Titleobject contains hard line breaks" );
305 pOutliner->SetUpdateLayout(bOldUpdateMode);
306 }
307 }
308
309 if( !mrDoc.IsChanged() )
310 {
311 if (pOutliner->IsModified())
313 }
314 }
315 }
316 else
317 {
318 Point aPos = pWindow->GetVisibleCenter();
319 DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>( mpDocSh->GetViewShell() );
320
321 if (pDrViewSh != nullptr)
322 {
323 sal_Int8 nDnDAction = DND_ACTION_COPY;
324 if( !InsertData( aDataHelper, aPos, nDnDAction, false ) )
325 {
326 INetBookmark aINetBookmark( "", "" );
327
328 if( ( aDataHelper.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) &&
329 aDataHelper.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
330 ( aDataHelper.HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) &&
331 aDataHelper.GetINetBookmark( SotClipboardFormatId::FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
332 ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) &&
333 aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
334 {
335 pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), "" );
336 }
337 }
338 }
339 }
340}
341
342void View::StartDrag( const Point& rStartPos, vcl::Window* pWindow )
343{
344 if (!AreObjectsMarked() || !IsAction() || !mpViewSh || !pWindow)
345 return;
346
347 BrkAction();
348
349 if( IsTextEdit() )
351
352 if (DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(mpDocSh ? mpDocSh->GetViewShell() : nullptr))
353 {
354 const rtl::Reference<FuPoor>& xFunction(pDrawViewShell->GetCurrentFunction());
355 if (FuDraw* pFunction = dynamic_cast<FuDraw*>(xFunction.get()))
356 pFunction->ForcePointer();
357 }
358
361
362 CreateDragDataObject( this, *pWindow, rStartPos );
363}
364
365void View::DragFinished( sal_Int8 nDropAction )
366{
367 const bool bUndo = IsUndoEnabled();
368 const bool bGroupUndo = bUndo && mpDragSrcMarkList;
369 if (bGroupUndo)
370 {
371 OUString aStr(SdResId(STR_UNDO_DRAGDROP));
372 BegUndo(aStr + " " + mpDragSrcMarkList->GetMarkDescription());
373 }
374
375 SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
376
377 if( pDragTransferable )
378 pDragTransferable->SetView( nullptr );
379
380 if( ( nDropAction & DND_ACTION_MOVE ) &&
381 pDragTransferable && !pDragTransferable->IsInternalMove() &&
382 mpDragSrcMarkList && mpDragSrcMarkList->GetMarkCount() &&
384 {
385 mpDragSrcMarkList->ForceSort();
386
387 if( bUndo )
388 BegUndo();
389
390 const size_t nCnt = mpDragSrcMarkList->GetMarkCount();
391
392 for( size_t nm = nCnt; nm>0; )
393 {
394 --nm;
395 SdrMark* pM=mpDragSrcMarkList->GetMark(nm);
396 if( bUndo )
398 }
399
400 mpDragSrcMarkList->GetMark(0)->GetMarkedSdrObj()->GetOrdNum();
401
402 for (size_t nm = nCnt; nm>0;)
403 {
404 --nm;
405 SdrMark* pM=mpDragSrcMarkList->GetMark(nm);
406 SdrObject* pObj=pM->GetMarkedSdrObj();
407
408 if( pObj && pObj->getSdrPageFromSdrObject() )
409 {
410 const size_t nOrdNum = pObj->GetOrdNumDirect();
412 DBG_ASSERT(pChkObj.get()==pObj,"pChkObj!=pObj in RemoveObject()");
413 }
414 }
415
416 if( bUndo )
417 EndUndo();
418 }
419
420 if( pDragTransferable )
421 pDragTransferable->SetInternalMove( false );
422
423 if (bGroupUndo)
424 EndUndo();
426 mpDragSrcMarkList.reset();
427}
428
429sal_Int8 View::AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
430 SdrLayerID nLayer )
431{
432 OUString aLayerName = GetActiveLayer();
434 sal_Int8 nDropAction = rEvt.mnAction;
436
437 if( nLayer != SDRLAYER_NOTFOUND )
438 {
439 SdrLayerAdmin& rLayerAdmin = mrDoc.GetLayerAdmin();
440 SdrLayer* pLayer = rLayerAdmin.GetLayerPerID(nLayer);
441 assert(pLayer && "layer missing");
442 aLayerName = pLayer->GetName();
443 }
444
445 if( mbIsDropAllowed && !pPV->IsLayerLocked( aLayerName ) && pPV->IsLayerVisible( aLayerName ) )
446 {
448 bool bIsInsideOutlinerView = false;
449
450 if( pOLV )
451 {
452 ::tools::Rectangle aRect( pOLV->GetOutputArea() );
453
454 if (GetMarkedObjectCount() == 1)
455 {
456 SdrMark* pMark = GetSdrMarkByIndex(0);
457 SdrObject* pObj = pMark->GetMarkedSdrObj();
458 aRect.Union( pObj->GetLogicRect() );
459 }
460
461 if( aRect.Contains( pOLV->GetWindow()->PixelToLogic( rEvt.maPosPixel ) ) )
462 {
463 bIsInsideOutlinerView = true;
464 }
465 }
466
467 if( !bIsInsideOutlinerView )
468 {
469 SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
470
471 if(pDragTransferable && (nDropAction & DND_ACTION_LINK))
472 {
473 // suppress own data when it's intention is to use it as fill information
474 pDragTransferable = nullptr;
475 }
476
477 if( pDragTransferable )
478 {
479 const View* pSourceView = pDragTransferable->GetView();
480
481 if( pDragTransferable->IsPageTransferable() )
482 {
483 nRet = DND_ACTION_COPY;
484 }
485 else if( pSourceView )
486 {
487 if( !( nDropAction & DND_ACTION_LINK ) ||
488 !pSourceView->GetDocSh()->GetMedium()->GetName().isEmpty() )
489 {
490 nRet = nDropAction;
491 }
492 }
493 }
494 else
495 {
496 const bool bDrawing = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::DRAWING );
497 const bool bGraphic = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::SVXB );
498 const bool bMtf = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::GDIMETAFILE );
499 const bool bBitmap = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::BITMAP );
500 bool bBookmark = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::NETSCAPE_BOOKMARK );
501 bool bXFillExchange = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::XFA );
502
503 // check handle insert
504 if ((bXFillExchange && (SdrDragMode::Gradient == GetDragMode()))
505 || (SdrDragMode::Transparence == GetDragMode()))
506 {
507 const SdrHdlList& rHdlList = GetHdlList();
508
509 for( size_t n = 0; n < rHdlList.GetHdlCount(); ++n )
510 {
511 SdrHdl* pIAOHandle = rHdlList.GetHdl( n );
512
513 if( pIAOHandle && ( SdrHdlKind::Color == pIAOHandle->GetKind() ) )
514 {
515 if(pIAOHandle->getOverlayObjectList().isHitPixel(rEvt.maPosPixel))
516 {
517 nRet = nDropAction;
518 static_cast< SdrHdlColor* >( pIAOHandle )->SetSize( SDR_HANDLE_COLOR_SIZE_SELECTED );
519 }
520 else
521 {
522 static_cast< SdrHdlColor* >( pIAOHandle )->SetSize( SDR_HANDLE_COLOR_SIZE_NORMAL );
523 }
524 }
525 }
526 }
527
528 // check object insert
529 if( !nRet && ( bXFillExchange || ( ( bDrawing || bGraphic || bMtf || bBitmap || bBookmark ) && ( nDropAction & DND_ACTION_LINK ) ) ) )
530 {
531 SdrPageView* pPageView = nullptr;
533 Point aPos( pWindow->PixelToLogic( rEvt.maPosPixel ) );
534 SdrObject* pPickObj = PickObj(aPos, getHitTolLog(), pPageView);
535 bool bIsPresTarget = false;
536
537 if (pPickObj && (pPickObj->IsEmptyPresObj() || pPickObj->GetUserCall()))
538 {
539 SdPage* pPage = static_cast<SdPage*>( pPickObj->getSdrPageFromSdrObject() );
540
541 if( pPage && pPage->IsMasterPage() )
542 bIsPresTarget = pPage->IsPresObj( pPickObj );
543 }
544
545 if (pPickObj && !bIsPresTarget && (bGraphic || bMtf || bBitmap || bXFillExchange))
546 {
547 if( mpDropMarkerObj != pPickObj )
548 {
549 mpDropMarkerObj = pPickObj;
551
553 {
555 }
556 }
557
558 nRet = nDropAction;
559 }
560 else
561 bXFillExchange = false;
562 }
563
564 // check normal insert
565 if( !nRet )
566 {
567 const bool bSBAFormat = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::SVX_FORMFIELDEXCH );
568 const bool bEditEngineODF = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT );
569 const bool bString = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::STRING );
570 const bool bRTF = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::RTF );
571 const bool bFile = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::SIMPLE_FILE );
572 const bool bFileList = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::FILE_LIST );
573
574 if( mpDropMarker )
575 {
577 mpDropMarkerObj = nullptr;
578 }
579
580 if( bBookmark && bFile && ( nDropAction & DND_ACTION_MOVE ) && mpViewSh && SlideShow::IsRunning(mpViewSh->GetViewShellBase()) )
581 bBookmark = false;
582
583 if( bDrawing || bGraphic || bMtf || bBitmap || bBookmark || bFile || bFileList || bXFillExchange || bSBAFormat || bEditEngineODF || bString || bRTF )
584 nRet = nDropAction;
585
586 // For entries from the navigator, change action copy.
587 if (bBookmark
588 && rTargetHelper.IsDropFormatSupported(
590 && (nDropAction & DND_ACTION_MOVE)!=0)
591 {
592 nRet = DND_ACTION_COPY;
593 }
594 }
595 }
596 }
597 }
598
599 // destroy drop marker if this is a leaving event
600 if( rEvt.mbLeaving && mpDropMarker )
601 {
603 mpDropMarkerObj = nullptr;
604 }
605
606 return nRet;
607}
608
610 ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer )
611{
613 OUString aActiveLayer = GetActiveLayer();
614 sal_Int8 nDropAction = rEvt.mnAction;
616
617 // destroy drop marker if it is shown
618 if( mpDropMarker )
619 {
621 mpDropMarkerObj = nullptr;
622 }
623
624 if( !pPV->IsLayerLocked( aActiveLayer ) )
625 {
627 bool bIsInsideOutlinerView = false;
628
629 if( pOLV )
630 {
631 ::tools::Rectangle aRect( pOLV->GetOutputArea() );
632
633 if( GetMarkedObjectCount() == 1 )
634 {
635 SdrMark* pMark = GetSdrMarkByIndex(0);
636 SdrObject* pObj = pMark->GetMarkedSdrObj();
637 aRect.Union( pObj->GetLogicRect() );
638 }
639
640 Point aPos( pOLV->GetWindow()->PixelToLogic( rEvt.maPosPixel ) );
641
642 if( aRect.Contains( aPos ) )
643 {
644 bIsInsideOutlinerView = true;
645 }
646 }
647
648 if( !bIsInsideOutlinerView )
649 {
650 Point aPos;
651 TransferableDataHelper aDataHelper( rEvt.maDropEvent.Transferable );
652
653 if( pTargetWindow )
654 aPos = pTargetWindow->PixelToLogic( rEvt.maPosPixel );
655
656 // handle insert?
657 if ((SdrDragMode::Gradient == GetDragMode())
658 || ((SdrDragMode::Transparence == GetDragMode())
659 && aDataHelper.HasFormat(SotClipboardFormatId::XFA)))
660 {
661 const SdrHdlList& rHdlList = GetHdlList();
662
663 for( size_t n = 0; !nRet && n < rHdlList.GetHdlCount(); ++n )
664 {
665 SdrHdl* pIAOHandle = rHdlList.GetHdl( n );
666
667 if( pIAOHandle && ( SdrHdlKind::Color == pIAOHandle->GetKind() ) )
668 {
669 if(pIAOHandle->getOverlayObjectList().isHitPixel(rEvt.maPosPixel))
670 {
671 uno::Any const data(aDataHelper.GetAny(SotClipboardFormatId::XFA, ""));
672 uno::Sequence<beans::NamedValue> props;
673 if (data >>= props)
674 {
676 Color aColor(COL_BLACK);
677 auto const it = map.find("FillColor");
678 if (it != map.end())
679 {
681 color.PutValue(it->second, 0);
682 aColor = color.GetColorValue();
683 }
684 static_cast< SdrHdlColor* >( pIAOHandle )->SetColor( aColor, true );
685 nRet = nDropAction;
686 }
687 }
688 }
689 }
690 }
691
692 // standard insert?
693 if( !nRet && InsertData( aDataHelper, aPos, nDropAction, true, SotClipboardFormatId::NONE, nPage, nLayer ) )
694 nRet = nDropAction;
695
696 // special insert?
697 if( !nRet && mpViewSh )
698 {
699 INetBookmark aINetBookmark( (OUString()), (OUString()) );
700
701 // insert bookmark
702 if( aDataHelper.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) &&
703 aDataHelper.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) )
704 {
706
707 if( pPageObjsTransferable &&
708 ( NAVIGATOR_DRAGTYPE_LINK == pPageObjsTransferable->GetDragType() ||
709 NAVIGATOR_DRAGTYPE_EMBEDDED == pPageObjsTransferable->GetDragType() ) )
710 {
711 // insert bookmark from own navigator (handled async. due to possible message box )
712 Application::PostUserEvent( LINK( this, View, ExecuteNavigatorDrop ),
713 new SdNavigatorDropEvent( rEvt, pTargetWindow ) );
714 nRet = nDropAction;
715 }
716 else
717 {
718 SdrPageView* pPageView = nullptr;
719
720 SdrObject* pPickObj = PickObj(aPos, getHitTolLog(), pPageView);
721 if (pPickObj)
722 {
723 // insert as clip action => jump
724 OUString aBookmark( aINetBookmark.GetURL() );
726
727 if( !aBookmark.isEmpty() )
728 {
729 bool bCreated = false;
730
731 presentation::ClickAction eClickAction = presentation::ClickAction_DOCUMENT;
732
733 sal_Int32 nIndex = aBookmark.indexOf( '#' );
734 if( nIndex != -1 )
735 {
736 const std::u16string_view aDocName( aBookmark.subView( 0, nIndex ) );
737
738 if (mpDocSh->GetMedium()->GetName() == aDocName || aDocName == mpDocSh->GetName())
739 {
740 // internal jump, only use the part after and including '#'
741 eClickAction = presentation::ClickAction_BOOKMARK;
742 aBookmark = aBookmark.copy( nIndex+1 );
743 }
744 }
745
746 if( !pInfo )
747 {
748 pInfo = SdDrawDocument::GetShapeUserData( *pPickObj, true );
749 bCreated = true;
750 }
751
752 // create undo action with old and new sizes
753 std::unique_ptr<SdAnimationPrmsUndoAction> pAction(new SdAnimationPrmsUndoAction(&mrDoc, pPickObj, bCreated));
754 pAction->SetActive(pInfo->mbActive, pInfo->mbActive);
755 pAction->SetEffect(pInfo->meEffect, pInfo->meEffect);
756 pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect);
757 pAction->SetSpeed(pInfo->meSpeed, pInfo->meSpeed);
758 pAction->SetDim(pInfo->mbDimPrevious, pInfo->mbDimPrevious);
759 pAction->SetDimColor(pInfo->maDimColor, pInfo->maDimColor);
760 pAction->SetDimHide(pInfo->mbDimHide, pInfo->mbDimHide);
761 pAction->SetSoundOn(pInfo->mbSoundOn, pInfo->mbSoundOn);
762 pAction->SetSound(pInfo->maSoundFile, pInfo->maSoundFile);
763 pAction->SetPlayFull(pInfo->mbPlayFull, pInfo->mbPlayFull);
764 pAction->SetClickAction(pInfo->meClickAction, eClickAction);
765 pAction->SetBookmark(pInfo->GetBookmark(), aBookmark);
766 pAction->SetVerb(pInfo->mnVerb, pInfo->mnVerb);
767 pAction->SetSecondEffect(pInfo->meSecondEffect, pInfo->meSecondEffect);
768 pAction->SetSecondSpeed(pInfo->meSecondSpeed, pInfo->meSecondSpeed);
769 pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, pInfo->mbSecondSoundOn);
770 pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull, pInfo->mbSecondPlayFull);
771
772 OUString aString(SdResId(STR_UNDO_ANIMATION));
773 pAction->SetComment(aString);
774 mpDocSh->GetUndoManager()->AddUndoAction(std::move(pAction));
775 pInfo->meClickAction = eClickAction;
776 pInfo->SetBookmark( aBookmark );
778
779 nRet = nDropAction;
780 }
781 }
782 else if( auto pDrawViewShell = dynamic_cast< DrawViewShell *>( mpViewSh ) )
783 {
784 // insert as normal URL button
785 pDrawViewShell->InsertURLButton( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), OUString(), &aPos );
786 nRet = nDropAction;
787 }
788 }
789 }
790 }
791 }
792 }
793
794 return nRet;
795}
796
797IMPL_LINK( View, ExecuteNavigatorDrop, void*, p, void )
798{
799 SdNavigatorDropEvent* pSdNavigatorDropEvent = static_cast<SdNavigatorDropEvent*>(p);
800 TransferableDataHelper aDataHelper( pSdNavigatorDropEvent->maDropEvent.Transferable );
802 INetBookmark aINetBookmark;
803
804 if( pPageObjsTransferable && aDataHelper.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) )
805 {
806 Point aPos;
807 OUString aBookmark;
808 SdPage* pPage = static_cast<SdPage*>( GetSdrPageView()->GetPage() );
809 sal_uInt16 nPgPos = 0xFFFF;
810
811 if( pSdNavigatorDropEvent->mpTargetWindow )
812 aPos = pSdNavigatorDropEvent->mpTargetWindow->PixelToLogic( pSdNavigatorDropEvent->maPosPixel );
813
814 const OUString& aURL( aINetBookmark.GetURL() );
815 sal_Int32 nIndex = aURL.indexOf( '#' );
816 if( nIndex != -1 )
817 aBookmark = aURL.copy( nIndex+1 );
818
819 std::vector<OUString> aExchangeList;
820 std::vector<OUString> aBookmarkList(1,aBookmark);
821
822 if( !pPage->IsMasterPage() )
823 {
824 if( pPage->GetPageKind() == PageKind::Standard )
825 nPgPos = pPage->GetPageNum() + 2;
826 else if( pPage->GetPageKind() == PageKind::Notes )
827 nPgPos = pPage->GetPageNum() + 1;
828 }
829
830 /* In order t ensure unique page names, we test the ones we want to
831 insert. If necessary. we put them into and replacement list (bNameOK
832 == sal_False -> User canceled). */
833 bool bLink = pPageObjsTransferable->GetDragType() == NAVIGATOR_DRAGTYPE_LINK;
834 bool bNameOK = GetExchangeList( aExchangeList, aBookmarkList, 2 );
835
836 /* Since we don't know the type (page or object), we fill a list with
837 pages and objects.
838 Of course we have problems if there are pages and objects with the
839 same name!!! */
840 if( bNameOK )
841 {
842 mrDoc.InsertBookmark( aBookmarkList, aExchangeList,
843 bLink, nPgPos,
844 &pPageObjsTransferable->GetDocShell(),
845 &aPos );
846 }
847 }
848
849 delete pSdNavigatorDropEvent;
850}
851
852bool View::GetExchangeList (std::vector<OUString> &rExchangeList,
853 std::vector<OUString> &rBookmarkList,
854 const sal_uInt16 nType)
855{
856 assert(rExchangeList.empty());
857
858 bool bListIdentical = true;
859 bool bNameOK = true;
860
861 for ( const auto& rBookmark : rBookmarkList )
862 {
863 OUString aNewName = rBookmark;
864
865 if( nType == 0 || nType == 2 )
866 bNameOK = mpDocSh->CheckPageName(mpViewSh->GetFrameWeld(), aNewName);
867
868 if( bNameOK && ( nType == 1 || nType == 2 ) )
869 {
870 if( mrDoc.GetObj( aNewName ) )
871 {
872 OUString aTitle(SdResId(STR_TITLE_NAMEGROUP));
873 OUString aDesc(SdResId(STR_DESC_NAMEGROUP));
874
877
878 pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_OBJECT );
879
880 bNameOK = false;
881 pDlg->SetText( aTitle );
882
883 while( !bNameOK && pDlg->Execute() == RET_OK )
884 {
885 pDlg->GetName( aNewName );
886
887 if( !mrDoc.GetObj( aNewName ) )
888 bNameOK = true;
889 }
890 }
891 }
892
893 bListIdentical = rBookmark == aNewName;
894
895 rExchangeList.push_back(aNewName);
896
897 if (!bNameOK)
898 break;
899 }
900
901 // Exchange list is identical to bookmark list
902 if( !rExchangeList.empty() && bListIdentical )
903 rExchangeList.clear();
904
905 return bNameOK;
906}
907
908} // end of namespace sd
909
910/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VclPtr< sd::Window > mpTargetWindow
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
virtual std::unique_ptr< SdrModel > CreateMarkedObjModel() const override
sal_Int32 GetParagraphCount() const
sal_Int32 GetTextLen() const
static bool HasValidData(const css::uno::Reference< css::datatransfer::XTransferable > &rTransferable)
const OUString & GetDescription() const
const OUString & GetURL() const
OUString GetURLNoPass(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
vcl::Window * GetWindow() const
tools::Rectangle const & GetOutputArea() const
Outliner * GetOutliner() const
const EditEngine & GetEditEngine() const
bool SetUpdateLayout(bool bUpdate)
void QuickDelete(const ESelection &rSel)
void QuickInsertLineBreak(const ESelection &rSel)
bool IsModified() const
sal_Int32 GetParagraphCount() const
bool mbPlayFull
play sound completely.
Definition: anminfo.hxx:47
css::presentation::AnimationEffect meTextEffect
Animation effect for text content.
Definition: anminfo.hxx:37
bool mbDimHide
hide rather than dim
Definition: anminfo.hxx:42
css::presentation::AnimationEffect meEffect
Animation effect.
Definition: anminfo.hxx:36
void SetBookmark(const OUString &rBookmark)
Definition: anminfo.cxx:95
css::presentation::ClickAction meClickAction
Action at mouse click.
Definition: anminfo.hxx:48
Color maDimColor
for fading the object
Definition: anminfo.hxx:44
sal_uInt16 mnVerb
for OLE object
Definition: anminfo.hxx:54
css::presentation::AnimationEffect meSecondEffect
for object fading.
Definition: anminfo.hxx:49
bool mbSecondSoundOn
for object fading.
Definition: anminfo.hxx:52
OUString GetBookmark() const
Definition: anminfo.cxx:110
OUString maSoundFile
Path to the sound file in MS DOS notation.
Definition: anminfo.hxx:45
css::presentation::AnimationSpeed meSpeed
Speed of the animation.
Definition: anminfo.hxx:38
bool mbDimPrevious
Object fade out.
Definition: anminfo.hxx:40
bool mbActive
turned on?
Definition: anminfo.hxx:39
bool mbSoundOn
Sound on / off.
Definition: anminfo.hxx:46
bool mbSecondPlayFull
for object fading.
Definition: anminfo.hxx:53
css::presentation::AnimationSpeed meSecondSpeed
for object fading.
Definition: anminfo.hxx:50
static SdAnimationInfo * GetShapeUserData(SdrObject &rObject, bool bCreate=false)
Definition: drawdoc2.cxx:959
SAL_DLLPRIVATE void CreatingDataObj(SdTransferable *pTransferable)
Definition: drawdoc.hxx:255
static SAL_DLLPRIVATE SdAnimationInfo * GetAnimationInfo(SdrObject *pObject)
deprecated
Definition: drawdoc2.cxx:950
SAL_DLLPRIVATE SdrObject * GetObj(std::u16string_view rObjName) const
Definition: drawdoc2.cxx:66
virtual SAL_DLLPRIVATE void SetChanged(bool bFlag=true) override
Definition: drawdoc.cxx:658
static SdPageObjsTransferable * getImplementation(const css::uno::Reference< css::uno::XInterface > &rxData) noexcept
Definition: sdtreelb.cxx:132
NavigatorDragType GetDragType() const
Definition: sdtreelb.hxx:432
static SotClipboardFormatId GetListBoxDropFormatId()
Return a temporary transferable data flavor that is used internally in the navigator for reordering e...
Definition: sdtreelb.cxx:138
::sd::DrawDocShell & GetDocShell() const
Definition: sdtreelb.hxx:431
bool IsPresObj(const SdrObject *pObj)
Definition: sdpage.cxx:2322
PageKind GetPageKind() const
Definition: sdpage.hxx:205
PresObjKind GetPresObjKind(SdrObject *pObj) const
Definition: sdpage.cxx:2309
virtual OUString GetLayoutName() const override
Definition: sdpage.hxx:255
virtual void SetSize(const Size &aSize) override
Definition: sdpage.cxx:1746
bool IsPageTransferable() const
Definition: sdxfer.hxx:67
const ::sd::View * GetView() const
Definition: sdxfer.hxx:54
void SetInternalMove(bool bSet)
Definition: sdxfer.hxx:61
bool IsInternalMove() const
Definition: sdxfer.hxx:62
void SetView(const ::sd::View *pView)
Definition: sdxfer.cxx:754
virtual void BrkAction() override
virtual bool IsAction() const override
bool IsUndoEnabled() const
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
void BegUndo()
void EndUndo()
size_t GetHdlCount() const
SdrHdl * GetHdl(size_t nNum) const
SdrHdlKind GetKind() const
const sdr::overlay::OverlayObjectList & getOverlayObjectList() const
SdrLayer * GetLayerPerID(SdrLayerID nID)
const OUString & GetName() const
const SdrMarkList & GetMarkedObjectList() const
bool AreObjectsMarked() const
SdrObject * GetMarkedObjectByIndex(size_t nNum) const
const SdrHdlList & GetHdlList() const
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
tools::Rectangle GetAllMarkedBoundRect() const
size_t GetMarkedObjectCount() const
SdrMark * GetSdrMarkByIndex(size_t nNum) const
SdrDragMode GetDragMode() const
OUString const & GetDescriptionOfMarkedObjects() const
const tools::Rectangle & GetAllMarkedRect() const
SdrObject * GetMarkedSdrObj() const
bool IsChanged() const
SdrUndoFactory & GetSdrUndoFactory() const
const SdrLayerAdmin & GetLayerAdmin() const
SdrTextObj * GetTextEditObject() const
const OutlinerView * GetTextEditOutlinerView() const
virtual bool IsTextEdit() const final override
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum)
sal_uInt32 GetOrdNumDirect() const
SdrObjUserCall * GetUserCall() const
bool IsEmptyPresObj() const
SdrPage * getSdrPageFromSdrObject() const
virtual const tools::Rectangle & GetLogicRect() const
sal_Int64 GetAspect() const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
const Graphic * GetGraphic() const
bool IsLayerVisible(const OUString &rName) const
SdrPage * GetPage() const
bool IsLayerLocked(const OUString &rName) const
sal_uInt16 GetPageNum() const
bool IsMasterPage() const
Size GetSize() const
SdrPageView * GetSdrPageView() const
sal_uInt16 getHitTolLog() const
const OUString & GetActiveLayer() const
virtual std::unique_ptr< SdrUndoAction > CreateUndoDeleteObject(SdrObject &rObject, bool bOrdNumDirect=false)
virtual void DeleteMarked()
const INetURLObject & GetURLObject() const
const OUString & GetName() const
void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc) const
SfxMedium * GetMedium() const
const OUString & GetName() const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
static void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc, const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, const Graphic *pGraphic, sal_Int64 nAspect)
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
static SvxAbstractDialogFactory * Create()
css::uno::Any GetAny(SotClipboardFormatId nFormat, const OUString &rDestDoc) const
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
bool HasFormat(SotClipboardFormatId nFormat) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
bool GetINetBookmark(SotClipboardFormatId nFormat, INetBookmark &rBmk) const
css::uno::Reference< css::datatransfer::XTransferable > GetXTransferable() const
static void ClearPrimarySelection()
void clear()
virtual SfxUndoManager * GetUndoManager() override
Definition: docshell.cxx:363
sd::ViewShell * GetViewShell()
bool CheckPageName(weld::Window *pWin, OUString &rName)
checks, if the given name is a valid new name for a slide
Definition: docshel2.cxx:270
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
void InsertURLField(const OUString &rURL, const OUString &rText, const OUString &rTarget)
Definition: drviewse.cxx:1481
Base class for all Draw specific functions.
Definition: fudraw.hxx:34
static bool IsRunning(ViewShellBase const &rBase)
returns true if there is a running presentation for the given ViewShellBase
Definition: slideshow.cxx:208
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
Definition: ViewShell.hxx:155
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
Definition: viewshel.cxx:1582
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
css::uno::Reference< css::datatransfer::XTransferable > CreateSelectionDataObject(::sd::View *)
Definition: sdview2.cxx:191
virtual void DragFinished(sal_Int8 nDropAction)
Definition: sdview2.cxx:365
bool IsPresObjSelected(bool bOnPage=true, bool bOnMasterPage=true, bool bCheckPresObjListOnly=false, bool bCheckLayoutOnly=false) const
Is a presentation object selected?
Definition: sdview.cxx:523
css::uno::Reference< css::datatransfer::XTransferable > CreateDragDataObject(::sd::View *, vcl::Window &rWindow, const Point &rDragPos)
Definition: sdview2.cxx:143
DrawDocShell * GetDocSh() const
Definition: View.hxx:142
bool GetExchangeList(std::vector< OUString > &rExchangeList, std::vector< OUString > &rBookmarkList, const sal_uInt16 nType)
return parameter: pExchangeList == NULL -> all names are unique bNameOK == false -> cancel by user nT...
Definition: sdview2.cxx:852
SdrObject * mpDropMarkerObj
Definition: View.hxx:265
css::uno::Reference< css::datatransfer::XTransferable > CreateClipboardDataObject()
Definition: sdview2.cxx:80
DrawDocShell * mpDocSh
Definition: View.hxx:262
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt, DropTargetHelper &rTargetHelper, SdrLayerID nLayer)
Definition: sdview2.cxx:429
void StartDrag(const Point &rStartPos, vcl::Window *pWindow)
Definition: sdview2.cxx:342
ViewShell * mpViewSh
Definition: View.hxx:263
void ClearSelectionClipboard()
Definition: sdview2.cxx:226
bool mbIsDropAllowed
Definition: View.hxx:275
std::unique_ptr< SdrMarkList > mpDragSrcMarkList
Definition: View.hxx:264
bool InsertData(const TransferableDataHelper &rDataHelper, const Point &rPos, sal_Int8 &rDnDAction, bool bDrag, SotClipboardFormatId nFormat=SotClipboardFormatId::NONE, sal_uInt16 nPage=SDRPAGE_NOTFOUND, SdrLayerID nLayer=SDRLAYER_NOTFOUND)
Definition: sdview3.cxx:254
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
ends current text editing
Definition: sdview.cxx:772
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer)
Definition: sdview2.cxx:609
void DoCopy()
Definition: sdview2.cxx:256
void UpdateSelectionClipboard()
Definition: sdview2.cxx:214
void DoCut()
Definition: sdview2.cxx:239
void ImplClearDrawDropMarker()
Definition: sdview.cxx:136
std::unique_ptr< SdrDropMarkerOverlay > mpDropMarker
Definition: View.hxx:266
SdDrawDocument & mrDoc
Definition: View.hxx:261
sal_uInt16 mnDragSrcPgNum
Definition: View.hxx:267
void DoPaste(::sd::Window *pWindow=nullptr)
Definition: sdview2.cxx:269
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
Point GetVisibleCenter()
Definition: sdwindow.cxx:689
bool isHitPixel(const Point &rDiscretePosition) const
bool Contains(const Point &rPOINT) const
constexpr Size GetSize() const
tools::Rectangle & Union(const tools::Rectangle &rRect)
Point PixelToLogic(const Point &rDevicePt) const
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define DBG_ASSERT(sCon, aError)
URL aURL
constexpr OUStringLiteral HID_SD_NAMEDIALOG_OBJECT
Definition: helpids.h:40
sal_Int32 nIndex
void * p
sal_Int64 n
aStr
dictionary props
IMPL_LINK(SdCharHeightPropertyBox, implMenuSelectHdl, const OUString &, rIdent, void)
@ NAVIGATOR_DRAGTYPE_EMBEDDED
Definition: pres.hxx:69
@ NAVIGATOR_DRAGTYPE_LINK
Definition: pres.hxx:68
QPRO_FUNC_TYPE nType
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define SD_MOD()
Definition: sdmod.hxx:184
std::map< OUString, rtl::Reference< Entity > > map
sal_Int8 mnAction
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
#define SDR_HANDLE_COLOR_SIZE_SELECTED
#define SDR_HANDLE_COLOR_SIZE_NORMAL
#define SDRPAGE_NOTFOUND
constexpr SdrLayerID SDRLAYER_NOTFOUND(-1)
#define DND_ACTION_COPYMOVE
#define DND_ACTION_MOVE
#define DND_ACTION_COPY
#define DND_ACTION_LINK
#define DND_ACTION_NONE
signed char sal_Int8
RET_OK