LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/drawfunc - drawsh5.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 323 0.9 %
Date: 2013-07-09 Functions: 3 11 27.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10