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

Generated by: LCOV version 1.10