1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp> 27cdf0e10cSrcweir #include <com/sun/star/presentation/ShapeAnimationSubType.hpp> 28cdf0e10cSrcweir #include <com/sun/star/presentation/EffectNodeType.hpp> 29cdf0e10cSrcweir #include <com/sun/star/presentation/ParagraphTarget.hpp> 30cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp> 31cdf0e10cSrcweir #include <com/sun/star/animations/XIterateContainer.hpp> 32cdf0e10cSrcweir #include <com/sun/star/presentation/EffectPresetClass.hpp> 33cdf0e10cSrcweir #include <com/sun/star/presentation/EffectCommands.hpp> 34cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp> 35cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 36cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp> 37cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx> 38cdf0e10cSrcweir #include "CustomAnimationList.hxx" 39cdf0e10cSrcweir #ifndef _SD_CUSTOMANIMATIONPANE_HRC 40cdf0e10cSrcweir #include "CustomAnimationPane.hrc" 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #ifndef _SD_CUSTOMANIMATION_HRC 43cdf0e10cSrcweir #include "CustomAnimation.hrc" 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #include "CustomAnimationPreset.hxx" 46cdf0e10cSrcweir #include <svtools/treelist.hxx> 47cdf0e10cSrcweir #include <vcl/svapp.hxx> 48cdf0e10cSrcweir #include "sdresid.hxx" 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include "res_bmp.hrc" 51cdf0e10cSrcweir #include "glob.hrc" 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include <algorithm> 54cdf0e10cSrcweir 55cdf0e10cSrcweir using namespace ::com::sun::star; 56cdf0e10cSrcweir using namespace ::com::sun::star::animations; 57cdf0e10cSrcweir using namespace ::com::sun::star::presentation; 58cdf0e10cSrcweir 59cdf0e10cSrcweir using ::rtl::OUString; 60cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 61cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 62cdf0e10cSrcweir using ::com::sun::star::uno::Any; 63cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 64cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 65cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 66cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 67cdf0e10cSrcweir using ::com::sun::star::text::XTextRange; 68cdf0e10cSrcweir using ::com::sun::star::drawing::XShape; 69cdf0e10cSrcweir using ::com::sun::star::drawing::XShapes; 70cdf0e10cSrcweir using ::com::sun::star::drawing::XDrawPage; 71cdf0e10cSrcweir using ::com::sun::star::container::XChild; 72cdf0e10cSrcweir using ::com::sun::star::container::XIndexAccess; 73cdf0e10cSrcweir using ::com::sun::star::container::XEnumerationAccess; 74cdf0e10cSrcweir using ::com::sun::star::container::XEnumeration; 75cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet; 76cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySetInfo; 77cdf0e10cSrcweir using ::accessibility::ShapeTypeHandler; 78cdf0e10cSrcweir 79cdf0e10cSrcweir namespace sd { 80cdf0e10cSrcweir 81cdf0e10cSrcweir // go recursivly through all shapes in the given XShapes collection and return true as soon as the 82cdf0e10cSrcweir // given shape is found. nIndex is incremented for each shape with the same shape type as the given 83cdf0e10cSrcweir // shape is found until the given shape is found. 84cdf0e10cSrcweir static bool getShapeIndex( const Reference< XShapes >& xShapes, const Reference< XShape >& xShape, sal_Int32& nIndex ) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir const sal_Int32 nCount = xShapes->getCount(); 87cdf0e10cSrcweir sal_Int32 n; 88cdf0e10cSrcweir for( n = 0; n < nCount; n++ ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir Reference< XShape > xChild; 91cdf0e10cSrcweir xShapes->getByIndex( n ) >>= xChild; 92cdf0e10cSrcweir if( xChild == xShape ) 93cdf0e10cSrcweir return true; 94cdf0e10cSrcweir 95cdf0e10cSrcweir if( xChild->getShapeType() == xShape->getShapeType() ) 96cdf0e10cSrcweir nIndex++; 97cdf0e10cSrcweir 98cdf0e10cSrcweir Reference< XShapes > xChildContainer( xChild, UNO_QUERY ); 99cdf0e10cSrcweir if( xChildContainer.is() ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir if( getShapeIndex( xChildContainer, xShape, nIndex ) ) 102cdf0e10cSrcweir return true; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir return false; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir // returns the index of the shape type from the given shape 110cdf0e10cSrcweir static sal_Int32 getShapeIndex( const Reference< XShape >& xShape ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir Reference< XChild > xChild( xShape, UNO_QUERY ); 113cdf0e10cSrcweir Reference< XShapes > xPage; 114cdf0e10cSrcweir 115cdf0e10cSrcweir while( xChild.is() && !xPage.is() ) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir Reference< XInterface > x( xChild->getParent() ); 118cdf0e10cSrcweir xChild = Reference< XChild >::query( x ); 119cdf0e10cSrcweir Reference< XDrawPage > xTestPage( x, UNO_QUERY ); 120cdf0e10cSrcweir if( xTestPage.is() ) 121cdf0e10cSrcweir xPage = Reference< XShapes >::query( x ); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir sal_Int32 nIndex = 1; 125cdf0e10cSrcweir 126cdf0e10cSrcweir if( xPage.is() && getShapeIndex( xPage, xShape, nIndex ) ) 127cdf0e10cSrcweir return nIndex; 128cdf0e10cSrcweir else 129cdf0e10cSrcweir return -1; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir OUString getShapeDescription( const Reference< XShape >& xShape, bool bWithText = true ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir OUString aDescription; 135cdf0e10cSrcweir Reference< XPropertySet > xSet( xShape, UNO_QUERY ); 136cdf0e10cSrcweir if( xSet.is() ) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir Reference< XPropertySetInfo > xInfo( xSet->getPropertySetInfo() ); 139cdf0e10cSrcweir const OUString aPropName( RTL_CONSTASCII_USTRINGPARAM("UINameSingular") ); 140cdf0e10cSrcweir if( xInfo->hasPropertyByName( aPropName ) ) 141cdf0e10cSrcweir xSet->getPropertyValue( aPropName ) >>= aDescription; 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir aDescription += OUString( RTL_CONSTASCII_USTRINGPARAM(" ")); 145cdf0e10cSrcweir aDescription += OUString::valueOf( getShapeIndex( xShape ) ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir if( bWithText ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir Reference< XTextRange > xText( xShape, UNO_QUERY ); 150cdf0e10cSrcweir if( xText.is() ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir OUString aText( xText->getString() ); 153cdf0e10cSrcweir if( aText.getLength() ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir aDescription += OUString(RTL_CONSTASCII_USTRINGPARAM(": ")); 156cdf0e10cSrcweir 157cdf0e10cSrcweir aText = aText.replace( (sal_Unicode)'\n', (sal_Unicode)' ' ); 158cdf0e10cSrcweir aText = aText.replace( (sal_Unicode)'\r', (sal_Unicode)' ' ); 159cdf0e10cSrcweir 160cdf0e10cSrcweir aDescription += aText; 161cdf0e10cSrcweir } 162cdf0e10cSrcweir } 163cdf0e10cSrcweir } 164cdf0e10cSrcweir return aDescription; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir static OUString getDescription( const Any& rTarget, bool bWithText = true ) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir OUString aDescription; 170cdf0e10cSrcweir 171cdf0e10cSrcweir if( rTarget.getValueType() == ::getCppuType((const ParagraphTarget*)0) ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir ParagraphTarget aParaTarget; 174cdf0e10cSrcweir rTarget >>= aParaTarget; 175cdf0e10cSrcweir 176cdf0e10cSrcweir Reference< XEnumerationAccess > xText( aParaTarget.Shape, UNO_QUERY_THROW ); 177cdf0e10cSrcweir Reference< XEnumeration > xEnumeration( xText->createEnumeration(), UNO_QUERY_THROW ); 178cdf0e10cSrcweir sal_Int32 nPara = aParaTarget.Paragraph; 179cdf0e10cSrcweir 180cdf0e10cSrcweir while( xEnumeration->hasMoreElements() && nPara ) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir xEnumeration->nextElement(); 183cdf0e10cSrcweir nPara--; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir DBG_ASSERT( xEnumeration->hasMoreElements(), "sd::CustomAnimationEffect::prepareText(), paragraph out of range!" ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir if( xEnumeration->hasMoreElements() ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir Reference< XTextRange > xParagraph; 191cdf0e10cSrcweir xEnumeration->nextElement() >>= xParagraph; 192cdf0e10cSrcweir 193cdf0e10cSrcweir if( xParagraph.is() ) 194cdf0e10cSrcweir aDescription = xParagraph->getString(); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir } 197cdf0e10cSrcweir else 198cdf0e10cSrcweir { 199cdf0e10cSrcweir Reference< XShape > xShape; 200cdf0e10cSrcweir rTarget >>= xShape; 201cdf0e10cSrcweir if( xShape.is() ) 202cdf0e10cSrcweir aDescription = getShapeDescription( xShape, bWithText ); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir return aDescription; 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir // ==================================================================== 209cdf0e10cSrcweir 210cdf0e10cSrcweir class CustomAnimationListEntryItem : public SvLBoxString 211cdf0e10cSrcweir { 212cdf0e10cSrcweir public: 213cdf0e10cSrcweir CustomAnimationListEntryItem( SvLBoxEntry*,sal_uInt16 nFlags, OUString aDescription, CustomAnimationEffectPtr pEffect, CustomAnimationList* pParent ); 214cdf0e10cSrcweir virtual ~CustomAnimationListEntryItem(); 215cdf0e10cSrcweir void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* ); 216cdf0e10cSrcweir void Paint( const Point&, SvLBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* ); 217cdf0e10cSrcweir SvLBoxItem* Create() const; 218cdf0e10cSrcweir void Clone( SvLBoxItem* pSource ); 219cdf0e10cSrcweir 220cdf0e10cSrcweir private: 221cdf0e10cSrcweir CustomAnimationList* mpParent; 222cdf0e10cSrcweir OUString maDescription; 223cdf0e10cSrcweir CustomAnimationEffectPtr mpEffect; 224cdf0e10cSrcweir }; 225cdf0e10cSrcweir 226cdf0e10cSrcweir // -------------------------------------------------------------------- 227cdf0e10cSrcweir 228cdf0e10cSrcweir CustomAnimationListEntryItem::CustomAnimationListEntryItem( SvLBoxEntry* pEntry, sal_uInt16 nFlags, OUString aDescription, CustomAnimationEffectPtr pEffect, CustomAnimationList* pParent ) 229cdf0e10cSrcweir : SvLBoxString( pEntry, nFlags, aDescription ) 230cdf0e10cSrcweir , mpParent( pParent ) 231cdf0e10cSrcweir , maDescription( aDescription ) 232cdf0e10cSrcweir , mpEffect(pEffect) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir // -------------------------------------------------------------------- 237cdf0e10cSrcweir 238cdf0e10cSrcweir CustomAnimationListEntryItem::~CustomAnimationListEntryItem() 239cdf0e10cSrcweir { 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 242cdf0e10cSrcweir // -------------------------------------------------------------------- 243cdf0e10cSrcweir 244cdf0e10cSrcweir void CustomAnimationListEntryItem::InitViewData( SvLBox* pView, SvLBoxEntry* pEntry, SvViewDataItem* pViewData ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir if( !pViewData ) 247cdf0e10cSrcweir pViewData = pView->GetViewDataItem( pEntry, this ); 248cdf0e10cSrcweir 249cdf0e10cSrcweir Size aSize(pView->GetTextWidth( maDescription ) + 2 * 19, pView->GetTextHeight() ); 250cdf0e10cSrcweir if( aSize.Height() < 19 ) 251cdf0e10cSrcweir aSize.Height() = 19; 252cdf0e10cSrcweir pViewData->aSize = aSize; 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir // -------------------------------------------------------------------- 256cdf0e10cSrcweir 257cdf0e10cSrcweir void CustomAnimationListEntryItem::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16, SvLBoxEntry* pEntry ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir const bool bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); 260cdf0e10cSrcweir 261cdf0e10cSrcweir SvViewDataItem* pViewData = mpParent->GetViewDataItem( pEntry, this ); 262cdf0e10cSrcweir 263cdf0e10cSrcweir Point aPos( rPos ); 264cdf0e10cSrcweir Size aSize( pViewData->aSize ); 265cdf0e10cSrcweir 266cdf0e10cSrcweir sal_Int16 nNodeType = mpEffect->getNodeType(); 267cdf0e10cSrcweir if( nNodeType == EffectNodeType::ON_CLICK ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir rDev.DrawImage( aPos, mpParent->getImage( IMG_CUSTOMANIMATION_ON_CLICK, bHighContrast ) ); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir else if( nNodeType == EffectNodeType::AFTER_PREVIOUS ) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir rDev.DrawImage( aPos, mpParent->getImage( IMG_CUSTOMANIMATION_AFTER_PREVIOUS, bHighContrast ) ); 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir aPos.X() += 19; 277cdf0e10cSrcweir 278cdf0e10cSrcweir sal_uInt16 nImage; 279cdf0e10cSrcweir switch( mpEffect->getPresetClass() ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir case EffectPresetClass::ENTRANCE: nImage = IMG_CUSTOMANIMATION_ENTRANCE_EFFECT; break; 282cdf0e10cSrcweir case EffectPresetClass::EXIT: nImage = IMG_CUSTOMANIMATION_EXIT_EFFECT; break; 283cdf0e10cSrcweir case EffectPresetClass::EMPHASIS: nImage = IMG_CUSTOMANIMATION_EMPHASIS_EFFECT; break; 284cdf0e10cSrcweir case EffectPresetClass::MOTIONPATH: nImage = IMG_CUSTOMANIMATION_MOTION_PATH; break; 285cdf0e10cSrcweir case EffectPresetClass::OLEACTION: nImage = IMG_CUSTOMANIMATION_OLE; break; 286cdf0e10cSrcweir case EffectPresetClass::MEDIACALL: 287cdf0e10cSrcweir switch( mpEffect->getCommand() ) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir case EffectCommands::TOGGLEPAUSE: nImage = IMG_CUSTOMANIMATION_MEDIA_PAUSE; break; 290cdf0e10cSrcweir case EffectCommands::STOP: nImage = IMG_CUSTOMANIMATION_MEDIA_STOP; break; 291cdf0e10cSrcweir case EffectCommands::PLAY: 292cdf0e10cSrcweir default: nImage = IMG_CUSTOMANIMATION_MEDIA_PLAY; break; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir break; 295cdf0e10cSrcweir default: nImage = 0xffff; 296cdf0e10cSrcweir } 297cdf0e10cSrcweir 298cdf0e10cSrcweir if( nImage != 0xffff ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir const Image& rImage = mpParent->getImage( nImage, bHighContrast ); 301cdf0e10cSrcweir Point aImagePos( aPos ); 302cdf0e10cSrcweir aImagePos.Y() += ( aSize.Height() - rImage.GetSizePixel().Height() ) >> 1; 303cdf0e10cSrcweir rDev.DrawImage( aImagePos, rImage ); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir aPos.X() += 19; 307cdf0e10cSrcweir aPos.Y() += ( aSize.Height() - rDev.GetTextHeight()) >> 1; 308cdf0e10cSrcweir 309cdf0e10cSrcweir rDev.DrawText( aPos, rDev.GetEllipsisString( maDescription, rDev.GetOutputSizePixel().Width() - aPos.X() ) ); 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir // -------------------------------------------------------------------- 313cdf0e10cSrcweir 314cdf0e10cSrcweir SvLBoxItem* CustomAnimationListEntryItem::Create() const 315cdf0e10cSrcweir { 316cdf0e10cSrcweir return NULL; 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir // -------------------------------------------------------------------- 320cdf0e10cSrcweir 321cdf0e10cSrcweir void CustomAnimationListEntryItem::Clone( SvLBoxItem* ) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir // ==================================================================== 326cdf0e10cSrcweir 327cdf0e10cSrcweir class CustomAnimationListEntry : public SvLBoxEntry 328cdf0e10cSrcweir { 329cdf0e10cSrcweir public: 330cdf0e10cSrcweir CustomAnimationListEntry(); 331cdf0e10cSrcweir CustomAnimationListEntry( CustomAnimationEffectPtr pEffect ); 332cdf0e10cSrcweir virtual ~CustomAnimationListEntry(); 333cdf0e10cSrcweir 334cdf0e10cSrcweir CustomAnimationEffectPtr getEffect() const { return mpEffect; } 335cdf0e10cSrcweir 336cdf0e10cSrcweir private: 337cdf0e10cSrcweir CustomAnimationEffectPtr mpEffect; 338cdf0e10cSrcweir }; 339cdf0e10cSrcweir 340cdf0e10cSrcweir // -------------------------------------------------------------------- 341cdf0e10cSrcweir 342cdf0e10cSrcweir CustomAnimationListEntry::CustomAnimationListEntry() 343cdf0e10cSrcweir { 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir // -------------------------------------------------------------------- 347cdf0e10cSrcweir 348cdf0e10cSrcweir CustomAnimationListEntry::CustomAnimationListEntry( CustomAnimationEffectPtr pEffect ) 349cdf0e10cSrcweir : mpEffect( pEffect ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir // -------------------------------------------------------------------- 354cdf0e10cSrcweir 355cdf0e10cSrcweir CustomAnimationListEntry::~CustomAnimationListEntry() 356cdf0e10cSrcweir { 357cdf0e10cSrcweir } 358cdf0e10cSrcweir 359cdf0e10cSrcweir // ==================================================================== 360cdf0e10cSrcweir 361cdf0e10cSrcweir class CustomAnimationTriggerEntryItem : public SvLBoxString 362cdf0e10cSrcweir { 363cdf0e10cSrcweir public: 364cdf0e10cSrcweir CustomAnimationTriggerEntryItem( SvLBoxEntry*,sal_uInt16 nFlags, OUString aDescription, CustomAnimationList* pParent ); 365cdf0e10cSrcweir virtual ~CustomAnimationTriggerEntryItem(); 366cdf0e10cSrcweir virtual sal_uInt16 IsA(); 367cdf0e10cSrcweir void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* ); 368cdf0e10cSrcweir void Paint( const Point&, SvLBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* ); 369cdf0e10cSrcweir SvLBoxItem* Create() const; 370cdf0e10cSrcweir void Clone( SvLBoxItem* pSource ); 371cdf0e10cSrcweir 372cdf0e10cSrcweir private: 373cdf0e10cSrcweir CustomAnimationList* mpParent; 374cdf0e10cSrcweir OUString maDescription; 375cdf0e10cSrcweir }; 376cdf0e10cSrcweir 377cdf0e10cSrcweir // -------------------------------------------------------------------- 378cdf0e10cSrcweir 379cdf0e10cSrcweir CustomAnimationTriggerEntryItem::CustomAnimationTriggerEntryItem( SvLBoxEntry* pEntry, sal_uInt16 nFlags, OUString aDescription, CustomAnimationList* pParent ) 380cdf0e10cSrcweir : SvLBoxString( pEntry, nFlags, aDescription ), mpParent( pParent ), maDescription( aDescription ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir } 383cdf0e10cSrcweir 384cdf0e10cSrcweir // -------------------------------------------------------------------- 385cdf0e10cSrcweir 386cdf0e10cSrcweir CustomAnimationTriggerEntryItem::~CustomAnimationTriggerEntryItem() 387cdf0e10cSrcweir { 388cdf0e10cSrcweir } 389cdf0e10cSrcweir 390cdf0e10cSrcweir // -------------------------------------------------------------------- 391cdf0e10cSrcweir 392cdf0e10cSrcweir sal_uInt16 CustomAnimationTriggerEntryItem::IsA() 393cdf0e10cSrcweir { 394cdf0e10cSrcweir return (sal_uInt16)-1; 395cdf0e10cSrcweir } 396cdf0e10cSrcweir 397cdf0e10cSrcweir // -------------------------------------------------------------------- 398cdf0e10cSrcweir 399cdf0e10cSrcweir void CustomAnimationTriggerEntryItem::InitViewData( SvLBox* pView, SvLBoxEntry* pEntry, SvViewDataItem* pViewData ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir if( !pViewData ) 402cdf0e10cSrcweir pViewData = pView->GetViewDataItem( pEntry, this ); 403cdf0e10cSrcweir 404cdf0e10cSrcweir Size aSize(pView->GetTextWidth( maDescription ) + 2 * 19, pView->GetTextHeight() ); 405cdf0e10cSrcweir if( aSize.Height() < 19 ) 406cdf0e10cSrcweir aSize.Height() = 19; 407cdf0e10cSrcweir pViewData->aSize = aSize; 408cdf0e10cSrcweir 409cdf0e10cSrcweir /* 410cdf0e10cSrcweir SvViewData* pViewData = pView->GetViewData( pEntry ); 411cdf0e10cSrcweir if( pViewData ) 412cdf0e10cSrcweir pViewData->SetSelectable(false); 413cdf0e10cSrcweir */ 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir // -------------------------------------------------------------------- 417cdf0e10cSrcweir 418cdf0e10cSrcweir void CustomAnimationTriggerEntryItem::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16, SvLBoxEntry* ) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir Size aSize( rDev.GetOutputSizePixel().Width(), static_cast< SvTreeListBox* >(&rDev)->GetEntryHeight() ); 421cdf0e10cSrcweir 422cdf0e10cSrcweir Point aPos( 0, rPos.Y() ); 423cdf0e10cSrcweir 424cdf0e10cSrcweir Rectangle aOutRect( aPos, aSize ); 425cdf0e10cSrcweir 426cdf0e10cSrcweir // fill the background 427cdf0e10cSrcweir Color aColor (rDev.GetSettings().GetStyleSettings().GetDialogColor()); 428cdf0e10cSrcweir 429cdf0e10cSrcweir rDev.Push(); 430cdf0e10cSrcweir rDev.SetFillColor (aColor); 431cdf0e10cSrcweir rDev.SetLineColor (); 432cdf0e10cSrcweir rDev.DrawRect(aOutRect); 433cdf0e10cSrcweir 434cdf0e10cSrcweir // Erase the four corner pixels to make the rectangle appear rounded. 435cdf0e10cSrcweir rDev.SetLineColor( rDev.GetSettings().GetStyleSettings().GetWindowColor()); 436cdf0e10cSrcweir rDev.DrawPixel( aOutRect.TopLeft()); 437cdf0e10cSrcweir rDev.DrawPixel( Point(aOutRect.Right(), aOutRect.Top())); 438cdf0e10cSrcweir rDev.DrawPixel( Point(aOutRect.Left(), aOutRect.Bottom())); 439cdf0e10cSrcweir rDev.DrawPixel( Point(aOutRect.Right(), aOutRect.Bottom())); 440cdf0e10cSrcweir 441cdf0e10cSrcweir // draw the category title 442cdf0e10cSrcweir 443cdf0e10cSrcweir int nVertBorder = (( aSize.Height() - rDev.GetTextHeight()) >> 1); 444cdf0e10cSrcweir int nHorzBorder = rDev.LogicToPixel( Size( 3, 3 ), MAP_APPFONT ).Width(); 445cdf0e10cSrcweir 446cdf0e10cSrcweir aOutRect.nLeft += nHorzBorder; 447cdf0e10cSrcweir aOutRect.nRight -= nHorzBorder; 448cdf0e10cSrcweir aOutRect.nTop += nVertBorder; 449cdf0e10cSrcweir aOutRect.nBottom -= nVertBorder; 450cdf0e10cSrcweir 451cdf0e10cSrcweir rDev.DrawText (aOutRect, rDev.GetEllipsisString( maDescription, aOutRect.GetWidth() ) ); 452cdf0e10cSrcweir rDev.Pop(); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir // -------------------------------------------------------------------- 456cdf0e10cSrcweir 457cdf0e10cSrcweir SvLBoxItem* CustomAnimationTriggerEntryItem::Create() const 458cdf0e10cSrcweir { 459cdf0e10cSrcweir return NULL; 460cdf0e10cSrcweir } 461cdf0e10cSrcweir 462cdf0e10cSrcweir // -------------------------------------------------------------------- 463cdf0e10cSrcweir 464cdf0e10cSrcweir void CustomAnimationTriggerEntryItem::Clone( SvLBoxItem* ) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir // ==================================================================== 469cdf0e10cSrcweir 470cdf0e10cSrcweir CustomAnimationList::CustomAnimationList( ::Window* pParent, const ResId& rResId, ICustomAnimationListController* pController ) 471cdf0e10cSrcweir : SvTreeListBox( pParent, rResId ) 472cdf0e10cSrcweir , mbIgnorePaint( false ) 473cdf0e10cSrcweir , mpController( pController ) 474cdf0e10cSrcweir , mpLastParentEntry(0) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT ); 477cdf0e10cSrcweir 478cdf0e10cSrcweir EnableContextMenuHandling(); 479cdf0e10cSrcweir SetSelectionMode( MULTIPLE_SELECTION ); 480cdf0e10cSrcweir SetIndent(16); 481cdf0e10cSrcweir SetNodeDefaultImages(); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir 484cdf0e10cSrcweir // -------------------------------------------------------------------- 485cdf0e10cSrcweir 486cdf0e10cSrcweir const Image& CustomAnimationList::getImage( sal_uInt16 nId, bool bHighContrast ) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir DBG_ASSERT( (nId >= IMG_CUSTOMANIMATION_ON_CLICK) && (nId <= IMG_CUSTOMANIMATION_MEDIA_STOP), "sd::CustomAnimationList::getImage(), illegal index!" ); 489cdf0e10cSrcweir 490cdf0e10cSrcweir if( bHighContrast ) 491cdf0e10cSrcweir nId += 1; 492cdf0e10cSrcweir 493cdf0e10cSrcweir Image& rImage = maImages[nId - IMG_CUSTOMANIMATION_ON_CLICK]; 494cdf0e10cSrcweir 495cdf0e10cSrcweir // load on demand 496cdf0e10cSrcweir if( rImage.GetSizePixel().Width() == 0 ) 497cdf0e10cSrcweir rImage = Image(SdResId( nId ) ); 498cdf0e10cSrcweir 499cdf0e10cSrcweir return rImage; 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir // -------------------------------------------------------------------- 503cdf0e10cSrcweir 504cdf0e10cSrcweir CustomAnimationList::~CustomAnimationList() 505cdf0e10cSrcweir { 506cdf0e10cSrcweir if( mpMainSequence.get() ) 507cdf0e10cSrcweir mpMainSequence->removeListener( this ); 508cdf0e10cSrcweir 509cdf0e10cSrcweir clear(); 510cdf0e10cSrcweir } 511cdf0e10cSrcweir 512cdf0e10cSrcweir // -------------------------------------------------------------------- 513cdf0e10cSrcweir 514cdf0e10cSrcweir void CustomAnimationList::KeyInput( const KeyEvent& rKEvt ) 515cdf0e10cSrcweir { 516cdf0e10cSrcweir const int nKeyCode = rKEvt.GetKeyCode().GetCode(); 517cdf0e10cSrcweir switch( nKeyCode ) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir case KEY_DELETE: mpController->onContextMenu( CM_REMOVE ); return; 520cdf0e10cSrcweir case KEY_INSERT: mpController->onContextMenu( CM_CREATE ); return; 521cdf0e10cSrcweir case KEY_SPACE: 522cdf0e10cSrcweir { 523cdf0e10cSrcweir const Point aPos; 524cdf0e10cSrcweir const CommandEvent aCEvt( aPos, COMMAND_CONTEXTMENU ); 525cdf0e10cSrcweir Command( aCEvt ); 526cdf0e10cSrcweir return; 527cdf0e10cSrcweir } 528cdf0e10cSrcweir 529cdf0e10cSrcweir } 530cdf0e10cSrcweir 531cdf0e10cSrcweir ::SvTreeListBox::KeyInput( rKEvt ); 532cdf0e10cSrcweir } 533cdf0e10cSrcweir 534cdf0e10cSrcweir // -------------------------------------------------------------------- 535cdf0e10cSrcweir 536cdf0e10cSrcweir /** selects or deselects the given effect. 537cdf0e10cSrcweir Selections of other effects are not changed */ 538cdf0e10cSrcweir void CustomAnimationList::select( CustomAnimationEffectPtr pEffect, bool bSelect /* = true */ ) 539cdf0e10cSrcweir { 540cdf0e10cSrcweir CustomAnimationListEntry* pEntry = static_cast< CustomAnimationListEntry* >(First()); 541cdf0e10cSrcweir while( pEntry ) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir if( pEntry->getEffect() == pEffect ) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir Select( pEntry, bSelect ); 546cdf0e10cSrcweir break; 547cdf0e10cSrcweir } 548cdf0e10cSrcweir pEntry = static_cast< CustomAnimationListEntry* >(Next( pEntry )); 549cdf0e10cSrcweir } 550cdf0e10cSrcweir 551cdf0e10cSrcweir if( !pEntry && bSelect ) 552cdf0e10cSrcweir { 553cdf0e10cSrcweir append( pEffect ); 554cdf0e10cSrcweir select( pEffect ); 555cdf0e10cSrcweir } 556cdf0e10cSrcweir } 557cdf0e10cSrcweir 558cdf0e10cSrcweir // -------------------------------------------------------------------- 559cdf0e10cSrcweir 560cdf0e10cSrcweir void CustomAnimationList::clear() 561cdf0e10cSrcweir { 562cdf0e10cSrcweir Clear(); 563cdf0e10cSrcweir 564cdf0e10cSrcweir mpLastParentEntry = 0; 565cdf0e10cSrcweir mxLastTargetShape = 0; 566cdf0e10cSrcweir } 567cdf0e10cSrcweir 568cdf0e10cSrcweir // -------------------------------------------------------------------- 569cdf0e10cSrcweir 570cdf0e10cSrcweir void CustomAnimationList::update( MainSequencePtr pMainSequence ) 571cdf0e10cSrcweir { 572cdf0e10cSrcweir if( mpMainSequence.get() ) 573cdf0e10cSrcweir mpMainSequence->removeListener( this ); 574cdf0e10cSrcweir 575cdf0e10cSrcweir mpMainSequence = pMainSequence; 576cdf0e10cSrcweir update(); 577cdf0e10cSrcweir 578cdf0e10cSrcweir if( mpMainSequence.get() ) 579cdf0e10cSrcweir mpMainSequence->addListener( this ); 580cdf0e10cSrcweir } 581cdf0e10cSrcweir 582cdf0e10cSrcweir // -------------------------------------------------------------------- 583cdf0e10cSrcweir 584cdf0e10cSrcweir struct stl_append_effect_func : public std::unary_function<CustomAnimationEffectPtr, void> 585cdf0e10cSrcweir { 586cdf0e10cSrcweir stl_append_effect_func( CustomAnimationList& rList ) : mrList( rList ) {} 587cdf0e10cSrcweir void operator()(CustomAnimationEffectPtr pEffect); 588cdf0e10cSrcweir CustomAnimationList& mrList; 589cdf0e10cSrcweir }; 590cdf0e10cSrcweir 591cdf0e10cSrcweir void stl_append_effect_func::operator()(CustomAnimationEffectPtr pEffect) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir mrList.append( pEffect ); 594cdf0e10cSrcweir } 595cdf0e10cSrcweir // -------------------------------------------------------------------- 596cdf0e10cSrcweir 597cdf0e10cSrcweir void CustomAnimationList::update() 598cdf0e10cSrcweir { 599cdf0e10cSrcweir mbIgnorePaint = true; 600cdf0e10cSrcweir 601cdf0e10cSrcweir CustomAnimationListEntry* pEntry = 0; 602cdf0e10cSrcweir 603cdf0e10cSrcweir std::list< CustomAnimationEffectPtr > aExpanded; 604cdf0e10cSrcweir std::list< CustomAnimationEffectPtr > aSelected; 605cdf0e10cSrcweir 606cdf0e10cSrcweir CustomAnimationEffectPtr pFirstVisibleEffect; 607cdf0e10cSrcweir 608cdf0e10cSrcweir if( mpMainSequence.get() ) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir // save selection and expand states 611cdf0e10cSrcweir pEntry = static_cast<CustomAnimationListEntry*>(FirstVisible()); 612cdf0e10cSrcweir if( pEntry ) 613cdf0e10cSrcweir pFirstVisibleEffect = pEntry->getEffect(); 614cdf0e10cSrcweir 615cdf0e10cSrcweir pEntry = static_cast<CustomAnimationListEntry*>(First()); 616cdf0e10cSrcweir 617cdf0e10cSrcweir while( pEntry ) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir CustomAnimationEffectPtr pEffect( pEntry->getEffect() ); 620cdf0e10cSrcweir if( pEffect.get() ) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir if( IsExpanded( pEntry ) ) 623cdf0e10cSrcweir aExpanded.push_back( pEffect ); 624cdf0e10cSrcweir 625cdf0e10cSrcweir if( IsSelected( pEntry ) ) 626cdf0e10cSrcweir aSelected.push_back( pEffect ); 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir pEntry = static_cast<CustomAnimationListEntry*>(Next( pEntry )); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir } 632cdf0e10cSrcweir 633cdf0e10cSrcweir // rebuild list 634cdf0e10cSrcweir clear(); 635cdf0e10cSrcweir if( mpMainSequence.get() ) 636cdf0e10cSrcweir { 637cdf0e10cSrcweir std::for_each( mpMainSequence->getBegin(), mpMainSequence->getEnd(), stl_append_effect_func( *this ) ); 638cdf0e10cSrcweir mpLastParentEntry = 0; 639cdf0e10cSrcweir 640cdf0e10cSrcweir const InteractiveSequenceList& rISL = mpMainSequence->getInteractiveSequenceList(); 641cdf0e10cSrcweir 642cdf0e10cSrcweir InteractiveSequenceList::const_iterator aIter( rISL.begin() ); 643cdf0e10cSrcweir const InteractiveSequenceList::const_iterator aEnd( rISL.end() ); 644cdf0e10cSrcweir while( aIter != aEnd ) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir InteractiveSequencePtr pIS( (*aIter++) ); 647cdf0e10cSrcweir 648cdf0e10cSrcweir Reference< XShape > xShape( pIS->getTriggerShape() ); 649cdf0e10cSrcweir if( xShape.is() ) 650cdf0e10cSrcweir { 651cdf0e10cSrcweir SvLBoxEntry* pLBoxEntry = new CustomAnimationListEntry; 652cdf0e10cSrcweir pLBoxEntry->AddItem( new SvLBoxContextBmp( pLBoxEntry, 0, Image(), Image(), 0)); 653cdf0e10cSrcweir OUString aDescription = String( SdResId( STR_CUSTOMANIMATION_TRIGGER ) ); 654cdf0e10cSrcweir aDescription += OUString( RTL_CONSTASCII_USTRINGPARAM(": ") ); 655cdf0e10cSrcweir aDescription += getShapeDescription( xShape, false ); 656cdf0e10cSrcweir pLBoxEntry->AddItem( new CustomAnimationTriggerEntryItem( pLBoxEntry, 0, aDescription, this ) ); 657cdf0e10cSrcweir Insert( pLBoxEntry ); 658cdf0e10cSrcweir SvViewData* pViewData = GetViewData( pLBoxEntry ); 659cdf0e10cSrcweir if( pViewData ) 660cdf0e10cSrcweir pViewData->SetSelectable(false); 661cdf0e10cSrcweir 662cdf0e10cSrcweir std::for_each( pIS->getBegin(), pIS->getEnd(), stl_append_effect_func( *this ) ); 663cdf0e10cSrcweir mpLastParentEntry = 0; 664cdf0e10cSrcweir } 665cdf0e10cSrcweir } 666cdf0e10cSrcweir 667cdf0e10cSrcweir // restore selection and expand states 668cdf0e10cSrcweir pEntry = static_cast<CustomAnimationListEntry*>(First()); 669cdf0e10cSrcweir 670cdf0e10cSrcweir while( pEntry ) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir CustomAnimationEffectPtr pEffect( pEntry->getEffect() ); 673cdf0e10cSrcweir if( pEffect.get() ) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir if( std::find( aExpanded.begin(), aExpanded.end(), pEffect ) != aExpanded.end() ) 676cdf0e10cSrcweir Expand( pEntry ); 677cdf0e10cSrcweir 678cdf0e10cSrcweir if( std::find( aSelected.begin(), aSelected.end(), pEffect ) != aSelected.end() ) 679cdf0e10cSrcweir Select( pEntry ); 680cdf0e10cSrcweir 681cdf0e10cSrcweir if( pFirstVisibleEffect == pEffect ) 682cdf0e10cSrcweir MakeVisible( pEntry ); 683cdf0e10cSrcweir } 684cdf0e10cSrcweir 685cdf0e10cSrcweir pEntry = static_cast<CustomAnimationListEntry*>(Next( pEntry )); 686cdf0e10cSrcweir } 687cdf0e10cSrcweir } 688cdf0e10cSrcweir 689cdf0e10cSrcweir mbIgnorePaint = false; 690cdf0e10cSrcweir Invalidate(); 691cdf0e10cSrcweir } 692cdf0e10cSrcweir 693cdf0e10cSrcweir // -------------------------------------------------------------------- 694cdf0e10cSrcweir 695cdf0e10cSrcweir /* 696cdf0e10cSrcweir void CustomAnimationList::update( CustomAnimationEffectPtr pEffect ) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir SvLBoxEntry* pEntry = First(); 699cdf0e10cSrcweir while( pEntry ) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir if( static_cast< CustomAnimationEffectPtr * >( pEntry->GetUserData() )->get() == pEffect.get() ) 702cdf0e10cSrcweir { 703cdf0e10cSrcweir CustomAnimationPresetsPtr pPresets = mpController->getPresets(); 704cdf0e10cSrcweir const CustomAnimationPresetPtr pPreset = pPresets->getEffectDescriptor( pEffect->getPresetId() ); 705cdf0e10cSrcweir if( pPreset.get() ) 706cdf0e10cSrcweir pEffect->setName( pPresets->getUINameForPresetId( pPreset->getPresetId() ) ); 707cdf0e10cSrcweir else 708cdf0e10cSrcweir pEffect->setName( pEffect->getPresetId() ); 709cdf0e10cSrcweir break; 710cdf0e10cSrcweir } 711cdf0e10cSrcweir pEntry = Next( pEntry ); 712cdf0e10cSrcweir } 713cdf0e10cSrcweir 714cdf0e10cSrcweir Invalidate(); 715cdf0e10cSrcweir } 716cdf0e10cSrcweir */ 717cdf0e10cSrcweir 718cdf0e10cSrcweir // -------------------------------------------------------------------- 719cdf0e10cSrcweir 720cdf0e10cSrcweir void CustomAnimationList::append( CustomAnimationEffectPtr pEffect ) 721cdf0e10cSrcweir { 722cdf0e10cSrcweir // create a ui description 723cdf0e10cSrcweir OUString aDescription; 724cdf0e10cSrcweir 725cdf0e10cSrcweir Any aTarget( pEffect->getTarget() ); 726cdf0e10cSrcweir if( aTarget.hasValue() ) try 727cdf0e10cSrcweir { 728cdf0e10cSrcweir aDescription = getDescription( aTarget, pEffect->getTargetSubItem() != ShapeAnimationSubType::ONLY_BACKGROUND ); 729cdf0e10cSrcweir 730cdf0e10cSrcweir SvLBoxEntry* pParentEntry = 0; 731cdf0e10cSrcweir 732cdf0e10cSrcweir Reference< XShape > xTargetShape( pEffect->getTargetShape() ); 733cdf0e10cSrcweir sal_Int32 nGroupId = pEffect->getGroupId(); 734cdf0e10cSrcweir 735cdf0e10cSrcweir // if this effect has the same target and group-id as the last root effect, 736cdf0e10cSrcweir // the last root effect is also this effects parent 737cdf0e10cSrcweir if( mpLastParentEntry && (nGroupId != -1) && (mxLastTargetShape == xTargetShape) && (mnLastGroupId == nGroupId) ) 738cdf0e10cSrcweir pParentEntry = mpLastParentEntry; 739cdf0e10cSrcweir 740cdf0e10cSrcweir // create an entry for the effect 741cdf0e10cSrcweir SvLBoxEntry* pEntry = new CustomAnimationListEntry( pEffect ); 742cdf0e10cSrcweir 743cdf0e10cSrcweir pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0)); 744cdf0e10cSrcweir pEntry->AddItem( new CustomAnimationListEntryItem( pEntry, 0, aDescription, pEffect, this ) ); 745cdf0e10cSrcweir 746cdf0e10cSrcweir if( pParentEntry ) 747cdf0e10cSrcweir { 748cdf0e10cSrcweir // add a subentry 749cdf0e10cSrcweir Insert( pEntry, pParentEntry ); 750cdf0e10cSrcweir } 751cdf0e10cSrcweir else 752cdf0e10cSrcweir { 753cdf0e10cSrcweir // add a root entry 754cdf0e10cSrcweir Insert( pEntry ); 755cdf0e10cSrcweir 756cdf0e10cSrcweir // and the new root entry becomes the possible next group header 757cdf0e10cSrcweir mxLastTargetShape = xTargetShape; 758cdf0e10cSrcweir mnLastGroupId = nGroupId; 759cdf0e10cSrcweir mpLastParentEntry = pEntry; 760cdf0e10cSrcweir } 761cdf0e10cSrcweir } 762cdf0e10cSrcweir catch( Exception& e ) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir (void)e; 765cdf0e10cSrcweir DBG_ERROR("sd::CustomAnimationList::append(), exception catched!" ); 766cdf0e10cSrcweir } 767cdf0e10cSrcweir } 768cdf0e10cSrcweir 769cdf0e10cSrcweir // -------------------------------------------------------------------- 770cdf0e10cSrcweir 771cdf0e10cSrcweir /* 772cdf0e10cSrcweir void CustomAnimationList::remove( CustomAnimationEffectPtr pEffect ) 773cdf0e10cSrcweir { 774cdf0e10cSrcweir SvLBoxEntry* pEntry = First(); 775cdf0e10cSrcweir while( pEntry ) 776cdf0e10cSrcweir { 777cdf0e10cSrcweir if( static_cast< CustomAnimationEffectPtr * >( pEntry->GetUserData() )->get() == pEffect.get() ) 778cdf0e10cSrcweir { 779cdf0e10cSrcweir GetModel()->Remove( pEntry ); 780cdf0e10cSrcweir if( pEntry == mpLastParentEntry ) 781cdf0e10cSrcweir { 782cdf0e10cSrcweir mpLastParentEntry = 0; 783cdf0e10cSrcweir mxLastTargetShape = 0; 784cdf0e10cSrcweir } 785cdf0e10cSrcweir break; 786cdf0e10cSrcweir } 787cdf0e10cSrcweir pEntry = Next( pEntry ); 788cdf0e10cSrcweir } 789cdf0e10cSrcweir 790cdf0e10cSrcweir Invalidate(); 791cdf0e10cSrcweir } 792cdf0e10cSrcweir */ 793cdf0e10cSrcweir 794cdf0e10cSrcweir // -------------------------------------------------------------------- 795cdf0e10cSrcweir 796cdf0e10cSrcweir void selectShape( SvTreeListBox* pTreeList, Reference< XShape > xShape ) 797cdf0e10cSrcweir { 798cdf0e10cSrcweir CustomAnimationListEntry* pEntry = static_cast< CustomAnimationListEntry* >(pTreeList->First()); 799cdf0e10cSrcweir while( pEntry ) 800cdf0e10cSrcweir { 801cdf0e10cSrcweir CustomAnimationEffectPtr pEffect( pEntry->getEffect() ); 802cdf0e10cSrcweir if( pEffect.get() ) 803cdf0e10cSrcweir { 804cdf0e10cSrcweir if( pEffect->getTarget() == xShape ) 805cdf0e10cSrcweir pTreeList->Select( pEntry ); 806cdf0e10cSrcweir } 807cdf0e10cSrcweir 808cdf0e10cSrcweir pEntry = static_cast< CustomAnimationListEntry* >(pTreeList->Next( pEntry )); 809cdf0e10cSrcweir } 810cdf0e10cSrcweir } 811cdf0e10cSrcweir 812cdf0e10cSrcweir // -------------------------------------------------------------------- 813cdf0e10cSrcweir 814cdf0e10cSrcweir void CustomAnimationList::onSelectionChanged( Any aSelection ) 815cdf0e10cSrcweir { 816cdf0e10cSrcweir try 817cdf0e10cSrcweir { 818cdf0e10cSrcweir SelectAll(sal_False); 819cdf0e10cSrcweir 820cdf0e10cSrcweir if( aSelection.hasValue() ) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir Reference< XIndexAccess > xShapes( aSelection, UNO_QUERY ); 823cdf0e10cSrcweir if( xShapes.is() ) 824cdf0e10cSrcweir { 825cdf0e10cSrcweir sal_Int32 nCount = xShapes->getCount(); 826cdf0e10cSrcweir sal_Int32 nIndex; 827cdf0e10cSrcweir for( nIndex = 0; nIndex < nCount; nIndex++ ) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir Reference< XShape > xShape( xShapes->getByIndex( nIndex ), UNO_QUERY ); 830cdf0e10cSrcweir if( xShape.is() ) 831cdf0e10cSrcweir selectShape( this, xShape ); 832cdf0e10cSrcweir } 833cdf0e10cSrcweir } 834cdf0e10cSrcweir else 835cdf0e10cSrcweir { 836cdf0e10cSrcweir Reference< XShape > xShape( aSelection, UNO_QUERY ); 837cdf0e10cSrcweir if( xShape.is() ) 838cdf0e10cSrcweir selectShape( this, xShape ); 839cdf0e10cSrcweir } 840cdf0e10cSrcweir } 841cdf0e10cSrcweir 842cdf0e10cSrcweir SelectHdl(); 843cdf0e10cSrcweir } 844cdf0e10cSrcweir catch( Exception& ) 845cdf0e10cSrcweir { 846cdf0e10cSrcweir DBG_ERROR( "sd::CustomAnimationList::onSelectionChanged(), Exception catched!" ); 847cdf0e10cSrcweir } 848cdf0e10cSrcweir } 849cdf0e10cSrcweir 850cdf0e10cSrcweir // -------------------------------------------------------------------- 851cdf0e10cSrcweir 852cdf0e10cSrcweir void CustomAnimationList::SelectHdl() 853cdf0e10cSrcweir { 854cdf0e10cSrcweir SvTreeListBox::SelectHdl(); 855cdf0e10cSrcweir mpController->onSelect(); 856cdf0e10cSrcweir } 857cdf0e10cSrcweir 858cdf0e10cSrcweir // -------------------------------------------------------------------- 859cdf0e10cSrcweir 860cdf0e10cSrcweir bool CustomAnimationList::isExpanded( const CustomAnimationEffectPtr& pEffect ) const 861cdf0e10cSrcweir { 862cdf0e10cSrcweir CustomAnimationListEntry* pEntry = static_cast<CustomAnimationListEntry*>(First()); 863cdf0e10cSrcweir 864cdf0e10cSrcweir while( pEntry ) 865cdf0e10cSrcweir { 866cdf0e10cSrcweir if( pEntry->getEffect() == pEffect ) 867cdf0e10cSrcweir break; 868cdf0e10cSrcweir 869cdf0e10cSrcweir pEntry = static_cast<CustomAnimationListEntry*>(Next( pEntry )); 870cdf0e10cSrcweir } 871cdf0e10cSrcweir 872cdf0e10cSrcweir if( pEntry ) 873cdf0e10cSrcweir pEntry = static_cast<CustomAnimationListEntry*>(GetParent( pEntry )); 874cdf0e10cSrcweir 875cdf0e10cSrcweir return (pEntry == 0) || IsExpanded( pEntry ); 876cdf0e10cSrcweir } 877cdf0e10cSrcweir 878cdf0e10cSrcweir // -------------------------------------------------------------------- 879cdf0e10cSrcweir EffectSequence CustomAnimationList::getSelection() const 880cdf0e10cSrcweir { 881cdf0e10cSrcweir EffectSequence aSelection; 882cdf0e10cSrcweir 883cdf0e10cSrcweir CustomAnimationListEntry* pEntry = dynamic_cast< CustomAnimationListEntry* >(FirstSelected()); 884cdf0e10cSrcweir while( pEntry ) 885cdf0e10cSrcweir { 886cdf0e10cSrcweir CustomAnimationEffectPtr pEffect( pEntry->getEffect() ); 887cdf0e10cSrcweir if( pEffect.get() ) 888cdf0e10cSrcweir aSelection.push_back( pEffect ); 889cdf0e10cSrcweir 890cdf0e10cSrcweir // if the selected effect is not expanded and has children 891cdf0e10cSrcweir // we say that the children are automaticly selected 892cdf0e10cSrcweir if( !IsExpanded( pEntry ) ) 893cdf0e10cSrcweir { 894cdf0e10cSrcweir CustomAnimationListEntry* pChild = dynamic_cast< CustomAnimationListEntry* >( FirstChild( pEntry ) ); 895cdf0e10cSrcweir while( pChild ) 896cdf0e10cSrcweir { 897cdf0e10cSrcweir if( !IsSelected( pChild ) ) 898cdf0e10cSrcweir { 899cdf0e10cSrcweir CustomAnimationEffectPtr pChildEffect( pChild->getEffect() ); 900cdf0e10cSrcweir if( pChildEffect.get() ) 901cdf0e10cSrcweir aSelection.push_back( pChildEffect ); 902cdf0e10cSrcweir } 903cdf0e10cSrcweir 904cdf0e10cSrcweir pChild = dynamic_cast< CustomAnimationListEntry* >( NextSibling( pChild ) ); 905cdf0e10cSrcweir } 906cdf0e10cSrcweir } 907cdf0e10cSrcweir 908cdf0e10cSrcweir pEntry = static_cast< CustomAnimationListEntry* >(NextSelected( pEntry )); 909cdf0e10cSrcweir } 910cdf0e10cSrcweir 911cdf0e10cSrcweir return aSelection; 912cdf0e10cSrcweir } 913cdf0e10cSrcweir 914cdf0e10cSrcweir // -------------------------------------------------------------------- 915cdf0e10cSrcweir 916cdf0e10cSrcweir sal_Bool CustomAnimationList::DoubleClickHdl() 917cdf0e10cSrcweir { 918cdf0e10cSrcweir mpController->onDoubleClick(); 919cdf0e10cSrcweir return false; 920cdf0e10cSrcweir } 921cdf0e10cSrcweir 922cdf0e10cSrcweir // -------------------------------------------------------------------- 923cdf0e10cSrcweir 924cdf0e10cSrcweir PopupMenu* CustomAnimationList::CreateContextMenu() 925cdf0e10cSrcweir { 926cdf0e10cSrcweir PopupMenu* pMenu = new PopupMenu(SdResId( RID_EFFECT_CONTEXTMENU )); 927cdf0e10cSrcweir 928cdf0e10cSrcweir sal_Int16 nNodeType = -1; 929cdf0e10cSrcweir sal_Int16 nEntries = 0; 930cdf0e10cSrcweir 931cdf0e10cSrcweir CustomAnimationListEntry* pEntry = static_cast< CustomAnimationListEntry* >(FirstSelected()); 932cdf0e10cSrcweir while( pEntry ) 933cdf0e10cSrcweir { 934cdf0e10cSrcweir nEntries++; 935cdf0e10cSrcweir CustomAnimationEffectPtr pEffect( pEntry->getEffect() ); 936cdf0e10cSrcweir if( pEffect.get() ) 937cdf0e10cSrcweir { 938cdf0e10cSrcweir if( nNodeType == -1 ) 939cdf0e10cSrcweir { 940cdf0e10cSrcweir nNodeType = pEffect->getNodeType(); 941cdf0e10cSrcweir } 942cdf0e10cSrcweir else 943cdf0e10cSrcweir { 944cdf0e10cSrcweir if( nNodeType != pEffect->getNodeType() ) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir nNodeType = -1; 947cdf0e10cSrcweir break; 948cdf0e10cSrcweir } 949cdf0e10cSrcweir } 950cdf0e10cSrcweir } 951cdf0e10cSrcweir 952cdf0e10cSrcweir pEntry = static_cast< CustomAnimationListEntry* >(NextSelected( pEntry )); 953cdf0e10cSrcweir } 954cdf0e10cSrcweir 955cdf0e10cSrcweir pMenu->CheckItem( CM_WITH_CLICK, nNodeType == EffectNodeType::ON_CLICK ); 956cdf0e10cSrcweir pMenu->CheckItem( CM_WITH_PREVIOUS, nNodeType == EffectNodeType::WITH_PREVIOUS ); 957cdf0e10cSrcweir pMenu->CheckItem( CM_AFTER_PREVIOUS, nNodeType == EffectNodeType::AFTER_PREVIOUS ); 958cdf0e10cSrcweir pMenu->EnableItem( CM_OPTIONS, nEntries == 1 ); 959cdf0e10cSrcweir pMenu->EnableItem( CM_DURATION, nEntries == 1 ); 960cdf0e10cSrcweir 961cdf0e10cSrcweir return pMenu; 962cdf0e10cSrcweir } 963cdf0e10cSrcweir 964cdf0e10cSrcweir // -------------------------------------------------------------------- 965cdf0e10cSrcweir 966cdf0e10cSrcweir void CustomAnimationList::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) 967cdf0e10cSrcweir { 968cdf0e10cSrcweir mpController->onContextMenu( nSelectedPopupEntry ); 969cdf0e10cSrcweir } 970cdf0e10cSrcweir 971cdf0e10cSrcweir // -------------------------------------------------------------------- 972cdf0e10cSrcweir 973cdf0e10cSrcweir void CustomAnimationList::SetTabs() 974cdf0e10cSrcweir { 975cdf0e10cSrcweir SvTreeListBox::SetTabs(); 976cdf0e10cSrcweir } 977cdf0e10cSrcweir 978cdf0e10cSrcweir // -------------------------------------------------------------------- 979cdf0e10cSrcweir 980cdf0e10cSrcweir void CustomAnimationList::notify_change() 981cdf0e10cSrcweir { 982cdf0e10cSrcweir update(); 983cdf0e10cSrcweir mpController->onSelect(); 984cdf0e10cSrcweir } 985cdf0e10cSrcweir 986cdf0e10cSrcweir void CustomAnimationList::Paint( const Rectangle& rRect ) 987cdf0e10cSrcweir { 988cdf0e10cSrcweir if( mbIgnorePaint ) 989cdf0e10cSrcweir return; 990cdf0e10cSrcweir 991cdf0e10cSrcweir SvTreeListBox::Paint( rRect ); 992cdf0e10cSrcweir 993cdf0e10cSrcweir // draw help text if list box is still empty 994cdf0e10cSrcweir if( First() == 0 ) 995cdf0e10cSrcweir { 996cdf0e10cSrcweir Color aOldColor( GetTextColor() ); 997cdf0e10cSrcweir SetTextColor( GetSettings().GetStyleSettings().GetDisableColor() ); 998cdf0e10cSrcweir ::Point aOffset( LogicToPixel( Point( 6, 6 ), MAP_APPFONT ) ); 999cdf0e10cSrcweir 1000cdf0e10cSrcweir Rectangle aRect( Point( 0,0 ), GetOutputSizePixel() ); 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir aRect.Left() += aOffset.X(); 1003cdf0e10cSrcweir aRect.Top() += aOffset.Y(); 1004cdf0e10cSrcweir aRect.Right() -= aOffset.X(); 1005cdf0e10cSrcweir aRect.Bottom() -= aOffset.Y(); 1006cdf0e10cSrcweir 1007cdf0e10cSrcweir DrawText( aRect, String( SdResId( STR_CUSTOMANIMATION_LIST_HELPTEXT ) ), 1008cdf0e10cSrcweir TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK | TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER ); 1009cdf0e10cSrcweir 1010cdf0e10cSrcweir SetTextColor( aOldColor ); 1011cdf0e10cSrcweir } 1012cdf0e10cSrcweir } 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir } 1015