xref: /aoo42x/main/sc/source/ui/drawfunc/drawsh5.cxx (revision 1e9c32af)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 //------------------------------------------------------------------
30 
31 #include <editeng/eeitem.hxx>
32 
33 #include <sfx2/viewfrm.hxx>
34 #include <sfx2/request.hxx>
35 #include <sfx2/bindings.hxx>
36 #include <tools/urlobj.hxx>
37 //CHINA001 #include <svx/dlgname.hxx>
38 #include <svx/svxdlg.hxx> //CHINA001
39 #include <svx/dialogs.hrc> //CHINA001
40 #include <svx/fmglob.hxx>
41 #include <svx/hlnkitem.hxx>
42 #include <svx/fontwork.hxx>
43 #include <svx/svdocapt.hxx>
44 #include <svx/svdoole2.hxx>
45 #include <svx/svdouno.hxx>
46 #include <svx/svdpage.hxx>
47 #include <svx/svdundo.hxx>
48 #include <svx/xdef.hxx>
49 #include <vcl/msgbox.hxx>
50 #include <svx/extrusionbar.hxx>
51 #include <svx/fontworkbar.hxx>
52 #include <sfx2/docfile.hxx>
53 
54 #include <com/sun/star/form/FormButtonType.hpp>
55 #include <com/sun/star/beans/XPropertySet.hpp>
56 #include <com/sun/star/beans/XPropertySetInfo.hpp>
57 #include <com/sun/star/awt/XControlModel.hpp>
58 
59 #include "drawsh.hxx"
60 #include "drawview.hxx"
61 #include "viewdata.hxx"
62 #include "tabvwsh.hxx"
63 #include "docsh.hxx"
64 //CHINA001 #include "strindlg.hxx"
65 #include "scresid.hxx"
66 #include "undotab.hxx"
67 #include "drwlayer.hxx"
68 #include "userdat.hxx"
69 #include "postit.hxx"
70 
71 #include "sc.hrc"
72 
73 using namespace com::sun::star;
74 
75 //------------------------------------------------------------------
76 
77 void ScDrawShell::GetHLinkState( SfxItemSet& rSet )             //  Hyperlink
78 {
79     ScDrawView* pView = pViewData->GetScDrawView();
80     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
81     sal_uLong nMarkCount = rMarkList.GetMarkCount();
82 
83         //  Hyperlink
84 
85     SvxHyperlinkItem aHLinkItem;
86 
87     if ( nMarkCount == 1 )              // URL-Button markiert ?
88     {
89         SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
90 #ifdef ISSUE66550_HLINK_FOR_SHAPES
91         ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
92         if ( pInfo && (pInfo->GetHlink().getLength() > 0) )
93         {
94             aHLinkItem.SetURL( pInfo->GetHlink() );
95             aHLinkItem.SetInsertMode(HLINK_FIELD);
96         }
97 #endif
98         SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj);
99         if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
100         {
101             uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel();
102             DBG_ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
103             if( !xControlModel.is() )
104                 return;
105 
106             uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
107             uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
108 
109             rtl::OUString sPropButtonType  = rtl::OUString::createFromAscii( "ButtonType" );
110             rtl::OUString sPropTargetURL   = rtl::OUString::createFromAscii( "TargetURL" );
111             rtl::OUString sPropTargetFrame = rtl::OUString::createFromAscii( "TargetFrame" );
112             rtl::OUString sPropLabel       = rtl::OUString::createFromAscii( "Label" );
113 
114             if(xInfo->hasPropertyByName( sPropButtonType ))
115             {
116                 uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
117                 form::FormButtonType eTmp;
118                 if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
119                 {
120                     rtl::OUString sTmp;
121                     // Label
122                     if(xInfo->hasPropertyByName( sPropLabel ))
123                     {
124                         aAny = xPropSet->getPropertyValue( sPropLabel );
125                         if ( (aAny >>= sTmp) && sTmp.getLength() )
126                         {
127                             aHLinkItem.SetName(sTmp);
128                         }
129                     }
130                     // URL
131                     if(xInfo->hasPropertyByName( sPropTargetURL ))
132                     {
133                         aAny = xPropSet->getPropertyValue( sPropTargetURL );
134                         if ( (aAny >>= sTmp) && sTmp.getLength() )
135                         {
136                             aHLinkItem.SetURL(sTmp);
137                         }
138                     }
139                     // Target
140                     if(xInfo->hasPropertyByName( sPropTargetFrame ))
141                     {
142                         aAny = xPropSet->getPropertyValue( sPropTargetFrame );
143                         if ( (aAny >>= sTmp) && sTmp.getLength() )
144                         {
145                             aHLinkItem.SetTargetFrame(sTmp);
146                         }
147                     }
148                     aHLinkItem.SetInsertMode(HLINK_BUTTON);
149                 }
150             }
151         }
152     }
153 
154     rSet.Put(aHLinkItem);
155 }
156 
157 void ScDrawShell::ExecuteHLink( SfxRequest& rReq )
158 {
159     const SfxItemSet* pReqArgs = rReq.GetArgs();
160 
161     sal_uInt16 nSlot = rReq.GetSlot();
162     switch ( nSlot )
163     {
164         case SID_HYPERLINK_SETLINK:
165             if( pReqArgs )
166             {
167                 const SfxPoolItem* pItem;
168                 if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET )
169                 {
170                     const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
171                     const String& rName     = pHyper->GetName();
172                     const String& rURL      = pHyper->GetURL();
173                     const String& rTarget   = pHyper->GetTargetFrame();
174                     SvxLinkInsertMode eMode = pHyper->GetInsertMode();
175 
176                     sal_Bool bDone = sal_False;
177                     if ( eMode == HLINK_FIELD || eMode == HLINK_BUTTON )
178                     {
179                         ScDrawView* pView = pViewData->GetScDrawView();
180                         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
181                         if ( rMarkList.GetMarkCount() == 1 )
182                         {
183                             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
184                             SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj );
185                             if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
186                             {
187                                 uno::Reference<awt::XControlModel> xControlModel =
188                                                         pUnoCtrl->GetUnoControlModel();
189                                 DBG_ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
190                                 if( !xControlModel.is() )
191                                     return;
192 
193                                 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
194                                 uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
195 
196                                 rtl::OUString sPropTargetURL =
197                                     rtl::OUString::createFromAscii( "TargetURL" );
198 
199                                 // Darf man eine URL an dem Objekt setzen?
200                                 if (xInfo->hasPropertyByName( sPropTargetURL ))
201                                 {
202                                     // Ja!
203 
204                                     rtl::OUString sPropButtonType =
205                                         rtl::OUString::createFromAscii( "ButtonType" );
206                                     rtl::OUString sPropTargetFrame =
207                                         rtl::OUString::createFromAscii( "TargetFrame" );
208                                     rtl::OUString sPropLabel =
209                                         rtl::OUString::createFromAscii( "Label" );
210 
211                                     uno::Any aAny;
212                                     if ( xInfo->hasPropertyByName( sPropLabel ) )
213                                     {
214                                         aAny <<= rtl::OUString(rName);
215                                         xPropSet->setPropertyValue( sPropLabel, aAny );
216                                     }
217 
218                                     ::rtl::OUString aTmp = INetURLObject::GetAbsURL( pViewData->GetDocShell()->GetMedium()->GetBaseURL(), rURL );
219                                     aAny <<= aTmp;
220                                     xPropSet->setPropertyValue( sPropTargetURL, aAny );
221 
222                                     if( rTarget.Len() && xInfo->hasPropertyByName( sPropTargetFrame ) )
223                                     {
224                                         aAny <<= rtl::OUString(rTarget);
225                                         xPropSet->setPropertyValue( sPropTargetFrame, aAny );
226                                     }
227 
228                                     if ( xInfo->hasPropertyByName( sPropButtonType ) )
229                                     {
230                                         form::FormButtonType eButtonType = form::FormButtonType_URL;
231                                         aAny <<= eButtonType;
232                                         xPropSet->setPropertyValue( sPropButtonType, aAny );
233                                     }
234 
235                                     //! Undo ???
236                                     pViewData->GetDocShell()->SetDocumentModified();
237                                     bDone = sal_True;
238                                 }
239                             }
240 #ifdef ISSUE66550_HLINK_FOR_SHAPES
241                             else
242                             {
243                                 SetHlinkForObject( pObj, rURL );
244                                 bDone = sal_True;
245                             }
246 #endif
247                         }
248                     }
249 
250                     if (!bDone)
251                         pViewData->GetViewShell()->
252                             InsertURL( rName, rURL, rTarget, (sal_uInt16) eMode );
253 
254                     //  InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
255                 }
256             }
257             break;
258         default:
259             DBG_ERROR("falscher Slot");
260     }
261 }
262 
263 sal_uInt16 ScGetFontWorkId();       // wegen CLOOKs - in drtxtob2
264 
265 //------------------------------------------------------------------
266 
267 //
268 //          Funktionen auf Drawing-Objekten
269 //
270 
271 void ScDrawShell::ExecDrawFunc( SfxRequest& rReq )
272 {
273     SfxBindings& rBindings = pViewData->GetBindings();
274     ScTabView*   pTabView  = pViewData->GetView();
275     ScDrawView*  pView     = pTabView->GetScDrawView();
276     const SfxItemSet *pArgs = rReq.GetArgs();
277     sal_uInt16 nSlotId = rReq.GetSlot();
278 
279     //!!!
280     // wer weiss, wie lange das funktioniert? (->vom Abreisscontrol funktioniert es)
281     //
282     if (nSlotId == SID_OBJECT_ALIGN && pArgs)
283         nSlotId = SID_OBJECT_ALIGN + ((SfxEnumItem&)pArgs->Get(SID_OBJECT_ALIGN)).GetValue() + 1;
284 
285     switch (nSlotId)
286     {
287         case SID_OBJECT_HEAVEN:
288             pView->SetMarkedToLayer( SC_LAYER_FRONT );
289             rBindings.Invalidate(SID_OBJECT_HEAVEN);
290             rBindings.Invalidate(SID_OBJECT_HELL);
291             break;
292         case SID_OBJECT_HELL:
293             pView->SetMarkedToLayer( SC_LAYER_BACK );
294             rBindings.Invalidate(SID_OBJECT_HEAVEN);
295             rBindings.Invalidate(SID_OBJECT_HELL);
296             //  leave draw shell if nothing selected (layer may be locked)
297             pViewData->GetViewShell()->UpdateDrawShell();
298             break;
299 
300         case SID_FRAME_TO_TOP:
301             pView->PutMarkedToTop();
302             break;
303         case SID_FRAME_TO_BOTTOM:
304             pView->PutMarkedToBtm();
305             break;
306         case SID_FRAME_UP:
307             pView->MovMarkedToTop();
308             break;
309         case SID_FRAME_DOWN:
310             pView->MovMarkedToBtm();
311             break;
312 
313         case SID_GROUP:
314             pView->GroupMarked();
315             break;
316         case SID_UNGROUP:
317             pView->UnGroupMarked();
318             break;
319         case SID_ENTER_GROUP:
320             pView->EnterMarkedGroup();
321             break;
322         case SID_LEAVE_GROUP:
323             pView->LeaveOneGroup();
324             break;
325 
326         case SID_MIRROR_HORIZONTAL:
327             pView->MirrorAllMarkedHorizontal();
328             break;
329         case SID_MIRROR_VERTICAL:
330             pView->MirrorAllMarkedVertical();
331             break;
332 
333         case SID_OBJECT_ALIGN_LEFT:
334         case SID_ALIGN_ANY_LEFT:
335             if (pView->IsAlignPossible())
336                 pView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
337             break;
338         case SID_OBJECT_ALIGN_CENTER:
339         case SID_ALIGN_ANY_HCENTER:
340             if (pView->IsAlignPossible())
341                 pView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
342             break;
343         case SID_OBJECT_ALIGN_RIGHT:
344         case SID_ALIGN_ANY_RIGHT:
345             if (pView->IsAlignPossible())
346                 pView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
347             break;
348         case SID_OBJECT_ALIGN_UP:
349         case SID_ALIGN_ANY_TOP:
350             if (pView->IsAlignPossible())
351                 pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
352             break;
353         case SID_OBJECT_ALIGN_MIDDLE:
354         case SID_ALIGN_ANY_VCENTER:
355             if (pView->IsAlignPossible())
356                 pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
357             break;
358         case SID_OBJECT_ALIGN_DOWN:
359         case SID_ALIGN_ANY_BOTTOM:
360             if (pView->IsAlignPossible())
361                 pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
362             break;
363 
364         case SID_DELETE:
365         case SID_DELETE_CONTENTS:
366             pView->DeleteMarked();
367             pViewData->GetViewShell()->UpdateDrawShell();
368         break;
369 
370         case SID_CUT:
371             pView->DoCut();
372             pViewData->GetViewShell()->UpdateDrawShell();
373             break;
374 
375         case SID_COPY:
376             pView->DoCopy();
377             break;
378 
379         case SID_PASTE:
380             DBG_ERROR( "SdrView::PasteClipboard not supported anymore" );
381             // pView->PasteClipboard( pWin );
382             break;
383 
384         case SID_SELECTALL:
385             pView->MarkAll();
386             break;
387 
388         case SID_ANCHOR_PAGE:
389             pView->SetAnchor( SCA_PAGE );
390             rBindings.Invalidate( SID_ANCHOR_PAGE );
391             rBindings.Invalidate( SID_ANCHOR_CELL );
392             break;
393 
394         case SID_ANCHOR_CELL:
395             pView->SetAnchor( SCA_CELL );
396             rBindings.Invalidate( SID_ANCHOR_PAGE );
397             rBindings.Invalidate( SID_ANCHOR_CELL );
398             break;
399 
400         case SID_ANCHOR_TOGGLE:
401             {
402                 switch( pView->GetAnchor() )
403                 {
404                     case SCA_CELL:
405                     pView->SetAnchor( SCA_PAGE );
406                     break;
407                     default:
408                     pView->SetAnchor( SCA_CELL );
409                     break;
410                 }
411             }
412             rBindings.Invalidate( SID_ANCHOR_PAGE );
413             rBindings.Invalidate( SID_ANCHOR_CELL );
414             break;
415 
416         case SID_OBJECT_ROTATE:
417             {
418                 SdrDragMode eMode;
419                 if (pView->GetDragMode() == SDRDRAG_ROTATE)
420                     eMode = SDRDRAG_MOVE;
421                 else
422                     eMode = SDRDRAG_ROTATE;
423                 pView->SetDragMode( eMode );
424                 rBindings.Invalidate( SID_OBJECT_ROTATE );
425                 rBindings.Invalidate( SID_OBJECT_MIRROR );
426                 if (eMode == SDRDRAG_ROTATE && !pView->IsFrameDragSingles())
427                 {
428                     pView->SetFrameDragSingles( sal_True );
429                     rBindings.Invalidate( SID_BEZIER_EDIT );
430                 }
431             }
432             break;
433         case SID_OBJECT_MIRROR:
434             {
435                 SdrDragMode eMode;
436                 if (pView->GetDragMode() == SDRDRAG_MIRROR)
437                     eMode = SDRDRAG_MOVE;
438                 else
439                     eMode = SDRDRAG_MIRROR;
440                 pView->SetDragMode( eMode );
441                 rBindings.Invalidate( SID_OBJECT_ROTATE );
442                 rBindings.Invalidate( SID_OBJECT_MIRROR );
443                 if (eMode == SDRDRAG_MIRROR && !pView->IsFrameDragSingles())
444                 {
445                     pView->SetFrameDragSingles( sal_True );
446                     rBindings.Invalidate( SID_BEZIER_EDIT );
447                 }
448             }
449             break;
450         case SID_BEZIER_EDIT:
451             {
452                 sal_Bool bOld = pView->IsFrameDragSingles();
453                 pView->SetFrameDragSingles( !bOld );
454                 rBindings.Invalidate( SID_BEZIER_EDIT );
455                 if (bOld && pView->GetDragMode() != SDRDRAG_MOVE)
456                 {
457                     pView->SetDragMode( SDRDRAG_MOVE );
458                     rBindings.Invalidate( SID_OBJECT_ROTATE );
459                     rBindings.Invalidate( SID_OBJECT_MIRROR );
460                 }
461             }
462             break;
463 
464         case SID_FONTWORK:
465         {
466             sal_uInt16 nId = ScGetFontWorkId();
467             SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
468 
469             if ( rReq.GetArgs() )
470                 pViewFrm->SetChildWindow( nId,
471                                            ((const SfxBoolItem&)
472                                             (rReq.GetArgs()->Get(SID_FONTWORK))).
473                                                 GetValue() );
474             else
475                 pViewFrm->ToggleChildWindow( nId );
476 
477             rBindings.Invalidate( SID_FONTWORK );
478             rReq.Done();
479         }
480         break;
481 
482         case SID_ORIGINALSIZE:
483             pView->SetMarkedOriginalSize();
484             break;
485 
486 		case SID_ENABLE_HYPHENATION:
487 			{
488 				SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, sal_False);
489 				if( pItem )
490 				{
491 					SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
492 					sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
493 					aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
494 					pView->SetAttributes( aSet );
495 				}
496 				rReq.Done();
497 			}
498 			break;
499 
500 		case SID_RENAME_OBJECT:
501 			{
502 				if(1L == pView->GetMarkedObjectCount())
503 				{
504 					// #i68101#
505 					SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L);
506 					OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
507 
508                     if(SC_LAYER_INTERN != pSelected->GetLayer())
509 					{
510 						String aName(pSelected->GetName());
511 
512 						SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
513 						OSL_ENSURE(pFact, "Dialogdiet fail!");
514 						AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName);
515 						OSL_ENSURE(pDlg, "Dialogdiet fail!");
516 
517 						pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl));
518 
519 						if(RET_OK == pDlg->Execute())
520 						{
521 							ScDocShell* pDocSh = pViewData->GetDocShell();
522 							pDlg->GetName(aName);
523 
524 							if(aName != pSelected->GetName())
525 							{
526 								// handle name change
527 		                        const sal_uInt16 nObjType(pSelected->GetObjIdentifier());
528 
529 								if(OBJ_GRAF == nObjType && 0L == aName.Len())
530 								{
531 									//	graphics objects must have names
532 									//	(all graphics are supposed to be in the navigator)
533 									ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
534 
535 									if(pModel)
536 									{
537 										aName = pModel->GetNewGraphicName();
538 									}
539 								}
540 
541 								//	An undo action for renaming is missing in svdraw (99363).
542 								//	For OLE objects (which can be identified using the persist name),
543 								//	ScUndoRenameObject can be used until there is a common action for all objects.
544 								if(OBJ_OLE2 == nObjType)
545 								{
546 									const String aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName();
547 
548 									if(aPersistName.Len())
549 									{
550 										pDocSh->GetUndoManager()->AddUndoAction(
551 											new ScUndoRenameObject(pDocSh, aPersistName, pSelected->GetName(), aName));
552 									}
553 								}
554 
555 								// set new name
556 								pSelected->SetName(aName);
557 							}
558 
559 							// ChartListenerCollectionNeedsUpdate is needed for Navigator update
560                             pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( sal_True );
561 							pDocSh->SetDrawModified();
562 						}
563 
564 						delete pDlg;
565 					}
566 				}
567 				break;
568 			}
569 
570 		// #i68101#
571 		case SID_TITLE_DESCRIPTION_OBJECT:
572 			{
573 				if(1L == pView->GetMarkedObjectCount())
574 				{
575 					SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L);
576 					OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
577 
578                     if(SC_LAYER_INTERN != pSelected->GetLayer())
579 					{
580 						String aTitle(pSelected->GetTitle());
581 						String aDescription(pSelected->GetDescription());
582 
583 						SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
584 						OSL_ENSURE(pFact, "Dialogdiet fail!");
585 						AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
586 						OSL_ENSURE(pDlg, "Dialogdiet fail!");
587 
588 						if(RET_OK == pDlg->Execute())
589 						{
590 							ScDocShell* pDocSh = pViewData->GetDocShell();
591 
592 							// handle Title and Description
593 							pDlg->GetTitle(aTitle);
594 							pDlg->GetDescription(aDescription);
595 							pSelected->SetTitle(aTitle);
596 							pSelected->SetDescription(aDescription);
597 
598 							// ChartListenerCollectionNeedsUpdate is needed for Navigator update
599                             pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( sal_True );
600 							pDocSh->SetDrawModified();
601 						}
602 
603 						delete pDlg;
604 					}
605 				}
606 				break;
607 			}
608 
609 		case SID_EXTRUSION_TOOGLE:
610 		case SID_EXTRUSION_TILT_DOWN:
611 		case SID_EXTRUSION_TILT_UP:
612 		case SID_EXTRUSION_TILT_LEFT:
613 		case SID_EXTRUSION_TILT_RIGHT:
614 		case SID_EXTRUSION_3D_COLOR:
615 		case SID_EXTRUSION_DEPTH:
616 		case SID_EXTRUSION_DIRECTION:
617 		case SID_EXTRUSION_PROJECTION:
618 		case SID_EXTRUSION_LIGHTING_DIRECTION:
619 		case SID_EXTRUSION_LIGHTING_INTENSITY:
620 		case SID_EXTRUSION_SURFACE:
621 		case SID_EXTRUSION_DEPTH_FLOATER:
622 		case SID_EXTRUSION_DIRECTION_FLOATER:
623 		case SID_EXTRUSION_LIGHTING_FLOATER:
624 		case SID_EXTRUSION_SURFACE_FLOATER:
625 		case SID_EXTRUSION_DEPTH_DIALOG:
626 			svx::ExtrusionBar::execute( pView, rReq, rBindings );
627 			rReq.Ignore ();
628 			break;
629 
630 		case SID_FONTWORK_SHAPE:
631 		case SID_FONTWORK_SHAPE_TYPE:
632 		case SID_FONTWORK_ALIGNMENT:
633 		case SID_FONTWORK_SAME_LETTER_HEIGHTS:
634 		case SID_FONTWORK_CHARACTER_SPACING:
635 		case SID_FONTWORK_KERN_CHARACTER_PAIRS:
636 		case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
637 		case SID_FONTWORK_ALIGNMENT_FLOATER:
638 		case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
639 			svx::FontworkBar::execute( pView, rReq, rBindings );
640 			rReq.Ignore ();
641 			break;
642 
643         default:
644             break;
645     }
646 }
647 
648 IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
649 {
650     String aName;
651 
652     if( pDialog )
653         pDialog->GetName( aName );
654 
655 	ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
656 	if ( aName.Len() && pModel )
657 	{
658 		SCTAB nDummyTab;
659 		if ( pModel->GetNamedObject( aName, 0, nDummyTab ) )
660 		{
661 			// existing object found -> name invalid
662 			return 0;
663 		}
664 	}
665 
666     return 1;	// name is valid
667 }
668 
669 //------------------------------------------------------------------
670 
671 void ScDrawShell::ExecFormText(SfxRequest& rReq)
672 {
673     ScDrawView*         pDrView     = pViewData->GetScDrawView();
674     const SdrMarkList&  rMarkList   = pDrView->GetMarkedObjectList();
675 
676     if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
677     {
678         const SfxItemSet& rSet = *rReq.GetArgs();
679         const SfxPoolItem* pItem;
680 
681         if ( pDrView->IsTextEdit() )
682             pDrView->ScEndTextEdit();
683 
684         pDrView->SetAttributes(rSet);
685     }
686 }
687 
688 //------------------------------------------------------------------
689 
690 void ScDrawShell::ExecFormatPaintbrush( SfxRequest& rReq )
691 {
692     ScViewFunc* pView = pViewData->GetView();
693     if ( pView->HasPaintBrush() )
694     {
695         // cancel paintbrush mode
696         pView->ResetBrushDocument();
697     }
698     else
699     {
700         sal_Bool bLock = sal_False;
701         const SfxItemSet *pArgs = rReq.GetArgs();
702         if( pArgs && pArgs->Count() >= 1 )
703             bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
704 
705         ScDrawView* pDrawView = pViewData->GetScDrawView();
706         if ( pDrawView && pDrawView->AreObjectsMarked() )
707         {
708             sal_Bool bOnlyHardAttr = sal_True;
709             SfxItemSet* pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) );
710             pView->SetDrawBrushSet( pItemSet, bLock );
711         }
712     }
713 }
714 
715 void ScDrawShell::StateFormatPaintbrush( SfxItemSet& rSet )
716 {
717     ScDrawView* pDrawView = pViewData->GetScDrawView();
718     sal_Bool bSelection = pDrawView && pDrawView->AreObjectsMarked();
719     sal_Bool bHasPaintBrush = pViewData->GetView()->HasPaintBrush();
720 
721     if ( !bHasPaintBrush && !bSelection )
722         rSet.DisableItem( SID_FORMATPAINTBRUSH );
723     else
724         rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) );
725 }
726 
727 ScDrawView* ScDrawShell::GetDrawView()
728 {
729     return pViewData->GetView()->GetScDrawView();
730 }
731 
732 
733 
734 
735