1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
|
/*************************************************************************
*
* $RCSfile: viewfun7.cxx,v $
*
* $Revision: 1.3 $
*
* last change: $Author: ka $ $Date: 2000-11-08 16:18:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifdef PCH
#include "ui_pch.hxx"
#endif
#pragma hdrstop
//------------------------------------------------------------------
#define _SV_NOXSOUND
#ifdef WIN
#define _MENUBTN_HXX
#endif
#define _BASE_DLGS_HXX
#define _BIGINT_HXX
#define _CACHESTR_HXX
#define _CONFIG_HXX
#define _CURSOR_HXX
#define _CTRLTOOL_HXX
#define _DLGCFG_HXX
#define _DYNARR_HXX
#define _EXTATTR_HXX
#define _FILDLG_HXX
#define _FONTDLG_HXX
#define _FRM3D_HXX
#define _INTRO_HXX
#define _ISETBWR_HXX
#define _NO_SVRTF_PARSER_HXX
#define _MACRODLG_HXX
#define _MODALDLG_HXX
#define _MOREBUTTON_HXX
#define _OUTLINER_HXX
//#define _PRNDLG_HXX
//#define _POLY_HXX
#define _PVRWIN_HXX
#define _QUEUE_HXX
#define _RULER_HXX
#define _SCRWIN_HXX
#define _SETBRW_HXX
#define _STACK_HXX
//#define _STATUS_HXX
#define _STDCTRL_HXX
#define _STDMENU_HXX
//#define _TAB_HXX
#define _TABBAR_HXX
#define _TREELIST_HXX
#define _VALUESET_HXX
#define _VCATTR_HXX
#define _VCBRW_HXX
#define _VCTRLS_HXX
//#define _VCSBX_HXX
#define _VCONT_HXX
#define _VDRWOBJ_HXX
//SV
//#define _CLIP_HXX ***
#define _CONFIG_HXX
#define _CURSOR_HXX
#define _FONTDLG_HXX
#define _PRVWIN_HXX
//#define _COLOR_HXX
//#define _PAL_HXX
//#define _BITMAP_HXX
//#define _GDIOBJ_HXX
//#define _POINTR_HXX
//#define _ICON_HXX
//#define _IMAGE_HXX
//#define _KEYCOD_HXX
//#define _EVENT_HXX
#define _HELP_HXX
//#define _APP_HXX
//#define _MDIAPP_HXX
//#define _TIMER_HXX
//#define _METRIC_HXX
//#define _REGION_HXX
//#define _OUTDEV_HXX
//#define _SYSTEM_HXX
//#define _VIRDEV_HXX
//#define _JOBSET_HXX
//#define _PRINT_HXX
//#define _WINDOW_HXX
//#define _SYSWIN_HXX
//#define _WRKWIN_HXX
#define _MDIWIN_HXX
//#define _FLOATWIN_HXX
//#define _DOCKWIN_HXX
//#define _CTRL_HXX
//#define _SCRBAR_HXX
//#define _BUTTON_HXX
//#define _IMAGEBTN_HXX
//#define _FIXED_HXX
//#define _GROUP_HXX
//#define _EDIT_HXX
//#define _COMBOBOX_HXX
//#define _LSTBOX_HXX
//#define _SELENG_HXX ***
//#define _SPLIT_HXX
#define _SPIN_HXX
//#define _FIELD_HXX
//#define _MOREBTN_HXX ***
//#define _TOOLBOX_HXX
//#define _STATUS_HXX ***
//#define _DIALOG_HXX
//#define _MSGBOX_HXX
//#define _SYSDLG_HXX
#define _FILDLG_HXX
//#define _PRNDLG_HXX
#define _COLDLG_HXX
//#define _TABDLG_HXX
#ifdef WIN
#define _MENU_HXX
#endif
//#define _GDIMTF_HXX
//#define _POLY_HXX
//#define _ACCEL_HXX
//#define _GRAPH_HXX
#define _SOUND_HXX
#define _PASSWD_HXX
#define _SFX_DOCFILE_HXX
#define _SFX_DOCFILT_HXX
#define _SFX_DOCSH_HXX
#define _SFXDOCFILE_HXX
#define _SFXDOCFILT_HXX
//#define _SFXDOCINF_HXX
//#define _SFXDOCSH_HXX
#define _SFX_PRNMON_HXX
#define _SFX_RESMGR_HXX
#define _SFX_TEMPLDLG_HXX
//#define _SFXAPPWIN_HXX
#define _SFXBASIC_HXX
#define _SFXCTRLITEM
#define _SFXDLGCFG_HXX
#define _SFXDISPATCH_HXX
#define _SFXFILEDLG_HXX
//#define _SFXIMGMGR_HXX
#define _SFXIPFRM_HXX
#define _SFX_MACRO_HXX
#define _SFXMNUITEM_HXX
#define _SFXMNUMGR_HXX
#define _SFXMULTISEL_HXX
//#define _SFXMSG_HXX
#define _SFXMSGDESCR_HXX
#define _SFXMSGPOOL_HXX
#define _SFX_MINFITEM_HXX
#define _SFXOBJFACE_HXX
#define _SFXOBJFAC_HXX
#define _SFX_SAVEOPT_HXX
#define _SFXSTBITEM_HXX
#define _SFXSTBMGR_HXX
#define _SFXTBXCTRL_HXX
#define _SFXTBXMGR_HXX
//sfxdoc.hxx
//#define _SFX_OBJSH_HXX
//#define _SFX_CLIENTSH_HXX
//#define _SFXDOCINF_HXX
//#define _SFX_OBJFAC_HXX
#define _SFX_DOCFILT_HXX
//#define _SFXDOCFILE_HXX ***
//define _VIEWFAC_HXX
//#define _SFXVIEWFRM_HXX ***
//#define _SFXVIEWSH_HXX ***
//#define _MDIFRM_HXX ***
#define _SFX_IPFRM_HXX
//#define _SFX_INTERNO_HXX
//sfxdlg.hxx
//#define _SFXTABDLG_HXX ***
//#define _BASEDLGS_HXX ***
#define _SFX_DINFDLG_HXX
#define _SFXDINFEDT_HXX
#define _SFX_MGETEMPL_HXX
#define _SFX_TPLPITEM_HXX
#define _SFX_STYLEDLG_HXX
#define _NEWSTYLE_HXX
//#define _SFXDOCTEMPL_HXX ***
//#define _SFXDOCTDLG_HXX ***
//#define _SFX_TEMPLDLG_HXX ***
//#define _SFXNEW_HXX ***
#define _SFXDOCMAN_HXX
//#define _SFXDOCKWIN_HXX
//sfxitems.hxx
#define _SFX_WHMAP_HXX
#define _ARGS_HXX
//#define _SFXPOOLITEM_HXX
//#define _SFXINTITEM_HXX
//#define _SFXENUMITEM_HXX
#define _SFXFLAGITEM_HXX
//#define _SFXSTRITEM_HXX ***
#define _SFXPTITEM_HXX
#define _SFXRECTITEM_HXX
//#define _SFXITEMPOOL_HXX ***
//#define _SFXITEMSET_HXX ***
#define _SFXITEMITER_HXX
#define _SFX_WHITER_HXX
#define _SFXPOOLCACH_HXX
#define _AEITEM_HXX
#define _SFXRNGITEM_HXX
#define _SFXSLSTITM_HXX
#define _SFXSTYLE_HXX
//xout.hxx
//#define _XENUM_HXX ***
//#define _XPOLY_HXX ***
//#define _XATTR_HXX ***
#define _XOUTX_HXX
//#define _XPOOL_HXX ***
#define _XTABLE_HXX
//svdraw.hxx
//#define _SVDRAW_HXX
#define _SDR_NOITEMS
#define _SDR_NOTOUCH
#define _SDR_NOTRANSFORM
#define _SDR_NOVIEWMARKER
#define _SDR_NODRAGMETHODS
//#define _SDR_NOUNDO ***
#define _SDR_NOXOUTDEV
//#define _SDR_NOOBJECTS ***
//#define _SDR_NOVIEWS ***
//inet
#define _INETINDP_HXX
#define _INETIMP_HXX
#define _INETWRAP_HXX
#define _INETKEEP_HXX
#define _PLUGMGR_HXX
#define _URLOBJ_HXX //*
#define SFX_NOCLOOKS
#define _SI_DLL_HXX
#define _SIDLL_HXX
#define _SI_NOITEMS
#define _SI_NOOTHERFORMS
#define _SI_NOSBXCONTROLS
#define _SINOSBXCONTROLS
#define _SI_NODRW
#define _SI_NOCONTROL
#define _SVBOXITM_HXX
#define _SVCONTNR_HXX
//#define _SVDATTR_HXX ***
#define _SVDEC_HXX
#define _SVDIO_HXX
#define _SVDRAG_HXX
#define _SVINCVW_HXX
#define _SV_MULTISEL_HXX
#define _SVRTV_HXX
#define _SVTABBX_HXX
#define _SVTREEBOX_HXX
#define _SVTREELIST_HXX
#define _SVX_DAILDLL_HXX
#define _SVX_HYPHEN_HXX
#define _SVX_IMPGRF_HXX
#define _SVX_LAYCTRL_HXX
#define _SVX_OPTITEMS_HXX
#define _SVX_OPTGERL_HXX
#define _SVX_OPTSAVE_HXX
#define _SVX_OPTSPELL_HXX
#define _SVX_OPTPATH_HXX
#define _SVX_OPTLINGU_HXX
#define _SVX_RULER_HXX
#define _SVX_RULRITEM_HXX
#define _SVX_SELCTRL_HXX
#define _SVX_SPLWRAP_HXX
#define _SVX_SPLDLG_HXX
#define _SVX_STDDLG_HXX
#define _SVX_THESDLG_HXX
#define SI_NOITEMS
//#define SI_NODRW
#define _SI_NOSBXCONTROLS
#define _VCATTR_HXX
#define _VCONT_HXX
//#define _VCSBX_HXX
#define _SI_NOOTHERFORMS
#define _VCTRLS_HXX
//#define _VCDRWOBJ_HXX
#define _SI_NOCONTROL
#define _SETBRW_HXX
#define _VCBRW_HXX
#define _SI_NOSBXCONTROLS
#define _SIDLL_HXX
//#define _SI_HXX
#define _SDR_NOTRANSFORM
#define _SDR_NOTOUCH
#define _SVDOPAGE_HXX // SdrPageObj
#define _SVDSURO_HXX // SdrObjSurrogate
#define _SVDOVIRT_HXX // SdrVirtObj
#define _SVDOGRP_HXX // SdrGroupObj
//#define _SVDOTEXT_HXX // SdrTextObj
#define _SVDOPATH_HXX // SdrPathObj
//#define _SVDOEDGE_HXX // SdrEdgeObj
//#define _SVDORECT_HXX // SdrRectObj (+SdrTextObj)
#define _SVDCAPT_HXX // SdrCaptionObj
#define _SVDOCIRC_HXX // SdrCircleObj
//#define _SVDOGRAF_HXX // SdrGrafObj (+SdrRectObj)
//#define _SVDOOLE2_HXX // SdrOle2Obj (+SdrRectObj)
// INCLUDE ---------------------------------------------------------------
#include <so3/ipobj.hxx>
#include <svx/svditer.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdouno.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdpagv.hxx>
#include <svx/svdundo.hxx>
#include <svx/xbitmap.hxx>
#include <svx/xbtmpit.hxx>
#include <svx/xoutbmp.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/viewfrm.hxx>
#include "document.hxx" // fuer MapMode Initialisierung in PasteDraw
#include "viewfunc.hxx"
#include "tabvwsh.hxx"
#include "drawview.hxx"
#include "scmod.hxx"
#include "drwlayer.hxx"
#include "globstr.hrc"
extern Point aDragStartDiff;
// STATIC DATA -----------------------------------------------------------
BOOL bPasteIsMove = FALSE;
//==================================================================
void lcl_AdjustInsertPos( ScViewData* pData, Point& rPos, Size& rSize )
{
// SdrPage* pPage = pData->GetDocument()->GetDrawLayer()->GetPage( pData->GetTabNo() );
SdrPage* pPage = pData->GetScDrawView()->GetModel()->GetPage( pData->GetTabNo() );
DBG_ASSERT(pPage,"pPage ???");
Size aPgSize( pPage->GetSize() );
long x = aPgSize.Width() - rPos.X() - rSize.Width();
long y = aPgSize.Height() - rPos.Y() - rSize.Height();
// ggf. Ajustments (80/200) fuer Pixel-Rundungsfehler
if( x < 0 )
rPos.X() += x + 80;
if( y < 0 )
rPos.Y() += y + 200;
rPos.X() += rSize.Width() / 2; // Position bei Paste gibt Mittelpunkt an
rPos.Y() += rSize.Height() / 2;
}
void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, BOOL bGroup )
{
MakeDrawLayer();
Point aPos( rLogicPos );
// #64184# MapMode am Outliner-RefDevice muss stimmen (wie in FuText::MakeOutliner)
//! mit FuText::MakeOutliner zusammenfassen?
MapMode aOldMapMode;
OutputDevice* pRef = GetViewData()->GetDocument()->GetDrawLayer()->GetRefDevice();
if (pRef)
{
aOldMapMode = pRef->GetMapMode();
pRef->SetMapMode( MapMode(MAP_100TH_MM) );
}
SdrView* pDragEditView = SC_MOD()->GetDragData().pSdrView;
if (pDragEditView)
{
aPos -= aDragStartDiff;
if (aPos.X() < 0) aPos.X() = 0;
if (aPos.Y() < 0) aPos.Y() = 0;
}
ScDrawView* pDrawView = GetScDrawView();
if (bGroup)
pDrawView->BegUndo( ScGlobal::GetRscString( STR_UNDO_PASTE ) );
BOOL bSameDoc = ( pDragEditView && pDragEditView->GetModel() == pDrawView->GetModel() );
if (bSameDoc)
{
// lokal kopieren - incl. Charts
Point aSourceStart = pDragEditView->GetAllMarkedRect().TopLeft();
long nDiffX = aPos.X() - aSourceStart.X();
long nDiffY = aPos.Y() - aSourceStart.Y();
// innerhalb einer Page verschieben?
if ( bPasteIsMove &&
pDrawView->GetPageViewPvNum(0)->GetPage() ==
pDragEditView->GetPageViewPvNum(0)->GetPage() )
{
pDragEditView->MoveAllMarked(Size(nDiffX,nDiffY), FALSE);
}
else
{
SdrModel* pModel = pDragEditView->GetModel();
SdrPage* pDestPage = pModel->GetPage( GetViewData()->GetTabNo() );
DBG_ASSERT(pDestPage,"nanu, Page?");
SdrMarkList aMark = pDragEditView->GetMarkList();
aMark.ForceSort();
ULONG nMarkAnz=aMark.GetMarkCount();
for (ULONG nm=0; nm<nMarkAnz; nm++) {
const SdrMark* pM=aMark.GetMark(nm);
const SdrObject* pObj=pM->GetObj();
SdrObject* pNeuObj=pObj->Clone(pDestPage,pModel);
if (pNeuObj!=NULL)
{
// #68787# copy graphics within the same model - always needs new name
if ( pNeuObj->ISA(SdrGrafObj) && !bPasteIsMove )
pNeuObj->SetName(((ScDrawLayer*)pModel)->GetNewGraphicName());
if (nDiffX!=0 || nDiffY!=0)
pNeuObj->NbcMove(Size(nDiffX,nDiffY));
pDestPage->InsertObject( pNeuObj );
pDrawView->AddUndo(new SdrUndoInsertObj( *pNeuObj ));
// Chart braucht nicht mehr getrennt behandelt zu werden,
// weil es seine Daten jetzt selber hat
}
}
if (bPasteIsMove)
pDragEditView->DeleteMarked();
}
}
else
{
bPasteIsMove = FALSE; // kein internes Verschieben passiert
SdrMarkView aView(pModel);
SdrPageView* pPv = aView.ShowPagePgNum(0,Point());
aView.MarkAll(pPv);
Size aSize = aView.GetAllMarkedRect().GetSize();
lcl_AdjustInsertPos( GetViewData(), aPos, aSize );
// #41333# Markierung nicht aendern, wenn Ole-Objekt aktiv
// (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!)
ULONG nOptions = 0;
SfxInPlaceClient* pClient = GetViewData()->GetViewShell()->GetIPClient();
if ( pClient && pClient->IsInPlaceActive() )
nOptions |= SDRINSERT_DONTMARK;
pDrawView->Paste( *pModel, aPos, NULL, nOptions );
// #68991# Paste puts all objects on the active (front) layer
// controls must be on SC_LAYER_CONTROLS
USHORT nTab = GetViewData()->GetTabNo();
SdrPage* pPage = pDrawView->GetModel()->GetPage(nTab);
DBG_ASSERT(pPage,"Page?");
if (pPage)
{
SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
SdrObject* pObject = aIter.Next();
while (pObject)
{
if ( pObject->ISA(SdrUnoObj) && pObject->GetLayer() != SC_LAYER_CONTROLS )
pObject->NbcSetLayer(SC_LAYER_CONTROLS);
pObject = aIter.Next();
}
}
// #75299# all graphics objects must have names
GetViewData()->GetDocument()->EnsureGraphicNames();
}
if (bGroup)
{
pDrawView->GroupMarked();
pDrawView->EndUndo();
}
if (pRef)
pRef->SetMapMode( aOldMapMode );
GetViewData()->GetViewShell()->SetDrawShell( TRUE );
}
BOOL ScViewFunc::PasteObject( const Point& rPos, SvInPlaceObject* pObj,
SvDataObject* pDataObject )
{
MakeDrawLayer();
if ( pObj )
{
SvEmbeddedInfoObject* pInfoObj = GetViewData()->GetViewShell()->
GetViewFrame()->GetObjectShell()->
InsertObject(pObj, String());
String aName = pInfoObj->GetObjName();
MapMode aMap100( MAP_100TH_MM );
MapMode aMapObj( pObj->GetMapUnit() );
Size aSize;
if (pDataObject) // Size aus DataObject in IPObject uebernehmen
{
SvObjectDescriptor aDesc(pDataObject);
Size aDescSize = aDesc.GetSize();
if( aDescSize.Width() && aDescSize.Height() )
pObj->SetVisAreaSize(OutputDevice::LogicToLogic( aDescSize, aMap100, aMapObj ));
}
aSize = pObj->GetVisArea().GetSize();
aSize = OutputDevice::LogicToLogic( aSize, aMapObj, aMap100 ); // fuer SdrOle2Obj
if( aSize.Height() == 0 || aSize.Width() == 0 )
{
DBG_ERROR("SvObjectDescriptor::GetSize == 0");
aSize.Width() = 5000;
aSize.Height() = 5000;
aSize = OutputDevice::LogicToLogic( aSize, aMap100, aMapObj );
pObj->SetVisAreaSize(aSize);
}
// kein AdjustInsertPos
Rectangle aRect( rPos, aSize );
ScDrawView* pDrView = GetScDrawView();
SdrOle2Obj* pSdrObj = new SdrOle2Obj( pObj, aName, aRect );
SdrPageView* pPV = pDrView->GetPageViewPvNum(0);
pDrView->InsertObjectSafe( pSdrObj, *pPV ); // nicht markieren wenn Ole
pSdrObj->SetOleLink(pInfoObj);
GetViewData()->GetViewShell()->SetDrawShell( TRUE );
return TRUE;
}
else
return FALSE;
}
BOOL ScViewFunc::PasteBitmap( const Point& rPos, const Bitmap& rBmp )
{
String aEmpty;
Graphic aGraphic(rBmp);
return PasteGraphic( rPos, aGraphic, aEmpty, aEmpty );
}
BOOL ScViewFunc::PasteMetaFile( const Point& rPos, const GDIMetaFile& rMtf )
{
String aEmpty;
Graphic aGraphic(rMtf);
return PasteGraphic( rPos, aGraphic, aEmpty, aEmpty );
}
BOOL ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic,
const String& rFile, const String& rFilter )
{
MakeDrawLayer();
ScDrawView* pDrawView = GetScDrawView();
Point aPos( rPos );
Window* pWin = GetActiveWin();
MapMode aSourceMap = rGraphic.GetPrefMapMode();
MapMode aDestMap( MAP_100TH_MM );
if (aSourceMap.GetMapUnit() == MAP_PIXEL)
{
// Pixel-Korrektur beruecksichtigen, damit Bitmap auf dem Bildschirm stimmt
Fraction aScaleX, aScaleY;
pDrawView->CalcNormScale( aScaleX, aScaleY );
aDestMap.SetScaleX(aScaleX);
aDestMap.SetScaleY(aScaleY);
}
Size aSize = pWin->LogicToLogic( rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
// lcl_AdjustInsertPos( GetViewData(), aPos, aSize );
GetViewData()->GetViewShell()->SetDrawShell( TRUE );
Rectangle aRect(aPos, aSize);
SdrGrafObj* pGrafObj = new SdrGrafObj(rGraphic, aRect);
if (rFile.Len())
pGrafObj->SetGraphicLink( rFile, rFilter );
// #49961# Pfad wird nicht mehr als Name der Grafik gesetzt
ScDrawLayer* pLayer = (ScDrawLayer*) pDrawView->GetModel();
String aName = pLayer->GetNewGraphicName(); // "Grafik x"
pGrafObj->SetName(aName);
// nicht markieren wenn Ole
pDrawView->InsertObjectSafe(pGrafObj, *pDrawView->GetPageViewPvNum(0));
return TRUE;
}
BOOL ScViewFunc::ApplyGraphicToObject( SdrObject* pPickObj, const Graphic& rGraphic )
{
BOOL bRet = FALSE;
SdrGrafObj* pNewGrafObj = NULL;
ScDrawView* pDrawView = GetScDrawView();
if ( pDrawView && pPickObj )
{
/**********************************************************************
* Objekt neu attributieren
**********************************************************************/
SdrPageView* pPV = pDrawView->GetPageViewPvNum(0);
if (pPickObj->ISA(SdrGrafObj))
{
/******************************************************************
* Das Graphik-Objekt bekommt eine neue Graphik
******************************************************************/
pNewGrafObj = (SdrGrafObj*) pPickObj->Clone();
pNewGrafObj->SetGraphic(rGraphic);
pDrawView->BegUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP));
pDrawView->ReplaceObject(pPickObj, *pPV, pNewGrafObj);
pDrawView->EndUndo();
bRet = TRUE;
}
else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj))
{
/******************************************************************
* Das Objekt wird mit der Graphik gefuellt
******************************************************************/
//pDrawView->BegUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP));
pDrawView->AddUndo(new SdrUndoAttrObj(*pPickObj));
//pDrawView->EndUndo();
XOBitmap aXOBitmap( rGraphic.GetBitmap() );
SfxItemSet aSet( pDrawView->GetModel()->GetItemPool(),
XATTR_FILLSTYLE, XATTR_FILLBITMAP );
aSet.Put(XFillStyleItem(XFILL_BITMAP));
aSet.Put(XFillBitmapItem(String(), aXOBitmap));
//-/ pPickObj->SetAttributes(aSet, FALSE);
pPickObj->SetItemSetAndBroadcast(aSet);
bRet = TRUE;
}
}
return bRet;
}
|