fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / drawfunc / drawsh5.cxx
blob5d2483aa63f0466939fd7eb6f233bfd46e97adb6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <editeng/eeitem.hxx>
22 #include <sfx2/viewfrm.hxx>
23 #include <sfx2/request.hxx>
24 #include <sfx2/bindings.hxx>
25 #include <tools/urlobj.hxx>
26 #include <cliputil.hxx>
27 #include <svx/svxdlg.hxx>
28 #include <svx/dialogs.hrc>
29 #include <svx/fmglob.hxx>
30 #include <svx/hlnkitem.hxx>
31 #include <svx/fontwork.hxx>
32 #include <svx/svdocapt.hxx>
33 #include <svx/svdoole2.hxx>
34 #include <svx/svdouno.hxx>
35 #include <svx/svdpage.hxx>
36 #include <svx/svdundo.hxx>
37 #include <svx/xdef.hxx>
38 #include <vcl/msgbox.hxx>
39 #include <svx/extrusionbar.hxx>
40 #include <svx/fontworkbar.hxx>
41 #include <sfx2/docfile.hxx>
43 #include <com/sun/star/form/FormButtonType.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/beans/XPropertySetInfo.hpp>
46 #include <com/sun/star/awt/XControlModel.hpp>
48 #include "drawsh.hxx"
49 #include "drawview.hxx"
50 #include "viewdata.hxx"
51 #include "tabvwsh.hxx"
52 #include "docsh.hxx"
53 #include "scresid.hxx"
54 #include "undotab.hxx"
55 #include "drwlayer.hxx"
56 #include "userdat.hxx"
57 #include "postit.hxx"
58 #include "drtxtob.hxx"
59 #include <boost/scoped_ptr.hpp>
61 #include "sc.hrc"
63 using namespace com::sun::star;
65 void ScDrawShell::GetHLinkState( SfxItemSet& rSet ) // Hyperlink
67 ScDrawView* pView = pViewData->GetScDrawView();
68 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
70 // Hyperlink
72 SvxHyperlinkItem aHLinkItem;
74 if ( rMarkList.GetMarkCount() == 1 ) // URL-Button markiert ?
76 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
77 ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
78 if ( pInfo && !pInfo->GetHlink().isEmpty() )
80 aHLinkItem.SetURL( pInfo->GetHlink() );
81 aHLinkItem.SetInsertMode(HLINK_FIELD);
83 SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj);
84 if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
86 uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel();
87 OSL_ENSURE( xControlModel.is(), "UNO-Control ohne Model" );
88 if( !xControlModel.is() )
89 return;
91 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
92 uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
94 OUString sPropButtonType( "ButtonType" );
95 OUString sPropTargetURL( "TargetURL" );
96 OUString sPropTargetFrame( "TargetFrame" );
97 OUString sPropLabel( "Label" );
99 if(xInfo->hasPropertyByName( sPropButtonType ))
101 uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
102 form::FormButtonType eTmp;
103 if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
105 OUString sTmp;
106 // Label
107 if(xInfo->hasPropertyByName( sPropLabel ))
109 aAny = xPropSet->getPropertyValue( sPropLabel );
110 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
112 aHLinkItem.SetName(sTmp);
115 // URL
116 if(xInfo->hasPropertyByName( sPropTargetURL ))
118 aAny = xPropSet->getPropertyValue( sPropTargetURL );
119 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
121 aHLinkItem.SetURL(sTmp);
124 // Target
125 if(xInfo->hasPropertyByName( sPropTargetFrame ))
127 aAny = xPropSet->getPropertyValue( sPropTargetFrame );
128 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
130 aHLinkItem.SetTargetFrame(sTmp);
133 aHLinkItem.SetInsertMode(HLINK_BUTTON);
139 rSet.Put(aHLinkItem);
142 void ScDrawShell::ExecuteHLink( SfxRequest& rReq )
144 const SfxItemSet* pReqArgs = rReq.GetArgs();
146 sal_uInt16 nSlot = rReq.GetSlot();
147 switch ( nSlot )
149 case SID_HYPERLINK_SETLINK:
150 if( pReqArgs )
152 const SfxPoolItem* pItem;
153 if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, true, &pItem ) == SfxItemState::SET )
155 const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
156 const OUString& rName = pHyper->GetName();
157 const OUString& rURL = pHyper->GetURL();
158 const OUString& rTarget = pHyper->GetTargetFrame();
159 SvxLinkInsertMode eMode = pHyper->GetInsertMode();
161 bool bDone = false;
162 if ( eMode == HLINK_FIELD || eMode == HLINK_BUTTON )
164 ScDrawView* pView = pViewData->GetScDrawView();
165 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
166 if ( rMarkList.GetMarkCount() == 1 )
168 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
169 SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj );
170 if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
172 uno::Reference<awt::XControlModel> xControlModel =
173 pUnoCtrl->GetUnoControlModel();
174 OSL_ENSURE( xControlModel.is(), "UNO-Control ohne Model" );
175 if( !xControlModel.is() )
176 return;
178 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
179 uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
181 OUString sPropTargetURL( "TargetURL" );
183 // Darf man eine URL an dem Objekt setzen?
184 if (xInfo->hasPropertyByName( sPropTargetURL ))
186 // Ja!
188 OUString sPropButtonType( "ButtonType");
189 OUString sPropTargetFrame( "TargetFrame" );
190 OUString sPropLabel( "Label" );
192 uno::Any aAny;
193 if ( xInfo->hasPropertyByName( sPropLabel ) )
195 aAny <<= OUString(rName);
196 xPropSet->setPropertyValue( sPropLabel, aAny );
199 OUString aTmp = INetURLObject::GetAbsURL( pViewData->GetDocShell()->GetMedium()->GetBaseURL(), rURL );
200 aAny <<= aTmp;
201 xPropSet->setPropertyValue( sPropTargetURL, aAny );
203 if( !rTarget.isEmpty() && xInfo->hasPropertyByName( sPropTargetFrame ) )
205 aAny <<= OUString(rTarget);
206 xPropSet->setPropertyValue( sPropTargetFrame, aAny );
209 if ( xInfo->hasPropertyByName( sPropButtonType ) )
211 form::FormButtonType eButtonType = form::FormButtonType_URL;
212 aAny <<= eButtonType;
213 xPropSet->setPropertyValue( sPropButtonType, aAny );
216 //! Undo ???
217 pViewData->GetDocShell()->SetDocumentModified();
218 bDone = true;
221 else
223 SetHlinkForObject( pObj, rURL );
224 bDone = true;
229 if (!bDone)
230 pViewData->GetViewShell()->
231 InsertURL( rName, rURL, rTarget, (sal_uInt16) eMode );
233 // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
236 break;
237 default:
238 OSL_FAIL("falscher Slot");
242 // Funktionen auf Drawing-Objekten
244 void ScDrawShell::ExecDrawFunc( SfxRequest& rReq )
246 SfxBindings& rBindings = pViewData->GetBindings();
247 ScTabView* pTabView = pViewData->GetView();
248 ScDrawView* pView = pTabView->GetScDrawView();
249 const SfxItemSet *pArgs = rReq.GetArgs();
250 sal_uInt16 nSlotId = rReq.GetSlot();
252 //!!!
253 // wer weiss, wie lange das funktioniert? (->vom Abreisscontrol funktioniert es)
255 if (nSlotId == SID_OBJECT_ALIGN && pArgs)
256 nSlotId = SID_OBJECT_ALIGN + static_cast<const SfxEnumItem&>(pArgs->Get(SID_OBJECT_ALIGN)).GetValue() + 1;
258 switch (nSlotId)
260 case SID_OBJECT_HEAVEN:
261 pView->SetMarkedToLayer( SC_LAYER_FRONT );
262 rBindings.Invalidate(SID_OBJECT_HEAVEN);
263 rBindings.Invalidate(SID_OBJECT_HELL);
264 break;
265 case SID_OBJECT_HELL:
266 pView->SetMarkedToLayer( SC_LAYER_BACK );
267 rBindings.Invalidate(SID_OBJECT_HEAVEN);
268 rBindings.Invalidate(SID_OBJECT_HELL);
269 // leave draw shell if nothing selected (layer may be locked)
270 pViewData->GetViewShell()->UpdateDrawShell();
271 break;
273 case SID_FRAME_TO_TOP:
274 pView->PutMarkedToTop();
275 break;
276 case SID_FRAME_TO_BOTTOM:
277 pView->PutMarkedToBtm();
278 break;
279 case SID_FRAME_UP:
280 pView->MovMarkedToTop();
281 break;
282 case SID_FRAME_DOWN:
283 pView->MovMarkedToBtm();
284 break;
286 case SID_GROUP:
287 pView->GroupMarked();
288 break;
289 case SID_UNGROUP:
290 pView->UnGroupMarked();
291 break;
292 case SID_ENTER_GROUP:
293 pView->EnterMarkedGroup();
294 break;
295 case SID_LEAVE_GROUP:
296 pView->LeaveOneGroup();
297 break;
299 case SID_MIRROR_HORIZONTAL:
300 case SID_FLIP_HORIZONTAL:
301 pView->MirrorAllMarkedHorizontal();
302 rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
303 break;
304 case SID_MIRROR_VERTICAL:
305 case SID_FLIP_VERTICAL:
306 pView->MirrorAllMarkedVertical();
307 rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
308 break;
310 case SID_OBJECT_ALIGN_LEFT:
311 case SID_ALIGN_ANY_LEFT:
312 if (pView->IsAlignPossible())
313 pView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
314 break;
315 case SID_OBJECT_ALIGN_CENTER:
316 case SID_ALIGN_ANY_HCENTER:
317 if (pView->IsAlignPossible())
318 pView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
319 break;
320 case SID_OBJECT_ALIGN_RIGHT:
321 case SID_ALIGN_ANY_RIGHT:
322 if (pView->IsAlignPossible())
323 pView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
324 break;
325 case SID_OBJECT_ALIGN_UP:
326 case SID_ALIGN_ANY_TOP:
327 if (pView->IsAlignPossible())
328 pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
329 break;
330 case SID_OBJECT_ALIGN_MIDDLE:
331 case SID_ALIGN_ANY_VCENTER:
332 if (pView->IsAlignPossible())
333 pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
334 break;
335 case SID_OBJECT_ALIGN_DOWN:
336 case SID_ALIGN_ANY_BOTTOM:
337 if (pView->IsAlignPossible())
338 pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
339 break;
341 case SID_DELETE:
342 case SID_DELETE_CONTENTS:
343 pView->DeleteMarked();
344 pViewData->GetViewShell()->UpdateDrawShell();
345 break;
347 case SID_CUT:
348 pView->DoCut();
349 pViewData->GetViewShell()->UpdateDrawShell();
350 break;
352 case SID_COPY:
353 pView->DoCopy();
354 break;
356 case SID_PASTE:
357 ScClipUtil::PasteFromClipboard ( GetViewData(), GetViewData()->GetViewShell(), true );
358 break;
360 case SID_SELECTALL:
361 pView->MarkAll();
362 break;
364 case SID_ANCHOR_PAGE:
365 pView->SetPageAnchored();
366 rBindings.Invalidate( SID_ANCHOR_PAGE );
367 rBindings.Invalidate( SID_ANCHOR_CELL );
368 break;
370 case SID_ANCHOR_CELL:
371 pView->SetCellAnchored();
372 rBindings.Invalidate( SID_ANCHOR_PAGE );
373 rBindings.Invalidate( SID_ANCHOR_CELL );
374 break;
376 case SID_ANCHOR_TOGGLE:
378 switch( pView->GetAnchorType() )
380 case SCA_CELL:
381 pView->SetPageAnchored();
382 break;
383 default:
384 pView->SetCellAnchored();
385 break;
388 rBindings.Invalidate( SID_ANCHOR_PAGE );
389 rBindings.Invalidate( SID_ANCHOR_CELL );
390 break;
392 case SID_OBJECT_ROTATE:
394 SdrDragMode eMode;
395 if (pView->GetDragMode() == SDRDRAG_ROTATE)
396 eMode = SDRDRAG_MOVE;
397 else
398 eMode = SDRDRAG_ROTATE;
399 pView->SetDragMode( eMode );
400 rBindings.Invalidate( SID_OBJECT_ROTATE );
401 rBindings.Invalidate( SID_OBJECT_MIRROR );
402 if (eMode == SDRDRAG_ROTATE && !pView->IsFrameDragSingles())
404 pView->SetFrameDragSingles( true );
405 rBindings.Invalidate( SID_BEZIER_EDIT );
408 break;
409 case SID_OBJECT_MIRROR:
411 SdrDragMode eMode;
412 if (pView->GetDragMode() == SDRDRAG_MIRROR)
413 eMode = SDRDRAG_MOVE;
414 else
415 eMode = SDRDRAG_MIRROR;
416 pView->SetDragMode( eMode );
417 rBindings.Invalidate( SID_OBJECT_ROTATE );
418 rBindings.Invalidate( SID_OBJECT_MIRROR );
419 if (eMode == SDRDRAG_MIRROR && !pView->IsFrameDragSingles())
421 pView->SetFrameDragSingles( true );
422 rBindings.Invalidate( SID_BEZIER_EDIT );
425 break;
426 case SID_BEZIER_EDIT:
428 bool bOld = pView->IsFrameDragSingles();
429 pView->SetFrameDragSingles( !bOld );
430 rBindings.Invalidate( SID_BEZIER_EDIT );
431 if (bOld && pView->GetDragMode() != SDRDRAG_MOVE)
433 pView->SetDragMode( SDRDRAG_MOVE );
434 rBindings.Invalidate( SID_OBJECT_ROTATE );
435 rBindings.Invalidate( SID_OBJECT_MIRROR );
438 break;
440 case SID_FONTWORK:
442 sal_uInt16 nId = ScGetFontWorkId();
443 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
445 if ( rReq.GetArgs() )
446 pViewFrm->SetChildWindow( nId,
447 static_cast<const SfxBoolItem&>(
448 (rReq.GetArgs()->Get(SID_FONTWORK))).
449 GetValue() );
450 else
451 pViewFrm->ToggleChildWindow( nId );
453 rBindings.Invalidate( SID_FONTWORK );
454 rReq.Done();
456 break;
458 case SID_ORIGINALSIZE:
459 pView->SetMarkedOriginalSize();
460 break;
462 case SID_ENABLE_HYPHENATION:
464 SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, false);
465 if( pItem )
467 SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
468 bool bValue = pItem->GetValue();
469 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
470 pView->SetAttributes( aSet );
472 rReq.Done();
474 break;
476 case SID_RENAME_OBJECT:
478 if(1 == pView->GetMarkedObjectCount())
480 // #i68101#
481 SdrObject* pSelected = pView->GetMarkedObjectByIndex(0);
482 OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
484 if(SC_LAYER_INTERN != pSelected->GetLayer())
486 OUString aName = pSelected->GetName();
488 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
489 OSL_ENSURE(pFact, "Dialog creation failed!");
490 boost::scoped_ptr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(NULL, aName));
491 OSL_ENSURE(pDlg, "Dialog creation failed!");
493 pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl));
495 if(RET_OK == pDlg->Execute())
497 ScDocShell* pDocSh = pViewData->GetDocShell();
498 pDlg->GetName(aName);
500 if (!aName.equals(pSelected->GetName()))
502 // handle name change
503 const sal_uInt16 nObjType(pSelected->GetObjIdentifier());
505 if (OBJ_GRAF == nObjType && aName.isEmpty())
507 // graphics objects must have names
508 // (all graphics are supposed to be in the navigator)
509 ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
511 if(pModel)
513 aName = pModel->GetNewGraphicName();
517 // An undo action for renaming is missing in svdraw (99363).
518 // For OLE objects (which can be identified using the persist name),
519 // ScUndoRenameObject can be used until there is a common action for all objects.
520 if(OBJ_OLE2 == nObjType)
522 const OUString aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName();
524 if(!aPersistName.isEmpty())
526 pDocSh->GetUndoManager()->AddUndoAction(
527 new ScUndoRenameObject(pDocSh, aPersistName, pSelected->GetName(), aName));
531 // set new name
532 pSelected->SetName(aName);
535 // ChartListenerCollectionNeedsUpdate is needed for Navigator update
536 pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true );
537 pDocSh->SetDrawModified();
541 break;
544 // #i68101#
545 case SID_TITLE_DESCRIPTION_OBJECT:
547 if(1 == pView->GetMarkedObjectCount())
549 SdrObject* pSelected = pView->GetMarkedObjectByIndex(0);
550 OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
552 if(SC_LAYER_INTERN != pSelected->GetLayer())
554 OUString aTitle(pSelected->GetTitle());
555 OUString aDescription(pSelected->GetDescription());
557 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
558 OSL_ENSURE(pFact, "Dialog creation failed!");
559 boost::scoped_ptr<AbstractSvxObjectTitleDescDialog> pDlg(pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription));
560 OSL_ENSURE(pDlg, "Dialog creation failed!");
562 if(RET_OK == pDlg->Execute())
564 ScDocShell* pDocSh = pViewData->GetDocShell();
566 // handle Title and Description
567 pDlg->GetTitle(aTitle);
568 pDlg->GetDescription(aDescription);
569 pSelected->SetTitle(aTitle);
570 pSelected->SetDescription(aDescription);
572 // ChartListenerCollectionNeedsUpdate is needed for Navigator update
573 pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true );
574 pDocSh->SetDrawModified();
578 break;
581 case SID_EXTRUSION_TOOGLE:
582 case SID_EXTRUSION_TILT_DOWN:
583 case SID_EXTRUSION_TILT_UP:
584 case SID_EXTRUSION_TILT_LEFT:
585 case SID_EXTRUSION_TILT_RIGHT:
586 case SID_EXTRUSION_3D_COLOR:
587 case SID_EXTRUSION_DEPTH:
588 case SID_EXTRUSION_DIRECTION:
589 case SID_EXTRUSION_PROJECTION:
590 case SID_EXTRUSION_LIGHTING_DIRECTION:
591 case SID_EXTRUSION_LIGHTING_INTENSITY:
592 case SID_EXTRUSION_SURFACE:
593 case SID_EXTRUSION_DEPTH_FLOATER:
594 case SID_EXTRUSION_DIRECTION_FLOATER:
595 case SID_EXTRUSION_LIGHTING_FLOATER:
596 case SID_EXTRUSION_SURFACE_FLOATER:
597 case SID_EXTRUSION_DEPTH_DIALOG:
598 svx::ExtrusionBar::execute( pView, rReq, rBindings );
599 rReq.Ignore ();
600 break;
602 case SID_FONTWORK_SHAPE:
603 case SID_FONTWORK_SHAPE_TYPE:
604 case SID_FONTWORK_ALIGNMENT:
605 case SID_FONTWORK_SAME_LETTER_HEIGHTS:
606 case SID_FONTWORK_CHARACTER_SPACING:
607 case SID_FONTWORK_KERN_CHARACTER_PAIRS:
608 case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
609 case SID_FONTWORK_ALIGNMENT_FLOATER:
610 case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
611 svx::FontworkBar::execute( pView, rReq, rBindings );
612 rReq.Ignore ();
613 break;
615 default:
616 break;
620 IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
622 OUString aName;
624 if( pDialog )
625 pDialog->GetName( aName );
627 ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
628 if ( !aName.isEmpty() && pModel )
630 SCTAB nDummyTab;
631 if ( pModel->GetNamedObject( aName, 0, nDummyTab ) )
633 // existing object found -> name invalid
634 return 0;
638 return 1; // name is valid
641 void ScDrawShell::ExecFormText(SfxRequest& rReq)
643 ScDrawView* pDrView = pViewData->GetScDrawView();
644 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
646 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
648 const SfxItemSet& rSet = *rReq.GetArgs();
650 if ( pDrView->IsTextEdit() )
651 pDrView->ScEndTextEdit();
653 pDrView->SetAttributes(rSet);
657 void ScDrawShell::ExecFormatPaintbrush( SfxRequest& rReq )
659 ScViewFunc* pView = pViewData->GetView();
660 if ( pView->HasPaintBrush() )
662 // cancel paintbrush mode
663 pView->ResetBrushDocument();
665 else
667 bool bLock = false;
668 const SfxItemSet *pArgs = rReq.GetArgs();
669 if( pArgs && pArgs->Count() >= 1 )
670 bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
672 ScDrawView* pDrawView = pViewData->GetScDrawView();
673 if ( pDrawView && pDrawView->AreObjectsMarked() )
675 bool bOnlyHardAttr = true;
676 SfxItemSet* pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) );
677 pView->SetDrawBrushSet( pItemSet, bLock );
682 void ScDrawShell::StateFormatPaintbrush( SfxItemSet& rSet )
684 ScDrawView* pDrawView = pViewData->GetScDrawView();
685 bool bSelection = pDrawView && pDrawView->AreObjectsMarked();
686 bool bHasPaintBrush = pViewData->GetView()->HasPaintBrush();
688 if ( !bHasPaintBrush && !bSelection )
689 rSet.DisableItem( SID_FORMATPAINTBRUSH );
690 else
691 rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) );
694 ScDrawView* ScDrawShell::GetDrawView()
696 return pViewData->GetView()->GetScDrawView();
699 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */