xref: /aoo4110/main/sc/source/ui/drawfunc/drawsh5.cxx (revision b1cdbd2c)
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 
GetHLinkState(SfxItemSet & rSet)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 
ExecuteHLink(SfxRequest & rReq)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 
ExecDrawFunc(SfxRequest & rReq)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         case SID_FLIP_HORIZONTAL:
328             pView->MirrorAllMarkedHorizontal();
329             rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
330             break;
331         case SID_MIRROR_VERTICAL:
332         case SID_FLIP_VERTICAL:
333             pView->MirrorAllMarkedVertical();
334             rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
335             break;
336 
337         case SID_OBJECT_ALIGN_LEFT:
338         case SID_ALIGN_ANY_LEFT:
339             if (pView->IsAlignPossible())
340                 pView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
341             break;
342         case SID_OBJECT_ALIGN_CENTER:
343         case SID_ALIGN_ANY_HCENTER:
344             if (pView->IsAlignPossible())
345                 pView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
346             break;
347         case SID_OBJECT_ALIGN_RIGHT:
348         case SID_ALIGN_ANY_RIGHT:
349             if (pView->IsAlignPossible())
350                 pView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
351             break;
352         case SID_OBJECT_ALIGN_UP:
353         case SID_ALIGN_ANY_TOP:
354             if (pView->IsAlignPossible())
355                 pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
356             break;
357         case SID_OBJECT_ALIGN_MIDDLE:
358         case SID_ALIGN_ANY_VCENTER:
359             if (pView->IsAlignPossible())
360                 pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
361             break;
362         case SID_OBJECT_ALIGN_DOWN:
363         case SID_ALIGN_ANY_BOTTOM:
364             if (pView->IsAlignPossible())
365                 pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
366             break;
367 
368         case SID_DELETE:
369         case SID_DELETE_CONTENTS:
370             pView->DeleteMarked();
371             pViewData->GetViewShell()->UpdateDrawShell();
372         break;
373 
374         case SID_CUT:
375             pView->DoCut();
376             pViewData->GetViewShell()->UpdateDrawShell();
377             break;
378 
379         case SID_COPY:
380             pView->DoCopy();
381             break;
382 
383         case SID_PASTE:
384             DBG_ERROR( "SdrView::PasteClipboard not supported anymore" );
385             // pView->PasteClipboard( pWin );
386             break;
387 
388         case SID_SELECTALL:
389             pView->MarkAll();
390             break;
391 
392         case SID_ANCHOR_PAGE:
393             pView->SetAnchor( SCA_PAGE );
394             rBindings.Invalidate( SID_ANCHOR_PAGE );
395             rBindings.Invalidate( SID_ANCHOR_CELL );
396             break;
397 
398         case SID_ANCHOR_CELL:
399             pView->SetAnchor( SCA_CELL );
400             rBindings.Invalidate( SID_ANCHOR_PAGE );
401             rBindings.Invalidate( SID_ANCHOR_CELL );
402             break;
403 
404         case SID_ANCHOR_TOGGLE:
405             {
406                 switch( pView->GetAnchor() )
407                 {
408                     case SCA_CELL:
409                     pView->SetAnchor( SCA_PAGE );
410                     break;
411                     default:
412                     pView->SetAnchor( SCA_CELL );
413                     break;
414                 }
415             }
416             rBindings.Invalidate( SID_ANCHOR_PAGE );
417             rBindings.Invalidate( SID_ANCHOR_CELL );
418             break;
419 
420         case SID_OBJECT_ROTATE:
421             {
422                 SdrDragMode eMode;
423                 if (pView->GetDragMode() == SDRDRAG_ROTATE)
424                     eMode = SDRDRAG_MOVE;
425                 else
426                     eMode = SDRDRAG_ROTATE;
427                 pView->SetDragMode( eMode );
428                 rBindings.Invalidate( SID_OBJECT_ROTATE );
429                 rBindings.Invalidate( SID_OBJECT_MIRROR );
430                 if (eMode == SDRDRAG_ROTATE && !pView->IsFrameDragSingles())
431                 {
432                     pView->SetFrameDragSingles( sal_True );
433                     rBindings.Invalidate( SID_BEZIER_EDIT );
434                 }
435             }
436             break;
437         case SID_OBJECT_MIRROR:
438             {
439                 SdrDragMode eMode;
440                 if (pView->GetDragMode() == SDRDRAG_MIRROR)
441                     eMode = SDRDRAG_MOVE;
442                 else
443                     eMode = SDRDRAG_MIRROR;
444                 pView->SetDragMode( eMode );
445                 rBindings.Invalidate( SID_OBJECT_ROTATE );
446                 rBindings.Invalidate( SID_OBJECT_MIRROR );
447                 if (eMode == SDRDRAG_MIRROR && !pView->IsFrameDragSingles())
448                 {
449                     pView->SetFrameDragSingles( sal_True );
450                     rBindings.Invalidate( SID_BEZIER_EDIT );
451                 }
452             }
453             break;
454         case SID_BEZIER_EDIT:
455             {
456                 sal_Bool bOld = pView->IsFrameDragSingles();
457                 pView->SetFrameDragSingles( !bOld );
458                 rBindings.Invalidate( SID_BEZIER_EDIT );
459                 if (bOld && pView->GetDragMode() != SDRDRAG_MOVE)
460                 {
461                     pView->SetDragMode( SDRDRAG_MOVE );
462                     rBindings.Invalidate( SID_OBJECT_ROTATE );
463                     rBindings.Invalidate( SID_OBJECT_MIRROR );
464                 }
465             }
466             break;
467 
468         case SID_FONTWORK:
469         {
470             sal_uInt16 nId = ScGetFontWorkId();
471             SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
472 
473             if ( rReq.GetArgs() )
474                 pViewFrm->SetChildWindow( nId,
475                                            ((const SfxBoolItem&)
476                                             (rReq.GetArgs()->Get(SID_FONTWORK))).
477                                                 GetValue() );
478             else
479                 pViewFrm->ToggleChildWindow( nId );
480 
481             rBindings.Invalidate( SID_FONTWORK );
482             rReq.Done();
483         }
484         break;
485 
486         case SID_ORIGINALSIZE:
487             pView->SetMarkedOriginalSize();
488             break;
489 
490 		case SID_ENABLE_HYPHENATION:
491 			{
492 				SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, sal_False);
493 				if( pItem )
494 				{
495 					SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
496 					sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
497 					aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
498 					pView->SetAttributes( aSet );
499 				}
500 				rReq.Done();
501 			}
502 			break;
503 
504 		case SID_RENAME_OBJECT:
505 			{
506 				if(1L == pView->GetMarkedObjectCount())
507 				{
508 					// #i68101#
509 					SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L);
510 					OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
511 
512                     if(SC_LAYER_INTERN != pSelected->GetLayer())
513 					{
514 						String aName(pSelected->GetName());
515 
516 						SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
517 						OSL_ENSURE(pFact, "Dialogdiet fail!");
518 						AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName);
519 						OSL_ENSURE(pDlg, "Dialogdiet fail!");
520 
521 						pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl));
522 
523 						if(RET_OK == pDlg->Execute())
524 						{
525 							ScDocShell* pDocSh = pViewData->GetDocShell();
526 							pDlg->GetName(aName);
527 
528 							if(aName != pSelected->GetName())
529 							{
530 								// handle name change
531 		                        const sal_uInt16 nObjType(pSelected->GetObjIdentifier());
532 
533 								if(OBJ_GRAF == nObjType && 0L == aName.Len())
534 								{
535 									//	graphics objects must have names
536 									//	(all graphics are supposed to be in the navigator)
537 									ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
538 
539 									if(pModel)
540 									{
541 										aName = pModel->GetNewGraphicName();
542 									}
543 								}
544 
545 								//	An undo action for renaming is missing in svdraw (99363).
546 								//	For OLE objects (which can be identified using the persist name),
547 								//	ScUndoRenameObject can be used until there is a common action for all objects.
548 								if(OBJ_OLE2 == nObjType)
549 								{
550 									const String aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName();
551 
552 									if(aPersistName.Len())
553 									{
554 										pDocSh->GetUndoManager()->AddUndoAction(
555 											new ScUndoRenameObject(pDocSh, aPersistName, pSelected->GetName(), aName));
556 									}
557 								}
558 
559 								// set new name
560 								pSelected->SetName(aName);
561 							}
562 
563 							// ChartListenerCollectionNeedsUpdate is needed for Navigator update
564                             pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( sal_True );
565 							pDocSh->SetDrawModified();
566 						}
567 
568 						delete pDlg;
569 					}
570 				}
571 				break;
572 			}
573 
574 		// #i68101#
575 		case SID_TITLE_DESCRIPTION_OBJECT:
576 			{
577 				if(1L == pView->GetMarkedObjectCount())
578 				{
579 					SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L);
580 					OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
581 
582                     if(SC_LAYER_INTERN != pSelected->GetLayer())
583 					{
584 						String aTitle(pSelected->GetTitle());
585 						String aDescription(pSelected->GetDescription());
586 
587 						SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
588 						OSL_ENSURE(pFact, "Dialogdiet fail!");
589 						AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
590 						OSL_ENSURE(pDlg, "Dialogdiet fail!");
591 
592 						if(RET_OK == pDlg->Execute())
593 						{
594 							ScDocShell* pDocSh = pViewData->GetDocShell();
595 
596 							// handle Title and Description
597 							pDlg->GetTitle(aTitle);
598 							pDlg->GetDescription(aDescription);
599 							pSelected->SetTitle(aTitle);
600 							pSelected->SetDescription(aDescription);
601 
602 							// ChartListenerCollectionNeedsUpdate is needed for Navigator update
603                             pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( sal_True );
604 							pDocSh->SetDrawModified();
605 						}
606 
607 						delete pDlg;
608 					}
609 				}
610 				break;
611 			}
612 
613 		case SID_EXTRUSION_TOOGLE:
614 		case SID_EXTRUSION_TILT_DOWN:
615 		case SID_EXTRUSION_TILT_UP:
616 		case SID_EXTRUSION_TILT_LEFT:
617 		case SID_EXTRUSION_TILT_RIGHT:
618 		case SID_EXTRUSION_3D_COLOR:
619 		case SID_EXTRUSION_DEPTH:
620 		case SID_EXTRUSION_DIRECTION:
621 		case SID_EXTRUSION_PROJECTION:
622 		case SID_EXTRUSION_LIGHTING_DIRECTION:
623 		case SID_EXTRUSION_LIGHTING_INTENSITY:
624 		case SID_EXTRUSION_SURFACE:
625 		case SID_EXTRUSION_DEPTH_FLOATER:
626 		case SID_EXTRUSION_DIRECTION_FLOATER:
627 		case SID_EXTRUSION_LIGHTING_FLOATER:
628 		case SID_EXTRUSION_SURFACE_FLOATER:
629 		case SID_EXTRUSION_DEPTH_DIALOG:
630 			svx::ExtrusionBar::execute( pView, rReq, rBindings );
631 			rReq.Ignore ();
632 			break;
633 
634 		case SID_FONTWORK_SHAPE:
635 		case SID_FONTWORK_SHAPE_TYPE:
636 		case SID_FONTWORK_ALIGNMENT:
637 		case SID_FONTWORK_SAME_LETTER_HEIGHTS:
638 		case SID_FONTWORK_CHARACTER_SPACING:
639 		case SID_FONTWORK_KERN_CHARACTER_PAIRS:
640 		case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
641 		case SID_FONTWORK_ALIGNMENT_FLOATER:
642 		case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
643 			svx::FontworkBar::execute( pView, rReq, rBindings );
644 			rReq.Ignore ();
645 			break;
646 
647         default:
648             break;
649     }
650 }
651 
IMPL_LINK(ScDrawShell,NameObjectHdl,AbstractSvxNameDialog *,pDialog)652 IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
653 {
654     String aName;
655 
656     if( pDialog )
657         pDialog->GetName( aName );
658 
659 	ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
660 	if ( aName.Len() && pModel )
661 	{
662 		SCTAB nDummyTab;
663 		if ( pModel->GetNamedObject( aName, 0, nDummyTab ) )
664 		{
665 			// existing object found -> name invalid
666 			return 0;
667 		}
668 	}
669 
670     return 1;	// name is valid
671 }
672 
673 //------------------------------------------------------------------
674 
ExecFormText(SfxRequest & rReq)675 void ScDrawShell::ExecFormText(SfxRequest& rReq)
676 {
677     ScDrawView*         pDrView     = pViewData->GetScDrawView();
678     const SdrMarkList&  rMarkList   = pDrView->GetMarkedObjectList();
679 
680     if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
681     {
682         const SfxItemSet& rSet = *rReq.GetArgs();
683 
684         if ( pDrView->IsTextEdit() )
685             pDrView->ScEndTextEdit();
686 
687         pDrView->SetAttributes(rSet);
688     }
689 }
690 
691 //------------------------------------------------------------------
692 
ExecFormatPaintbrush(SfxRequest & rReq)693 void ScDrawShell::ExecFormatPaintbrush( SfxRequest& rReq )
694 {
695     ScViewFunc* pView = pViewData->GetView();
696     if ( pView->HasPaintBrush() )
697     {
698         // cancel paintbrush mode
699         pView->ResetBrushDocument();
700     }
701     else
702     {
703         sal_Bool bLock = sal_False;
704         const SfxItemSet *pArgs = rReq.GetArgs();
705         if( pArgs && pArgs->Count() >= 1 )
706             bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
707 
708         ScDrawView* pDrawView = pViewData->GetScDrawView();
709         if ( pDrawView && pDrawView->AreObjectsMarked() )
710         {
711             sal_Bool bOnlyHardAttr = sal_True;
712             SfxItemSet* pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) );
713             pView->SetDrawBrushSet( pItemSet, bLock );
714         }
715     }
716 }
717 
StateFormatPaintbrush(SfxItemSet & rSet)718 void ScDrawShell::StateFormatPaintbrush( SfxItemSet& rSet )
719 {
720     ScDrawView* pDrawView = pViewData->GetScDrawView();
721     sal_Bool bSelection = pDrawView && pDrawView->AreObjectsMarked();
722     sal_Bool bHasPaintBrush = pViewData->GetView()->HasPaintBrush();
723 
724     if ( !bHasPaintBrush && !bSelection )
725         rSet.DisableItem( SID_FORMATPAINTBRUSH );
726     else
727         rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) );
728 }
729 
GetDrawView()730 ScDrawView* ScDrawShell::GetDrawView()
731 {
732     return pViewData->GetView()->GetScDrawView();
733 }
734 
735 
736 
737 
738