LCOV - code coverage report
Current view: top level - chart2/source/controller/main - ShapeController.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 369 0.0 %
Date: 2014-04-14 Functions: 0 26 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 "ShapeController.hxx"
      21             : #include "ShapeController.hrc"
      22             : #include "ChartController.hxx"
      23             : #include "ChartWindow.hxx"
      24             : #include "ViewElementListProvider.hxx"
      25             : #include "dlg_ShapeFont.hxx"
      26             : #include "dlg_ShapeParagraph.hxx"
      27             : #include "chartview/DrawModelWrapper.hxx"
      28             : #include "macros.hxx"
      29             : 
      30             : #include <com/sun/star/frame/XStorable.hpp>
      31             : 
      32             : #include <osl/mutex.hxx>
      33             : #include <vcl/msgbox.hxx>
      34             : #include <vcl/svapp.hxx>
      35             : #include <editeng/formatbreakitem.hxx>
      36             : #include <svx/dialogs.hrc>
      37             : #include <svx/drawitem.hxx>
      38             : #include <editeng/eeitem.hxx>
      39             : #include <editeng/hyphenzoneitem.hxx>
      40             : #include <editeng/orphitem.hxx>
      41             : #include <editeng/spltitem.hxx>
      42             : #include <svx/svxdlg.hxx>
      43             : #include <editeng/widwitem.hxx>
      44             : 
      45             : #include <boost/scoped_ptr.hpp>
      46             : 
      47             : using namespace ::com::sun::star;
      48             : using namespace ::com::sun::star::frame;
      49             : 
      50             : using ::com::sun::star::uno::Reference;
      51             : using ::com::sun::star::uno::Sequence;
      52             : 
      53             : namespace chart
      54             : {
      55             : 
      56           0 : ShapeController::ShapeController( const Reference< uno::XComponentContext >& rxContext,
      57             :         ChartController* pController )
      58             :     :FeatureCommandDispatchBase( rxContext )
      59           0 :     ,m_pChartController( pController )
      60             : {
      61           0 : }
      62             : 
      63           0 : ShapeController::~ShapeController()
      64             : {
      65           0 : }
      66             : 
      67           0 : void ShapeController::initialize()
      68             : {
      69           0 :     FeatureCommandDispatchBase::initialize();
      70           0 : }
      71             : 
      72             : // WeakComponentImplHelperBase
      73           0 : void ShapeController::disposing()
      74             : {
      75           0 : }
      76             : 
      77             : // XEventListener
      78           0 : void ShapeController::disposing( const lang::EventObject& /* Source */ )
      79             :     throw (uno::RuntimeException, std::exception)
      80             : {
      81           0 : }
      82             : 
      83           0 : FeatureState ShapeController::getState( const OUString& rCommand )
      84             : {
      85           0 :     FeatureState aReturn;
      86           0 :     aReturn.bEnabled = false;
      87           0 :     aReturn.aState <<= false;
      88             : 
      89           0 :     bool bWritable = false;
      90           0 :     if ( m_pChartController )
      91             :     {
      92           0 :         Reference< frame::XStorable > xStorable( m_pChartController->getModel(), uno::UNO_QUERY );
      93           0 :         if ( xStorable.is() )
      94             :         {
      95           0 :             bWritable = !xStorable->isReadonly();
      96           0 :         }
      97             :     }
      98             : 
      99           0 :     SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand );
     100           0 :     if ( aIter != m_aSupportedFeatures.end() )
     101             :     {
     102           0 :         sal_uInt16 nFeatureId = aIter->second.nFeatureId;
     103           0 :         switch ( nFeatureId )
     104             :         {
     105             :             case COMMAND_ID_FORMAT_LINE:
     106             :             case COMMAND_ID_FORMAT_AREA:
     107             :             case COMMAND_ID_TEXT_ATTRIBUTES:
     108             :             case COMMAND_ID_TRANSFORM_DIALOG:
     109             :             case COMMAND_ID_OBJECT_TITLE_DESCRIPTION:
     110             :             case COMMAND_ID_RENAME_OBJECT:
     111             :                 {
     112           0 :                     aReturn.bEnabled = bWritable;
     113           0 :                     aReturn.aState <<= false;
     114             :                 }
     115           0 :                 break;
     116             :             case COMMAND_ID_BRING_TO_FRONT:
     117             :             case COMMAND_ID_FORWARD:
     118             :                 {
     119           0 :                     aReturn.bEnabled = ( bWritable && isForwardPossible() );
     120           0 :                     aReturn.aState <<= false;
     121             :                 }
     122           0 :                 break;
     123             :             case COMMAND_ID_BACKWARD:
     124             :             case COMMAND_ID_SEND_TO_BACK:
     125             :                 {
     126             : 
     127           0 :                     aReturn.bEnabled = ( bWritable && isBackwardPossible() );
     128           0 :                     aReturn.aState <<= false;
     129             :                 }
     130           0 :                 break;
     131             :             case COMMAND_ID_FONT_DIALOG:
     132             :             case COMMAND_ID_PARAGRAPH_DIALOG:
     133             :                 {
     134           0 :                     aReturn.bEnabled = bWritable;
     135           0 :                     aReturn.aState <<= false;
     136             :                 }
     137           0 :                 break;
     138             :             default:
     139             :                 {
     140           0 :                     aReturn.bEnabled = false;
     141           0 :                     aReturn.aState <<= false;
     142             :                 }
     143           0 :                 break;
     144             :         }
     145             :     }
     146             : 
     147           0 :     return aReturn;
     148             : }
     149             : 
     150           0 : void ShapeController::execute( const OUString& rCommand, const Sequence< beans::PropertyValue>& rArgs )
     151             : {
     152             :     (void)rArgs;
     153             : 
     154           0 :     SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand );
     155           0 :     if ( aIter != m_aSupportedFeatures.end() )
     156             :     {
     157           0 :         sal_uInt16 nFeatureId = aIter->second.nFeatureId;
     158           0 :         switch ( nFeatureId )
     159             :         {
     160             :             case COMMAND_ID_FORMAT_LINE:
     161             :                 {
     162           0 :                     executeDispatch_FormatLine();
     163             :                 }
     164           0 :                 break;
     165             :             case COMMAND_ID_FORMAT_AREA:
     166             :                 {
     167           0 :                     executeDispatch_FormatArea();
     168             :                 }
     169           0 :                 break;
     170             :             case COMMAND_ID_TEXT_ATTRIBUTES:
     171             :                 {
     172           0 :                     executeDispatch_TextAttributes();
     173             :                 }
     174           0 :                 break;
     175             :             case COMMAND_ID_TRANSFORM_DIALOG:
     176             :                 {
     177           0 :                     executeDispatch_TransformDialog();
     178             :                 }
     179           0 :                 break;
     180             :             case COMMAND_ID_OBJECT_TITLE_DESCRIPTION:
     181             :                 {
     182           0 :                     executeDispatch_ObjectTitleDescription();
     183             :                 }
     184           0 :                 break;
     185             :             case COMMAND_ID_RENAME_OBJECT:
     186             :                 {
     187           0 :                     executeDispatch_RenameObject();
     188             :                 }
     189           0 :                 break;
     190             :             case COMMAND_ID_BRING_TO_FRONT:
     191             :             case COMMAND_ID_FORWARD:
     192             :             case COMMAND_ID_BACKWARD:
     193             :             case COMMAND_ID_SEND_TO_BACK:
     194             :                 {
     195           0 :                     executeDispatch_ChangeZOrder( nFeatureId );
     196             :                 }
     197           0 :                 break;
     198             :             case COMMAND_ID_FONT_DIALOG:
     199             :                 {
     200           0 :                     executeDispatch_FontDialog();
     201             :                 }
     202           0 :                 break;
     203             :             case COMMAND_ID_PARAGRAPH_DIALOG:
     204             :                 {
     205           0 :                     executeDispatch_ParagraphDialog();
     206             :                 }
     207           0 :                 break;
     208             :             default:
     209             :                 {
     210             :                 }
     211           0 :                 break;
     212             :         }
     213             :     }
     214           0 : }
     215             : 
     216           0 : void ShapeController::describeSupportedFeatures()
     217             : {
     218           0 :     implDescribeSupportedFeature( ".uno:FormatLine",                COMMAND_ID_FORMAT_LINE,                 CommandGroup::FORMAT );
     219           0 :     implDescribeSupportedFeature( ".uno:FormatArea",                COMMAND_ID_FORMAT_AREA,                 CommandGroup::FORMAT );
     220           0 :     implDescribeSupportedFeature( ".uno:TextAttributes",            COMMAND_ID_TEXT_ATTRIBUTES,             CommandGroup::FORMAT );
     221           0 :     implDescribeSupportedFeature( ".uno:TransformDialog",           COMMAND_ID_TRANSFORM_DIALOG,            CommandGroup::FORMAT );
     222           0 :     implDescribeSupportedFeature( ".uno:ObjectTitleDescription",    COMMAND_ID_OBJECT_TITLE_DESCRIPTION,    CommandGroup::FORMAT );
     223           0 :     implDescribeSupportedFeature( ".uno:RenameObject",              COMMAND_ID_RENAME_OBJECT,               CommandGroup::FORMAT );
     224           0 :     implDescribeSupportedFeature( ".uno:BringToFront",              COMMAND_ID_BRING_TO_FRONT,              CommandGroup::FORMAT );
     225           0 :     implDescribeSupportedFeature( ".uno:Forward",                   COMMAND_ID_FORWARD,                     CommandGroup::FORMAT );
     226           0 :     implDescribeSupportedFeature( ".uno:Backward",                  COMMAND_ID_BACKWARD,                    CommandGroup::FORMAT );
     227           0 :     implDescribeSupportedFeature( ".uno:SendToBack",                COMMAND_ID_SEND_TO_BACK,                CommandGroup::FORMAT );
     228           0 :     implDescribeSupportedFeature( ".uno:FontDialog",                COMMAND_ID_FONT_DIALOG,                 CommandGroup::EDIT );
     229           0 :     implDescribeSupportedFeature( ".uno:ParagraphDialog",           COMMAND_ID_PARAGRAPH_DIALOG,            CommandGroup::EDIT );
     230           0 : }
     231             : 
     232           0 : IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxNameDialog*, pDialog )
     233             : {
     234           0 :     OUString aName;
     235           0 :     if ( pDialog )
     236             :     {
     237           0 :         pDialog->GetName( aName );
     238             :     }
     239           0 :     if ( !aName.isEmpty() )
     240             :     {
     241           0 :         DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
     242           0 :         if ( pDrawViewWrapper && pDrawViewWrapper->getNamedSdrObject( aName ) )
     243             :         {
     244           0 :             return 0;
     245             :         }
     246             :     }
     247           0 :     return 1;
     248             : }
     249             : 
     250           0 : void ShapeController::executeDispatch_FormatLine()
     251             : {
     252           0 :     SolarMutexGuard aGuard;
     253           0 :     if ( m_pChartController )
     254             :     {
     255           0 :         Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
     256           0 :         DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
     257           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     258           0 :         if ( pParent && pDrawModelWrapper && pDrawViewWrapper )
     259             :         {
     260           0 :             SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
     261           0 :             SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
     262           0 :             sal_Bool bHasMarked = pDrawViewWrapper->AreObjectsMarked();
     263           0 :             if ( bHasMarked )
     264             :             {
     265           0 :                 pDrawViewWrapper->MergeAttrFromMarked( aAttr, false );
     266             :             }
     267           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     268           0 :             if ( pFact )
     269             :             {
     270             :                 ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
     271           0 :                     pFact->CreateSvxLineTabDialog( pParent, &aAttr, &pDrawModelWrapper->getSdrModel(),
     272           0 :                         pSelectedObj, bHasMarked ) );
     273           0 :                 if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
     274             :                 {
     275           0 :                     const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
     276           0 :                     if ( bHasMarked )
     277             :                     {
     278           0 :                         pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false );
     279             :                     }
     280             :                     else
     281             :                     {
     282           0 :                         pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
     283             :                     }
     284           0 :                 }
     285           0 :             }
     286             :         }
     287           0 :     }
     288           0 : }
     289             : 
     290           0 : void ShapeController::executeDispatch_FormatArea()
     291             : {
     292           0 :     SolarMutexGuard aGuard;
     293           0 :     if ( m_pChartController )
     294             :     {
     295           0 :         Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
     296           0 :         DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
     297           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     298           0 :         if ( pParent && pDrawModelWrapper && pDrawViewWrapper )
     299             :         {
     300           0 :             SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
     301           0 :             sal_Bool bHasMarked = pDrawViewWrapper->AreObjectsMarked();
     302           0 :             if ( bHasMarked )
     303             :             {
     304           0 :                 pDrawViewWrapper->MergeAttrFromMarked( aAttr, false );
     305             :             }
     306           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     307           0 :             if ( pFact )
     308             :             {
     309             :                 ::boost::scoped_ptr< AbstractSvxAreaTabDialog > pDlg(
     310           0 :                     pFact->CreateSvxAreaTabDialog( pParent, &aAttr, &pDrawModelWrapper->getSdrModel(), true ) );
     311           0 :                 if ( pDlg.get() )
     312             :                 {
     313           0 :                     SfxItemPool& rItemPool = pDrawViewWrapper->GetModel()->GetItemPool();
     314           0 :                     SfxItemSet aSet( rItemPool, rItemPool.GetFirstWhich(), rItemPool.GetLastWhich() );
     315           0 :                     if ( pDlg->Execute() == RET_OK )
     316             :                     {
     317           0 :                         const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
     318           0 :                         if ( bHasMarked )
     319             :                         {
     320           0 :                             pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false );
     321             :                         }
     322             :                         else
     323             :                         {
     324           0 :                             pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
     325             :                         }
     326           0 :                     }
     327           0 :                 }
     328           0 :             }
     329             :         }
     330           0 :     }
     331           0 : }
     332             : 
     333           0 : void ShapeController::executeDispatch_TextAttributes()
     334             : {
     335           0 :     SolarMutexGuard aGuard;
     336           0 :     if ( m_pChartController )
     337             :     {
     338           0 :         Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
     339           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     340           0 :         if ( pParent && pDrawViewWrapper )
     341             :         {
     342           0 :             SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
     343           0 :             sal_Bool bHasMarked = pDrawViewWrapper->AreObjectsMarked();
     344           0 :             if ( bHasMarked )
     345             :             {
     346           0 :                 pDrawViewWrapper->MergeAttrFromMarked( aAttr, false );
     347             :             }
     348           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     349           0 :             if ( pFact )
     350             :             {
     351             :                 ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
     352           0 :                     pFact->CreateTextTabDialog( pParent, &aAttr, pDrawViewWrapper ) );
     353           0 :                 if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
     354             :                 {
     355           0 :                     const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
     356           0 :                     if ( bHasMarked )
     357             :                     {
     358           0 :                         pDrawViewWrapper->SetAttributes( *pOutAttr );
     359             :                     }
     360             :                     else
     361             :                     {
     362           0 :                         pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
     363             :                     }
     364           0 :                 }
     365           0 :             }
     366             :         }
     367           0 :     }
     368           0 : }
     369             : 
     370           0 : void ShapeController::executeDispatch_TransformDialog()
     371             : {
     372           0 :     SolarMutexGuard aGuard;
     373           0 :     if ( m_pChartController )
     374             :     {
     375           0 :         Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
     376           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     377           0 :         if ( pParent && pDrawViewWrapper )
     378             :         {
     379           0 :             SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
     380           0 :             if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == OBJ_CAPTION )
     381             :             {
     382             :                 // item set for caption
     383           0 :                 SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() );
     384           0 :                 pDrawViewWrapper->GetAttributes( aAttr );
     385             :                 // item set for position and size
     386           0 :                 SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() );
     387           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     388           0 :                 if ( pFact )
     389             :                 {
     390             :                     ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
     391           0 :                         pFact->CreateCaptionDialog( pParent, pDrawViewWrapper ) );
     392           0 :                     if ( pDlg.get() )
     393             :                     {
     394           0 :                         const sal_uInt16* pRange = pDlg->GetInputRanges( *aAttr.GetPool() );
     395           0 :                         SfxItemSet aCombAttr( *aAttr.GetPool(), pRange );
     396           0 :                         aCombAttr.Put( aAttr );
     397           0 :                         aCombAttr.Put( aGeoAttr );
     398           0 :                         pDlg->SetInputSet( &aCombAttr );
     399           0 :                         if ( pDlg->Execute() == RET_OK )
     400             :                         {
     401           0 :                             const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
     402           0 :                             pDrawViewWrapper->SetAttributes( *pOutAttr );
     403           0 :                             pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr );
     404           0 :                         }
     405           0 :                     }
     406           0 :                 }
     407             :             }
     408             :             else
     409             :             {
     410           0 :                 SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() );
     411           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     412           0 :                 if ( pFact )
     413             :                 {
     414             :                     ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
     415           0 :                         pFact->CreateSvxTransformTabDialog( pParent, &aGeoAttr, pDrawViewWrapper ) );
     416           0 :                     if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
     417             :                     {
     418           0 :                         const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
     419           0 :                         pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr );
     420           0 :                     }
     421           0 :                 }
     422             :             }
     423             :         }
     424           0 :     }
     425           0 : }
     426             : 
     427           0 : void ShapeController::executeDispatch_ObjectTitleDescription()
     428             : {
     429           0 :     SolarMutexGuard aGuard;
     430           0 :     if ( m_pChartController )
     431             :     {
     432           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     433           0 :         if ( pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1 )
     434             :         {
     435           0 :             SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
     436           0 :             if ( pSelectedObj )
     437             :             {
     438           0 :                 OUString aTitle( pSelectedObj->GetTitle() );
     439           0 :                 OUString aDescription( pSelectedObj->GetDescription() );
     440           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     441           0 :                 if ( pFact )
     442             :                 {
     443             :                     ::boost::scoped_ptr< AbstractSvxObjectTitleDescDialog > pDlg(
     444           0 :                         pFact->CreateSvxObjectTitleDescDialog( NULL, aTitle, aDescription ) );
     445           0 :                     if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
     446             :                     {
     447           0 :                         pDlg->GetTitle( aTitle );
     448           0 :                         pDlg->GetDescription( aDescription );
     449           0 :                         pSelectedObj->SetTitle( aTitle );
     450           0 :                         pSelectedObj->SetDescription( aDescription );
     451           0 :                     }
     452           0 :                 }
     453             :             }
     454             :         }
     455           0 :     }
     456           0 : }
     457             : 
     458           0 : void ShapeController::executeDispatch_RenameObject()
     459             : {
     460           0 :     SolarMutexGuard aGuard;
     461           0 :     if ( m_pChartController )
     462             :     {
     463           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     464           0 :         if ( pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1 )
     465             :         {
     466           0 :             SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
     467           0 :             if ( pSelectedObj )
     468             :             {
     469           0 :                 OUString aName = pSelectedObj->GetName();
     470           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     471           0 :                 if ( pFact )
     472             :                 {
     473             :                     ::boost::scoped_ptr< AbstractSvxObjectNameDialog > pDlg(
     474           0 :                         pFact->CreateSvxObjectNameDialog( NULL, aName ) );
     475           0 :                     pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) );
     476           0 :                     if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
     477             :                     {
     478           0 :                         pDlg->GetName(aName);
     479           0 :                         if (pSelectedObj->GetName().equals(aName))
     480             :                         {
     481           0 :                             pSelectedObj->SetName( aName );
     482             :                         }
     483           0 :                     }
     484           0 :                 }
     485             :             }
     486             :         }
     487           0 :     }
     488           0 : }
     489             : 
     490           0 : void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId )
     491             : {
     492           0 :     SolarMutexGuard aGuard;
     493           0 :     DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
     494           0 :     if ( pDrawViewWrapper )
     495             :     {
     496           0 :         switch ( nId )
     497             :         {
     498             :             case COMMAND_ID_BRING_TO_FRONT:
     499             :                 {
     500           0 :                     if ( isForwardPossible() )
     501             :                     {
     502           0 :                         pDrawViewWrapper->PutMarkedToTop();
     503             :                     }
     504             :                 }
     505           0 :                 break;
     506             :             case COMMAND_ID_FORWARD:
     507             :                 {
     508           0 :                     if ( isForwardPossible() )
     509             :                     {
     510           0 :                         pDrawViewWrapper->MovMarkedToTop();
     511             :                     }
     512             :                 }
     513           0 :                 break;
     514             :             case COMMAND_ID_BACKWARD:
     515             :                 {
     516           0 :                     if ( isBackwardPossible() )
     517             :                     {
     518           0 :                         pDrawViewWrapper->MovMarkedToBtm();
     519             :                     }
     520             :                 }
     521           0 :                 break;
     522             :             case COMMAND_ID_SEND_TO_BACK:
     523             :                 {
     524           0 :                     if ( isBackwardPossible() )
     525             :                     {
     526           0 :                         SdrObject* pFirstObj = getFirstAdditionalShape();
     527           0 :                         pDrawViewWrapper->PutMarkedBehindObj( pFirstObj );
     528             :                     }
     529             :                 }
     530           0 :                 break;
     531             :             default:
     532             :                 {
     533             :                 }
     534           0 :                 break;
     535             :         }
     536           0 :     }
     537           0 : }
     538             : 
     539           0 : void ShapeController::executeDispatch_FontDialog()
     540             : {
     541           0 :     SolarMutexGuard aGuard;
     542           0 :     if ( m_pChartController )
     543             :     {
     544           0 :         Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
     545           0 :         DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
     546           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     547           0 :         if ( pParent && pDrawModelWrapper && pDrawViewWrapper )
     548             :         {
     549           0 :             SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() );
     550           0 :             pDrawViewWrapper->GetAttributes( aAttr );
     551           0 :             ViewElementListProvider aViewElementListProvider( pDrawModelWrapper );
     552           0 :             ::boost::scoped_ptr< ShapeFontDialog > pDlg( new ShapeFontDialog( pParent, &aAttr, &aViewElementListProvider ) );
     553           0 :             if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
     554             :             {
     555           0 :                 const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
     556           0 :                 pDrawViewWrapper->SetAttributes( *pOutAttr );
     557           0 :             }
     558             :         }
     559           0 :     }
     560           0 : }
     561             : 
     562           0 : void ShapeController::executeDispatch_ParagraphDialog()
     563             : {
     564           0 :     SolarMutexGuard aGuard;
     565           0 :     if ( m_pChartController )
     566             :     {
     567           0 :         Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
     568           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     569           0 :         if ( pParent && pDrawViewWrapper )
     570             :         {
     571           0 :             SfxItemPool& rPool = pDrawViewWrapper->GetModel()->GetItemPool();
     572           0 :             SfxItemSet aAttr( rPool );
     573           0 :             pDrawViewWrapper->GetAttributes( aAttr );
     574             : 
     575             :             SfxItemSet aNewAttr( rPool,
     576             :                                     EE_ITEMS_START, EE_ITEMS_END,
     577             :                                     SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
     578             :                                     SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_PAGEBREAK,
     579             :                                     SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
     580             :                                     SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
     581             :                                     SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
     582           0 :                                     0 );
     583           0 :             aNewAttr.Put( aAttr );
     584           0 :             aNewAttr.Put( SvxHyphenZoneItem( false, SID_ATTR_PARA_HYPHENZONE ) );
     585           0 :             aNewAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, SID_ATTR_PARA_PAGEBREAK ) );
     586           0 :             aNewAttr.Put( SvxFmtSplitItem( true, SID_ATTR_PARA_SPLIT)  );
     587           0 :             aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) );
     588           0 :             aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) );
     589             : 
     590           0 :             ::boost::scoped_ptr< ShapeParagraphDialog > pDlg( new ShapeParagraphDialog( pParent, &aNewAttr ) );
     591           0 :             if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
     592             :             {
     593           0 :                 const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
     594           0 :                 pDrawViewWrapper->SetAttributes( *pOutAttr );
     595           0 :             }
     596             :         }
     597           0 :     }
     598           0 : }
     599             : 
     600           0 : SdrObject* ShapeController::getFirstAdditionalShape()
     601             : {
     602           0 :     SdrObject* pFirstObj = NULL;
     603             : 
     604             :     try
     605             :     {
     606           0 :         DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : NULL );
     607           0 :         if ( pDrawModelWrapper )
     608             :         {
     609           0 :             Reference< drawing::XShape > xFirstShape;
     610           0 :             Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() );
     611           0 :             Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW );
     612           0 :             Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
     613           0 :             sal_Int32 nCount = xDrawPageShapes->getCount();
     614           0 :             for ( sal_Int32 i = 0; i < nCount; ++i )
     615             :             {
     616           0 :                 Reference< drawing::XShape > xShape;
     617           0 :                 if ( xDrawPageShapes->getByIndex( i ) >>= xShape )
     618             :                 {
     619           0 :                     if ( xShape.is() && xShape != xChartRoot )
     620             :                     {
     621           0 :                         xFirstShape = xShape;
     622           0 :                         break;
     623             :                     }
     624             :                 }
     625           0 :             }
     626           0 :             if ( xFirstShape.is() )
     627             :             {
     628           0 :                 pFirstObj = DrawViewWrapper::getSdrObject( xFirstShape );
     629           0 :             }
     630             :         }
     631             :     }
     632           0 :     catch ( const uno::Exception& ex )
     633             :     {
     634             :         ASSERT_EXCEPTION( ex );
     635             :     }
     636             : 
     637           0 :     return pFirstObj;
     638             : }
     639             : 
     640           0 : SdrObject* ShapeController::getLastAdditionalShape()
     641             : {
     642           0 :     SdrObject* pLastObj = NULL;
     643             : 
     644             :     try
     645             :     {
     646           0 :         DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : NULL );
     647           0 :         if ( pDrawModelWrapper )
     648             :         {
     649           0 :             Reference< drawing::XShape > xLastShape;
     650           0 :             Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() );
     651           0 :             Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW );
     652           0 :             Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
     653           0 :             sal_Int32 nCount = xDrawPageShapes->getCount();
     654           0 :             for ( sal_Int32 i = nCount - 1; i >= 0; --i )
     655             :             {
     656           0 :                 Reference< drawing::XShape > xShape;
     657           0 :                 if ( xDrawPageShapes->getByIndex( i ) >>= xShape )
     658             :                 {
     659           0 :                     if ( xShape.is() && xShape != xChartRoot )
     660             :                     {
     661           0 :                         xLastShape = xShape;
     662           0 :                         break;
     663             :                     }
     664             :                 }
     665           0 :             }
     666           0 :             if ( xLastShape.is() )
     667             :             {
     668           0 :                 pLastObj = DrawViewWrapper::getSdrObject( xLastShape );
     669           0 :             }
     670             :         }
     671             :     }
     672           0 :     catch ( const uno::Exception& ex )
     673             :     {
     674             :         ASSERT_EXCEPTION( ex );
     675             :     }
     676             : 
     677           0 :     return pLastObj;
     678             : }
     679             : 
     680           0 : bool ShapeController::isBackwardPossible()
     681             : {
     682           0 :     if ( m_pChartController && m_pChartController->m_aSelection.isAdditionalShapeSelected() )
     683             :     {
     684           0 :         SolarMutexGuard aGuard;
     685           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     686           0 :         if ( pDrawViewWrapper )
     687             :         {
     688           0 :             SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
     689           0 :             SdrObject* pFirstObj = getFirstAdditionalShape();
     690           0 :             if ( pSelectedObj && pFirstObj && pSelectedObj != pFirstObj )
     691             :             {
     692           0 :                 return true;
     693             :             }
     694           0 :         }
     695             :     }
     696           0 :     return false;
     697             : }
     698             : 
     699           0 : bool ShapeController::isForwardPossible()
     700             : {
     701           0 :     if ( m_pChartController && m_pChartController->m_aSelection.isAdditionalShapeSelected() )
     702             :     {
     703           0 :         SolarMutexGuard aGuard;
     704           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     705           0 :         if ( pDrawViewWrapper )
     706             :         {
     707           0 :             SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
     708           0 :             SdrObject* pLastObj = getLastAdditionalShape();
     709           0 :             if ( pSelectedObj && pLastObj && pSelectedObj != pLastObj )
     710             :             {
     711           0 :                 return true;
     712             :             }
     713           0 :         }
     714             :     }
     715           0 :     return false;
     716             : }
     717             : 
     718           0 : } //  namespace chart
     719             : 
     720             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10