Bug Summary

File:home/maarten/src/libreoffice/core/sd/source/ui/view/sdview3.cxx
Warning:line 727, column 51
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name sdview3.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D SD_DLLIMPLEMENTATION -D SDUI_DLL_NAME="libsduilo.so" -D SYSTEM_LIBXML -D ENABLE_SDREMOTE -D ENABLE_SDREMOTE_BLUETOOTH -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/external/bluez_bluetooth/inc -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/sd/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/slidesorter/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sd/sdi -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/oox/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sd/source/ui/view/sdview3.cxx
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#include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
22#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
23#include <com/sun/star/embed/MSOLEObjectSystemCreator.hpp>
24#include <com/sun/star/lang/XComponent.hpp>
25#include <sot/filelist.hxx>
26#include <editeng/editdata.hxx>
27#include <svx/xfillit0.hxx>
28#include <svx/xflclit.hxx>
29#include <svx/xlnclit.hxx>
30#include <svx/svdpagv.hxx>
31#include <sfx2/docfile.hxx>
32#include <svx/svdoole2.hxx>
33#include <svx/svdograf.hxx>
34#include <svx/svdundo.hxx>
35#include <svl/itempool.hxx>
36#include <sot/formats.hxx>
37#include <editeng/outliner.hxx>
38#include <svx/obj3d.hxx>
39#include <svx/e3dundo.hxx>
40#include <svx/unomodel.hxx>
41#include <svx/ImageMapInfo.hxx>
42#include <unotools/streamwrap.hxx>
43#include <vcl/metaact.hxx>
44#include <svx/svxids.hrc>
45#include <toolkit/helper/vclunohelper.hxx>
46#include <svtools/embedhlp.hxx>
47#include <DrawDocShell.hxx>
48#include <fupoor.hxx>
49#include <tablefunction.hxx>
50#include <Window.hxx>
51#include <sdxfer.hxx>
52#include <sdpage.hxx>
53#include <drawdoc.hxx>
54#include <sdmod.hxx>
55#include <sdresid.hxx>
56#include <strings.hrc>
57#include <SlideSorterViewShell.hxx>
58#include <unomodel.hxx>
59#include <ViewClipboard.hxx>
60#include <sfx2/ipclient.hxx>
61#include <sfx2/classificationhelper.hxx>
62#include <comphelper/sequenceashashmap.hxx>
63#include <comphelper/storagehelper.hxx>
64#include <comphelper/processfactory.hxx>
65#include <svx/sdrhittesthelper.hxx>
66#include <svx/xbtmpit.hxx>
67#include <memory>
68
69
70using namespace ::com::sun::star;
71using namespace ::com::sun::star::lang;
72using namespace ::com::sun::star::uno;
73using namespace ::com::sun::star::io;
74using namespace ::com::sun::star::datatransfer;
75using namespace ::com::sun::star::datatransfer::clipboard;
76
77namespace sd {
78
79#define CHECK_FORMAT_TRANS( _def_Type )( ( nFormat == (_def_Type) || nFormat == SotClipboardFormatId
::NONE ) && aDataHelper.HasFormat( _def_Type ) )
( ( nFormat == (_def_Type) || nFormat == SotClipboardFormatId::NONE ) && aDataHelper.HasFormat( _def_Type ) )
80
81/*************************************************************************
82|*
83|* Paste
84|*
85\************************************************************************/
86
87namespace {
88
89struct ImpRememberOrigAndClone
90{
91 SdrObject* pOrig;
92 SdrObject* pClone;
93};
94
95}
96
97static SdrObject* ImpGetClone(std::vector<ImpRememberOrigAndClone>& aConnectorContainer, SdrObject const * pConnObj)
98{
99 for(const ImpRememberOrigAndClone& rImp : aConnectorContainer)
100 {
101 if(pConnObj == rImp.pOrig)
102 return rImp.pClone;
103 }
104 return nullptr;
105}
106
107// restrict movement to WorkArea
108static void ImpCheckInsertPos(Point& rPos, const Size& rSize, const ::tools::Rectangle& rWorkArea)
109{
110 if(rWorkArea.IsEmpty())
111 return;
112
113 ::tools::Rectangle aMarkRect(Point(rPos.X() - (rSize.Width() / 2), rPos.Y() - (rSize.Height() / 2)), rSize);
114
115 if(aMarkRect.IsInside(rWorkArea))
116 return;
117
118 if(aMarkRect.Left() < rWorkArea.Left())
119 {
120 rPos.AdjustX(rWorkArea.Left() - aMarkRect.Left() );
121 }
122
123 if(aMarkRect.Right() > rWorkArea.Right())
124 {
125 rPos.AdjustX( -(aMarkRect.Right() - rWorkArea.Right()) );
126 }
127
128 if(aMarkRect.Top() < rWorkArea.Top())
129 {
130 rPos.AdjustY(rWorkArea.Top() - aMarkRect.Top() );
131 }
132
133 if(aMarkRect.Bottom() > rWorkArea.Bottom())
134 {
135 rPos.AdjustY( -(aMarkRect.Bottom() - rWorkArea.Bottom()) );
136 }
137}
138
139bool View::InsertMetaFile( TransferableDataHelper& rDataHelper, const Point& rPos, ImageMap const * pImageMap, bool bOptimize )
140{
141 GDIMetaFile aMtf;
142
143 if( !rDataHelper.GetGDIMetaFile( SotClipboardFormatId::GDIMETAFILE, aMtf ) )
144 return false;
145
146 bool bVector = false;
147 Graphic aGraphic;
148
149 // check if metafile only contains a pixel image, if so insert a bitmap instead
150 if( bOptimize )
151 {
152 MetaAction* pAction = aMtf.FirstAction();
153 while( pAction && !bVector )
154 {
155 switch( pAction->GetType() )
156 {
157 case MetaActionType::POINT:
158 case MetaActionType::LINE:
159 case MetaActionType::RECT:
160 case MetaActionType::ROUNDRECT:
161 case MetaActionType::ELLIPSE:
162 case MetaActionType::ARC:
163 case MetaActionType::PIE:
164 case MetaActionType::CHORD:
165 case MetaActionType::POLYLINE:
166 case MetaActionType::POLYGON:
167 case MetaActionType::POLYPOLYGON:
168 case MetaActionType::TEXT:
169 case MetaActionType::TEXTARRAY:
170 case MetaActionType::STRETCHTEXT:
171 case MetaActionType::TEXTRECT:
172 case MetaActionType::GRADIENT:
173 case MetaActionType::HATCH:
174 case MetaActionType::WALLPAPER:
175 case MetaActionType::EPS:
176 case MetaActionType::TEXTLINE:
177 case MetaActionType::FLOATTRANSPARENT:
178 case MetaActionType::GRADIENTEX:
179 case MetaActionType::BMPSCALEPART:
180 case MetaActionType::BMPEXSCALEPART:
181 bVector = true;
182 break;
183 case MetaActionType::BMP:
184 case MetaActionType::BMPSCALE:
185 case MetaActionType::BMPEX:
186 case MetaActionType::BMPEXSCALE:
187 if( aGraphic.GetType() != GraphicType::NONE )
188 {
189 bVector = true;
190 }
191 else switch( pAction->GetType() )
192 {
193 case MetaActionType::BMP:
194 {
195 MetaBmpAction* pBmpAction = dynamic_cast< MetaBmpAction* >( pAction );
196 if( pBmpAction )
197 aGraphic = Graphic(BitmapEx(pBmpAction->GetBitmap()));
198 }
199 break;
200 case MetaActionType::BMPSCALE:
201 {
202 MetaBmpScaleAction* pBmpScaleAction = dynamic_cast< MetaBmpScaleAction* >( pAction );
203 if( pBmpScaleAction )
204 aGraphic = Graphic(BitmapEx(pBmpScaleAction->GetBitmap()));
205 }
206 break;
207 case MetaActionType::BMPEX:
208 {
209 MetaBmpExAction* pBmpExAction = dynamic_cast< MetaBmpExAction* >( pAction );
210 if( pBmpExAction )
211 aGraphic = Graphic(pBmpExAction->GetBitmapEx() );
212 }
213 break;
214 case MetaActionType::BMPEXSCALE:
215 {
216 MetaBmpExScaleAction* pBmpExScaleAction = dynamic_cast< MetaBmpExScaleAction* >( pAction );
217 if( pBmpExScaleAction )
218 aGraphic = Graphic( pBmpExScaleAction->GetBitmapEx() );
219 }
220 break;
221 default: break;
222 }
223 break;
224 default: break;
225 }
226
227 pAction = aMtf.NextAction();
228 }
229 }
230
231 // it is not a vector metafile but it also has no graphic?
232 if( !bVector && (aGraphic.GetType() == GraphicType::NONE) )
233 bVector = true;
234
235 // restrict movement to WorkArea
236 Point aInsertPos( rPos );
237 Size aImageSize = bVector ? aMtf.GetPrefSize() : aGraphic.GetSizePixel();
238 ImpCheckInsertPos(aInsertPos, aImageSize, GetWorkArea());
239
240 if( bVector )
241 aGraphic = Graphic( aMtf );
242
243 aGraphic.SetPrefMapMode( aMtf.GetPrefMapMode() );
244 aGraphic.SetPrefSize( aMtf.GetPrefSize() );
245 InsertGraphic( aGraphic, mnAction, aInsertPos, nullptr, pImageMap );
246
247 return true;
248}
249
250bool View::InsertData( const TransferableDataHelper& rDataHelper,
251 const Point& rPos, sal_Int8& rDnDAction, bool bDrag,
252 SotClipboardFormatId nFormat, sal_uInt16 nPage, SdrLayerID nLayer )
253{
254 maDropPos = rPos;
255 mnAction = rDnDAction;
256 mbIsDropAllowed = false;
257
258 TransferableDataHelper aDataHelper( rDataHelper );
259 SdrObject* pPickObj = nullptr;
1
'pPickObj' initialized to a null pointer value
260 SdPage* pPage = nullptr;
261 std::unique_ptr<ImageMap> pImageMap;
262 bool bReturn = false;
263 bool bLink = ( ( mnAction & DND_ACTION_LINKcss::datatransfer::dnd::DNDConstants::ACTION_LINK ) != 0 );
2
Assuming the condition is false
264 bool bCopy = ( ( ( mnAction & DND_ACTION_COPYcss::datatransfer::dnd::DNDConstants::ACTION_COPY ) != 0 ) || bLink );
3
Assuming the condition is false
265 SdrInsertFlags nPasteOptions = SdrInsertFlags::SETDEFLAYER;
266
267 if (mpViewSh != nullptr)
4
Assuming the condition is false
5
Taking false branch
268 {
269 OSL_ASSERT (mpViewSh->GetViewShell()!=nullptr)do { if (true && (!(mpViewSh->GetViewShell()!=nullptr
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/sdview3.cxx"
":" "269" ": "), "OSL_ASSERT: %s", "mpViewSh->GetViewShell()!=nullptr"
); } } while (false)
;
270 SfxInPlaceClient* pIpClient = mpViewSh->GetViewShell()->GetIPClient();
271 if( dynamic_cast< ::sd::slidesorter::SlideSorterViewShell *>( mpViewSh ) != nullptr
272 || (pIpClient!=nullptr && pIpClient->IsObjectInPlaceActive()))
273 nPasteOptions |= SdrInsertFlags::DONTMARK;
274 }
275
276 if( bDrag )
6
Assuming 'bDrag' is false
7
Taking false branch
277 {
278 SdrPageView* pPV = nullptr;
279 pPickObj = PickObj(rPos, getHitTolLog(), pPV);
280 }
281
282 if( nPage != SDRPAGE_NOTFOUND0xFFFF )
8
Assuming 'nPage' is equal to SDRPAGE_NOTFOUND
9
Taking false branch
283 pPage = static_cast<SdPage*>( mrDoc.GetPage( nPage ) );
284
285 SdTransferable* pOwnData = nullptr;
286 SdTransferable* pImplementation = SdTransferable::getImplementation( aDataHelper.GetTransferable() );
287
288 if(pImplementation && (rDnDAction & DND_ACTION_LINKcss::datatransfer::dnd::DNDConstants::ACTION_LINK))
10
Assuming 'pImplementation' is null
289 {
290 // suppress own data when it's intention is to use it as fill information
291 pImplementation = nullptr;
292 }
293
294 // try to get own transfer data
295 if( pImplementation
10.1
'pImplementation' is null
)
11
Taking false branch
296 {
297 if( SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->pTransferClip == pImplementation )
298 pOwnData = SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->pTransferClip;
299 else if( SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->pTransferDrag == pImplementation )
300 pOwnData = SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->pTransferDrag;
301 else if( SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->pTransferSelection == pImplementation )
302 pOwnData = SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->pTransferSelection;
303 }
304
305 // ImageMap?
306 if( !pOwnData
11.1
'pOwnData' is null
&& aDataHelper.HasFormat( SotClipboardFormatId::SVIM ) )
12
Assuming the condition is false
13
Taking false branch
307 {
308 ::tools::SvRef<SotStorageStream> xStm;
309
310 if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVIM, xStm ) )
311 {
312 pImageMap.reset(new ImageMap);
313 // mba: clipboard always must contain absolute URLs (could be from alien source)
314 pImageMap->Read( *xStm );
315 }
316 }
317
318 bool bTable = false;
319 // check special cases for pasting table formats as RTL
320 if( !bLink
13.1
'bLink' is false
&& (nFormat == SotClipboardFormatId::NONE || (nFormat == SotClipboardFormatId::RTF) || (nFormat == SotClipboardFormatId::RICHTEXT)) )
14
Assuming 'nFormat' is not equal to NONE
15
Assuming 'nFormat' is not equal to RTF
16
Assuming 'nFormat' is not equal to RICHTEXT
17
Taking false branch
321 {
322 // if the object supports rtf and there is a table involved, default is to create a table
323 bool bIsRTF = aDataHelper.HasFormat( SotClipboardFormatId::RTF );
324 if( ( bIsRTF || aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) )
325 && ! aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) )
326 {
327 ::tools::SvRef<SotStorageStream> xStm;
328
329 if( aDataHelper.GetSotStorageStream( bIsRTF ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT, xStm ) )
330 {
331 xStm->Seek( 0 );
332
333 OString aLine;
334 while (xStm->ReadLine(aLine))
335 {
336 sal_Int32 x = aLine.indexOf( "\\trowd" );
337 if (x != -1)
338 {
339 bTable = true;
340 nFormat = bIsRTF ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT;
341 break;
342 }
343 }
344 }
345 }
346 }
347
348 // Changed the whole decision tree to be dependent of bReturn as a flag that
349 // the work was done; this allows to check multiple formats and not just fail
350 // when a CHECK_FORMAT_TRANS(*format*) detected format does not work. This is
351 // e.g. necessary for SotClipboardFormatId::BITMAP
352
353 if (!bReturn
17.1
'bReturn' is false
&& pOwnData
17.2
'pOwnData' is null
)
18
Taking false branch
354 {
355 // Paste only if SfxClassificationHelper recommends so.
356 const SfxObjectShellRef& pSource = pOwnData->GetDocShell();
357 SfxObjectShell* pDestination = mrDoc.GetDocSh();
358 if (pSource.is() && pDestination)
359 {
360 SfxClassificationCheckPasteResult eResult = SfxClassificationHelper::CheckPaste(pSource->getDocProperties(), pDestination->getDocProperties());
361 if (!SfxClassificationHelper::ShowPasteInfo(eResult))
362 bReturn = true;
363 }
364 }
365
366 if( !bReturn
18.1
'bReturn' is false
&& pOwnData
18.2
'pOwnData' is null
&& nFormat == SotClipboardFormatId::NONE )
367 {
368 const View* pSourceView = pOwnData->GetView();
369
370 if( pOwnData->GetDocShell().is() && pOwnData->IsPageTransferable() )
371 {
372 mpClipboard->HandlePageDrop (*pOwnData);
373 bReturn = true;
374 }
375 else if( pSourceView )
376 {
377 if( pSourceView == this )
378 {
379 // same view
380 if( nLayer != SDRLAYER_NOTFOUND )
381 {
382 // drop on layer tab bar
383 SdrLayerAdmin& rLayerAdmin = mrDoc.GetLayerAdmin();
384 SdrLayer* pLayer = rLayerAdmin.GetLayerPerID( nLayer );
385 SdrPageView* pPV = GetSdrPageView();
386 OUString aLayer = pLayer->GetName();
387
388 if( !pPV->IsLayerLocked( aLayer ) )
389 {
390 pOwnData->SetInternalMove( true );
391 SortMarkedObjects();
392
393 for( size_t nM = 0; nM < GetMarkedObjectCount(); ++nM )
394 {
395 SdrMark* pM = GetSdrMarkByIndex( nM );
396 SdrObject* pO = pM->GetMarkedSdrObj();
397
398 if( pO )
399 {
400 // #i11702#
401 if( IsUndoEnabled() )
402 {
403 BegUndo(SdResId(STR_MODIFYLAYERreinterpret_cast<char const *>("STR_MODIFYLAYER" "\004"
u8"Modify Layer")
));
404 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO, pO->GetLayer(), nLayer));
405 EndUndo();
406 }
407
408 pO->SetLayer( nLayer );
409 }
410 }
411
412 bReturn = true;
413 }
414 }
415 else
416 {
417 SdrPageView* pPV = GetSdrPageView();
418 bool bDropOnTabBar = true;
419
420 if( !pPage && pPV->GetPage()->GetPageNum() != mnDragSrcPgNum )
421 {
422 pPage = static_cast<SdPage*>( pPV->GetPage() );
423 bDropOnTabBar = false;
424 }
425
426 if( pPage )
427 {
428 // drop on other page
429 OUString aActiveLayer = GetActiveLayer();
430
431 if( !pPV->IsLayerLocked( aActiveLayer ) )
432 {
433 if( !IsPresObjSelected() )
434 {
435 SdrMarkList* pMarkList;
436
437 if( (mnDragSrcPgNum != SDRPAGE_NOTFOUND0xFFFF) && (mnDragSrcPgNum != pPV->GetPage()->GetPageNum()) )
438 {
439 pMarkList = mpDragSrcMarkList.get();
440 }
441 else
442 {
443 // actual mark list is used
444 pMarkList = new SdrMarkList( GetMarkedObjectList());
445 }
446
447 pMarkList->ForceSort();
448
449 // stuff to remember originals and clones
450 std::vector<ImpRememberOrigAndClone> aConnectorContainer;
451 size_t nConnectorCount = 0;
452 Point aCurPos;
453
454 // calculate real position of current
455 // source objects, if necessary (#103207)
456 if( pOwnData == SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->pTransferSelection )
457 {
458 ::tools::Rectangle aCurBoundRect;
459
460 if( pMarkList->TakeBoundRect( pPV, aCurBoundRect ) )
461 aCurPos = aCurBoundRect.TopLeft();
462 else
463 aCurPos = pOwnData->GetStartPos();
464 }
465 else
466 aCurPos = pOwnData->GetStartPos();
467
468 const Size aVector( maDropPos.X() - aCurPos.X(), maDropPos.Y() - aCurPos.Y() );
469
470 std::unordered_set<rtl::OUString> aNameSet;
471 for(size_t a = 0; a < pMarkList->GetMarkCount(); ++a)
472 {
473 SdrMark* pM = pMarkList->GetMark(a);
474 SdrObject* pObj(pM->GetMarkedSdrObj()->CloneSdrObject(pPage->getSdrModelFromSdrPage()));
475
476 if(pObj)
477 {
478 if(!bDropOnTabBar)
479 {
480 // do a NbcMove(...) instead of setting SnapRects here
481 pObj->NbcMove(aVector);
482 }
483
484 SdrObject* pMarkParent = pM->GetMarkedSdrObj()->getParentSdrObjectFromSdrObject();
485 if (bCopy || (pMarkParent && pMarkParent->IsGroupObject()))
486 pPage->InsertObjectThenMakeNameUnique(pObj, aNameSet);
487 else
488 pPage->InsertObject(pObj);
489
490 if( IsUndoEnabled() )
491 {
492 BegUndo(SdResId(STR_UNDO_DRAGDROPreinterpret_cast<char const *>("STR_UNDO_DRAGDROP" "\004"
u8"Drag and Drop")
));
493 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
494 EndUndo();
495 }
496
497 ImpRememberOrigAndClone aRem;
498 aRem.pOrig = pM->GetMarkedSdrObj();
499 aRem.pClone = pObj;
500 aConnectorContainer.push_back(aRem);
501
502 if(dynamic_cast< SdrEdgeObj *>( pObj ) != nullptr)
503 nConnectorCount++;
504 }
505 }
506
507 // try to re-establish connections at clones
508 if(nConnectorCount)
509 {
510 for(size_t a = 0; a < aConnectorContainer.size(); ++a)
511 {
512 ImpRememberOrigAndClone* pRem = &aConnectorContainer[a];
513
514 if(dynamic_cast< const SdrEdgeObj *>( pRem->pClone ) != nullptr)
515 {
516 SdrEdgeObj* pOrigEdge = static_cast<SdrEdgeObj*>(pRem->pOrig);
517 SdrEdgeObj* pCloneEdge = static_cast<SdrEdgeObj*>(pRem->pClone);
518
519 // test first connection
520 SdrObjConnection& rConn0 = pOrigEdge->GetConnection(false);
521 SdrObject* pConnObj = rConn0.GetObject();
522 if(pConnObj)
523 {
524 SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
525 if(pConnClone)
526 {
527 // if dest obj was cloned, too, re-establish connection
528 pCloneEdge->ConnectToNode(false, pConnClone);
529 pCloneEdge->GetConnection(false).SetConnectorId(rConn0.GetConnectorId());
530 }
531 else
532 {
533 // set position of connection point of original connected object
534 const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
535 if(pGlueList)
536 {
537 sal_uInt16 nInd = pGlueList->FindGluePoint(rConn0.GetConnectorId());
538
539 if(SDRGLUEPOINT_NOTFOUND0xFFFF != nInd)
540 {
541 const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
542 Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
543 aPosition.AdjustX(aVector.Width() );
544 aPosition.AdjustY(aVector.Height() );
545 pCloneEdge->SetTailPoint(false, aPosition);
546 }
547 }
548 }
549 }
550
551 // test second connection
552 SdrObjConnection& rConn1 = pOrigEdge->GetConnection(true);
553 pConnObj = rConn1.GetObject();
554 if(pConnObj)
555 {
556 SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
557 if(pConnClone)
558 {
559 // if dest obj was cloned, too, re-establish connection
560 pCloneEdge->ConnectToNode(true, pConnClone);
561 pCloneEdge->GetConnection(true).SetConnectorId(rConn1.GetConnectorId());
562 }
563 else
564 {
565 // set position of connection point of original connected object
566 const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
567 if(pGlueList)
568 {
569 sal_uInt16 nInd = pGlueList->FindGluePoint(rConn1.GetConnectorId());
570
571 if(SDRGLUEPOINT_NOTFOUND0xFFFF != nInd)
572 {
573 const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
574 Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
575 aPosition.AdjustX(aVector.Width() );
576 aPosition.AdjustY(aVector.Height() );
577 pCloneEdge->SetTailPoint(true, aPosition);
578 }
579 }
580 }
581 }
582 }
583 }
584 }
585
586 if( pMarkList != mpDragSrcMarkList.get() )
587 delete pMarkList;
588
589 bReturn = true;
590 }
591 else
592 {
593 maDropErrorIdle.Start();
594 bReturn = false;
595 }
596 }
597 }
598 else
599 {
600 pOwnData->SetInternalMove( true );
601 MoveAllMarked( Size( maDropPos.X() - pOwnData->GetStartPos().X(),
602 maDropPos.Y() - pOwnData->GetStartPos().Y() ), bCopy );
603 bReturn = true;
604 }
605 }
606 }
607 else
608 {
609 // different views
610 if( !pSourceView->IsPresObjSelected() )
611 {
612 // model is owned by from AllocModel() created DocShell
613 SdDrawDocument* pSourceDoc = static_cast<SdDrawDocument*>( pSourceView->GetModel() );
614 pSourceDoc->CreatingDataObj( pOwnData );
615 SdDrawDocument* pModel = static_cast<SdDrawDocument*>( pSourceView->CreateMarkedObjModel().release() );
616 bReturn = Paste(*pModel, maDropPos, pPage, nPasteOptions);
617
618 if( !pPage )
619 pPage = static_cast<SdPage*>( GetSdrPageView()->GetPage() );
620
621 OUString aLayout = pPage->GetLayoutName();
622 sal_Int32 nPos = aLayout.indexOf(SD_LT_SEPARATOR"~LT~");
623 if (nPos != -1)
624 aLayout = aLayout.copy(0, nPos);
625 pPage->SetPresentationLayout( aLayout, false, false );
626 pSourceDoc->CreatingDataObj( nullptr );
627 }
628 else
629 {
630 maDropErrorIdle.Start();
631 bReturn = false;
632 }
633 }
634 }
635 else
636 {
637 SdDrawDocument* pWorkModel = const_cast<SdDrawDocument*>(pOwnData->GetWorkDocument());
638 SdPage* pWorkPage = pWorkModel->GetSdPage( 0, PageKind::Standard );
639
640 pWorkPage->SetSdrObjListRectsDirty();
641
642 // #i120393# Clipboard data uses full object geometry range
643 const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
644
645 maDropPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ) );
646 maDropPos.setY( pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ) );
647
648 // delete pages, that are not of any interest for us
649 for( long i = pWorkModel->GetPageCount() - 1; i >= 0; i-- )
650 {
651 SdPage* pP = static_cast< SdPage* >( pWorkModel->GetPage( static_cast<sal_uInt16>(i) ) );
652
653 if( pP->GetPageKind() != PageKind::Standard )
654 pWorkModel->DeletePage( static_cast<sal_uInt16>(i) );
655 }
656
657 bReturn = Paste(*pWorkModel, maDropPos, pPage, nPasteOptions);
658
659 if( !pPage )
660 pPage = static_cast<SdPage*>( GetSdrPageView()->GetPage() );
661
662 OUString aLayout = pPage->GetLayoutName();
663 sal_Int32 nPos = aLayout.indexOf(SD_LT_SEPARATOR"~LT~");
664 if (nPos != -1)
665 aLayout = aLayout.copy(0, nPos);
666 pPage->SetPresentationLayout( aLayout, false, false );
667 }
668 }
669
670 if(!bReturn
18.3
'bReturn' is false
&& CHECK_FORMAT_TRANS( SotClipboardFormatId::DRAWING )( ( nFormat == (SotClipboardFormatId::DRAWING) || nFormat == SotClipboardFormatId
::NONE ) && aDataHelper.HasFormat( SotClipboardFormatId
::DRAWING ) )
)
19
Assuming 'nFormat' is equal to DRAWING
20
Assuming the condition is true
21
Taking true branch
671 {
672 ::tools::SvRef<SotStorageStream> xStm;
673
674 if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING, xStm ) )
22
Assuming the condition is true
23
Taking true branch
675 {
676 DrawDocShellRef xShell = new DrawDocShell(SfxObjectCreateMode::INTERNAL, false, DocumentType::Impress);
677 xShell->DoInitNew();
678
679 SdDrawDocument* pModel = xShell->GetDoc();
680 pModel->InsertPage(pModel->AllocPage(false));
681
682 Reference< XComponent > xComponent = xShell->GetModel();
683 xStm->Seek( 0 );
684
685 css::uno::Reference< css::io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
686 bReturn = SvxDrawingLayerImport( pModel, xInputStream, xComponent, "com.sun.star.comp.Impress.XMLOasisImporter" );
687
688 if( pModel->GetPageCount() == 0 )
24
Assuming the condition is false
25
Taking false branch
689 {
690 OSL_FAIL("empty or invalid drawing xml document on clipboard!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/sdview3.cxx"
":" "690" ": "), "%s", "empty or invalid drawing xml document on clipboard!"
); } } while (false)
;
691 }
692 else
693 {
694 bool bChanged = false;
695
696 if( bReturn )
26
Assuming 'bReturn' is true
27
Taking true branch
697 {
698 if( pModel->GetSdPage( 0, PageKind::Standard )->GetObjCount() == 1 )
28
Assuming the condition is true
29
Taking true branch
699 {
700 // only one object
701 SdrObject* pObj = pModel->GetSdPage( 0, PageKind::Standard )->GetObj( 0 );
702 SdrPageView* pPV = nullptr;
703 SdrObject* pPickObj2 = PickObj(rPos, getHitTolLog(), pPV);
704
705 if( ( mnAction & DND_ACTION_MOVEcss::datatransfer::dnd::DNDConstants::ACTION_MOVE ) && pPickObj2 && pObj )
30
Assuming the condition is true
31
Assuming 'pPickObj2' is non-null
32
Assuming 'pObj' is non-null
33
Taking true branch
706 {
707 // replace object
708 SdrPage* pWorkPage = GetSdrPageView()->GetPage();
709 SdrObject* pNewObj(pObj->CloneSdrObject(pWorkPage->getSdrModelFromSdrPage()));
710 ::tools::Rectangle aPickObjRect( pPickObj2->GetCurrentBoundRect() );
711 Size aPickObjSize( aPickObjRect.GetSize() );
712 Point aVec( aPickObjRect.TopLeft() );
713 ::tools::Rectangle aObjRect( pNewObj->GetCurrentBoundRect() );
714 Size aObjSize( aObjRect.GetSize() );
715
716 Fraction aScaleWidth( aPickObjSize.Width(), aObjSize.Width() );
717 Fraction aScaleHeight( aPickObjSize.Height(), aObjSize.Height() );
718 pNewObj->NbcResize( aObjRect.TopLeft(), aScaleWidth, aScaleHeight );
719
720 aVec -= aObjRect.TopLeft();
721 pNewObj->NbcMove( Size( aVec.X(), aVec.Y() ) );
722
723 const bool bUndo = IsUndoEnabled();
724
725 if( bUndo )
34
Assuming 'bUndo' is false
35
Taking false branch
726 BegUndo(SdResId(STR_UNDO_DRAGDROPreinterpret_cast<char const *>("STR_UNDO_DRAGDROP" "\004"
u8"Drag and Drop")
));
727 pNewObj->NbcSetLayer( pPickObj->GetLayer() );
36
Called C++ object pointer is null
728 pWorkPage->InsertObject( pNewObj );
729 if( bUndo )
730 {
731 AddUndo( mrDoc.GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
732 AddUndo( mrDoc.GetSdrUndoFactory().CreateUndoDeleteObject( *pPickObj2 ) );
733 }
734 pWorkPage->RemoveObject( pPickObj2->GetOrdNum() );
735
736 if( bUndo )
737 {
738 EndUndo();
739 }
740 else
741 {
742 SdrObject::Free(pPickObj2 );
743 }
744 bChanged = true;
745 mnAction = DND_ACTION_COPYcss::datatransfer::dnd::DNDConstants::ACTION_COPY;
746 }
747 else if( ( mnAction & DND_ACTION_LINKcss::datatransfer::dnd::DNDConstants::ACTION_LINK ) && pPickObj && pObj &&
748 dynamic_cast< const SdrGrafObj *>( pPickObj ) == nullptr &&
749 dynamic_cast< const SdrOle2Obj *>( pPickObj ) == nullptr )
750 {
751 SfxItemSet aSet( mrDoc.GetPool() );
752
753 // set new attributes to object
754 const bool bUndo = IsUndoEnabled();
755 if( bUndo )
756 {
757 BegUndo( SdResId(STR_UNDO_DRAGDROPreinterpret_cast<char const *>("STR_UNDO_DRAGDROP" "\004"
u8"Drag and Drop")
) );
758 AddUndo( mrDoc.GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
759 }
760
761 aSet.Put( pObj->GetMergedItemSet() );
762
763 /* Do not take over corner radius. There are
764 gradients (rectangles) in the gallery with corner
765 radius of 0. We should not use that on the
766 object. */
767 aSet.ClearItem( SDRATTR_ECKENRADIUS );
768
769 const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
770
771 if(pSdrGrafObj)
772 {
773 // If we have a graphic as source object, use its graphic
774 // content as fill style
775 aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
776 aSet.Put(XFillBitmapItem(pSdrGrafObj->GetGraphic()));
777 }
778
779 pPickObj->SetMergedItemSetAndBroadcast( aSet );
780
781 if( dynamic_cast< E3dObject *>( pPickObj ) != nullptr && dynamic_cast< E3dObject *>( pObj ) != nullptr )
782 {
783 // handle 3D attribute in addition
784 SfxItemSet aNewSet( mrDoc.GetPool(), svl::Items<SID_ATTR_3D_START( 10000 + 415 ), SID_ATTR_3D_END( 10000 + 649 )>{} );
785 SfxItemSet aOldSet( mrDoc.GetPool(), svl::Items<SID_ATTR_3D_START( 10000 + 415 ), SID_ATTR_3D_END( 10000 + 649 )>{} );
786
787 aOldSet.Put(pPickObj->GetMergedItemSet());
788 aNewSet.Put( pObj->GetMergedItemSet() );
789
790 if( bUndo )
791 AddUndo(
792 std::make_unique<E3dAttributesUndoAction>(
793 *static_cast< E3dObject* >(pPickObj),
794 aNewSet,
795 aOldSet));
796 pPickObj->SetMergedItemSetAndBroadcast( aNewSet );
797 }
798
799 if( bUndo )
800 EndUndo();
801 bChanged = true;
802 }
803 }
804 }
805
806 if( !bChanged )
807 {
808 SdrPage* pWorkPage = pModel->GetSdPage( 0, PageKind::Standard );
809
810 pWorkPage->SetSdrObjListRectsDirty();
811
812 if( pOwnData )
813 {
814 // #i120393# Clipboard data uses full object geometry range
815 const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
816
817 maDropPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ) );
818 maDropPos.setY( pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ) );
819 }
820
821 bReturn = Paste(*pModel, maDropPos, pPage, nPasteOptions);
822 }
823
824 xShell->DoClose();
825 }
826 }
827 }
828
829 if(!bReturn && CHECK_FORMAT_TRANS(SotClipboardFormatId::SBA_FIELDDATAEXCHANGE)( ( nFormat == (SotClipboardFormatId::SBA_FIELDDATAEXCHANGE) ||
nFormat == SotClipboardFormatId::NONE ) && aDataHelper
.HasFormat( SotClipboardFormatId::SBA_FIELDDATAEXCHANGE ) )
)
830 {
831 OUString aOUString;
832
833 if( aDataHelper.GetString( SotClipboardFormatId::SBA_FIELDDATAEXCHANGE, aOUString ) )
834 {
835 SdrObjectUniquePtr pObj = CreateFieldControl( aOUString );
836
837 if( pObj )
838 {
839 ::tools::Rectangle aRect( pObj->GetLogicRect() );
840 Size aSize( aRect.GetSize() );
841
842 maDropPos.AdjustX( -( aSize.Width() >> 1 ) );
843 maDropPos.AdjustY( -( aSize.Height() >> 1 ) );
844
845 aRect.SetPos( maDropPos );
846 pObj->SetLogicRect( aRect );
847 InsertObjectAtView( pObj.release(), *GetSdrPageView(), SdrInsertFlags::SETDEFLAYER );
848 bReturn = true;
849 }
850 }
851 }
852
853 if(!bReturn &&
854 !bLink &&
855 (CHECK_FORMAT_TRANS(SotClipboardFormatId::EMBED_SOURCE)( ( nFormat == (SotClipboardFormatId::EMBED_SOURCE) || nFormat
== SotClipboardFormatId::NONE ) && aDataHelper.HasFormat
( SotClipboardFormatId::EMBED_SOURCE ) )
|| CHECK_FORMAT_TRANS(SotClipboardFormatId::EMBEDDED_OBJ)( ( nFormat == (SotClipboardFormatId::EMBEDDED_OBJ) || nFormat
== SotClipboardFormatId::NONE ) && aDataHelper.HasFormat
( SotClipboardFormatId::EMBEDDED_OBJ ) )
) &&
856 aDataHelper.HasFormat(SotClipboardFormatId::OBJECTDESCRIPTOR))
857 {
858 //TODO/LATER: is it possible that this format is binary?! (from old versions of SO)
859 uno::Reference < io::XInputStream > xStm;
860 TransferableObjectDescriptor aObjDesc;
861
862 if (aDataHelper.GetTransferableObjectDescriptor(SotClipboardFormatId::OBJECTDESCRIPTOR, aObjDesc))
863 {
864 OUString aDocShellID = SfxObjectShell::CreateShellID(mrDoc.GetDocSh());
865 xStm = aDataHelper.GetInputStream(nFormat != SotClipboardFormatId::NONE ? nFormat : SotClipboardFormatId::EMBED_SOURCE, aDocShellID);
866 if (!xStm.is())
867 xStm = aDataHelper.GetInputStream(SotClipboardFormatId::EMBEDDED_OBJ, aDocShellID);
868 }
869
870 if (xStm.is())
871 {
872 if( mrDoc.GetDocSh() && ( mrDoc.GetDocSh()->GetClassName() == aObjDesc.maClassName ) )
873 {
874 uno::Reference < embed::XStorage > xStore( ::comphelper::OStorageHelper::GetStorageFromInputStream( xStm ) );
875 ::sd::DrawDocShellRef xDocShRef( new ::sd::DrawDocShell( SfxObjectCreateMode::EMBEDDED, true, mrDoc.GetDocumentType() ) );
876
877 // mba: BaseURL doesn't make sense for clipboard functionality
878 SfxMedium *pMedium = new SfxMedium( xStore, OUString() );
879 if( xDocShRef->DoLoad( pMedium ) )
880 {
881 SdDrawDocument* pModel = xDocShRef->GetDoc();
882 SdPage* pWorkPage = pModel->GetSdPage( 0, PageKind::Standard );
883
884 pWorkPage->SetSdrObjListRectsDirty();
885
886 if( pOwnData )
887 {
888 // #i120393# Clipboard data uses full object geometry range
889 const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
890
891 maDropPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ) );
892 maDropPos.setY( pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ) );
893 }
894
895 // delete pages, that are not of any interest for us
896 for( long i = pModel->GetPageCount() - 1; i >= 0; i-- )
897 {
898 SdPage* pP = static_cast< SdPage* >( pModel->GetPage( static_cast<sal_uInt16>(i) ) );
899
900 if( pP->GetPageKind() != PageKind::Standard )
901 pModel->DeletePage( static_cast<sal_uInt16>(i) );
902 }
903
904 bReturn = Paste(*pModel, maDropPos, pPage, nPasteOptions);
905
906 if( !pPage )
907 pPage = static_cast<SdPage*>(GetSdrPageView()->GetPage());
908
909 OUString aLayout = pPage->GetLayoutName();
910 sal_Int32 nPos = aLayout.indexOf(SD_LT_SEPARATOR"~LT~");
911 if (nPos != -1)
912 aLayout = aLayout.copy(0, nPos);
913 pPage->SetPresentationLayout( aLayout, false, false );
914 }
915
916 xDocShRef->DoClose();
917 xDocShRef.clear();
918
919 }
920 else
921 {
922 OUString aName;
923 uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
924 if ( xObj.is() )
925 {
926 svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
927
928 Size aSize;
929 if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
930 {
931 if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
932 aSize = aObjDesc.maSize;
933 else
934 {
935 MapMode aMapMode( MapUnit::Map100thMM );
936 aSize = aObjRef.GetSize( &aMapMode );
937 }
938 }
939 else
940 {
941 awt::Size aSz;
942 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
943 if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
944 {
945 Size aTmp(OutputDevice::LogicToLogic(aObjDesc.maSize, MapMode(MapUnit::Map100thMM), MapMode(aMapUnit)));
946 aSz.Width = aTmp.Width();
947 aSz.Height = aTmp.Height();
948 xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
949 }
950
951 try
952 {
953 aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
954 }
955 catch( embed::NoVisualAreaSizeException& )
956 {
957 // if the size still was not set the default size will be set later
958 }
959
960 aSize = Size( aSz.Width, aSz.Height );
961
962 if( !aSize.Width() || !aSize.Height() )
963 {
964 aSize.setWidth( 14100 );
965 aSize.setHeight( 10000 );
966 aSize = OutputDevice::LogicToLogic(Size(14100, 10000), MapMode(MapUnit::Map100thMM), MapMode(aMapUnit));
967 aSz.Width = aSize.Width();
968 aSz.Height = aSize.Height();
969 xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
970 }
971
972 aSize = OutputDevice::LogicToLogic(aSize, MapMode(aMapUnit), MapMode(MapUnit::Map100thMM));
973 }
974
975 Size aMaxSize( mrDoc.GetMaxObjSize() );
976
977 maDropPos.AdjustX( -(std::min( aSize.Width(), aMaxSize.Width() ) >> 1) );
978 maDropPos.AdjustY( -(std::min( aSize.Height(), aMaxSize.Height() ) >> 1) );
979
980 ::tools::Rectangle aRect( maDropPos, aSize );
981 SdrOle2Obj* pObj = new SdrOle2Obj(
982 getSdrModelFromSdrView(),
983 aObjRef,
984 aName,
985 aRect);
986 SdrPageView* pPV = GetSdrPageView();
987 SdrInsertFlags nOptions = SdrInsertFlags::SETDEFLAYER;
988
989 if (mpViewSh!=nullptr)
990 {
991 OSL_ASSERT (mpViewSh->GetViewShell()!=nullptr)do { if (true && (!(mpViewSh->GetViewShell()!=nullptr
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/sdview3.cxx"
":" "991" ": "), "OSL_ASSERT: %s", "mpViewSh->GetViewShell()!=nullptr"
); } } while (false)
;
992 SfxInPlaceClient* pIpClient
993 = mpViewSh->GetViewShell()->GetIPClient();
994 if (pIpClient!=nullptr && pIpClient->IsObjectInPlaceActive())
995 nOptions |= SdrInsertFlags::DONTMARK;
996 }
997
998 InsertObjectAtView( pObj, *pPV, nOptions );
999
1000 if( pImageMap )
1001 pObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( *pImageMap )) );
1002
1003 if (pObj->IsChart())
1004 {
1005 bool bDisableDataTableDialog = false;
1006 svt::EmbeddedObjectRef::TryRunningState( xObj );
1007 uno::Reference< beans::XPropertySet > xProps( xObj->getComponent(), uno::UNO_QUERY );
1008 if ( xProps.is() &&
1009 ( xProps->getPropertyValue( "DisableDataTableDialog" ) >>= bDisableDataTableDialog ) &&
1010 bDisableDataTableDialog )
1011 {
1012 xProps->setPropertyValue( "DisableDataTableDialog" , uno::makeAny( false ) );
1013 xProps->setPropertyValue( "DisableComplexChartTypes" , uno::makeAny( false ) );
1014 uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY );
1015 if ( xModifiable.is() )
1016 {
1017 xModifiable->setModified( true );
1018 }
1019 }
1020 }
1021
1022 bReturn = true;
1023 }
1024 }
1025 }
1026 }
1027
1028 if(!bReturn &&
1029 !bLink &&
1030 (CHECK_FORMAT_TRANS(SotClipboardFormatId::EMBEDDED_OBJ_OLE)( ( nFormat == (SotClipboardFormatId::EMBEDDED_OBJ_OLE) || nFormat
== SotClipboardFormatId::NONE ) && aDataHelper.HasFormat
( SotClipboardFormatId::EMBEDDED_OBJ_OLE ) )
|| CHECK_FORMAT_TRANS(SotClipboardFormatId::EMBED_SOURCE_OLE)( ( nFormat == (SotClipboardFormatId::EMBED_SOURCE_OLE) || nFormat
== SotClipboardFormatId::NONE ) && aDataHelper.HasFormat
( SotClipboardFormatId::EMBED_SOURCE_OLE ) )
) &&
1031 aDataHelper.HasFormat(SotClipboardFormatId::OBJECTDESCRIPTOR_OLE))
1032 {
1033 // online insert ole if format is forced or no gdi metafile is available
1034 if( (nFormat != SotClipboardFormatId::NONE) || !aDataHelper.HasFormat( SotClipboardFormatId::GDIMETAFILE ) )
1035 {
1036 uno::Reference < io::XInputStream > xStm;
1037 TransferableObjectDescriptor aObjDesc;
1038
1039 if ( aDataHelper.GetTransferableObjectDescriptor( SotClipboardFormatId::OBJECTDESCRIPTOR_OLE, aObjDesc ) )
1040 {
1041 uno::Reference < embed::XEmbeddedObject > xObj;
1042 OUString aName;
1043
1044 xStm = aDataHelper.GetInputStream(nFormat != SotClipboardFormatId::NONE ? nFormat : SotClipboardFormatId::EMBED_SOURCE_OLE, OUString());
1045 if (!xStm.is())
1046 xStm = aDataHelper.GetInputStream(SotClipboardFormatId::EMBEDDED_OBJ_OLE, OUString());
1047
1048 if (xStm.is())
1049 {
1050 xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
1051 }
1052 else
1053 {
1054 try
1055 {
1056 uno::Reference< embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
1057 uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator =
1058 embed::MSOLEObjectSystemCreator::create( ::comphelper::getProcessComponentContext() );
1059
1060 embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
1061 xTmpStor,
1062 "DummyName" ,
1063 uno::Sequence< beans::PropertyValue >() );
1064
1065 // TODO/LATER: in future InsertedObjectInfo will be used to get container related information
1066 // for example whether the object should be an iconified one
1067 xObj = aInfo.Object;
1068 if ( xObj.is() )
1069 mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
1070 }
1071 catch( uno::Exception& )
1072 {}
1073 }
1074
1075 if ( xObj.is() )
1076 {
1077 svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
1078
1079 // try to get the replacement image from the clipboard
1080 Graphic aGraphic;
1081 SotClipboardFormatId nGrFormat = SotClipboardFormatId::NONE;
1082
1083// (for Selection Manager in Trusted Solaris)
1084#ifndef __sun
1085 if( aDataHelper.GetGraphic( SotClipboardFormatId::SVXB, aGraphic ) )
1086 nGrFormat = SotClipboardFormatId::SVXB;
1087 else if( aDataHelper.GetGraphic( SotClipboardFormatId::GDIMETAFILE, aGraphic ) )
1088 nGrFormat = SotClipboardFormatId::GDIMETAFILE;
1089 else if( aDataHelper.GetGraphic( SotClipboardFormatId::BITMAP, aGraphic ) )
1090 nGrFormat = SotClipboardFormatId::BITMAP;
1091#endif
1092
1093 // insert replacement image ( if there is one ) into the object helper
1094 if ( nGrFormat != SotClipboardFormatId::NONE )
1095 {
1096 datatransfer::DataFlavor aDataFlavor;
1097 SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
1098 aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
1099 }
1100
1101 Size aSize;
1102 if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
1103 {
1104 if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
1105 aSize = aObjDesc.maSize;
1106 else
1107 {
1108 MapMode aMapMode( MapUnit::Map100thMM );
1109 aSize = aObjRef.GetSize( &aMapMode );
1110 }
1111 }
1112 else
1113 {
1114 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
1115
1116 awt::Size aSz;
1117 try{
1118 aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
1119 }
1120 catch( embed::NoVisualAreaSizeException& )
1121 {
1122 // the default size will be set later
1123 }
1124
1125 if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
1126 {
1127 Size aTmp(OutputDevice::LogicToLogic(aObjDesc.maSize, MapMode(MapUnit::Map100thMM), MapMode(aMapUnit)));
1128 if ( aSz.Width != aTmp.Width() || aSz.Height != aTmp.Height() )
1129 {
1130 aSz.Width = aTmp.Width();
1131 aSz.Height = aTmp.Height();
1132 xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
1133 }
1134 }
1135
1136 aSize = Size( aSz.Width, aSz.Height );
1137
1138 if( !aSize.Width() || !aSize.Height() )
1139 {
1140 aSize = OutputDevice::LogicToLogic(Size(14100, 10000), MapMode(MapUnit::Map100thMM), MapMode(aMapUnit));
1141 aSz.Width = aSize.Width();
1142 aSz.Height = aSize.Height();
1143 xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
1144 }
1145
1146 aSize = OutputDevice::LogicToLogic(aSize, MapMode(aMapUnit), MapMode(MapUnit::Map100thMM));
1147 }
1148
1149 Size aMaxSize( mrDoc.GetMaxObjSize() );
1150
1151 maDropPos.AdjustX( -(std::min( aSize.Width(), aMaxSize.Width() ) >> 1) );
1152 maDropPos.AdjustY( -(std::min( aSize.Height(), aMaxSize.Height() ) >> 1) );
1153
1154 ::tools::Rectangle aRect( maDropPos, aSize );
1155 SdrOle2Obj* pObj = new SdrOle2Obj(
1156 getSdrModelFromSdrView(),
1157 aObjRef,
1158 aName,
1159 aRect);
1160 SdrPageView* pPV = GetSdrPageView();
1161 SdrInsertFlags nOptions = SdrInsertFlags::SETDEFLAYER;
1162
1163 if (mpViewSh!=nullptr)
1164 {
1165 OSL_ASSERT (mpViewSh->GetViewShell()!=nullptr)do { if (true && (!(mpViewSh->GetViewShell()!=nullptr
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/sdview3.cxx"
":" "1165" ": "), "OSL_ASSERT: %s", "mpViewSh->GetViewShell()!=nullptr"
); } } while (false)
;
1166 SfxInPlaceClient* pIpClient
1167 = mpViewSh->GetViewShell()->GetIPClient();
1168 if (pIpClient!=nullptr && pIpClient->IsObjectInPlaceActive())
1169 nOptions |= SdrInsertFlags::DONTMARK;
1170 }
1171
1172 bReturn = InsertObjectAtView( pObj, *pPV, nOptions );
1173
1174 if (bReturn)
1175 {
1176 if( pImageMap )
1177 pObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( *pImageMap )) );
1178
1179 // let the object stay in loaded state after insertion
1180 pObj->Unload();
1181 }
1182 }
1183 }
1184 }
1185
1186 if( !bReturn && aDataHelper.HasFormat( SotClipboardFormatId::GDIMETAFILE ) )
1187 {
1188 // if no object was inserted, insert a picture
1189 InsertMetaFile( aDataHelper, rPos, pImageMap.get(), true );
1190 bReturn = true;
1191 }
1192 }
1193
1194 if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(SotClipboardFormatId::SVXB)( ( nFormat == (SotClipboardFormatId::SVXB) || nFormat == SotClipboardFormatId
::NONE ) && aDataHelper.HasFormat( SotClipboardFormatId
::SVXB ) )
)
1195 {
1196 ::tools::SvRef<SotStorageStream> xStm;
1197
1198 if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB, xStm ) )
1199 {
1200 Point aInsertPos( rPos );
1201 Graphic aGraphic;
1202
1203 ReadGraphic( *xStm, aGraphic );
1204
1205 if( pOwnData && pOwnData->GetWorkDocument() )
1206 {
1207 const SdDrawDocument* pWorkModel = pOwnData->GetWorkDocument();
1208 SdrPage* pWorkPage = const_cast<SdrPage*>( ( pWorkModel->GetPageCount() > 1 ) ?
1209 pWorkModel->GetSdPage( 0, PageKind::Standard ) :
1210 pWorkModel->GetPage( 0 ) );
1211
1212 pWorkPage->SetSdrObjListRectsDirty();
1213
1214 // #i120393# Clipboard data uses full object geometry range
1215 const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
1216
1217 aInsertPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ) );
1218 aInsertPos.setY( pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ) );
1219 }
1220
1221 // restrict movement to WorkArea
1222 Size aImageMapSize = OutputDevice::LogicToLogic(aGraphic.GetPrefSize(),
1223 aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM));
1224
1225 ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
1226
1227 InsertGraphic( aGraphic, mnAction, aInsertPos, nullptr, pImageMap.get() );
1228 bReturn = true;
1229 }
1230 }
1231
1232 if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(SotClipboardFormatId::GDIMETAFILE)( ( nFormat == (SotClipboardFormatId::GDIMETAFILE) || nFormat
== SotClipboardFormatId::NONE ) && aDataHelper.HasFormat
( SotClipboardFormatId::GDIMETAFILE ) )
)
1233 {
1234 Point aInsertPos( rPos );
1235
1236 if( pOwnData && pOwnData->GetWorkDocument() )
1237
1238 {
1239 const SdDrawDocument* pWorkModel = pOwnData->GetWorkDocument();
1240 SdrPage* pWorkPage = const_cast<SdrPage*>( ( pWorkModel->GetPageCount() > 1 ) ?
1241 pWorkModel->GetSdPage( 0, PageKind::Standard ) :
1242 pWorkModel->GetPage( 0 ) );
1243
1244 pWorkPage->SetSdrObjListRectsDirty();
1245
1246 // #i120393# Clipboard data uses full object geometry range
1247 const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
1248
1249 aInsertPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ) );
1250 aInsertPos.setY( pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ) );
1251 }
1252
1253 bReturn = InsertMetaFile( aDataHelper, aInsertPos, pImageMap.get(), nFormat == SotClipboardFormatId::NONE );
1254 }
1255
1256 if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(SotClipboardFormatId::BITMAP)( ( nFormat == (SotClipboardFormatId::BITMAP) || nFormat == SotClipboardFormatId
::NONE ) && aDataHelper.HasFormat( SotClipboardFormatId
::BITMAP ) )
)
1257 {
1258 BitmapEx aBmpEx;
1259
1260 // get basic Bitmap data
1261 aDataHelper.GetBitmapEx(SotClipboardFormatId::BITMAP, aBmpEx);
1262
1263 if(aBmpEx.IsEmpty())
1264 {
1265 // if this did not work, try to get graphic formats and convert these to bitmap
1266 Graphic aGraphic;
1267
1268 if(aDataHelper.GetGraphic(SotClipboardFormatId::GDIMETAFILE, aGraphic))
1269 {
1270 aBmpEx = aGraphic.GetBitmapEx();
1271 }
1272 else if(aDataHelper.GetGraphic(SotClipboardFormatId::SVXB, aGraphic))
1273 {
1274 aBmpEx = aGraphic.GetBitmapEx();
1275 }
1276 else if(aDataHelper.GetGraphic(SotClipboardFormatId::BITMAP, aGraphic))
1277 {
1278 aBmpEx = aGraphic.GetBitmapEx();
1279 }
1280 }
1281
1282 if(!aBmpEx.IsEmpty())
1283 {
1284 Point aInsertPos( rPos );
1285
1286 if( pOwnData && pOwnData->GetWorkDocument() )
1287 {
1288 const SdDrawDocument* pWorkModel = pOwnData->GetWorkDocument();
1289 SdrPage* pWorkPage = const_cast<SdrPage*>( ( pWorkModel->GetPageCount() > 1 ) ?
1290 pWorkModel->GetSdPage( 0, PageKind::Standard ) :
1291 pWorkModel->GetPage( 0 ) );
1292
1293 pWorkPage->SetSdrObjListRectsDirty();
1294
1295 // #i120393# Clipboard data uses full object geometry range
1296 const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
1297
1298 aInsertPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ) );
1299 aInsertPos.setY( pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ) );
1300 }
1301
1302 // restrict movement to WorkArea
1303 Size aImageMapSize(aBmpEx.GetPrefSize());
1304 ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
1305
1306 InsertGraphic( aBmpEx, mnAction, aInsertPos, nullptr, pImageMap.get() );
1307 bReturn = true;
1308 }
1309 }
1310
1311 if(!bReturn && pPickObj && CHECK_FORMAT_TRANS( SotClipboardFormatId::XFA )( ( nFormat == (SotClipboardFormatId::XFA) || nFormat == SotClipboardFormatId
::NONE ) && aDataHelper.HasFormat( SotClipboardFormatId
::XFA ) )
)
1312 {
1313 uno::Any const data(aDataHelper.GetAny(SotClipboardFormatId::XFA, ""));
1314 uno::Sequence<beans::NamedValue> props;
1315 if (data >>= props)
1316 {
1317 if( IsUndoEnabled() )
1318 {
1319 BegUndo( SdResId(STR_UNDO_DRAGDROPreinterpret_cast<char const *>("STR_UNDO_DRAGDROP" "\004"
u8"Drag and Drop")
) );
1320 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
1321 EndUndo();
1322 }
1323
1324 ::comphelper::SequenceAsHashMap const map(props);
1325 drawing::FillStyle eFill(drawing::FillStyle_BITMAP); // default to something that's ignored
1326 Color aColor(COL_BLACK);
1327 auto it = map.find("FillStyle");
1328 if (it != map.end())
1329 {
1330 XFillStyleItem style;
1331 style.PutValue(it->second, 0);
1332 eFill = style.GetValue();
1333 }
1334 it = map.find("FillColor");
1335 if (it != map.end())
1336 {
1337 XFillColorItem color;
1338 color.PutValue(it->second, 0);
1339 aColor = color.GetColorValue();
1340 }
1341
1342 if( eFill == drawing::FillStyle_SOLID || eFill == drawing::FillStyle_NONE )
1343 {
1344 SfxItemSet aSet( mrDoc.GetPool() );
1345 bool bClosed = pPickObj->IsClosedObj();
1346 ::sd::Window* pWin = mpViewSh->GetActiveWindow();
1347 sal_uInt16 nHitLog = static_cast<sal_uInt16>(pWin->PixelToLogic(
1348 Size(FuPoor::HITPIX, 0 ) ).Width());
1349 const long n2HitLog = nHitLog << 1;
1350 Point aHitPosR( rPos );
1351 Point aHitPosL( rPos );
1352 Point aHitPosT( rPos );
1353 Point aHitPosB( rPos );
1354 const SdrLayerIDSet* pVisiLayer = &GetSdrPageView()->GetVisibleLayers();
1355
1356 aHitPosR.AdjustX(n2HitLog );
1357 aHitPosL.AdjustX( -n2HitLog );
1358 aHitPosT.AdjustY(n2HitLog );
1359 aHitPosB.AdjustY( -n2HitLog );
1360
1361 if( bClosed &&
1362 SdrObjectPrimitiveHit(*pPickObj, aHitPosR, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
1363 SdrObjectPrimitiveHit(*pPickObj, aHitPosL, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
1364 SdrObjectPrimitiveHit(*pPickObj, aHitPosT, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
1365 SdrObjectPrimitiveHit(*pPickObj, aHitPosB, nHitLog, *GetSdrPageView(), pVisiLayer, false) )
1366 {
1367 // area fill
1368 if(eFill == drawing::FillStyle_SOLID )
1369 aSet.Put(XFillColorItem("", aColor));
1370
1371 aSet.Put( XFillStyleItem( eFill ) );
1372 }
1373 else
1374 aSet.Put( XLineColorItem( "", aColor ) );
1375
1376 // add text color
1377 pPickObj->SetMergedItemSetAndBroadcast( aSet );
1378 }
1379 bReturn = true;
1380 }
1381 }
1382
1383 if(!bReturn && !bLink && CHECK_FORMAT_TRANS(SotClipboardFormatId::HTML)( ( nFormat == (SotClipboardFormatId::HTML) || nFormat == SotClipboardFormatId
::NONE ) && aDataHelper.HasFormat( SotClipboardFormatId
::HTML ) )
)
1384 {
1385 ::tools::SvRef<SotStorageStream> xStm;
1386
1387 if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::HTML, xStm ) )
1388 {
1389 xStm->Seek( 0 );
1390 // mba: clipboard always must contain absolute URLs (could be from alien source)
1391 bReturn = SdrView::Paste( *xStm, EETextFormat::Html, maDropPos, pPage, nPasteOptions );
1392 }
1393 }
1394
1395 if(!bReturn && !bLink && CHECK_FORMAT_TRANS(SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT)( ( nFormat == (SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT
) || nFormat == SotClipboardFormatId::NONE ) && aDataHelper
.HasFormat( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT ) )
)
1396 {
1397 ::tools::SvRef<SotStorageStream> xStm;
1398 if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT, xStm ) )
1399 {
1400 OutlinerView* pOLV = GetTextEditOutlinerView();
1401
1402 xStm->Seek( 0 );
1403
1404 if( pOLV )
1405 {
1406 ::tools::Rectangle aRect( pOLV->GetOutputArea() );
1407 Point aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
1408
1409 if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
1410 {
1411 // mba: clipboard always must contain absolute URLs (could be from alien source)
1412 pOLV->Read( *xStm, EETextFormat::Xml, mpDocSh->GetHeaderAttributes() );
1413 bReturn = true;
1414 }
1415 }
1416
1417 if( !bReturn )
1418 // mba: clipboard always must contain absolute URLs (could be from alien source)
1419 bReturn = SdrView::Paste( *xStm, EETextFormat::Xml, maDropPos, pPage, nPasteOptions );
1420 }
1421 }
1422
1423 if(!bReturn && !bLink)
1424 {
1425 bool bIsRTF = CHECK_FORMAT_TRANS(SotClipboardFormatId::RTF)( ( nFormat == (SotClipboardFormatId::RTF) || nFormat == SotClipboardFormatId
::NONE ) && aDataHelper.HasFormat( SotClipboardFormatId
::RTF ) )
;
1426 if (bIsRTF || CHECK_FORMAT_TRANS(SotClipboardFormatId::RICHTEXT)( ( nFormat == (SotClipboardFormatId::RICHTEXT) || nFormat ==
SotClipboardFormatId::NONE ) && aDataHelper.HasFormat
( SotClipboardFormatId::RICHTEXT ) )
)
1427 {
1428 ::tools::SvRef<SotStorageStream> xStm;
1429
1430 if( aDataHelper.GetSotStorageStream( bIsRTF ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT, xStm ) )
1431 {
1432 xStm->Seek( 0 );
1433
1434 if( bTable )
1435 {
1436 bReturn = PasteRTFTable( xStm, pPage, nPasteOptions );
1437 }
1438 else
1439 {
1440 OutlinerView* pOLV = GetTextEditOutlinerView();
1441
1442 if( pOLV )
1443 {
1444 ::tools::Rectangle aRect( pOLV->GetOutputArea() );
1445 Point aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
1446
1447 if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
1448 {
1449 // mba: clipboard always must contain absolute URLs (could be from alien source)
1450 pOLV->Read( *xStm, EETextFormat::Rtf, mpDocSh->GetHeaderAttributes() );
1451 bReturn = true;
1452 }
1453 }
1454
1455 if( !bReturn )
1456 // mba: clipboard always must contain absolute URLs (could be from alien source)
1457 bReturn = SdrView::Paste( *xStm, EETextFormat::Rtf, maDropPos, pPage, nPasteOptions );
1458 }
1459 }
1460 }
1461 }
1462
1463 if(!bReturn && CHECK_FORMAT_TRANS(SotClipboardFormatId::FILE_LIST)( ( nFormat == (SotClipboardFormatId::FILE_LIST) || nFormat ==
SotClipboardFormatId::NONE ) && aDataHelper.HasFormat
( SotClipboardFormatId::FILE_LIST ) )
)
1464 {
1465 FileList aDropFileList;
1466
1467 if( aDataHelper.GetFileList( SotClipboardFormatId::FILE_LIST, aDropFileList ) )
1468 {
1469 maDropFileVector.clear();
1470
1471 for( sal_uLong i = 0, nCount = aDropFileList.Count(); i < nCount; i++ )
1472 maDropFileVector.push_back( aDropFileList.GetFile( i ) );
1473
1474 maDropInsertFileIdle.Start();
1475 }
1476
1477 bReturn = true;
1478 }
1479
1480 if(!bReturn && CHECK_FORMAT_TRANS(SotClipboardFormatId::SIMPLE_FILE)( ( nFormat == (SotClipboardFormatId::SIMPLE_FILE) || nFormat
== SotClipboardFormatId::NONE ) && aDataHelper.HasFormat
( SotClipboardFormatId::SIMPLE_FILE ) )
)
1481 {
1482 OUString aDropFile;
1483
1484 if( aDataHelper.GetString( SotClipboardFormatId::SIMPLE_FILE, aDropFile ) )
1485 {
1486 maDropFileVector.clear();
1487 maDropFileVector.push_back( aDropFile );
1488 maDropInsertFileIdle.Start();
1489 }
1490
1491 bReturn = true;
1492 }
1493
1494 if(!bReturn && !bLink && CHECK_FORMAT_TRANS(SotClipboardFormatId::STRING)( ( nFormat == (SotClipboardFormatId::STRING) || nFormat == SotClipboardFormatId
::NONE ) && aDataHelper.HasFormat( SotClipboardFormatId
::STRING ) )
)
1495 {
1496 if( ( SotClipboardFormatId::STRING == nFormat ) ||
1497 ( !aDataHelper.HasFormat( SotClipboardFormatId::SOLK ) &&
1498 !aDataHelper.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) &&
1499 !aDataHelper.HasFormat( SotClipboardFormatId::FILENAME ) ) )
1500 {
1501 OUString aOUString;
1502
1503 if( aDataHelper.GetString( SotClipboardFormatId::STRING, aOUString ) )
1504 {
1505 OutlinerView* pOLV = GetTextEditOutlinerView();
1506
1507 if( pOLV )
1508 {
1509 pOLV->InsertText( aOUString );
1510 bReturn = true;
1511 }
1512
1513 if( !bReturn )
1514 bReturn = SdrView::Paste( aOUString, maDropPos, pPage, nPasteOptions );
1515 }
1516 }
1517 }
1518
1519 MarkListHasChanged();
1520 mbIsDropAllowed = true;
1521 rDnDAction = mnAction;
1522
1523 return bReturn;
1524}
1525
1526bool View::PasteRTFTable( const ::tools::SvRef<SotStorageStream>& xStm, SdrPage* pPage, SdrInsertFlags nPasteOptions )
1527{
1528 std::unique_ptr<SdDrawDocument> pModel(new SdDrawDocument( DocumentType::Impress, mpDocSh ));
1529 pModel->NewOrLoadCompleted(DocCreationMode::New);
1530 pModel->GetItemPool().SetDefaultMetric(MapUnit::Map100thMM);
1531 pModel->InsertPage(pModel->AllocPage(false));
1532
1533 Reference< XComponent > xComponent( new SdXImpressDocument( pModel.get(), true ) );
1534 pModel->setUnoModel( Reference< XInterface >::query( xComponent ) );
1535
1536 CreateTableFromRTF( *xStm, pModel.get() );
1537 bool bRet = Paste(*pModel, maDropPos, pPage, nPasteOptions);
1538
1539 xComponent->dispose();
1540 xComponent.clear();
1541
1542 return bRet;
1543}
1544
1545} // end of namespace sd
1546
1547/* vim:set shiftwidth=4 softtabstop=4 expandtab: */