LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/main - DrawCommandDispatch.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 315 0.0 %
Date: 2012-12-27 Functions: 0 17 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             : 
      21             : #include "DrawCommandDispatch.hxx"
      22             : #include "DrawCommandDispatch.hrc"
      23             : #include "ChartController.hxx"
      24             : #include "DrawViewWrapper.hxx"
      25             : #include "chartview/DrawModelWrapper.hxx"
      26             : #include "macros.hxx"
      27             : 
      28             : #include <osl/mutex.hxx>
      29             : #include <vcl/svapp.hxx>
      30             : #include <svl/itempool.hxx>
      31             : #include <editeng/adjitem.hxx>
      32             : #include <svx/dialogs.hrc>
      33             : #include <svx/dialmgr.hxx>
      34             : #include <svx/fmmodel.hxx>
      35             : #include <svx/gallery.hxx>
      36             : #include <svx/svdoashp.hxx>
      37             : #include <svx/svdocapt.hxx>
      38             : #include <svx/svdopath.hxx>
      39             : #include <svx/svdpage.hxx>
      40             : #include <svx/unoapi.hxx>
      41             : #include <svx/xlnedit.hxx>
      42             : #include <svx/xlnedwit.hxx>
      43             : #include <svx/xlnwtit.hxx>
      44             : #include <svx/xtable.hxx>
      45             : #include <basegfx/polygon/b2dpolygon.hxx>
      46             : 
      47             : #include <boost/ref.hpp>
      48             : 
      49             : using namespace ::com::sun::star;
      50             : using namespace ::com::sun::star::frame;
      51             : 
      52             : using ::com::sun::star::uno::Reference;
      53             : using ::com::sun::star::uno::Sequence;
      54             : 
      55             : 
      56             : //.............................................................................
      57             : namespace
      58             : {
      59             : //.............................................................................
      60             : 
      61             :     // comparing two PropertyValue instances
      62             :     struct PropertyValueCompare : public ::std::binary_function< beans::PropertyValue, ::rtl::OUString, bool >
      63             :     {
      64           0 :         bool operator() ( const beans::PropertyValue& rPropValue, const ::rtl::OUString& rName ) const
      65             :         {
      66           0 :             return rPropValue.Name.equals( rName );
      67             :         }
      68             :         bool operator() ( const ::rtl::OUString& rName, const beans::PropertyValue& rPropValue ) const
      69             :         {
      70             :             return rName.equals( rPropValue.Name );
      71             :         }
      72             :     };
      73             : 
      74             : //.............................................................................
      75             : } // anonymous namespace
      76             : //.............................................................................
      77             : 
      78             : 
      79             : //.............................................................................
      80             : namespace chart
      81             : {
      82             : //.............................................................................
      83             : 
      84           0 : DrawCommandDispatch::DrawCommandDispatch( const Reference< uno::XComponentContext >& rxContext,
      85             :     ChartController* pController )
      86             :     :FeatureCommandDispatchBase( rxContext )
      87           0 :     ,m_pChartController( pController )
      88             : {
      89           0 : }
      90             : 
      91           0 : DrawCommandDispatch::~DrawCommandDispatch()
      92             : {
      93           0 : }
      94             : 
      95           0 : void DrawCommandDispatch::initialize()
      96             : {
      97           0 :     FeatureCommandDispatchBase::initialize();
      98           0 : }
      99             : 
     100           0 : bool DrawCommandDispatch::isFeatureSupported( const ::rtl::OUString& rCommandURL )
     101             : {
     102           0 :     sal_uInt16 nFeatureId = 0;
     103           0 :     ::rtl::OUString aBaseCommand;
     104           0 :     ::rtl::OUString aCustomShapeType;
     105           0 :     return parseCommandURL( rCommandURL, &nFeatureId, &aBaseCommand, &aCustomShapeType );
     106             : }
     107             : 
     108           0 : ::basegfx::B2DPolyPolygon getPolygon( sal_uInt16 nResId, SdrModel& rModel )
     109             : {
     110           0 :     ::basegfx::B2DPolyPolygon aReturn;
     111           0 :     XLineEndListRef pLineEndList = rModel.GetLineEndList();
     112           0 :     if ( pLineEndList.is() )
     113             :     {
     114           0 :         String aName( SVX_RES( nResId ) );
     115           0 :         long nCount = pLineEndList->Count();
     116           0 :         for ( long nIndex = 0; nIndex < nCount; ++nIndex )
     117             :         {
     118           0 :             XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nIndex );
     119           0 :             if ( pEntry->GetName() == aName )
     120             :             {
     121           0 :                 aReturn = pEntry->GetLineEnd();
     122           0 :                 break;
     123             :             }
     124           0 :         }
     125             :     }
     126           0 :     return aReturn;
     127             : }
     128             : 
     129           0 : void DrawCommandDispatch::setAttributes( SdrObject* pObj )
     130             : {
     131           0 :     if ( m_pChartController )
     132             :     {
     133           0 :         DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
     134           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     135           0 :         if ( pDrawModelWrapper && pDrawViewWrapper && pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_CUSTOMSHAPE )
     136             :         {
     137           0 :             sal_Bool bAttributesAppliedFromGallery = sal_False;
     138           0 :             if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
     139             :             {
     140           0 :                 ::std::vector< ::rtl::OUString > aObjList;
     141           0 :                 if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
     142             :                 {
     143           0 :                     for ( sal_uInt16 i = 0; i < aObjList.size(); ++i )
     144             :                     {
     145           0 :                         if ( aObjList[ i ].equalsIgnoreAsciiCase( m_aCustomShapeType ) )
     146             :                         {
     147           0 :                             FmFormModel aModel;
     148           0 :                             SfxItemPool& rPool = aModel.GetItemPool();
     149           0 :                             rPool.FreezeIdRanges();
     150           0 :                             if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aModel ) )
     151             :                             {
     152           0 :                                 const SdrObject* pSourceObj = aModel.GetPage( 0 )->GetObj( 0 );
     153           0 :                                 if ( pSourceObj )
     154             :                                 {
     155           0 :                                     const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
     156           0 :                                     SfxItemSet aDest( pObj->GetModel()->GetItemPool(),          // ranges from SdrAttrObj
     157             :                                         SDRATTR_START, SDRATTR_SHADOW_LAST,
     158             :                                         SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
     159             :                                         SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
     160             :                                         // Graphic Attributes
     161             :                                         SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
     162             :                                         // 3d Properties
     163             :                                         SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
     164             :                                         // CustomShape properties
     165             :                                         SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
     166             :                                         // range from SdrTextObj
     167             :                                         EE_ITEMS_START, EE_ITEMS_END,
     168             :                                         // end
     169           0 :                                         0, 0);
     170           0 :                                     aDest.Set( rSource );
     171           0 :                                     pObj->SetMergedItemSet( aDest );
     172           0 :                                     sal_Int32 nAngle = pSourceObj->GetRotateAngle();
     173           0 :                                     if ( nAngle )
     174             :                                     {
     175           0 :                                         double a = nAngle * F_PI18000;
     176           0 :                                         pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
     177             :                                     }
     178           0 :                                     bAttributesAppliedFromGallery = sal_True;
     179             :                                 }
     180             :                             }
     181           0 :                             break;
     182             :                         }
     183             :                     }
     184           0 :                 }
     185             :             }
     186           0 :             if ( !bAttributesAppliedFromGallery )
     187             :             {
     188           0 :                 pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, 0 ) );
     189           0 :                 pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
     190           0 :                 pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
     191           0 :                 pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
     192           0 :                 ( dynamic_cast< SdrObjCustomShape* >( pObj ) )->MergeDefaultAttributes( &m_aCustomShapeType );
     193             :             }
     194             :         }
     195             :     }
     196           0 : }
     197             : 
     198           0 : void DrawCommandDispatch::setLineEnds( SfxItemSet& rAttr )
     199             : {
     200           0 :     if ( m_nFeatureId == COMMAND_ID_LINE_ARROW_END && m_pChartController )
     201             :     {
     202           0 :         DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
     203           0 :         DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     204           0 :         if ( pDrawModelWrapper && pDrawViewWrapper )
     205             :         {
     206           0 :             ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, pDrawModelWrapper->getSdrModel() ) );
     207           0 :             if ( !aArrow.count() )
     208             :             {
     209           0 :                 ::basegfx::B2DPolygon aNewArrow;
     210           0 :                 aNewArrow.append( ::basegfx::B2DPoint( 10.0, 0.0 ) );
     211           0 :                 aNewArrow.append( ::basegfx::B2DPoint( 0.0, 30.0) );
     212           0 :                 aNewArrow.append( ::basegfx::B2DPoint( 20.0, 30.0 ) );
     213           0 :                 aNewArrow.setClosed( true );
     214           0 :                 aArrow.append( aNewArrow );
     215             :             }
     216             : 
     217           0 :             SfxItemSet aSet( pDrawViewWrapper->GetModel()->GetItemPool() );
     218           0 :             pDrawViewWrapper->GetAttributes( aSet );
     219             : 
     220           0 :             long nWidth = 300; // (1/100th mm)
     221           0 :             if ( aSet.GetItemState( XATTR_LINEWIDTH ) != SFX_ITEM_DONTCARE )
     222             :             {
     223           0 :                 long nValue = ( ( const XLineWidthItem& ) aSet.Get( XATTR_LINEWIDTH ) ).GetValue();
     224           0 :                 if ( nValue > 0 )
     225             :                 {
     226           0 :                     nWidth = nValue * 3;
     227             :                 }
     228             :             }
     229             : 
     230           0 :             rAttr.Put( XLineEndItem( SVX_RESSTR( RID_SVXSTR_ARROW ), aArrow ) );
     231           0 :             rAttr.Put( XLineEndWidthItem( nWidth ) );
     232             :         }
     233             :     }
     234           0 : }
     235             : 
     236             : // WeakComponentImplHelperBase
     237           0 : void DrawCommandDispatch::disposing()
     238             : {
     239           0 : }
     240             : 
     241             : // XEventListener
     242           0 : void DrawCommandDispatch::disposing( const lang::EventObject& /* Source */ )
     243             :     throw (uno::RuntimeException)
     244             : {
     245           0 : }
     246             : 
     247           0 : FeatureState DrawCommandDispatch::getState( const ::rtl::OUString& rCommand )
     248             : {
     249           0 :     FeatureState aReturn;
     250           0 :     aReturn.bEnabled = false;
     251           0 :     aReturn.aState <<= false;
     252             : 
     253           0 :     sal_uInt16 nFeatureId = 0;
     254           0 :     ::rtl::OUString aBaseCommand;
     255           0 :     ::rtl::OUString aCustomShapeType;
     256           0 :     if ( parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) )
     257             :     {
     258           0 :         switch ( nFeatureId )
     259             :         {
     260             :             case COMMAND_ID_OBJECT_SELECT:
     261             :             case COMMAND_ID_DRAW_LINE:
     262             :             case COMMAND_ID_LINE_ARROW_END:
     263             :             case COMMAND_ID_DRAW_RECT:
     264             :             case COMMAND_ID_DRAW_ELLIPSE:
     265             :             case COMMAND_ID_DRAW_FREELINE_NOFILL:
     266             :             case COMMAND_ID_DRAW_TEXT:
     267             :             case COMMAND_ID_DRAW_CAPTION:
     268             :             case COMMAND_ID_DRAWTBX_CS_BASIC:
     269             :             case COMMAND_ID_DRAWTBX_CS_SYMBOL:
     270             :             case COMMAND_ID_DRAWTBX_CS_ARROW:
     271             :             case COMMAND_ID_DRAWTBX_CS_FLOWCHART:
     272             :             case COMMAND_ID_DRAWTBX_CS_CALLOUT:
     273             :             case COMMAND_ID_DRAWTBX_CS_STAR:
     274             :                 {
     275           0 :                     aReturn.bEnabled = true;
     276           0 :                     aReturn.aState <<= false;
     277             :                 }
     278           0 :                 break;
     279             :             default:
     280             :                 {
     281           0 :                     aReturn.bEnabled = false;
     282           0 :                     aReturn.aState <<= false;
     283             :                 }
     284           0 :                 break;
     285             :         }
     286             :     }
     287             : 
     288           0 :     return aReturn;
     289             : }
     290             : 
     291           0 : void DrawCommandDispatch::execute( const ::rtl::OUString& rCommand, const Sequence< beans::PropertyValue>& rArgs )
     292             : {
     293             :     (void)rArgs;
     294             : 
     295           0 :     ChartDrawMode eDrawMode = CHARTDRAW_SELECT;
     296           0 :     SdrObjKind eKind = OBJ_NONE;
     297           0 :     bool bCreate = false;
     298             : 
     299           0 :     sal_uInt16 nFeatureId = 0;
     300           0 :     ::rtl::OUString aBaseCommand;
     301           0 :     ::rtl::OUString aCustomShapeType;
     302           0 :     if ( parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) )
     303             :     {
     304           0 :         m_nFeatureId = nFeatureId;
     305           0 :         m_aCustomShapeType = aCustomShapeType;
     306             : 
     307           0 :         switch ( nFeatureId )
     308             :         {
     309             :             case COMMAND_ID_OBJECT_SELECT:
     310             :                 {
     311           0 :                     eDrawMode = CHARTDRAW_SELECT;
     312           0 :                     eKind = OBJ_NONE;
     313             :                 }
     314           0 :                 break;
     315             :             case COMMAND_ID_DRAW_LINE:
     316             :             case COMMAND_ID_LINE_ARROW_END:
     317             :                 {
     318           0 :                     eDrawMode = CHARTDRAW_INSERT;
     319           0 :                     eKind = OBJ_LINE;
     320             :                 }
     321           0 :                 break;
     322             :             case COMMAND_ID_DRAW_RECT:
     323             :                 {
     324           0 :                     eDrawMode = CHARTDRAW_INSERT;
     325           0 :                     eKind = OBJ_RECT;
     326             :                 }
     327           0 :                 break;
     328             :             case COMMAND_ID_DRAW_ELLIPSE:
     329             :                 {
     330           0 :                     eDrawMode = CHARTDRAW_INSERT;
     331           0 :                     eKind = OBJ_CIRC;
     332             :                 }
     333           0 :                 break;
     334             :             case COMMAND_ID_DRAW_FREELINE_NOFILL:
     335             :                 {
     336           0 :                     eDrawMode = CHARTDRAW_INSERT;
     337           0 :                     eKind = OBJ_FREELINE;
     338             :                 }
     339           0 :                 break;
     340             :             case COMMAND_ID_DRAW_TEXT:
     341             :                 {
     342           0 :                     eDrawMode = CHARTDRAW_INSERT;
     343           0 :                     eKind = OBJ_TEXT;
     344           0 :                     bCreate = true;
     345             :                 }
     346           0 :                 break;
     347             :             case COMMAND_ID_DRAW_CAPTION:
     348             :                 {
     349           0 :                     eDrawMode = CHARTDRAW_INSERT;
     350           0 :                     eKind = OBJ_CAPTION;
     351             :                 }
     352           0 :                 break;
     353             :             case COMMAND_ID_DRAWTBX_CS_BASIC:
     354             :             case COMMAND_ID_DRAWTBX_CS_SYMBOL:
     355             :             case COMMAND_ID_DRAWTBX_CS_ARROW:
     356             :             case COMMAND_ID_DRAWTBX_CS_FLOWCHART:
     357             :             case COMMAND_ID_DRAWTBX_CS_CALLOUT:
     358             :             case COMMAND_ID_DRAWTBX_CS_STAR:
     359             :                 {
     360           0 :                     eDrawMode = CHARTDRAW_INSERT;
     361           0 :                     eKind = OBJ_CUSTOMSHAPE;
     362             :                 }
     363           0 :                 break;
     364             :             default:
     365             :                 {
     366           0 :                     eDrawMode = CHARTDRAW_SELECT;
     367           0 :                     eKind = OBJ_NONE;
     368             :                 }
     369           0 :                 break;
     370             :         }
     371             : 
     372           0 :         if ( m_pChartController )
     373             :         {
     374           0 :             DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
     375           0 :             if ( pDrawViewWrapper )
     376             :             {
     377           0 :                 SolarMutexGuard aGuard;
     378           0 :                 m_pChartController->setDrawMode( eDrawMode );
     379           0 :                 setInsertObj( sal::static_int_cast< sal_uInt16 >( eKind ) );
     380           0 :                 if ( bCreate )
     381             :                 {
     382           0 :                     pDrawViewWrapper->SetCreateMode();
     383             :                 }
     384             : 
     385           0 :                 const ::rtl::OUString sKeyModifier( C2U( "KeyModifier" ) );
     386           0 :                 const beans::PropertyValue* pIter = rArgs.getConstArray();
     387           0 :                 const beans::PropertyValue* pEnd  = pIter + rArgs.getLength();
     388             :                 const beans::PropertyValue* pKeyModifier = ::std::find_if(
     389           0 :                     pIter, pEnd, ::std::bind2nd( PropertyValueCompare(), boost::cref( sKeyModifier ) ) );
     390           0 :                 sal_Int16 nKeyModifier = 0;
     391           0 :                 if ( pKeyModifier && ( pKeyModifier->Value >>= nKeyModifier ) && nKeyModifier == KEY_MOD1 )
     392             :                 {
     393           0 :                     if ( eDrawMode == CHARTDRAW_INSERT )
     394             :                     {
     395           0 :                         SdrObject* pObj = createDefaultObject( nFeatureId );
     396           0 :                         if ( pObj )
     397             :                         {
     398           0 :                             SdrPageView* pPageView = pDrawViewWrapper->GetSdrPageView();
     399           0 :                             pDrawViewWrapper->InsertObjectAtView( pObj, *pPageView );
     400           0 :                             Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY );
     401           0 :                             if ( xShape.is() )
     402             :                             {
     403           0 :                                 m_pChartController->m_aSelection.setSelection( xShape );
     404           0 :                                 m_pChartController->m_aSelection.applySelection( pDrawViewWrapper );
     405             :                             }
     406           0 :                             if ( nFeatureId == SID_DRAW_TEXT )
     407             :                             {
     408           0 :                                 m_pChartController->StartTextEdit();
     409           0 :                             }
     410             :                         }
     411             :                     }
     412           0 :                 }
     413             :             }
     414             :         }
     415           0 :     }
     416           0 : }
     417             : 
     418           0 : void DrawCommandDispatch::describeSupportedFeatures()
     419             : {
     420           0 :     implDescribeSupportedFeature( ".uno:SelectObject",      COMMAND_ID_OBJECT_SELECT,           CommandGroup::INSERT );
     421           0 :     implDescribeSupportedFeature( ".uno:Line",              COMMAND_ID_DRAW_LINE,               CommandGroup::INSERT );
     422           0 :     implDescribeSupportedFeature( ".uno:LineArrowEnd",      COMMAND_ID_LINE_ARROW_END,          CommandGroup::INSERT );
     423           0 :     implDescribeSupportedFeature( ".uno:Rect",              COMMAND_ID_DRAW_RECT,               CommandGroup::INSERT );
     424           0 :     implDescribeSupportedFeature( ".uno:Ellipse",           COMMAND_ID_DRAW_ELLIPSE,            CommandGroup::INSERT );
     425           0 :     implDescribeSupportedFeature( ".uno:Freeline_Unfilled", COMMAND_ID_DRAW_FREELINE_NOFILL,    CommandGroup::INSERT );
     426           0 :     implDescribeSupportedFeature( ".uno:DrawText",          COMMAND_ID_DRAW_TEXT,               CommandGroup::INSERT );
     427           0 :     implDescribeSupportedFeature( ".uno:DrawCaption",       COMMAND_ID_DRAW_CAPTION,            CommandGroup::INSERT );
     428           0 :     implDescribeSupportedFeature( ".uno:BasicShapes",       COMMAND_ID_DRAWTBX_CS_BASIC,        CommandGroup::INSERT );
     429           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes",      COMMAND_ID_DRAWTBX_CS_SYMBOL,       CommandGroup::INSERT );
     430           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes",       COMMAND_ID_DRAWTBX_CS_ARROW,        CommandGroup::INSERT );
     431           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes",   COMMAND_ID_DRAWTBX_CS_FLOWCHART,    CommandGroup::INSERT );
     432           0 :     implDescribeSupportedFeature( ".uno:CalloutShapes",     COMMAND_ID_DRAWTBX_CS_CALLOUT,      CommandGroup::INSERT );
     433           0 :     implDescribeSupportedFeature( ".uno:StarShapes",        COMMAND_ID_DRAWTBX_CS_STAR,         CommandGroup::INSERT );
     434           0 : }
     435             : 
     436           0 : void DrawCommandDispatch::setInsertObj( sal_uInt16 eObj )
     437             : {
     438           0 :     DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
     439           0 :     if ( pDrawViewWrapper )
     440             :     {
     441           0 :         pDrawViewWrapper->SetCurrentObj( eObj /*, Inventor */);
     442             :     }
     443           0 : }
     444             : 
     445           0 : SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
     446             : {
     447           0 :     SdrObject* pObj = NULL;
     448           0 :     DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
     449           0 :     DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : NULL );
     450             : 
     451           0 :     if ( pDrawViewWrapper && pDrawModelWrapper )
     452             :     {
     453           0 :         Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() );
     454           0 :         SdrPage* pPage = GetSdrPageFromXDrawPage( xDrawPage );
     455           0 :         if ( pPage )
     456             :         {
     457           0 :             SolarMutexGuard aGuard;
     458             :             pObj = SdrObjFactory::MakeNewObject( pDrawViewWrapper->GetCurrentObjInventor(),
     459           0 :                 pDrawViewWrapper->GetCurrentObjIdentifier(), pPage );
     460           0 :             if ( pObj )
     461             :             {
     462           0 :                 long nDefaultObjectSizeWidth = 4000;
     463           0 :                 long nDefaultObjectSizeHeight = 2500;
     464           0 :                 Size aObjectSize( nDefaultObjectSizeWidth, nDefaultObjectSizeHeight );
     465           0 :                 Rectangle aPageRect( Rectangle( Point( 0, 0 ), pPage->GetSize() ) );
     466           0 :                 Point aObjectPos = aPageRect.Center();
     467           0 :                 aObjectPos.X() -= aObjectSize.Width() / 2;
     468           0 :                 aObjectPos.Y() -= aObjectSize.Height() / 2;
     469           0 :                 Rectangle aRect( aObjectPos, aObjectSize );
     470             : 
     471           0 :                 switch ( nID )
     472             :                 {
     473             :                     case COMMAND_ID_DRAW_LINE:
     474             :                     case COMMAND_ID_LINE_ARROW_END:
     475             :                         {
     476           0 :                             if ( pObj->ISA( SdrPathObj ) )
     477             :                             {
     478           0 :                                 Point aStart = aRect.TopLeft();
     479           0 :                                 Point aEnd = aRect.BottomRight();
     480           0 :                                 sal_Int32 nYMiddle( ( aRect.Top() + aRect.Bottom() ) / 2 );
     481           0 :                                 basegfx::B2DPolygon aPoly;
     482           0 :                                 aPoly.append( basegfx::B2DPoint( aStart.X(), nYMiddle ) );
     483           0 :                                 aPoly.append( basegfx::B2DPoint( aEnd.X(), nYMiddle ) );
     484           0 :                                 ( dynamic_cast< SdrPathObj* >( pObj ) )->SetPathPoly( basegfx::B2DPolyPolygon( aPoly ) );
     485           0 :                                 SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
     486           0 :                                 setLineEnds( aSet );
     487           0 :                                 pObj->SetMergedItemSet( aSet );
     488             :                             }
     489             :                         }
     490           0 :                         break;
     491             :                     case COMMAND_ID_DRAW_FREELINE_NOFILL:
     492             :                         {
     493           0 :                             if ( pObj->ISA( SdrPathObj ) )
     494             :                             {
     495           0 :                                 basegfx::B2DPolygon aInnerPoly;
     496           0 :                                 aInnerPoly.append( basegfx::B2DPoint( aRect.Left(), aRect.Bottom() ) );
     497             :                                 aInnerPoly.appendBezierSegment(
     498           0 :                                     basegfx::B2DPoint( aRect.Left(), aRect.Top() ),
     499           0 :                                     basegfx::B2DPoint( aRect.Center().X(), aRect.Top() ),
     500           0 :                                     basegfx::B2DPoint( aRect.Center().X(), aRect.Center().Y() ) );
     501             :                                 aInnerPoly.appendBezierSegment(
     502           0 :                                     basegfx::B2DPoint( aRect.Center().X(), aRect.Bottom() ),
     503           0 :                                     basegfx::B2DPoint( aRect.Right(), aRect.Bottom() ),
     504           0 :                                     basegfx::B2DPoint( aRect.Right(), aRect.Top() ) );
     505           0 :                                 basegfx::B2DPolyPolygon aPoly;
     506           0 :                                 aPoly.append( aInnerPoly );
     507           0 :                                 ( dynamic_cast< SdrPathObj* >( pObj ) )->SetPathPoly( aPoly );
     508             :                             }
     509             :                         }
     510           0 :                         break;
     511             :                     case COMMAND_ID_DRAW_TEXT:
     512             :                     case COMMAND_ID_DRAW_TEXT_VERTICAL:
     513             :                         {
     514           0 :                             if ( pObj->ISA( SdrTextObj ) )
     515             :                             {
     516           0 :                                 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
     517           0 :                                 if ( pTextObj )
     518             :                                 {
     519           0 :                                     pTextObj->SetLogicRect( aRect );
     520           0 :                                     sal_Bool bVertical = ( nID == SID_DRAW_TEXT_VERTICAL );
     521           0 :                                     pTextObj->SetVerticalWriting( bVertical );
     522           0 :                                     if ( bVertical )
     523             :                                     {
     524           0 :                                         SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
     525           0 :                                         aSet.Put( SdrTextAutoGrowWidthItem( sal_True ) );
     526           0 :                                         aSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
     527           0 :                                         aSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_TOP ) );
     528           0 :                                         aSet.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_RIGHT ) );
     529           0 :                                         pTextObj->SetMergedItemSet( aSet );
     530             :                                     }
     531             :                                 }
     532             :                             }
     533             :                         }
     534           0 :                         break;
     535             :                     case COMMAND_ID_DRAW_CAPTION:
     536             :                     case COMMAND_ID_DRAW_CAPTION_VERTICAL:
     537             :                         {
     538           0 :                             if ( pObj->ISA( SdrCaptionObj ) )
     539             :                             {
     540           0 :                                 sal_Bool bIsVertical( SID_DRAW_CAPTION_VERTICAL == nID );
     541           0 :                                 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
     542           0 :                                 if ( pTextObj )
     543             :                                 {
     544           0 :                                     pTextObj->SetVerticalWriting( bIsVertical );
     545             :                                 }
     546           0 :                                 if ( bIsVertical )
     547             :                                 {
     548           0 :                                     SfxItemSet aSet( pObj->GetMergedItemSet() );
     549           0 :                                     aSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
     550           0 :                                     aSet.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_RIGHT ) );
     551           0 :                                     pObj->SetMergedItemSet( aSet );
     552             :                                 }
     553           0 :                                 SdrCaptionObj* pCaptionObj = dynamic_cast< SdrCaptionObj* >( pObj );
     554           0 :                                 if ( pCaptionObj )
     555             :                                 {
     556           0 :                                     pCaptionObj->SetLogicRect( aRect );
     557             :                                     pCaptionObj->SetTailPos(
     558           0 :                                         aRect.TopLeft() - Point( aRect.GetWidth() / 2, aRect.GetHeight() / 2 ) );
     559             :                                 }
     560             :                             }
     561             :                         }
     562           0 :                         break;
     563             :                     default:
     564             :                         {
     565           0 :                             pObj->SetLogicRect( aRect );
     566           0 :                             SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
     567           0 :                             setAttributes( pObj );
     568           0 :                             pObj->SetMergedItemSet( aSet );
     569             :                         }
     570           0 :                         break;
     571             :                 }
     572           0 :             }
     573           0 :         }
     574             :     }
     575             : 
     576           0 :     return pObj;
     577             : }
     578             : 
     579           0 : bool DrawCommandDispatch::parseCommandURL( const ::rtl::OUString& rCommandURL, sal_uInt16* pnFeatureId,
     580             :     ::rtl::OUString* pBaseCommand, ::rtl::OUString* pCustomShapeType )
     581             : {
     582           0 :     bool bFound = true;
     583           0 :     sal_uInt16 nFeatureId = 0;
     584           0 :     ::rtl::OUString aBaseCommand;
     585           0 :     ::rtl::OUString aType;
     586             : 
     587           0 :     sal_Int32 nIndex = 1;
     588           0 :     ::rtl::OUString aToken = rCommandURL.getToken( 0, '.', nIndex );
     589           0 :     if ( nIndex == -1 || aToken.isEmpty() )
     590             :     {
     591           0 :         aBaseCommand = rCommandURL;
     592           0 :         SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( aBaseCommand );
     593           0 :         if ( aIter != m_aSupportedFeatures.end() )
     594             :         {
     595           0 :             nFeatureId = aIter->second.nFeatureId;
     596             : 
     597           0 :             switch ( nFeatureId )
     598             :             {
     599             :                 case COMMAND_ID_DRAWTBX_CS_BASIC:
     600             :                     {
     601           0 :                         aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "diamond" ) );
     602             :                     }
     603           0 :                     break;
     604             :                 case COMMAND_ID_DRAWTBX_CS_SYMBOL:
     605             :                     {
     606           0 :                         aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "smiley" ) );
     607             :                     }
     608           0 :                     break;
     609             :                 case COMMAND_ID_DRAWTBX_CS_ARROW:
     610             :                     {
     611           0 :                         aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "left-right-arrow" ) );
     612             :                     }
     613           0 :                     break;
     614             :                 case COMMAND_ID_DRAWTBX_CS_FLOWCHART:
     615             :                     {
     616           0 :                         aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "flowchart-internal-storage" ) );
     617             :                     }
     618           0 :                     break;
     619             :                 case COMMAND_ID_DRAWTBX_CS_CALLOUT:
     620             :                     {
     621           0 :                         aType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "round-rectangular-callout" ) );
     622             :                     }
     623           0 :                     break;
     624             :                 case COMMAND_ID_DRAWTBX_CS_STAR:
     625             :                     {
     626           0 :                         aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "star5" ) );
     627             :                     }
     628           0 :                     break;
     629             :                 default:
     630             :                     {
     631             :                     }
     632           0 :                     break;
     633             :             }
     634             :         }
     635             :         else
     636             :         {
     637           0 :             bFound = false;
     638             :         }
     639             :     }
     640             :     else
     641             :     {
     642           0 :         aBaseCommand = rCommandURL.copy( 0, nIndex - 1 );
     643           0 :         SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( aBaseCommand );
     644           0 :         if ( aIter != m_aSupportedFeatures.end() )
     645             :         {
     646           0 :             nFeatureId = aIter->second.nFeatureId;
     647           0 :             aType = rCommandURL.getToken( 0, '.', nIndex );
     648             :         }
     649             :         else
     650             :         {
     651           0 :             bFound = false;
     652             :         }
     653             :     }
     654             : 
     655           0 :     *pnFeatureId = nFeatureId;
     656           0 :     *pBaseCommand = aBaseCommand;
     657           0 :     *pCustomShapeType = aType;
     658             : 
     659           0 :     return bFound;
     660             : }
     661             : 
     662             : //.............................................................................
     663             : } //  namespace chart
     664             : //.............................................................................
     665             : 
     666             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10