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