Index: sc/source/ui/unoobj/shapeuno.cxx =================================================================== RCS file: /cvs/sc/sc/source/ui/unoobj/shapeuno.cxx,v retrieving revision 1.14 diff -u -p -r1.14 shapeuno.cxx --- sc/source/ui/unoobj/shapeuno.cxx 8 Sep 2005 22:50:06 -0000 1.14 +++ sc/source/ui/unoobj/shapeuno.cxx 8 Dec 2005 11:31:38 -0000 @@ -68,6 +68,8 @@ #include #endif +#include + using namespace ::com::sun::star; //------------------------------------------------------------------------ @@ -141,6 +143,7 @@ uno::Any SAL_CALL ScShapeObj::queryInter SC_QUERYINTERFACE( beans::XPropertyState ) SC_QUERYINTERFACE( text::XTextContent ) SC_QUERYINTERFACE( lang::XComponent ) + SC_QUERYINTERFACE( document::XEventsSupplier ) if ( bIsTextShape ) { // #105585# for text shapes, XText (and parent interfaces) must @@ -1320,3 +1323,126 @@ SdrObject* ScShapeObj::GetSdrObject() co return NULL; } +typedef ::cppu::WeakImplHelper1< container::XNameReplace > ShapeUnoEventAcess_BASE; +const rtl::OUString sOnClick = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OnClick") ); +const rtl::OUString sStrScript = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Script") ); +const rtl::OUString sEventType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("EventType") ); +class ShapeUnoEventAccessImpl : public ShapeUnoEventAcess_BASE +{ + + ScShapeObj* mpShape; + bool isValidName( const rtl::OUString& aName ) + { + if ( !aName.equals( sOnClick ) ) + return false; + return true; + } + + ScDrawObjData* getInfo( BOOL bCreate = false ) + { + ScDrawObjData* pInfo = NULL; + SdrObject* pObj = NULL; + if ( mpShape ) + { + pObj = mpShape->GetSdrObject(); + if ( pObj ) + pInfo = ScDrawLayer::GetObjData( pObj, bCreate ); + } + return pInfo; + } + +public: + ShapeUnoEventAccessImpl( ScShapeObj* pShape ): mpShape( pShape ) + { + } + + // XNameReplace + virtual void SAL_CALL replaceByName( const rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) + { + if ( !isValidName( aName ) ) + throw container::NoSuchElementException(); + uno::Sequence< beans::PropertyValue > aProperties; + aElement >>= aProperties; + const beans::PropertyValue* pProperties = aProperties.getConstArray(); + const sal_Int32 nCount = aProperties.getLength(); + sal_Int32 nIndex; + bool isEventType = false; + for( nIndex = 0; nIndex < nCount; nIndex++, pProperties++ ) + { + + if ( pProperties->Name.equals( sEventType ) ) + { + isEventType = true; + continue; + } + if ( isEventType && pProperties->Name.equals( sStrScript ) ) + { + rtl::OUString sMacro; + if ( ! ( pProperties->Value >>= sMacro ) ) + continue; + ScDrawObjData* pInfo = getInfo(); + if ( !pInfo ) + pInfo = getInfo( TRUE ); + DBG_ASSERT( pInfo, "shape animation info could not be created!" ); + + if ( !pInfo ) + break; + + pInfo->sMacro = sMacro; + } + + } + } + + // XNameAccess + virtual uno::Any SAL_CALL getByName( const rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) + { + if ( !isValidName( aName ) ) + throw container::NoSuchElementException(); + + ScDrawObjData* pInfo = getInfo(); + uno::Sequence< beans::PropertyValue > aProperties; + if ( pInfo ) + { + if ( pInfo->sMacro.getLength() ) + { + aProperties.realloc(2); + aProperties[ 0 ].Name = sEventType; + aProperties[ 0 ].Value <<= sStrScript; + aProperties[ 1 ].Name = sStrScript; + aProperties[ 1 ].Value <<= pInfo->sMacro; + } + + } + return uno::makeAny( aProperties ); + } + virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw(uno::RuntimeException) + { + uno::Sequence< rtl::OUString > aStr( &sOnClick, 1 ); + return aStr; + } + + virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException) + { + return aName.equals( sOnClick ); + } + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw(uno::RuntimeException) + { + return *SEQTYPE(::getCppuType((const uno::Sequence< beans::PropertyValue >*)0)); + } + + virtual sal_Bool SAL_CALL hasElements( ) throw(uno::RuntimeException) + { + return ( getInfo() != NULL ); + } + +}; + +::uno::Reference< container::XNameReplace > SAL_CALL +ScShapeObj::getEvents( ) throw(uno::RuntimeException) +{ + return new ShapeUnoEventAccessImpl( this ); +} + Index: sc/inc/shapeuno.hxx =================================================================== RCS file: /cvs/sc/sc/inc/shapeuno.hxx,v retrieving revision 1.8 diff -u -p -r1.8 shapeuno.hxx --- sc/inc/shapeuno.hxx 8 Sep 2005 17:57:10 -0000 1.8 +++ sc/inc/shapeuno.hxx 8 Dec 2005 11:31:39 -0000 @@ -56,6 +56,8 @@ #include #endif +#include + #ifndef _CPPUHELPER_WEAK_HXX_ #include #endif @@ -71,6 +73,7 @@ namespace com { namespace sun { namespac class SdrObject; struct SvEventDescription; +class ShapeUnoEventAccessImpl; //------------------------------------------------------------------------ @@ -82,7 +85,8 @@ class ScShapeObj : public ::cppu::OWeakO public ::com::sun::star::beans::XPropertyState, public ::com::sun::star::text::XTextContent, public ::com::sun::star::text::XText, - public ::com::sun::star::lang::XTypeProvider + public ::com::sun::star::lang::XTypeProvider, + public ::com::sun::star::document::XEventsSupplier { private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > mxShapeAgg; @@ -91,6 +95,8 @@ private: SdrObject* GetSdrObject() const throw(); +friend class ShapeUnoEventAccessImpl; + public: static const SvEventDescription* GetSupportedMacroItems(); @@ -229,6 +235,7 @@ public: throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(::com::sun::star::uno::RuntimeException); }; #endif Index: sc/inc/userdat.hxx =================================================================== RCS file: /cvs/sc/sc/inc/userdat.hxx,v retrieving revision 1.5 diff -u -p -r1.5 userdat.hxx --- sc/inc/userdat.hxx 8 Sep 2005 18:02:42 -0000 1.5 +++ sc/inc/userdat.hxx 8 Dec 2005 11:31:39 -0000 @@ -79,6 +79,7 @@ class ScDrawObjData : public SdrObjUserD //BFS01 virtual void WriteData(SvStream& rOut); //BFS01 virtual void ReadData(SvStream& rIn); public: + rtl::OUString sMacro; ScAddress aStt, aEnd; BOOL bValidStart, bValidEnd; ScDrawObjData(); Index: sc/source/ui/drawfunc/fusel.cxx =================================================================== RCS file: /cvs/sc/sc/source/ui/drawfunc/fusel.cxx,v retrieving revision 1.11 diff -u -p -r1.11 fusel.cxx --- sc/source/ui/drawfunc/fusel.cxx 8 Sep 2005 20:58:07 -0000 1.11 +++ sc/source/ui/drawfunc/fusel.cxx 8 Dec 2005 11:31:39 -0000 @@ -70,6 +70,7 @@ #include "drawpage.hxx" #include "globstr.hrc" #include "drwlayer.hxx" +#include "userdat.hxx" // ----------------------------------------------------------------------- @@ -125,7 +126,7 @@ BOOL __EXPORT FuSelection::MouseButtonDo { // #95491# remember button state for creation of own MouseEvents SetMouseButtonCode(rMEvt.GetButtons()); - + const bool bSelectionOnly = rMEvt.IsRight(); if ( pView->IsAction() ) { if ( rMEvt.IsRight() ) @@ -189,6 +190,33 @@ BOOL __EXPORT FuSelection::MouseButtonDo } else { + + if ( !bAlt && pView->PickObj(aMDPos, pObj, pPV, SDRSEARCH_ALSOONMASTER)) + { + if ( ! bSelectionOnly) + { + ScDrawObjData* pInfo = ScDrawLayer::GetObjData( pObj ); + if ( pInfo && pInfo->sMacro.getLength() ) + { + SfxObjectShell* pObjSh = SfxObjectShell::Current(); + if ( pObjSh && SfxApplication::IsXScriptURL( pInfo->sMacro ) ) + { + uno::Any aRet; + uno::Sequence< sal_Int16 > aOutArgsIndex; + uno::Sequence< uno::Any > aOutArgs; + uno::Sequence< uno::Any >* pInArgs = + new uno::Sequence< uno::Any >(0); + pObjSh->CallXScript( pInfo->sMacro, + *pInArgs, aRet, aOutArgsIndex, aOutArgs); + pViewShell->FakeButtonUp( pViewShell->GetViewData()->GetActivePart() ); + return TRUE; // kein CaptureMouse etc. + + } + } + } + } + + // URL / ImageMap SdrViewEvent aVEvt; @@ -217,7 +245,6 @@ BOOL __EXPORT FuSelection::MouseButtonDo return TRUE; // kein CaptureMouse etc. } } - // Is another object being edited in this view? // (Editing is ended in MarkListHasChanged - test before UnmarkAll) SfxInPlaceClient* pClient = pViewShell->GetIPClient(); Index: sc/source/ui/drawfunc/fudraw.cxx =================================================================== RCS file: /cvs/sc/sc/source/ui/drawfunc/fudraw.cxx,v retrieving revision 1.16 diff -u -p -r1.16 fudraw.cxx --- sc/source/ui/drawfunc/fudraw.cxx 28 Sep 2005 12:10:36 -0000 1.16 +++ sc/source/ui/drawfunc/fudraw.cxx 8 Dec 2005 11:31:39 -0000 @@ -866,6 +866,9 @@ void FuDraw::ForcePointer(const MouseEve SdrObject* pObj; SdrPageView* pPV; + ScDrawObjData* pInfo = NULL; + if ( pView->PickObj(aPnt, pObj, pPV, SDRSEARCH_ALSOONMASTER) ) + pInfo = ScDrawLayer::GetObjData( pObj ); if ( pView->IsTextEdit() ) { pViewShell->SetActivePointer(Pointer(POINTER_TEXT)); // kann nicht sein ? @@ -891,6 +894,10 @@ void FuDraw::ForcePointer(const MouseEve SdrObjMacroHitRec aHitRec; //! muss da noch irgendwas gesetzt werden ???? pViewShell->SetActivePointer( pObj->GetMacroPointer(aHitRec) ); } + else if ( !bAlt && pInfo && pInfo->sMacro.getLength() ) + { + pWindow->SetPointer( Pointer( POINTER_REFHAND ) ); + } else if ( IsDetectiveHit( aPnt ) ) pViewShell->SetActivePointer( Pointer( POINTER_DETECTIVE ) ); else Index: sc/source/filter/inc/xiescher.hxx =================================================================== RCS file: /cvs/sc/sc/source/filter/inc/xiescher.hxx,v retrieving revision 1.19 diff -u -p -r1.19 xiescher.hxx --- sc/source/filter/inc/xiescher.hxx 28 Sep 2005 12:00:09 -0000 1.19 +++ sc/source/filter/inc/xiescher.hxx 8 Dec 2005 11:31:40 -0000 @@ -148,6 +148,7 @@ public: sal_uInt32 GetProgressSize() const; /** Additional processing for the passed SdrObject (calls virtual DoProcessSdrObj() function). */ void ProcessSdrObject( SdrObject& rSdrObj ) const; + String maMacroName; /// Name of an attached macro. protected: /** Derived classes may return a progress bar size different from 1. */ @@ -158,6 +159,9 @@ protected: /** Creates an Escher anchor from the passed position (used for sheet charts). */ void CreateEscherAnchor( const Rectangle& rAnchorRect ); + /** Reads the contents of the ftMacro sub structure in an OBJ record. */ + void ReadMacro( XclImpStream& rStrm ); + private: typedef ScfRef< XclEscherAnchor > XclEscherAnchorRef; @@ -278,12 +282,10 @@ private: void ReadSbs( XclImpStream& rStrm ); /** Reads the contents of the ftGboData sub structure in an OBJ record. */ void ReadGboData( XclImpStream& rStrm ); - /** Reads the contents of the ftMacro sub structure in an OBJ record. */ - void ReadMacro( XclImpStream& rStrm ); + private: ScfInt16Vec maMultiSel; /// Indexes of all selected entries in a multi selection. - String maMacroName; /// Name of an attached macro. sal_uInt16 mnState; /// Checked/unchecked state. sal_Int16 mnSelEntry; /// Index of selected entry (1-based). sal_Int16 mnSelType; /// Selection type. Index: sc/source/filter/excel/xiescher.cxx =================================================================== RCS file: /cvs/sc/sc/source/filter/excel/xiescher.cxx,v retrieving revision 1.38 diff -u -p -r1.38 xiescher.cxx --- sc/source/filter/excel/xiescher.cxx 28 Sep 2005 11:48:05 -0000 1.38 +++ sc/source/filter/excel/xiescher.cxx 8 Dec 2005 11:31:41 -0000 @@ -189,6 +189,7 @@ #endif #include "excform.hxx" +#include using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -413,6 +414,15 @@ XclImpDrawObjRef XclImpDrawObjBase::Read void XclImpDrawObjBase::ReadSubRecord( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) { + switch( nSubRecId ) + { + case EXC_ID_OBJ_FTMACRO: + ReadMacro( rStrm ); + break; + default: + ;// perhaps an assert here + } + } Rectangle XclImpDrawObjBase::ReadClientAnchor( SvStream& rEscherStrm, const DffRecordHeader& rHeader ) @@ -494,6 +504,38 @@ void XclImpDrawObjBase::DoProcessSdrObj( if( !IsPrintable() ) GetTracer().TraceObjectNotPrintable(); } +void XclImpDrawObjBase::ReadMacro( XclImpStream& rStrm ) +{ + maMacroName.Erase(); + if( rStrm.GetRecLeft() > 6 ) + { + // macro is stored in a tNameXR token containing a link to a defined name + sal_uInt16 nFmlaSize; + rStrm >> nFmlaSize; + rStrm.Ignore( 4 ); + DBG_ASSERT( nFmlaSize == 7, "XclImpDrawObjBase::ReadMacro - unexpected formula size" ); + if( nFmlaSize == 7 ) + { + sal_uInt8 nTokenId; + sal_uInt16 nExtSheet, nExtName; + rStrm >> nTokenId >> nExtSheet >> nExtName; + DBG_ASSERT( nTokenId == XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX, EXC_TOKCLASS_REF ), + "XclImpDrawObjBase::ReadMacro - tNameXR token expected" ); + if( nTokenId == XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX, EXC_TOKCLASS_REF ) ) + { + maMacroName = GetLinkManager().GetMacroName( nExtSheet, nExtName ); + // #i38718# missing module name - try to find the macro in the imported modules + if( maMacroName.Len() && (maMacroName.Search( '.' ) == STRING_NOTFOUND) ) + if( SfxObjectShell* pDocShell = GetDocShell() ) + if( StarBASIC* pBasic = pDocShell->GetBasic() ) + if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( maMacroName, SbxCLASS_METHOD ) ) ) + if( SbModule* pModule = pMethod->GetModule() ) + maMacroName.Insert( '.', 0 ).Insert( pModule->GetName(), 0 ); + } + } + } +} + // ---------------------------------------------------------------------------- @@ -654,9 +696,6 @@ void XclImpTbxControlObj::ReadSubRecord( case EXC_ID_OBJ_FTGBODATA: ReadGboData( rStrm ); break; - case EXC_ID_OBJ_FTMACRO: - ReadMacro( rStrm ); - break; default: XclImpDrawObjBase::ReadSubRecord( rStrm, nSubRecId, nSubRecSize ); } @@ -924,38 +963,6 @@ void XclImpTbxControlObj::ReadGboData( X mbFlatBorder = ::get_flag( nStyle, EXC_OBJ_GBO_FLAT ); } -void XclImpTbxControlObj::ReadMacro( XclImpStream& rStrm ) -{ - maMacroName.Erase(); - if( rStrm.GetRecLeft() > 6 ) - { - // macro is stored in a tNameXR token containing a link to a defined name - sal_uInt16 nFmlaSize; - rStrm >> nFmlaSize; - rStrm.Ignore( 4 ); - DBG_ASSERT( nFmlaSize == 7, "XclImpTbxControlObj::ReadMacro - unexpected formula size" ); - if( nFmlaSize == 7 ) - { - sal_uInt8 nTokenId; - sal_uInt16 nExtSheet, nExtName; - rStrm >> nTokenId >> nExtSheet >> nExtName; - DBG_ASSERT( nTokenId == XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX, EXC_TOKCLASS_REF ), - "XclImpTbxControlObj::ReadMacro - tNameXR token expected" ); - if( nTokenId == XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX, EXC_TOKCLASS_REF ) ) - { - maMacroName = GetLinkManager().GetMacroName( nExtSheet, nExtName ); - // #i38718# missing module name - try to find the macro in the imported modules - if( maMacroName.Len() && (maMacroName.Search( '.' ) == STRING_NOTFOUND) ) - if( SfxObjectShell* pDocShell = GetDocShell() ) - if( StarBASIC* pBasic = pDocShell->GetBasic() ) - if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( maMacroName, SbxCLASS_METHOD ) ) ) - if( SbModule* pModule = pMethod->GetModule() ) - maMacroName.Insert( '.', 0 ).Insert( pModule->GetName(), 0 ); - } - } - } -} - // ---------------------------------------------------------------------------- XclImpOleObj::XclImpOleObj( const XclImpRoot& rRoot ) : @@ -1386,7 +1393,9 @@ SdrObject* XclImpDffManager::ProcessObj( /* Connect textbox data (string, alignment, text orientation) to object. #98132# don't ask for a text-ID, Escher export doesn't set one. */ - if( XclImpDrawingObj* pDrawingObj = dynamic_cast< XclImpDrawingObj* >( xDrawObj.get() ) ) + //if( XclImpDrawingObj* pDrawingObj = dynamic_cast< XclImpDrawingObj* >( xDrawObj.get() ) ) + XclImpDrawingObj* pDrawingObj = dynamic_cast< XclImpDrawingObj* >( xDrawObj.get() ); + if( pDrawingObj ) pDrawingObj->SetTxoData( mrObjManager.FindTxoData( rObjData.rSpHd ) ); // #118052# import internal name of a control @@ -1396,6 +1405,17 @@ SdrObject* XclImpDffManager::ProcessObj( if( aName.Len() ) pOleObj->SetControlName( aName ); } + else + { + // its a drawing object or form control + if ( pDrawingObj && xSdrObj.get() ) + { + ScDrawObjData* pInfo = ScDrawLayer::GetObjData( xSdrObj.get(), TRUE ); + if ( pInfo && pDrawingObj->maMacroName.Len() ) + pInfo->sMacro = XclTbxControlHelper::GetScMacroName(pDrawingObj->maMacroName); + + } + } // try to create a custom SdrObject that overwrites the passed object SdrObjectPtr xNewSdrObj( CreateCustomSdrObject( *xDrawObj, rAnchorRect ) );