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
|
/*************************************************************************
*
* $RCSfile: tabvwsh2.cxx,v $
*
* $Revision: 1.12 $
*
* last change: $Author: nn $ $Date: 2002-12-11 14:13:00 $
*
* 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
// INCLUDE ---------------------------------------------------------------
#ifdef WNT
#pragma optimize ("", off)
#endif
#include <sfx2/bindings.hxx>
#include <sfx2/ipfrm.hxx>
#include <svtools/aeitem.hxx>
#include <svtools/whiter.hxx>
#include <svtools/moduleoptions.hxx>
#include <sfx2/dispatch.hxx>
#include "tabvwsh.hxx"
#include "drawattr.hxx"
#include "drawsh.hxx"
#include "drawview.hxx"
#include "fupoor.hxx"
#include "fuconrec.hxx"
#include "fuconpol.hxx"
#include "fuconarc.hxx"
#include "fuconuno.hxx"
#include "fusel.hxx"
#include "futext.hxx"
#include "fumark.hxx"
#include "global.hxx"
#include "sc.hrc"
#include "scmod.hxx"
#include "appoptio.hxx"
// #98185# Create default drawing objects via keyboard
#ifndef _SVDPAGV_HXX
#include <svx/svdpagv.hxx>
#endif
#ifndef _SVDPAGE_HXX
#include <svx/svdpage.hxx>
#endif
// -----------------------------------------------------------------------
SdrView* __EXPORT ScTabViewShell::GetDrawView() const
{
return ((ScTabViewShell*)this)->GetScDrawView(); // GetScDrawView ist nicht-const
}
void ScTabViewShell::WindowChanged()
{
Window* pWin = GetActiveWin();
ScDrawView* pDrView = GetScDrawView();
if (pDrView)
pDrView->SetActualWin(pWin);
FuPoor* pFunc = GetDrawFuncPtr();
if (pFunc)
pFunc->SetWindow(pWin);
// when font from InputContext is used,
// this must be moved to change of cursor position:
UpdateInputContext();
}
void ScTabViewShell::ExecDraw(SfxRequest& rReq)
{
SC_MOD()->InputEnterHandler();
UpdateInputHandler();
MakeDrawLayer();
ScTabView* pTabView = GetViewData()->GetView();
USHORT nTab = GetViewData()->GetTabNo();
SfxBindings& rBindings = GetViewFrame()->GetBindings();
Window* pWin = pTabView->GetActiveWin();
SdrView* pView = pTabView->GetSdrView();
SdrModel* pDoc = pView->GetModel();
const SfxItemSet *pArgs = rReq.GetArgs();
USHORT nNewId = rReq.GetSlot();
//
// Pseudo-Slots von Draw-Toolbox auswerten
//! wird das ueberhaupt noch gebraucht ?????
//
if (nNewId == SID_INSERT_DRAW && pArgs)
{
const SfxPoolItem* pItem;
if ( pArgs->GetItemState( SID_INSERT_DRAW, TRUE, &pItem ) == SFX_ITEM_SET &&
pItem->ISA( SvxDrawToolItem ) )
{
SvxDrawToolEnum eSel = (SvxDrawToolEnum)((const SvxDrawToolItem*)pItem)->GetValue();
switch (eSel)
{
case SVX_SNAP_DRAW_SELECT: nNewId = SID_OBJECT_SELECT; break;
case SVX_SNAP_DRAW_LINE: nNewId = SID_DRAW_LINE; break;
case SVX_SNAP_DRAW_RECT: nNewId = SID_DRAW_RECT; break;
case SVX_SNAP_DRAW_ELLIPSE: nNewId = SID_DRAW_ELLIPSE; break;
case SVX_SNAP_DRAW_POLYGON_NOFILL: nNewId = SID_DRAW_POLYGON_NOFILL; break;
case SVX_SNAP_DRAW_BEZIER_NOFILL: nNewId = SID_DRAW_BEZIER_NOFILL; break;
case SVX_SNAP_DRAW_FREELINE_NOFILL: nNewId = SID_DRAW_FREELINE_NOFILL; break;
case SVX_SNAP_DRAW_ARC: nNewId = SID_DRAW_ARC; break;
case SVX_SNAP_DRAW_PIE: nNewId = SID_DRAW_PIE; break;
case SVX_SNAP_DRAW_CIRCLECUT: nNewId = SID_DRAW_CIRCLECUT; break;
case SVX_SNAP_DRAW_TEXT: nNewId = SID_DRAW_TEXT; break;
case SVX_SNAP_DRAW_TEXT_VERTICAL: nNewId = SID_DRAW_TEXT_VERTICAL; break;
case SVX_SNAP_DRAW_TEXT_MARQUEE: nNewId = SID_DRAW_TEXT_MARQUEE; break;
case SVX_SNAP_DRAW_CAPTION: nNewId = SID_DRAW_CAPTION; break;
case SVX_SNAP_DRAW_CAPTION_VERTICAL: nNewId = SID_DRAW_CAPTION_VERTICAL; break;
}
}
else // USHORT-Item vom Controller
{
rReq.Done();
return;
}
}
if ( nNewId == SID_DRAW_SELECT )
nNewId = SID_OBJECT_SELECT;
USHORT nNewFormId = 0;
if ( nNewId == SID_FM_CREATE_CONTROL && pArgs )
{
const SfxPoolItem* pItem;
if ( pArgs->GetItemState( SID_FM_CONTROL_IDENTIFIER, TRUE, &pItem ) == SFX_ITEM_SET &&
pItem->ISA( SfxUInt16Item ) )
nNewFormId = ((const SfxUInt16Item*)pItem)->GetValue();
}
if (nNewId == SID_INSERT_FRAME) // vom Tbx-Button
nNewId = SID_DRAW_TEXT;
// #97016# CTRL-SID_OBJECT_SELECT is used to select the first object,
// but not if SID_OBJECT_SELECT is the result of clicking a create function again,
// so this must be tested before changing nNewId below.
BOOL bSelectFirst = ( nNewId == SID_OBJECT_SELECT && (rReq.GetModifier() & KEY_MOD1) );
BOOL bEx = IsDrawSelMode();
if ( rReq.GetModifier() & KEY_MOD1 )
{
// #97016# always allow keyboard selection also on background layer
// #98185# also allow creation of default objects if the same object type
// was already active
bEx = TRUE;
}
else if ( nNewId == nDrawSfxId && ( nNewId != SID_FM_CREATE_CONTROL ||
nNewFormId == nFormSfxId || nNewFormId == 0 ) )
{
// SID_FM_CREATE_CONTROL mit nNewFormId==0 (ohne Parameter) kommt beim Deaktivieren
// aus FuConstruct::SimpleMouseButtonUp
// #59280# Execute fuer die Form-Shell, um im Controller zu deselektieren
if ( nNewId == SID_FM_CREATE_CONTROL )
{
GetViewData()->GetDispatcher().Execute(SID_FM_LEAVE_CREATE);
GetViewFrame()->GetBindings().InvalidateAll(FALSE);
//! was fuer einen Slot braucht der komische Controller wirklich, um das anzuzeigen????
}
bEx = !bEx;
nNewId = SID_OBJECT_SELECT;
}
else
bEx = TRUE;
if ( nDrawSfxId == SID_FM_CREATE_CONTROL && nNewId != nDrawSfxId )
{
// Wechsel von Control- zu Zeichenfunktion -> im Control-Controller deselektieren
GetViewData()->GetDispatcher().Execute(SID_FM_LEAVE_CREATE);
GetViewFrame()->GetBindings().InvalidateAll(FALSE);
//! was fuer einen Slot braucht der komische Controller wirklich, um das anzuzeigen????
}
SetDrawSelMode(bEx);
SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_BACK);
if (pLayer)
pView->SetLayerLocked( pLayer->GetName(), !bEx );
if ( bSelectFirst )
{
// #97016# select first draw object if none is selected yet
if(!pView->HasMarkedObj())
{
// select first object
pView->UnmarkAllObj();
pView->MarkNextObj(TRUE);
// ...and make it visible
if(pView->HasMarkedObj())
pView->MakeVisible(pView->GetAllMarkedRect(), *pWin);
}
}
nDrawSfxId = nNewId;
if ( nNewId != SID_DRAW_CHART ) // Chart nicht mit DrawShell
{
if ( nNewId == SID_DRAW_TEXT || nNewId == SID_DRAW_TEXT_VERTICAL ||
nNewId == SID_DRAW_TEXT_MARQUEE || nNewId == SID_DRAW_NOTEEDIT )
SetDrawTextShell( TRUE );
else
{
if ( bEx || pView->GetMarkList().GetMarkCount() != 0 )
SetDrawShellOrSub();
else
SetDrawShell( FALSE );
}
}
if (pTabView->GetDrawFuncPtr())
{
if (pTabView->GetDrawFuncOldPtr() != pTabView->GetDrawFuncPtr())
delete pTabView->GetDrawFuncOldPtr();
pTabView->GetDrawFuncPtr()->Deactivate();
pTabView->SetDrawFuncOldPtr(pTabView->GetDrawFuncPtr());
pTabView->SetDrawFuncPtr(NULL);
}
SfxRequest aNewReq(rReq);
aNewReq.SetSlot(nDrawSfxId);
switch (nNewId)
{
case SID_OBJECT_SELECT:
//@#70206# Nicht immer zurueckschalten
if(pView->GetMarkList().GetMarkCount() == 0) SetDrawShell(bEx);
pTabView->SetDrawFuncPtr(new FuSelection(this, pWin, pView, pDoc, aNewReq));
break;
case SID_DRAW_LINE:
case SID_DRAW_RECT:
case SID_DRAW_ELLIPSE:
pTabView->SetDrawFuncPtr(new FuConstRectangle(this, pWin, pView, pDoc, aNewReq));
break;
case SID_DRAW_CAPTION:
case SID_DRAW_CAPTION_VERTICAL:
pTabView->SetDrawFuncPtr(new FuConstRectangle(this, pWin, pView, pDoc, aNewReq));
pView->SetFrameDragSingles( FALSE );
rBindings.Invalidate( SID_BEZIER_EDIT );
break;
case SID_DRAW_POLYGON:
case SID_DRAW_POLYGON_NOFILL:
case SID_DRAW_BEZIER_NOFILL:
case SID_DRAW_FREELINE_NOFILL:
pTabView->SetDrawFuncPtr(new FuConstPolygon(this, pWin, pView, pDoc, aNewReq));
break;
case SID_DRAW_ARC:
case SID_DRAW_PIE:
case SID_DRAW_CIRCLECUT:
pTabView->SetDrawFuncPtr(new FuConstArc(this, pWin, pView, pDoc, aNewReq));
break;
case SID_DRAW_TEXT:
case SID_DRAW_TEXT_VERTICAL:
case SID_DRAW_TEXT_MARQUEE:
case SID_DRAW_NOTEEDIT:
pTabView->SetDrawFuncPtr(new FuText(this, pWin, pView, pDoc, aNewReq));
break;
case SID_FM_CREATE_CONTROL:
SetDrawFormShell(TRUE);
pTabView->SetDrawFuncPtr(new FuConstUnoControl(this, pWin, pView, pDoc, aNewReq));
nFormSfxId = nNewFormId;
break;
case SID_DRAW_CHART:
bChartDlgIsEdit = FALSE;
pTabView->SetDrawFuncPtr(new FuMarkRect(this, pWin, pView, pDoc, aNewReq));
break;
default:
break;
}
if (pTabView->GetDrawFuncPtr())
pTabView->GetDrawFuncPtr()->Activate();
rReq.Done();
rBindings.Invalidate( SID_INSERT_DRAW );
rBindings.Update( SID_INSERT_DRAW );
// #98185# Create default drawing objects via keyboard
// with qualifier construct directly
FuPoor* pFuActual = GetDrawFuncPtr();
if(pFuActual && (rReq.GetModifier() & KEY_MOD1))
{
// #98185# Create default drawing objects via keyboard
const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
sal_uInt32 nDefaultObjectSizeWidth = rAppOpt.GetDefaultObjectSizeWidth();
sal_uInt32 nDefaultObjectSizeHeight = rAppOpt.GetDefaultObjectSizeHeight();
// calc position and size
Rectangle aVisArea = pWin->PixelToLogic(Rectangle(Point(0,0), pWin->GetOutputSizePixel()));
Point aPagePos = aVisArea.Center();
aPagePos.X() -= nDefaultObjectSizeWidth / 2;
aPagePos.Y() -= nDefaultObjectSizeHeight / 2;
Rectangle aNewObjectRectangle(aPagePos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight));
ScDrawView* pDrView = GetScDrawView();
if(pDrView)
{
SdrPageView* pPageView = pDrView->GetPageViewPvNum(0);
if(pPageView)
{
// create the default object
SdrObject* pObj = pFuActual->CreateDefaultObject(nNewId, aNewObjectRectangle);
if(pObj)
{
// insert into page
pView->InsertObject(pObj, *pPageView, pView->IsSolidDraggingNow() ? SDRINSERT_NOBROADCAST : 0);
if ( nNewId == SID_DRAW_CAPTION || nNewId == SID_DRAW_CAPTION_VERTICAL )
{
// #105815# use KeyInput to start edit mode (FuText is created).
// For FuText objects, edit mode is handled within CreateDefaultObject.
// KEY_F2 is handled in FuDraw::KeyInput.
pFuActual->KeyInput( KeyEvent( 0, KeyCode( KEY_F2 ) ) );
}
}
}
}
}
}
void ScTabViewShell::GetDrawState(SfxItemSet &rSet)
{
SfxWhichIter aIter(rSet);
USHORT nWhich = aIter.FirstWhich();
while ( nWhich )
{
switch ( nWhich )
{
case SID_INSERT_DRAW:
{
// SID_OBJECT_SELECT nur, wenn "harter" Selektionsmodus
USHORT nPutId = nDrawSfxId;
if ( nPutId == SID_OBJECT_SELECT && !IsDrawSelMode() )
nPutId = USHRT_MAX;
// nur die Images, die auch auf dem Controller liegen
if ( nPutId != SID_OBJECT_SELECT &&
nPutId != SID_DRAW_LINE &&
nPutId != SID_DRAW_RECT &&
nPutId != SID_DRAW_ELLIPSE &&
nPutId != SID_DRAW_POLYGON_NOFILL &&
nPutId != SID_DRAW_BEZIER_NOFILL &&
nPutId != SID_DRAW_FREELINE_NOFILL &&
nPutId != SID_DRAW_ARC &&
nPutId != SID_DRAW_PIE &&
nPutId != SID_DRAW_CIRCLECUT &&
nPutId != SID_DRAW_TEXT &&
nPutId != SID_DRAW_TEXT_VERTICAL &&
nPutId != SID_DRAW_TEXT_MARQUEE &&
nPutId != SID_DRAW_CAPTION &&
nPutId != SID_DRAW_CAPTION_VERTICAL )
nPutId = USHRT_MAX;
SfxAllEnumItem aItem( nWhich, nPutId );
rSet.Put( aItem );
}
break;
case SID_DRAW_CHART:
{
BOOL bOle = GetViewFrame()->ISA(SfxInPlaceFrame);
if ( bOle || !SvtModuleOptions().IsChart() )
rSet.DisableItem( nWhich );
}
break;
case SID_OBJECT_SELECT: // wichtig fuer den ollen Control-Controller
rSet.Put( SfxBoolItem( nWhich, nDrawSfxId == SID_OBJECT_SELECT && IsDrawSelMode() ) );
break;
}
nWhich = aIter.NextWhich();
}
}
BOOL ScTabViewShell::SelectObject( const String& rName )
{
ScDrawView* pView = GetViewData()->GetScDrawView();
if (!pView)
return FALSE;
BOOL bFound = pView->SelectObject( rName );
// DrawShell etc. is handled in MarkListHasChanged
return bFound;
}
|