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

Generated by: LCOV version 1.10