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

Generated by: LCOV version 1.10