Bump for 3.6-28
[LibreOffice.git] / chart2 / source / controller / main / ShapeController.cxx
bloba4c5f82eec2e988c53663791cc4a16c7e41b20f0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "ShapeController.hxx"
31 #include "ShapeController.hrc"
32 #include "ChartController.hxx"
33 #include "ChartWindow.hxx"
34 #include "ViewElementListProvider.hxx"
35 #include "dlg_ShapeFont.hxx"
36 #include "dlg_ShapeParagraph.hxx"
37 #include "chartview/DrawModelWrapper.hxx"
38 #include "macros.hxx"
40 #include <com/sun/star/frame/XStorable.hpp>
42 #include <osl/mutex.hxx>
43 #include <vcl/msgbox.hxx>
44 #include <vcl/svapp.hxx>
45 #include <editeng/brkitem.hxx>
46 #include <svx/dialogs.hrc>
47 #include <svx/drawitem.hxx>
48 #include <editeng/eeitem.hxx>
49 #include <editeng/hyznitem.hxx>
50 #include <editeng/orphitem.hxx>
51 #include <editeng/spltitem.hxx>
52 #include <svx/svxdlg.hxx>
53 #include <editeng/widwitem.hxx>
55 #include <boost/scoped_ptr.hpp>
57 using namespace ::com::sun::star;
58 using namespace ::com::sun::star::frame;
60 using ::com::sun::star::uno::Reference;
61 using ::com::sun::star::uno::Sequence;
63 //.............................................................................
64 namespace chart
66 //.............................................................................
68 ShapeController::ShapeController( const Reference< uno::XComponentContext >& rxContext,
69 ChartController* pController )
70 :FeatureCommandDispatchBase( rxContext )
71 ,m_pChartController( pController )
75 ShapeController::~ShapeController()
79 void ShapeController::initialize()
81 FeatureCommandDispatchBase::initialize();
84 // WeakComponentImplHelperBase
85 void ShapeController::disposing()
89 // XEventListener
90 void ShapeController::disposing( const lang::EventObject& /* Source */ )
91 throw (uno::RuntimeException)
95 FeatureState ShapeController::getState( const ::rtl::OUString& rCommand )
97 FeatureState aReturn;
98 aReturn.bEnabled = false;
99 aReturn.aState <<= false;
101 bool bWritable = false;
102 if ( m_pChartController )
104 Reference< frame::XStorable > xStorable( m_pChartController->getModel(), uno::UNO_QUERY );
105 if ( xStorable.is() )
107 bWritable = !xStorable->isReadonly();
111 SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand );
112 if ( aIter != m_aSupportedFeatures.end() )
114 sal_uInt16 nFeatureId = aIter->second.nFeatureId;
115 switch ( nFeatureId )
117 case COMMAND_ID_FORMAT_LINE:
118 case COMMAND_ID_FORMAT_AREA:
119 case COMMAND_ID_TEXT_ATTRIBUTES:
120 case COMMAND_ID_TRANSFORM_DIALOG:
121 case COMMAND_ID_OBJECT_TITLE_DESCRIPTION:
122 case COMMAND_ID_RENAME_OBJECT:
124 aReturn.bEnabled = bWritable;
125 aReturn.aState <<= false;
127 break;
128 case COMMAND_ID_BRING_TO_FRONT:
129 case COMMAND_ID_FORWARD:
131 aReturn.bEnabled = ( bWritable && isForwardPossible() );
132 aReturn.aState <<= false;
134 break;
135 case COMMAND_ID_BACKWARD:
136 case COMMAND_ID_SEND_TO_BACK:
139 aReturn.bEnabled = ( bWritable && isBackwardPossible() );
140 aReturn.aState <<= false;
142 break;
143 case COMMAND_ID_FONT_DIALOG:
144 case COMMAND_ID_PARAGRAPH_DIALOG:
146 aReturn.bEnabled = bWritable;
147 aReturn.aState <<= false;
149 break;
150 default:
152 aReturn.bEnabled = false;
153 aReturn.aState <<= false;
155 break;
159 return aReturn;
162 void ShapeController::execute( const ::rtl::OUString& rCommand, const Sequence< beans::PropertyValue>& rArgs )
164 (void)rArgs;
166 SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand );
167 if ( aIter != m_aSupportedFeatures.end() )
169 sal_uInt16 nFeatureId = aIter->second.nFeatureId;
170 switch ( nFeatureId )
172 case COMMAND_ID_FORMAT_LINE:
174 executeDispatch_FormatLine();
176 break;
177 case COMMAND_ID_FORMAT_AREA:
179 executeDispatch_FormatArea();
181 break;
182 case COMMAND_ID_TEXT_ATTRIBUTES:
184 executeDispatch_TextAttributes();
186 break;
187 case COMMAND_ID_TRANSFORM_DIALOG:
189 executeDispatch_TransformDialog();
191 break;
192 case COMMAND_ID_OBJECT_TITLE_DESCRIPTION:
194 executeDispatch_ObjectTitleDescription();
196 break;
197 case COMMAND_ID_RENAME_OBJECT:
199 executeDispatch_RenameObject();
201 break;
202 case COMMAND_ID_BRING_TO_FRONT:
203 case COMMAND_ID_FORWARD:
204 case COMMAND_ID_BACKWARD:
205 case COMMAND_ID_SEND_TO_BACK:
207 executeDispatch_ChangeZOrder( nFeatureId );
209 break;
210 case COMMAND_ID_FONT_DIALOG:
212 executeDispatch_FontDialog();
214 break;
215 case COMMAND_ID_PARAGRAPH_DIALOG:
217 executeDispatch_ParagraphDialog();
219 break;
220 default:
223 break;
228 void ShapeController::describeSupportedFeatures()
230 implDescribeSupportedFeature( ".uno:FormatLine", COMMAND_ID_FORMAT_LINE, CommandGroup::FORMAT );
231 implDescribeSupportedFeature( ".uno:FormatArea", COMMAND_ID_FORMAT_AREA, CommandGroup::FORMAT );
232 implDescribeSupportedFeature( ".uno:TextAttributes", COMMAND_ID_TEXT_ATTRIBUTES, CommandGroup::FORMAT );
233 implDescribeSupportedFeature( ".uno:TransformDialog", COMMAND_ID_TRANSFORM_DIALOG, CommandGroup::FORMAT );
234 implDescribeSupportedFeature( ".uno:ObjectTitleDescription", COMMAND_ID_OBJECT_TITLE_DESCRIPTION, CommandGroup::FORMAT );
235 implDescribeSupportedFeature( ".uno:RenameObject", COMMAND_ID_RENAME_OBJECT, CommandGroup::FORMAT );
236 implDescribeSupportedFeature( ".uno:BringToFront", COMMAND_ID_BRING_TO_FRONT, CommandGroup::FORMAT );
237 implDescribeSupportedFeature( ".uno:Forward", COMMAND_ID_FORWARD, CommandGroup::FORMAT );
238 implDescribeSupportedFeature( ".uno:Backward", COMMAND_ID_BACKWARD, CommandGroup::FORMAT );
239 implDescribeSupportedFeature( ".uno:SendToBack", COMMAND_ID_SEND_TO_BACK, CommandGroup::FORMAT );
240 implDescribeSupportedFeature( ".uno:FontDialog", COMMAND_ID_FONT_DIALOG, CommandGroup::EDIT );
241 implDescribeSupportedFeature( ".uno:ParagraphDialog", COMMAND_ID_PARAGRAPH_DIALOG, CommandGroup::EDIT );
244 IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxNameDialog*, pDialog )
246 String aName;
247 if ( pDialog )
249 pDialog->GetName( aName );
251 if ( aName.Len() )
253 DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
254 if ( pDrawViewWrapper && pDrawViewWrapper->getNamedSdrObject( aName ) )
256 return 0;
259 return 1;
262 void ShapeController::executeDispatch_FormatLine()
264 SolarMutexGuard aGuard;
265 if ( m_pChartController )
267 Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
268 DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
269 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
270 if ( pParent && pDrawModelWrapper && pDrawViewWrapper )
272 SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
273 SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
274 sal_Bool bHasMarked = pDrawViewWrapper->AreObjectsMarked();
275 if ( bHasMarked )
277 pDrawViewWrapper->MergeAttrFromMarked( aAttr, sal_False );
279 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
280 if ( pFact )
282 ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
283 pFact->CreateSvxLineTabDialog( pParent, &aAttr, &pDrawModelWrapper->getSdrModel(),
284 pSelectedObj, bHasMarked ) );
285 if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
287 const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
288 if ( bHasMarked )
290 pDrawViewWrapper->SetAttrToMarked( *pOutAttr, sal_False );
292 else
294 pDrawViewWrapper->SetDefaultAttr( *pOutAttr, sal_False );
302 void ShapeController::executeDispatch_FormatArea()
304 SolarMutexGuard aGuard;
305 if ( m_pChartController )
307 Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
308 DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
309 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
310 if ( pParent && pDrawModelWrapper && pDrawViewWrapper )
312 SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
313 sal_Bool bHasMarked = pDrawViewWrapper->AreObjectsMarked();
314 if ( bHasMarked )
316 pDrawViewWrapper->MergeAttrFromMarked( aAttr, sal_False );
318 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
319 if ( pFact )
321 ::boost::scoped_ptr< AbstractSvxAreaTabDialog > pDlg(
322 pFact->CreateSvxAreaTabDialog( pParent, &aAttr, &pDrawModelWrapper->getSdrModel(),
323 pDrawViewWrapper ) );
324 if ( pDlg.get() )
326 SfxItemPool& rItemPool = pDrawViewWrapper->GetModel()->GetItemPool();
327 SfxItemSet aSet( rItemPool, rItemPool.GetFirstWhich(), rItemPool.GetLastWhich() );
328 if ( pDlg->Execute() == RET_OK )
330 const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
331 if ( bHasMarked )
333 pDrawViewWrapper->SetAttrToMarked( *pOutAttr, sal_False );
335 else
337 pDrawViewWrapper->SetDefaultAttr( *pOutAttr, sal_False );
346 void ShapeController::executeDispatch_TextAttributes()
348 SolarMutexGuard aGuard;
349 if ( m_pChartController )
351 Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
352 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
353 if ( pParent && pDrawViewWrapper )
355 SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
356 sal_Bool bHasMarked = pDrawViewWrapper->AreObjectsMarked();
357 if ( bHasMarked )
359 pDrawViewWrapper->MergeAttrFromMarked( aAttr, sal_False );
361 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
362 if ( pFact )
364 ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
365 pFact->CreateTextTabDialog( pParent, &aAttr, pDrawViewWrapper ) );
366 if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
368 const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
369 if ( bHasMarked )
371 pDrawViewWrapper->SetAttributes( *pOutAttr );
373 else
375 pDrawViewWrapper->SetDefaultAttr( *pOutAttr, sal_False );
383 void ShapeController::executeDispatch_TransformDialog()
385 SolarMutexGuard aGuard;
386 if ( m_pChartController )
388 Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
389 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
390 if ( pParent && pDrawViewWrapper )
392 SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
393 if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == OBJ_CAPTION )
395 // item set for caption
396 SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() );
397 pDrawViewWrapper->GetAttributes( aAttr );
398 // item set for position and size
399 SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() );
400 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
401 if ( pFact )
403 ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
404 pFact->CreateCaptionDialog( pParent, pDrawViewWrapper ) );
405 if ( pDlg.get() )
407 const sal_uInt16* pRange = pDlg->GetInputRanges( *aAttr.GetPool() );
408 SfxItemSet aCombAttr( *aAttr.GetPool(), pRange );
409 aCombAttr.Put( aAttr );
410 aCombAttr.Put( aGeoAttr );
411 pDlg->SetInputSet( &aCombAttr );
412 if ( pDlg->Execute() == RET_OK )
414 const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
415 pDrawViewWrapper->SetAttributes( *pOutAttr );
416 pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr );
421 else
423 SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() );
424 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
425 if ( pFact )
427 ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
428 pFact->CreateSvxTransformTabDialog( pParent, &aGeoAttr, pDrawViewWrapper ) );
429 if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
431 const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
432 pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr );
440 void ShapeController::executeDispatch_ObjectTitleDescription()
442 SolarMutexGuard aGuard;
443 if ( m_pChartController )
445 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
446 if ( pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1 )
448 SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
449 if ( pSelectedObj )
451 String aTitle( pSelectedObj->GetTitle() );
452 String aDescription( pSelectedObj->GetDescription() );
453 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
454 if ( pFact )
456 ::boost::scoped_ptr< AbstractSvxObjectTitleDescDialog > pDlg(
457 pFact->CreateSvxObjectTitleDescDialog( NULL, aTitle, aDescription ) );
458 if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
460 pDlg->GetTitle( aTitle );
461 pDlg->GetDescription( aDescription );
462 pSelectedObj->SetTitle( aTitle );
463 pSelectedObj->SetDescription( aDescription );
471 void ShapeController::executeDispatch_RenameObject()
473 SolarMutexGuard aGuard;
474 if ( m_pChartController )
476 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
477 if ( pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1 )
479 SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
480 if ( pSelectedObj )
482 rtl::OUString aName = pSelectedObj->GetName();
483 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
484 if ( pFact )
486 ::boost::scoped_ptr< AbstractSvxObjectNameDialog > pDlg(
487 pFact->CreateSvxObjectNameDialog( NULL, aName ) );
488 pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) );
489 if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
491 String aTmp;
492 pDlg->GetName(aTmp);
493 aName = aTmp;
494 if (pSelectedObj->GetName().equals(aName))
496 pSelectedObj->SetName( aName );
505 void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId )
507 SolarMutexGuard aGuard;
508 DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
509 if ( pDrawViewWrapper )
511 switch ( nId )
513 case COMMAND_ID_BRING_TO_FRONT:
515 if ( isForwardPossible() )
517 pDrawViewWrapper->PutMarkedToTop();
520 break;
521 case COMMAND_ID_FORWARD:
523 if ( isForwardPossible() )
525 pDrawViewWrapper->MovMarkedToTop();
528 break;
529 case COMMAND_ID_BACKWARD:
531 if ( isBackwardPossible() )
533 pDrawViewWrapper->MovMarkedToBtm();
536 break;
537 case COMMAND_ID_SEND_TO_BACK:
539 if ( isBackwardPossible() )
541 SdrObject* pFirstObj = getFirstAdditionalShape();
542 pDrawViewWrapper->PutMarkedBehindObj( pFirstObj );
545 break;
546 default:
549 break;
554 void ShapeController::executeDispatch_FontDialog()
556 SolarMutexGuard aGuard;
557 if ( m_pChartController )
559 Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
560 DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
561 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
562 if ( pParent && pDrawModelWrapper && pDrawViewWrapper )
564 SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() );
565 pDrawViewWrapper->GetAttributes( aAttr );
566 ViewElementListProvider aViewElementListProvider( pDrawModelWrapper );
567 ::boost::scoped_ptr< ShapeFontDialog > pDlg( new ShapeFontDialog( pParent, &aAttr, &aViewElementListProvider ) );
568 if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
570 const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
571 pDrawViewWrapper->SetAttributes( *pOutAttr );
577 void ShapeController::executeDispatch_ParagraphDialog()
579 SolarMutexGuard aGuard;
580 if ( m_pChartController )
582 Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
583 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
584 if ( pParent && pDrawViewWrapper )
586 SfxItemPool& rPool = pDrawViewWrapper->GetModel()->GetItemPool();
587 SfxItemSet aAttr( rPool );
588 pDrawViewWrapper->GetAttributes( aAttr );
590 SfxItemSet aNewAttr( rPool,
591 EE_ITEMS_START, EE_ITEMS_END,
592 SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
593 SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_PAGEBREAK,
594 SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
595 SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
596 SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
597 0 );
598 aNewAttr.Put( aAttr );
599 aNewAttr.Put( SvxHyphenZoneItem( sal_False, SID_ATTR_PARA_HYPHENZONE ) );
600 aNewAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, SID_ATTR_PARA_PAGEBREAK ) );
601 aNewAttr.Put( SvxFmtSplitItem( sal_True, SID_ATTR_PARA_SPLIT) );
602 aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) );
603 aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) );
605 ::boost::scoped_ptr< ShapeParagraphDialog > pDlg( new ShapeParagraphDialog( pParent, &aNewAttr ) );
606 if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
608 const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
609 pDrawViewWrapper->SetAttributes( *pOutAttr );
615 SdrObject* ShapeController::getFirstAdditionalShape()
617 SdrObject* pFirstObj = NULL;
621 DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : NULL );
622 if ( pDrawModelWrapper )
624 Reference< drawing::XShape > xFirstShape;
625 Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() );
626 Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW );
627 Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
628 sal_Int32 nCount = xDrawPageShapes->getCount();
629 for ( sal_Int32 i = 0; i < nCount; ++i )
631 Reference< drawing::XShape > xShape;
632 if ( xDrawPageShapes->getByIndex( i ) >>= xShape )
634 if ( xShape.is() && xShape != xChartRoot )
636 xFirstShape = xShape;
637 break;
641 if ( xFirstShape.is() )
643 pFirstObj = DrawViewWrapper::getSdrObject( xFirstShape );
647 catch ( const uno::Exception& ex )
649 ASSERT_EXCEPTION( ex );
652 return pFirstObj;
655 SdrObject* ShapeController::getLastAdditionalShape()
657 SdrObject* pLastObj = NULL;
661 DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : NULL );
662 if ( pDrawModelWrapper )
664 Reference< drawing::XShape > xLastShape;
665 Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() );
666 Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW );
667 Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
668 sal_Int32 nCount = xDrawPageShapes->getCount();
669 for ( sal_Int32 i = nCount - 1; i >= 0; --i )
671 Reference< drawing::XShape > xShape;
672 if ( xDrawPageShapes->getByIndex( i ) >>= xShape )
674 if ( xShape.is() && xShape != xChartRoot )
676 xLastShape = xShape;
677 break;
681 if ( xLastShape.is() )
683 pLastObj = DrawViewWrapper::getSdrObject( xLastShape );
687 catch ( const uno::Exception& ex )
689 ASSERT_EXCEPTION( ex );
692 return pLastObj;
695 bool ShapeController::isBackwardPossible()
697 if ( m_pChartController && m_pChartController->m_aSelection.isAdditionalShapeSelected() )
699 SolarMutexGuard aGuard;
700 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
701 if ( pDrawViewWrapper )
703 SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
704 SdrObject* pFirstObj = getFirstAdditionalShape();
705 if ( pSelectedObj && pFirstObj && pSelectedObj != pFirstObj )
707 return true;
711 return false;
714 bool ShapeController::isForwardPossible()
716 if ( m_pChartController && m_pChartController->m_aSelection.isAdditionalShapeSelected() )
718 SolarMutexGuard aGuard;
719 DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
720 if ( pDrawViewWrapper )
722 SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
723 SdrObject* pLastObj = getLastAdditionalShape();
724 if ( pSelectedObj && pLastObj && pSelectedObj != pLastObj )
726 return true;
730 return false;
733 //.............................................................................
734 } // namespace chart
735 //.............................................................................
737 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */