LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/drawfunc - drawsh5.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 329 0.3 %
Date: 2012-12-27 Functions: 2 11 18.2 %
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 <svx/svxdlg.hxx>
      27             : #include <svx/dialogs.hrc>
      28             : #include <svx/fmglob.hxx>
      29             : #include <svx/hlnkitem.hxx>
      30             : #include <svx/fontwork.hxx>
      31             : #include <svx/svdocapt.hxx>
      32             : #include <svx/svdoole2.hxx>
      33             : #include <svx/svdouno.hxx>
      34             : #include <svx/svdpage.hxx>
      35             : #include <svx/svdundo.hxx>
      36             : #include <svx/xdef.hxx>
      37             : #include <svx/xftsfit.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 :             rtl::OUString sPropButtonType(RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ));
      96           0 :             rtl::OUString sPropTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
      97           0 :             rtl::OUString sPropTargetFrame(RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" ));
      98           0 :             rtl::OUString sPropLabel(RTL_CONSTASCII_USTRINGPARAM( "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 :                     rtl::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 :                                 rtl::OUString sPropTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
     183             : 
     184             :                                 // Darf man eine URL an dem Objekt setzen?
     185           0 :                                 if (xInfo->hasPropertyByName( sPropTargetURL ))
     186             :                                 {
     187             :                                     // Ja!
     188             : 
     189           0 :                                     rtl::OUString sPropButtonType(RTL_CONSTASCII_USTRINGPARAM( "ButtonType") );
     190           0 :                                     rtl::OUString sPropTargetFrame(RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" ));
     191           0 :                                     rtl::OUString sPropLabel(RTL_CONSTASCII_USTRINGPARAM( "Label" ));
     192             : 
     193           0 :                                     uno::Any aAny;
     194           0 :                                     if ( xInfo->hasPropertyByName( sPropLabel ) )
     195             :                                     {
     196           0 :                                         aAny <<= rtl::OUString(rName);
     197           0 :                                         xPropSet->setPropertyValue( sPropLabel, aAny );
     198             :                                     }
     199             : 
     200           0 :                                     ::rtl::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 <<= rtl::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();       // wegen CLOOKs - in drtxtob2
     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           0 :             pView->MirrorAllMarkedHorizontal();
     308           0 :             break;
     309             :         case SID_MIRROR_VERTICAL:
     310           0 :             pView->MirrorAllMarkedVertical();
     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             :             OSL_FAIL( "SdrView::PasteClipboard not supported anymore" );
     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( sal_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( sal_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 :                         rtl::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 :                             String aTmp;
     502           0 :                             pDlg->GetName(aTmp);
     503           0 :                             aName = aTmp;
     504             : 
     505           0 :                             if (!aName.equals(pSelected->GetName()))
     506             :                             {
     507             :                                 // handle name change
     508           0 :                                 const sal_uInt16 nObjType(pSelected->GetObjIdentifier());
     509             : 
     510           0 :                                 if (OBJ_GRAF == nObjType && aName.isEmpty())
     511             :                                 {
     512             :                                     //  graphics objects must have names
     513             :                                     //  (all graphics are supposed to be in the navigator)
     514           0 :                                     ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
     515             : 
     516           0 :                                     if(pModel)
     517             :                                     {
     518           0 :                                         aName = pModel->GetNewGraphicName();
     519             :                                     }
     520             :                                 }
     521             : 
     522             :                                 //  An undo action for renaming is missing in svdraw (99363).
     523             :                                 //  For OLE objects (which can be identified using the persist name),
     524             :                                 //  ScUndoRenameObject can be used until there is a common action for all objects.
     525           0 :                                 if(OBJ_OLE2 == nObjType)
     526             :                                 {
     527           0 :                                     const String aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName();
     528             : 
     529           0 :                                     if(aPersistName.Len())
     530             :                                     {
     531           0 :                                         pDocSh->GetUndoManager()->AddUndoAction(
     532           0 :                                             new ScUndoRenameObject(pDocSh, aPersistName, pSelected->GetName(), aName));
     533           0 :                                     }
     534             :                                 }
     535             : 
     536             :                                 // set new name
     537           0 :                                 pSelected->SetName(aName);
     538             :                             }
     539             : 
     540             :                             // ChartListenerCollectionNeedsUpdate is needed for Navigator update
     541           0 :                             pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( sal_True );
     542           0 :                             pDocSh->SetDrawModified();
     543             :                         }
     544             : 
     545           0 :                         delete pDlg;
     546             :                     }
     547             :                 }
     548           0 :                 break;
     549             :             }
     550             : 
     551             :         // #i68101#
     552             :         case SID_TITLE_DESCRIPTION_OBJECT:
     553             :             {
     554           0 :                 if(1L == pView->GetMarkedObjectCount())
     555             :                 {
     556           0 :                     SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L);
     557             :                     OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
     558             : 
     559           0 :                     if(SC_LAYER_INTERN != pSelected->GetLayer())
     560             :                     {
     561           0 :                         String aTitle(pSelected->GetTitle());
     562           0 :                         String aDescription(pSelected->GetDescription());
     563             : 
     564           0 :                         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     565             :                         OSL_ENSURE(pFact, "Dialogdiet fail!");
     566           0 :                         AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
     567             :                         OSL_ENSURE(pDlg, "Dialogdiet fail!");
     568             : 
     569           0 :                         if(RET_OK == pDlg->Execute())
     570             :                         {
     571           0 :                             ScDocShell* pDocSh = pViewData->GetDocShell();
     572             : 
     573             :                             // handle Title and Description
     574           0 :                             pDlg->GetTitle(aTitle);
     575           0 :                             pDlg->GetDescription(aDescription);
     576           0 :                             pSelected->SetTitle(aTitle);
     577           0 :                             pSelected->SetDescription(aDescription);
     578             : 
     579             :                             // ChartListenerCollectionNeedsUpdate is needed for Navigator update
     580           0 :                             pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( sal_True );
     581           0 :                             pDocSh->SetDrawModified();
     582             :                         }
     583             : 
     584           0 :                         delete pDlg;
     585             :                     }
     586             :                 }
     587           0 :                 break;
     588             :             }
     589             : 
     590             :         case SID_EXTRUSION_TOOGLE:
     591             :         case SID_EXTRUSION_TILT_DOWN:
     592             :         case SID_EXTRUSION_TILT_UP:
     593             :         case SID_EXTRUSION_TILT_LEFT:
     594             :         case SID_EXTRUSION_TILT_RIGHT:
     595             :         case SID_EXTRUSION_3D_COLOR:
     596             :         case SID_EXTRUSION_DEPTH:
     597             :         case SID_EXTRUSION_DIRECTION:
     598             :         case SID_EXTRUSION_PROJECTION:
     599             :         case SID_EXTRUSION_LIGHTING_DIRECTION:
     600             :         case SID_EXTRUSION_LIGHTING_INTENSITY:
     601             :         case SID_EXTRUSION_SURFACE:
     602             :         case SID_EXTRUSION_DEPTH_FLOATER:
     603             :         case SID_EXTRUSION_DIRECTION_FLOATER:
     604             :         case SID_EXTRUSION_LIGHTING_FLOATER:
     605             :         case SID_EXTRUSION_SURFACE_FLOATER:
     606             :         case SID_EXTRUSION_DEPTH_DIALOG:
     607           0 :             svx::ExtrusionBar::execute( pView, rReq, rBindings );
     608           0 :             rReq.Ignore ();
     609           0 :             break;
     610             : 
     611             :         case SID_FONTWORK_SHAPE:
     612             :         case SID_FONTWORK_SHAPE_TYPE:
     613             :         case SID_FONTWORK_ALIGNMENT:
     614             :         case SID_FONTWORK_SAME_LETTER_HEIGHTS:
     615             :         case SID_FONTWORK_CHARACTER_SPACING:
     616             :         case SID_FONTWORK_KERN_CHARACTER_PAIRS:
     617             :         case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
     618             :         case SID_FONTWORK_ALIGNMENT_FLOATER:
     619             :         case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
     620           0 :             svx::FontworkBar::execute( pView, rReq, rBindings );
     621           0 :             rReq.Ignore ();
     622           0 :             break;
     623             : 
     624             :         default:
     625           0 :             break;
     626             :     }
     627           0 : }
     628             : 
     629           0 : IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
     630             : {
     631           0 :     String aName;
     632             : 
     633           0 :     if( pDialog )
     634           0 :         pDialog->GetName( aName );
     635             : 
     636           0 :     ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
     637           0 :     if ( aName.Len() && pModel )
     638             :     {
     639             :         SCTAB nDummyTab;
     640           0 :         if ( pModel->GetNamedObject( aName, 0, nDummyTab ) )
     641             :         {
     642             :             // existing object found -> name invalid
     643           0 :             return 0;
     644             :         }
     645             :     }
     646             : 
     647           0 :     return 1;   // name is valid
     648             : }
     649             : 
     650             : //------------------------------------------------------------------
     651             : 
     652           0 : void ScDrawShell::ExecFormText(SfxRequest& rReq)
     653             : {
     654           0 :     ScDrawView*         pDrView     = pViewData->GetScDrawView();
     655           0 :     const SdrMarkList&  rMarkList   = pDrView->GetMarkedObjectList();
     656             : 
     657           0 :     if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
     658             :     {
     659           0 :         const SfxItemSet& rSet = *rReq.GetArgs();
     660             :         const SfxPoolItem* pItem;
     661             : 
     662           0 :         if ( pDrView->IsTextEdit() )
     663           0 :             pDrView->ScEndTextEdit();
     664             : 
     665           0 :         if (    SFX_ITEM_SET ==
     666           0 :                 rSet.GetItemState(XATTR_FORMTXTSTDFORM, sal_True, &pItem)
     667             :              && XFTFORM_NONE !=
     668           0 :                 ((const XFormTextStdFormItem*) pItem)->GetValue() )
     669             :         {
     670             : 
     671           0 :             sal_uInt16 nId              = SvxFontWorkChildWindow::GetChildWindowId();
     672           0 :             SfxViewFrame* pViewFrm  = pViewData->GetViewShell()->GetViewFrame();
     673             :             SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)
     674             :                                        (pViewFrm->
     675           0 :                                             GetChildWindow(nId)->GetWindow());
     676             : 
     677           0 :             pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(),
     678           0 :                                     rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
     679             :                                    ((const XFormTextStdFormItem*) pItem)->
     680           0 :                                    GetValue());
     681             :         }
     682             :         else
     683           0 :             pDrView->SetAttributes(rSet);
     684             :     }
     685           0 : }
     686             : 
     687             : //------------------------------------------------------------------
     688             : 
     689           0 : void ScDrawShell::ExecFormatPaintbrush( SfxRequest& rReq )
     690             : {
     691           0 :     ScViewFunc* pView = pViewData->GetView();
     692           0 :     if ( pView->HasPaintBrush() )
     693             :     {
     694             :         // cancel paintbrush mode
     695           0 :         pView->ResetBrushDocument();
     696             :     }
     697             :     else
     698             :     {
     699           0 :         sal_Bool bLock = false;
     700           0 :         const SfxItemSet *pArgs = rReq.GetArgs();
     701           0 :         if( pArgs && pArgs->Count() >= 1 )
     702           0 :             bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
     703             : 
     704           0 :         ScDrawView* pDrawView = pViewData->GetScDrawView();
     705           0 :         if ( pDrawView && pDrawView->AreObjectsMarked() )
     706             :         {
     707           0 :             sal_Bool bOnlyHardAttr = sal_True;
     708           0 :             SfxItemSet* pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) );
     709           0 :             pView->SetDrawBrushSet( pItemSet, bLock );
     710             :         }
     711             :     }
     712           0 : }
     713             : 
     714           0 : void ScDrawShell::StateFormatPaintbrush( SfxItemSet& rSet )
     715             : {
     716           0 :     ScDrawView* pDrawView = pViewData->GetScDrawView();
     717           0 :     sal_Bool bSelection = pDrawView && pDrawView->AreObjectsMarked();
     718           0 :     sal_Bool bHasPaintBrush = pViewData->GetView()->HasPaintBrush();
     719             : 
     720           0 :     if ( !bHasPaintBrush && !bSelection )
     721           0 :         rSet.DisableItem( SID_FORMATPAINTBRUSH );
     722             :     else
     723           0 :         rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) );
     724           0 : }
     725             : 
     726           0 : ScDrawView* ScDrawShell::GetDrawView()
     727             : {
     728           0 :     return pViewData->GetView()->GetScDrawView();
     729          15 : }
     730             : 
     731             : 
     732             : 
     733             : 
     734             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10