diff options
241 files changed, 5590 insertions, 2050 deletions
diff --git a/avmedia/source/gstreamer/gstframegrabber.cxx b/avmedia/source/gstreamer/gstframegrabber.cxx index bd55e11f8afe..daf64d80ed25 100644 --- a/avmedia/source/gstreamer/gstframegrabber.cxx +++ b/avmedia/source/gstreamer/gstframegrabber.cxx @@ -31,6 +31,9 @@ #include <vcl/graph.hxx> #include <vcl/bmpacc.hxx> +#include <string> + + using namespace ::com::sun::star; namespace avmedia { namespace gst { @@ -42,12 +45,18 @@ const gulong GRAB_TIMEOUT = 10000000; // ---------------- FrameGrabber::FrameGrabber( GString* pURI ) : - Player( pURI ), mpFrameMutex( g_mutex_new() ), mpFrameCond( g_cond_new() ), mpLastPixbuf( NULL ), mbIsInGrabMode( false ) { + if( pURI ) + { + OSL_TRACE( ">>> --------------------------------" ); + OSL_TRACE( ">>> Creating Player object with URL: %s", pURI->str ); + + mpThread = g_thread_create( Player::implThreadFunc, this, true, NULL ); + } } // ------------------------------------------------------------------------------ diff --git a/avmedia/source/gstreamer/gstframegrabber.hxx b/avmedia/source/gstreamer/gstframegrabber.hxx index 9a7ec1b74102..fac2e298fb2c 100644 --- a/avmedia/source/gstreamer/gstframegrabber.hxx +++ b/avmedia/source/gstreamer/gstframegrabber.hxx @@ -34,6 +34,7 @@ #ifndef _COM_SUN_STAR_MEDIA_XFRAMEGRABBER_HDL_ #include "com/sun/star/media/XFrameGrabber.hdl" #endif +#include <cppuhelper/implbase1.hxx> namespace avmedia { namespace gst { @@ -41,9 +42,8 @@ namespace avmedia { namespace gst { // - FrameGrabber - // ---------------- -class FrameGrabber : public Player, - public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XFrameGrabber, - ::com::sun::star::lang::XServiceInfo > +class FrameGrabber : + public ::cppu::ImplInheritanceHelper1 < Player,::com::sun::star::media::XFrameGrabber > { public: diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index f082cfc5c513..a056b14b2b99 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -66,10 +66,97 @@ struct GstBusSource : public GSource {} }; + +// ----------------------------------------------------------------------- +extern "C" +{ + +static gpointer +lcl_implThreadFunc( gpointer pData ) +{ + return( pData ? static_cast< Player* >( pData )->run() : NULL ); +} + +static gboolean +lcl_implBusCheck( GSource* pSource ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + + return( pBusSource && + GST_IS_BUS( pBusSource->mpBus ) && + gst_bus_have_pending( GST_BUS_CAST( pBusSource->mpBus ) ) ); +} + + +static gboolean +lcl_implBusPrepare( GSource* pSource, gint* pTimeout ) +{ + if (pTimeout) + { + *pTimeout = 0; + } + + return lcl_implBusCheck(pSource); +} + +static gboolean +lcl_implBusDispatch( GSource* pSource, + GSourceFunc /*aCallback*/, + gpointer pData ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + gboolean bRet = false; + + if( pData && pBusSource && GST_IS_BUS( pBusSource->mpBus ) ) + { + GstMessage* pMsg = gst_bus_pop( pBusSource->mpBus ); + + if( pMsg ) + { + bRet = static_cast< Player* >( pData )->busCallback( + pBusSource->mpBus, pMsg ); + gst_message_unref( pMsg ); + } + } + + return( bRet ); +} + +static void +lcl_implBusFinalize( GSource* pSource ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + + if( pBusSource && pBusSource->mpBus ) + { + gst_object_unref( pBusSource->mpBus ); + pBusSource->mpBus = NULL; + } +} + +static gboolean +lcl_implIdleFunc( gpointer pData ) +{ + return( pData ? static_cast< Player* >( pData )->idle() : true ); +} + +static GstBusSyncReply +lcl_implHandleCreateWindowFunc( GstBus* pBus, GstMessage* pMsg, gpointer pData ) +{ + return (pData) + ? static_cast< Player* >( pData )->handleCreateWindow( pBus, pMsg ) + : GST_BUS_PASS; +} + +} // extern "C" + + + // --------------- // - Player - // --------------- Player::Player( GString* pURI ) : + Player_BASE(m_aMutex), mpMutex( g_mutex_new() ), mpCond( g_cond_new() ), mpThread( NULL ), @@ -102,7 +189,7 @@ Player::Player( GString* pURI ) : OSL_TRACE( ">>> --------------------------------" ); OSL_TRACE( ">>> Creating Player object with URL: %s", pURI->str ); - mpThread = g_thread_create( Player::implThreadFunc, this, true, NULL ); + mpThread = g_thread_create( &lcl_implThreadFunc, this, true, NULL ); } } @@ -188,6 +275,7 @@ Player* Player::create( const ::rtl::OUString& rURL ) void SAL_CALL Player::start() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() && !isPlaying() ) { gst_element_set_state( mpPlayer, GST_STATE_PLAYING ); @@ -198,6 +286,7 @@ void SAL_CALL Player::start() void SAL_CALL Player::stop() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() && isPlaying() ) { gst_element_set_state( mpPlayer, GST_STATE_PAUSED ); @@ -209,7 +298,7 @@ sal_Bool SAL_CALL Player::isPlaying() throw( uno::RuntimeException ) { GstState aState = GST_STATE_NULL; - + ::osl::MutexGuard aGuard(m_aMutex); if( mpPlayer ) { gst_element_get_state( mpPlayer, &aState, NULL, GST_MAX_TIMEOUT ); @@ -222,6 +311,7 @@ sal_Bool SAL_CALL Player::isPlaying() double SAL_CALL Player::getDuration() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); gint64 nDuration = 0; if( implInitPlayer() ) @@ -243,6 +333,7 @@ double SAL_CALL Player::getDuration() void SAL_CALL Player::setMediaTime( double fTime ) throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() ) { fTime = ::std::min( ::std::max( fTime, 0.0 ), getDuration() ); @@ -258,7 +349,7 @@ double SAL_CALL Player::getMediaTime() throw( uno::RuntimeException ) { double fRet = 0.0; - + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() ) { GstFormat aFormat = GST_FORMAT_TIME; @@ -298,7 +389,7 @@ double SAL_CALL Player::getStopTime() Currently no need for implementation since higher levels of code don't set a stop time ATM !!! TODO: needs to be fully implemented if this functionality is needed at a later point of time */ - + ::osl::MutexGuard aGuard(m_aMutex); return( getDuration() ); } @@ -329,16 +420,22 @@ double SAL_CALL Player::getRate() void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) throw( uno::RuntimeException ) { - if( bSet && !isPlaybackLoop() ) - g_atomic_int_inc( &mnLooping ); - else if( !bSet && isPlaybackLoop() ) - g_atomic_int_dec_and_test( &mnLooping ); + ::osl::MutexGuard aGuard(m_aMutex); + if (bSet) + { + g_atomic_int_compare_and_exchange(&mnLooping, 0, 1); + } + else + { + g_atomic_int_compare_and_exchange(&mnLooping, 1, 0); + } } // ------------------------------------------------------------------------------ sal_Bool SAL_CALL Player::isPlaybackLoop() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); return( g_atomic_int_get( &mnLooping ) > 0 ); } @@ -346,6 +443,7 @@ sal_Bool SAL_CALL Player::isPlaybackLoop() void SAL_CALL Player::setMute( sal_Bool bSet ) throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() && ( bSet != isMute() ) ) { if( bSet ) @@ -364,6 +462,7 @@ sal_Bool SAL_CALL Player::isMute() throw( uno::RuntimeException ) { gdouble fGstVolume = 1.0; + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() ) { @@ -377,6 +476,7 @@ sal_Bool SAL_CALL Player::isMute() void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() ) { g_mutex_lock( mpMutex ); @@ -395,6 +495,7 @@ void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) sal_Int16 SAL_CALL Player::getVolumeDB() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); return( static_cast< sal_Int16 >( g_atomic_int_get( &mnVolumeDB ) ) ); } @@ -403,6 +504,7 @@ awt::Size SAL_CALL Player::getPreferredPlayerWindowSize() throw( uno::RuntimeException ) { awt::Size aSize( 0, 0 ); + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() && ( g_atomic_int_get( &mnIsVideoSource ) > 0 ) ) { @@ -427,6 +529,7 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& rArguments ) throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); uno::Reference< ::media::XPlayerWindow > xRet; awt::Size aSize( getPreferredPlayerWindowSize() ); @@ -470,6 +573,7 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber() throw( ::com::sun::star::uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); FrameGrabber* pFrameGrabber = NULL; const awt::Size aPrefSize( getPreferredPlayerWindowSize() ); @@ -482,9 +586,9 @@ uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber() } // ------------------------------------------------------------------------------ -void SAL_CALL Player::dispose() - throw( uno::RuntimeException ) +void SAL_CALL Player::disposing() { + ::osl::MutexGuard aGuard(m_aMutex); if( mpPlayer ) { stop(); @@ -495,16 +599,6 @@ void SAL_CALL Player::dispose() } // ------------------------------------------------------------------------------ -void SAL_CALL Player::addEventListener( const uno::Reference< lang::XEventListener >& /*rxListener*/ ) - throw( uno::RuntimeException ) -{} - -// ------------------------------------------------------------------------------ -void SAL_CALL Player::removeEventListener( const uno::Reference< lang::XEventListener >& /*rxListener*/ ) - throw( uno::RuntimeException ) -{} - -// ------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL Player::getImplementationName() throw( uno::RuntimeException ) { @@ -573,62 +667,6 @@ bool Player::implInitPlayer() } // ------------------------------------------------------------------------------ -gboolean Player::implBusPrepare( GSource* pSource, - gint* pTimeout ) -{ - if( pTimeout ) - { - *pTimeout = 0; - } - - return( implBusCheck( pSource ) ); -} - -// ------------------------------------------------------------------------------ -gboolean Player::implBusCheck( GSource* pSource ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - - return( pBusSource && - GST_IS_BUS( pBusSource->mpBus ) && - gst_bus_have_pending( GST_BUS_CAST( pBusSource->mpBus ) ) ); -} - -// ------------------------------------------------------------------------------ -gboolean Player::implBusDispatch( GSource* pSource, - GSourceFunc /*aCallback*/, - gpointer pData ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - gboolean bRet = false; - - if( pData && pBusSource && GST_IS_BUS( pBusSource->mpBus ) ) - { - GstMessage* pMsg = gst_bus_pop( pBusSource->mpBus ); - - if( pMsg ) - { - bRet = static_cast< Player* >( pData )->busCallback( pBusSource->mpBus, pMsg ); - gst_message_unref( pMsg ); - } - } - - return( bRet ); -} - -// ------------------------------------------------------------------------------ -void Player::implBusFinalize( GSource* pSource ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - - if( pBusSource && pBusSource->mpBus ) - { - gst_object_unref( pBusSource->mpBus ); - pBusSource->mpBus = NULL; - } -} - -// ------------------------------------------------------------------------------ gboolean Player::busCallback( GstBus* /*pBus*/, GstMessage* pMsg ) { @@ -674,26 +712,6 @@ gboolean Player::busCallback( GstBus* /*pBus*/, } // ------------------------------------------------------------------------------ -gboolean Player::implIdleFunc( gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->idle() : true ); -} - -// ------------------------------------------------------------------------------ -gpointer Player::implThreadFunc( gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->run() : NULL ); -} - -// ------------------------------------------------------------------------------ -GstBusSyncReply Player::implHandleCreateWindowFunc( GstBus* pBus, - GstMessage* pMsg, - gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->handleCreateWindow( pBus, pMsg ) : GST_BUS_PASS ); -} - -// ------------------------------------------------------------------------------ void Player::implHandleNewElementFunc( GstBin* /* pBin */, GstElement* pElement, gpointer pData ) @@ -800,16 +818,12 @@ void Player::implHandleNewPadFunc( GstElement* pElement, // ------------------------------------------------------------------------------ gboolean Player::idle() { - // test if main loop should quit and set flag mnQuit to 1 - bool bQuit = g_atomic_int_compare_and_exchange( &mnQuit, 1, 1 ); + // test if main loop should quit by comparing with 1 + // and set flag mnQuit to 0 so we call g_main_loop_quit exactly once + bool const bQuit = g_atomic_int_compare_and_exchange( &mnQuit, 1, 0 ); if( bQuit ) { - // set mnQuit back to 0 to avoid mutiple g_main_loop_quit calls - // in case Player::idle() is called again later; - // the flag should have been set only once within Ctor called from - // the application thread - g_atomic_int_dec_and_test( &mnQuit ); g_main_loop_quit( mpLoop ); } @@ -824,10 +838,10 @@ gpointer Player::run() { static GSourceFuncs aSourceFuncs = { - Player::implBusPrepare, - Player::implBusCheck, - Player::implBusDispatch, - Player::implBusFinalize, + &lcl_implBusPrepare, + &lcl_implBusCheck, + &lcl_implBusDispatch, + &lcl_implBusFinalize, NULL, NULL }; @@ -842,7 +856,7 @@ gpointer Player::run() // add idle callback GSource* pIdleSource = g_idle_source_new(); - g_source_set_callback( pIdleSource, Player::implIdleFunc, this, NULL ); + g_source_set_callback( pIdleSource, &lcl_implIdleFunc, this, NULL ); g_source_attach( pIdleSource, mpContext ); // add bus callback @@ -853,7 +867,7 @@ gpointer Player::run() // add bus sync handler to intercept video window creation for setting our own window gst_bus_set_sync_handler( static_cast< GstBusSource* >( pBusSource )->mpBus, - Player::implHandleCreateWindowFunc, this ); + &lcl_implHandleCreateWindowFunc, this ); // watch for all elements (and pads) that will be added to the playbin, // in order to retrieve properties like video width and height diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx index d751e381258d..2127e87a93ec 100644 --- a/avmedia/source/gstreamer/gstplayer.hxx +++ b/avmedia/source/gstreamer/gstplayer.hxx @@ -46,6 +46,8 @@ typedef struct _GOptionGroup GOptionGroup; #include <gst/gst.h> #include "com/sun/star/media/XPlayer.hdl" +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/basemutex.hxx> namespace avmedia { @@ -56,10 +58,11 @@ class Window; // --------------- // - Player_Impl - // --------------- +typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer, + ::com::sun::star::lang::XServiceInfo > Player_BASE; -class Player : public ::cppu::WeakImplHelper3< ::com::sun::star::media::XPlayer, - ::com::sun::star::lang::XComponent, - ::com::sun::star::lang::XServiceInfo > +class Player : public cppu::BaseMutex, + public Player_BASE { public: @@ -67,7 +70,7 @@ public: static Player* create( const ::rtl::OUString& rURL ); ~Player(); - +//protected: // XPlayer virtual void SAL_CALL start() throw( ::com::sun::star::uno::RuntimeException ); @@ -127,18 +130,6 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XFrameGrabber > SAL_CALL createFrameGrabber() throw( ::com::sun::star::uno::RuntimeException ); - // XComponent - virtual void SAL_CALL dispose() - throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL addEventListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) - throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL removeEventListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) - throw( ::com::sun::star::uno::RuntimeException ); - // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); @@ -149,10 +140,7 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); - -protected: - - Player( GString* pURI = NULL ); +// these are public because the C callbacks call them virtual gboolean busCallback( GstBus* pBus, GstMessage* pMsg ); @@ -164,6 +152,13 @@ protected: virtual GstBusSyncReply handleCreateWindow( GstBus* pBus, GstMessage* pMsg ); +protected: + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + + Player( GString* pURI = NULL ); + void implQuitThread(); bool implInitPlayer(); @@ -173,6 +168,7 @@ protected: return( g_atomic_int_get( &mnInitialized ) > 0 ); } + static gpointer implThreadFunc( gpointer pData ); private: @@ -180,25 +176,6 @@ private: Player& operator=( const Player& ); - static gboolean implBusPrepare( GSource* pSource, - gint* pTimeout ); - - static gboolean implBusCheck( GSource* pSource ); - - static gboolean implBusDispatch( GSource* pSource, - GSourceFunc aCallback, - gpointer pData ); - - static void implBusFinalize( GSource* pSource ); - - static gboolean implIdleFunc( gpointer pData ); - - static gpointer implThreadFunc( gpointer pData ); - - static GstBusSyncReply implHandleCreateWindowFunc( GstBus* pBus, - GstMessage* pMsg, - gpointer pDData ); - static void implHandleNewElementFunc( GstBin* pBin, GstElement* pElement, gpointer pData ); diff --git a/avmedia/source/gstreamer/gstwindow.cxx b/avmedia/source/gstreamer/gstwindow.cxx index 12606ad5e88b..417525c1946e 100644 --- a/avmedia/source/gstreamer/gstwindow.cxx +++ b/avmedia/source/gstreamer/gstwindow.cxx @@ -271,7 +271,7 @@ value in sequence of arguments" ); if( pParentWindow ) { - meZoomLevel = media::ZoomLevel_ORIGINAL; + meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW; mpPlayerWindow = new PlayerChildWindow( pParentWindow ); mpPlayerWindow->SetBackground( Color( COL_BLACK ) ); diff --git a/avmedia/source/gstreamer/makefile.mk b/avmedia/source/gstreamer/makefile.mk index c648fcc77f89..857c5914b094 100644 --- a/avmedia/source/gstreamer/makefile.mk +++ b/avmedia/source/gstreamer/makefile.mk @@ -62,6 +62,8 @@ SHL1STDLIBS+=$(PKGCONFIG_LIBS) SHL1IMPLIB=i$(TARGET) SHL1LIBS=$(SLB)$/$(TARGET).lib SHL1DEF=$(MISC)$/$(SHL1TARGET).def +# on Solaris checkdll does not work: LD_LIBRARY_PATH breaks the 2 libxml2.so.2 +SHL1NOCHECK=t DEF1NAME=$(SHL1TARGET) DEF1EXPORTFILE=exports.dxp diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx index 94a6c36ed064..cd9ac849132a 100644 --- a/avmedia/source/viewer/mediawindowbase_impl.cxx +++ b/avmedia/source/viewer/mediawindowbase_impl.cxx @@ -207,17 +207,11 @@ void MediaWindowBaseImpl::setPlayerWindow( const uno::Reference< media::XPlayerW void MediaWindowBaseImpl::cleanUp() { - if( mxPlayer.is() ) - { - mxPlayer->stop(); - - uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY ); + uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY ); + if( xComponent.is() ) // this stops the player + xComponent->dispose(); - if( xComponent.is() ) - xComponent->dispose(); - - mxPlayer.clear(); - } + mxPlayer.clear(); mpMediaWindow = NULL; } diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx index d27b2b55ff93..56efbe6b107b 100644 --- a/avmedia/source/win/player.cxx +++ b/avmedia/source/win/player.cxx @@ -52,6 +52,30 @@ using namespace ::com::sun::star; namespace avmedia { namespace win { +LRESULT CALLBACK MediaPlayerWndProc_2( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) +{ + Player* pPlayer = (Player*) ::GetWindowLong( hWnd, 0 ); + bool bProcessed = true; + + if( pPlayer ) + { + switch( nMsg ) + { + case( WM_GRAPHNOTIFY ): + pPlayer->processEvent(); + break; + default: + bProcessed = false; + break; + } + } + else + bProcessed = false; + + return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) ); +} + + bool isWindowsVistaOrHigher() { // POST: return true if we are at least on Windows Vista @@ -59,10 +83,7 @@ bool isWindowsVistaOrHigher() ZeroMemory(&osvi, sizeof(osvi)); osvi.dwOSVersionInfoSize = sizeof(osvi); GetVersionEx(&osvi); - if ( osvi.dwMajorVersion >= 6 ) - return true; - - return false; + return osvi.dwMajorVersion >= 6; } // ---------------- @@ -70,6 +91,7 @@ bool isWindowsVistaOrHigher() // ---------------- Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : + Player_BASE(m_aMutex), mxMgr( rxMgr ), mpGB( NULL ), mpOMF( NULL ), @@ -82,8 +104,10 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : mpVW( NULL ), mpEV( NULL ), mnUnmutedVolume( 0 ), + mnFrameWnd( 0 ), mbMuted( false ), - mbLooping( false ) + mbLooping( false ), + mbAddWindow(sal_True) { ::CoInitialize( NULL ); } @@ -92,6 +116,18 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : Player::~Player() { + if( mnFrameWnd ) + ::DestroyWindow( (HWND) mnFrameWnd ); + + ::CoUninitialize(); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + stop(); if( mpBA ) mpBA->Release(); @@ -108,7 +144,11 @@ Player::~Player() mpMS->Release(); if( mpME ) + { + mpME->SetNotifyWindow( 0, WM_GRAPHNOTIFY, 0); mpME->Release(); + } + if( mpMC ) mpMC->Release(); @@ -121,12 +161,8 @@ Player::~Player() if( mpGB ) mpGB->Release(); - - ::CoUninitialize(); } - // ------------------------------------------------------------------------------ - bool Player::create( const ::rtl::OUString& rURL ) { HRESULT hR; @@ -137,15 +173,12 @@ bool Player::create( const ::rtl::OUString& rURL ) // Don't use the overlay mixer on Windows Vista // It disables the desktop composition as soon as RenderFile is called // also causes some other problems: video rendering is not reliable - if( !isWindowsVistaOrHigher() ) + if( !isWindowsVistaOrHigher() && SUCCEEDED( CoCreateInstance( CLSID_OverlayMixer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &mpOMF ) ) ) { - if( SUCCEEDED( CoCreateInstance( CLSID_OverlayMixer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &mpOMF ) ) ) - { - mpGB->AddFilter( mpOMF, L"com_sun_star_media_OverlayMixerFilter" ); + mpGB->AddFilter( mpOMF, L"com_sun_star_media_OverlayMixerFilter" ); - if( !SUCCEEDED( mpOMF->QueryInterface( IID_IDDrawExclModeVideo, (void**) &mpEV ) ) ) - mpEV = NULL; - } + if( !SUCCEEDED( mpOMF->QueryInterface( IID_IDDrawExclModeVideo, (void**) &mpEV ) ) ) + mpEV = NULL; } if( SUCCEEDED( hR = mpGB->RenderFile( reinterpret_cast<LPCWSTR>(rURL.getStr()), NULL ) ) && @@ -187,6 +220,7 @@ const IVideoWindow* Player::getVideoWindow() const void Player::setNotifyWnd( int nNotifyWnd ) { + mbAddWindow = sal_False; if( mpME ) mpME->SetNotifyWindow( (OAHWND) nNotifyWnd, WM_GRAPHNOTIFY, reinterpret_cast< LONG_PTR>( this ) ); } @@ -208,7 +242,7 @@ long Player::processEvent() { long nCode, nParam1, nParam2; - if( mpME && SUCCEEDED( mpME->GetEvent( &nCode, &nParam1, &nParam2, 0 ) ) ) + while( mpME && SUCCEEDED( mpME->GetEvent( &nCode, &nParam1, &nParam2, 0 ) ) ) { if( EC_COMPLETE == nCode ) { @@ -235,8 +269,44 @@ long Player::processEvent() void SAL_CALL Player::start( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); if( mpMC ) + { + if ( mbAddWindow ) + { + static WNDCLASS* mpWndClass = NULL; + if ( !mpWndClass ) + { + mpWndClass = new WNDCLASS; + + memset( mpWndClass, 0, sizeof( *mpWndClass ) ); + mpWndClass->hInstance = GetModuleHandle( NULL ); + mpWndClass->cbWndExtra = sizeof( DWORD ); + mpWndClass->lpfnWndProc = MediaPlayerWndProc_2; + mpWndClass->lpszClassName = "com_sun_star_media_Sound_Player"; + mpWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH ); + mpWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW ); + + ::RegisterClass( mpWndClass ); + } + if ( !mnFrameWnd ) + { + mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL, + 0, + 0, 0, 0, 0, + (HWND) NULL, NULL, mpWndClass->hInstance, 0 ); + if ( mnFrameWnd ) + { + ::ShowWindow((HWND) mnFrameWnd, SW_HIDE); + ::SetWindowLong( (HWND) mnFrameWnd, 0, (DWORD) this ); + // mpVW->put_Owner( (OAHWND) mnFrameWnd ); + setNotifyWnd( mnFrameWnd ); + } + } + } + mpMC->Run(); + } } // ------------------------------------------------------------------------------ @@ -244,6 +314,8 @@ void SAL_CALL Player::start( ) void SAL_CALL Player::stop( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpMC ) mpMC->Stop(); } @@ -253,6 +325,8 @@ void SAL_CALL Player::stop( ) sal_Bool SAL_CALL Player::isPlaying() throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + OAFilterState eFilterState; bool bRet = false; @@ -267,6 +341,8 @@ sal_Bool SAL_CALL Player::isPlaying() double SAL_CALL Player::getDuration( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + REFTIME aRefTime( 0.0 ); if( mpMP ) @@ -280,6 +356,8 @@ double SAL_CALL Player::getDuration( ) void SAL_CALL Player::setMediaTime( double fTime ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpMP ) { const bool bPlaying = isPlaying(); @@ -296,6 +374,8 @@ void SAL_CALL Player::setMediaTime( double fTime ) double SAL_CALL Player::getMediaTime( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + REFTIME aRefTime( 0.0 ); if( mpMP ) @@ -309,6 +389,8 @@ double SAL_CALL Player::getMediaTime( ) void SAL_CALL Player::setStopTime( double fTime ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpMP ) mpMP->put_StopTime( fTime ); } @@ -318,6 +400,8 @@ void SAL_CALL Player::setStopTime( double fTime ) double SAL_CALL Player::getStopTime( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + REFTIME aRefTime( 0.0 ); if( mpMP ) @@ -331,6 +415,8 @@ double SAL_CALL Player::getStopTime( ) void SAL_CALL Player::setRate( double fRate ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpMP ) mpMP->put_Rate( fRate ); } @@ -340,6 +426,8 @@ void SAL_CALL Player::setRate( double fRate ) double SAL_CALL Player::getRate( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + double fRet( 0.0 ); if( mpMP ) @@ -353,6 +441,8 @@ double SAL_CALL Player::getRate( ) void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + mbLooping = bSet; } @@ -361,6 +451,8 @@ void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) sal_Bool SAL_CALL Player::isPlaybackLoop( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + return mbLooping; } @@ -369,6 +461,8 @@ sal_Bool SAL_CALL Player::isPlaybackLoop( ) void SAL_CALL Player::setMute( sal_Bool bSet ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpBA && ( mbMuted != bSet ) ) { mbMuted = bSet; @@ -381,6 +475,8 @@ void SAL_CALL Player::setMute( sal_Bool bSet ) sal_Bool SAL_CALL Player::isMute( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + return mbMuted; } @@ -389,6 +485,8 @@ sal_Bool SAL_CALL Player::isMute( ) void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + mnUnmutedVolume = static_cast< long >( nVolumeDB ) * 100; if( !mbMuted && mpBA ) @@ -400,6 +498,8 @@ void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) sal_Int16 SAL_CALL Player::getVolumeDB( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + return( static_cast< sal_Int16 >( mnUnmutedVolume / 100 ) ); } @@ -408,6 +508,8 @@ sal_Int16 SAL_CALL Player::getVolumeDB( ) awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + awt::Size aSize( 0, 0 ); if( mpBV ) @@ -427,6 +529,8 @@ awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( ) uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& aArguments ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + uno::Reference< ::media::XPlayerWindow > xRet; awt::Size aSize( getPreferredPlayerWindowSize() ); @@ -448,6 +552,8 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + uno::Reference< media::XFrameGrabber > xRet; if( maURL.getLength() > 0 ) diff --git a/avmedia/source/win/player.hxx b/avmedia/source/win/player.hxx index 34a567750b74..eee9b52ee94b 100644 --- a/avmedia/source/win/player.hxx +++ b/avmedia/source/win/player.hxx @@ -30,9 +30,10 @@ #include "wincommon.hxx" -#ifndef _COM_SUN_STAR_MEDIA_XPLAYER_HDL_ #include "com/sun/star/media/XPlayer.hdl" -#endif + +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/basemutex.hxx> struct IGraphBuilder; struct IBaseFilter; @@ -52,9 +53,11 @@ namespace avmedia { namespace win { // ---------- // - Player - // ---------- +typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer, + ::com::sun::star::lang::XServiceInfo > Player_BASE; -class Player : public ::cppu::WeakImplHelper2< ::com::sun::star::media::XPlayer, - ::com::sun::star::lang::XServiceInfo > +class Player : public cppu::BaseMutex, + public Player_BASE { public: @@ -95,6 +98,9 @@ public: virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + private: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr; @@ -111,8 +117,11 @@ private: IVideoWindow* mpVW; IDDrawExclModeVideo* mpEV; long mnUnmutedVolume; + int mnFrameWnd; + sal_Bool mbMuted; sal_Bool mbLooping; + sal_Bool mbAddWindow; void ImplLayoutVideoWindow(); }; diff --git a/avmedia/source/win/window.cxx b/avmedia/source/win/window.cxx index 1170505b440b..8d4aeb73a65c 100644 --- a/avmedia/source/win/window.cxx +++ b/avmedia/source/win/window.cxx @@ -179,7 +179,25 @@ LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM n // - Window - // --------------- -WNDCLASS* Window::mpWndClass = NULL; +WNDCLASS* lcl_getWndClass() +{ + static WNDCLASS* s_pWndClass = NULL; + if ( !s_pWndClass ) + { + s_pWndClass = new WNDCLASS; + + memset( s_pWndClass, 0, sizeof( *s_pWndClass ) ); + s_pWndClass->hInstance = GetModuleHandle( NULL ); + s_pWndClass->cbWndExtra = sizeof( DWORD ); + s_pWndClass->lpfnWndProc = MediaPlayerWndProc; + s_pWndClass->lpszClassName = "com_sun_star_media_PlayerWnd"; + s_pWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH ); + s_pWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW ); + + ::RegisterClass( s_pWndClass ); + } + return s_pWndClass; +} // ------------------------------------------------------------------------------ @@ -194,20 +212,7 @@ Window::Window( const uno::Reference< lang::XMultiServiceFactory >& rxMgr, Playe { ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() ); - if( !mpWndClass ) - { - mpWndClass = new WNDCLASS; - - memset( mpWndClass, 0, sizeof( *mpWndClass ) ); - mpWndClass->hInstance = GetModuleHandle( NULL ); - mpWndClass->cbWndExtra = sizeof( DWORD ); - mpWndClass->lpfnWndProc = MediaPlayerWndProc; - mpWndClass->lpszClassName = "com_sun_star_media_PlayerWnd"; - mpWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH ); - mpWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW ); - - ::RegisterClass( mpWndClass ); - } + lcl_getWndClass(); } // ------------------------------------------------------------------------------ @@ -310,6 +315,8 @@ void Window::ImplLayoutVideoWindow() bool Window::create( const uno::Sequence< uno::Any >& rArguments ) { IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() ); + WNDCLASS* mpWndClass = lcl_getWndClass(); + if( !mnFrameWnd && pVideoWindow && mpWndClass ) { @@ -374,7 +381,7 @@ bool Window::create( const uno::Sequence< uno::Any >& rArguments ) mrPlayer.setNotifyWnd( mnFrameWnd ); - meZoomLevel = media::ZoomLevel_ORIGINAL; + meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW; ImplLayoutVideoWindow(); #ifdef DDRAW_TEST_OUTPUT } diff --git a/avmedia/source/win/window.hxx b/avmedia/source/win/window.hxx index 36cff49a742a..3605ba970f7a 100644 --- a/avmedia/source/win/window.hxx +++ b/avmedia/source/win/window.hxx @@ -114,8 +114,6 @@ private: int mnParentWnd; int mnPointerType; - static WNDCLASS* mpWndClass; - void ImplLayoutVideoWindow(); }; diff --git a/basic/inc/basic/sbxdef.hxx b/basic/inc/basic/sbxdef.hxx index 6dc9fe1d8d66..cc669fd03649 100644 --- a/basic/inc/basic/sbxdef.hxx +++ b/basic/inc/basic/sbxdef.hxx @@ -108,6 +108,7 @@ enum SbxDataType { const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000; const sal_uInt32 SBX_TYPE_DIM_AS_NEW_FLAG = 0x20000; const sal_uInt32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible +const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG = 0x40000; #endif @@ -320,6 +321,8 @@ enum SbxError { // Ergebnis einer Rechenoperation/Konversion #define SBX_WITH_EVENTS 0x0080 // Same value as unused SBX_HIDDEN #define SBX_DIM_AS_NEW 0x0800 // Same value as SBX_GBLSEARCH, cannot conflict as one // is used for objects, the other for variables only +#define SBX_VAR_TO_DIM 0x2000 // Same value as SBX_NO_BROADCAST, cannot conflict as + // used for variables without broadcaster only // Broadcaster-IDs: #define SBX_HINT_DYING SFX_HINT_DYING diff --git a/basic/inc/basic/vbahelper.hxx b/basic/inc/basic/vbahelper.hxx index 0d99387965fe..f83548f7e02c 100755..100644 --- a/basic/inc/basic/vbahelper.hxx +++ b/basic/inc/basic/vbahelper.hxx @@ -28,7 +28,9 @@ #ifndef BASIC_VBAHELPR_HXX #define BASIC_VBAHELPR_HXX +#include <com/sun/star/container/XEnumeration.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <rtl/ustring.hxx> namespace basic { namespace vba { @@ -39,6 +41,21 @@ namespace vba { // ============================================================================ +/** Creates and returns an enumeration of all open documents of the same type + as the specified document. + + First, the global module manager (com.sun.star.frame.ModuleManager) is + asked for the type of the passed model, and all open documents with the + same type will be stored in an enumeration object. + + @param rxModel + A document model determining the type of the documents. + */ +::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > createDocumentsEnumeration( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel ); + +// ============================================================================ + /** Locks or unlocks the controllers of all documents that have the same type as the specified document. @@ -80,6 +97,38 @@ void enableContainerWindowsOfAllDocuments( // ============================================================================ +/** Registers the passed path as working directory for the application the + passed document belongs to. + + @param rxModel + A document model determining the type of the application whose working + directory has been changed. + + @param rPath + The new working directory. + */ +void registerCurrentDirectory( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, + const ::rtl::OUString& rPath ); + +// ============================================================================ + +/** Returns the working directory of the application the passed document + belongs to. + + @param rxModel + A document model determining the type of the application whose working + directory is querried. + + @return + The working directory of the specified application, or an empty string + on error (e.g. if the passed document reference is empty). + */ +::rtl::OUString getCurrentDirectory( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel ); + +// ============================================================================ + } // namespace vba } // namespace basic diff --git a/basic/source/app/brkpnts.cxx b/basic/source/app/brkpnts.cxx index e7687222d5da..2878d736e493 100644 --- a/basic/source/app/brkpnts.cxx +++ b/basic/source/app/brkpnts.cxx @@ -108,7 +108,7 @@ void BreakpointWindow::SetBPsInModule() { pModule->SetBP( (sal_uInt16)pBrk->nLine ); #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( (USHORT)pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" ); + DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( (sal_uInt16)pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" ); #endif pBrk = Next(); } diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx index a09446f2e40b..0e9338b52c5e 100755..100644 --- a/basic/source/basmgr/vbahelper.cxx +++ b/basic/source/basmgr/vbahelper.cxx @@ -28,13 +28,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#include "basic/vbahelper.hxx" +#include <basic/vbahelper.hxx> + +#include <map> +#include <vector> #include <com/sun/star/container/XEnumeration.hpp> #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/frame/XModel2.hpp> #include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/processfactory.hxx> +#include <cppuhelper/implbase1.hxx> +#include <rtl/instance.hxx> namespace basic { namespace vba { @@ -45,64 +50,71 @@ using namespace ::com::sun::star; namespace { -/** Creates the global module manager needed to identify the type of documents. +/** Create an instance of a module manager. */ uno::Reference< frame::XModuleManager > lclCreateModuleManager() { uno::Reference< frame::XModuleManager > xModuleManager; try { - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_SET_THROW ); + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); xModuleManager.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ), uno::UNO_QUERY ); } catch( uno::Exception& ) { } - OSL_ENSURE( xModuleManager.is(), "::basic::vba::lclCreateModuleManager - cannot create module manager" ); return xModuleManager; } // ---------------------------------------------------------------------------- -/** Returns the document service name of the specified document. +/** Implementation of an enumeration of all open documents of the same type. */ -::rtl::OUString lclIdentifyDocument( const uno::Reference< frame::XModuleManager >& rxModuleManager, const uno::Reference< frame::XModel >& rxModel ) +class DocumentsEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration > { - ::rtl::OUString aServiceName; - if( rxModuleManager.is() ) - { - try - { - aServiceName = rxModuleManager->identify( rxModel ); - } - catch( uno::Exception& ) - { - } - OSL_ENSURE( aServiceName.getLength() > 0, "::basic::vba::lclIdentifyDocument - cannot identify document" ); - } - return aServiceName; -} - -// ---------------------------------------------------------------------------- +public: + DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel ); + virtual sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); +private: + typedef ::std::vector< uno::Reference< frame::XModel > > ModelVector; + ModelVector maModels; + ModelVector::iterator maModelIt; +}; -/** Returns an enumeration of all open documents. - */ -uno::Reference< container::XEnumeration > lclCreateDocumentEnumeration() +DocumentsEnumeration::DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel ) { - uno::Reference< container::XEnumeration > xEnumeration; try { - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_SET_THROW ); + uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW ); + ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel ); + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); uno::Reference< frame::XDesktop > xDesktop( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), uno::UNO_QUERY_THROW ); uno::Reference< container::XEnumerationAccess > xComponentsEA( xDesktop->getComponents(), uno::UNO_SET_THROW ); - xEnumeration = xComponentsEA->createEnumeration(); - + uno::Reference< container::XEnumeration > xEnumeration( xComponentsEA->createEnumeration(), uno::UNO_SET_THROW ); + while( xEnumeration->hasMoreElements() ) + { + uno::Reference< frame::XModel > xCurrModel( xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); + if( xModuleManager->identify( xCurrModel ) == aIdentifier ) + maModels.push_back( xCurrModel ); + } } catch( uno::Exception& ) { } - OSL_ENSURE( xEnumeration.is(), "::basic::vba::lclCreateDocumentEnumeration - cannot create enumeration of all documents" ); - return xEnumeration; + maModelIt = maModels.begin(); +} + +sal_Bool SAL_CALL DocumentsEnumeration::hasMoreElements() throw (uno::RuntimeException) +{ + return maModelIt != maModels.end(); +} + +uno::Any SAL_CALL DocumentsEnumeration::nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( maModelIt == maModels.end() ) + throw container::NoSuchElementException(); + return uno::Any( *maModelIt++ ); } // ---------------------------------------------------------------------------- @@ -163,37 +175,39 @@ typedef void (*ModifyDocumentFunc)( const uno::Reference< frame::XModel >&, sal_ */ void lclIterateDocuments( ModifyDocumentFunc pModifyDocumentFunc, const uno::Reference< frame::XModel >& rxModel, sal_Bool bModificator ) { - uno::Reference< frame::XModuleManager > xModuleManager = lclCreateModuleManager(); - uno::Reference< container::XEnumeration > xDocumentsEnum = lclCreateDocumentEnumeration(); - ::rtl::OUString aIdentifier = lclIdentifyDocument( xModuleManager, rxModel ); - if( xModuleManager.is() && xDocumentsEnum.is() && (aIdentifier.getLength() > 0) ) + uno::Reference< container::XEnumeration > xDocumentsEnum( new DocumentsEnumeration( rxModel ) ); + // iterate over all open documents + while( xDocumentsEnum->hasMoreElements() ) try { - // iterate over all open documents - while( xDocumentsEnum->hasMoreElements() ) - { - try - { - uno::Reference< frame::XModel > xCurrModel( xDocumentsEnum->nextElement(), uno::UNO_QUERY_THROW ); - ::rtl::OUString aCurrIdentifier = lclIdentifyDocument( xModuleManager, xCurrModel ); - if( aCurrIdentifier == aIdentifier ) - pModifyDocumentFunc( xCurrModel, bModificator ); - } - catch( uno::Exception& ) - { - } - } + uno::Reference< frame::XModel > xCurrModel( xDocumentsEnum->nextElement(), uno::UNO_QUERY_THROW ); + pModifyDocumentFunc( xCurrModel, bModificator ); } - else + catch( uno::Exception& ) { - // no module manager, no documents enumeration, no identifier -> at least process the passed document - pModifyDocumentFunc( rxModel, bModificator ); } } +// ---------------------------------------------------------------------------- + +struct CurrDirPool +{ + ::osl::Mutex maMutex; + ::std::map< ::rtl::OUString, ::rtl::OUString > maCurrDirs; +}; + +struct StaticCurrDirPool : public ::rtl::Static< CurrDirPool, StaticCurrDirPool > {}; + } // namespace // ============================================================================ +uno::Reference< container::XEnumeration > createDocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel ) +{ + return new DocumentsEnumeration( rxModel ); +} + +// ============================================================================ + void lockControllersOfAllDocuments( const uno::Reference< frame::XModel >& rxModel, sal_Bool bLockControllers ) { lclIterateDocuments( &lclLockControllers, rxModel, bLockControllers ); @@ -208,5 +222,45 @@ void enableContainerWindowsOfAllDocuments( const uno::Reference< frame::XModel > // ============================================================================ +void registerCurrentDirectory( const uno::Reference< frame::XModel >& rxModel, const ::rtl::OUString& rPath ) +{ + if( rPath.getLength() > 0 ) + { + CurrDirPool& rPool = StaticCurrDirPool::get(); + ::osl::MutexGuard aGuard( rPool.maMutex ); + try + { + uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW ); + ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel ); + if( aIdentifier.getLength() > 0 ) + rPool.maCurrDirs[ aIdentifier ] = rPath; + } + catch( uno::Exception& ) + { + } + } +} + +// ============================================================================ + +::rtl::OUString getCurrentDirectory( const uno::Reference< frame::XModel >& rxModel ) +{ + ::rtl::OUString aPath; + CurrDirPool& rPool = StaticCurrDirPool::get(); + ::osl::MutexGuard aGuard( rPool.maMutex ); + try + { + uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW ); + ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel ); + aPath = rPool.maCurrDirs[ aIdentifier ]; + } + catch( uno::Exception& ) + { + } + return aPath; +} + +// ============================================================================ + } // namespace vba } // namespace basic diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index f8ffa46d48a5..bf7b00e2a633 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -42,6 +42,7 @@ #include <tools/shl.hxx> #include <tools/rc.hxx> #include <vcl/svapp.hxx> +#include <comphelper/processfactory.hxx> #include "sbunoobj.hxx" #include "sbjsmeth.hxx" #include "sbjsmod.hxx" @@ -136,6 +137,7 @@ void DocBasicItem::startListening() Any aThisComp; mrDocBasic.GetUNOConstant( "ThisComponent", aThisComp ); Reference< util::XCloseBroadcaster > xCloseBC( aThisComp, UNO_QUERY ); + mbDisposed = !xCloseBC.is(); if( xCloseBC.is() ) try { xCloseBC->addCloseListener( this ); } catch( uno::Exception& ) {} } @@ -437,7 +439,20 @@ SbxObject* SbiFactory::CreateObject( const String& rClass ) return new BasicCollection( aCollectionName ); } else - return NULL; + if( rClass.EqualsIgnoreCaseAscii( "FileSystemObject" ) ) + { + try + { + Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW ); + ::rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.FileSystemObject" ) ); + Reference< XInterface > xInterface( xFactory->createInstance( aServiceName ), UNO_SET_THROW ); + return new SbUnoObject( aServiceName, uno::makeAny( xInterface ) ); + } + catch( Exception& ) + {} + } + + return NULL; } @@ -934,8 +949,14 @@ void StarBASIC::SetModified( sal_Bool b ) SbxBase::SetModified( b ); } +extern void lcl_closeTraceFile(); + StarBASIC::~StarBASIC() { +#ifdef DBG_TRACE_BASIC + lcl_closeTraceFile(); +#endif + // Needs to be first action as it can trigger events disposeComVariablesForBasic( this ); @@ -2273,7 +2294,22 @@ void BasicCollection::CollRemove( SbxArray* pPar_ ) SbxVariable* p = pPar_->Get( 1 ); sal_Int32 nIndex = implGetIndex( p ); if( nIndex >= 0 && nIndex < (sal_Int32)xItemArray->Count32() ) + { xItemArray->Remove32( nIndex ); + + // Correct for stack if necessary + SbiInstance* pInst = pINST; + SbiRuntime* pRT = pInst ? pInst->pRun : NULL; + if( pRT ) + { + SbiForStack* pStack = pRT->FindForStackItemForCollection( this ); + if( pStack != NULL ) + { + if( pStack->nCurCollectionIndex >= nIndex ) + --pStack->nCurCollectionIndex; + } + } + } else SetError( SbERR_BAD_ARGUMENT ); } diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 13ae406cb305..6f20a68a274f 100755 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -1722,8 +1722,7 @@ String getBasicObjectTypeName( SbxObject* pObj ) return aName; } -bool checkUnoObjectType( SbUnoObject* pUnoObj, - const String& aClass ) +bool checkUnoObjectType( SbUnoObject* pUnoObj, const ::rtl::OUString& rClass ) { Any aToInspectObj = pUnoObj->getUnoAny(); TypeClass eType = aToInspectObj.getValueType().getTypeClass(); @@ -1740,6 +1739,21 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY ); if( xTypeProvider.is() ) { + /* Although interfaces in the ooo.vba namespace obey the IDL rules and + have a leading 'X', in Basic we want to be able to do something + like 'Dim wb As Workbooks' or 'Dim lb As MSForms.Label'. Here we + add a leading 'X' to the class name and a leading dot to the entire + type name. This results e.g. in '.XWorkbooks' or '.MSForms.XLabel' + which matches the interface names 'ooo.vba.excel.XWorkbooks' or + 'ooo.vba.msforms.XLabel'. + */ + ::rtl::OUString aClassName( sal_Unicode( '.' ) ); + sal_Int32 nClassNameDot = rClass.lastIndexOf( '.' ); + if( nClassNameDot >= 0 ) + aClassName += rClass.copy( 0, nClassNameDot + 1 ) + ::rtl::OUString( sal_Unicode( 'X' ) ) + rClass.copy( nClassNameDot + 1 ); + else + aClassName += ::rtl::OUString( sal_Unicode( 'X' ) ) + rClass; + Sequence< Type > aTypeSeq = xTypeProvider->getTypes(); const Type* pTypeArray = aTypeSeq.getConstArray(); sal_uInt32 nIfaceCount = aTypeSeq.getLength(); @@ -1753,8 +1767,8 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, DBG_ERROR("failed to get XIdlClass for type"); break; } - ::rtl::OUString sClassName = xClass->getName(); - if ( sClassName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.XAutomationObject" ) ) ) ) + ::rtl::OUString aInterfaceName = xClass->getName(); + if ( aInterfaceName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.XAutomationObject" ) ) ) ) { // there is a hack in the extensions/source/ole/oleobj.cxx to return the typename of the automation object, lets check if it // matches @@ -1767,20 +1781,15 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, // can't check type, leave it pass result = true; else - result = sTypeName.equals( aClass ); + result = sTypeName.equals( rClass ); } break; // finished checking automation object } - OSL_TRACE("Checking if object implements %s", - OUStringToOString( defaultNameSpace + aClass, - RTL_TEXTENCODING_UTF8 ).getStr() ); - // although interfaces in the ooo.vba.vba namespace - // obey the idl rules and have a leading X, in basic we - // want to be able to do something like - // 'dim wrkbooks as WorkBooks' - // so test assumes the 'X' has been dropped - sal_Int32 indexLastDot = sClassName.lastIndexOf('.'); - if ( indexLastDot > -1 && sClassName.copy( indexLastDot + 1).equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("X") ) + aClass ) ) + + // match interface name with passed class name + OSL_TRACE("Checking if object implements %s", OUStringToOString( aClassName, RTL_TEXTENCODING_UTF8 ).getStr() ); + if ( (aClassName.getLength() < aInterfaceName.getLength()) && + aInterfaceName.matchIgnoreAsciiCase( aClassName, aInterfaceName.getLength() - aClassName.getLength() ) ) { result = true; break; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index c722e680fd8c..a9e378d69d9d 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -61,6 +61,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/VBAScriptEventId.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/document/XEventBroadcaster.hpp> #include <com/sun/star/document/XEventListener.hpp> @@ -88,10 +89,8 @@ using namespace com::sun::star; #include <cppuhelper/implbase1.hxx> #include <basic/sbobjmod.hxx> #include <com/sun/star/uno/XAggregation.hpp> -#include <map> #include <com/sun/star/script/XInvocation.hpp> - using namespace ::com::sun::star; using namespace com::sun::star::lang; using namespace com::sun::star::reflection; using namespace com::sun::star::beans; @@ -107,6 +106,7 @@ using namespace com::sun::star::script; #include <cppuhelper/implbase1.hxx> #include <comphelper/anytostring.hxx> #include <com/sun/star/beans/XPropertySet.hpp> +#include <ooo/vba/VbQueryClose.hpp> typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE; typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap; @@ -451,24 +451,36 @@ TYPEINIT1(SbUserFormModule,SbObjModule) typedef std::vector<HighlightPortion> HighlightPortions; -bool getDefaultVBAMode( StarBASIC* pb ) +uno::Reference< frame::XModel > getDocumentModel( StarBASIC* pb ) { - bool bResult = false; - if ( pb && pb->IsDocBasic() ) + uno::Reference< frame::XModel > xModel; + if( pb && pb->IsDocBasic() ) { uno::Any aDoc; - if ( pb->GetUNOConstant( "ThisComponent", aDoc ) ) - { - uno::Reference< beans::XPropertySet > xProp( aDoc, uno::UNO_QUERY ); - if ( xProp.is() ) - { - uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY ); - if ( xVBAMode.is() ) - bResult = xVBAMode->getVBACompatibilityMode() == sal_True; - } - } + if( pb->GetUNOConstant( "ThisComponent", aDoc ) ) + xModel.set( aDoc, uno::UNO_QUERY ); + } + return xModel; +} + +uno::Reference< vba::XVBACompatibility > getVBACompatibility( const uno::Reference< frame::XModel >& rxModel ) +{ + uno::Reference< vba::XVBACompatibility > xVBACompat; + try + { + uno::Reference< beans::XPropertySet > xModelProps( rxModel, uno::UNO_QUERY_THROW ); + xVBACompat.set( xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY ); + } + catch( uno::Exception& ) + { } - return bResult; + return xVBACompat; +} + +bool getDefaultVBAMode( StarBASIC* pb ) +{ + uno::Reference< vba::XVBACompatibility > xVBACompat = getVBACompatibility( getDocumentModel( pb ) ); + return xVBACompat.is() && xVBACompat->getVBACompatibilityMode(); } class AsyncQuitHandler @@ -501,20 +513,6 @@ IMPL_LINK( AsyncQuitHandler, OnAsyncQuit, void*, /*pNull*/ ) return 0L; } -void VBAUnlockDocuments( StarBASIC* pBasic ) -{ - if ( pBasic && pBasic->IsDocBasic() ) - { - SbUnoObject* pGlobs = dynamic_cast< SbUnoObject* >( pBasic->Find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) ), SbxCLASS_DONTCARE ) ); - if ( pGlobs ) - { - uno::Reference< frame::XModel > xModel( pGlobs->getUnoAny(), uno::UNO_QUERY ); - ::basic::vba::lockControllersOfAllDocuments( xModel, sal_False ); - ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, sal_True ); - } - } -} - ///////////////////////////////////////////////////////////////////////////// // Ein BASIC-Modul hat EXTSEARCH gesetzt, damit die im Modul enthaltenen @@ -833,7 +831,7 @@ void SbModule::SetSource( const String& r ) void SbModule::SetSource32( const ::rtl::OUString& r ) { // Default basic mode to library container mode, but.. allow Option VBASupport 0/1 override - SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) ); + SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) ); aOUSource = r; StartDefinitions(); SbiTokenizer aTok( r ); @@ -1019,8 +1017,22 @@ sal_Bool SbModule::IsVBACompat() const void SbModule::SetVBACompat( sal_Bool bCompat ) { - mbVBACompat = bCompat; + if( mbVBACompat != bCompat ) + { + mbVBACompat = bCompat; + // initialize VBA document API + if( mbVBACompat ) try + { + StarBASIC* pBasic = static_cast< StarBASIC* >( GetParent() ); + uno::Reference< lang::XMultiServiceFactory > xFactory( getDocumentModel( pBasic ), uno::UNO_QUERY_THROW ); + xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); + } + catch( Exception& ) + { + } + } } + // Ausfuehren eines BASIC-Unterprogramms sal_uInt16 SbModule::Run( SbMethod* pMeth ) { @@ -1031,6 +1043,8 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) sal_uInt16 nRes = 0; sal_Bool bDelInst = sal_Bool( pINST == NULL ); StarBASICRef xBasic; + uno::Reference< frame::XModel > xModel; + uno::Reference< script::vba::XVBACompatibility > xVBACompat; if( bDelInst ) { #ifdef DBG_TRACE_BASIC @@ -1041,6 +1055,23 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) pINST = new SbiInstance( (StarBASIC*) GetParent() ); + /* If a VBA script in a document is started, get the VBA compatibility + interface from the document Basic library container, and notify all + VBA script listeners about the started script. */ + if( mbVBACompat ) + { + StarBASIC* pBasic = static_cast< StarBASIC* >( GetParent() ); + if( pBasic && pBasic->IsDocBasic() ) try + { + xModel.set( getDocumentModel( pBasic ), uno::UNO_SET_THROW ); + xVBACompat.set( getVBACompatibility( xModel ), uno::UNO_SET_THROW ); + xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STARTED, GetName() ); + } + catch( uno::Exception& ) + { + } + } + // Launcher problem // i80726 The Find below will genarate an error in Testtool so we reset it unless there was one before already sal_Bool bWasError = SbxBase::GetError() != 0; @@ -1183,9 +1214,20 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) ResetCapturedAssertions(); #endif - // VBA always ensures screenupdating is enabled after completing - if ( mbVBACompat ) - VBAUnlockDocuments( PTR_CAST( StarBASIC, GetParent() ) ); + if( xVBACompat.is() ) + { + // notify all VBA script listeners about the stopped script + try + { + xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STOPPED, GetName() ); + } + catch( uno::Exception& ) + { + } + // VBA always ensures screenupdating is enabled after completing + ::basic::vba::lockControllersOfAllDocuments( xModel, sal_False ); + ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, sal_True ); + } #ifdef DBG_TRACE_BASIC dbg_DeInitTrace(); @@ -2276,8 +2318,9 @@ public: uno::Reference< document::XVbaMethodParameter > xVbaMethodParameter( xControl->getPeer(), uno::UNO_QUERY ); if ( xVbaMethodParameter.is() ) { +#endif sal_Int8 nCancel = 0; - sal_Int8 nCloseMode = 0; + sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormControlMenu; Sequence< Any > aParams; aParams.realloc(2); @@ -2286,14 +2329,13 @@ public: mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), aParams); +#if IN_THE_FUTURE xVbaMethodParameter->setVbaMethodParameter( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cancel")), aParams[0]); return; } } } - - mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ) ); #endif } //liuchen 2009-7-21 @@ -2403,15 +2445,14 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun ) Sequence< Any > aArguments; triggerMethod( aMethodToRun, aArguments ); } -void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& /*aArguments*/) + +void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& aArguments ) { OSL_TRACE("*** trigger %s ***", rtl::OUStringToOString( aMethodToRun, RTL_TEXTENCODING_UTF8 ).getStr() ); // Search method SbxVariable* pMeth = SbObjModule::Find( aMethodToRun, SbxCLASS_METHOD ); if( pMeth ) { -#if IN_THE_FUTURE - //liuchen 2009-7-21, support Excel VBA UserForm_QueryClose event with parameters if ( aArguments.getLength() > 0 ) // Setup parameters { SbxArrayRef xArray = new SbxArray; @@ -2439,8 +2480,6 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any pMeth->SetParameters( NULL ); } else -//liuchen 2009-7-21 -#endif { SbxValues aVals; pMeth->Get( aVals ); @@ -2532,7 +2571,7 @@ void SbUserFormModule::Unload() OSL_TRACE("** Unload() "); sal_Int8 nCancel = 0; - sal_Int8 nCloseMode = 1; + sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormCode; Sequence< Any > aParams; aParams.realloc(2); @@ -2542,7 +2581,7 @@ void SbUserFormModule::Unload() triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), aParams); aParams[0] >>= nCancel; - if (nCancel == 1) + if (nCancel != 0) // Basic returns -1 for "True" { return; } @@ -2585,6 +2624,9 @@ void SbUserFormModule::InitObject() SbUnoObject* pGlobs = (SbUnoObject*)GetParent()->Find( aHook, SbxCLASS_DONTCARE ); if ( m_xModel.is() && pGlobs ) { + // broadcast INITIALIZE_USERFORM script event before the dialog is created + Reference< script::vba::XVBACompatibility > xVBACompat( getVBACompatibility( m_xModel ), uno::UNO_SET_THROW ); + xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::INITIALIZE_USERFORM, GetName() ); uno::Reference< lang::XMultiServiceFactory > xVBAFactory( pGlobs->getUnoAny(), uno::UNO_QUERY_THROW ); uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index a8c7e3f5330f..f59edfbb12e9 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -303,6 +303,8 @@ void SbiCodeGen::Save() nUserData |= nDefaultId; if( pPar->IsParamArray() ) nUserData |= PARAM_INFO_PARAMARRAY; + if( pPar->IsWithBrackets() ) + nUserData |= PARAM_INFO_WITHBRACKETS; if( nUserData ) { SbxParamInfo* pParam = (SbxParamInfo*)pInfo->GetParam( i ); diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index 1ba8982404e4..03c4845569a7 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -51,7 +51,11 @@ SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, sal_Bool bStatic, sal_Bool bC SbiDimList* pDim = NULL; // Klammern? if( Peek() == LPAREN ) + { pDim = new SbiDimList( this ); + if( !pDim->GetDims() ) + pDef->SetWithBrackets(); + } pDef->SetType( t ); if( bStatic ) pDef->SetStatic(); @@ -382,6 +386,9 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) if( nFixedStringLength >= 0 ) nOpnd2 |= (SBX_FIXED_LEN_STRING_FLAG + (sal_uInt32(nFixedStringLength) << 17)); // len = all bits above 0x10000 + if( pDim != NULL && pDim->GetDims() > 0 ) + nOpnd2 |= SBX_TYPE_VAR_TO_DIM_FLAG; + aGen.Gen( eOp2, pDef->GetId(), nOpnd2 ); } diff --git a/basic/source/comp/makefile.mk b/basic/source/comp/makefile.mk index d65f6a431e43..1e17b35cde61 100644 --- a/basic/source/comp/makefile.mk +++ b/basic/source/comp/makefile.mk @@ -53,7 +53,8 @@ EXCEPTIONSFILES= \ $(SLO)$/codegen.obj \ $(SLO)$/dim.obj \ $(SLO)$/exprtree.obj \ - $(SLO)$/parser.obj + $(SLO)$/parser.obj \ + $(SLO)$/sbcomp.obj # --- Targets -------------------------------------------------------------- diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 12e368d1c7eb..1b3395b70526 100755 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -33,7 +33,7 @@ #include "image.hxx" #include "sbtrace.hxx" #include <basic/sbobjmod.hxx> - +#include <stdio.h> //========================================================================== // Tracing, for debugging only @@ -44,12 +44,13 @@ #include <hash_map> // Trace ini file (set NULL to ignore) -static char GpTraceIniFile[] = "d:\\zBasic.Asm\\BasicTrace.ini"; +// can be overridden with the environment variable OOO_BASICTRACEINI +static char GpTraceIniFile[] = "~/BasicTrace.ini"; //static char* GpTraceIniFile = NULL; // Trace Settings, used if no ini file / not found in ini file -static char GpTraceFileNameDefault[] = "d:\\zBasic.Asm\\BasicTrace.txt"; +static char GpTraceFileNameDefault[] = "~/BasicTrace.txt"; static char* GpTraceFileName = GpTraceFileNameDefault; // GbTraceOn: @@ -63,6 +64,12 @@ static bool GbTraceOn = true; // with TraceCommand( "PCodeOn" / "PCodeOff" ), see below static bool GbIncludePCodes = false; +// GbInitOnlyAtOfficeStart: +// true = Tracing is only intialized onces after Office start when +// Basic runs the first time. Further calls to Basic, e.g. via events +// use the same output file. The trace ini file is not read again. +static bool GbInitOnlyAtOfficeStart = false; + static int GnIndentPerCallLevel = 4; static int GnIndentForPCode = 2; @@ -84,6 +91,37 @@ static int GnIndentForPCode = 2; long as it can be converted to string */ +#ifdef DBG_TRACE_PROFILING + +#include <algorithm> +#include <stack> +#include "canvas/elapsedtime.hxx" + +//*** Profiling *** +// GbTimerOn: +// true = including time stamps +static bool GbTimerOn = true; + +// GbTimeStampForEachStep: +// true = prints time stamp after each command / pcode (very slow) +static bool GbTimeStampForEachStep = false; + +// GbBlockAllAfterFirstFunctionUsage: +// true = everything (commands, pcodes, functions) is only printed +// for the first usage (improves performance when tracing / pro- +// filing large macros) +static bool GbBlockAllAfterFirstFunctionUsage = false; + +// GbBlockStepsAfterFirstFunctionUsage: +// true = commands / pcodes are only printed for the first time +// a function is executed. Afterwards only the entering/leaving +// messages are logged (improves performance when tracing / pro- +// filing large macros) +static bool GbBlockStepsAfterFirstFunctionUsage = false; + +#endif + + static void lcl_skipWhites( char*& rpc ) { while( *rpc == ' ' || *rpc == '\t' ) @@ -174,11 +212,28 @@ static void lcl_ReadIniFile( const char* pIniFileName ) if( strcmp( VarNameBuffer, "GbIncludePCodes") == 0 ) GbIncludePCodes = (strcmp( ValBuffer, "true" ) == 0); else + if( strcmp( VarNameBuffer, "GbInitOnlyAtOfficeStart") == 0 ) + GbInitOnlyAtOfficeStart = (strcmp( ValBuffer, "true" ) == 0); + else if( strcmp( VarNameBuffer, "GnIndentPerCallLevel") == 0 ) GnIndentPerCallLevel = strtol( ValBuffer, NULL, 10 ); else if( strcmp( VarNameBuffer, "GnIndentForPCode") == 0 ) GnIndentForPCode = strtol( ValBuffer, NULL, 10 ); +#ifdef DBG_TRACE_PROFILING + else + if( strcmp( VarNameBuffer, "GbTimerOn") == 0 ) + GbTimerOn = (strcmp( ValBuffer, "true" ) == 0); + else + if( strcmp( VarNameBuffer, "GbTimeStampForEachStep") == 0 ) + GbTimeStampForEachStep = (strcmp( ValBuffer, "true" ) == 0); + else + if( strcmp( VarNameBuffer, "GbBlockAllAfterFirstFunctionUsage") == 0 ) + GbBlockAllAfterFirstFunctionUsage = (strcmp( ValBuffer, "true" ) == 0); + else + if( strcmp( VarNameBuffer, "GbBlockStepsAfterFirstFunctionUsage") == 0 ) + GbBlockStepsAfterFirstFunctionUsage = (strcmp( ValBuffer, "true" ) == 0); +#endif } fclose( pFile ); } @@ -209,14 +264,14 @@ static void lcl_PrepareTraceForModule( SbModule* pModule ) pModule->Disassemble( aDisassemblyStr ); } -static void lcl_lineOut( const char* pFileName, const char* pStr, const char* pPreStr = NULL ) +static FILE* GpGlobalFile = NULL; + +static void lcl_lineOut( const char* pStr, const char* pPreStr = NULL, const char* pPostStr = NULL ) { - const char* pPrintFirst = (pPreStr != NULL) ? pPreStr : ""; - FILE* pFile = fopen( pFileName, "a+" ); - if( pFile != NULL ) + if( GpGlobalFile != NULL ) { - fprintf( pFile, "%s%s\n", pPrintFirst, pStr ); - fclose( pFile ); + fprintf( GpGlobalFile, "%s%s%s\n", pPreStr ? pPreStr : "", pStr, pPostStr ? pPostStr : "" ); + fflush( GpGlobalFile ); } } @@ -304,32 +359,198 @@ String lcl_dumpMethodParameters( SbMethod* pMethod ) // Public functions - static bool GbSavTraceOn = false; + +#ifdef DBG_TRACE_PROFILING +static canvas::tools::ElapsedTime* GpTimer = NULL; +static double GdStartTime = 0.0; +static double GdLastTime = 0.0; +static bool GbBlockSteps = false; +static bool GbBlockAll = false; + +struct FunctionItem +{ + String m_aCompleteFunctionName; + double m_dTotalTime; + double m_dNetTime; + int m_nCallCount; + bool m_bBlockAll; + bool m_bBlockSteps; + + FunctionItem( void ) + : m_dTotalTime( 0.0 ) + , m_dNetTime( 0.0 ) + , m_nCallCount( 0 ) + , m_bBlockAll( false ) + , m_bBlockSteps( false ) + {} +}; +typedef std::hash_map< ::rtl::OUString, FunctionItem*, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > FunctionItemMap; + +static std::stack< double > GaCallEnterTimeStack; +static std::stack< FunctionItem* > GaFunctionItemStack; +static FunctionItemMap GaFunctionItemMap; + +bool compareFunctionNetTime( FunctionItem* p1, FunctionItem* p2 ) +{ + return (p1->m_dNetTime > p2->m_dNetTime); +} + +void lcl_printTimeOutput( void ) +{ + // Overall time output + lcl_lineOut( "" ); + lcl_lineOut( "***** Time Output *****" ); + char TimeBuffer[500]; + double dTotalTime = GpTimer->getElapsedTime() - GdStartTime; + sprintf( TimeBuffer, "Total execution time = %f ms", dTotalTime*1000.0 ); + lcl_lineOut( TimeBuffer ); + lcl_lineOut( "" ); + + if( GbTimerOn ) + { + lcl_lineOut( "Functions:" ); + + std::vector<FunctionItem*> avFunctionItems; + + FunctionItemMap::iterator it; + for( it = GaFunctionItemMap.begin() ; it != GaFunctionItemMap.end() ; ++it ) + { + FunctionItem* pFunctionItem = it->second; + if( pFunctionItem != NULL ) + avFunctionItems.push_back( pFunctionItem ); + } + + std::sort( avFunctionItems.begin(), avFunctionItems.end(), compareFunctionNetTime ); + + std::vector<FunctionItem*>::iterator itv; + for( itv = avFunctionItems.begin() ; itv != avFunctionItems.end() ; ++itv ) + { + FunctionItem* pFunctionItem = *itv; + if( pFunctionItem != NULL ) + { + rtl::OUString aCompleteFunctionName = pFunctionItem->m_aCompleteFunctionName; + const char* pName = OUStringToOString( aCompleteFunctionName, RTL_TEXTENCODING_ASCII_US ).getStr(); + int nNameLen = aCompleteFunctionName.getLength(); + + double dFctTotalTime = pFunctionItem->m_dTotalTime; + double dFctNetTime = pFunctionItem->m_dNetTime; + double dFctTotalTimePercent = 100.0 * dFctTotalTime / dTotalTime; + double dFctNetTimePercent = 100.0 * dFctNetTime / dTotalTime; + int nSpaceCount = 30 - nNameLen; + if( nSpaceCount < 0 ) + nSpaceCount = 2; + sprintf( TimeBuffer, "%s:%sCalled %d times\t%f ms (%f%%) / net %f (%f%%) ms", + pName, lcl_getSpaces( nSpaceCount ), pFunctionItem->m_nCallCount, + dFctTotalTime*1000.0, dFctTotalTimePercent, dFctNetTime*1000.0, dFctNetTimePercent ); + lcl_lineOut( TimeBuffer ); + } + } + } +} +#endif + + +static bool GbInitTraceAlreadyCalled = false; + void dbg_InitTrace( void ) { - if( GpTraceIniFile != NULL ) + if( GbInitOnlyAtOfficeStart && GbInitTraceAlreadyCalled ) + { +#ifdef DBG_TRACE_PROFILING + if( GbTimerOn ) + GpTimer->continueTimer(); +#endif + GpGlobalFile = fopen( GpTraceFileName, "a+" ); + return; + } + GbInitTraceAlreadyCalled = true; + + if( const sal_Char* pcIniFileName = ::getenv( "OOO_BASICTRACEINI" ) ) + lcl_ReadIniFile( pcIniFileName ); + else if( GpTraceIniFile != NULL ) lcl_ReadIniFile( GpTraceIniFile ); - FILE* pFile = fopen( GpTraceFileName, "w" ); - if( pFile != NULL ) - fclose( pFile ); + GpGlobalFile = fopen( GpTraceFileName, "w" ); GbSavTraceOn = GbTraceOn; if( !GbTraceOn ) - lcl_lineOut( GpTraceFileName, "### Program started with trace off ###" ); + lcl_lineOut( "### Program started with trace off ###" ); + +#ifdef DBG_TRACE_PROFILING + GpTimer = new canvas::tools::ElapsedTime(); + GdStartTime = GpTimer->getElapsedTime(); + GdLastTime = GdStartTime; + GbBlockSteps = false; + GbBlockAll = false; +#endif } void dbg_DeInitTrace( void ) { GbTraceOn = GbSavTraceOn; + +#ifdef DBG_TRACE_PROFILING + while( !GaCallEnterTimeStack.empty() ) + GaCallEnterTimeStack.pop(); + while( !GaFunctionItemStack.empty() ) + GaFunctionItemStack.pop(); + + lcl_printTimeOutput(); + + for( FunctionItemMap::iterator it = GaFunctionItemMap.begin() ; it != GaFunctionItemMap.end() ; ++it ) + delete it->second; + GaFunctionItemMap.clear(); + + if( GpGlobalFile ) + { + fclose( GpGlobalFile ); + GpGlobalFile = NULL; + } + + if( GbInitOnlyAtOfficeStart ) + { + if( GbTimerOn ) + GpTimer->pauseTimer(); + } + else + { + delete GpTimer; + } +#endif } static sal_Int32 GnLastCallLvl = 0; +void dbg_tracePrint( const String& aStr, sal_Int32 nCallLvl, bool bCallLvlRelativeToCurrent ) +{ + if( bCallLvlRelativeToCurrent ) + nCallLvl += GnLastCallLvl; + + int nIndent = nCallLvl * GnIndentPerCallLevel; + lcl_lineOut( OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) ); +} + void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl ) { if( !GbTraceOn ) return; + +#ifdef DBG_TRACE_PROFILING + if( GbBlockSteps || GbBlockAll ) + return; + + double dCurTime = 0.0; + bool bPrintTimeStamp = false; + if( GbTimerOn ) + { + GpTimer->pauseTimer(); + dCurTime = GpTimer->getElapsedTime(); + bPrintTimeStamp = GbTimeStampForEachStep; + } +#else + bool bPrintTimeStamp = false; +#endif + GnLastCallLvl = nCallLvl; SbModule* pTraceMod = pModule; @@ -346,14 +567,14 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl ) const char* pModuleNameStr = OUStringToOString( rtl::OUString( aModuleName ), RTL_TEXTENCODING_ASCII_US ).getStr(); char Buffer[200]; sprintf( Buffer, "TRACE ERROR: Unknown module \"%s\"", pModuleNameStr ); - lcl_lineOut( GpTraceFileName, Buffer ); + lcl_lineOut( Buffer ); return; } PCToTextDataMap* pInnerMap = it->second; if( pInnerMap == NULL ) { - lcl_lineOut( GpTraceFileName, "TRACE INTERNAL ERROR: No inner map" ); + lcl_lineOut( "TRACE INTERNAL ERROR: No inner map" ); return; } @@ -363,7 +584,7 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl ) const char* pModuleNameStr = OUStringToOString( rtl::OUString( aModuleName ), RTL_TEXTENCODING_ASCII_US ).getStr(); char Buffer[200]; sprintf( Buffer, "TRACE ERROR: No info for PC = %d in module \"%s\"", (int)nPC, pModuleNameStr ); - lcl_lineOut( GpTraceFileName, Buffer ); + lcl_lineOut( Buffer ); return; } @@ -371,24 +592,67 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl ) const TraceTextData& rTraceTextData = itInner->second; const rtl::OString& rStr_STMNT = rTraceTextData.m_aTraceStr_STMNT; + bool bSTMT = false; if( rStr_STMNT.getLength() ) - lcl_lineOut( GpTraceFileName, rStr_STMNT.getStr(), lcl_getSpaces( nIndent ) ); + bSTMT = true; + + char TimeBuffer[200]; +#ifdef DBG_TRACE_PROFILING + if( bPrintTimeStamp ) + { + double dDiffTime = dCurTime - GdLastTime; + GdLastTime = dCurTime; + sprintf( TimeBuffer, "\t\t// Time = %f ms / += %f ms", dCurTime*1000.0, dDiffTime*1000.0 ); + } +#endif + + if( bSTMT ) + { + lcl_lineOut( rStr_STMNT.getStr(), lcl_getSpaces( nIndent ), + (bPrintTimeStamp && !GbIncludePCodes) ? TimeBuffer : NULL ); + } if( !GbIncludePCodes ) + { +#ifdef DBG_TRACE_PROFILING + if( GbTimerOn ) + GpTimer->continueTimer(); +#endif return; + } nIndent += GnIndentForPCode; const rtl::OString& rStr_PCode = rTraceTextData.m_aTraceStr_PCode; if( rStr_PCode.getLength() ) - lcl_lineOut( GpTraceFileName, rStr_PCode.getStr(), lcl_getSpaces( nIndent ) ); + { + lcl_lineOut( rStr_PCode.getStr(), lcl_getSpaces( nIndent ), + bPrintTimeStamp ? TimeBuffer : NULL ); + } + +#ifdef DBG_TRACE_PROFILING + if( GbTimerOn ) + GpTimer->continueTimer(); +#endif } + void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallLvl, bool bLeave ) { static const char* pSeparator = "' ================================================================================"; if( !GbTraceOn ) return; + +#ifdef DBG_TRACE_PROFILING + double dCurTime = 0.0; + double dExecutionTime = 0.0; + if( GbTimerOn ) + { + dCurTime = GpTimer->getElapsedTime(); + GpTimer->pauseTimer(); + } +#endif + GnLastCallLvl = nCallLvl; SbModule* pTraceMod = pModule; @@ -399,39 +663,116 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL pTraceMod = pClassModuleObj->getClassModule(); } + String aCompleteFunctionName = pTraceMod->GetName(); + if( pMethod != NULL ) + { + aCompleteFunctionName.AppendAscii( "::" ); + String aMethodName = pMethod->GetName(); + aCompleteFunctionName += aMethodName; + } + else + { + aCompleteFunctionName.AppendAscii( "/RunInit" ); + } + + bool bOwnBlockSteps = false; +#ifdef DBG_TRACE_PROFILING + bool bOwnBlockAll = false; + FunctionItem* pFunctionItem = NULL; + if( GbTimerOn ) + { + FunctionItemMap::iterator itFunctionItem = GaFunctionItemMap.find( aCompleteFunctionName ); + if( itFunctionItem != GaFunctionItemMap.end() ) + pFunctionItem = itFunctionItem->second; + + if( pFunctionItem == NULL ) + { + DBG_ASSERT( !bLeave, "No FunctionItem in leave!" ); + + pFunctionItem = new FunctionItem(); + pFunctionItem->m_aCompleteFunctionName = aCompleteFunctionName; + GaFunctionItemMap[ aCompleteFunctionName ] = pFunctionItem; + } + else if( GbBlockAllAfterFirstFunctionUsage && !bLeave ) + { + pFunctionItem->m_bBlockAll = true; + } + else if( GbBlockStepsAfterFirstFunctionUsage && !bLeave ) + { + pFunctionItem->m_bBlockSteps = true; + } + + if( bLeave ) + { + bOwnBlockAll = GbBlockAll; + bOwnBlockSteps = GbBlockSteps; + GbBlockAll = false; + GbBlockSteps = false; + + dExecutionTime = dCurTime - GaCallEnterTimeStack.top(); + GaCallEnterTimeStack.pop(); + + pFunctionItem->m_dTotalTime += dExecutionTime; + pFunctionItem->m_dNetTime += dExecutionTime; + pFunctionItem->m_nCallCount++; + + GaFunctionItemStack.pop(); + if( !GaFunctionItemStack.empty() ) + { + FunctionItem* pParentItem = GaFunctionItemStack.top(); + if( pParentItem != NULL ) + { + pParentItem->m_dNetTime -= dExecutionTime; + + GbBlockSteps = pParentItem->m_bBlockSteps; + GbBlockAll = pParentItem->m_bBlockAll; + } + } + } + else + { + GbBlockSteps = bOwnBlockSteps = pFunctionItem->m_bBlockSteps; + GbBlockAll = bOwnBlockAll = pFunctionItem->m_bBlockAll; + + GaCallEnterTimeStack.push( dCurTime ); + GaFunctionItemStack.push( pFunctionItem ); + } + } + + if( bOwnBlockAll ) + { + if( GbTimerOn ) + GpTimer->continueTimer(); + return; + } +#endif + if( nCallLvl > 0 ) nCallLvl--; int nIndent = nCallLvl * GnIndentPerCallLevel; - if( !bLeave ) + if( !bLeave && !bOwnBlockSteps ) { - lcl_lineOut( GpTraceFileName, "" ); - lcl_lineOut( GpTraceFileName, pSeparator, lcl_getSpaces( nIndent ) ); + lcl_lineOut( "" ); + lcl_lineOut( pSeparator, lcl_getSpaces( nIndent ) ); } String aStr; if( bLeave ) { - lcl_lineOut( GpTraceFileName, "}", lcl_getSpaces( nIndent ) ); - aStr.AppendAscii( "' Leaving " ); + if( !bOwnBlockSteps ) + { + lcl_lineOut( "}", lcl_getSpaces( nIndent ) ); + aStr.AppendAscii( "' Leaving " ); + } } else { aStr.AppendAscii( "Entering " ); } - String aModuleName = pTraceMod->GetName(); - aStr += aModuleName; - if( pMethod != NULL ) - { - aStr.AppendAscii( "::" ); - String aMethodName = pMethod->GetName(); - aStr += aMethodName; - } - else - { - aStr.AppendAscii( "/RunInit" ); - } + if( !bLeave || !bOwnBlockSteps ) + aStr += aCompleteFunctionName; - if( pClassModuleObj != NULL ) + if( !bOwnBlockSteps && pClassModuleObj != NULL ) { aStr.AppendAscii( "[this=" ); aStr += pClassModuleObj->GetName(); @@ -440,18 +781,37 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL if( !bLeave ) aStr += lcl_dumpMethodParameters( pMethod ); - lcl_lineOut( GpTraceFileName, OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) ); + const char* pPostStr = NULL; +#ifdef DBG_TRACE_PROFILING + char TimeBuffer[200]; + if( GbTimerOn && bLeave ) + { + sprintf( TimeBuffer, " // Execution Time = %f ms", dExecutionTime*1000.0 ); + pPostStr = TimeBuffer; + } +#endif + lcl_lineOut( (!bLeave || !bOwnBlockSteps) ? OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr() : "}", + lcl_getSpaces( nIndent ), pPostStr ); if( !bLeave ) - lcl_lineOut( GpTraceFileName, "{", lcl_getSpaces( nIndent ) ); + lcl_lineOut( "{", lcl_getSpaces( nIndent ) ); - if( bLeave ) - lcl_lineOut( GpTraceFileName, "" ); + if( bLeave && !bOwnBlockSteps ) + lcl_lineOut( "" ); + +#ifdef DBG_TRACE_PROFILING + if( GbTimerOn ) + GpTimer->continueTimer(); +#endif } void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, sal_Int32 nCallLvl ) { if( !GbTraceOn ) return; +#ifdef DBG_TRACE_PROFILING + if( GbBlockSteps || GbBlockAll ) + return; +#endif GnLastCallLvl = nCallLvl; rtl::OString aOTraceErrMsg = OUStringToOString( rtl::OUString( aTraceErrMsg ), RTL_TEXTENCODING_ASCII_US ); @@ -460,7 +820,7 @@ void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool b const char* pHandledStr = bTraceErrHandled ? " / HANDLED" : ""; sprintf( Buffer, "*** ERROR%s, Id = %d, Msg = \"%s\" ***", pHandledStr, (int)nTraceErr, aOTraceErrMsg.getStr() ); int nIndent = nCallLvl * GnIndentPerCallLevel; - lcl_lineOut( GpTraceFileName, Buffer, lcl_getSpaces( nIndent ) ); + lcl_lineOut( Buffer, lcl_getSpaces( nIndent ) ); } void dbg_RegisterTraceTextForPC( SbModule* pModule, sal_uInt32 nPC, @@ -540,7 +900,7 @@ void RTL_Impl_TraceCommand( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ) sprintf( Buffer, "### TRACE_PRINT: %s ###", pValStr ); int nIndent = GnLastCallLvl * GnIndentPerCallLevel; - lcl_lineOut( GpTraceFileName, Buffer, lcl_getSpaces( nIndent ) ); + lcl_lineOut( Buffer, lcl_getSpaces( nIndent ) ); if( eOld != SbxERR_OK ) SbxBase::SetError( eOld ); diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx index 2688b5be28cf..cc6dc04fde65 100644 --- a/basic/source/comp/symtbl.cxx +++ b/basic/source/comp/symtbl.cxx @@ -302,6 +302,7 @@ SbiSymDef::SbiSymDef( const String& rName ) : aName( rName ) bOpt = bParamArray = bWithEvents = + bWithBrackets = bByVal = bChained = bGlobal = sal_False; diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx index 8700ae4129ba..28c90ff0bd87 100644 --- a/basic/source/comp/token.cxx +++ b/basic/source/comp/token.cxx @@ -561,7 +561,8 @@ SbiToken SbiTokenizer::Next() } special: // #i92642 - if( eCurTok != NIL && eCurTok != REM && eCurTok != EOLN && (tp->t == NAME || tp->t == LINE) ) + bool bStartOfLine = (eCurTok == NIL || eCurTok == REM || eCurTok == EOLN); + if( !bStartOfLine && (tp->t == NAME || tp->t == LINE) ) return eCurTok = SYMBOL; else if( tp->t == TEXT ) return eCurTok = SYMBOL; @@ -628,6 +629,9 @@ special: // #129904 Suppress system if( eTok == STOP && aSym.CompareIgnoreCaseToAscii( "system" ) == COMPARE_EQUAL ) eCurTok = SYMBOL; + + if( eTok == GET && bStartOfLine ) + eCurTok = SYMBOL; } else { diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx index a496322bb6d7..9ba99e7ceae8 100644 --- a/basic/source/inc/codegen.hxx +++ b/basic/source/inc/codegen.hxx @@ -87,6 +87,7 @@ public: // #111897 PARAM_INFO flags start at 0x00010000 to not // conflict with DefaultId in SbxParamInfo::nUserData -#define PARAM_INFO_PARAMARRAY 0x0010000 +#define PARAM_INFO_PARAMARRAY 0x0010000 +#define PARAM_INFO_WITHBRACKETS 0x0020000 #endif diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 7fd6eb06f607..c0e8191be307 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -29,6 +29,7 @@ #define BASIC_NAMECONTAINER_HXX #include <hash_map> + #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/lang/XInitialization.hpp> @@ -46,71 +47,41 @@ #include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/deployment/XPackage.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAScriptListener.hpp> +#include <com/sun/star/util/XChangesNotifier.hpp> + #include <osl/mutex.hxx> #include <unotools/eventlisteneradapter.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/compbase8.hxx> +#include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/weakref.hxx> #include <cppuhelper/component.hxx> #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/basemutex.hxx> #include <sot/storage.hxx> +#include <comphelper/listenernotification.hxx> #include <xmlscript/xmllib_imexp.hxx> -#include <com/sun/star/deployment/XPackage.hpp> - -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/compbase8.hxx> -#include <cppuhelper/interfacecontainer.hxx> -#include <com/sun/star/script/vba/XVBACompatibility.hpp> class BasicManager; namespace basic { -typedef ::cppu::WeakComponentImplHelper8< - ::com::sun::star::lang::XInitialization, - ::com::sun::star::script::XStorageBasedLibraryContainer, - ::com::sun::star::script::XLibraryContainerPassword, - ::com::sun::star::script::XLibraryContainerExport, - ::com::sun::star::script::XLibraryContainer3, - ::com::sun::star::container::XContainer, - ::com::sun::star::script::vba::XVBACompatibility, - ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper; - -typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer, - ::com::sun::star::container::XContainer > NameContainerHelper; - +//============================================================================ -struct hashName_Impl -{ - size_t operator()(const ::rtl::OUString Str) const - { - return (size_t)Str.hashCode(); - } -}; +typedef ::cppu::WeakImplHelper3< + ::com::sun::star::container::XNameContainer, + ::com::sun::star::container::XContainer, + ::com::sun::star::util::XChangesNotifier > NameContainer_BASE; -struct eqName_Impl +class NameContainer : public ::cppu::BaseMutex, public NameContainer_BASE { - sal_Bool operator()(const ::rtl::OUString Str1, const ::rtl::OUString Str2) const - { - return ( Str1 == Str2 ); - } -}; - -typedef std::hash_map -< - ::rtl::OUString, - sal_Int32, - hashName_Impl, - eqName_Impl -> -NameContainerNameMap; - - -//============================================================================ + typedef std::hash_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > NameContainerNameMap; -class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper -{ NameContainerNameMap mHashMap; ::com::sun::star::uno::Sequence< ::rtl::OUString > mNames; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > mValues; @@ -119,14 +90,16 @@ class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper ::com::sun::star::uno::Type mType; ::com::sun::star::uno::XInterface* mpxEventSource; - ::cppu::OInterfaceContainerHelper maListenerContainer; + ::cppu::OInterfaceContainerHelper maContainerListeners; + ::cppu::OInterfaceContainerHelper maChangesListeners; public: NameContainer( const ::com::sun::star::uno::Type& rType ) : mnElementCount( 0 ) , mType( rType ) , mpxEventSource( NULL ) - , maListenerContainer( m_aMutex ) + , maContainerListeners( m_aMutex ) + , maChangesListeners( m_aMutex ) {} void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource ) @@ -173,21 +146,18 @@ public: virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // Methods XChangesNotifier + virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); }; //============================================================================ -class SfxLibrary; - -enum InitMode -{ - DEFAULT, - CONTAINER_INIT_FILE, - LIBRARY_INIT_FILE, - OFFICE_DOCUMENT, - OLD_BASIC_STORAGE -}; - class ModifiableHelper { private: @@ -217,9 +187,42 @@ public: } }; -class SfxLibraryContainer :public LibraryContainerHelper - ,public ::utl::OEventListenerAdapter +//============================================================================ + +typedef ::comphelper::OListenerContainerBase< + ::com::sun::star::script::vba::XVBAScriptListener, + ::com::sun::star::script::vba::VBAScriptEvent > VBAScriptListenerContainer_BASE; + +class VBAScriptListenerContainer : public VBAScriptListenerContainer_BASE +{ +public: + explicit VBAScriptListenerContainer( ::osl::Mutex& rMutex ); + +private: + virtual bool implTypedNotify( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& rxListener, + const ::com::sun::star::script::vba::VBAScriptEvent& rEvent ) + throw (::com::sun::star::uno::Exception); +}; + +//============================================================================ + +class SfxLibrary; + +typedef ::cppu::WeakComponentImplHelper8< + ::com::sun::star::lang::XInitialization, + ::com::sun::star::script::XStorageBasedLibraryContainer, + ::com::sun::star::script::XLibraryContainerPassword, + ::com::sun::star::script::XLibraryContainerExport, + ::com::sun::star::script::XLibraryContainer3, + ::com::sun::star::container::XContainer, + ::com::sun::star::script::vba::XVBACompatibility, + ::com::sun::star::lang::XServiceInfo > SfxLibraryContainer_BASE; + +class SfxLibraryContainer : public SfxLibraryContainer_BASE, public ::utl::OEventListenerAdapter { + VBAScriptListenerContainer maVBAScriptListeners; + sal_Int32 mnRunningVBAScripts; sal_Bool mbVBACompat; protected: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; @@ -246,7 +249,14 @@ protected: BasicManager* mpBasMgr; sal_Bool mbOwnBasMgr; - InitMode meInitMode; + enum InitMode + { + DEFAULT, + CONTAINER_INIT_FILE, + LIBRARY_INIT_FILE, + OFFICE_DOCUMENT, + OLD_BASIC_STORAGE + } meInitMode; void implStoreLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName, @@ -508,10 +518,24 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0; // Methods XVBACompatibility - virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRunningVBAScripts() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVBAScriptListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVBAScriptListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName ) + throw (::com::sun::star::uno::RuntimeException); }; +//============================================================================ + class LibraryContainerMethodGuard { private: @@ -529,12 +553,12 @@ public: } }; - //============================================================================ class SfxLibrary : public ::com::sun::star::container::XNameContainer , public ::com::sun::star::container::XContainer + , public ::com::sun::star::util::XChangesNotifier , public ::cppu::BaseMutex , public ::cppu::OComponentHelper { @@ -670,6 +694,14 @@ public: ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + // Methods XChangesNotifier + virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + public: struct LibraryContainerAccess { friend class SfxLibraryContainer; private: LibraryContainerAccess() { } }; void removeElementWithoutChecks( const ::rtl::OUString& _rElementName, LibraryContainerAccess ) @@ -681,18 +713,19 @@ protected: virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0; }; -//=================================================================== +//============================================================================ + class ScriptSubPackageIterator { - com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage; + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage; - bool m_bIsValid; - bool m_bIsBundle; + bool m_bIsValid; + bool m_bIsBundle; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aSubPkgSeq; - sal_Int32 m_nSubPkgCount; - sal_Int32 m_iNextSubPkg; + < com::sun::star::deployment::XPackage > > m_aSubPkgSeq; + sal_Int32 m_nSubPkgCount; + sal_Int32 m_iNextSubPkg; com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implDetectScriptPackage( const com::sun::star::uno::Reference @@ -704,13 +737,7 @@ public: com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > getNextScriptSubPackage( bool& rbPureDialogLib ); }; -enum IteratorState -{ - USER_EXTENSIONS, - SHARED_EXTENSIONS, - BUNDLED_EXTENSIONS, - END_REACHED -}; +//============================================================================ class ScriptExtensionIterator { @@ -731,34 +758,37 @@ protected: com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledScriptPackage( bool& rbPureDialogLib ); - com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; - IteratorState m_eState; + enum IteratorState + { + USER_EXTENSIONS, + SHARED_EXTENSIONS, + BUNDLED_EXTENSIONS, + END_REACHED + } m_eState; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq; - bool m_bUserPackagesLoaded; + < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq; + bool m_bUserPackagesLoaded; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; - bool m_bSharedPackagesLoaded; + < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; + bool m_bSharedPackagesLoaded; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; - bool m_bBundledPackagesLoaded; + < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; + bool m_bBundledPackagesLoaded; + int m_iUserPackage; + int m_iSharedPackage; + int m_iBundledPackage; - int m_iUserPackage; - int m_iSharedPackage; - int m_iBundledPackage; - - - - ScriptSubPackageIterator* m_pScriptSubPackageIterator; + ScriptSubPackageIterator* m_pScriptSubPackageIterator; }; // end class ScriptExtensionIterator - +//============================================================================ } // namespace basic diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index 46cd9d16521f..406bd487034c 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -465,6 +465,8 @@ public: SbxArray* GetLocals(); SbxArray* GetParams(); + SbiForStack* FindForStackItemForCollection( class BasicCollection* pCollection ); + SbxBase* FindElementExtern( const String& rName ); static bool isVBAEnabled(); diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx index d91c7bdf16e8..6ab27050d263 100755 --- a/basic/source/inc/sbtrace.hxx +++ b/basic/source/inc/sbtrace.hxx @@ -30,6 +30,19 @@ //#define DBG_TRACE_BASIC +// ############################################################################### +// ### +// ### ATTENTION: +// ### +// ### - DBG_TRACE_PROFILING can only be activated together with DBG_TRACE_BASIC +// ### +// ### - If you activate DBG_TRACE_PROFILING you also need to uncomment line +// ### # SHL1STDLIBS+=$(CANVASTOOLSLIB) in basic/util/makefile.mk (search +// ### for DBG_TRACE_PROFILING there) +// ### +// ############################################################################### +//#define DBG_TRACE_PROFILING + #ifdef DBG_TRACE_BASIC void dbg_InitTrace( void ); void dbg_DeInitTrace( void ); diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx index d788a73da0fc..9ef4c41c6ce3 100644 --- a/basic/source/inc/scriptcont.hxx +++ b/basic/source/inc/scriptcont.hxx @@ -35,11 +35,11 @@ class BasicManager; -//============================================================================ - namespace basic { +//============================================================================ + class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword { ::rtl::OUString maScriptLanguage; @@ -140,16 +140,15 @@ public: }; //============================================================================ -typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInfoMap; -typedef ::cppu::ImplHelper1 < ::com::sun::star::script::vba::XVBAModuleInfo - > SfxScriptLibrary_BASE; +typedef ::cppu::ImplHelper1< ::com::sun::star::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE; -class SfxScriptLibrary : public SfxLibrary - , public SfxScriptLibrary_BASE +class SfxScriptLibrary : public SfxLibrary, public SfxScriptLibrary_BASE { friend class SfxScriptLibraryContainer; + typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash > ModuleInfoMap; + sal_Bool mbLoadedSource; sal_Bool mbLoadedBinary; ModuleInfoMap mModuleInfos; @@ -194,7 +193,9 @@ protected: virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; }; -} // namespace base +//============================================================================ + +} // namespace basic #endif diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx index c30445d87634..576639dc5a45 100644 --- a/basic/source/inc/symtbl.hxx +++ b/basic/source/inc/symtbl.hxx @@ -133,6 +133,7 @@ protected: sal_Bool bGlobal : 1; // sal_True: Global-Variable sal_Bool bParamArray : 1; // sal_True: ParamArray parameter sal_Bool bWithEvents : 1; // sal_True: Declared WithEvents + sal_Bool bWithBrackets : 1; // sal_True: Followed by () sal_uInt16 nDefaultId; // Symbol number of default value short nFixedStringLength; // String length in: Dim foo As String*Length public: @@ -159,6 +160,7 @@ public: void SetOptional() { bOpt = sal_True; } void SetParamArray() { bParamArray = sal_True; } void SetWithEvents() { bWithEvents = sal_True; } + void SetWithBrackets(){ bWithBrackets = sal_True; } void SetByVal( sal_Bool bByVal_ = sal_True ) { bByVal = bByVal_; } void SetStatic( sal_Bool bAsStatic = sal_True ) { bStatic = bAsStatic; } @@ -170,6 +172,7 @@ public: sal_Bool IsOptional() const{ return bOpt; } sal_Bool IsParamArray() const{ return bParamArray; } sal_Bool IsWithEvents() const{ return bWithEvents; } + sal_Bool IsWithBrackets() const{ return bWithBrackets; } sal_Bool IsByVal() const { return bByVal; } sal_Bool IsStatic() const { return bStatic; } sal_Bool IsNew() const { return bNew; } diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 1d1f1c641547..640dd7e8bcbe 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -82,6 +82,7 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::ucb; using namespace com::sun::star::io; +using namespace com::sun::star::frame; #endif /* _USE_UNO */ @@ -96,6 +97,7 @@ using namespace com::sun::star::io; #include "iosys.hxx" #include "ddectrl.hxx" #include <sbintern.hxx> +#include <basic/vbahelper.hxx> #include <list> #include <math.h> @@ -118,6 +120,9 @@ using namespace com::sun::star::io; #include <basic/sbobjmod.hxx> +// from source/classes/sbxmod.cxx +Reference< XModel > getDocumentModel( StarBASIC* ); + static void FilterWhiteSpace( String& rStr ) { rStr.EraseAllChars( ' ' ); @@ -382,22 +387,48 @@ RTLFUNC(Asc) } } -RTLFUNC(Chr) +void implChr( SbxArray& rPar, bool bChrW ) { - (void)pBasic; - (void)bWrite; - if ( rPar.Count() < 2 ) StarBASIC::Error( SbERR_BAD_ARGUMENT ); else { SbxVariableRef pArg = rPar.Get( 1 ); - sal_Unicode aCh = (sal_Unicode)pArg->GetUShort(); - String aStr( aCh ); + + String aStr; + if( !bChrW && SbiRuntime::isVBAEnabled() ) + { + sal_Char c = (sal_Char)pArg->GetByte(); + ByteString s( c ); + aStr = String( s, gsl_getSystemTextEncoding() ); + } + else + { + sal_Unicode aCh = (sal_Unicode)pArg->GetUShort(); + aStr = String( aCh ); + } rPar.Get(0)->PutString( aStr ); } } +RTLFUNC(Chr) +{ + (void)pBasic; + (void)bWrite; + + bool bChrW = false; + implChr( rPar, bChrW ); +} + +RTLFUNC(ChrW) +{ + (void)pBasic; + (void)bWrite; + + bool bChrW = true; + implChr( rPar, bChrW ); +} + #ifdef UNX #define _MAX_PATH 260 @@ -481,7 +512,6 @@ RTLFUNC(CurDir) RTLFUNC(ChDir) // JSM { - (void)pBasic; (void)bWrite; rPar.Get(0)->PutEmpty(); @@ -504,6 +534,9 @@ RTLFUNC(ChDir) // JSM if( bError ) StarBASIC::Error( SbERR_PATH_NOT_FOUND ); #endif + // VBA: track current directory per document type (separately for Writer, Calc, Impress, etc.) + if( SbiRuntime::isVBAEnabled() ) + ::basic::vba::registerCurrentDirectory( getDocumentModel( pBasic ), rPar.Get(1)->GetString() ); } else StarBASIC::Error( SbERR_BAD_ARGUMENT ); diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 2f6d18685803..20eca1f985ff 100755..100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -1075,6 +1075,10 @@ sal_Bool lcl_ReadSbxVariable( SbxVariable& rVar, SvStream* pStrm, { sal_uInt8 aByte; *pStrm >> aByte; + + if( bBinary && SbiRuntime::isVBAEnabled() && aByte == 1 && pStrm->IsEof() ) + aByte = 0; + rVar.PutByte( aByte ); } break; @@ -1185,7 +1189,8 @@ void PutGet( SbxArray& rPar, sal_Bool bPut ) } sal_Int16 nFileNo = rPar.Get(1)->GetInteger(); SbxVariable* pVar2 = rPar.Get(2); - sal_Bool bHasRecordNo = (sal_Bool)(pVar2->GetType() != SbxEMPTY); + SbxDataType eType2 = pVar2->GetType(); + sal_Bool bHasRecordNo = (sal_Bool)(eType2 != SbxEMPTY && eType2 != SbxERROR); long nRecordNo = pVar2->GetLong(); if ( nFileNo < 1 || ( bHasRecordNo && nRecordNo < 1 ) ) { diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx index bba1867d3591..8594382bd733 100644 --- a/basic/source/runtime/rtlproto.hxx +++ b/basic/source/runtime/rtlproto.hxx @@ -157,6 +157,7 @@ extern RTLFUNC(Abs); extern RTLFUNC(Asc); extern RTLFUNC(Atn); extern RTLFUNC(Chr); +extern RTLFUNC(ChrW); extern RTLFUNC(Cos); extern RTLFUNC(CurDir); extern RTLFUNC(ChDir); // JSM diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 10d25cc2292b..1a83a323931d 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -648,6 +648,7 @@ void SbiRuntime::SetParameters( SbxArray* pParams ) // Methoden sind immer byval! sal_Bool bByVal = v->IsA( TYPE(SbxMethod) ); SbxDataType t = v->GetType(); + bool bTargetTypeIsArray = false; if( p ) { bByVal |= sal_Bool( ( p->eType & SbxBYREF ) == 0 ); @@ -656,9 +657,13 @@ void SbiRuntime::SetParameters( SbxArray* pParams ) if( !bByVal && t != SbxVARIANT && (!v->IsFixed() || (SbxDataType)(v->GetType() & 0x0FFF ) != t) ) bByVal = sal_True; + + bTargetTypeIsArray = (p->nUserData & PARAM_INFO_WITHBRACKETS) != 0; } if( bByVal ) { + if( bTargetTypeIsArray ) + t = SbxOBJECT; SbxVariable* v2 = new SbxVariable( t ); v2->SetFlag( SBX_READWRITE ); *v2 = *v; @@ -1237,6 +1242,26 @@ void SbiRuntime::ClearForStack() PopFor(); } +SbiForStack* SbiRuntime::FindForStackItemForCollection( class BasicCollection* pCollection ) +{ + SbiForStack* pRet = NULL; + + SbiForStack* p = pForStk; + while( p ) + { + SbxVariable* pVar = p->refEnd.Is() ? (SbxVariable*)p->refEnd : NULL; + if( p->eForType == FOR_EACH_COLLECTION && pVar != NULL && + (pCollection = PTR_CAST(BasicCollection,pVar)) == pCollection ) + { + pRet = p; + break; + } + } + + return pRet; +} + + ////////////////////////////////////////////////////////////////////////// // // DLL-Aufrufe diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 92d8152e60f4..4004b40e882c 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -128,7 +128,7 @@ static Methods aMethods[] = { { "Chr", SbxSTRING, 1 | _FUNCTION, RTLNAME(Chr),0 }, { "string", SbxINTEGER, 0,NULL,0 }, -{ "ChrW", SbxSTRING, 1 | _FUNCTION | _COMPTMASK, RTLNAME(Chr),0}, +{ "ChrW", SbxSTRING, 1 | _FUNCTION | _COMPTMASK, RTLNAME(ChrW),0}, { "string", SbxINTEGER, 0,NULL,0 }, { "CInt", SbxINTEGER, 1 | _FUNCTION, RTLNAME(CInt),0 }, diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 43c930e975d2..462726a4c55f 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -797,6 +797,8 @@ void SbiRuntime::DimImpl( SbxVariableRef refVar ) // AB 2.4.1996, auch Arrays ohne Dimensionsangaben zulassen (VB-komp.) if( pDims ) { + refVar->ResetFlag( SBX_VAR_TO_DIM ); + for( sal_uInt16 i = 1; i < pDims->Count(); ) { sal_Int32 lb = pDims->Get( i++ )->GetLong(); diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx index 0a9572906cc8..4fd91b692a4b 100644 --- a/basic/source/runtime/step1.cxx +++ b/basic/source/runtime/step1.cxx @@ -38,8 +38,7 @@ #include "sbunoobj.hxx" #include "errobject.hxx" -bool checkUnoObjectType( SbUnoObject* refVal, - const String& aClass ); +bool checkUnoObjectType( SbUnoObject* refVal, const ::rtl::OUString& aClass ); // Laden einer numerischen Konstanten (+ID) diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index bbb3668b5b69..dc8ff0a5fd50 100755 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -624,7 +624,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) else if( bVBAEnabled ) // !pObj { SbxArray* pParam = pElem->GetParameters(); - if( pParam != NULL ) + if( pParam != NULL && !pElem->IsSet( SBX_VAR_TO_DIM ) ) Error( SbERR_NO_OBJECT ); } } @@ -1141,6 +1141,10 @@ void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt3 aStr.Fill( nCount, 0 ); pVar->PutString( aStr ); } + + bool bVarToDim = ((nOp2 & SBX_TYPE_VAR_TO_DIM_FLAG) != 0); + if( bVarToDim ) + pVar->SetFlag( SBX_VAR_TO_DIM ); } // Einrichten einer lokalen Variablen (+StringID+Typ) diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index fbf1429f9753..ae110f4bcf6e 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -34,17 +34,13 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <vcl/svapp.hxx> #include <vos/mutex.hxx> -#ifndef __RSC //autogen #include <tools/errinf.hxx> -#endif #include <osl/mutex.hxx> #include <vos/diagnose.hxx> #include <rtl/uri.hxx> #include <rtl/strbuf.hxx> #include <comphelper/processfactory.hxx> -#ifndef INCLUDED_COMPHELPER_ANYTOSTRING_HXX #include <comphelper/anytostring.hxx> -#endif #include "namecont.hxx" #include <basic/basicmanagerrepository.hxx> @@ -65,11 +61,9 @@ #include <com/sun/star/uno/DeploymentException.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/script/LibraryNotLoadedException.hpp> -#include "com/sun/star/deployment/ExtensionManager.hpp" +#include <com/sun/star/script/vba/VBAScriptEventId.hpp> +#include <com/sun/star/deployment/ExtensionManager.hpp> #include <comphelper/storagehelper.hxx> -#ifndef _RTL_USTRING_HXX_ -#include <comphelper/anytostring.hxx> -#endif #include <cppuhelper/exc_hlp.hxx> #include <basic/sbmod.hxx> @@ -165,25 +159,29 @@ void NameContainer::replaceByName( const OUString& aName, const Any& aElement ) // Fire event - ContainerEvent aEvent; - aEvent.Source = mpxEventSource; - aEvent.Accessor <<= aName; - aEvent.Element = aElement; - aEvent.ReplacedElement = aOldElement; + if( maContainerListeners.getLength() > 0 ) + { + ContainerEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Accessor <<= aName; + aEvent.Element = aElement; + aEvent.ReplacedElement = aOldElement; + maContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvent ); + } - OInterfaceIteratorHelper aIterator( maListenerContainer ); - while( aIterator.hasMoreElements() ) + /* After the container event has been fired (one listener will update the + core Basic manager), fire change event. Listeners can rely that the + Basic source code of the core Basic manager is up-to-date. */ + if( maChangesListeners.getLength() > 0 ) { - Reference< XInterface > xIface = aIterator.next(); - Reference< XContainerListener > xListener( xIface, UNO_QUERY ); - try - { - xListener->elementReplaced( aEvent ); - } - catch(RuntimeException&) - { - aIterator.remove(); - } + ChangesEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Base <<= aEvent.Source; + aEvent.Changes.realloc( 1 ); + aEvent.Changes[ 0 ].Accessor <<= aName; + aEvent.Changes[ 0 ].Element <<= aElement; + aEvent.Changes[ 0 ].ReplacedElement = aOldElement; + maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent ); } } @@ -211,33 +209,35 @@ void NameContainer::insertByName( const OUString& aName, const Any& aElement ) mHashMap[ aName ] = nCount; mnElementCount++; - // Fire event - ContainerEvent aEvent; - aEvent.Source = mpxEventSource; - aEvent.Accessor <<= aName; - aEvent.Element = aElement; + if( maContainerListeners.getLength() > 0 ) + { + ContainerEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Accessor <<= aName; + aEvent.Element = aElement; + maContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); + } - OInterfaceIteratorHelper aIterator( maListenerContainer ); - while( aIterator.hasMoreElements() ) + /* After the container event has been fired (one listener will update the + core Basic manager), fire change event. Listeners can rely that the + Basic source code of the core Basic manager is up-to-date. */ + if( maChangesListeners.getLength() > 0 ) { - Reference< XInterface > xIface = aIterator.next(); - Reference< XContainerListener > xListener( xIface, UNO_QUERY ); - try - { - xListener->elementInserted( aEvent ); - } - catch(RuntimeException&) - { - aIterator.remove(); - } + ChangesEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Base <<= aEvent.Source; + aEvent.Changes.realloc( 1 ); + aEvent.Changes[ 0 ].Accessor <<= aName; + aEvent.Changes[ 0 ].Element <<= aElement; + maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent ); } } -void NameContainer::removeByName( const OUString& Name ) +void NameContainer::removeByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) { - NameContainerNameMap::iterator aIt = mHashMap.find( Name ); + NameContainerNameMap::iterator aIt = mHashMap.find( aName ); if( aIt == mHashMap.end() ) { throw NoSuchElementException(); @@ -259,26 +259,29 @@ void NameContainer::removeByName( const OUString& Name ) mValues.realloc( iLast ); mnElementCount--; - // Fire event - ContainerEvent aEvent; - aEvent.Source = mpxEventSource; - aEvent.Accessor <<= Name; - aEvent.Element = aOldElement; + if( maContainerListeners.getLength() > 0 ) + { + ContainerEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Accessor <<= aName; + aEvent.Element = aOldElement; + maContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent ); + } - OInterfaceIteratorHelper aIterator( maListenerContainer ); - while( aIterator.hasMoreElements() ) + /* After the container event has been fired (one listener will update the + core Basic manager), fire change event. Listeners can rely that the + Basic source code of the core Basic manager is up-to-date. */ + if( maChangesListeners.getLength() > 0 ) { - Reference< XInterface > xIface = aIterator.next(); - Reference< XContainerListener > xListener( xIface, UNO_QUERY ); - try - { - xListener->elementRemoved( aEvent ); - } - catch(RuntimeException&) - { - aIterator.remove(); - } + ChangesEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Base <<= aEvent.Source; + aEvent.Changes.realloc( 1 ); + aEvent.Changes[ 0 ].Accessor <<= aName; + // aEvent.Changes[ 0 ].Element remains empty (meaning "replaced with nothing") + aEvent.Changes[ 0 ].ReplacedElement = aOldElement; + maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent ); } } @@ -290,7 +293,7 @@ void SAL_CALL NameContainer::addContainerListener( const Reference< XContainerLi if( !xListener.is() ) throw RuntimeException(); Reference< XInterface > xIface( xListener, UNO_QUERY ); - maListenerContainer.addInterface( xIface ); + maContainerListeners.addInterface( xIface ); } void SAL_CALL NameContainer::removeContainerListener( const Reference< XContainerListener >& xListener ) @@ -299,7 +302,26 @@ void SAL_CALL NameContainer::removeContainerListener( const Reference< XContaine if( !xListener.is() ) throw RuntimeException(); Reference< XInterface > xIface( xListener, UNO_QUERY ); - maListenerContainer.removeInterface( xIface ); + maContainerListeners.removeInterface( xIface ); +} + +// Methods XChangesNotifier +void SAL_CALL NameContainer::addChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + if( !xListener.is() ) + throw RuntimeException(); + Reference< XInterface > xIface( xListener, UNO_QUERY ); + maChangesListeners.addInterface( xIface ); +} + +void SAL_CALL NameContainer::removeChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + if( !xListener.is() ) + throw RuntimeException(); + Reference< XInterface > xIface( xListener, UNO_QUERY ); + maChangesListeners.removeInterface( xIface ); } //============================================================================ @@ -320,12 +342,28 @@ void ModifiableHelper::setModified( sal_Bool _bModified ) //============================================================================ +VBAScriptListenerContainer::VBAScriptListenerContainer( ::osl::Mutex& rMutex ) : + VBAScriptListenerContainer_BASE( rMutex ) +{ +} + +bool VBAScriptListenerContainer::implTypedNotify( const Reference< vba::XVBAScriptListener >& rxListener, const vba::VBAScriptEvent& rEvent ) throw (Exception) +{ + rxListener->notifyVBAScriptEvent( rEvent ); + return true; // notify all other listeners too +} + +//============================================================================ + // Implementation class SfxLibraryContainer DBG_NAME( SfxLibraryContainer ) // Ctor SfxLibraryContainer::SfxLibraryContainer( void ) - : LibraryContainerHelper( maMutex ) + : SfxLibraryContainer_BASE( maMutex ) + + , maVBAScriptListeners( maMutex ) + , mnRunningVBAScripts( 0 ) , mbVBACompat( sal_False ) , maModifiable( *this, maMutex ) , maNameContainer( getCppuType( (Reference< XNameAccess >*) NULL ) ) @@ -2649,6 +2687,9 @@ void SfxLibraryContainer::_disposing( const EventObject& _rSource ) // OComponentHelper void SAL_CALL SfxLibraryContainer::disposing() { + Reference< XModel > xModel = mxOwnerDocument; + EventObject aEvent( xModel.get() ); + maVBAScriptListeners.disposing( aEvent ); stopAllComponentListening(); mxOwnerDocument = WeakReference< XModel >(); } @@ -2838,7 +2879,7 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa */ if( mbVBACompat ) try { - Reference< frame::XModel > xModel( mxOwnerDocument ); // weak-ref -> ref + Reference< XModel > xModel( mxOwnerDocument ); // weak-ref -> ref Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW ); xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); } @@ -2848,6 +2889,43 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa } } +sal_Int32 SAL_CALL SfxLibraryContainer::getRunningVBAScripts() throw (RuntimeException) +{ + LibraryContainerMethodGuard aGuard( *this ); + return mnRunningVBAScripts; +} + +void SAL_CALL SfxLibraryContainer::addVBAScriptListener( const Reference< vba::XVBAScriptListener >& rxListener ) throw (RuntimeException) +{ + maVBAScriptListeners.addTypedListener( rxListener ); +} + +void SAL_CALL SfxLibraryContainer::removeVBAScriptListener( const Reference< vba::XVBAScriptListener >& rxListener ) throw (RuntimeException) +{ + maVBAScriptListeners.removeTypedListener( rxListener ); +} + +void SAL_CALL SfxLibraryContainer::broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName ) throw (RuntimeException) +{ + // own lock for accessing the number of running scripts + enterMethod(); + switch( nIdentifier ) + { + case vba::VBAScriptEventId::SCRIPT_STARTED: + ++mnRunningVBAScripts; + break; + case vba::VBAScriptEventId::SCRIPT_STOPPED: + --mnRunningVBAScripts; + break; + } + leaveMethod(); + + Reference< XModel > xModel = mxOwnerDocument; // weak-ref -> ref + Reference< XInterface > xSender( xModel, UNO_QUERY_THROW ); + vba::VBAScriptEvent aEvent( xSender, nIdentifier, rModuleName ); + maVBAScriptListeners.notify( aEvent ); +} + // Methods XServiceInfo ::sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) @@ -2941,7 +3019,9 @@ Any SAL_CALL SfxLibrary::queryInterface( const Type& rType ) aRet = Any( ::cppu::queryInterface( rType, static_cast< XContainer * >( this ), static_cast< XNameContainer * >( this ), - static_cast< XNameAccess * >( this ) ) ); + static_cast< XNameAccess * >( this ), + static_cast< XElementAccess * >( this ), + static_cast< XChangesNotifier * >( this ) ) ); //} if( !aRet.hasValue() ) aRet = OComponentHelper::queryInterface( rType ); @@ -3083,6 +3163,7 @@ Sequence< Type > SfxLibrary::getTypes() static OTypeCollection s_aTypes_NameContainer( ::getCppuType( (const Reference< XNameContainer > *)0 ), ::getCppuType( (const Reference< XContainer > *)0 ), + ::getCppuType( (const Reference< XChangesNotifier > *)0 ), OComponentHelper::getTypes() ); s_pTypes_NameContainer = &s_aTypes_NameContainer; } @@ -3110,9 +3191,6 @@ Sequence< sal_Int8 > SfxLibrary::getImplementationId() } } - -//============================================================================ - // Methods XContainer void SAL_CALL SfxLibrary::addContainerListener( const Reference< XContainerListener >& xListener ) throw (RuntimeException) @@ -3127,6 +3205,19 @@ void SAL_CALL SfxLibrary::removeContainerListener( const Reference< XContainerLi maNameContainer.removeContainerListener( xListener ); } +// Methods XChangesNotifier +void SAL_CALL SfxLibrary::addChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + maNameContainer.setEventSource( static_cast< XInterface* >( (OWeakObject*)this ) ); + maNameContainer.addChangesListener( xListener ); +} + +void SAL_CALL SfxLibrary::removeChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + maNameContainer.removeChangesListener( xListener ); +} //============================================================================ // Implementation class ScriptExtensionIterator diff --git a/basic/util/makefile.mk b/basic/util/makefile.mk index 31a4dcca8f8b..ae4456cbc923 100644 --- a/basic/util/makefile.mk +++ b/basic/util/makefile.mk @@ -66,6 +66,9 @@ SHL1STDLIBS= \ $(VOSLIB) \ $(XMLSCRIPTLIB) +# Uncomment the following line if DBG_TRACE_PROFILING is active in source/inc/sbtrace.hxx +# SHL1STDLIBS+=$(CANVASTOOLSLIB) + .IF "$(SOLAR_JAVA)" != "TRUE" SHL1STDLIBS+=$(SJLIB) .ENDIF diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 033a87cfaea2..02d838ca25c2 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1732,8 +1732,17 @@ void Desktop::Main() bool bAbort = CheckExtensionDependencies(); if ( bAbort ) return; + + { + ::comphelper::ComponentContext aContext( xSMgr ); + xRestartManager.set( aContext.getSingleton( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.OfficeRestartManager" ) ) ), UNO_QUERY ); + } + + // check whether the shutdown is caused by restart + pExecGlobals->bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); + // First Start Wizard allowed ? - if ( ! pCmdLineArgs->IsNoFirstStartWizard()) + if ( ! pCmdLineArgs->IsNoFirstStartWizard() && !pExecGlobals->bRestartRequested ) { RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ FirstStartWizard" ); diff --git a/desktop/source/deployment/dp_services.cxx b/desktop/source/deployment/dp_services.cxx index f3dc75ae39c5..c302d1d1cc42 100644 --- a/desktop/source/deployment/dp_services.cxx +++ b/desktop/source/deployment/dp_services.cxx @@ -84,8 +84,6 @@ bool singleton_entries( uno::Reference<registry::XRegistryKey> const& ); extern "C" { -struct uno_Environment; - void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ) { diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 87aae8cb768f..5b23c6fcfbc0 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -103,6 +103,7 @@ #define PRIMITIVE2D_ID_EPSPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 60) #define PRIMITIVE2D_ID_DISCRETESHADOWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 61) #define PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 62) +#define PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 63) ////////////////////////////////////////////////////////////////////////////// diff --git a/drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx new file mode 100644 index 000000000000..190439442917 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_RENDERGRAPHICPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_RENDERGRAPHICPRIMITIVE2D_HXX + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/rendergraphic.hxx> +#include <memory> + +////////////////////////////////////////////////////////////////////////////// +// RenderGraphicPrimitive2D class + +namespace vcl { class RenderGraphicRasterizer; } + +namespace drawinglayer +{ + namespace primitive2d + { + /** RenderGraphicPrimitive2D class + + This class is the central primitive for RenderGraphic-based primitives. + */ + class RenderGraphicPrimitive2D : public BasePrimitive2D + { + private: + /// the RenderGraphic data + vcl::RenderGraphic maRenderGraphic; + mutable std::auto_ptr< vcl::RenderGraphicRasterizer > mapCurrentRasterizer; + + /** the object transformation from unit coordinates, defining + size, shear, rotate and position + */ + basegfx::B2DHomMatrix maTransform; + + public: + /// constructor + RenderGraphicPrimitive2D( + const vcl::RenderGraphic& rRenderGraphic, + const basegfx::B2DHomMatrix& rTransform); + + /// data read access + inline const vcl::RenderGraphic& getRenderGraphic() const { return maRenderGraphic; } + inline const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + + // access to latest used vcl::GraphicRasterizer for possibly reusing + // an already rendered vcl::RenderGraphic with the same transform + // properties during the next rendering process + void setCurrentRasterizer() const; + void setCurrentRasterizer( const vcl::RenderGraphicRasterizer& rCurrentGraphicRasterizer ) const; + inline const vcl::RenderGraphicRasterizer* getCurrentRasterizer() const { return( mapCurrentRasterizer.get() ); } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_RENDERGRAPHICPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx b/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx index 72ff97076a6c..d218b7737c2b 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx @@ -56,6 +56,7 @@ namespace drawinglayer { namespace primitive2d { class MetafilePrimitive2D; class TextSimplePortionPrimitive2D; class BitmapPrimitive2D; + class RenderGraphicPrimitive2D; class TransparencePrimitive2D; class PolygonStrokePrimitive2D; class FillBitmapPrimitive2D; @@ -108,6 +109,7 @@ namespace drawinglayer void impRenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate); void impRenderTextSimplePortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); void impRenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); + void impRenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate); void impRenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransparenceCandidate); void impRenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive); void impRenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapPrimitive2D); diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx index 9db84f3e7e0c..9e9a827d2518 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -41,6 +41,7 @@ namespace drawinglayer { namespace primitive2d { class TextSimplePortionPrimitive2D; class PolygonHairlinePrimitive2D; class BitmapPrimitive2D; + class RenderGraphicPrimitive2D; class FillBitmapPrimitive2D; class PolyPolygonGradientPrimitive2D; class PolyPolygonBitmapPrimitive2D; @@ -97,6 +98,7 @@ namespace drawinglayer void RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); void RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased); void RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); + void RenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate); void RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate); void RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate); void RenderPolyPolygonBitmapPrimitive2D(const primitive2d::PolyPolygonBitmapPrimitive2D& rPolygonCandidate); diff --git a/drawinglayer/prj/d.lst b/drawinglayer/prj/d.lst index 54f087d317e4..10e692785a81 100644 --- a/drawinglayer/prj/d.lst +++ b/drawinglayer/prj/d.lst @@ -13,6 +13,7 @@ mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive2d ..\inc\drawinglayer\primitive2d\backgroundcolorprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\backgroundcolorprimitive2d.hxx ..\inc\drawinglayer\primitive2d\baseprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\baseprimitive2d.hxx ..\inc\drawinglayer\primitive2d\bitmapprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\bitmapprimitive2d.hxx +..\inc\drawinglayer\primitive2d\rendergraphicprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\rendergraphicprimitive2d.hxx ..\inc\drawinglayer\primitive2d\borderlineprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\borderlineprimitive2d.hxx ..\inc\drawinglayer\primitive2d\chartprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\chartprimitive2d.hxx ..\inc\drawinglayer\primitive2d\controlprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\controlprimitive2d.hxx diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx index 1e26881c9757..3b52f2340f17 100644 --- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx @@ -31,6 +31,7 @@ #include <drawinglayer/primitive2d/graphicprimitive2d.hxx> #include <drawinglayer/animation/animationtiming.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <drawinglayer/primitive2d/animatedprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> @@ -46,6 +47,7 @@ #include <vcl/graph.hxx> #include <vcl/virdev.hxx> #include <vcl/svapp.hxx> +#include <vcl/metaact.hxx> ////////////////////////////////////////////////////////////////////////////// // includes for testing MetafilePrimitive2D::create2DDecomposition @@ -260,7 +262,9 @@ namespace drawinglayer aSuppressGraphicAttr.SetCrop(0, 0, 0, 0); aSuppressGraphicAttr.SetRotation(0); aSuppressGraphicAttr.SetMirrorFlags(0); - const Graphic aTransformedGraphic(getGraphicObject().GetTransformedGraphic(&aSuppressGraphicAttr)); + + const GraphicObject& rGraphicObject = getGraphicObject(); + const Graphic aTransformedGraphic(rGraphicObject.GetTransformedGraphic(&aSuppressGraphicAttr)); switch(aTransformedGraphic.GetType()) { @@ -743,34 +747,43 @@ namespace drawinglayer { #endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE // create MetafilePrimitive2D - const Graphic aGraphic(getGraphicObject().GetGraphic()); const GDIMetaFile& rMetafile = aTransformedGraphic.GetGDIMetaFile(); - xPrimitive = Primitive2DReference( - new MetafilePrimitive2D( - aTransform, - rMetafile)); - - // #i100357# find out if clipping is needed for this primitive. Unfortunately, - // there exist Metafiles who's content is bigger than the proposed PrefSize set - // at them. This is an error, but we need to work around this - const Size aMetaFilePrefSize(rMetafile.GetPrefSize()); - const Size aMetaFileRealSize( - const_cast< GDIMetaFile& >(rMetafile).GetBoundRect( - *Application::GetDefaultDevice()).GetSize()); - - if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth() - || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight()) + if( aTransformedGraphic.IsRenderGraphic() ) { - // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon - const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1); - basegfx::B2DPolygon aMaskPolygon(basegfx::tools::createUnitPolygon()); - aMaskPolygon.transform(aTransform); - xPrimitive = Primitive2DReference( - new MaskPrimitive2D( - basegfx::B2DPolyPolygon(aMaskPolygon), - aChildContent)); + new RenderGraphicPrimitive2D( + static_cast< MetaRenderGraphicAction* >(rMetafile.GetAction(0))->GetRenderGraphic(), + aTransform)); + } + else + { + xPrimitive = Primitive2DReference( + new MetafilePrimitive2D( + aTransform, + rMetafile)); + + // #i100357# find out if clipping is needed for this primitive. Unfortunately, + // there exist Metafiles who's content is bigger than the proposed PrefSize set + // at them. This is an error, but we need to work around this + const Size aMetaFilePrefSize(rMetafile.GetPrefSize()); + const Size aMetaFileRealSize( + const_cast< GDIMetaFile& >(rMetafile).GetBoundRect( + *Application::GetDefaultDevice()).GetSize()); + + if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth() + || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight()) + { + // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon + const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1); + basegfx::B2DPolygon aMaskPolygon(basegfx::tools::createUnitPolygon()); + aMaskPolygon.transform(aTransform); + + xPrimitive = Primitive2DReference( + new MaskPrimitive2D( + basegfx::B2DPolyPolygon(aMaskPolygon), + aChildContent)); + } } #ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE } @@ -808,16 +821,16 @@ namespace drawinglayer { const MapMode aMapMode100thmm(MAP_100TH_MM); - Size aBitmapSize(getGraphicObject().GetPrefSize()); + Size aBitmapSize(rGraphicObject.GetPrefSize()); // #i95968# better support PrefMapMode; special for MAP_PIXEL was missing - if(MAP_PIXEL == getGraphicObject().GetPrefMapMode().GetMapUnit()) + if(MAP_PIXEL == rGraphicObject.GetPrefMapMode().GetMapUnit()) { aBitmapSize = Application::GetDefaultDevice()->PixelToLogic(aBitmapSize, aMapMode100thmm); } else { - aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize, getGraphicObject().GetPrefMapMode(), aMapMode100thmm); + aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize, rGraphicObject.GetPrefMapMode(), aMapMode100thmm); } const double fDivX(aBitmapSize.Width() - getGraphicAttr().GetLeftCrop() - getGraphicAttr().GetRightCrop()); diff --git a/drawinglayer/source/primitive2d/makefile.mk b/drawinglayer/source/primitive2d/makefile.mk index 720769a0efd5..77e59dca2469 100644 --- a/drawinglayer/source/primitive2d/makefile.mk +++ b/drawinglayer/source/primitive2d/makefile.mk @@ -42,6 +42,7 @@ SLOFILES= \ $(SLO)$/baseprimitive2d.obj \ $(SLO)$/backgroundcolorprimitive2d.obj \ $(SLO)$/bitmapprimitive2d.obj \ + $(SLO)$/rendergraphicprimitive2d.obj \ $(SLO)$/borderlineprimitive2d.obj \ $(SLO)$/chartprimitive2d.obj \ $(SLO)$/controlprimitive2d.obj \ diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index 893c572a3086..9988eb884679 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -63,6 +63,7 @@ #include <drawinglayer/primitive2d/textlineprimitive2d.hxx> #include <drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx> #include <drawinglayer/primitive2d/epsprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <numeric> ////////////////////////////////////////////////////////////////////////////// @@ -3068,6 +3069,33 @@ namespace break; } + case META_RENDERGRAPHIC_ACTION : + { + const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*)pAction; + const Rectangle aRectangle(pA->GetPoint(), pA->GetSize()); + + if(!aRectangle.IsEmpty()) + { + // create object transform + basegfx::B2DHomMatrix aObjectTransform; + + aObjectTransform.set(0, 0, aRectangle.GetWidth()); + aObjectTransform.set(1, 1, aRectangle.GetHeight()); + aObjectTransform.set(0, 2, aRectangle.Left()); + aObjectTransform.set(1, 2, aRectangle.Top()); + + // add current transformation + aObjectTransform = rPropertyHolders.Current().getTransformation() * aObjectTransform; + + // embed using EpsPrimitive + rTargetHolders.Current().append( + new drawinglayer::primitive2d::RenderGraphicPrimitive2D( + pA->GetRenderGraphic(), + aObjectTransform ) ); + } + + break; + } case META_COMMENT_ACTION : { /** CHECKED, WORKS WELL */ diff --git a/drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx b/drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx new file mode 100644 index 000000000000..439937f5d0f5 --- /dev/null +++ b/drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <basegfx/tools/canvastools.hxx> +#include <vcl/rendergraphicrasterizer.hxx> + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + RenderGraphicPrimitive2D::RenderGraphicPrimitive2D( + const vcl::RenderGraphic& rRenderGraphic, + const basegfx::B2DHomMatrix& rTransform) + : BasePrimitive2D(), + maRenderGraphic(rRenderGraphic), + maTransform(rTransform) + { + } + + void RenderGraphicPrimitive2D::setCurrentRasterizer() const + { + mapCurrentRasterizer.reset(); + } + + void RenderGraphicPrimitive2D::setCurrentRasterizer( const vcl::RenderGraphicRasterizer& rCurrentRasterizer ) const + { + mapCurrentRasterizer.reset( new vcl::RenderGraphicRasterizer( rCurrentRasterizer ) ); + } + + bool RenderGraphicPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const RenderGraphicPrimitive2D& rCompare = (RenderGraphicPrimitive2D&)rPrimitive; + + return (getRenderGraphic() == rCompare.getRenderGraphic() + && getTransform() == rCompare.getTransform()); + } + + return false; + } + + basegfx::B2DRange RenderGraphicPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0); + aRetval.transform(maTransform); + return aRetval; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(RenderGraphicPrimitive2D, PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx index aaafa42ec44e..74166d4fba33 100644 --- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx +++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx @@ -528,6 +528,8 @@ namespace drawinglayer case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D : case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D : case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D : + case PRIMITIVE2D_ID_MEDIAPRIMITIVE2D: + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D: { if(!getHitTextOnly()) { diff --git a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx index be3601dd0024..6eac340a7aab 100644 --- a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx +++ b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx @@ -123,6 +123,7 @@ namespace drawinglayer case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : case PRIMITIVE2D_ID_MASKPRIMITIVE2D : { diff --git a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx index b9ad83373923..73b5189979ff 100644 --- a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx +++ b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx @@ -214,6 +214,7 @@ namespace drawinglayer case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : case PRIMITIVE2D_ID_MASKPRIMITIVE2D : { diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index c8899514d5a3..ed2b6e2e8244 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -38,6 +38,7 @@ #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <drawinglayer/primitive2d/maskprimitive2d.hxx> #include <basegfx/polygon/b2dpolygonclipper.hxx> @@ -1287,6 +1288,12 @@ namespace drawinglayer RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); break; } + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : + { + // direct draw of transformed RenderGraphic primitive; use default processing + RenderRenderGraphicPrimitive2D(static_cast< const primitive2d::RenderGraphicPrimitive2D& >(rCandidate)); + break; + } case PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D : { // need to handle PolyPolygonBitmapPrimitive2D here to support XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 6a280fcad95e..3ed8d135ffbd 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -35,6 +35,7 @@ #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <drawinglayer/primitive2d/maskprimitive2d.hxx> @@ -193,6 +194,12 @@ namespace drawinglayer RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); break; } + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : + { + // direct draw of transformed BitmapEx primitive + RenderRenderGraphicPrimitive2D(static_cast< const primitive2d::RenderGraphicPrimitive2D& >(rCandidate)); + break; + } case PRIMITIVE2D_ID_FILLBITMAPPRIMITIVE2D : { // direct draw of fillBitmapPrimitive @@ -401,7 +408,9 @@ namespace drawinglayer } catch(const uno::Exception&) { - DBG_UNHANDLED_EXCEPTION(); + // #i116763# removing since there is a good alternative when the xControlView + // is not found and it is allowed to happen + // DBG_UNHANDLED_EXCEPTION(); // process recursively and use the decomposition as Bitmap process(rCandidate.get2DDecomposition(getViewInformation2D())); diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index e49e54fb751c..bcfa4b6776a3 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -35,6 +35,7 @@ #include <vcl/outdev.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <vclhelperbitmaptransform.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <vclhelperbitmaprender.hxx> @@ -60,6 +61,7 @@ #include <vcl/metric.hxx> #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> #include <drawinglayer/primitive2d/epsprimitive2d.hxx> +#include <vcl/rendergraphicrasterizer.hxx> ////////////////////////////////////////////////////////////////////////////// // control support @@ -421,6 +423,75 @@ namespace drawinglayer } } + void VclProcessor2D::RenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate) + { + // create local transform + basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rRenderGraphicCandidate.getTransform()); + vcl::RenderGraphic aRenderGraphic(rRenderGraphicCandidate.getRenderGraphic()); + bool bPainted(false); + + if(maBColorModifierStack.count()) + { + // !!! TODO + // aRenderGraphic = impModifyRenderGraphic(maBColorModifierStack, aRenderGraphic); + + if(aRenderGraphic.IsEmpty()) + { + // color gets completely replaced, get it + const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor())); + basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon()); + aPolygon.transform(aLocalTransform); + + mpOutputDevice->SetFillColor(Color(aModifiedColor)); + mpOutputDevice->SetLineColor(); + mpOutputDevice->DrawPolygon(aPolygon); + + bPainted = true; + } + } + + if(!bPainted) + { + // decompose matrix to check for shear, rotate and mirroring + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); + + basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0); + + if( basegfx::fTools::equalZero( fRotate ) ) + { + aOutlineRange.transform( aLocalTransform ); + } + else + { + // !!! TODO + // if rotated, create the unrotated output rectangle for the GraphicManager paint + /* + const basegfx::B2DHomMatrix aSimpleObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix( + fabs(aScale.getX()), fabs(aScale.getY()), + aTranslate.getX(), aTranslate.getY())); + + aOutlineRange.transform(aSimpleObjectMatrix); + */ + } + + // prepare dest coordinates + const Point aPoint( basegfx::fround(aOutlineRange.getMinX() ), + basegfx::fround(aOutlineRange.getMinY() ) ); + const Size aSize( basegfx::fround(aOutlineRange.getWidth() ), + basegfx::fround(aOutlineRange.getHeight() ) ); + const Size aSizePixel( mpOutputDevice->LogicToPixel( aSize ) ); + const vcl::RenderGraphicRasterizer aRasterizer( aRenderGraphic ); + const BitmapEx aBitmapEx( aRasterizer.Rasterize( aSizePixel, fRotate, fShearX ) ); + + if( !aBitmapEx.IsEmpty() ) + { + mpOutputDevice->DrawBitmapEx( aPoint, aSize, aBitmapEx ); + } + } + } + void VclProcessor2D::RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate) { const attribute::FillBitmapAttribute& rFillBitmapAttribute(rFillBitmapCandidate.getFillBitmap()); diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 352fb8ace115..b9e00cf89008 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -2948,6 +2948,27 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta // Ueber die Portions der Zeile... // -------------------------------------------------- nIndex = pLine->GetStart(); + + // #i108052# When stripping a callback for empty paragraphs is needed. This + // was somehow lost/removed/killed by making the TextPortions with empty + // paragraph to type PORTIONKIND_TAB instead of PORTIONKIND_TEXT. Adding here + // since I could not find out who and why this has changed. + if(bStripOnly && pLine->GetStartPortion() == pLine->GetEndPortion()) + { + const Color aOverlineColor(pOutDev->GetOverlineColor()); + const Color aTextLineColor(pOutDev->GetTextLineColor()); + + GetEditEnginePtr()->DrawingText( + aTmpPos, String(), 0, 0, 0, + aTmpFont, n, nIndex, 0, + 0, + 0, + false, true, false, // support for EOL/EOP TEXT comments + 0, + aOverlineColor, + aTextLineColor); + } + for ( sal_uInt16 y = pLine->GetStartPortion(); y <= pLine->GetEndPortion(); y++ ) { DBG_ASSERT( pPortion->GetTextPortions().Count(), "Zeile ohne Textportion im Paint!" ); diff --git a/formula/inc/formula/token.hxx b/formula/inc/formula/token.hxx index 30618c67381a..8a94b1005bc8 100644 --- a/formula/inc/formula/token.hxx +++ b/formula/inc/formula/token.hxx @@ -70,6 +70,7 @@ enum StackVarEnum svExternalSingleRef, svExternalDoubleRef, svExternalName, + svSubroutine, // A token with a subroutine token array. svError, // error token svMissing = 0x70, // 0 or "" svSep, // separator, ocSep, ocOpen, ocClose @@ -89,6 +90,7 @@ class FormulaToken; typedef SimpleIntrusiveReference< class FormulaToken > FormulaTokenRef; typedef SimpleIntrusiveReference< const class FormulaToken > FormulaConstTokenRef; +class FormulaTokenArray; class FORMULA_DLLPUBLIC FormulaToken : public IFormulaToken { @@ -364,6 +366,23 @@ public: }; +class FORMULA_DLLPUBLIC FormulaSubroutineToken : public FormulaToken +{ +public: + /** Takes ownership of pArray and deletes it upon destruction! */ + FormulaSubroutineToken( const FormulaTokenArray* pArray ) : + FormulaToken( svSubroutine, ocCall ), mpArray( pArray) {} + FormulaSubroutineToken( const FormulaSubroutineToken& r ); + virtual ~FormulaSubroutineToken(); + virtual FormulaToken* Clone() const { return new FormulaSubroutineToken(*this); } + virtual sal_Bool operator==( const FormulaToken& rToken ) const; + const FormulaTokenArray* GetTokenArray() const; + +private: + const FormulaTokenArray* mpArray; +}; + + class FORMULA_DLLPUBLIC FormulaUnknownToken : public FormulaToken { public: diff --git a/formula/inc/formula/tokenarray.hxx b/formula/inc/formula/tokenarray.hxx index 31d780c81a79..bcd4061f5ac6 100644 --- a/formula/inc/formula/tokenarray.hxx +++ b/formula/inc/formula/tokenarray.hxx @@ -256,6 +256,7 @@ public: void Reset(); const FormulaToken* First(); const FormulaToken* Next(); + const FormulaToken* PeekNextOperator(); bool IsEndOfPath() const; /// if a jump or subroutine path is done bool HasStacked() const { return pCur->pNext != 0; } short GetPC() const { return pCur->nPC; } @@ -276,6 +277,9 @@ public: void Jump( short nStart, short nNext, short nStop = SHRT_MAX ); void Push( const FormulaTokenArray* ); void Pop(); + +private: + const FormulaToken* GetNonEndOfPathToken( short nIdx ) const; }; // ============================================================================= } // formula diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 3942712da6a4..b644d1cd8fb3 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -1265,15 +1265,7 @@ const FormulaToken* FormulaTokenIterator::First() const FormulaToken* FormulaTokenIterator::Next() { - const FormulaToken* t = NULL; - ++pCur->nPC; - if( pCur->nPC < pCur->pArr->nRPN && pCur->nPC < pCur->nStop ) - { - t = pCur->pArr->pRPN[ pCur->nPC ]; - // such an OpCode ends an IF() or CHOOSE() path - if( t->GetOpCode() == ocSep || t->GetOpCode() == ocClose ) - t = NULL; - } + const FormulaToken* t = GetNonEndOfPathToken( ++pCur->nPC ); if( !t && pCur->pNext ) { Pop(); @@ -1282,6 +1274,25 @@ const FormulaToken* FormulaTokenIterator::Next() return t; } +const FormulaToken* FormulaTokenIterator::PeekNextOperator() +{ + const FormulaToken* t = NULL; + short nIdx = pCur->nPC; + while (!t && ((t = GetNonEndOfPathToken( ++nIdx)) != NULL)) + { + if (t->GetOpCode() == ocPush) + t = NULL; // ignore operands + } + if (!t && pCur->pNext) + { + ImpTokenIterator* pHere = pCur; + pCur = pCur->pNext; + t = PeekNextOperator(); + pCur = pHere; + } + return t; +} + //! The nPC counts after a Push() are -1 void FormulaTokenIterator::Jump( short nStart, short nNext, short nStop ) @@ -1295,17 +1306,22 @@ void FormulaTokenIterator::Jump( short nStart, short nNext, short nStop ) } } -bool FormulaTokenIterator::IsEndOfPath() const +const FormulaToken* FormulaTokenIterator::GetNonEndOfPathToken( short nIdx ) const { - sal_uInt16 nTest = pCur->nPC + 1; - if( nTest < pCur->pArr->nRPN && nTest < pCur->nStop ) + if (nIdx < pCur->pArr->nRPN && nIdx < pCur->nStop) { - const FormulaToken* t = pCur->pArr->pRPN[ nTest ]; + const FormulaToken* t = pCur->pArr->pRPN[ nIdx ]; // such an OpCode ends an IF() or CHOOSE() path - return t->GetOpCode() == ocSep || t->GetOpCode() == ocClose; + return (t->GetOpCode() == ocSep || t->GetOpCode() == ocClose) ? NULL : t; } - return true; + return NULL; } + +bool FormulaTokenIterator::IsEndOfPath() const +{ + return GetNonEndOfPathToken( pCur->nPC + 1) != NULL; +} + // ----------------------------------------------------------------------------- // ========================================================================== // real implementations of virtual functions @@ -1367,6 +1383,27 @@ sal_Bool FormulaMissingToken::operator==( const FormulaToken& r ) const } +FormulaSubroutineToken::FormulaSubroutineToken( const FormulaSubroutineToken& r ) : + FormulaToken( r ), + mpArray( r.mpArray->Clone()) +{ +} +FormulaSubroutineToken::~FormulaSubroutineToken() +{ + delete mpArray; +} +const FormulaTokenArray* FormulaSubroutineToken::GetTokenArray() const +{ + return mpArray; +} +sal_Bool FormulaSubroutineToken::operator==( const FormulaToken& r ) const +{ + // Arrays don't equal.. + return FormulaToken::operator==( r ) && + (mpArray == static_cast<const FormulaSubroutineToken&>(r).mpArray); +} + + sal_Bool FormulaUnknownToken::operator==( const FormulaToken& r ) const { return FormulaToken::operator==( r ); diff --git a/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx b/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx index 8f4e0d040f3e..d47c21c40cb2 100644 --- a/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx +++ b/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx @@ -66,6 +66,8 @@ class IVistaFilePickerInternalNotify public: virtual void onAutoExtensionChanged (bool bChecked) = 0; + + virtual bool onFileTypeChanged( UINT nTypeIndex ) = 0; }; }}} diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx index 14b185ee2688..f150120e132f 100644 --- a/fpicker/source/win32/filepicker/VistaFilePicker.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePicker.cxx @@ -224,7 +224,7 @@ void SAL_CALL VistaFilePicker::setTitle(const ::rtl::OUString& sTitle) //----------------------------------------------------------------------------------------- void SAL_CALL VistaFilePicker::appendFilter(const ::rtl::OUString& sTitle , - const ::rtl::OUString& sFilter) + const ::rtl::OUString& sFilter) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException ) { @@ -263,17 +263,15 @@ void SAL_CALL VistaFilePicker::setCurrentFilter(const ::rtl::OUString& sTitle) //----------------------------------------------------------------------------------------- void SAL_CALL VistaFilePicker::appendFilterGroup(const ::rtl::OUString& /*sGroupTitle*/, - const css::uno::Sequence< css::beans::StringPair >& lFilters ) + const css::uno::Sequence< css::beans::StringPair >& rFilters ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException ) { - ::sal_Int32 c = lFilters.getLength(); - ::sal_Int32 i = 0; - for (i=0; i<c; ++i) - { - const css::beans::StringPair& rFilter = lFilters[i]; - appendFilter(rFilter.First, rFilter.Second); - } + RequestRef rRequest(new Request()); + rRequest->setRequest (VistaFilePickerImpl::E_APPEND_FILTERGROUP); + rRequest->setArgument(PROP_FILTER_GROUP, rFilters); + + m_aAsyncExecute.triggerRequestThreadAware(rRequest, AsyncRequests::NON_BLOCKED); } //----------------------------------------------------------------------------------------- diff --git a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx index 2fadaa6bfdff..f399c55de694 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx @@ -269,33 +269,16 @@ STDMETHODIMP VistaFilePickerEventHandler::OnShareViolation(IFileDialog* } //----------------------------------------------------------------------------------------- -STDMETHODIMP VistaFilePickerEventHandler::OnTypeChange(IFileDialog* /*pDialog*/) +STDMETHODIMP VistaFilePickerEventHandler::OnTypeChange(IFileDialog* pDialog) { - /* - IFileDialogCustomize *iCustomize; - pDialog->QueryInterface(IID_IFileDialogCustomize, (void**)(&iCustomize)); + UINT nFileTypeIndex; + HRESULT hResult = pDialog->GetFileTypeIndex( &nFileTypeIndex ); - BOOL bValue = FALSE; - HRESULT hResult = iCustomize->GetCheckButtonState( css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, &bValue); - - if ( bValue ) + if ( hResult == S_OK ) { - UINT nIndex; - - pDialog->GetFileTypeIndex( &nIndex ); - - LPCWSTR lpFilterExt = lFilters[nIndex].pszSpec; - - lpFilterExt = wcschr( lpFilterExt, '.' ); - if ( lpFilterExt ) - lpFilterExt++; - pDialog->SetDefaultExtension( lpFilterExt ); + if ( m_pInternalNotify->onFileTypeChanged( nFileTypeIndex )) + impl_sendEvent(E_CONTROL_STATE_CHANGED, css::ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER); } - return S_OK; - - */ - - impl_sendEvent(E_CONTROL_STATE_CHANGED, css::ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER); return S_OK; } @@ -334,32 +317,9 @@ STDMETHODIMP VistaFilePickerEventHandler::OnCheckButtonToggled(IFileDialogCustom DWORD nIDCtl , BOOL bChecked ) { - /* - if (nIDCtl == css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION) - { - LPCWSTR lpFilterExt = 0; - if ( bChecked ) - { - UINT nIndex; - if (m_pDialog) - { - m_pDialog->GetFileTypeIndex( &nIndex ); - lpFilterExt = lFilters[nIndex].pszSpec; - lpFilterExt = wcschr( lpFilterExt, '.' ); - if ( lpFilterExt ) - lpFilterExt++; - } - } - - if (m_pDialog) - m_pDialog->SetDefaultExtension( lpFilterExt ); - } - */ - if (nIDCtl == css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION) m_pInternalNotify->onAutoExtensionChanged(bChecked); - impl_sendEvent(E_CONTROL_STATE_CHANGED, static_cast<sal_Int16>( nIDCtl)); return S_OK; diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index 677c2bdbfa7d..97afa038fcab 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ControlActions.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <com/sun/star/beans/StringPair.hpp> #include <comphelper/sequenceasvector.hxx> #include <osl/file.hxx> #include <osl/mutex.hxx> @@ -42,6 +43,8 @@ #endif #include "..\misc\WinImplHelper.hxx" +#include <Shlguid.h> + inline bool is_current_process_window(HWND hwnd) { DWORD pid; @@ -199,6 +202,10 @@ void VistaFilePickerImpl::doRequest(const RequestRef& rRequest) impl_sta_appendFilter(rRequest); break; + case E_APPEND_FILTERGROUP : + impl_sta_appendFilterGroup(rRequest); + break; + case E_SET_CURRENT_FILTER : impl_sta_setCurrentFilter(rRequest); break; @@ -331,6 +338,28 @@ void VistaFilePickerImpl::impl_sta_appendFilter(const RequestRef& rRequest) } //------------------------------------------------------------------------------- +void VistaFilePickerImpl::impl_sta_appendFilterGroup(const RequestRef& rRequest) +{ + const css::uno::Sequence< css::beans::StringPair > aFilterGroup = + rRequest->getArgumentOrDefault(PROP_FILTER_GROUP, css::uno::Sequence< css::beans::StringPair >()); + + // SYNCHRONIZED-> + ::rtl::OUString aEmpty; + ::osl::ResettableMutexGuard aLock(m_aMutex); + + if ( m_lFilters.numFilter() > 0 && aFilterGroup.getLength() > 0 ) + m_lFilters.addFilter( STRING_SEPARATOR, aEmpty, sal_True ); + + ::sal_Int32 c = aFilterGroup.getLength(); + ::sal_Int32 i = 0; + for (i=0; i<c; ++i) + { + const css::beans::StringPair& rFilter = aFilterGroup[i]; + m_lFilters.addFilter(rFilter.First, rFilter.Second); + } +} + +//------------------------------------------------------------------------------- void VistaFilePickerImpl::impl_sta_setCurrentFilter(const RequestRef& rRequest) { const ::rtl::OUString sTitle = rRequest->getArgumentOrDefault(PROP_FILTER_TITLE, ::rtl::OUString()); @@ -941,7 +970,7 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest) return; impl_sta_getSelectedFiles(rRequest); - rRequest->setArgument(PROP_DIALOG_SHOW_RESULT, (::sal_Bool)sal_True); + rRequest->setArgument(PROP_DIALOG_SHOW_RESULT, sal_True); } //------------------------------------------------------------------------------- @@ -1179,6 +1208,23 @@ void VistaFilePickerImpl::impl_SetDefaultExtension( const rtl::OUString& current } } +static void impl_refreshFileDialog( TFileDialog iDialog ) +{ + if ( SUCCEEDED(iDialog->SetFileName(L"")) && + SUCCEEDED(iDialog->SetFileName(L"*.*")) ) + { + IOleWindow* iOleWindow; + if (SUCCEEDED(iDialog->QueryInterface(IID_PPV_ARGS(&iOleWindow)))) + { + HWND hwnd; + if (SUCCEEDED(iOleWindow->GetWindow(&hwnd))) + { + PostMessage(hwnd, WM_COMMAND, IDOK, 0); + } + iOleWindow->Release(); + } + } +} //------------------------------------------------------------------------------- void VistaFilePickerImpl::onAutoExtensionChanged (bool bChecked) @@ -1207,6 +1253,11 @@ void VistaFilePickerImpl::onAutoExtensionChanged (bool bChecked) iDialog->SetDefaultExtension( pExt ); } +bool VistaFilePickerImpl::onFileTypeChanged( UINT /*nTypeIndex*/ ) +{ + return true; +} + } // namespace vista } // namespace win32 } // namespace fpicker diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx index 6be17935609b..201ed9f1764d 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx @@ -104,12 +104,14 @@ static const ::rtl::OUString PROP_TEMPLATE_DESCR = ::rtl::OUString::createF static const ::rtl::OUString PROP_FILTER_TITLE = ::rtl::OUString::createFromAscii("filter_title" ); // [OUString] static const ::rtl::OUString PROP_FILTER_VALUE = ::rtl::OUString::createFromAscii("filter_value" ); // [OUString] static const ::rtl::OUString PROP_FORCE = ::rtl::OUString::createFromAscii("force" ); // [sal_Bool] +static const ::rtl::OUString PROP_FILTER_GROUP = ::rtl::OUString::createFromAscii("filter_group" ); // [seq< css:beans::StringPair >] contains a group of filters static const ::rtl::OUString PROP_CONTROL_ID = ::rtl::OUString::createFromAscii("control_id" ); // [sal_Int16] static const ::rtl::OUString PROP_CONTROL_ACTION = ::rtl::OUString::createFromAscii("control_action" ); // [sal_Int16] static const ::rtl::OUString PROP_CONTROL_VALUE = ::rtl::OUString::createFromAscii("control_value" ); // [Any] static const ::rtl::OUString PROP_CONTROL_LABEL = ::rtl::OUString::createFromAscii("control_label" ); // [OUString] static const ::rtl::OUString PROP_CONTROL_ENABLE = ::rtl::OUString::createFromAscii("control_enable" ); // [sal_Bool] true=ON, false=OFF +static const ::rtl::OUString STRING_SEPARATOR = ::rtl::OUString::createFromAscii("------------------------------------------" ); //----------------------------------------------------------------------------- /** native implementation of the file picker on Vista and upcoming windows versions. @@ -149,7 +151,8 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex E_GET_CONTROL_VALUE, E_SET_CONTROL_LABEL, E_GET_CONTROL_LABEL, - E_ENABLE_CONTROL + E_ENABLE_CONTROL, + E_APPEND_FILTERGROUP }; public: @@ -169,7 +172,10 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex virtual void after(); //--------------------------------------------------------------------- + // IVistaFilePickerInternalNotify + //--------------------------------------------------------------------- virtual void onAutoExtensionChanged (bool bChecked); + virtual bool onFileTypeChanged( UINT nTypeIndex ); private: @@ -186,6 +192,10 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex void impl_sta_appendFilter(const RequestRef& rRequest); //--------------------------------------------------------------------- + /// implementation of request E_APPEND_FILTERGROUP + void impl_sta_appendFilterGroup(const RequestRef& rRequest); + + //--------------------------------------------------------------------- /// implementation of request E_SET_CURRENT_FILTER void impl_sta_setCurrentFilter(const RequestRef& rRequest); diff --git a/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx b/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx index 9fb13c1a2d5e..f701efe1357b 100644 --- a/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx +++ b/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx @@ -316,11 +316,24 @@ void SAL_CALL CWinFileOpenImpl::appendFilterGroup(const rtl::OUString& sGroupTit // XExtendedFilePicker //================================================================================================================= +// #i90917: Due to a different feature set for the system-dependent file pickers +// it's possible that generic code (e.g. sfx2) provides control ids +// (see ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR) which are NOT +// available on all platforms. This filter function should filter out control ids +// which are only available on KDE/GTK file pickers. +static bool filterControlCommand( sal_Int16 nControlId ) +{ + if ( nControlId == LISTBOX_FILTER_SELECTOR ) + return true; + return false; +} + void SAL_CALL CWinFileOpenImpl::setValue(sal_Int16 aControlId, sal_Int16 aControlAction, const uno::Any& aValue) throw(uno::RuntimeException) { OSL_ASSERT(m_FilePickerState); - m_FilePickerState->setValue(aControlId, aControlAction, aValue); + if ( !filterControlCommand( aControlId )) + m_FilePickerState->setValue(aControlId, aControlAction, aValue); } //----------------------------------------------------------------------------------------- @@ -332,7 +345,10 @@ uno::Any SAL_CALL CWinFileOpenImpl::getValue(sal_Int16 aControlId, sal_Int16 aCo throw(uno::RuntimeException) { OSL_ASSERT(m_FilePickerState); - return m_FilePickerState->getValue(aControlId, aControlAction); + if ( !filterControlCommand( aControlId )) + return m_FilePickerState->getValue(aControlId, aControlAction); + else + return uno::Any(); } //----------------------------------------------------------------------------------------- @@ -343,7 +359,8 @@ void SAL_CALL CWinFileOpenImpl::enableControl(sal_Int16 ControlID, sal_Bool bEna throw(uno::RuntimeException) { OSL_ASSERT(m_FilePickerState); - m_FilePickerState->enableControl(ControlID, bEnable); + if ( !filterControlCommand( ControlID )) + m_FilePickerState->enableControl(ControlID, bEnable); } //----------------------------------------------------------------------------------------- @@ -353,7 +370,9 @@ void SAL_CALL CWinFileOpenImpl::enableControl(sal_Int16 ControlID, sal_Bool bEna void SAL_CALL CWinFileOpenImpl::setLabel( sal_Int16 aControlId, const rtl::OUString& aLabel ) throw (uno::RuntimeException) { - m_FilePickerState->setLabel(aControlId, aLabel); + OSL_ASSERT(m_FilePickerState); + if ( !filterControlCommand( aControlId )) + m_FilePickerState->setLabel(aControlId, aLabel); } //----------------------------------------------------------------------------------------- @@ -363,7 +382,11 @@ void SAL_CALL CWinFileOpenImpl::setLabel( sal_Int16 aControlId, const rtl::OUStr rtl::OUString SAL_CALL CWinFileOpenImpl::getLabel( sal_Int16 aControlId ) throw (uno::RuntimeException) { - return m_FilePickerState->getLabel(aControlId); + OSL_ASSERT(m_FilePickerState); + if ( !filterControlCommand( aControlId )) + return m_FilePickerState->getLabel(aControlId); + else + return rtl::OUString(); } //----------------------------------------------------------------------------------------- diff --git a/fpicker/source/win32/filepicker/platform_vista.h b/fpicker/source/win32/filepicker/platform_vista.h index e8812909f757..553ff811ef5e 100644 --- a/fpicker/source/win32/filepicker/platform_vista.h +++ b/fpicker/source/win32/filepicker/platform_vista.h @@ -47,32 +47,6 @@ #pragma warning(pop) #endif -// ATL/WTL -//#include <atlbase.h> -//#include <atlstr.h> -//#include <atlapp.h> -//extern CAppModule _Module; -//#include <atlcom.h> -//#include <atlwin.h> -//#include <atlframe.h> -//#include <atlcrack.h> -//#include <atlctrls.h> -//#include <atlctrlx.h> -//#include <atldlgs.h> -//#include <atlmisc.h> - -/* -// STL -#include <vector> - -// Global functions -LPCTSTR PrepFilterString ( CString& sFilters ); -bool PathFromShellItem ( IShellItem* pItem, CString& sPath ); -bool BuildFilterSpecList ( _U_STRINGorID szFilterList, - std::vector<CString>& vecsFilterParts, - std::vector<COMDLG_FILTERSPEC>& vecFilters ); -*/ - #if defined _M_IX86 #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_IA64 @@ -84,4 +58,3 @@ bool BuildFilterSpecList ( _U_STRINGorID szFilterList, #endif #endif - diff --git a/fpicker/source/win32/filepicker/previewadapter.cxx b/fpicker/source/win32/filepicker/previewadapter.cxx index a145c2af563d..aa784a2f7607 100644 --- a/fpicker/source/win32/filepicker/previewadapter.cxx +++ b/fpicker/source/win32/filepicker/previewadapter.cxx @@ -308,7 +308,7 @@ void SAL_CALL CPreviewAdapterImpl::rearrangeLayout() // style bit of the FileOpen dialog must be set after that // message LONG lStyle = GetWindowLong(prvwnd,GWL_STYLE); - sal_Bool bIsVisible = (sal_Bool)(lStyle & WS_VISIBLE); + bool bIsVisible = ((lStyle & WS_VISIBLE) != 0); int cx = 0; diff --git a/framework/Library_fwe.mk b/framework/Library_fwe.mk index 5d30d108cde6..408a514c2f06 100644 --- a/framework/Library_fwe.mk +++ b/framework/Library_fwe.mk @@ -83,8 +83,6 @@ $(eval $(call gb_Library_add_exception_objects,fwe,\ framework/source/fwe/interaction/preventduplicateinteraction \ framework/source/fwe/xml/eventsconfiguration \ framework/source/fwe/xml/eventsdocumenthandler \ - framework/source/fwe/xml/imagesconfiguration \ - framework/source/fwe/xml/imagesdocumenthandler \ framework/source/fwe/xml/menuconfiguration \ framework/source/fwe/xml/menudocumenthandler \ framework/source/fwe/xml/saxnamespacefilter \ diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk index a34a1bc59720..3953d129afc2 100644 --- a/framework/Library_fwk.mk +++ b/framework/Library_fwk.mk @@ -183,6 +183,8 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\ framework/source/uifactory/windowcontentfactorymanager \ framework/source/xml/acceleratorconfigurationreader \ framework/source/xml/acceleratorconfigurationwriter \ + framework/source/xml/imagesconfiguration \ + framework/source/xml/imagesdocumenthandler \ )) # vim: set noet sw=4 ts=4: diff --git a/framework/Package_inc.mk b/framework/Package_inc.mk index 6d1c03a5975b..d72dd52128b8 100644 --- a/framework/Package_inc.mk +++ b/framework/Package_inc.mk @@ -39,7 +39,6 @@ $(eval $(call gb_Package_add_file,framework_inc,inc/framework/undomanagerhelper. $(eval $(call gb_Package_add_file,framework_inc,inc/framework/imutex.hxx,framework/imutex.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/iguard.hxx,framework/iguard.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/imageproducer.hxx,framework/imageproducer.hxx)) -$(eval $(call gb_Package_add_file,framework_inc,inc/framework/imagesconfiguration.hxx,framework/imagesconfiguration.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/interaction.hxx,framework/interaction.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/menuconfiguration.hxx,framework/menuconfiguration.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/menuextensionsupplier.hxx,framework/menuextensionsupplier.hxx)) diff --git a/framework/inc/framework/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx index 0771e2d8f7f1..3174e6d51b22 100644 --- a/framework/inc/framework/imagesconfiguration.hxx +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -25,8 +25,8 @@ * ************************************************************************/ -#ifndef __FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ -#define __FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ +#ifndef FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ +#define FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ #include <framework/fwedllapi.h> #include <svl/svarray.hxx> @@ -50,7 +50,7 @@ enum ImageMaskMode ImageMaskMode_Bitmap }; -struct FWE_DLLPUBLIC ImageItemDescriptor +struct ImageItemDescriptor { ImageItemDescriptor() : nIndex( -1 ) {} @@ -58,7 +58,7 @@ struct FWE_DLLPUBLIC ImageItemDescriptor long nIndex; // index of the bitmap inside the bitmaplist }; -struct FWE_DLLPUBLIC ExternalImageItemDescriptor +struct ExternalImageItemDescriptor { String aCommandURL; // URL command to dispatch String aURL; // a URL to an external bitmap @@ -70,7 +70,7 @@ SV_DECL_PTRARR_DEL( ImageItemListDescriptor, ImageItemDescriptorPtr, 10, 2) typedef ExternalImageItemDescriptor* ExternalImageItemDescriptorPtr; SV_DECL_PTRARR_DEL( ExternalImageItemListDescriptor, ExternalImageItemDescriptorPtr, 10, 2) -struct FWE_DLLPUBLIC ImageListItemDescriptor +struct ImageListItemDescriptor { ImageListItemDescriptor() : nMaskMode( ImageMaskMode_Color ), pImageItemList( 0 ) {} @@ -89,7 +89,7 @@ struct FWE_DLLPUBLIC ImageListItemDescriptor typedef ImageListItemDescriptor* ImageListItemDescriptorPtr; SV_DECL_PTRARR_DEL( ImageListDescriptor, ImageListItemDescriptorPtr, 10, 2) -struct FWE_DLLPUBLIC ImageListsDescriptor +struct ImageListsDescriptor { ImageListsDescriptor() : pImageList( 0 ), pExternalImageList( 0 ) {} @@ -99,7 +99,7 @@ struct FWE_DLLPUBLIC ImageListsDescriptor ExternalImageItemListDescriptor* pExternalImageList; }; -class FWE_DLLPUBLIC ImagesConfiguration +class ImagesConfiguration { public: // #110897# diff --git a/framework/inc/xml/imagesdocumenthandler.hxx b/framework/inc/xml/imagesdocumenthandler.hxx index 59d1e4abdb3a..dd6201b5b9e3 100644 --- a/framework/inc/xml/imagesdocumenthandler.hxx +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -25,8 +25,8 @@ * ************************************************************************/ -#ifndef __FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ -#define __FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ +#ifndef FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ +#define FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ #include <framework/fwedllapi.h> @@ -34,14 +34,12 @@ // interface includes //_________________________________________________________________________________________________________________ -#ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_ #include <com/sun/star/xml/sax/XDocumentHandler.hpp> -#endif //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ -#include <framework/imagesconfiguration.hxx> +#include <xml/imagesconfiguration.hxx> #include <threadhelp/threadhelpbase.hxx> #include <rtl/ustring.hxx> #include <cppuhelper/implbase1.hxx> @@ -59,7 +57,7 @@ namespace framework{ //***************************************************************************************************************** // Hash code function for using in all hash maps of follow implementation. -class FWE_DLLPUBLIC OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses. +class OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses. public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler > { public: @@ -160,7 +158,7 @@ class FWE_DLLPUBLIC OReadImagesDocumentHandler : private ThreadHelpBase, // S ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator; }; -class FWE_DLLPUBLIC OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses. +class OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses. { public: OWriteImagesDocumentHandler( diff --git a/framework/source/fwe/classes/framelistanalyzer.cxx b/framework/source/fwe/classes/framelistanalyzer.cxx index 1a33ebf91d7e..1585fb7b1342 100644 --- a/framework/source/fwe/classes/framelistanalyzer.cxx +++ b/framework/source/fwe/classes/framelistanalyzer.cxx @@ -48,6 +48,7 @@ // includes of other projects #include <unotools/processfactory.hxx> #include <vcl/svapp.hxx> +#include <tools/diagnose_ex.h> //_______________________________________________ // namespace @@ -153,7 +154,7 @@ void FrameListAnalyzer::impl_analyze() // check, if the reference frame includes the backing component. // But look, if this analyze step is realy needed. - if ((m_eDetectMode & E_BACKINGCOMPONENT) == E_BACKINGCOMPONENT) + if (((m_eDetectMode & E_BACKINGCOMPONENT) == E_BACKINGCOMPONENT) && m_xReferenceFrame.is() ) { try { @@ -162,8 +163,13 @@ void FrameListAnalyzer::impl_analyze() ::rtl::OUString sModule = xModuleMgr->identify(m_xReferenceFrame); m_bReferenceIsBacking = (sModule.equals(SERVICENAME_STARTMODULE)); } + catch(const css::frame::UnknownModuleException&) + { + } catch(const css::uno::Exception&) - {} + { + DBG_UNHANDLED_EXCEPTION(); + } } // check, if the reference frame includes the help module. diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx index 877c2dd3d711..c25036c5c346 100644 --- a/framework/source/helper/persistentwindowstate.cxx +++ b/framework/source/helper/persistentwindowstate.cxx @@ -61,6 +61,7 @@ #endif #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> +#include <rtl/string.hxx> //_________________________________________________________________________________________________________________ // namespace @@ -343,7 +344,9 @@ void PersistentWindowState::implst_setWindowStateOnWindow(const css::uno::Refere if (pWorkWindow->IsMinimized()) return; - pSystemWindow->SetWindowState(U2B_ENC(sWindowState,RTL_TEXTENCODING_UTF8)); + ::rtl::OUString sOldWindowState = ::rtl::OStringToOUString( pSystemWindow->GetWindowState(), RTL_TEXTENCODING_ASCII_US ); + if ( sOldWindowState != sWindowState ) + pSystemWindow->SetWindowState(U2B_ENC(sWindowState,RTL_TEXTENCODING_UTF8)); aSolarLock.clear(); // <- SOLAR SAFE ------------------------ diff --git a/framework/source/helper/titlebarupdate.cxx b/framework/source/helper/titlebarupdate.cxx index 9b6501af4c20..a8282c135062 100644 --- a/framework/source/helper/titlebarupdate.cxx +++ b/framework/source/helper/titlebarupdate.cxx @@ -104,37 +104,15 @@ // other includes //_________________________________________________________________________________________________________________ -#ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX #include <comphelper/sequenceashashmap.hxx> -#endif - -#ifndef _UTL_CONFIGMGR_HXX #include <unotools/configmgr.hxx> -#endif - -#ifndef _UTL_BOOTSTRAP_HXX #include <unotools/bootstrap.hxx> -#endif - -#ifndef _SV_WINDOW_HXX #include <vcl/window.hxx> -#endif - -#ifndef _SV_SYSWIN_HXX #include <vcl/syswin.hxx> -#endif - -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> -#endif - -#ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> -#endif - -#ifndef _SV_WRKWIN_HXX #include <vcl/wrkwin.hxx> -#endif +#include <tools/diagnose_ex.h> //_________________________________________________________________________________________________________________ // namespace @@ -332,10 +310,14 @@ void TitleBarUpdate::impl_updateIcon(const css::uno::Reference< css::frame::XFra { try { - xSet->getPropertyValue( CONTROLLER_PROPNAME_ICONID ) >>= nIcon; + css::uno::Reference< css::beans::XPropertySetInfo > const xPSI( xSet->getPropertySetInfo(), css::uno::UNO_SET_THROW ); + if ( xPSI->hasPropertyByName( CONTROLLER_PROPNAME_ICONID ) ) + xSet->getPropertyValue( CONTROLLER_PROPNAME_ICONID ) >>= nIcon; } catch(const css::uno::Exception&) - {} + { + DBG_UNHANDLED_EXCEPTION(); + } } // c) if b) failed ... identify the used module and retrieve set icon from module config. diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 5992e7b42dc5..2f66699de459 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -420,6 +420,14 @@ bool ToolbarLayoutManager::requestToolbar( const ::rtl::OUString& rResourceURL ) bool bMustCallCreate( false ); uno::Reference< ui::XUIElement > xUIElement; + ReadGuard aReadLock( m_aLock ); + uno::Reference< frame::XFrame > xFrame( m_xFrame ); + aReadLock.unlock(); + + uno::Reference< frame::XModel > xModel( impl_getModelFromFrame( xFrame )); + if ( implts_isPreviewModel( xModel )) + return false; // no toolbars for preview frame! + UIElement aRequestedToolbar = impl_findToolbar( rResourceURL ); if ( aRequestedToolbar.m_aName != rResourceURL ) { diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index b9dd626cf06d..a2de01b9c333 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -103,6 +103,7 @@ #include <toolkit/awt/vclxwindow.hxx> #include <comphelper/processfactory.hxx> #include <unotools/moduleoptions.hxx> +#include <tools/diagnose_ex.h> #ifdef ENABLE_ASSERTIONS #ifndef _RTL_STRBUF_HXX_ @@ -2882,10 +2883,13 @@ void Frame::implts_setIconOnWindow() { try { - xSet->getPropertyValue( DECLARE_ASCII("IconId") )>>= nIcon; + css::uno::Reference< css::beans::XPropertySetInfo > const xPSI( xSet->getPropertySetInfo(), css::uno::UNO_SET_THROW ); + if ( xPSI->hasPropertyByName( CONTROLLER_PROPNAME_ICONID ) ) + xSet->getPropertyValue( CONTROLLER_PROPNAME_ICONID ) >>= nIcon; } - catch( css::beans::UnknownPropertyException& ) + catch( css::uno::Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } diff --git a/framework/source/uiconfiguration/imagemanager.cxx b/framework/source/uiconfiguration/imagemanager.cxx index 2a57e72e1ce4..776af9982de4 100644 --- a/framework/source/uiconfiguration/imagemanager.cxx +++ b/framework/source/uiconfiguration/imagemanager.cxx @@ -27,9 +27,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include <uiconfiguration/imagemanager.hxx> #include <threadhelp/resetableguard.hxx> -#include <framework/imagesconfiguration.hxx> +#include <xml/imagesconfiguration.hxx> #include <uiconfiguration/graphicnameaccess.hxx> #include <services.h> #include "imagemanagerimpl.hxx" diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index 537fe623d633..d0caee82297e 100755 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -27,9 +27,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include <imagemanagerimpl.hxx> #include <threadhelp/resetableguard.hxx> -#include <framework/imagesconfiguration.hxx> +#include <xml/imagesconfiguration.hxx> #include <uiconfiguration/graphicnameaccess.hxx> #include <services.h> diff --git a/framework/source/uiconfiguration/moduleimagemanager.cxx b/framework/source/uiconfiguration/moduleimagemanager.cxx index fc90dd102912..0e0f828a253f 100644 --- a/framework/source/uiconfiguration/moduleimagemanager.cxx +++ b/framework/source/uiconfiguration/moduleimagemanager.cxx @@ -27,10 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include <rtl/logfile.hxx> #include <uiconfiguration/moduleimagemanager.hxx> #include <threadhelp/resetableguard.hxx> -#include <framework/imagesconfiguration.hxx> +#include <xml/imagesconfiguration.hxx> #include <uiconfiguration/graphicnameaccess.hxx> #include <services.h> #include "imagemanagerimpl.hxx" diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index fd8e0d3fbcd7..9df04fa17ab4 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -134,16 +134,20 @@ static const char ITEM_DESCRIPTOR_LABEL[] = "Label"; static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; static const char ITEM_DESCRIPTOR_MODULEIDENTIFIER[] = "ModuleIdentifier"; static const char ITEM_DESCRIPTOR_DISPATCHPROVIDER[] = "DispatchProvider"; -static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; - -const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10; -const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7; -const sal_Int32 LEN_DESCRIPTOR_CONTAINER = 23; -const sal_Int32 LEN_DESCRIPTOR_LABEL = 5; -const sal_Int32 LEN_DESCRIPTOR_TYPE = 4; -const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16; -const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16; -static const sal_Int32 ITEM_DESCRIPTOR_STYLE_LEN = 5; +static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; +static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible"; +static const char ITEM_DESCRIPTOR_ENABLED[] = "Enabled"; + +static const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10; +static const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7; +static const sal_Int32 LEN_DESCRIPTOR_CONTAINER = 23; +static const sal_Int32 LEN_DESCRIPTOR_LABEL = 5; +static const sal_Int32 LEN_DESCRIPTOR_TYPE = 4; +static const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16; +static const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16; +static const sal_Int32 LEN_DESCRIPTOR_STYLE = 5; +static const sal_Int32 LEN_DESCRIPTOR_ISVISIBLE = 9; +static const sal_Int32 LEN_DESCRIPTOR_ENABLED = 7; const sal_uInt16 ADDONMENU_MERGE_ITEMID_START = 1500; @@ -1757,6 +1761,8 @@ void MenuBarManager::FillMenu( rtl::OUString aLabel; rtl::OUString aHelpURL; rtl::OUString aModuleIdentifier( rModuleIdentifier ); + sal_Bool bShow(sal_True); + sal_Bool bEnabled(sal_True); sal_uInt16 nType = 0; Reference< XIndexAccess > xIndexContainer; Reference< XDispatchProvider > xDispatchProvider( rDispatchProvider ); @@ -1768,29 +1774,26 @@ void MenuBarManager::FillMenu( for ( int i = 0; i < aProp.getLength(); i++ ) { rtl::OUString aPropName = aProp[i].Name; - if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL, - LEN_DESCRIPTOR_COMMANDURL )) + if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL, LEN_DESCRIPTOR_COMMANDURL )) aProp[i].Value >>= aCommandURL; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, - LEN_DESCRIPTOR_HELPURL )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, LEN_DESCRIPTOR_HELPURL )) aProp[i].Value >>= aHelpURL; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, - LEN_DESCRIPTOR_CONTAINER )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, LEN_DESCRIPTOR_CONTAINER )) aProp[i].Value >>= xIndexContainer; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, - LEN_DESCRIPTOR_LABEL )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, LEN_DESCRIPTOR_LABEL )) aProp[i].Value >>= aLabel; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, - LEN_DESCRIPTOR_TYPE )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, LEN_DESCRIPTOR_TYPE )) aProp[i].Value >>= nType; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_MODULEIDENTIFIER, - LEN_DESCRIPTOR_MODULEIDENTIFIER )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_MODULEIDENTIFIER, LEN_DESCRIPTOR_MODULEIDENTIFIER )) aProp[i].Value >>= aModuleIdentifier; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER, - LEN_DESCRIPTOR_DISPATCHPROVIDER )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER, LEN_DESCRIPTOR_DISPATCHPROVIDER )) aProp[i].Value >>= xDispatchProvider; - else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, ITEM_DESCRIPTOR_STYLE_LEN )) + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, LEN_DESCRIPTOR_STYLE )) aProp[i].Value >>= nStyle; + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_ISVISIBLE, LEN_DESCRIPTOR_ISVISIBLE )) + aProp[i].Value >>= bShow; + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_ENABLED, LEN_DESCRIPTOR_ENABLED )) + aProp[i].Value >>= bEnabled; } if ( nType == ::com::sun::star::ui::ItemType::DEFAULT ) @@ -1809,6 +1812,13 @@ void MenuBarManager::FillMenu( nBits |= MIB_RADIOCHECK; pMenu->SetItemBits( nId, nBits ); } + + if ( !bShow ) + pMenu->HideItem( nId ); + + if ( !bEnabled) + pMenu->EnableItem( nId, sal_False ); + if ( xIndexContainer.is() ) { PopupMenu* pNewPopupMenu = new PopupMenu; diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx index 352fc1ad21f7..1b510a294952 100644 --- a/framework/source/uifactory/windowcontentfactorymanager.cxx +++ b/framework/source/uifactory/windowcontentfactorymanager.cxx @@ -55,6 +55,7 @@ #include <rtl/ustrbuf.hxx> #include <cppuhelper/weak.hxx> #include <tools/urlobj.hxx> +#include <tools/diagnose_ex.h> #include <vcl/svapp.hxx> //_________________________________________________________________________________________________________________ @@ -242,11 +243,9 @@ throw (uno::Exception, uno::RuntimeException) { xWindow = xFactory->createInstanceWithArgumentsAndContext( Arguments, Context ); } - catch ( uno::RuntimeException& ) - { - } catch ( uno::Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } } diff --git a/framework/source/fwe/xml/imagesconfiguration.cxx b/framework/source/xml/imagesconfiguration.cxx index d561a76d5995..946b5b9d0f11 100644 --- a/framework/source/fwe/xml/imagesconfiguration.cxx +++ b/framework/source/xml/imagesconfiguration.cxx @@ -27,12 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" -#include <framework/imagesconfiguration.hxx> + +#include <xml/imagesconfiguration.hxx> #include <services.h> -#ifndef __FRAMEWORK_CLASSES_IMAGESDOCUMENTHANDLER_HXX_ #include <xml/imagesdocumenthandler.hxx> -#endif #include <xml/saxnamespacefilter.hxx> //_________________________________________________________________________________________________________________ diff --git a/framework/source/fwe/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx index cdf20958332a..cdf20958332a 100644 --- a/framework/source/fwe/xml/imagesdocumenthandler.cxx +++ b/framework/source/xml/imagesdocumenthandler.cxx diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu index 2616566225b9..c61dc303dff1 100644 --- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu @@ -863,6 +863,12 @@ <value xml:lang="en-US">.uno:Redo</value> </prop> </node> + <node oor:name="C_MOD1_MOD2" oor:op="replace"> + <prop oor:name="Command"> + <value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> + <value xml:lang="en-US">.uno:InsertAnnotation</value> + </prop> + </node> </node> <node oor:name="com.sun.star.chart2.ChartDocument" oor:op="replace"> <node oor:name="9_SHIFT_MOD1_MOD2" oor:op="replace"> diff --git a/officecfg/registry/data/org/openoffice/Office/Canvas.xcu b/officecfg/registry/data/org/openoffice/Office/Canvas.xcu index a51ff5b244c8..bbabdce6c6f2 100755 --- a/officecfg/registry/data/org/openoffice/Office/Canvas.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Canvas.xcu @@ -77,6 +77,34 @@ </value> </prop> </node> + <node oor:name="com.sun.star.rendering.Canvas.MultiScreen" oor:op="replace"> + <prop oor:name="PreferredImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.Canvas.VCL + </value> + </prop> + <prop oor:name="AcceleratedImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.Canvas.VCL + </value> + </prop> + <prop oor:name="AntialiasingImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.Canvas.VCL + </value> + </prop> + </node> + <node oor:name="com.sun.star.rendering.SpriteCanvas.MultiScreen" oor:op="replace"> + <prop oor:name="PreferredImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.SpriteCanvas.VCL + </value> + </prop> + <prop oor:name="AcceleratedImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.SpriteCanvas.VCL + </value> + </prop> + <prop oor:name="AntialiasingImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.SpriteCanvas.VCL + </value> + </prop> + </node> </node> </oor:component-data> diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index ae171230dd13..3572b37e3e82 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2392,9 +2392,23 @@ <desc>ODFVER_LATEST</desc> </info> </enumeration> - </constraints> - <value>3</value> - </prop> + </constraints> + <value>3</value> + </prop> + <prop oor:name="UseSHA1InODF12" oor:type="xs:boolean"> + <info> + <author>MAV</author> + <desc>Specifies whether SHA1 algorithm instead of SHA256 should be used in ODF12 for StartKey and Checksum generation during encryption.</desc> + </info> + <value>false</value> + </prop> + <prop oor:name="UseBlowfishInODF12" oor:type="xs:boolean"> + <info> + <author>MAV</author> + <desc>Specifies whether Blowfish algorithm instead of AES should be used in ODF12 for encryption.</desc> + </info> + <value>false</value> + </prop> </group> </group> <group oor:name="Load"> @@ -4833,6 +4847,33 @@ <value>1</value> </prop> </group> + <group oor:name="SVG"> + <info> + <author>KA</author> + <desc>Specifies default settings of SVG export dialog.</desc> + </info> + <prop oor:name="TinyMode" oor:type="xs:boolean"> + <info> + <author>KA</author> + <desc>Specifies if SVG Tiny profile should be used for export.</desc> + </info> + <value>false</value> + </prop> + <prop oor:name="EmbedFonts" oor:type="xs:boolean"> + <info> + <author>KA</author> + <desc>Specifies if fonts should be embedded into SVG file.</desc> + </info> + <value>true</value> + </prop> + <prop oor:name="UseNativeTextDecoration" oor:type="xs:boolean"> + <info> + <author>KA</author> + <desc>Specifies if text decoration like underlining and strike-through be drawm by using SVG attributes (true) or by drawing SVG primitives (false).</desc> + </info> + <value>true</value> + </prop> + </group> </group> </group> <group oor:name="HTML"> diff --git a/oovbaapi/ooo/vba/XApplicationBase.idl b/oovbaapi/ooo/vba/XApplicationBase.idl index 1291276ae643..3d0e6c9ce0f5 100644 --- a/oovbaapi/ooo/vba/XApplicationBase.idl +++ b/oovbaapi/ooo/vba/XApplicationBase.idl @@ -45,7 +45,6 @@ interface XApplicationBase [attribute, readonly] string Version; [attribute, readonly] any VBE; - [attribute, readonly] any VBProjects; void Quit(); diff --git a/oovbaapi/ooo/vba/XCollectionBase.idl b/oovbaapi/ooo/vba/XCollectionBase.idl new file mode 100755 index 000000000000..245b252f7856 --- /dev/null +++ b/oovbaapi/ooo/vba/XCollectionBase.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * Copyright 2010, Oracle and/or its affiliates. All rights reserved. + * + ************************************************************************/ + +#ifndef OOO_VBA_XOLLECTIONBASE_IDL +#define OOO_VBA_XOLLECTIONBASE_IDL + +#include <com/sun/star/container/XEnumerationAccess.idl> +#include <com/sun/star/script/XDefaultMethod.idl> + +//============================================================================= + +module ooo { module vba { + +//============================================================================= + +/** Base interface for VBA collections. + + Every VBA collection provides the number of items, an enumeration access of + all collection items (e.g. for the "For Each" loop), and a way to access + single items, usually via the method "Item". + + The various VBA collection objects expect a specific number of arguments in + the "Item" method, therefore this method is not part of this base interface + but has to be specified seperately in every derived interface. + */ +interface XCollectionBase +{ + //------------------------------------------------------------------------- + /** Provides an enumeration of all items in this collection. + */ + interface ::com::sun::star::container::XEnumerationAccess; + + //------------------------------------------------------------------------- + /** Provides the name of the default item access method. + + Usually this method is called "Item". The access method has to be + specified and implemented separately by every derived class. + */ + interface ::com::sun::star::script::XDefaultMethod; + + //------------------------------------------------------------------------- + /** Returns the number of items contained in this collection. + */ + [attribute, readonly] long Count; + + //------------------------------------------------------------------------- +}; + +//============================================================================= + +}; }; + +#endif diff --git a/oovbaapi/ooo/vba/XControlProvider.idl b/oovbaapi/ooo/vba/XControlProvider.idl index 23f890d5a1c3..df8b53bdfc72 100644 --- a/oovbaapi/ooo/vba/XControlProvider.idl +++ b/oovbaapi/ooo/vba/XControlProvider.idl @@ -51,8 +51,6 @@ module ooo { module vba { interface XControlProvider { ::ooo::vba::msforms::XControl createControl( [in] ::com::sun::star::drawing::XControlShape xControl, [in] ::com::sun::star::frame::XModel xDocOwner ); - ::ooo::vba::msforms::XControl createUserformControl( [in] ::com::sun::star::awt::XControl xControl, [in] ::com::sun::star::awt::XControl xDialog, [in] ::com::sun::star::frame::XModel xDocOwner ); - }; }; }; diff --git a/oovbaapi/ooo/vba/XExecutableDialog.idl b/oovbaapi/ooo/vba/XExecutableDialog.idl new file mode 100755 index 000000000000..8754c8071348 --- /dev/null +++ b/oovbaapi/ooo/vba/XExecutableDialog.idl @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_XExecutableDialog_idl__ +#define __ooo_vba_XExecutableDialog_idl__ + +#include <com/sun/star/uno/XInterface.idl> + +//============================================================================= + +module ooo { module vba { + +/** The VBA equivalent to the UNO interface + <type scope="com::sun::star::ui::dialogs">XExecutableDialog</type>. + */ +interface XExecutableDialog +{ + /** Executes the dialog. + + @return + The return value is dependent on the calling context. Usually, on + cancelling the dialog the implementation will return <FALSE/>, + otherwise the return value will contain the expected result. + */ + any execute(); +}; + +//============================================================================= + +}; }; + +#endif + + diff --git a/oovbaapi/ooo/vba/excel/SheetObjects.idl b/oovbaapi/ooo/vba/excel/SheetObjects.idl index 5947c52ff4a0..0a2a3fd9ffe9 100644 --- a/oovbaapi/ooo/vba/excel/SheetObjects.idl +++ b/oovbaapi/ooo/vba/excel/SheetObjects.idl @@ -74,10 +74,10 @@ interface XGraphicObjects : com::sun::star::uno::XInterface /** Adds a new graphic object to the sheet this collection belongs to. The type of the object is determined by the type of the collection. - @param fLeft Position of the left border in points (1/72 inch). - @param fTop Position of the top border in points (1/72 inch). - @param fWidth Width of the object in points (1/72 inch). - @param fHeight Height of the object in points (1/72 inch). + @param Left Position of the left border in points (1/72 inch). + @param Top Position of the top border in points (1/72 inch). + @param Width Width of the object in points (1/72 inch). + @param Height Height of the object in points (1/72 inch). @return The created graphic object. */ @@ -102,10 +102,10 @@ interface XLineObjects : com::sun::star::uno::XInterface /** Adds a new line object to the sheet this collection belongs to. The type of the object is determined by the type of the collection. - @param fX1 Position of the first X coordinate in points (1/72 inch). - @param fY1 Position of the first Y coordinate in points (1/72 inch). - @param fX2 Position of the last X coordinate in points (1/72 inch). - @param fY2 Position of the last Y coordinate in points (1/72 inch). + @param X1 Position of the first X coordinate in points (1/72 inch). + @param Y1 Position of the first Y coordinate in points (1/72 inch). + @param X2 Position of the last X coordinate in points (1/72 inch). + @param Y2 Position of the last Y coordinate in points (1/72 inch). @return The created line object. */ @@ -123,11 +123,11 @@ interface XDrawings : com::sun::star::uno::XInterface { /** Adds a new polygon object to the sheet this collection belongs to. - @param fX1 Position of the first X coordinate in points (1/72 inch). - @param fY1 Position of the first Y coordinate in points (1/72 inch). - @param fX2 Position of the last X coordinate in points (1/72 inch). - @param fY2 Position of the last Y coordinate in points (1/72 inch). - @param bClosed True = outline closed (last and first point connected). + @param X1 Position of the first X coordinate in points (1/72 inch). + @param Y1 Position of the first Y coordinate in points (1/72 inch). + @param X2 Position of the last X coordinate in points (1/72 inch). + @param Y2 Position of the last Y coordinate in points (1/72 inch). + @param Closed True = outline closed (last and first point connected). @return The created polygon object. */ diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl index 5ec821dbe8bb..267c9589bfae 100644 --- a/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/oovbaapi/ooo/vba/excel/XApplication.idl @@ -64,15 +64,12 @@ interface XApplication [attribute] any CutCopyMode; [attribute] any StatusBar; [attribute] long Cursor; - [attribute] boolean EnableEvents; + [attribute] boolean EnableEvents; + [attribute] string DefaultFilePath; + [attribute, readonly] string LibraryPath; + [attribute, readonly] string TemplatesPath; + [attribute, readonly] string PathSeparator; - void setDefaultFilePath([in] string DefaultFilePath) raises(com::sun::star::script::BasicErrorException); - - string getDefaultFilePath() raises(com::sun::star::script::BasicErrorException); - - string LibraryPath() raises(com::sun::star::script::BasicErrorException); - string TemplatesPath() raises(com::sun::star::script::BasicErrorException); - string PathSeparator() raises(com::sun::star::script::BasicErrorException); //any CommandBars( [in] any Index ); any Workbooks( [in] any Index ); any Worksheets( [in] any Index ); @@ -93,10 +90,10 @@ interface XApplication void Volatile([in] any Volatile); void DoEvents(); any Caller( [in] any Index ); + any GetOpenFilename( [in] any FileFilter, [in] any FilterIndex, [in] any Title, [in] any ButtonText, [in] any MultiSelect ); + any GetSaveAsFilename( [in] any InitialFileName, [in] any FileFilter, [in] any FilterIndex, [in] any Title, [in] any ButtonText ); }; }; }; }; #endif - - diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk index 4f6d378cfe3f..d1adc1c4252e 100644 --- a/oovbaapi/ooo/vba/makefile.mk +++ b/oovbaapi/ooo/vba/makefile.mk @@ -39,6 +39,7 @@ PACKAGE=ooo$/vba IDLFILES=\ XErrObject.idl \ XCollection.idl\ + XCollectionBase.idl\ XVBAToOOEventDescGen.idl\ XPropValue.idl\ XHelperInterface.idl\ @@ -58,6 +59,7 @@ IDLFILES=\ XGlobalsBase.idl\ XDocumentProperty.idl\ XDocumentProperties.idl\ + XExecutableDialog.idl\ XFontBase.idl\ XDialogsBase.idl\ XDialogBase.idl\ diff --git a/oovbaapi/ooo/vba/msforms/XButton.idl b/oovbaapi/ooo/vba/msforms/XCheckBox.idl index 24cf1ba26c60..7520a559b0d5 100644..100755 --- a/oovbaapi/ooo/vba/msforms/XButton.idl +++ b/oovbaapi/ooo/vba/msforms/XCheckBox.idl @@ -24,20 +24,23 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef __ooo_vba_msforms_XButton_idl__ -#define __ooo_vba_msforms_XButton_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#ifndef __ooo_vba_msforms_XCheckBox_idl__ +#define __ooo_vba_msforms_XCheckBox_idl__ + +#include <ooo/vba/msforms/XNewFont.idl> + //============================================================================= module ooo { module vba { module msforms { //============================================================================= -interface XButton: com::sun::star::uno::XInterface + +interface XCheckBox { [attribute] string Caption; + [attribute] any Value; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XComboBox.idl b/oovbaapi/ooo/vba/msforms/XComboBox.idl index 5f2b66431eb8..51ca4a4135d1 100644 --- a/oovbaapi/ooo/vba/msforms/XComboBox.idl +++ b/oovbaapi/ooo/vba/msforms/XComboBox.idl @@ -24,26 +24,33 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XComboBox_idl__ #define __ooo_vba_msforms_XComboBox_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif - +#include <ooo/vba/msforms/XNewFont.idl> //============================================================================= module ooo { module vba { module msforms { - //============================================================================= -interface XComboBox: ::com::sun::star::uno::XInterface + +interface XComboBox { [attribute] any Value; [attribute] any ListIndex; - [attribute, readonly ] long ListCount; + [attribute, readonly] long ListCount; [attribute] string Text; + [attribute] long Style; + [attribute] long DropButtonStyle; + [attribute] long DragBehavior; + [attribute] long EnterFieldBehavior; + [attribute] long ListStyle; + [attribute] long TextAlign; + [attribute, readonly] long TextLength; + [attribute, readonly] XNewFont Font; + void AddItem( [in] any pvargItem, [in] any pvargIndex ); void removeItem( [in] any index ); void Clear(); diff --git a/oovbaapi/ooo/vba/msforms/XCommandButton.idl b/oovbaapi/ooo/vba/msforms/XCommandButton.idl new file mode 100644 index 000000000000..0e7697cbd162 --- /dev/null +++ b/oovbaapi/ooo/vba/msforms/XCommandButton.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_msforms_XCommandButton_idl__ +#define __ooo_vba_msforms_XCommandButton_idl__ + +#include <ooo/vba/msforms/XNewFont.idl> + +//============================================================================= + +module ooo { module vba { module msforms { + +//============================================================================= + +interface XCommandButton +{ + [attribute] string Caption; + [attribute] boolean AutoSize; + [attribute] boolean Cancel; + [attribute] boolean Default; + [attribute] long BackColor; + [attribute] long ForeColor; + [attribute, readonly] XNewFont Font; +}; + +//============================================================================= + +}; }; }; + +#endif + + diff --git a/oovbaapi/ooo/vba/msforms/XControl.idl b/oovbaapi/ooo/vba/msforms/XControl.idl index 97ca9d152716..3cd1f2c3e75c 100644 --- a/oovbaapi/ooo/vba/msforms/XControl.idl +++ b/oovbaapi/ooo/vba/msforms/XControl.idl @@ -63,6 +63,7 @@ interface XControl [attribute] string Name; [attribute] string ControlTipText; [attribute] string Tag; + [attribute] long TabIndex; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XFrame.idl b/oovbaapi/ooo/vba/msforms/XFrame.idl new file mode 100755 index 000000000000..6038b61dd3bd --- /dev/null +++ b/oovbaapi/ooo/vba/msforms/XFrame.idl @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_msforms_XFrame_idl__ +#define __ooo_vba_msforms_XFrame_idl__ + +#include <ooo/vba/msforms/XNewFont.idl> + +//============================================================================= + +module ooo { module vba { module msforms { + +//============================================================================= + +interface XFrame +{ + [attribute] string Caption; + [attribute] long SpecialEffect; + [attribute] long BorderStyle; + [attribute, readonly] XNewFont Font; + + any Controls( [in] any Index ); +}; + +//============================================================================= + +}; }; }; + +//============================================================================= + +#endif diff --git a/oovbaapi/ooo/vba/msforms/XGroupBox.idl b/oovbaapi/ooo/vba/msforms/XGroupBox.idl index 9ed6f9d45046..9718f23e1c66 100644 --- a/oovbaapi/ooo/vba/msforms/XGroupBox.idl +++ b/oovbaapi/ooo/vba/msforms/XGroupBox.idl @@ -24,19 +24,22 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XGroupBox_idl__ #define __ooo_vba_msforms_XGroupBox_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#include <ooo/vba/msforms/XNewFont.idl> + //============================================================================= module ooo { module vba { module msforms { + //============================================================================= + interface XGroupBox { [attribute] string Caption; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XLabel.idl b/oovbaapi/ooo/vba/msforms/XLabel.idl index d757af5074d8..399127a091c8 100644 --- a/oovbaapi/ooo/vba/msforms/XLabel.idl +++ b/oovbaapi/ooo/vba/msforms/XLabel.idl @@ -24,21 +24,23 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XLabel_idl__ #define __ooo_vba_msforms_XLabel_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#include <ooo/vba/msforms/XNewFont.idl> + //============================================================================= module ooo { module vba { module msforms { //============================================================================= -interface XLabel: com::sun::star::uno::XInterface + +interface XLabel { [attribute] string Caption; [attribute] any Value; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XListBox.idl b/oovbaapi/ooo/vba/msforms/XListBox.idl index bdc0c6bfc660..63f9cce0bdf8 100644 --- a/oovbaapi/ooo/vba/msforms/XListBox.idl +++ b/oovbaapi/ooo/vba/msforms/XListBox.idl @@ -24,25 +24,27 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XListBox_idl__ #define __ooo_vba_msforms_XListBox_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#include <ooo/vba/msforms/XNewFont.idl> + //============================================================================= module ooo { module vba { module msforms { - //============================================================================= -interface XListBox: com::sun::star::uno::XInterface + +interface XListBox { [attribute] any Value; [attribute] string Text; [attribute] boolean MultiSelect; [attribute] any ListIndex; - [attribute, readonly ] long ListCount; + [attribute, readonly] long ListCount; + [attribute, readonly] XNewFont Font; + void AddItem( [in] any pvargItem, [in] any pvargIndex ); void removeItem( [in] any index ); void Clear(); diff --git a/oovbaapi/ooo/vba/msforms/XNewFont.idl b/oovbaapi/ooo/vba/msforms/XNewFont.idl new file mode 100755 index 000000000000..755dd510b63a --- /dev/null +++ b/oovbaapi/ooo/vba/msforms/XNewFont.idl @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_msforms_XNewFont_idl__ +#define __ooo_vba_msforms_XNewFont_idl__ + +#include <com/sun/star/uno/XInterface.idl> + +//============================================================================= + +module ooo { module vba { module msforms { + +//============================================================================= + +interface XNewFont +{ + [attribute] string Name; + [attribute] double Size; + [attribute] short Charset; + [attribute] short Weight; + [attribute] boolean Bold; + [attribute] boolean Italic; + [attribute] boolean Underline; + [attribute] boolean Strikethrough; +}; + +//============================================================================= + +}; }; }; + +//============================================================================= + +#endif diff --git a/oovbaapi/ooo/vba/msforms/XRadioButton.idl b/oovbaapi/ooo/vba/msforms/XRadioButton.idl index b2289ce33331..2aced0e92e30 100644 --- a/oovbaapi/ooo/vba/msforms/XRadioButton.idl +++ b/oovbaapi/ooo/vba/msforms/XRadioButton.idl @@ -24,21 +24,23 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XRadioButton_idl__ #define __ooo_vba_msforms_XRadioButton_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#include <ooo/vba/msforms/XNewFont.idl> + //============================================================================= module ooo { module vba { module msforms { //============================================================================= -interface XRadioButton: com::sun::star::uno::XInterface + +interface XRadioButton { [attribute] string Caption; [attribute] any Value; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XTextBox.idl b/oovbaapi/ooo/vba/msforms/XTextBox.idl index 9c6b55e5ca6d..267fbf7f01cb 100644 --- a/oovbaapi/ooo/vba/msforms/XTextBox.idl +++ b/oovbaapi/ooo/vba/msforms/XTextBox.idl @@ -24,23 +24,28 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XTextBox_idl__ #define __ooo_vba_msforms_XTextBox_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#include <ooo/vba/msforms/XNewFont.idl> + //============================================================================= module ooo { module vba { module msforms { //============================================================================= -interface XTextBox: com::sun::star::uno::XInterface + +interface XTextBox { [attribute] string Text; [attribute] any Value; [attribute] long MaxLength; [attribute] boolean Multiline; + [attribute] long SpecialEffect; + [attribute] long BorderStyle; + [attribute, readonly] long TextLength; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XToggleButton.idl b/oovbaapi/ooo/vba/msforms/XToggleButton.idl index e66eea54babb..923f7e1e2203 100644 --- a/oovbaapi/ooo/vba/msforms/XToggleButton.idl +++ b/oovbaapi/ooo/vba/msforms/XToggleButton.idl @@ -24,22 +24,21 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XToggleButton_idl__ #define __ooo_vba_msforms_XToggleButton_idl__ -#ifndef __ooo_vba_msforms_XButton_idl__ -#include <ooo/vba/msforms/XButton.idl> -#endif -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#include <ooo/vba/msforms/XCommandButton.idl> + //============================================================================= module ooo { module vba { module msforms { + //============================================================================= + interface XToggleButton { - interface XButton; + interface XCommandButton; [attribute] any Value; }; diff --git a/oovbaapi/ooo/vba/msforms/XUserForm.idl b/oovbaapi/ooo/vba/msforms/XUserForm.idl index c06aa2902b53..1e54dd1b8f41 100644 --- a/oovbaapi/ooo/vba/msforms/XUserForm.idl +++ b/oovbaapi/ooo/vba/msforms/XUserForm.idl @@ -39,6 +39,8 @@ interface XUserForm //interface ::ooo::vba::XHelperInterface; interface ::com::sun::star::script::XInvocation; [attribute] string Caption; + [attribute] double InnerWidth; + [attribute] double InnerHeight; void Show(); void Hide(); void RePaint(); diff --git a/oovbaapi/ooo/vba/msforms/makefile.mk b/oovbaapi/ooo/vba/msforms/makefile.mk index 56ac4caf87cb..1d7d9ee166e5 100644 --- a/oovbaapi/ooo/vba/msforms/makefile.mk +++ b/oovbaapi/ooo/vba/msforms/makefile.mk @@ -38,10 +38,13 @@ PACKAGE=ooo$/vba$/msforms IDLFILES=\ MSFormReturnTypes.idl \ + XCheckBox.idl \ XComboBox.idl \ - XButton.idl \ + XCommandButton.idl \ XControl.idl \ + XFrame.idl \ XLabel.idl \ + XNewFont.idl \ XTextBox.idl \ XRadioButton.idl \ XShape.idl \ diff --git a/readlicense_oo/docs/readme.xsl b/readlicense_oo/docs/readme.xsl index 4e77fa522c3d..e63e319cf502 100644..100755 --- a/readlicense_oo/docs/readme.xsl +++ b/readlicense_oo/docs/readme.xsl @@ -34,6 +34,13 @@ </xsl:if> </xsl:param> + <xsl:param name="lf"> + <xsl:choose> + <xsl:when test="$platform='WIN'"><xsl:text>
</xsl:text></xsl:when> + <xsl:otherwise><xsl:text>
</xsl:text></xsl:otherwise> + </xsl:choose> + </xsl:param> + <xsl:template match="/"> <xsl:choose> <xsl:when test="$type='html'"> @@ -115,59 +122,50 @@ <xsl:apply-templates/> </xsl:when> <xsl:when test="name(.)='li'"> - <xsl:text> -</xsl:text>* <xsl:apply-templates/> + <xsl:value-of select="$lf"/>* <xsl:apply-templates/> </xsl:when> <xsl:when test="name(.)='ul'"> - <xsl:text> -</xsl:text> + <xsl:value-of select="$lf"/> <xsl:apply-templates/> </xsl:when> <xsl:when test="name(.)='ol'"> - <xsl:text> -</xsl:text> + <xsl:value-of select="$lf"/> <xsl:apply-templates/> </xsl:when> <xsl:when test="name(.)='p'"> <xsl:if test="(not(name(..)='li') and (count(a) = 0))"> - <xsl:text> - -</xsl:text> + <xsl:value-of select="$lf"/> + <xsl:value-of select="$lf"/> </xsl:if> <xsl:apply-templates/> </xsl:when> <xsl:when test="name(.)='h1'"> - <xsl:text> - -====================================================================== -</xsl:text> + <xsl:value-of select="$lf"/> + <xsl:text>======================================================================</xsl:text> + <xsl:value-of select="$lf"/> <xsl:apply-templates/> - <xsl:text> -======================================================================</xsl:text> + <xsl:value-of select="$lf"/> + <xsl:text>======================================================================</xsl:text> + <xsl:value-of select="$lf"/> </xsl:when> <xsl:when test="name(.)='h2'"> - <xsl:text> - ----------------------------------------------------------------------- -</xsl:text> + <xsl:value-of select="$lf"/> + <xsl:value-of select="$lf"/> + <xsl:text>----------------------------------------------------------------------</xsl:text> + <xsl:value-of select="$lf"/> <xsl:apply-templates/> - <xsl:text> -----------------------------------------------------------------------</xsl:text> - + <xsl:value-of select="$lf"/> + <xsl:text>----------------------------------------------------------------------</xsl:text> </xsl:when> <xsl:when test="name(.)='h3'"> - <xsl:text> - -</xsl:text> + <xsl:value-of select="$lf"/> + <xsl:value-of select="$lf"/> <xsl:apply-templates/> - <xsl:text> -----------------------------------------------------------------------</xsl:text> - + <xsl:value-of select="$lf"/> + <xsl:text>----------------------------------------------------------------------</xsl:text> </xsl:when> </xsl:choose> </xsl:if> </xsl:template> - - </xsl:stylesheet> diff --git a/readlicense_oo/docs/readme/eval.xsl b/readlicense_oo/docs/readme/eval.xsl index e8830d43015c..613e61d673f9 100644 --- a/readlicense_oo/docs/readme/eval.xsl +++ b/readlicense_oo/docs/readme/eval.xsl @@ -1,5 +1,5 @@ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> - <xsl:output method="html" /> + <xsl:output method="text" /> <xsl:template match="/Readme"> <html> <head> diff --git a/readlicense_oo/docs/readme/readme.xrm b/readlicense_oo/docs/readme/readme.xrm index 78716869e822..66203b687635 100755 --- a/readlicense_oo/docs/readme/readme.xrm +++ b/readlicense_oo/docs/readme/readme.xrm @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" -"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> @@ -31,6 +30,7 @@ <div id="Installation"> <h2 id="rr3fgf42r" xml:lang="en-US">Notes on Installation</h2> + <p class="note" id="javaneeded" xml:lang="en-US">${PRODUCTNAME} requires a recent version of JAVA for full functionality which is part of the ${PRODUCTNAME} installation package.</p> <h3 id="sdfsdfgf42r" xml:lang="en-US">System Requirements</h3> <div class="MAC" id="SystemRequirements_OSX"> <ul> diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx index 6c3694ea237d..ab2b52ae7d55 100644 --- a/scripting/source/dlgprov/dlgevtatt.cxx +++ b/scripting/source/dlgprov/dlgevtatt.cxx @@ -45,14 +45,13 @@ #include <com/sun/star/script/provider/XScriptProvider.hpp> #include <com/sun/star/script/provider/XScriptProviderFactory.hpp> #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <com/sun/star/lang/NoSuchMethodException.hpp> #include <com/sun/star/reflection/XIdlMethod.hpp> #include <com/sun/star/beans/MethodConcept.hpp> #include <com/sun/star/beans/XMaterialHolder.hpp> #include <ooo/vba/XVBAToOOEventDescGen.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <vbahelper/vbaaccesshelper.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::awt; @@ -175,19 +174,17 @@ namespace dlgprov // handler for Script & ::rtl::OUString::createFromAscii( "vnd.sun.star.UNO:" ) listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.UNO") ] = new DialogUnoScriptListenerImpl( rxContext, rxModel, rxControl, rxHandler, rxIntrospect, bProviderMode ); listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.script") ] = new DialogSFScriptListenerImpl( rxContext, rxModel ); - // Note: in a future cws ( npower13_ObjectModule ) it will be possible - // to determine the vba mode from the basiclibrary container, the tunnel hack - // below can then be replaced - SfxObjectShell* pFoundShell = NULL; - if ( rxModel.is() ) + + // determine the VBA compatibility mode from the Basic library container + try + { + uno::Reference< beans::XPropertySet > xModelProps( rxModel, uno::UNO_QUERY_THROW ); + uno::Reference< script::vba::XVBACompatibility > xVBACompat( + xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW ); + mbUseFakeVBAEvents = xVBACompat->getVBACompatibilityMode(); + } + catch( uno::Exception& ) { - uno::Reference< lang::XUnoTunnel > xObjShellTunnel( rxModel, uno::UNO_QUERY ); - if ( xObjShellTunnel.is() ) - { - pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId())); - if ( pFoundShell ) - mbUseFakeVBAEvents = ooo::vba::isAlienExcelDoc( *pFoundShell ); - } } if ( mbUseFakeVBAEvents ) listernersForTypes[ rtl::OUString::createFromAscii("VBAInterop") ] = new DialogVBAScriptListenerImpl( rxContext, rxControl, rxModel ); diff --git a/scripting/source/dlgprov/dlgprov.component b/scripting/source/dlgprov/dlgprov.component index f7ceed336cf6..ba58de62fde4 100644 --- a/scripting/source/dlgprov/dlgprov.component +++ b/scripting/source/dlgprov/dlgprov.component @@ -33,4 +33,7 @@ <service name="com.sun.star.awt.DialogProvider"/> <service name="com.sun.star.awt.DialogProvider2"/> </implementation> + <implementation name="com.sun.star.comp.scripting.DialogModelProvider"> + <service name="com.sun.star.awt.UnoControlDialogModelProvider"/> + </implementation> </component> diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx index 8a577ab03e1c..e80647cb1068 100644 --- a/scripting/source/dlgprov/dlgprov.cxx +++ b/scripting/source/dlgprov/dlgprov.cxx @@ -75,7 +75,7 @@ namespace comp_DialogModelProvider ::rtl::OUString SAL_CALL _getImplementationName() { - return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogModelProvider")); + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.scripting.DialogModelProvider")); } uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames() diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index 71a6fc269c11..2914c648bfe9 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -98,6 +98,8 @@ SfxAppData_Impl::SfxAppData_Impl( SfxApplication* ) : pTopFrames( new SfxFrameArr_Impl ), pInitLinkList(0), pMatcher( 0 ), + pBasicResMgr( 0 ), + pSvtResMgr( 0 ), pAppDispatch(NULL), pTemplates( 0 ), pPool(0), diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx index d9ff26beccba..ba23e04cad12 100644 --- a/sfx2/source/appl/appinit.cxx +++ b/sfx2/source/appl/appinit.cxx @@ -262,12 +262,11 @@ bool SfxApplication::Initialize_Impl() // nichtgehandelte Fehler durch Errorcode 1 an SFX gegeben. new SimpleErrorHandler; #endif - new SfxErrorHandler(RID_ERRHDL, ERRCODE_AREA_TOOLS, ERRCODE_AREA_LIB1); - - new SfxErrorHandler( - RID_SO_ERROR_HANDLER, ERRCODE_AREA_SO, ERRCODE_AREA_SO_END); - new SfxErrorHandler( - RID_BASIC_START, ERRCODE_AREA_SBX, ERRCODE_AREA_SBX_END ); + pAppData_Impl->pBasicResMgr = CreateResManager("sb"); + pAppData_Impl->pSvtResMgr = CreateResManager("svt"); + new SfxErrorHandler( RID_ERRHDL, ERRCODE_AREA_TOOLS, ERRCODE_AREA_LIB1 ); + new SfxErrorHandler( RID_SO_ERROR_HANDLER, ERRCODE_AREA_SO, ERRCODE_AREA_SO_END, pAppData_Impl->pSvtResMgr ); + new SfxErrorHandler( RID_BASIC_START, ERRCODE_AREA_SBX, ERRCODE_AREA_SBX_END, pAppData_Impl->pBasicResMgr ); // diverse Pointer SfxPickList::GetOrCreate( SvtHistoryOptions().GetSize( ePICKLIST ) ); diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 281a87c962f7..8b76024c1afb 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -288,8 +288,9 @@ private: } catch( const uno::Exception& ) { - // unknown error, do not try to ask again - eResult = ::comphelper::DocPasswordVerifierResult_ABORT; + // unknown error, report it as wrong password + // TODO/LATER: we need an additional way to report unknown problems in this case + eResult = ::comphelper::DocPasswordVerifierResult_WRONG_PASSWORD; } return eResult; } diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx index 351376091929..1a62f48a7a24 100644 --- a/sfx2/source/appl/appquit.cxx +++ b/sfx2/source/appl/appquit.cxx @@ -167,4 +167,6 @@ void SfxApplication::Deinitialize() NoChaos::ReleaseItemPool(); */ pAppData_Impl->pPool = NULL; + DELETEZ(pAppData_Impl->pBasicResMgr); + DELETEZ(pAppData_Impl->pSvtResMgr); } diff --git a/sfx2/source/appl/sfx.src b/sfx2/source/appl/sfx.src index 3bca517c5fd5..746b4c9688d6 100644 --- a/sfx2/source/appl/sfx.src +++ b/sfx2/source/appl/sfx.src @@ -27,19 +27,6 @@ #include <sfx2/sfx.hrc> -String STR_STYLE_FILTER_USED -{ - Text [ en-US ] = "Applied Styles" ; -}; -String STR_STYLE_FILTER_USERDEF -{ - Text [ en-US ] = "Custom Styles" ; -}; -String STR_STYLE_FILTER_ALL -{ - Text [ en-US ] = "All Styles" ; -}; - String STR_ACCTITLE_PRODUCTIVITYTOOLS { Text [ en-US ] = "%PRODUCTNAME"; diff --git a/sfx2/source/appl/shutdowniconaqua.mm b/sfx2/source/appl/shutdowniconaqua.mm index 14f12c79b53b..d51df52b02d1 100644 --- a/sfx2/source/appl/shutdowniconaqua.mm +++ b/sfx2/source/appl/shutdowniconaqua.mm @@ -115,6 +115,7 @@ using namespace ::com::sun::star::util; -(void)dockIconClicked: (NSObject*)pSender { + (void)pSender; // start start module ShutdownIcon::OpenURL( OUString( RTL_CONSTASCII_USTRINGPARAM( STARTMODULE_URL ) ), OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ) ); } diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index df0781be8877..0ff55513c547 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -699,11 +699,11 @@ writeStream(struct DocumentMetadataAccess_Impl & i_rImpl, buf.append(dir).append(static_cast<sal_Unicode>('/')); writeStream(i_rImpl, xDir, i_xGraphName, rest, buf.makeStringAndClear()); - } - const uno::Reference<embed::XTransactedObject> xTransaction( - i_xStorage, uno::UNO_QUERY); - if (xTransaction.is()) { - xTransaction->commit(); + uno::Reference<embed::XTransactedObject> const xTransaction( + xDir, uno::UNO_QUERY); + if (xTransaction.is()) { + xTransaction->commit(); + } } } catch (uno::RuntimeException &) { throw; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 2ccf5fa7a849..1df7d2b01920 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -670,6 +670,10 @@ sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus ) //------------------------------------------------------------------------- sal_Int8 ModelData_Impl::CheckStateForSave() { + // if the document is readonly or a new one a SaveAs operation must be used + if ( !GetStorable()->hasLocation() || GetStorable()->isReadonly() ) + return STATUS_SAVEAS; + // check acceptable entries for media descriptor sal_Bool bVersInfoNeedsStore = sal_False; ::comphelper::SequenceAsHashMap aAcceptedArgs; @@ -701,10 +705,6 @@ sal_Int8 ModelData_Impl::CheckStateForSave() if ( !GetModifiable()->isModified() && !bVersInfoNeedsStore ) return STATUS_NO_ACTION; - // if the document is readonly or a new one a SaveAs operation must be used - if ( !GetStorable()->hasLocation() || GetStorable()->isReadonly() ) - return STATUS_SAVEAS; - // check that the old filter is acceptable ::rtl::OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault( aFilterNameString, diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 9a86e962cac6..38f30b78974a 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -67,9 +67,12 @@ #include <com/sun/star/embed/XLinkageSupport.hpp> #include <com/sun/star/embed/EntryInitModes.hpp> #include <com/sun/star/embed/XOptimizedStorage.hpp> +#include <com/sun/star/embed/XEncryptionProtectedStorage.hpp> #include <com/sun/star/io/XTruncate.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/security/XDocumentDigitalSignatures.hpp> +#include <com/sun/star/xml/crypto/CipherID.hpp> +#include <com/sun/star/xml/crypto/DigestID.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -357,24 +360,51 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); } - ::rtl::OUString aVersion; SvtSaveOptions aSaveOpt; SvtSaveOptions::ODFDefaultVersion nDefVersion = aSaveOpt.GetODFDefaultVersion(); - // older versions can not have this property set, it exists only starting from ODF1.2 - if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) - aVersion = ODFVER_012_TEXT; + uno::Sequence< beans::NamedValue > aEncryptionAlgs( 3 ); + aEncryptionAlgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StartKeyGenerationAlgorithm" ) ); + aEncryptionAlgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptionAlgorithm" ) ); + aEncryptionAlgs[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ChecksumAlgorithm" ) ); + // the default values, that should be used for ODF1.1 and older formats + aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA1; + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8; + aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA1_1K; - if ( aVersion.getLength() ) + if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) { try { - xProps->setPropertyValue( ::rtl::OUString::createFromAscii( "Version" ), uno::makeAny( aVersion ) ); + // older versions can not have this property set, it exists only starting from ODF1.2 + xProps->setPropertyValue( ::rtl::OUString::createFromAscii( "Version" ), uno::makeAny( ODFVER_012_TEXT ) ); } catch( uno::Exception& ) { } + + if ( !aSaveOpt.IsUseSHA1InODF12() ) + { + aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; + aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; + } + if ( !aSaveOpt.IsUseBlowfishInODF12() ) + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; + } + + try + { + // set the encryption algorithms accordingly; + // the setting does not trigger encryption, + // it just provides the format for the case that contents should be encrypted + uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW ); + xEncr->setEncryptionAlgorithms( aEncryptionAlgs ); } + catch( uno::Exception& ) + { + const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); + } + } } } diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 3da1f374af1c..19169e90b984 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -29,6 +29,7 @@ #include "precompiled_sfx2.hxx" #include "arrdecl.hxx" +#include <map> #include <cppuhelper/implbase1.hxx> @@ -41,15 +42,9 @@ #include <com/sun/star/frame/XTitle.hpp> #include <vos/mutex.hxx> -#ifndef _SV_RESARY_HXX #include <tools/resary.hxx> -#endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <vcl/svapp.hxx> #include <svl/eitem.hxx> #include <tools/rtti.hxx> @@ -64,15 +59,11 @@ #include <sfx2/signaturestate.hxx> #include <sfx2/sfxmodelfactory.hxx> -#ifndef _BASIC_SBUNO_HXX #include <basic/sbuno.hxx> -#endif #include <svtools/sfxecode.hxx> #include <svtools/ehdl.hxx> #include <unotools/printwarningoptions.hxx> -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX #include <comphelper/processfactory.hxx> -#endif #include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/script/DocumentDialogLibraryContainer.hpp> @@ -132,8 +123,37 @@ DBG_NAME(SfxObjectShell) #define DocumentInfo #include "sfxslots.hxx" +namespace { + static WeakReference< XInterface > s_xCurrentComponent; +// remember all registered components for VBA compatibility, to be able to remove them on disposing the model +typedef ::std::map< XInterface*, ::rtl::OString > VBAConstantNameMap; +static VBAConstantNameMap s_aRegisteredVBAConstants; + +::rtl::OString lclGetVBAGlobalConstName( const Reference< XInterface >& rxComponent ) +{ + OSL_ENSURE( rxComponent.is(), "lclGetVBAGlobalConstName - missing component" ); + + VBAConstantNameMap::iterator aIt = s_aRegisteredVBAConstants.find( rxComponent.get() ); + if( aIt != s_aRegisteredVBAConstants.end() ) + return aIt->second; + + uno::Reference< beans::XPropertySet > xProps( rxComponent, uno::UNO_QUERY ); + if( xProps.is() ) try + { + ::rtl::OUString aConstName; + xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobalConstantName" ) ) ) >>= aConstName; + return ::rtl::OUStringToOString( aConstName, RTL_TEXTENCODING_ASCII_US ); + } + catch( uno::Exception& ) // not supported + { + } + return ::rtl::OString(); +} + +} // namespace + //========================================================================= @@ -164,14 +184,29 @@ void SAL_CALL SfxModelListener_Impl::notifyClosing( const com::sun::star::lang:: void SAL_CALL SfxModelListener_Impl::disposing( const com::sun::star::lang::EventObject& _rEvent ) throw ( com::sun::star::uno::RuntimeException ) { - // am I ThisComponent in AppBasic? ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + // am I ThisComponent in AppBasic? if ( SfxObjectShell::GetCurrentComponent() == _rEvent.Source ) { // remove ThisComponent reference from AppBasic SfxObjectShell::SetCurrentComponent( Reference< XInterface >() ); } + /* Remove VBA component from AppBasic. As every application registers its + own current component, the disposed component may not be the "current + component" of the SfxObjectShell. */ + if ( _rEvent.Source.is() ) + { + VBAConstantNameMap::iterator aIt = s_aRegisteredVBAConstants.find( _rEvent.Source.get() ); + if ( aIt != s_aRegisteredVBAConstants.end() ) + { + if ( BasicManager* pAppMgr = SFX_APP()->GetBasicManager() ) + pAppMgr->SetGlobalUNOConstant( aIt->second.getStr(), Any( Reference< XInterface >() ) ); + s_aRegisteredVBAConstants.erase( aIt ); + } + } + if ( !mpDoc->Get_Impl()->bClosing ) // GCC stuerzt ab, wenn schon im dtor, also vorher Flag abfragen mpDoc->DoClose(); @@ -908,8 +943,8 @@ sal_uInt16 SfxObjectShell::GetAutoStyleFilterIndex() void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComponent ) { - Reference< XInterface > xTest(s_xCurrentComponent); - if ( _rxComponent == xTest ) + Reference< XInterface > xOldCurrentComp(s_xCurrentComponent); + if ( _rxComponent == xOldCurrentComp ) // nothing to do return; // note that "_rxComponent.get() == s_xCurrentComponent.get().get()" is /sufficient/, but not @@ -920,7 +955,31 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); s_xCurrentComponent = _rxComponent; if ( pAppMgr ) - pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxComponent ) ); + { + // set "ThisComponent" for Basic + pAppMgr->SetGlobalUNOConstant( "ThisComponent", Any( _rxComponent ) ); + + // set new current component for VBA compatibility + if ( _rxComponent.is() ) + { + ::rtl::OString aVBAConstName = lclGetVBAGlobalConstName( _rxComponent ); + if ( aVBAConstName.getLength() > 0 ) + { + pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( _rxComponent ) ); + s_aRegisteredVBAConstants[ _rxComponent.get() ] = aVBAConstName; + } + } + // no new component passed -> remove last registered VBA component + else if ( xOldCurrentComp.is() ) + { + ::rtl::OString aVBAConstName = lclGetVBAGlobalConstName( xOldCurrentComp ); + if ( aVBAConstName.getLength() > 0 ) + { + pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( Reference< XInterface >() ) ); + s_aRegisteredVBAConstants.erase( xOldCurrentComp.get() ); + } + } + } } Reference< XInterface > SfxObjectShell::GetCurrentComponent() diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index 7da892ca89c9..92a56655a27d 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -110,7 +110,8 @@ public: // application members SfxFilterMatcher* pMatcher; - ResMgr* pLabelResMgr; + ResMgr* pBasicResMgr; + ResMgr* pSvtResMgr; SfxStatusDispatcher* pAppDispatch; SfxDocumentTemplates* pTemplates; diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index fd1327e423ca..c2680d702414 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/util/XURLTransformer.hpp> #endif #include <tools/urlobj.hxx> +#include <tools/diagnose_ex.h> #include <svl/macitem.hxx> #include <sfx2/appuno.hxx> #include <sfx2/objsh.hxx> @@ -842,14 +843,18 @@ void SfxGlobalEvents_Impl::implts_checkAndExecuteEventBindings(const css::docume // <- SAFE css::uno::Any aAny; - if (xEvents.is()) + if ( xEvents.is() && xEvents->hasByName( aEvent.EventName ) ) aAny = xEvents->getByName(aEvent.EventName); Execute(aAny, aEvent, 0); } - catch(const css::uno::RuntimeException& exRun) - { throw exRun; } - catch(const css::uno::Exception&) - {} + catch ( css::uno::RuntimeException const & ) + { + throw; + } + catch ( css::uno::Exception const & ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //----------------------------------------------------------------------------- diff --git a/svx/inc/galtheme.hrc b/svx/inc/galtheme.hrc index 483c397983ed..b0d656430864 100644 --- a/svx/inc/galtheme.hrc +++ b/svx/inc/galtheme.hrc @@ -43,7 +43,7 @@ #define RID_GALLERYSTR_THEME_MAPS (RID_GALLERYSTR_THEME_START + 12) #define RID_GALLERYSTR_THEME_PEOPLE (RID_GALLERYSTR_THEME_START + 13) #define RID_GALLERYSTR_THEME_SURFACES (RID_GALLERYSTR_THEME_START + 14) -#define RID_GALLERYSTR_THEME_HTMLBUTTONS (RID_GALLERYSTR_THEME_START + 15) +// free #define RID_GALLERYSTR_THEME_POWERPOINT (RID_GALLERYSTR_THEME_START + 16) #define RID_GALLERYSTR_THEME_RULERS (RID_GALLERYSTR_THEME_START + 17) #define RID_GALLERYSTR_THEME_SOUNDS (RID_GALLERYSTR_THEME_START + 18) diff --git a/svx/inc/svx/gallery.hxx b/svx/inc/svx/gallery.hxx index d87d93f8cc22..7edff48fd401 100644 --- a/svx/inc/svx/gallery.hxx +++ b/svx/inc/svx/gallery.hxx @@ -63,7 +63,7 @@ #define GALLERY_THEME_MAPS 12 #define GALLERY_THEME_PEOPLE 13 #define GALLERY_THEME_SURFACES 14 -#define GALLERY_THEME_HTMLBUTTONS 15 +// free #define GALLERY_THEME_POWERPOINT 16 #define GALLERY_THEME_RULERS 17 #define GALLERY_THEME_SOUNDS 18 diff --git a/svx/inc/svx/msdffdef.hxx b/svx/inc/svx/msdffdef.hxx index 92f00114edf4..d19757b9f8d0 100644 --- a/svx/inc/svx/msdffdef.hxx +++ b/svx/inc/svx/msdffdef.hxx @@ -579,6 +579,10 @@ enum DFF_TextHeader { #define DFF_PBit_Hidden 0x00000002 #define DFF_PBit_Print 0x00000001 +// properties of the second property set +#define DFF_Prop_metroBlob 937 // XML ZipPackage* + + //--------------------------------------------------------------------------- // Dreh- und Angelpunkt: der Shape-Typ //--------------------------------------------------------------------------- diff --git a/svx/inc/svx/sdr/properties/pageproperties.hxx b/svx/inc/svx/sdr/properties/pageproperties.hxx index d85686b3bc5b..9dbbc645d9be 100644 --- a/svx/inc/svx/sdr/properties/pageproperties.hxx +++ b/svx/inc/svx/sdr/properties/pageproperties.hxx @@ -45,6 +45,9 @@ namespace sdr // Do the ItemChange, may do special handling virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = 0); + // Called after ItemChange() is done for all items. + virtual void PostItemChange(const sal_uInt16 nWhich); + public: // basic constructor PageProperties(SdrObject& rObj); diff --git a/svx/inc/svx/sdr/properties/properties.hxx b/svx/inc/svx/sdr/properties/properties.hxx index 311c2ccfd1a5..99ebdfbb1be9 100644 --- a/svx/inc/svx/sdr/properties/properties.hxx +++ b/svx/inc/svx/sdr/properties/properties.hxx @@ -187,6 +187,10 @@ namespace sdr // default implementation returns 0 (zero) virtual sal_uInt32 getVersion() const; }; + + // checks the FillStyle item and removes unneeded Gradient, FillBitmap and Hatch items + void SVX_DLLPUBLIC CleanupFillProperties( SfxItemSet& rItemSet ); + } // end of namespace properties } // end of namespace sdr diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx index a32147a3032f..3c112bc57700 100644 --- a/svx/inc/svx/svdmodel.hxx +++ b/svx/inc/svx/svdmodel.hxx @@ -742,6 +742,7 @@ public: also during the runtime of the Undo() and Redo() methods. */ bool IsUndoEnabled() const; + void SetDrawingLayerPoolDefaults(); }; typedef tools::WeakReference< SdrModel > SdrModelWeakRef; diff --git a/svx/inc/svx/svdograf.hxx b/svx/inc/svx/svdograf.hxx index fa5b56e403e5..948115dff47e 100644 --- a/svx/inc/svx/svdograf.hxx +++ b/svx/inc/svx/svdograf.hxx @@ -148,6 +148,8 @@ public: // Keep ATM for SD. sal_Bool IsAnimated() const; sal_Bool IsEPS() const; + sal_Bool IsRenderGraphic() const; + sal_Bool HasRenderGraphic() const; sal_Bool IsSwappedOut() const; const MapMode& GetGrafPrefMapMode() const; @@ -225,4 +227,3 @@ public: }; #endif //_SVDOGRAF_HXX - diff --git a/svx/inc/svx/xdef.hxx b/svx/inc/svx/xdef.hxx index dd0fbd802291..9a06439f3738 100644 --- a/svx/inc/svx/xdef.hxx +++ b/svx/inc/svx/xdef.hxx @@ -36,7 +36,7 @@ |* \************************************************************************/ -#define COL_DEFAULT_SHAPE_FILLING RGB_COLORDATA( 0xCF, 0xE7, 0xE5 ) +#define COL_DEFAULT_SHAPE_FILLING RGB_COLORDATA( 0xCF, 0xE7, 0xF5 ) #define COL_DEFAULT_SHAPE_STROKE RGB_COLORDATA( 128, 128, 128 ) #define XATTR_START 1000 diff --git a/svx/inc/svx/xoutbmp.hxx b/svx/inc/svx/xoutbmp.hxx index 1d0fca8de220..6dd59dbd6e57 100644..100755 --- a/svx/inc/svx/xoutbmp.hxx +++ b/svx/inc/svx/xoutbmp.hxx @@ -43,6 +43,7 @@ #define XOUTBMP_CONTOUR_HORZ 0x00000001L #define XOUTBMP_CONTOUR_VERT 0x00000002L #define XOUTBMP_CONTOUR_EDGEDETECT 0x00000004L +#define XOUTBMP_DONT_ADD_EXTENSION 0x00000008L #define XOUTBMP_DONT_EXPAND_FILENAME 0x10000000L #define XOUTBMP_USE_GIF_IF_POSSIBLE 0x20000000L diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 6224373f9a15..a0c5f7dbcfb0 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -789,7 +789,7 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : case mso_sptCurvedLeftArrow : case mso_sptCurvedRightArrow : case mso_sptCurvedUpArrow : - case mso_sptCurvedDownArrow : nColorData = 0x2d000000; break; + case mso_sptCurvedDownArrow : nColorData = 0x20d00000; break; case mso_sptRibbon2 : nColorData = 0x30ee0000; break; case mso_sptRibbon : nColorData = 0x30ee0000; break; @@ -2002,7 +2002,7 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( sal_Bool bLineGeometryNeededOnl SdrObject* pRet = NULL; sal_uInt32 i; - if ( vObjectList.size() ) + if ( !vObjectList.empty() ) { const SfxItemSet& rCustomShapeSet = pCustomShapeObj->GetMergedItemSet(); Color aFillColor; @@ -2010,7 +2010,7 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( sal_Bool bLineGeometryNeededOnl sal_uInt32 nColorIndex = 0; // #i37011# remove invisible objects - if(vObjectList.size()) + if(!vObjectList.empty()) { std::vector< SdrPathObj* > vTempList; @@ -2092,7 +2092,7 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( sal_Bool bLineGeometryNeededOnl } // #i37011# - if(vObjectList.size()) + if(!vObjectList.empty()) { // copy remaining objects to pRet if(vObjectList.size() > 1L) diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx index 0af22d94334b..3fee313423b1 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx @@ -685,7 +685,7 @@ void FitTextOutlinesToShapeOutlines( const PolyPolygon& aOutlines2d, FWData& rFW std::vector< double > vDistances; vDistances.reserve( nPointCount ); CalcDistances( rOutlinePoly, vDistances ); - if ( vDistances.size() ) + if ( !vDistances.empty() ) { std::vector< FWParagraphData >::iterator aParagraphIter( aTextAreaIter->vParagraphs.begin() ); std::vector< FWParagraphData >::iterator aParagraphIEnd( aTextAreaIter->vParagraphs.end() ); @@ -816,7 +816,7 @@ void FitTextOutlinesToShapeOutlines( const PolyPolygon& aOutlines2d, FWData& rFW SdrObject* CreateSdrObjectFromParagraphOutlines( const FWData& rFWData, const SdrObject* pCustomShape ) { SdrObject* pRet = NULL; - if ( rFWData.vTextAreas.size() ) + if ( !rFWData.vTextAreas.empty() ) { pRet = new SdrObjGroup(); // SJ: not setting model, so we save a lot of broadcasting and the model is not modified any longer diff --git a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx index 2bf28c81ca18..e4f5738d531b 100644 --- a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx @@ -1186,30 +1186,29 @@ static const mso_CustomShape msoBentUpArrow = (SvxMSDffHandle*)mso_sptBentUpArrowHandle, sizeof( mso_sptBentUpArrowHandle ) / sizeof( SvxMSDffHandle ) }; - -static const SvxMSDffVertPair mso_sptCurvedDownVert[] = +static const SvxMSDffVertPair mso_sptCurvedRightVert[] = { - { 0, 0 }, { 3 MSO_I, 21 MSO_I }, { 0, 21600 }, { 4 MSO_I, 0 }, - { 0, 0 }, { 3 MSO_I, 21 MSO_I }, { 4 MSO_I, 0 }, { 17 MSO_I, 24 MSO_I }, - { 15 MSO_I, 0 }, { 1 MSO_I, 21 MSO_I }, { 17 MSO_I, 24 MSO_I }, { 15 MSO_I, 21600 }, - { 15 MSO_I, 0 }, { 1 MSO_I, 21 MSO_I }, { 7 MSO_I, 0 }, { 13 MSO_I, 2 MSO_I }, - { 14 MSO_I, 2 MSO_I }, { 8 MSO_I, 21600 }, { 12 MSO_I, 2 MSO_I }, - { 0, 0 }, { 3 MSO_I, 21 MSO_I }, { 11 MSO_I, 2 MSO_I }, { 17 MSO_I, 24 MSO_I }, - { 0, 0 }, { 3 MSO_I, 21 MSO_I }, { 17 MSO_I, 24 MSO_I }, { 4 MSO_I, 0 } + { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 22 MSO_I, 0 }, { 0, 4 MSO_I }, { 0, 15 MSO_I }, { 23 MSO_I, 1 MSO_I }, { 0, 7 MSO_I }, { 2 MSO_I, 13 MSO_I }, + { 2 MSO_I, 14 MSO_I }, { 22 MSO_I, 8 MSO_I }, { 2 MSO_I, 12 MSO_I }, + { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 2 MSO_I, 11 MSO_I }, { 26 MSO_I, 17 MSO_I }, { 0, 15 MSO_I }, { 23 MSO_I, 1 MSO_I }, { 26 MSO_I, 17 MSO_I }, { 22 MSO_I, 15 MSO_I }, + { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 22 MSO_I, 0 }, { 0, 4 MSO_I }, + { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 0, 4 MSO_I }, { 26 MSO_I, 17 MSO_I }, + { 0, 15 MSO_I }, { 23 MSO_I, 1 MSO_I }, { 26 MSO_I, 17 MSO_I }, { 22 MSO_I, 15 MSO_I } }; -static const sal_uInt16 mso_sptCurvedDownSegm[] = +static const sal_uInt16 mso_sptCurvedRightSegm[] = { + 0xa408, + 0x0003, 0xa508, - 0xa304, 0x6000, 0x8000, - 0xa604, - 0x0003, - 0xa308, + 0xa404, + 0xa304, + 0xa504, 0x6000, 0x8000 }; -static const SvxMSDffCalculationData mso_sptCurvedDownCalc[] = +static const SvxMSDffCalculationData mso_sptCurvedRightCalc[] = { { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }, @@ -1232,60 +1231,117 @@ static const SvxMSDffCalculationData mso_sptCurvedDownCalc[] = { 0x6000, { DFF_Prop_adjustValue, DFF_Prop_adjust2Value, 21600 } }, { 0x2001, { 0x412, 1, 2 } }, { 0xa000, { 0x411, 0, 0x413 } }, + { 0x0000, { 21600, 0, 0 } }, + { 0x0000, { 21600, 0, 0 } }, { 0x0001, { 21600, 2, 1 } }, { 0xa000, { 0x411, 0, 0x404 } }, - { 0x600f, { 0x416, 0x404, 21600 } }, - { 0x8000, { 21600, 0, 0x417 } }, + { 0x600f, { 0x418, 0x404, 21600 } }, + { 0x8000, { 21600, 0, 0x419 } }, { 0x2000, { 0x408, 128, 0 } }, { 0x2001, { 0x405, 1, 2 } }, { 0x2000, { 0x405, 0, 128 } }, { 0xe000, { DFF_Prop_adjustValue, 0x411, 0x40c } }, { 0x600f, { 0x414, 0x404, 21600 } }, { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }, - { 0x2001, { 0x41e, 1, 2 } }, + { 0x2001, { 0x420, 1, 2 } }, { 0x0001, { 21600, 21600, 1 } }, { 0x6001, { 0x409, 0x409, 1 } }, - { 0xa000, { 0x420, 0, 0x421 } }, - { 0x200d, { 0x422, 0, 0 } }, - { 0x2000, { 0x423, 21600, 0 } }, - { 0x8001, { 21600, 21600, 0x424 } }, - { 0x2000, { 0x425, 64, 0 } }, + { 0xa000, { 0x422, 0, 0x423 } }, + { 0x200d, { 0x424, 0, 0 } }, + { 0x2000, { 0x425, 21600, 0 } }, + { 0x8001, { 21600, 21600, 0x426 } }, + { 0x2000, { 0x427, 64, 0 } }, { 0x2001, { DFF_Prop_adjustValue, 1, 2 } }, - { 0x600f, { 0x41f, 0x427, 21600 } }, - { 0x8000, { 21600, 0, 0x428 } }, - { 0x2000, { 0x429, 64, 0 } }, + { 0x600f, { 0x421, 0x429, 21600 } }, + { 0x8000, { 21600, 0, 0x42a } }, + { 0x2000, { 0x42b, 64, 0 } }, { 0x2001, { 0x404, 1, 2 } }, - { 0xa000, { DFF_Prop_adjust2Value, 0, 0x42b } }, + { 0xa000, { DFF_Prop_adjust2Value, 0, 0x42d } }, { 0x0001, { 21600, 2195, 16384 } }, { 0x0001, { 21600, 14189, 16384 } } }; -static const sal_Int32 mso_sptCurvedDownDefault[] = +static const sal_Int32 mso_sptCurvedRightDefault[] = { 3, 12960, 19440, 14400 }; +static const SvxMSDffTextRectangles mso_sptCurvedRightTextRect[] = +{ + { { 47 MSO_I, 45 MSO_I }, { 48 MSO_I, 46 MSO_I } } +}; +static const SvxMSDffVertPair mso_sptCurvedRightGluePoints[] = +{ + { 0, 17 MSO_I }, { 2 MSO_I, 14 MSO_I }, { 22 MSO_I, 8 MSO_I }, { 2 MSO_I, 12 MSO_I }, { 22 MSO_I, 16 MSO_I } +}; +static const SvxMSDffHandle mso_sptCurvedRightHandles[] = +{ + { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL, + 21600, 0x100, 10800, 10800, 0, 10800, 3 + 40, 3 + 29 }, + { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL, + 21600, 0x101, 10800, 10800, 0, 10800, 3 + 27, 3 + 21 }, + { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL, + 0x102, 21600, 10800, 10800, 3 + 44, 3 + 22, 3375, 21600 } +}; +static const mso_CustomShape msoCurvedRightArrow = +{ + (SvxMSDffVertPair*)mso_sptCurvedRightVert, sizeof( mso_sptCurvedRightVert ) / sizeof( SvxMSDffVertPair ), + (sal_uInt16*)mso_sptCurvedRightSegm, sizeof( mso_sptCurvedRightSegm ) >> 1, + (SvxMSDffCalculationData*)mso_sptCurvedRightCalc, sizeof( mso_sptCurvedRightCalc ) / sizeof( SvxMSDffCalculationData ), + (sal_Int32*)mso_sptCurvedRightDefault, + (SvxMSDffTextRectangles*)mso_sptCurvedRightTextRect, sizeof( mso_sptCurvedRightTextRect ) / sizeof( SvxMSDffTextRectangles ), + 21600, 21600, + 0x80000000, 0x80000000, + (SvxMSDffVertPair*)mso_sptCurvedRightGluePoints, sizeof( mso_sptCurvedRightGluePoints ) / sizeof( SvxMSDffVertPair ), + (SvxMSDffHandle*)mso_sptCurvedRightHandles, sizeof( mso_sptCurvedRightHandles ) / sizeof( SvxMSDffHandle ) +}; + +static const SvxMSDffVertPair mso_sptCurvedDownVert[] = +{ + { 0, 0 }, { 3 MSO_I, 23 MSO_I }, { 0, 22 MSO_I }, { 4 MSO_I, 0 }, + { 15 MSO_I, 0 }, { 1 MSO_I, 23 MSO_I }, { 7 MSO_I, 0 }, { 13 MSO_I, 2 MSO_I }, + { 14 MSO_I, 2 MSO_I }, { 8 MSO_I, 22 MSO_I }, { 12 MSO_I, 2 MSO_I }, + { 0, 0 }, { 3 MSO_I, 23 MSO_I }, { 11 MSO_I, 2 MSO_I }, { 17 MSO_I, 26 MSO_I }, { 15 MSO_I, 0 }, + { 1 MSO_I, 23 MSO_I }, { 17 MSO_I, 26 MSO_I }, { 15 MSO_I, 22 MSO_I }, + { 0, 0 }, { 3 MSO_I, 23 MSO_I }, { 0, 22 MSO_I }, { 4 MSO_I, 0 }, + { 0, 0 }, { 3 MSO_I, 23 MSO_I }, { 4 MSO_I, 0 }, { 17 MSO_I, 26 MSO_I }, + { 15 MSO_I, 0 }, { 1 MSO_I, 23 MSO_I }, { 17 MSO_I, 26 MSO_I }, { 15 MSO_I, 22 MSO_I } +}; +static const sal_uInt16 mso_sptCurvedDownSegm[] = +{ + 0xa608, + 0x0003, + 0xa308, + 0x6000, + 0x8000, + 0xa604, + 0xa504, + 0xa304, + 0x6000, + 0x8000 +}; static const SvxMSDffTextRectangles mso_sptCurvedDownTextRect[] = { - { { 43 MSO_I, 45 MSO_I }, { 44 MSO_I, 46 MSO_I } } + { { 45 MSO_I, 47 MSO_I }, { 46 MSO_I, 48 MSO_I } } }; static const SvxMSDffVertPair mso_sptCurvedDownGluePoints[] = { - { 17 MSO_I, 0 }, { 16 MSO_I, 21600 }, { 12 MSO_I, 2 MSO_I }, { 8 MSO_I, 21600 }, { 14 MSO_I, 2 MSO_I } + { 17 MSO_I, 0 }, { 16 MSO_I, 22 MSO_I }, { 12 MSO_I, 2 MSO_I }, { 8 MSO_I, 22 MSO_I }, { 14 MSO_I, 2 MSO_I } }; static const SvxMSDffHandle mso_sptCurvedDownHandles[] = { { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL, - 0x100, 21600, 10800, 10800, 3 + 0x26, 3 + 0x1b, 0, 10800 }, - { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL, - 0x101, 21600, 10800, 10800, 3 + 0x19, 21600, 0, 10800 }, - { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL, - 21600, 0x102, 10800, 10800, 3375, 21600, 3 + 0x2a, 21600 } + 0x100, 21600, 10800, 10800, 3 + 40, 3 + 29, 0, 10800 }, + { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL, + 0x101, 21600, 10800, 10800, 3 + 27, 3 + 21, 0, 10800 }, + { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL, + 21600, 0x102, 10800, 10800, 3375, 21600, 3 + 44, 3 + 22 } }; + static const mso_CustomShape msoCurvedDownArrow = { (SvxMSDffVertPair*)mso_sptCurvedDownVert, sizeof( mso_sptCurvedDownVert ) / sizeof( SvxMSDffVertPair ), (sal_uInt16*)mso_sptCurvedDownSegm, sizeof( mso_sptCurvedDownSegm ) >> 1, - (SvxMSDffCalculationData*)mso_sptCurvedDownCalc, sizeof( mso_sptCurvedDownCalc ) / sizeof( SvxMSDffCalculationData ), - (sal_Int32*)mso_sptCurvedDownDefault, + (SvxMSDffCalculationData*)mso_sptCurvedRightCalc, sizeof( mso_sptCurvedRightCalc ) / sizeof( SvxMSDffCalculationData ), + (sal_Int32*)mso_sptCurvedRightDefault, (SvxMSDffTextRectangles*)mso_sptCurvedDownTextRect, sizeof( mso_sptCurvedDownTextRect ) / sizeof( SvxMSDffTextRectangles ), 21600, 21600, 0x80000000, 0x80000000, @@ -1296,11 +1352,13 @@ static const mso_CustomShape msoCurvedDownArrow = static const SvxMSDffVertPair mso_sptCurvedUpVert[] = { { 0, 22 MSO_I }, { 3 MSO_I, 21 MSO_I }, { 0, 0 }, { 4 MSO_I, 21 MSO_I }, - { 14 MSO_I, 22 MSO_I }, { 1 MSO_I, 21 MSO_I }, { 7 MSO_I, 21 MSO_I }, { 12 MSO_I, 2 MSO_I }, - { 13 MSO_I, 2 MSO_I }, { 8 MSO_I, 0 }, { 11 MSO_I, 2 MSO_I }, + { 14 MSO_I, 22 MSO_I }, { 1 MSO_I, 21 MSO_I }, { 7 MSO_I, 21 MSO_I }, + { 12 MSO_I, 2 MSO_I }, { 13 MSO_I, 2 MSO_I }, { 8 MSO_I, 0 }, { 11 MSO_I, 2 MSO_I }, { 0, 22 MSO_I }, { 3 MSO_I, 21 MSO_I }, { 10 MSO_I, 2 MSO_I }, { 16 MSO_I, 24 MSO_I }, { 14 MSO_I, 22 MSO_I }, { 1 MSO_I, 21 MSO_I }, { 16 MSO_I, 24 MSO_I }, { 14 MSO_I, 0 }, - { 14 MSO_I, 22 MSO_I }, { 1 MSO_I, 21 MSO_I }, { 7 MSO_I, 21 MSO_I }, { 16 MSO_I, 24 MSO_I } + { 0, 22 MSO_I }, { 3 MSO_I, 21 MSO_I }, { 0, 0 }, { 4 MSO_I, 21 MSO_I }, + { 14 MSO_I, 22 MSO_I }, { 1 MSO_I, 21 MSO_I }, { 7 MSO_I, 21 MSO_I }, { 16 MSO_I, 24 MSO_I }, + { 14 MSO_I, 22 MSO_I }, { 1 MSO_I, 21 MSO_I }, { 16 MSO_I, 24 MSO_I }, { 14 MSO_I, 0 } }; static const sal_uInt16 mso_sptCurvedUpSegm[] = { @@ -1309,8 +1367,10 @@ static const sal_uInt16 mso_sptCurvedUpSegm[] = 0xa508, 0x6000, 0x8000, - 0xa604, - 0xaa00, + 0xa404, + 0xa508, + 0xa504, + 0x6000, 0x8000 }; static const SvxMSDffCalculationData mso_sptCurvedUpCalc[] = @@ -1395,116 +1455,16 @@ static const mso_CustomShape msoCurvedUpArrow = (SvxMSDffHandle*)mso_sptCurvedUpHandles, sizeof( mso_sptCurvedUpHandles ) / sizeof( SvxMSDffHandle ) }; -static const SvxMSDffVertPair mso_sptCurvedRightVert[] = -{ - { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 22 MSO_I, 0 }, { 0, 4 MSO_I }, { 0, 15 MSO_I }, { 23 MSO_I, 1 MSO_I }, { 0, 7 MSO_I }, { 2 MSO_I, 13 MSO_I }, - { 2 MSO_I, 14 MSO_I }, { 22 MSO_I, 8 MSO_I }, { 2 MSO_I, 12 MSO_I }, - { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 2 MSO_I, 11 MSO_I }, { 26 MSO_I, 17 MSO_I }, { 0, 15 MSO_I }, { 23 MSO_I, 1 MSO_I }, { 26 MSO_I, 17 MSO_I }, { 22 MSO_I, 15 MSO_I }, - { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 0, 4 MSO_I }, { 26 MSO_I, 17 MSO_I } -}; -static const sal_uInt16 mso_sptCurvedRightSegm[] = -{ - 0xa408, - 0x0003, - 0xa508, - 0x6000, - 0x8000, - 0xa404, - 0xaa00, - 0x8000 -}; -static const SvxMSDffCalculationData mso_sptCurvedRightCalc[] = -{ - { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, - { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }, - { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } }, - { 0xa000, { DFF_Prop_adjustValue, 21600, DFF_Prop_adjust2Value } }, - { 0x2001, { 0x403, 1, 2 } }, - { 0x6000, { DFF_Prop_adjust2Value, DFF_Prop_adjust2Value, 21600 } }, - { 0xe000, { 0x405, DFF_Prop_adjust2Value, DFF_Prop_adjustValue } }, - { 0x2001, { 0x406, 1, 2 } }, - { 0x4002, { 21600, DFF_Prop_adjustValue, 0 } }, - { 0x8000, { 21600, 0, DFF_Prop_adjust3Value } }, - { 0xa00f, { 0x409, 21600, 0x404 } }, - { 0x6000, { 0x404, 0x40a, 0 } }, - { 0x6000, { 0x40b, DFF_Prop_adjust2Value, 21600 } }, - { 0x6000, { 0x407, 0x40a, 0 } }, - { 0xa000, { 0x40c, 21600, DFF_Prop_adjustValue } }, - { 0xa000, { 0x405, 0, DFF_Prop_adjustValue } }, - { 0x2001, { 0x40f, 1, 2 } }, - { 0x6002, { 0x404, 0x407, 0 } }, - { 0x6000, { DFF_Prop_adjustValue, DFF_Prop_adjust2Value, 21600 } }, - { 0x2001, { 0x412, 1, 2 } }, - { 0xa000, { 0x411, 0, 0x413 } }, - { 0x0000, { 21600, 0, 0 } }, - { 0x0000, { 21600, 0, 0 } }, - { 0x0001, { 21600, 2, 1 } }, - { 0xa000, { 0x411, 0, 0x404 } }, - { 0x600f, { 0x418, 0x404, 21600 } }, - { 0x8000, { 21600, 0, 0x419 } }, - { 0x2000, { 0x408, 128, 0 } }, - { 0x2001, { 0x405, 1, 2 } }, - { 0x2000, { 0x405, 0, 128 } }, - { 0xe000, { DFF_Prop_adjustValue, 0x411, 0x40c } }, - { 0x600f, { 0x414, 0x404, 21600 } }, - { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }, - { 0x2001, { 0x420, 1, 2 } }, - { 0x0001, { 21600, 21600, 1 } }, - { 0x6001, { 0x409, 0x409, 1 } }, - { 0xa000, { 0x422, 0, 0x423 } }, - { 0x200d, { 0x424, 0, 0 } }, - { 0x2000, { 0x425, 21600, 0 } }, - { 0x8001, { 21600, 21600, 0x426 } }, - { 0x2000, { 0x427, 64, 0 } }, - { 0x2001, { DFF_Prop_adjustValue, 1, 2 } }, - { 0x600f, { 0x421, 0x429, 21600 } }, - { 0x8000, { 21600, 0, 0x42a } }, - { 0x2000, { 0x42b, 64, 0 } }, - { 0x2001, { 0x404, 1, 2 } }, - { 0xa000, { DFF_Prop_adjust2Value, 0, 0x42d } }, - { 0x0001, { 21600, 2195, 16384 } }, - { 0x0001, { 21600, 14189, 16384 } } -}; -static const sal_Int32 mso_sptCurvedRightDefault[] = -{ - 3, 12960, 19440, 14400 -}; -static const SvxMSDffTextRectangles mso_sptCurvedRightTextRect[] = -{ - { { 47 MSO_I, 45 MSO_I }, { 48 MSO_I, 46 MSO_I } } -}; -static const SvxMSDffVertPair mso_sptCurvedRightGluePoints[] = -{ - { 0, 17 MSO_I }, { 2 MSO_I, 14 MSO_I }, { 22 MSO_I, 8 MSO_I }, { 2 MSO_I, 12 MSO_I }, { 22 MSO_I, 16 MSO_I } -}; -static const SvxMSDffHandle mso_sptCurvedRightHandles[] = -{ - { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL, - 21600, 0x100, 10800, 10800, 0, 10800, 3 + 40, 3 + 29 }, - { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL, - 21600, 0x101, 10800, 10800, 0, 10800, 3 + 27, 3 + 21 }, - { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL, - 0x102, 21600, 10800, 10800, 3 + 44, 3 + 22, 3375, 21600 } -}; -static const mso_CustomShape msoCurvedRightArrow = -{ - (SvxMSDffVertPair*)mso_sptCurvedRightVert, sizeof( mso_sptCurvedRightVert ) / sizeof( SvxMSDffVertPair ), - (sal_uInt16*)mso_sptCurvedRightSegm, sizeof( mso_sptCurvedRightSegm ) >> 1, - (SvxMSDffCalculationData*)mso_sptCurvedRightCalc, sizeof( mso_sptCurvedRightCalc ) / sizeof( SvxMSDffCalculationData ), - (sal_Int32*)mso_sptCurvedRightDefault, - (SvxMSDffTextRectangles*)mso_sptCurvedRightTextRect, sizeof( mso_sptCurvedRightTextRect ) / sizeof( SvxMSDffTextRectangles ), - 21600, 21600, - 0x80000000, 0x80000000, - (SvxMSDffVertPair*)mso_sptCurvedRightGluePoints, sizeof( mso_sptCurvedRightGluePoints ) / sizeof( SvxMSDffVertPair ), - (SvxMSDffHandle*)mso_sptCurvedRightHandles, sizeof( mso_sptCurvedRightHandles ) / sizeof( SvxMSDffHandle ) -}; - static const SvxMSDffVertPair mso_sptCurvedLeftVert[] = { - { 22 MSO_I, 0 }, { 21 MSO_I, 3 MSO_I }, { 0, 0 }, { 21 MSO_I, 4 MSO_I }, { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 21 MSO_I, 7 MSO_I }, { 2 MSO_I, 12 MSO_I }, + { 22 MSO_I, 0 }, { 21 MSO_I, 3 MSO_I }, { 0, 0 }, { 21 MSO_I, 4 MSO_I }, + { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 21 MSO_I, 7 MSO_I }, { 2 MSO_I, 12 MSO_I }, { 2 MSO_I, 13 MSO_I }, { 0, 8 MSO_I }, { 2 MSO_I, 11 MSO_I }, - { 22 MSO_I, 0 }, { 21 MSO_I, 3 MSO_I }, { 2 MSO_I, 10 MSO_I }, { 24 MSO_I, 16 MSO_I }, { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 24 MSO_I, 16 MSO_I }, { 0, 14 MSO_I }, - { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 21 MSO_I, 7 MSO_I }, { 24 MSO_I, 16 MSO_I } + { 22 MSO_I, 0 }, { 21 MSO_I, 3 MSO_I }, { 2 MSO_I, 10 MSO_I }, { 24 MSO_I, 16 MSO_I }, + { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 24 MSO_I, 16 MSO_I }, { 0, 14 MSO_I }, + { 22 MSO_I, 0 }, { 21 MSO_I, 3 MSO_I }, { 0, 0 }, { 21 MSO_I, 4 MSO_I }, + { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 21 MSO_I, 7 MSO_I }, { 24 MSO_I, 16 MSO_I }, + { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 24 MSO_I, 16 MSO_I }, { 0, 14 MSO_I } }; static const sal_uInt16 mso_sptCurvedLeftSegm[] = { @@ -1513,62 +1473,11 @@ static const sal_uInt16 mso_sptCurvedLeftSegm[] = 0xa308, 0x6000, 0x8000, - 0xa404, - 0xaa00, + 0xa604, + 0xa308, + 0x6000, 0x8000 }; -static const SvxMSDffCalculationData mso_sptCurvedLeftCalc[] = -{ - { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, - { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }, - { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } }, - { 0xa000, { DFF_Prop_adjustValue, 21600, DFF_Prop_adjust2Value } }, - { 0x2001, { 0x403, 1, 2 } }, - { 0x6000, { DFF_Prop_adjust2Value, DFF_Prop_adjust2Value, 21600 } }, - { 0xe000, { 0x405, DFF_Prop_adjust2Value, DFF_Prop_adjustValue } }, - { 0x2001, { 0x406, 1, 2 } }, - { 0x4002, { 21600, DFF_Prop_adjustValue, 0 } }, - { 0xa00f, { DFF_Prop_adjust3Value, 21600, 0x404 } }, - { 0x6000, { 0x404, 0x409, 0 } }, - { 0x6000, { 0x40a, DFF_Prop_adjust2Value, 21600 } }, - { 0x6000, { 0x407, 0x409, 0 } }, - { 0xa000, { 0x40b, 21600, DFF_Prop_adjustValue } }, - { 0xa000, { 0x405, 0, DFF_Prop_adjustValue } }, - { 0x2001, { 0x40e, 1, 2 } }, - { 0x6002, { 0x404, 0x407, 0 } }, - { 0x6000, { DFF_Prop_adjustValue, DFF_Prop_adjust2Value, 21600 } }, - { 0x2001, { 0x411, 1, 2 } }, - { 0xa000, { 0x410, 0, 0x412 } }, - { 0x0000, { 21600, 0, 0 } }, - { 0x0000, { 21600, 0, 0 } }, - { 0x0000, { 0, 0, 21600 } }, - { 0xa000, { 0x410, 0, 0x404 } }, - { 0x600f, { 0x417, 0x404, 21600 } }, - { 0x2000, { 0x408, 128, 0 } }, - { 0x2001, { 0x405, 1, 2 } }, - { 0x2000, { 0x405, 0, 128 } }, - { 0xe000, { DFF_Prop_adjustValue, 0x410, 0x40b } }, - { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }, - { 0x2001, { 0x41d, 1, 2 } }, - { 0x0001, { 21600, 21600, 1 } }, - { 0x6001, { DFF_Prop_adjust3Value, DFF_Prop_adjust3Value, 1 } }, - { 0xa000, { 0x41f, 0, 0x420 } }, - { 0x200d, { 0x421, 0, 0 } }, - { 0x2000, { 0x422, 21600, 0 } }, - { 0x8001, { 21600, 21600, 0x423 } }, - { 0x2000, { 0x424, 64, 0 } }, - { 0x2001, { DFF_Prop_adjustValue, 1, 2 } }, - { 0x600f, { 0x41e, 0x426, 21600 } }, - { 0x2000, { 0x427, 0, 64 } }, - { 0x2001, { 0x404, 1, 2 } }, - { 0xa000, { DFF_Prop_adjust2Value, 0, 0x429 } }, - { 0x0001, { 21600, 2195, 16384 } }, - { 0x0001, { 21600, 14189, 16384 } } -}; -static const sal_Int32 mso_sptCurvedLeftDefault[] = -{ - 3, 12960, 19440, 7200 -}; static const SvxMSDffTextRectangles mso_sptCurvedLeftTextRect[] = { { { 43 MSO_I, 41 MSO_I }, { 44 MSO_I, 42 MSO_I } } @@ -1590,8 +1499,8 @@ static const mso_CustomShape msoCurvedLeftArrow = { (SvxMSDffVertPair*)mso_sptCurvedLeftVert, sizeof( mso_sptCurvedLeftVert ) / sizeof( SvxMSDffVertPair ), (sal_uInt16*)mso_sptCurvedLeftSegm, sizeof( mso_sptCurvedLeftSegm ) >> 1, - (SvxMSDffCalculationData*)mso_sptCurvedLeftCalc, sizeof( mso_sptCurvedLeftCalc ) / sizeof( SvxMSDffCalculationData ), - (sal_Int32*)mso_sptCurvedLeftDefault, + (SvxMSDffCalculationData*)mso_sptCurvedUpCalc, sizeof( mso_sptCurvedUpCalc ) / sizeof( SvxMSDffCalculationData ), + (sal_Int32*)mso_sptCurvedUpDefault, (SvxMSDffTextRectangles*)mso_sptCurvedLeftTextRect, sizeof( mso_sptCurvedLeftTextRect ) / sizeof( SvxMSDffTextRectangles ), 21600, 21600, 0x80000000, 0x80000000, @@ -1599,10 +1508,6 @@ static const mso_CustomShape msoCurvedLeftArrow = (SvxMSDffHandle*)mso_sptCurvedLeftHandles, sizeof( mso_sptCurvedLeftHandles ) / sizeof( SvxMSDffHandle ) }; - - - - static const SvxMSDffVertPair mso_sptStripedRightArrowVert[] = // adjustment1 : x 3375 - 21600 { // adjustment2 : y 0 - 10800 { 3375, 0 MSO_I }, { 1 MSO_I, 0 MSO_I }, { 1 MSO_I, 0 }, { 21600, 10800 }, diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx index b6b8ca387969..006d288dfc47 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -1038,6 +1038,9 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) default: { + OSL_ENSURE( pAction->GetType() != META_RENDERGRAPHIC_ACTION, + "META_RENDERGRAPHIC_ACTION currently not supported at masking" ); + pAction->Duplicate(); aMtf.AddAction( pAction ); } diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx index ee59f6ce924d..b0dc050d6017 100644 --- a/svx/source/dialog/dlgctl3d.cxx +++ b/svx/source/dialog/dlgctl3d.cxx @@ -510,7 +510,7 @@ void Svx3DLightControl::TrySelection(Point aPosPixel) std::vector< const E3dCompoundObject* > aResult; getAllHit3DObjectsSortedFrontToBack(aPoint, *mpScene, aResult); - if(aResult.size()) + if(!aResult.empty()) { // exclude expansion object which will be part of // the hits. It's invisible, but for HitTest, it's included diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 2ff40610fa77..29eac2ab48d1 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -1569,7 +1569,7 @@ void FmXFormShell::ExecuteSearch() aContextNames.swap( aValidContexts ); } - if (m_aSearchForms.size() == 0) + if (m_aSearchForms.empty() ) { // es gibt keine Controls, die alle Bedingungen fuer eine Suche erfuellen ErrorBox(NULL, WB_OK, SVX_RESSTR(RID_STR_NODATACONTROLS)).Execute(); return; @@ -2571,7 +2571,7 @@ IMPL_LINK(FmXFormShell, OnSearchContextRequest, FmSearchContext*, pfmscContextIn strFieldList.EraseTrailingChars(';'); sFieldDisplayNames.EraseTrailingChars(';'); - if (!pfmscContextInfo->arrFields.size()) + if (pfmscContextInfo->arrFields.empty()) { pfmscContextInfo->arrFields.clear(); pfmscContextInfo->xCursor = NULL; @@ -3741,7 +3741,7 @@ void FmXFormShell::viewDeactivated( FmFormView& _rCurrentView, sal_Bool _bDeacti // move all events from our queue to a new one, omit the events for the deactivated // page ::std::queue< FmLoadAction > aNewEvents; - while ( m_aLoadingPages.size() ) + while ( !m_aLoadingPages.empty() ) { FmLoadAction aAction = m_aLoadingPages.front(); m_aLoadingPages.pop(); diff --git a/svx/source/gallery2/codec.cxx b/svx/source/gallery2/codec.cxx index 3306e7896c5d..e995e1937d9c 100644 --- a/svx/source/gallery2/codec.cxx +++ b/svx/source/gallery2/codec.cxx @@ -31,20 +31,26 @@ #include <tools/stream.hxx> #include <tools/zcodec.hxx> #include "codec.hxx" +#include <tools/debug.hxx> // ---------------- // - GalleryCodec - // ---------------- +DBG_NAME(GalleryCodec) GalleryCodec::GalleryCodec( SvStream& rIOStm ) : rStm( rIOStm ) { + DBG_CTOR(GalleryCodec,NULL); + } // ----------------------------------------------------------------------------- GalleryCodec::~GalleryCodec() { + + DBG_DTOR(GalleryCodec,NULL); } // ----------------------------------------------------------------------------- diff --git a/svx/source/gallery2/galbrws.cxx b/svx/source/gallery2/galbrws.cxx index 5d4e4297f0a4..5cd82383e9d5 100644 --- a/svx/source/gallery2/galbrws.cxx +++ b/svx/source/gallery2/galbrws.cxx @@ -57,16 +57,21 @@ public: }; // ----------------------------------------------------------------------------- +DBG_NAME(GallerySplitter) GallerySplitter::GallerySplitter( Window* pParent, const ResId& rResId ) : Splitter( pParent, rResId ) { + DBG_CTOR(GallerySplitter,NULL); + } // ----------------------------------------------------------------------------- GallerySplitter::~GallerySplitter() { + + DBG_DTOR(GallerySplitter,NULL); } // ----------------------------------------------------------------------------- @@ -80,10 +85,13 @@ void GallerySplitter::DataChanged( const DataChangedEvent& rDCEvt ) // ------------------------- // - SvxGalleryChildWindow - // ------------------------- +DBG_NAME(GalleryChildWindow) GalleryChildWindow::GalleryChildWindow( Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ) : SfxChildWindow( _pParent, nId ) { + DBG_CTOR(GalleryChildWindow,NULL); + pWindow = new GalleryBrowser( pBindings, this, _pParent, GAL_RESID( RID_SVXDLG_GALLERYBROWSER ) ); eChildAlignment = SFX_ALIGN_TOP; ( (GalleryBrowser*) pWindow )->Initialize( pInfo ); @@ -93,6 +101,8 @@ GalleryChildWindow::GalleryChildWindow( Window* _pParent, sal_uInt16 nId, SfxBin GalleryChildWindow::~GalleryChildWindow() { + + DBG_DTOR(GalleryChildWindow,NULL); } // ----------------------------------------------------------------------------- @@ -102,11 +112,14 @@ SFX_IMPL_DOCKINGWINDOW( GalleryChildWindow, SID_GALLERY ) // ------------------ // - GalleryBrowser - // ------------------ +DBG_NAME(GalleryBrowser) GalleryBrowser::GalleryBrowser( SfxBindings* _pBindings, SfxChildWindow* pCW, Window* pParent, const ResId& rResId ) : SfxDockingWindow( _pBindings, pCW, pParent, rResId ) { + DBG_CTOR(GalleryBrowser,NULL); + mpGallery = Gallery::GetGalleryInstance(); mpBrowser1 = new GalleryBrowser1( this, GAL_RESID( GALLERY_BROWSER1 ), mpGallery ); mpSplitter = new GallerySplitter( this, GAL_RESID( GALLERY_SPLITTER ) ); @@ -132,6 +145,8 @@ GalleryBrowser::~GalleryBrowser() delete mpBrowser2; delete mpSplitter; delete mpBrowser1; + + DBG_DTOR(GalleryBrowser,NULL); } // ----------------------------------------------------------------------------- diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx index 3704262833ed..0836be979866 100644 --- a/svx/source/gallery2/galbrws1.cxx +++ b/svx/source/gallery2/galbrws1.cxx @@ -57,16 +57,21 @@ using namespace ::com::sun::star; // ----------------- // - GalleryButton - // ----------------- +DBG_NAME(GalleryButton) GalleryButton::GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits ) : PushButton( pParent, nWinBits ) { + DBG_CTOR(GalleryButton,NULL); + } // ----------------------------------------------------------------------------- GalleryButton::~GalleryButton() { + + DBG_DTOR(GalleryButton,NULL); } // ----------------------------------------------------------------------------- @@ -80,10 +85,13 @@ void GalleryButton::KeyInput( const KeyEvent& rKEvt ) // ----------------------- // - GalleryThemeListBox - // ----------------------- +DBG_NAME(GalleryThemeListBox) GalleryThemeListBox::GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits ) : ListBox( pParent, nWinBits ) { + DBG_CTOR(GalleryThemeListBox,NULL); + InitSettings(); } @@ -91,6 +99,8 @@ GalleryThemeListBox::GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWin GalleryThemeListBox::~GalleryThemeListBox() { + + DBG_DTOR(GalleryThemeListBox,NULL); } // ------------------------------------------------------------------------ @@ -139,6 +149,7 @@ long GalleryThemeListBox::PreNotify( NotifyEvent& rNEvt ) // ------------------- // - GalleryBrowser1 - // ------------------- +DBG_NAME(GalleryBrowser1) GalleryBrowser1::GalleryBrowser1( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery ) : Control ( pParent, rResId ), @@ -152,6 +163,8 @@ GalleryBrowser1::GalleryBrowser1( GalleryBrowser* pParent, const ResId& rResId, aImgReadOnly ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_READONLY ) ), aImgImported ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_IMPORTED ) ) { + DBG_CTOR(GalleryBrowser1,NULL); + StartListening( *mpGallery ); maNewTheme.SetHelpId( HID_GALLERY_NEWTHEME ); @@ -183,6 +196,8 @@ GalleryBrowser1::~GalleryBrowser1() mpThemes = NULL; delete mpExchangeData; mpExchangeData = NULL; + + DBG_DTOR(GalleryBrowser1,NULL); } // ----------------------------------------------------------------------------- @@ -258,9 +273,8 @@ void GalleryBrowser1::ImplFillExchangeData( const GalleryTheme* pThm, ExchangeDa // ----------------------------------------------------------------------------- -::std::vector< sal_uInt16 > GalleryBrowser1::ImplGetExecuteVector() +void GalleryBrowser1::ImplGetExecuteVector(::std::vector< sal_uInt16 >& o_aExec) { - ::std::vector< sal_uInt16 > aExecVector; GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this ); if( pTheme ) @@ -284,23 +298,21 @@ void GalleryBrowser1::ImplFillExchangeData( const GalleryTheme* pThm, ExchangeDa bUpdateAllowed = bRenameAllowed = bRemoveAllowed = sal_True; if( bUpdateAllowed && pTheme->GetObjectCount() ) - aExecVector.push_back( MN_ACTUALIZE ); + o_aExec.push_back( MN_ACTUALIZE ); if( bRenameAllowed ) - aExecVector.push_back( MN_RENAME ); + o_aExec.push_back( MN_RENAME ); if( bRemoveAllowed ) - aExecVector.push_back( MN_DELETE ); + o_aExec.push_back( MN_DELETE ); if( bIdDialog && !pTheme->IsReadOnly() && !pTheme->IsImported() ) - aExecVector.push_back( MN_ASSIGN_ID ); + o_aExec.push_back( MN_ASSIGN_ID ); - aExecVector.push_back( MN_PROPERTIES ); + o_aExec.push_back( MN_PROPERTIES ); mpGallery->ReleaseTheme( pTheme, *this ); } - - return aExecVector; } // ----------------------------------------------------------------------------- @@ -587,7 +599,8 @@ sal_Bool GalleryBrowser1::KeyInput( const KeyEvent& rKEvt, Window* pWindow ) if( !bRet ) { - ::std::vector< sal_uInt16 > aExecVector( ImplGetExecuteVector() ); + ::std::vector< sal_uInt16 > aExecVector; + ImplGetExecuteVector(aExecVector); sal_uInt16 nExecuteId = 0; sal_Bool bMod1 = rKEvt.GetKeyCode().IsMod1(); @@ -651,9 +664,10 @@ sal_Bool GalleryBrowser1::KeyInput( const KeyEvent& rKEvt, Window* pWindow ) IMPL_LINK( GalleryBrowser1, ShowContextMenuHdl, void*, EMPTYARG ) { - ::std::vector< sal_uInt16 > aExecVector( ImplGetExecuteVector() ); + ::std::vector< sal_uInt16 > aExecVector; + ImplGetExecuteVector(aExecVector); - if( aExecVector.size() ) + if( !aExecVector.empty() ) { PopupMenu aMenu( GAL_RESID( RID_SVXMN_GALLERY1 ) ); diff --git a/svx/source/gallery2/galbrws1.hxx b/svx/source/gallery2/galbrws1.hxx index d05187d4c856..d6078a205042 100644 --- a/svx/source/gallery2/galbrws1.hxx +++ b/svx/source/gallery2/galbrws1.hxx @@ -101,7 +101,7 @@ private: void ImplAdjustControls(); sal_uIntPtr ImplInsertThemeEntry( const GalleryThemeEntry* pEntry ); void ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData ); - ::std::vector< sal_uInt16 > ImplGetExecuteVector(); + void ImplGetExecuteVector(::std::vector< sal_uInt16 >& o_aExec); void ImplExecute( sal_uInt16 nId ); void ImplGalleryThemeProperties( const String & rThemeName, bool bCreateNew ); void ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew ); diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx index 2fff76ba0c76..681ce3335df1 100644 --- a/svx/source/gallery2/galbrws2.cxx +++ b/svx/source/gallery2/galbrws2.cxx @@ -92,12 +92,15 @@ public: }; // ------------------------------------------------------------------------ +DBG_NAME(GalleryBackgroundPopup) GalleryBackgroundPopup::GalleryBackgroundPopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos ) : SfxControllerItem ( SID_GALLERY_BG_BRUSH, SfxViewFrame::Current()->GetBindings() ), mpTheme ( pTheme ), mnObjectPos ( nObjectPos ) { + DBG_CTOR(GalleryBackgroundPopup,NULL); + SfxViewFrame::Current()->GetBindings().Update( SID_GALLERY_BG_BRUSH ); RemoveDisabledEntries(); } @@ -106,6 +109,8 @@ GalleryBackgroundPopup::GalleryBackgroundPopup( const GalleryTheme* pTheme, sal_ GalleryBackgroundPopup::~GalleryBackgroundPopup() { + + DBG_DTOR(GalleryBackgroundPopup,NULL); } // ------------------------------------------------------------------------ @@ -172,6 +177,7 @@ public: }; // ------------------------------------------------------------------------ +DBG_NAME(GalleryThemePopup) GalleryThemePopup::GalleryThemePopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos, sal_Bool bPreview ) : PopupMenu ( GAL_RESID( RID_SVXMN_GALLERY2 ) ), @@ -181,6 +187,8 @@ GalleryThemePopup::GalleryThemePopup( const GalleryTheme* pTheme, sal_uIntPtr nO mnObjectPos ( nObjectPos ), mbPreview ( bPreview ) { + DBG_CTOR(GalleryThemePopup,NULL); + const SgaObjKind eObjKind = mpTheme->GetObjectKind( mnObjectPos ); PopupMenu* pAddMenu = GetPopupMenu( MN_ADDMENU ); SfxBindings& rBindings = SfxViewFrame::Current()->GetBindings(); @@ -259,6 +267,8 @@ GalleryThemePopup::GalleryThemePopup( const GalleryTheme* pTheme, sal_uIntPtr nO GalleryThemePopup::~GalleryThemePopup() { + + DBG_DTOR(GalleryThemePopup,NULL); } // ------------------------------------------------------------------------ @@ -279,16 +289,21 @@ void GalleryThemePopup::StateChanged( sal_uInt16 nSID, SfxItemState eState, cons // ------------------ // - GalleryToolBox - // ------------------ +DBG_NAME(GalleryToolBox) GalleryToolBox::GalleryToolBox( GalleryBrowser2* pParent ) : ToolBox( pParent, WB_TABSTOP ) { + DBG_CTOR(GalleryToolBox,NULL); + } // ------------------------------------------------------------------------ GalleryToolBox::~GalleryToolBox() { + + DBG_DTOR(GalleryToolBox,NULL); } // ------------------------------------------------------------------------ @@ -302,6 +317,7 @@ void GalleryToolBox::KeyInput( const KeyEvent& rKEvt ) // ------------------- // - GalleryBrowser2 - // ------------------- +DBG_NAME(GalleryBrowser2) GalleryBrowser2::GalleryBrowser2( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery ) : Control ( pParent, rResId ), @@ -318,6 +334,8 @@ GalleryBrowser2::GalleryBrowser2( GalleryBrowser* pParent, const ResId& rResId, meLastMode ( GALLERYBROWSERMODE_NONE ), mbCurActionIsLinkage( sal_False ) { + DBG_CTOR(GalleryBrowser2,NULL); + Image aDummyImage; const Link aSelectHdl( LINK( this, GalleryBrowser2, SelectObjectHdl ) ); Font aInfoFont( maInfoBar.GetControlFont() ); @@ -371,6 +389,8 @@ GalleryBrowser2::~GalleryBrowser2() if( mpCurTheme ) mpGallery->ReleaseTheme( mpCurTheme, *this ); + + DBG_DTOR(GalleryBrowser2,NULL); } // ----------------------------------------------------------------------------- diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx index 6dca7b050e01..9e2ea4abaf92 100644 --- a/svx/source/gallery2/galctrl.cxx +++ b/svx/source/gallery2/galctrl.cxx @@ -54,6 +54,7 @@ // ------------------ // - GalleryPreview - // ------------------ +DBG_NAME(GalleryPreview) GalleryPreview::GalleryPreview( GalleryBrowser2* pParent, GalleryTheme* pTheme ) : Window( pParent, WB_TABSTOP | WB_BORDER ), @@ -61,6 +62,8 @@ GalleryPreview::GalleryPreview( GalleryBrowser2* pParent, GalleryTheme* pTheme ) DragSourceHelper( this ), mpTheme( pTheme ) { + DBG_CTOR(GalleryPreview,NULL); + SetHelpId( HID_GALLERY_WINDOW ); InitSettings(); } @@ -73,6 +76,8 @@ GalleryPreview::GalleryPreview( Window* pParent, const ResId & rResId ) : DragSourceHelper( this ), mpTheme( NULL ) { + DBG_CTOR(GalleryPreview,NULL); + SetHelpId( HID_GALLERY_PREVIEW ); InitSettings(); } @@ -81,6 +86,8 @@ GalleryPreview::GalleryPreview( Window* pParent, const ResId & rResId ) : GalleryPreview::~GalleryPreview() { + + DBG_DTOR(GalleryPreview,NULL); } @@ -300,6 +307,7 @@ void GalleryPreview::PreviewMedia( const INetURLObject& rURL ) // ------------------- // - GalleryIconView - // ------------------- +DBG_NAME(GalleryIconView) GalleryIconView::GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) : ValueSet( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_VSCROLL | WB_FLATVALUESET ), @@ -307,6 +315,7 @@ GalleryIconView::GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme DragSourceHelper( this ), mpTheme ( pTheme ) { + DBG_CTOR(GalleryIconView,NULL); EnableFullItemMode( sal_False ); SetHelpId( HID_GALLERY_WINDOW ); @@ -320,6 +329,8 @@ GalleryIconView::GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme GalleryIconView::~GalleryIconView() { + + DBG_DTOR(GalleryIconView,NULL); } // ------------------------------------------------------------------------ @@ -402,7 +413,7 @@ void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt ) aGraphic.Draw( pDev, aPos, aSize ); } - SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_THEMENAME | GALLERY_ITEM_TITLE | GALLERY_ITEM_PATH ) ); + SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE) ); mpTheme->ReleaseObject( pObj ); } } @@ -468,6 +479,7 @@ void GalleryIconView::StartDrag( sal_Int8, const Point& ) // ------------------- // - GalleryListView - // ------------------- +DBG_NAME(GalleryListView) GalleryListView::GalleryListView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) : BrowseBox( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER ), @@ -475,6 +487,8 @@ GalleryListView::GalleryListView( GalleryBrowser2* pParent, GalleryTheme* pTheme mnCurRow( 0 ), mbInit( sal_False ) { + DBG_CTOR(GalleryListView,NULL); + SetHelpId( HID_GALLERY_WINDOW ); InitSettings(); @@ -489,6 +503,8 @@ GalleryListView::GalleryListView( GalleryBrowser2* pParent, GalleryTheme* pTheme GalleryListView::~GalleryListView() { + + DBG_DTOR(GalleryListView,NULL); } // ------------------------------------------------------------------------ diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index eee9f46953c4..f8e5dd5f24fa 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -175,6 +175,8 @@ SvStream& operator>>( SvStream& rIn, GalleryImportThemeEntry& rEntry ) // - GalleryThemeCacheEntry - // -------------------------- +class GalleryThemeCacheEntry; +DBG_NAME(GalleryThemeCacheEntry) class GalleryThemeCacheEntry { private: @@ -185,8 +187,8 @@ private: public: GalleryThemeCacheEntry( const GalleryThemeEntry* pThemeEntry, GalleryTheme* pTheme ) : - mpThemeEntry( pThemeEntry ), mpTheme( pTheme ) {} - ~GalleryThemeCacheEntry() { delete mpTheme; } + mpThemeEntry( pThemeEntry ), mpTheme( pTheme ) {DBG_CTOR(GalleryThemeCacheEntry,NULL);} + ~GalleryThemeCacheEntry() { delete mpTheme;DBG_DTOR(GalleryThemeCacheEntry,NULL); } const GalleryThemeEntry* GetThemeEntry() const { return mpThemeEntry; } GalleryTheme* GetTheme() const { return mpTheme; } @@ -195,7 +197,6 @@ public: // ----------- // - Gallery - // ----------- - Gallery::Gallery( const String& rMultiPath ) : nReadTextEncoding ( gsl_getSystemTextEncoding() ) , nLastFileNumber ( 0 ) @@ -327,16 +328,20 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR if( xContentAccess.is() ) { + static const ::rtl::OUString s_sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")); + static const ::rtl::OUString s_sIsReadOnly(RTL_CONSTASCII_USTRINGPARAM("IsReadOnly")); + static const ::rtl::OUString s_sSDG_EXT(RTL_CONSTASCII_USTRINGPARAM("sdg")); + static const ::rtl::OUString s_sSDV_EXT(RTL_CONSTASCII_USTRINGPARAM("sdv")); + while( xResultSet->next() ) { INetURLObject aThmURL( xContentAccess->queryContentIdentifierString() ); if(aThmURL.GetExtension().equalsIgnoreAsciiCaseAscii("thm")) { - INetURLObject aSdgURL( aThmURL); aSdgURL.SetExtension( OUString::createFromAscii( "sdg" ) ); - INetURLObject aSdvURL( aThmURL ); aSdvURL.SetExtension( OUString::createFromAscii( "sdv" ) ); - const OUString aTitleProp( OUString::createFromAscii( "Title" ) ); - const OUString aReadOnlyProp( OUString::createFromAscii( "IsReadOnly" ) ); + INetURLObject aSdgURL( aThmURL); aSdgURL.SetExtension( s_sSDG_EXT ); + INetURLObject aSdvURL( aThmURL ); aSdvURL.SetExtension( s_sSDV_EXT ); + OUString aTitle; sal_Bool bReadOnly = sal_False; @@ -348,7 +353,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR try { - aThmCnt.getPropertyValue( aTitleProp ) >>= aTitle; + aThmCnt.getPropertyValue( s_sTitle ) >>= aTitle; } catch( const uno::RuntimeException& ) { @@ -361,7 +366,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR { try { - aThmCnt.getPropertyValue( aReadOnlyProp ) >>= bReadOnly; + aThmCnt.getPropertyValue( s_sIsReadOnly ) >>= bReadOnly; } catch( const uno::RuntimeException& ) { @@ -374,7 +379,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR { try { - aSdgCnt.getPropertyValue( aTitleProp ) >>= aTitle; + aSdgCnt.getPropertyValue( s_sTitle ) >>= aTitle; } catch( const ::com::sun::star::uno::RuntimeException& ) { @@ -387,7 +392,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR { try { - aSdgCnt.getPropertyValue( aReadOnlyProp ) >>= bReadOnly; + aSdgCnt.getPropertyValue( s_sIsReadOnly ) >>= bReadOnly; } catch( const uno::RuntimeException& ) { @@ -402,7 +407,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR { try { - aSdvCnt.getPropertyValue( aTitleProp ) >>= aTitle; + aSdvCnt.getPropertyValue( s_sTitle ) >>= aTitle; } catch( const ::com::sun::star::uno::RuntimeException& ) { @@ -415,7 +420,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR { try { - aSdvCnt.getPropertyValue( aReadOnlyProp ) >>= bReadOnly; + aSdvCnt.getPropertyValue( s_sIsReadOnly ) >>= bReadOnly; } catch( const uno::RuntimeException& ) { @@ -594,7 +599,6 @@ String Gallery::GetThemeName( sal_uIntPtr nThemeId ) const case( GALLERY_THEME_3D ): aFallback = "3D"; break; case( GALLERY_THEME_BULLETS ): aFallback = "Bullets"; break; case( GALLERY_THEME_HOMEPAGE ): aFallback = "Homepage"; break; - case( GALLERY_THEME_HTMLBUTTONS ): aFallback = "private://gallery/hidden/HtmlExportButtons"; break; case( GALLERY_THEME_POWERPOINT ): aFallback = "private://gallery/hidden/imgppt"; break; case( GALLERY_THEME_FONTWORK ): aFallback = "private://gallery/hidden/fontwork"; break; case( GALLERY_THEME_FONTWORK_VERTICAL ): aFallback = "private://gallery/hidden/fontworkvertical"; break; diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx index da5375423b56..e9cad0b9e561 100644 --- a/svx/source/gallery2/galmisc.cxx +++ b/svx/source/gallery2/galmisc.cxx @@ -399,10 +399,13 @@ sal_Bool KillFile( const INetURLObject& rURL ) // ------------------- // - GalleryProgress - // ------------------- +DBG_NAME(GalleryProgress) GalleryProgress::GalleryProgress( GraphicFilter* pFilter ) : mpFilter( pFilter ) { + DBG_CTOR(GalleryProgress,NULL); + uno::Reference< lang::XMultiServiceFactory > xMgr( ::utl::getProcessServiceFactory() ); if( xMgr.is() ) @@ -442,6 +445,8 @@ GalleryProgress::~GalleryProgress() { // if( mpFilter ) // mpFilter->SetUpdatePercentHdl( Link() ); + + DBG_DTOR(GalleryProgress,NULL); } // ------------------------------------------------------------------------ @@ -455,6 +460,7 @@ void GalleryProgress::Update( sal_uIntPtr nVal, sal_uIntPtr nMaxVal ) // ----------------------- // - GalleryTransferable - // ----------------------- +DBG_NAME(GalleryTransferable) GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, sal_uIntPtr nObjectPos, bool bLazy ) : mpTheme( pTheme ), @@ -464,6 +470,8 @@ GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, sal_uIntPtr nObj mpImageMap( NULL ), mpURL( NULL ) { + DBG_CTOR(GalleryTransferable,NULL); + InitData( bLazy ); } @@ -471,6 +479,8 @@ GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, sal_uIntPtr nObj GalleryTransferable::~GalleryTransferable() { + + DBG_DTOR(GalleryTransferable,NULL); } // ------------------------------------------------------------------------ diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx index 9ba9cff068a3..ff870974d776 100644 --- a/svx/source/gallery2/galobj.cxx +++ b/svx/source/gallery2/galobj.cxx @@ -320,10 +320,13 @@ void SgaObjectBmp::ReadData( SvStream& rIn, sal_uInt16& rReadVersion ) // ------------------ // - SgaObjectSound - // ------------------ +DBG_NAME(SgaObjectSound) SgaObjectSound::SgaObjectSound() : eSoundType( SOUND_STANDARD ) { + DBG_CTOR(SgaObjectSound,NULL); + } // ------------------------------------------------------------------------ @@ -331,6 +334,8 @@ SgaObjectSound::SgaObjectSound() : SgaObjectSound::SgaObjectSound( const INetURLObject& rURL ) : eSoundType( SOUND_STANDARD ) { + DBG_CTOR(SgaObjectSound,NULL); + if( FileExists( rURL ) ) { aURL = rURL; @@ -345,6 +350,8 @@ SgaObjectSound::SgaObjectSound( const INetURLObject& rURL ) : SgaObjectSound::~SgaObjectSound() { + + DBG_DTOR(SgaObjectSound,NULL); } // ------------------------------------------------------------------------ @@ -453,10 +460,13 @@ SgaObjectSvDraw::SgaObjectSvDraw( const FmFormModel& rModel, const INetURLObject } // ------------------------------------------------------------------------ +DBG_NAME(SvxGalleryDrawModel) SvxGalleryDrawModel::SvxGalleryDrawModel() : mpFormModel( 0 ) { + DBG_CTOR(SvxGalleryDrawModel,NULL); + const String sFactoryURL(RTL_CONSTASCII_USTRINGPARAM("sdraw")); mxDoc = SfxObjectShell::CreateObjectByFactoryName( sFactoryURL ); @@ -484,6 +494,8 @@ SvxGalleryDrawModel::~SvxGalleryDrawModel() { if( mxDoc.Is() ) mxDoc->DoClose(); + + DBG_DTOR(SvxGalleryDrawModel,NULL); } // ------------------------------------------------------------------------ diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index bd1ae10cd746..196b35189c03 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -72,6 +72,7 @@ using namespace ::com::sun::star; // ------------ // - SgaTheme - // ------------ +DBG_NAME(GalleryTheme) GalleryTheme::GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry ) : pParent ( pGallery ), @@ -81,6 +82,8 @@ GalleryTheme::GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry ) nDragPos ( 0 ), bDragging ( sal_False ) { + DBG_CTOR(GalleryTheme,NULL); + ImplCreateSvDrawStorage(); if( pThm->IsImported() ) @@ -99,6 +102,8 @@ GalleryTheme::~GalleryTheme() delete pEntry; Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uIntPtr >( pEntry ) ) ); } + + DBG_DTOR(GalleryTheme,NULL); } // ------------------------------------------------------------------------ @@ -901,6 +906,7 @@ sal_Bool GalleryTheme::InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInse case( GFX_LINK_TYPE_NATIVE_WMF ): nExportFormat = CVT_WMF; break; case( GFX_LINK_TYPE_NATIVE_MET ): nExportFormat = CVT_MET; break; case( GFX_LINK_TYPE_NATIVE_PCT ): nExportFormat = CVT_PCT; break; + case( GFX_LINK_TYPE_NATIVE_SVG ): nExportFormat = CVT_SVG; break; default: break; } @@ -1187,18 +1193,13 @@ sal_Bool GalleryTheme::InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, s uno::Sequence< OUString > aProps( 1 ); aProps.getArray()[ 0 ] = OUString::createFromAscii( "Url" ); uno::Reference< sdbc::XResultSet > xResultSet( aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); - - if( xResultSet.is() ) + uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY ); + if( xContentAccess.is() ) { - uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY ); - - if( xContentAccess.is() ) + while( xResultSet->next() ) { - while( xResultSet->next() ) - { - aURL.SetSmartURL( xContentAccess->queryContentIdentifierString() ); - aURLVector.push_back( aURL ); - } + aURL.SetSmartURL( xContentAccess->queryContentIdentifierString() ); + aURLVector.push_back( aURL ); } } } diff --git a/svx/source/gallery2/galtheme.src b/svx/source/gallery2/galtheme.src index bfb1f65d0340..0c1771cac440 100644 --- a/svx/source/gallery2/galtheme.src +++ b/svx/source/gallery2/galtheme.src @@ -127,14 +127,6 @@ String RID_GALLERYSTR_THEME_SURFACES // ----------------------------------------------------------------------------- -String RID_GALLERYSTR_THEME_HTMLBUTTONS -{ - // !!! Don't translate, please !!! - Text = "private://gallery/hidden/HtmlExportButtons"; -}; - -// ----------------------------------------------------------------------------- - String RID_GALLERYSTR_THEME_POWERPOINT { // !!! Don't translate, please !!! diff --git a/svx/source/intro/about_ooo.src b/svx/source/intro/about_ooo.src index b49a0ff927cf..4523ffd739ce 100644 --- a/svx/source/intro/about_ooo.src +++ b/svx/source/intro/about_ooo.src @@ -30,7 +30,7 @@ String ABOUT_STR_COPYRIGHT { - Text[ en-US ] = "Copyright © 2000, 2010 Oracle and/or its affiliates. All rights reserved.\nThis product was created by %OOOVENDOR, based on OpenOffice.org.\nOpenOffice.org acknowledges all community members, especially those mentioned at\n http://www.openoffice.org/welcome/credits.html."; + Text[ en-US ] = "Copyright © 2000, 2011 Oracle and/or its affiliates. All rights reserved.\nThis product was created by %OOOVENDOR, based on OpenOffice.org.\nOpenOffice.org acknowledges all community members, especially those mentioned at\n http://www.openoffice.org/welcome/credits.html."; }; StringArray ABOUT_STR_DEVELOPER_ARY diff --git a/svx/source/sdr/contact/objectcontact.cxx b/svx/source/sdr/contact/objectcontact.cxx index bda2e1529988..c0ba5cec6bb8 100644 --- a/svx/source/sdr/contact/objectcontact.cxx +++ b/svx/source/sdr/contact/objectcontact.cxx @@ -66,7 +66,7 @@ namespace sdr std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector); maViewObjectContactVector.clear(); - while(aLocalVOCList.size()) + while(!aLocalVOCList.empty()) { ViewObjectContact* pCandidate = aLocalVOCList.back(); aLocalVOCList.pop_back(); diff --git a/svx/source/sdr/contact/viewcontact.cxx b/svx/source/sdr/contact/viewcontact.cxx index 3057acf55df1..3d6bd2d79a5a 100644 --- a/svx/source/sdr/contact/viewcontact.cxx +++ b/svx/source/sdr/contact/viewcontact.cxx @@ -82,7 +82,7 @@ namespace sdr std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector); maViewObjectContactVector.clear(); - while(aLocalVOCList.size()) + while(!aLocalVOCList.empty()) { ViewObjectContact* pCandidate = aLocalVOCList.back(); aLocalVOCList.pop_back(); @@ -147,7 +147,7 @@ namespace sdr { maViewObjectContactVector.erase(aFindResult); - if(0 == maViewObjectContactVector.size()) + if(maViewObjectContactVector.empty()) { // This may need to get asynchron later since it eventually triggers // deletes of OCs where the VOC is still added. diff --git a/svx/source/sdr/contact/viewcontactofsdrobj.cxx b/svx/source/sdr/contact/viewcontactofsdrobj.cxx index 3b002e406be1..c06bb7f25b0e 100644 --- a/svx/source/sdr/contact/viewcontactofsdrobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrobj.cxx @@ -173,7 +173,7 @@ namespace sdr aGluepointVector.push_back(basegfx::B2DPoint(aPosition.X(), aPosition.Y())); } - if(aGluepointVector.size()) + if(!aGluepointVector.empty()) { const basegfx::BColor aBackPen(1.0, 1.0, 1.0); const basegfx::BColor aRGBFrontColor(0.0, 0.0, 1.0); // COL_LIGHTBLUE diff --git a/svx/source/sdr/event/eventhandler.cxx b/svx/source/sdr/event/eventhandler.cxx index 967b6fefe949..e65dfe927fda 100644 --- a/svx/source/sdr/event/eventhandler.cxx +++ b/svx/source/sdr/event/eventhandler.cxx @@ -83,7 +83,7 @@ namespace sdr BaseEvent* EventHandler::GetEvent() { - if(maVector.size()) + if(!maVector.empty()) { // get the last event, that one is fastest to be removed return maVector.back(); @@ -100,7 +100,7 @@ namespace sdr EventHandler::~EventHandler() { - while(maVector.size()) + while(!maVector.empty()) { delete GetEvent(); } diff --git a/svx/source/sdr/overlay/overlayobjectlist.cxx b/svx/source/sdr/overlay/overlayobjectlist.cxx index e9464bdee09b..0e9f61d9b03a 100644 --- a/svx/source/sdr/overlay/overlayobjectlist.cxx +++ b/svx/source/sdr/overlay/overlayobjectlist.cxx @@ -83,7 +83,7 @@ namespace sdr bool OverlayObjectList::isHitLogic(const basegfx::B2DPoint& rLogicPosition, double fLogicTolerance) const { - if(maVector.size()) + if(!maVector.empty()) { OverlayObjectVector::const_iterator aStart(maVector.begin()); sdr::overlay::OverlayObject* pFirst = *aStart; @@ -134,7 +134,7 @@ namespace sdr bool OverlayObjectList::isHitPixel(const Point& rDiscretePosition, sal_uInt32 nDiscreteTolerance) const { - if(maVector.size()) + if(!maVector.empty()) { OverlayObjectVector::const_iterator aStart(maVector.begin()); sdr::overlay::OverlayObject* pCandidate = *aStart; @@ -164,7 +164,7 @@ namespace sdr { basegfx::B2DRange aRetval; - if(maVector.size()) + if(!maVector.empty()) { OverlayObjectVector::const_iterator aStart(maVector.begin()); diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx index 7d51b26a0051..41149a965248 100644 --- a/svx/source/sdr/properties/defaultproperties.cxx +++ b/svx/source/sdr/properties/defaultproperties.cxx @@ -204,8 +204,10 @@ namespace sdr { } - void DefaultProperties::PostItemChange(const sal_uInt16 /*nWhich*/) + void DefaultProperties::PostItemChange(const sal_uInt16 nWhich ) { + if( (nWhich == XATTR_FILLSTYLE) && (mpItemSet != NULL) ) + CleanupFillProperties(*mpItemSet); } void DefaultProperties::SetStyleSheet(SfxStyleSheet* /*pNewStyleSheet*/, sal_Bool /*bDontRemoveHardAttr*/) diff --git a/svx/source/sdr/properties/pageproperties.cxx b/svx/source/sdr/properties/pageproperties.cxx index 2fc92633b953..c1d0467b740e 100644 --- a/svx/source/sdr/properties/pageproperties.cxx +++ b/svx/source/sdr/properties/pageproperties.cxx @@ -89,6 +89,12 @@ namespace sdr return 0L; } + void PageProperties::PostItemChange(const sal_uInt16 nWhich ) + { + if( (nWhich == XATTR_FILLSTYLE) && (mpEmptyItemSet != NULL) ) + CleanupFillProperties(*mpEmptyItemSet); + } + void PageProperties::ClearObjectItem(const sal_uInt16 /*nWhich*/) { // simply ignore item clearing on page objects diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx index f8c307f26309..0439fd6baf4c 100644 --- a/svx/source/sdr/properties/properties.cxx +++ b/svx/source/sdr/properties/properties.cxx @@ -32,6 +32,7 @@ #include <svl/itemset.hxx> #include <svx/svdogrp.hxx> #include <svx/svditer.hxx> +#include <svx/xfillit0.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -182,6 +183,35 @@ namespace sdr { return 0; } + + void CleanupFillProperties( SfxItemSet& rItemSet ) + { + const bool bFillBitmap = rItemSet.GetItemState(XATTR_FILLBITMAP, sal_False) == SFX_ITEM_SET; + const bool bFillGradient = rItemSet.GetItemState(XATTR_FILLGRADIENT, sal_False) == SFX_ITEM_SET; + const bool bFillHatch = rItemSet.GetItemState(XATTR_FILLHATCH, sal_False) == SFX_ITEM_SET; + if( bFillBitmap || bFillGradient || bFillHatch ) + { + const XFillStyleItem* pFillStyleItem = dynamic_cast< const XFillStyleItem* >( rItemSet.GetItem(XATTR_FILLSTYLE) ); + if( pFillStyleItem ) + { + if( bFillBitmap && (pFillStyleItem->GetValue() != XFILL_BITMAP) ) + { + rItemSet.ClearItem( XATTR_FILLBITMAP ); + } + + if( bFillGradient && (pFillStyleItem->GetValue() != XFILL_GRADIENT) ) + { + rItemSet.ClearItem( XATTR_FILLGRADIENT ); + } + + if( bFillHatch && (pFillStyleItem->GetValue() != XFILL_HATCH) ) + { + rItemSet.ClearItem( XATTR_FILLHATCH ); + } + } + } + } + } // end of namespace properties } // end of namespace sdr diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index afbb6d0b4066..7590b7d14ae8 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -247,7 +247,7 @@ drawinglayer::primitive2d::Primitive2DSequence SdrDragEntryPointGlueDrag::create { drawinglayer::primitive2d::Primitive2DSequence aRetval; - if(maPositions.size()) + if(!maPositions.empty()) { basegfx::B2DPolygon aPolygon; sal_uInt32 a(0); @@ -499,7 +499,7 @@ void SdrDragMethod::createSdrDragEntries_PointDrag() } } - if(aPositions.size()) + if(!aPositions.empty()) { addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, true)); } @@ -543,7 +543,7 @@ void SdrDragMethod::createSdrDragEntries_GlueDrag() } } - if(aPositions.size()) + if(!aPositions.empty()) { addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, false)); } @@ -670,14 +670,14 @@ void SdrDragMethod::CancelSdrDrag() void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager) { // create SdrDragEntries on demand - if(!maSdrDragEntries.size()) + if(maSdrDragEntries.empty()) { createSdrDragEntries(); } // if there are entries, derive OverlayObjects from the entries, including // modification from current interactive state - if(maSdrDragEntries.size()) + if(!maSdrDragEntries.empty()) { drawinglayer::primitive2d::Primitive2DSequence aResult; drawinglayer::primitive2d::Primitive2DSequence aResultTransparent; diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index ec9fece55649..784866869d61 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -644,8 +644,12 @@ void SdrEditView::CheckPossibilities() sal_Bool bGraf=HAS_BASE(SdrGrafObj,pObj); sal_Bool bOle2=HAS_BASE(SdrOle2Obj,pObj); - if( bGraf && ((SdrGrafObj*)pObj)->HasGDIMetaFile() && !((SdrGrafObj*)pObj)->IsEPS() ) + if( bGraf && + ((SdrGrafObj*)pObj)->HasGDIMetaFile() && + !( ((SdrGrafObj*)pObj)->IsEPS() || ((SdrGrafObj*)pObj)->IsRenderGraphic() ) ) + { bImportMtfPossible = sal_True; + } if (bOle2) bImportMtfPossible=((SdrOle2Obj*)pObj)->GetObjRef().is(); @@ -781,7 +785,7 @@ void SdrEditView::DeleteMarkedList(const SdrMarkList& rMark) } // fire scene updaters - while(aUpdaters.size()) + while(!aUpdaters.empty()) { delete aUpdaters.back(); aUpdaters.pop_back(); @@ -790,7 +794,7 @@ void SdrEditView::DeleteMarkedList(const SdrMarkList& rMark) if( !bUndo ) { // now delete removed scene objects - while(aRemoved3DObjects.size()) + while(!aRemoved3DObjects.empty()) { SdrObject::Free( aRemoved3DObjects.back() ); aRemoved3DObjects.pop_back(); @@ -836,7 +840,7 @@ void SdrEditView::DeleteMarkedObj() if(pParent) { - if(aParents.size()) + if(!aParents.empty()) { std::vector< SdrObject* >::iterator aFindResult = std::find(aParents.begin(), aParents.end(), pParent); @@ -853,7 +857,7 @@ void SdrEditView::DeleteMarkedObj() } } - if(aParents.size()) + if(!aParents.empty()) { // in a 2nd run, remove all objects which may already be scheduled for // removal. I am not sure if this can happen, but theoretically @@ -1043,4 +1047,3 @@ bool SdrEditView::IsUndoEnabled() const { return pMod->IsUndoEnabled(); } - diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index 3502db48e4e9..ee95d8486e60 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -318,7 +318,7 @@ void SdrEditView::RotateMarkedObj(const Point& rRef, long nWink, bool bCopy) } // fire scene updaters - while(aUpdaters.size()) + while(!aUpdaters.empty()) { delete aUpdaters.back(); aUpdaters.pop_back(); @@ -378,7 +378,7 @@ void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool b } // fire scene updaters - while(aUpdaters.size()) + while(!aUpdaters.empty()) { delete aUpdaters.back(); aUpdaters.pop_back(); @@ -1051,7 +1051,7 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, sal_Bool bReplaceAll) { SdrTextObj* pTextObj = ((SdrTextObj*)pObj); - if(0 != aCharWhichIds.size()) + if(!aCharWhichIds.empty()) { Rectangle aOldBoundRect = pTextObj->GetLastBoundRect(); @@ -1079,7 +1079,7 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, sal_Bool bReplaceAll) } // fire scene updaters - while(aUpdaters.size()) + while(!aUpdaters.empty()) { delete aUpdaters.back(); aUpdaters.pop_back(); diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 6a207ca4cba4..0a4bc82e45f8 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -195,7 +195,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, case META_POP_ACTION : DoAction((MetaPopAction &)*pAct); break; case META_HATCH_ACTION : DoAction((MetaHatchAction &)*pAct); break; case META_COMMENT_ACTION : DoAction((MetaCommentAction &)*pAct, pMtf); break; - + case META_RENDERGRAPHIC_ACTION : DoAction((MetaRenderGraphicAction &)*pAct); break; } if(pProgrInfo != NULL) @@ -272,7 +272,7 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, FASTBOOL bForceText { bNoLine = sal_False; bNoFill = sal_False; FASTBOOL bLine=sal_True && !bForceTextAttr; - FASTBOOL bFill=pObj==NULL || pObj->IsClosedObj() && !bForceTextAttr; + FASTBOOL bFill=pObj==NULL || ( pObj->IsClosedObj() && !bForceTextAttr ); FASTBOOL bText=bForceTextAttr || (pObj!=NULL && pObj->GetOutlinerParaObject()!=NULL); if ( bLine ) @@ -1025,4 +1025,25 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM } } +//////////////////////////////////////////////////////////////////////////////////////////////////// + +void ImpSdrGDIMetaFileImport::DoAction(MetaRenderGraphicAction& rAct) +{ + GDIMetaFile aMtf; + const ::vcl::RenderGraphic& rRenderGraphic = rAct.GetRenderGraphic(); + Rectangle aRect( rAct.GetPoint(), rAct.GetSize() ); + const Point aPos; + const Size aPrefSize( rRenderGraphic.GetPrefSize() ); + + aRect.Right()++; aRect.Bottom()++; + + aMtf.SetPrefMapMode( rRenderGraphic.GetPrefMapMode() ); + aMtf.SetPrefSize( aPrefSize ); + aMtf.AddAction( new MetaRenderGraphicAction( aPos, aPrefSize, rRenderGraphic ) ); + aMtf.WindStart(); + + SdrGrafObj* pGraf=new SdrGrafObj( aMtf, aRect ); + InsertObj( pGraf ); +} + // eof diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx index abe434aa215b..463915d48096 100644 --- a/svx/source/svdraw/svdfmtf.hxx +++ b/svx/source/svdraw/svdfmtf.hxx @@ -140,6 +140,7 @@ protected: void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); } void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); } void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf); + void DoAction(MetaRenderGraphicAction& rAct); void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct ); void SetAttributes(SdrObject* pObj, FASTBOOL bForceTextAttr=sal_False); diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 30628a10df86..f012cac1757c 100755 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -69,6 +69,9 @@ #include "svx/svdstr.hrc" // Objektname #include "svdoutlinercache.hxx" +#include "svx/xflclit.hxx" +#include "svx/xflhtit.hxx" +#include "svx/xlnclit.hxx" #include <svl/asiancfg.hxx> #include "editeng/fontitem.hxx" @@ -210,6 +213,7 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe pItemPool->SetPoolDefaultItem( SdrTextWordWrapItem( sal_False ) ); SetTextDefaults(); + pLayerAdmin=new SdrLayerAdmin; pLayerAdmin->SetModel(this); ImpSetUIUnit(); @@ -2167,6 +2171,18 @@ const ::com::sun::star::uno::Sequence< sal_Int8 >& SdrModel::getUnoTunnelImpleme return *pSeq; } +void SdrModel::SetDrawingLayerPoolDefaults() +{ + const String aNullStr; + const Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE); + const Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING); + const XHatch aNullHatch(aNullLineCol); + + pItemPool->SetPoolDefaultItem( XFillColorItem(aNullStr,aNullFillCol) ); + pItemPool->SetPoolDefaultItem( XFillHatchItem(pItemPool,aNullHatch) ); + pItemPool->SetPoolDefaultItem( XLineColorItem(aNullStr,aNullLineCol) ); +} + //////////////////////////////////////////////////////////////////////////////////////////////////// TYPEINIT1(SdrHint,SfxHint); diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 30791ce216d4..f595909e654f 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -2438,7 +2438,7 @@ void SdrObjCustomShape::DragCreateObject( SdrDragStat& rStat ) aRect1 = Rectangle( rStat.GetNow(), Size( nDefaultObjectSizeWidth, nDefaultObjectSizeHeight ) ); // subtracting the horizontal difference of the latest handle from shape position - if ( aInteractionHandles.size() ) + if ( !aInteractionHandles.empty() ) { sal_Int32 nHandlePos = aInteractionHandles[ aInteractionHandles.size() - 1 ].xInteraction->getPosition().X; aRect1.Move( aRect.Left() - nHandlePos, 0 ); diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 81ff5005d0f6..cc2ece168ec7 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -929,7 +929,7 @@ const Rectangle& SdrObject::GetLastBoundRect() const void SdrObject::RecalcBoundRect() { // #i101680# suppress BoundRect calculations on import(s) - if(pModel && pModel->isLocked() ) + if(pModel && pModel->isLocked()) return; // central new method which will calculate the BoundRect using primitive geometry @@ -2440,7 +2440,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, sal_Bool bForceLin // #i102241# check for line results const std::vector< basegfx::B2DPolygon >& rHairlineVector = aExtractor.getExtractedHairlines(); - if(rHairlineVector.size()) + if(!rHairlineVector.empty()) { // for SdrObject creation, just copy all to a single Hairline-PolyPolygon for(sal_uInt32 a(0); a < rHairlineVector.size(); a++) @@ -2452,7 +2452,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, sal_Bool bForceLin // #i102241# check for fill rsults const std::vector< basegfx::B2DPolyPolygon >& rLineFillVector(aExtractor.getExtractedLineFills()); - if(rLineFillVector.size()) + if(!rLineFillVector.empty()) { // merge to a single PolyPolygon (OR) aMergedLineFillPolyPolygon = basegfx::tools::mergeToSinglePolyPolygon(rLineFillVector); diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index adfc7d0ba991..5895eface327 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -504,6 +504,16 @@ sal_Bool SdrGrafObj::IsEPS() const return pGraphic->IsEPS(); } +sal_Bool SdrGrafObj::IsRenderGraphic() const +{ + return pGraphic->IsRenderGraphic(); +} + +sal_Bool SdrGrafObj::HasRenderGraphic() const +{ + return pGraphic->HasRenderGraphic(); +} + sal_Bool SdrGrafObj::IsSwappedOut() const { return mbIsPreview ? sal_True : pGraphic->IsSwappedOut(); @@ -658,6 +668,7 @@ void SdrGrafObj::ReleaseGraphicLink() void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const { FASTBOOL bAnim = pGraphic->IsAnimated(); + FASTBOOL bRenderGraphic = pGraphic->HasRenderGraphic(); FASTBOOL bNoPresGrf = ( pGraphic->GetType() != GRAPHIC_NONE ) && !bEmptyPresObj; rInfo.bResizeFreeAllowed = aGeo.nDrehWink % 9000 == 0 || @@ -665,11 +676,11 @@ void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const aGeo.nDrehWink % 27000 == 0; rInfo.bResizePropAllowed = sal_True; - rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim; - rInfo.bRotate90Allowed = bNoPresGrf && !bAnim; - rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim; - rInfo.bMirror45Allowed = bNoPresGrf && !bAnim; - rInfo.bMirror90Allowed = !bEmptyPresObj; + rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bRotate90Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirror45Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirror90Allowed = !bEmptyPresObj && !bRenderGraphic; rInfo.bTransparenceAllowed = sal_False; rInfo.bGradientAllowed = sal_False; rInfo.bShearAllowed = sal_False; @@ -677,7 +688,7 @@ void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const rInfo.bCanConvToPath = sal_False; rInfo.bCanConvToPathLineToArea = sal_False; rInfo.bCanConvToPolyLineToArea = sal_False; - rInfo.bCanConvToPoly = !IsEPS(); + rInfo.bCanConvToPoly = !IsEPS() && !bRenderGraphic; rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary()); } diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index ede6b35178f9..152ab501f8e6 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -282,7 +282,6 @@ const Rectangle& SdrObjGroup::GetCurrentBoundRect() const // <-- } - const Rectangle& SdrObjGroup::GetSnapRect() const { // --> OD 2007-02-01 #144962# diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 9bc3bbb4958c..0ef0732ac80d 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -491,7 +491,7 @@ namespace { // only create a line primitive when we had content; there is no need for // empty line primitives (contrary to paragraphs, see below). - if(maTextPortionPrimitives.size()) + if(!maTextPortionPrimitives.empty()) { drawinglayer::primitive2d::Primitive2DSequence aLineSequence(impConvertVectorToPrimitive2DSequence(maTextPortionPrimitives)); maTextPortionPrimitives.clear(); @@ -658,13 +658,13 @@ namespace drawinglayer::primitive2d::Primitive2DSequence impTextBreakupHandler::getPrimitive2DSequence() { - if(maTextPortionPrimitives.size()) + if(!maTextPortionPrimitives.empty()) { // collect non-closed lines impFlushTextPortionPrimitivesToLinePrimitives(); } - if(maLinePrimitives.size()) + if(!maLinePrimitives.empty()) { // collect non-closed paragraphs impFlushLinePrimitivesToParagraphPrimitives(); diff --git a/svx/source/svdraw/svdotextpathdecomposition.cxx b/svx/source/svdraw/svdotextpathdecomposition.cxx index 72de016703bd..7b6f71eed59c 100644 --- a/svx/source/svdraw/svdotextpathdecomposition.cxx +++ b/svx/source/svdraw/svdotextpathdecomposition.cxx @@ -200,7 +200,7 @@ namespace mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decompositionPathTextPrimitive)); mrOutliner.StripPortions(); - if(maPathTextPortions.size()) + if(!maPathTextPortions.empty()) { // sort portions by paragraph, x and y ::std::sort(maPathTextPortions.begin(), maPathTextPortions.end()); @@ -627,7 +627,7 @@ namespace // get text outlines and their object transformation pTextCandidate->getTextOutlinesAndTransformation(aB2DPolyPolyVector, aPolygonTransform); - if(aB2DPolyPolyVector.size()) + if(!aB2DPolyPolyVector.empty()) { // create stroke primitives std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aStrokePrimitives; @@ -712,7 +712,7 @@ void SdrTextObj::impDecomposePathTextPrimitive( impTextBreakupHandler aConverter(rOutliner); const ::std::vector< impPathTextPortion > rPathTextPortions = aConverter.decompositionPathTextPrimitive(); - if(rPathTextPortions.size()) + if(!rPathTextPortions.empty()) { // get FormText and polygon values const drawinglayer::attribute::SdrFormTextAttribute& rFormTextAttribute = rSdrPathTextPrimitive.getSdrFormTextAttribute(); @@ -753,7 +753,7 @@ void SdrTextObj::impDecomposePathTextPrimitive( } // handle data pair polygon/ParagraphTextPortions - if(aParagraphTextPortions.size()) + if(!aParagraphTextPortions.empty()) { aPolygonParagraphHandler.HandlePair(rPathPolyPolygon.getB2DPolygon(a), aParagraphTextPortions); } diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index aaa83ed5f1fe..fd2327dd8139 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -308,7 +308,7 @@ SdrPaintView::~SdrPaintView() #endif // delete existing SdrPaintWindows - while(maPaintWindows.size()) + while(!maPaintWindows.empty()) { delete maPaintWindows.back(); maPaintWindows.pop_back(); diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 9ac652f5e025..5618a2880e31 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -330,6 +330,7 @@ void SdrTableObjImpl::operator=( const SdrTableObjImpl& rSource ) void SdrTableObjImpl::SetModel(SdrModel* /*pOldModel*/, SdrModel* pNewModel) { // try to find new table style + disconnectTableStyle(); Reference< XIndexAccess > xNewTableStyle; if( mxTableStyle.is() ) try @@ -360,6 +361,7 @@ void SdrTableObjImpl::SetModel(SdrModel* /*pOldModel*/, SdrModel* pNewModel) mxTableStyle = xNewTableStyle; + connectTableStyle(); update(); } diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx index ebad78935d13..fb7c1330f88c 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -856,10 +856,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView ) { SfxItemPool& rPool = rView.GetModel()->GetItemPool(); SfxItemSet aSet( rPool, SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST ); - - const bool bUndo = rView.IsUndoEnabled(); - - String aUndoStr; + String aUndoStr; + const bool bUndo = rView.IsUndoEnabled(); if( bUndo ) { @@ -1139,7 +1137,29 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) SfxItemPool& rPool = rView.GetModel()->GetItemPool(); SfxItemSet aAttrSet( rPool ); SfxWhichIter aIter( rSet ); - sal_uInt16 nWhich = aIter.FirstWhich(); + sal_uInt16 nWhich = aIter.FirstWhich(); + const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); + bool bEnableColors = true; + bool bEnableTransparency = true; + bool bEnableCrop = ( 1 == rMarkList.GetMarkCount() ); + + for( int i = 0, nCount = rMarkList.GetMarkCount(); i < nCount; ++i ) + { + SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( i )->GetMarkedSdrObj() ); + + if( !pGrafObj || + ( pGrafObj->GetGraphicType() == GRAPHIC_NONE ) || + ( pGrafObj->GetGraphicType() == GRAPHIC_DEFAULT ) || + pGrafObj->HasRenderGraphic() ) + { + bEnableColors = bEnableTransparency = bEnableCrop = false; + break; + } + else if( bEnableTransparency && ( pGrafObj->HasGDIMetaFile() || pGrafObj->IsAnimated() ) ) + { + bEnableTransparency = false; + } + } rView.GetAttributes( aAttrSet ); @@ -1153,8 +1173,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFMODE ) ) { - rSet.Put( SfxUInt16Item( nSlotId, - sal::static_int_cast< sal_uInt16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxUInt16Item( nSlotId, + sal::static_int_cast< sal_uInt16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_MODE ); + } } } break; @@ -1163,8 +1190,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFRED ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_RED ); + } } } break; @@ -1173,8 +1207,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGREEN ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_GREEN ); + } } } break; @@ -1183,8 +1224,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFBLUE ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_BLUE ); + } } } break; @@ -1193,8 +1241,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFLUMINANCE ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_LUMINANCE ); + } } } break; @@ -1203,8 +1258,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFCONTRAST ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_CONTRAST ); + } } } break; @@ -1213,8 +1275,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGAMMA ) ) { - rSet.Put( SfxUInt32Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxUInt32Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_GAMMA ); + } } } break; @@ -1223,53 +1292,22 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFTRANSPARENCE ) ) { - const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); - sal_Bool bEnable = sal_True; - - for( sal_uInt16 i = 0, nCount = (sal_uInt16) rMarkList.GetMarkCount(); - ( i < nCount ) && bEnable; i++ ) + if( bEnableTransparency ) { - SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - - if( !pObj || !pObj->ISA( SdrGrafObj ) || - ( (SdrGrafObj*) pObj )->HasGDIMetaFile() || - ( (SdrGrafObj*) pObj )->IsAnimated() ) - { - bEnable = sal_False; - } - } - - if( bEnable ) rSet.Put( SfxUInt16Item( nSlotId, ITEMVALUE( aAttrSet, SDRATTR_GRAFTRANSPARENCE, SdrGrafTransparenceItem ) ) ); + } else + { rSet.DisableItem( SID_ATTR_GRAF_TRANSPARENCE ); + } } } break; case( SID_ATTR_GRAF_CROP ): { - const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); - sal_Bool bDisable = sal_True; - - if( 1 == rMarkList.GetMarkCount() ) - { - SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - - if( pObj && pObj->ISA( SdrGrafObj ) ) - { - SdrGrafObj* pGrafObj = (SdrGrafObj*) pObj; - - if( ( pGrafObj->GetGraphicType() != GRAPHIC_NONE ) && - ( pGrafObj->GetGraphicType() != GRAPHIC_DEFAULT ) ) - { - bDisable = sal_False; - } - } - } - - if( bDisable ) + if( !bEnableCrop ) rSet.DisableItem( nSlotId ); } break; diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index ad97a61900fa..91548f37a05a 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -2247,7 +2247,7 @@ Window* SvxStyleToolBoxControl::CreateItemWindow( Window *pParent ) pImpl->aClearForm, pImpl->aMore, pImpl->bSpecModeWriter || pImpl->bSpecModeCalc ); - if( pImpl->aDefaultStyles.size()) + if( !pImpl->aDefaultStyles.empty()) pBox->SetDefaultStyle( pImpl->aDefaultStyles[0] ); // Set visibility listener to bind/unbind controller pBox->SetVisibilityListener( LINK( this, SvxStyleToolBoxControl, VisibilityNotification )); diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index eb9a7cb8128f..b8a344ce4609 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -819,11 +819,11 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, aShapes.push_back( pObj ); } - if( 0 == aShapes.size() ) + if( aShapes.empty() ) bRet = false; } - if( bRet && aShapes.size() ) + if( bRet && !aShapes.empty() ) { // special treatment for only one SdrGrafObj that has text sal_Bool bSingleGraphic = sal_False; @@ -949,7 +949,7 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, } } - if(aShapes.size()) + if(!aShapes.empty()) { // more effective way to paint a vector of SdrObjects. Hand over the processed page // to have it in the diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index 7889fcc0f5ff..5284e32f810e 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -153,7 +153,7 @@ SvXMLGraphicInputStream::SvXMLGraphicInputStream( const ::rtl::OUString& rGraphi { pStm->SetVersion( SOFFICE_FILEFORMAT_8 ); pStm->SetCompressMode( COMPRESSMODE_ZBITMAP ); - ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm ); + ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC ); bRet = ( pStm->GetError() == 0 ); } } @@ -543,7 +543,8 @@ String SvXMLGraphicHelper::ImplGetGraphicMimeType( const String& rFileName ) con { "gif", "image/gif" }, { "png", "image/png" }, { "jpg", "image/jpeg" }, - { "tif", "image/tiff" } + { "tif", "image/tiff" }, + { "svg", "image/svg+xml" } }; String aMimeType; @@ -648,7 +649,7 @@ sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureSt pStream->Write( rLink.GetData(), rLink.GetDataSize() ); } else - rMtf.Write( *pStream ); + rMtf.Write( *pStream, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC ); bRet = ( pStream->GetError() == 0 ); } @@ -728,6 +729,7 @@ void SvXMLGraphicHelper::ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, s case( GFX_LINK_TYPE_NATIVE_WMF ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".wmf" ) ); break; case( GFX_LINK_TYPE_NATIVE_MET ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".met" ) ); break; case( GFX_LINK_TYPE_NATIVE_PCT ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".pct" ) ); break; + case( GFX_LINK_TYPE_NATIVE_SVG ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".svg" ) ); break; default: aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".grf" ) ); @@ -1160,4 +1162,3 @@ Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicExportHelper_getSupportedServic } } // namespace svx - diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index e8958bf82479..62c434097699 100644..100755 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -367,7 +367,8 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName, if( aExt.Len() ) { - aURL.setExtension( aExt ); + if( 0 == (nFlags & XOUTBMP_DONT_ADD_EXTENSION)) + aURL.setExtension( aExt ); rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); SfxMedium aMedium( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_SHARE_DENYNONE | STREAM_TRUNC, sal_True ); @@ -472,7 +473,8 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName, if( ( GRFILTER_FORMAT_NOTFOUND != nFilter ) && ( aGraphic.GetType() != GRAPHIC_NONE ) ) { - aURL.setExtension( aExt ); + if( 0 == (nFlags & XOUTBMP_DONT_ADD_EXTENSION)) + aURL.setExtension( aExt ); rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); nErr = ExportGraphic( aGraphic, aURL, *pFilter, nFilter, NULL ); } diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx index 305b181a65a2..a86baef14810 100644 --- a/svx/source/xoutdev/xpool.cxx +++ b/svx/source/xoutdev/xpool.cxx @@ -52,8 +52,8 @@ XOutdevItemPool::XOutdevItemPool( const XubString aNullStr; const Bitmap aNullBmp; const basegfx::B2DPolyPolygon aNullPol; - const Color aNullLineCol(RGB_Color(COL_DEFAULT_SHAPE_STROKE)); - const Color aNullFillCol(RGB_Color(COL_DEFAULT_SHAPE_FILLING)); + const Color aNullLineCol(RGB_Color(COL_BLACK)); + const Color aNullFillCol(RGB_COLORDATA( 153, 204, 255 )); const Color aNullShadowCol(RGB_Color(COL_LIGHTGRAY)); const XDash aNullDash; const XGradient aNullGrad(aNullLineCol, RGB_Color(COL_WHITE)); diff --git a/ucb/source/ucp/gvfs/gvfs_content.cxx b/ucb/source/ucp/gvfs/gvfs_content.cxx index 3b1d726f9304..666c0616ba0e 100644 --- a/ucb/source/ucp/gvfs/gvfs_content.cxx +++ b/ucb/source/ucp/gvfs/gvfs_content.cxx @@ -1177,7 +1177,7 @@ uno::Any Content::mapVFSException( const GnomeVFSResult result, sal_Bool bWrite switch (result) { case GNOME_VFS_OK: - g_error ("VFS_OK mapped to exception."); + g_warning("VFS_OK mapped to exception."); break; case GNOME_VFS_ERROR_EOF: g_warning ("VFS_EOF not handled somewhere."); diff --git a/vbahelper/Library_msforms.mk b/vbahelper/Library_msforms.mk index 3e23c492f32b..58a90a7ccd42 100755 --- a/vbahelper/Library_msforms.mk +++ b/vbahelper/Library_msforms.mk @@ -50,17 +50,17 @@ $(eval $(call gb_Library_add_linked_libs,msforms,\ comphelper \ cppu \ cppuhelper \ + sal \ + sb \ + sfx \ svl \ svt \ + svx \ + stl \ + tk \ tl \ - sal \ vbahelper \ - sfx \ - svx \ vcl \ - tk \ - sb \ - stl \ $(gb_STDLIBS) \ )) @@ -79,6 +79,7 @@ $(eval $(call gb_Library_add_exception_objects,msforms,\ vbahelper/source/msforms/vbalistbox \ vbahelper/source/msforms/vbalistcontrolhelper \ vbahelper/source/msforms/vbamultipage \ + vbahelper/source/msforms/vbanewfont \ vbahelper/source/msforms/vbapages \ vbahelper/source/msforms/vbaprogressbar \ vbahelper/source/msforms/vbaradiobutton \ diff --git a/vbahelper/Library_vbahelper.mk b/vbahelper/Library_vbahelper.mk index 722b66d709a1..af6b4089ada8 100755 --- a/vbahelper/Library_vbahelper.mk +++ b/vbahelper/Library_vbahelper.mk @@ -50,25 +50,27 @@ $(eval $(call gb_Library_set_defs,vbahelper,\ # add libraries to be linked to vbahelper; again these names need to be given as # specified in Repository.mk $(eval $(call gb_Library_add_linked_libs,vbahelper,\ + comphelper \ cppu \ cppuhelper \ - comphelper \ - sb \ - tl \ + msfilter \ sal \ + sb \ sfx \ stl \ - svt \ - vcl \ svl \ - msfilter \ + svt \ tk \ + tl \ + utl \ + vcl \ $(gb_STDLIBS) \ )) # add all source files that shall be compiled with exceptions enabled # the name is relative to $(SRCROOT) and must not contain an extension $(eval $(call gb_Library_add_exception_objects,vbahelper,\ + vbahelper/source/vbahelper/collectionbase \ vbahelper/source/vbahelper/vbaapplicationbase \ vbahelper/source/vbahelper/vbacolorformat \ vbahelper/source/vbahelper/vbacommandbar \ diff --git a/vbahelper/Package_inc.mk b/vbahelper/Package_inc.mk index 6d8033aa5b02..385fbf15a625 100755 --- a/vbahelper/Package_inc.mk +++ b/vbahelper/Package_inc.mk @@ -26,6 +26,7 @@ #************************************************************************* $(eval $(call gb_Package_Package,vbahelper_inc,$(SRCDIR)/vbahelper/inc)) +$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/collectionbase.hxx,vbahelper/collectionbase.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/helperdecl.hxx,vbahelper/helperdecl.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbaaccesshelper.hxx,vbahelper/vbaaccesshelper.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbaapplicationbase.hxx,vbahelper/vbaapplicationbase.hxx)) @@ -47,5 +48,6 @@ $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashaperange.hxx, $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashapes.hxx,vbahelper/vbashapes.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbatextframe.hxx,vbahelper/vbatextframe.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbawindowbase.hxx,vbahelper/vbawindowbase.hxx)) +$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/weakreference.hxx,vbahelper/weakreference.hxx)) # vim: set noet sw=4 ts=4: diff --git a/vbahelper/inc/vbahelper/collectionbase.hxx b/vbahelper/inc/vbahelper/collectionbase.hxx new file mode 100755 index 000000000000..ebb5bf8f2b9a --- /dev/null +++ b/vbahelper/inc/vbahelper/collectionbase.hxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2011 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VBAHELPER_COLLECTIONBASE_HXX +#define VBAHELPER_COLLECTIONBASE_HXX + +#include <vector> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/container/XElementAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <ooo/vba/XCollectionBase.hpp> +#include <cppuhelper/implbase1.hxx> +#include <vbahelper/vbahelper.hxx> + +namespace vbahelper { + +// ============================================================================ + +typedef ::cppu::WeakImplHelper1< ov::XCollectionBase > CollectionBase_BASE; + +/** Base class of VBA objects implementing the VBA collection concept. + + This base class intentionally does not include the interface + XHelperInterface supported by all application VBA object. There may be + other VBA objects that do not support the special methods provided by + XHelperInterface. + */ +class VBAHELPER_DLLPUBLIC CollectionBase : public CollectionBase_BASE +{ +public: + /** Enumerates different container types a VBA collection can be based on. */ + enum ContainerType + { + /** Container elements are VBA items. + + The initial container contains the final VBA items provided by the + VBA collection. No conversion takes place on item access. + */ + CONTAINER_NATIVE_VBA, + + /** Container elements will be converted to VBA items on demand. + + The initial container contains intermediate objects (e.g. UNO + objects) which will be converted to VBA items everytime the item is + accessed (e.g. item access method, enumeration). Changes in the + initial container are reflected by the collection. + */ + CONTAINER_CONVERT_ON_DEMAND, + }; + + // ------------------------------------------------------------------------ + + CollectionBase( const css::uno::Type& rElementType ); + + // ------------------------------------------------------------------------ + + // attributes + virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException); + // XDefaultMethod + virtual ::rtl::OUString SAL_CALL getDefaultMethodName() throw (css::uno::RuntimeException); + + // ------------------------------------------------------------------------ + + /** Associates this collection with the passed UNO container. + + @param rxElementAccess + The UNO container with the elements of this collection. Shall + support either XIndexAccess or XNameAccess, may support both. + + If the container does not support XIndexAccess, index access is + simulated based on the order returned by the function + XNameAccess::getElementNames(). + + If the container does not support XNameAccess, name access is + simulated by iterating the elements via index access and asking the + elements for their name via the interface XNamed. If the elements + do not support XNamed, the elements cannot be accessed by name. + + @param eContainerType + Specifies the type of the passed container. + */ + void initContainer( + const css::uno::Reference< css::container::XElementAccess >& rxElementAccess, + ContainerType eContainerType ) throw (css::uno::RuntimeException); + + /** Initializes this collection with copies of all elements in the passed + temporary STL vector. + + @param rElements + The STL vector with the named elements of this collection. + @param eContainerType + Specifies the type of the passed vector. + */ + void initElements( + const ::std::vector< css::uno::Reference< css::container::XNamed > >& rElements, + ContainerType eContainerType ) throw (css::uno::RuntimeException); + + /** Initializes this collection with copies of all elements in the passed + temporary STL vector. + + @param rElements + The STL vector with the named elements of this collection. + @param eContainerType + Specifies the type of the passed vector. + */ + void initElements( + const ::std::vector< css::beans::NamedValue >& rElements, + ContainerType eContainerType ) throw (css::uno::RuntimeException); + + /** Returns a VBA implementation object from the passed element. + + If the container type is CONTAINER_NATIVE_VBA, returns the passed + object unmodified. If the container type is CONTAINER_CONVERT_ON_DEMAND, + calls the virtual function implCreateCollectionItem() that implements + creation of the VBA implmentation object. + + @param rElement + The container element the VBA implementation object is based on. + + @param rIndex + The index or name that has been used to access the item. + */ + css::uno::Any createCollectionItem( + const css::uno::Any& rElement, + const css::uno::Any& rIndex ) throw (css::uno::RuntimeException); + + /** Returns a collection item specified by its one-based item index. + + @param nIndex + The one-based index of the collection item. + */ + css::uno::Any getItemByIndex( sal_Int32 nIndex ) throw (css::uno::RuntimeException); + + /** Returns a collection item specified by its name. + + @param rName + The name of the collection item. + */ + css::uno::Any getItemByName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException); + + /** Returns a collection item specified by its index or name. + + @param rIndex + The index or name of the collection item. May be empty, in that + case the entire collection is returned. + */ + css::uno::Any getAnyItemOrThis( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException); + + /** Returns a collection item of a specific type specified by its index or + name. + + @param rIndex + The index or name of the collection item. + */ + template< typename XType > + inline css::uno::Reference< XType > getAnyItem( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException) + { css::uno::Any aRet; if( rIndex.hasValue() ) aRet = getAnyItemOrThis( rIndex ); return css::uno::Reference< XType >( aRet, css::uno::UNO_QUERY_THROW ); } + +protected: + /** Derived classes implement creation of a VBA implementation object from + the passed intermediate container element. + + May be kept unimplemented if container type is CONTAINER_NATIVE_VBA. + + @param rElement + The container element the VBA implementation object is based on. + + @param rIndex + The index or name used to access the item. Can be used by + implementations as a hint how to find or convert the VBA object. + */ + virtual css::uno::Any implCreateCollectionItem( const css::uno::Any& rElement, const css::uno::Any& rIndex ) throw (css::uno::RuntimeException); + +private: + css::uno::Reference< css::container::XIndexAccess > mxIndexAccess; + css::uno::Reference< css::container::XNameAccess > mxNameAccess; + css::uno::Type maElementType; + bool mbConvertOnDemand; +}; + +// ============================================================================ + +} // namespace vbahelper + +#endif diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx index 6902bc7b5042..10cf0ba6ab70 100644 --- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx +++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx @@ -60,7 +60,6 @@ public: virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getVBProjects() throw (css::uno::RuntimeException); virtual void SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException); virtual void SAL_CALL OnTime( const css::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const css::uno::Any& aLatestTime, const css::uno::Any& aSchedule ) throw (css::uno::RuntimeException); diff --git a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx index 601d996a5e64..da0fd29267ae 100644 --- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx +++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx @@ -88,8 +88,8 @@ private: /** A wrapper that holds a com.sun.star.container.XEnumeration or a com.sun.star.container.XIndexAccess and provides an enumeration of VBA objects. - The method nextElement() needs to be implemented by the derived class. This - class can be used to convert an enumeration or an index container + The method createCollectionObject() needs to be implemented by the derived + class. This class can be used to convert an enumeration or an index container containing UNO objects to an enumeration providing the related VBA objects. */ class VBAHELPER_DLLPUBLIC SimpleEnumerationBase : public EnumerationHelper_BASE diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx index 2588b7da1720..d1c7320fbfb1 100644 --- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx +++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx @@ -37,6 +37,7 @@ class VBAHELPER_DLLPUBLIC VbaDocumentBase : public VbaDocumentBase_BASE { protected: css::uno::Reference< css::frame::XModel > mxModel; + css::uno::Reference< css::uno::XInterface > mxVBProject; protected: virtual css::uno::Reference< css::frame::XModel > getModel() { return mxModel; } VbaDocumentBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext); diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx index 659837535ace..dc554d6a043f 100755 --- a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx +++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx @@ -28,20 +28,26 @@ #ifndef VBAHELPER_VBAEVENTSHELPERBASE_HXX #define VBAHELPER_VBAEVENTSHELPERBASE_HXX -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> -#include <cppuhelper/implbase2.hxx> -#include <map> #include <deque> +#include <hash_map> +#include <map> +#include <com/sun/star/document/XEventListener.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> +#include <com/sun/star/util/XChangesListener.hpp> +#include <cppuhelper/implbase3.hxx> #include "vbahelper/vbahelper.hxx" namespace com { namespace sun { namespace star { + namespace script { namespace vba { class XVBAModuleInfo; } } namespace uno { class XComponentContext; } } } } // ============================================================================ -typedef ::cppu::WeakImplHelper2< css::script::vba::XVBAEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE; +typedef ::cppu::WeakImplHelper3< + css::script::vba::XVBAEventProcessor, + css::document::XEventListener, + css::util::XChangesListener > VbaEventsHelperBase_BASE; class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE { @@ -51,15 +57,24 @@ public: const css::uno::Reference< css::uno::XComponentContext >& xContext ); virtual ~VbaEventsHelperBase(); - // XVBAEventProcessor + // script::vba::XVBAEventProcessor virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); - virtual void SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::script::provider::ScriptFrameworkErrorException, css::util::VetoException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::util::VetoException, css::uno::RuntimeException); - // XEventListener - virtual void SAL_CALL disposing( const css::lang::EventObject& aSource ) throw (css::uno::RuntimeException); + // document::XEventListener + virtual void SAL_CALL notifyEvent( const css::document::EventObject& rEvent ) throw (css::uno::RuntimeException); + + // util::XChangesListener + virtual void SAL_CALL changesOccurred( const css::util::ChangesEvent& rEvent ) throw (css::uno::RuntimeException); + + // lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& rEvent ) throw (css::uno::RuntimeException); // little helpers --------------------------------------------------------- + /** Helper to execute event handlers without throwing any exceptions. */ + void processVbaEventNoThrow( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ); + /** Throws, if the passed sequence does not contain a value at the specified index. */ static inline void checkArgument( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException) { if( (nIndex < 0) || (nIndex >= rArgs.getLength()) ) throw css::lang::IllegalArgumentException(); } @@ -72,12 +87,11 @@ public: protected: // ------------------------------------------------------------------------ - enum EventHandlerType { EVENTHANDLER_GLOBAL, EVENTHANDLER_DOCUMENT }; struct EventHandlerInfo { sal_Int32 mnEventId; + sal_Int32 mnModuleType; ::rtl::OUString maMacroName; - EventHandlerType meType; sal_Int32 mnCancelIndex; css::uno::Any maUserData; }; @@ -85,14 +99,14 @@ protected: /** Registers a supported event handler. @param nEventId Event identifier from com.sun.star.script.vba.VBAEventId. + @param nModuleType Type of the module containing the event handler. @param pcMacroName Name of the associated VBA event handler macro. - @param eType Document event or global event. @param nCancelIndex 0-based index of Cancel parameter, or -1. @param rUserData User data for free usage in derived implementations. */ void registerEventHandler( sal_Int32 nEventId, + sal_Int32 nModuleType, const sal_Char* pcMacroName, - EventHandlerType eType = EVENTHANDLER_DOCUMENT, sal_Int32 nCancelIndex = -1, const css::uno::Any& rUserData = css::uno::Any() ); @@ -124,7 +138,6 @@ protected: virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, - bool bSuccess, bool bCancel ) throw (css::uno::RuntimeException) = 0; /** Derived classes have to return the name of the Basic document module. */ @@ -133,25 +146,42 @@ protected: const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException) = 0; private: + typedef ::std::map< sal_Int32, ::rtl::OUString > ModulePathMap; + + /** Starts listening at the document model. */ + void startListening(); + /** Stops listening at the document model. */ + void stopListening(); + /** Returns the event handler info struct for the specified event, or throws. */ const EventHandlerInfo& getEventHandlerInfo( sal_Int32 nEventId ) const throw (css::lang::IllegalArgumentException); /** Searches the event handler in the document and returns its full script path. */ ::rtl::OUString getEventHandlerPath( const EventHandlerInfo& rInfo, - const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); - /** Removes this instance from all broadcasters. */ - void stopListening(); + /** On first call, accesses the Basic library containing the VBA source code. */ + void ensureVBALibrary() throw (css::uno::RuntimeException); + + /** Returns the type of the Basic module with the specified name. */ + sal_Int32 getModuleType( const ::rtl::OUString& rModuleName ) throw (css::uno::RuntimeException); + + /** Updates the map containing paths to event handlers for a Basic module. */ + ModulePathMap& updateModulePathMap( const ::rtl::OUString& rModuleName ) throw (css::uno::RuntimeException); protected: css::uno::Reference< css::frame::XModel > mxModel; SfxObjectShell* mpShell; private: - typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerMap; + typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerInfoMap; + typedef ::std::hash_map< ::rtl::OUString, ModulePathMap, ::rtl::OUStringHash > EventHandlerPathMap; - EventHandlerMap maEvents; + EventHandlerInfoMap maEventInfos; + EventHandlerPathMap maEventPaths; + css::uno::Reference< css::script::vba::XVBAModuleInfo > mxModuleInfos; + ::rtl::OUString maLibraryName; bool mbDisposed; }; diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index 22dc9a8f6cc8..bf20541eff1e 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -63,7 +63,12 @@ namespace ooo throw css::lang::IllegalArgumentException(); return aSomething; } - VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ); + + class XHelperInterface; + + /** Returns the VBA document implementation object representing the passed UNO document model. */ + VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getVBADocument( const css::uno::Reference< css::frame::XModel >& xModel ); + VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ); VBAHELPER_DLLPUBLIC SfxObjectShell* getSfxObjShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException); @@ -90,18 +95,32 @@ namespace ooo VBAHELPER_DLLPUBLIC void PrintOutHelper( SfxViewShell* pViewShell, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, sal_Bool bSelection ); VBAHELPER_DLLPUBLIC void PrintPreviewHelper( const css::uno::Any& EnableChanges, SfxViewShell* ); - /** Extracts a boolean value from the passed Any, which may contain sal_Bool or an integer or floating-point value. - Returns false, if the Any is empty or contains an incompatible type. */ - VBAHELPER_DLLPUBLIC bool extractBoolFromAny( bool& rbValue, const css::uno::Any& rAny ); - /** Extracts a boolean value from the passed Any, which may contain sal_Bool or an integer or floating-point value. + /** Extracts a 32-bit integer value from the passed Any, which may contain an integer or floating-point value. + Throws, if the Any is empty or contains an incompatible type. */ + VBAHELPER_DLLPUBLIC sal_Int32 extractIntFromAny( const css::uno::Any& rAny ) throw (css::uno::RuntimeException); + /** Extracts a 32-bit integer value from the passed Any, which may contain an integer or floating-point value. + Returns nDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */ + VBAHELPER_DLLPUBLIC sal_Int32 extractIntFromAny( const css::uno::Any& rAny, sal_Int32 nDefault ) throw (css::uno::RuntimeException); + + /** Extracts a boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value. Throws, if the Any is empty or contains an incompatible type. */ VBAHELPER_DLLPUBLIC bool extractBoolFromAny( const css::uno::Any& rAny ) throw (css::uno::RuntimeException); + /** Extracts a boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value. + Returns bDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */ + VBAHELPER_DLLPUBLIC bool extractBoolFromAny( const css::uno::Any& rAny, bool bDefault ) throw (css::uno::RuntimeException); + + /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string. + Throws, if the Any is empty or contains an incompatible type. */ + VBAHELPER_DLLPUBLIC ::rtl::OUString extractStringFromAny( const css::uno::Any& rAny, bool bUppercaseBool = false ) throw (css::uno::RuntimeException); + /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string. + Returns rDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */ + VBAHELPER_DLLPUBLIC ::rtl::OUString extractStringFromAny( const css::uno::Any& rAny, const ::rtl::OUString& rDefault, bool bUppercaseBool = false ) throw (css::uno::RuntimeException); VBAHELPER_DLLPUBLIC rtl::OUString getAnyAsString( const css::uno::Any& pvargItem ) throw ( css::uno::RuntimeException ); VBAHELPER_DLLPUBLIC rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike = false); // needs to be in an uno service ( already this code is duplicated in basic ) - VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical); - VBAHELPER_DLLPUBLIC double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical); - VBAHELPER_DLLPUBLIC double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical); VBAHELPER_DLLPUBLIC sal_Int32 PointsToHmm( double fPoints ); VBAHELPER_DLLPUBLIC double HmmToPoints( sal_Int32 nHmm ); VBAHELPER_DLLPUBLIC sal_Int32 getPointerStyle( const css::uno::Reference< css::frame::XModel >& ); @@ -135,14 +154,21 @@ class VBAHELPER_DLLPUBLIC AbstractGeometryAttributes // probably should replace { public: virtual ~AbstractGeometryAttributes() {} - virtual double getLeft() = 0; + virtual double getLeft() const = 0; virtual void setLeft( double ) = 0; - virtual double getTop() = 0; + virtual double getTop() const = 0; virtual void setTop( double ) = 0; - virtual double getHeight() = 0; + virtual double getHeight() const = 0; virtual void setHeight( double ) = 0; - virtual double getWidth() = 0; + virtual double getWidth() const = 0; virtual void setWidth( double ) = 0; + + virtual double getInnerHeight() const { return 0.0; } + virtual void setInnerHeight( double ) {} + virtual double getInnerWidth() const { return 0.0; } + virtual void setInnerWidth( double ) {} + virtual double getOffsetX() const { return 0.0; } + virtual double getOffsetY() const { return 0.0; } }; namespace msforms { @@ -156,20 +182,13 @@ protected: public: ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException ); - double getHeight(); - - void setHeight(double _fheight) throw ( css::script::BasicErrorException ); - - double getWidth(); - + double getHeight() const; + void setHeight(double _fheight) throw ( css::script::BasicErrorException ); + double getWidth() const; void setWidth(double _fWidth) throw ( css::script::BasicErrorException ); - - double getLeft(); - + double getLeft() const; void setLeft(double _fLeft); - - double getTop(); - + double getTop() const; void setTop(double _fTop); }; @@ -178,13 +197,13 @@ class VBAHELPER_DLLPUBLIC ConcreteXShapeGeometryAttributes : public AbstractGeom std::auto_ptr< ShapeHelper > m_pShapeHelper; public: ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape ); - virtual double getLeft(); + virtual double getLeft() const; virtual void setLeft( double nLeft ); - virtual double getTop(); + virtual double getTop() const; virtual void setTop( double nTop ); - virtual double getHeight(); + virtual double getHeight() const; virtual void setHeight( double nHeight ); - virtual double getWidth(); + virtual double getWidth() const; virtual void setWidth( double nWidth); virtual ~ConcreteXShapeGeometryAttributes(); }; @@ -195,19 +214,39 @@ public: #define VBA_WIDTH "Width" class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes { +public: + UserFormGeometryHelper( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::awt::XControl >& xControl, + double fOffsetX, double fOffsetY ); + virtual double getLeft() const; + virtual void setLeft( double fLeft ); + virtual double getTop() const; + virtual void setTop( double fTop ); + virtual double getWidth() const; + virtual void setWidth( double fWidth ); + virtual double getHeight() const; + virtual void setHeight( double fHeight ); + virtual double getInnerWidth() const; + virtual void setInnerWidth( double fWidth ); + virtual double getInnerHeight() const; + virtual void setInnerHeight( double fHeight ); + virtual double getOffsetX() const; + virtual double getOffsetY() const; + +private: + double implGetPos( bool bPosY ) const; + void implSetPos( double fPos, bool bPosY ); + double implGetSize( bool bHeight, bool bOuter ) const; + void implSetSize( double fSize, bool bHeight, bool bOuter ); + +private: css::uno::Reference< css::awt::XWindow > mxWindow; + css::uno::Reference< css::beans::XPropertySet > mxModelProps; + css::uno::Reference< css::awt::XUnitConversion > mxUnitConv; + double mfOffsetX; + double mfOffsetY; sal_Bool mbDialog; - -public: - UserFormGeometryHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::awt::XControl >& xControl ); - virtual double getLeft(); - virtual void setLeft( double nLeft ); - virtual double getTop(); - virtual void setTop( double nTop ); - virtual double getHeight(); - virtual void setHeight( double nHeight ); - virtual double getWidth(); - virtual void setWidth( double nWidth); }; class VBAHELPER_DLLPUBLIC ContainerUtilities @@ -230,8 +269,8 @@ public: static void exception( css::uno::Exception& ex ) throw( css::script::BasicErrorException ); }; - } // openoffice -} // org + } // vba +} // ooo namespace ov = ooo::vba; diff --git a/vbahelper/inc/vbahelper/vbawindowbase.hxx b/vbahelper/inc/vbahelper/vbawindowbase.hxx index f42c2a19854e..e9f1d40e4bd4 100644 --- a/vbahelper/inc/vbahelper/vbawindowbase.hxx +++ b/vbahelper/inc/vbahelper/vbawindowbase.hxx @@ -24,24 +24,30 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef VBA_WINDOWBASE_HXX #define VBA_WINDOWBASE_HXX -#include <cppuhelper/implbase1.hxx> -#include <ooo/vba/XWindowBase.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/awt/XDevice.hpp> +#include <ooo/vba/XWindowBase.hpp> +#include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/frame/XController.hpp> #include <vbahelper/vbahelperinterface.hxx> -typedef InheritedHelperInterfaceImpl1<ov::XWindowBase > WindowBaseImpl_BASE; +typedef InheritedHelperInterfaceImpl1< ov::XWindowBase > WindowBaseImpl_BASE; class VBAHELPER_DLLPUBLIC VbaWindowBase : public WindowBaseImpl_BASE { -protected: - css::uno::Reference< css::frame::XModel > m_xModel; public: - VbaWindowBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel ); - VbaWindowBase( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext ); + VbaWindowBase( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::frame::XModel >& xModel, + const css::uno::Reference< css::frame::XController >& xController ) + throw (css::uno::RuntimeException); + VbaWindowBase( + css::uno::Sequence< css::uno::Any > const& aArgs, + css::uno::Reference< css::uno::XComponentContext > const& xContext ) + throw (css::uno::RuntimeException); // XWindowBase virtual sal_Int32 SAL_CALL getHeight() throw (css::uno::RuntimeException) ; @@ -58,6 +64,19 @@ public: // XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); + +protected: + css::uno::Reference< css::frame::XController > getController() throw (css::uno::RuntimeException); + css::uno::Reference< css::awt::XWindow > getWindow() throw (css::uno::RuntimeException); + css::uno::Reference< css::awt::XWindow2 > getWindow2() throw (css::uno::RuntimeException); + + css::uno::Reference< css::frame::XModel > m_xModel; + +private: + void construct( const css::uno::Reference< css::frame::XController >& xController ) throw (css::uno::RuntimeException); + + css::uno::WeakReference< css::frame::XController > m_xController; + css::uno::WeakReference< css::awt::XWindow > m_xWindow; }; #endif //VBA_WINDOWBASE_HXX diff --git a/vbahelper/inc/vbahelper/weakreference.hxx b/vbahelper/inc/vbahelper/weakreference.hxx new file mode 100755 index 000000000000..661f3bc5d73e --- /dev/null +++ b/vbahelper/inc/vbahelper/weakreference.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2011 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VBAHELPER_WEAKREFERENCE_HXX +#define VBAHELPER_WEAKREFERENCE_HXX + +#include <cppuhelper/weakref.hxx> +#include <rtl/ref.hxx> + +namespace vbahelper { + +// ============================================================================ + +/** A weak reference holding any UNO implementation object. + + The held object must implement the ::com::sun::star::uno::XWeak interface. + + In difference to the ::com::sun::star::uno::WeakReference<> implementation + from cppuhelper/weakref.hxx, the class type of this weak reference is not + restricted to UNO interface types, but can be used for any C++ class type + implementing the XWeak interface somehow (e.g. ::cppu::WeakImplHelperN<>, + ::cppu::ImplInheritanceHelperN<>, etc.). + */ +template< typename ObjectType > +class WeakReference +{ +public: + /** Default constructor. Creates an empty weak reference. + */ + inline explicit WeakReference() SAL_THROW( () ) : mpObject( 0 ) {} + + /** Initializes this weak reference with the passed reference to an object. + */ + inline explicit WeakReference( const ::rtl::Reference< ObjectType >& rxObject ) SAL_THROW( () ) : + mxWeakRef( rxObject.get() ), mpObject( rxObject.get() ) {} + + /** Releases this weak reference and takes over the passed reference. + */ + inline WeakReference& SAL_CALL operator=( const ::rtl::Reference< ObjectType >& rxObject ) SAL_THROW( () ) + { + mxWeakRef = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XWeak >( rxObject.get() ); + mpObject = rxObject.get(); + return *this; + } + + /** Gets an RTL reference to the referenced object. + + @return Reference or null, if the weakly referenced object is gone. + */ + inline SAL_CALL operator ::rtl::Reference< ObjectType >() SAL_THROW( () ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XWeak > xRef = mxWeakRef; + ::rtl::Reference< ObjectType > xObject; + if( xRef.is() ) + xObject = mpObject; + else + mpObject = 0; + return xObject; + } + +private: + ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XWeak > mxWeakRef; + ObjectType* mpObject; +}; + +// ============================================================================ + +} // namespace vbahelper + +#endif diff --git a/vbahelper/prj/build.lst b/vbahelper/prj/build.lst index 312c9b062233..be2e516de360 100644 --- a/vbahelper/prj/build.lst +++ b/vbahelper/prj/build.lst @@ -1,3 +1,3 @@ -vba vbahelper : oovbaapi offuh basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal LIBXSLT:libxslt NULL +vba vbahelper : oovbaapi offuh basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal unotools LIBXSLT:libxslt NULL vba vbahelper usr1 - all vba_mkout NULL vba vbahelper\prj nmake - all vba_prj NULL diff --git a/vbahelper/source/msforms/vbabutton.cxx b/vbahelper/source/msforms/vbabutton.cxx index 21693128c899..775a05cbb5b5 100644 --- a/vbahelper/source/msforms/vbabutton.cxx +++ b/vbahelper/source/msforms/vbabutton.cxx @@ -24,8 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbabutton.hxx" -#include <vector> +#include "vbanewfont.hxx" using namespace com::sun::star; using namespace ooo::vba; @@ -51,6 +52,56 @@ ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); } +sal_Bool SAL_CALL ScVbaButton::getAutoSize() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException) +{ +} + +sal_Bool SAL_CALL ScVbaButton::getCancel() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException) +{ +} + +sal_Bool SAL_CALL ScVbaButton::getDefault() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaButton::getBackColor() throw (uno::RuntimeException) +{ + return 0; +} + +void SAL_CALL ScVbaButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaButton::getForeColor() throw (uno::RuntimeException) +{ + return 0; +} + +void SAL_CALL ScVbaButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException) +{ +} + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaButton::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaButton::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbabutton.hxx b/vbahelper/source/msforms/vbabutton.hxx index 1c65c293f76c..93a55e1bf73a 100644 --- a/vbahelper/source/msforms/vbabutton.hxx +++ b/vbahelper/source/msforms/vbabutton.hxx @@ -27,12 +27,12 @@ #ifndef SC_VBA_BUTTON_HXX #define SC_VBA_BUTTON_HXX #include <cppuhelper/implbase1.hxx> -#include <ooo/vba/msforms/XButton.hpp> +#include <ooo/vba/msforms/XCommandButton.hpp> #include "vbacontrol.hxx" #include <vbahelper/vbahelper.hxx> -typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XButton > ButtonImpl_BASE; +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XCommandButton > ButtonImpl_BASE; class ScVbaButton : public ButtonImpl_BASE { @@ -41,6 +41,17 @@ public: // Attributes virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException); + virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException); + virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); diff --git a/vbahelper/source/msforms/vbacheckbox.cxx b/vbahelper/source/msforms/vbacheckbox.cxx index e9ea64f772b6..329586cf6b27 100644 --- a/vbahelper/source/msforms/vbacheckbox.cxx +++ b/vbahelper/source/msforms/vbacheckbox.cxx @@ -24,9 +24,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbacheckbox.hxx" +#include "vbanewfont.hxx" #include <vbahelper/helperdecl.hxx> -#include <vector> using namespace com::sun::star; using namespace ooo::vba; @@ -83,6 +84,12 @@ ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeExcept } m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) ); } + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaCheckbox::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbacheckbox.hxx b/vbahelper/source/msforms/vbacheckbox.hxx index 34d0828e0c66..59e4d7e75e49 100644 --- a/vbahelper/source/msforms/vbacheckbox.hxx +++ b/vbahelper/source/msforms/vbacheckbox.hxx @@ -27,12 +27,12 @@ #ifndef SC_VBA_CHECKBOX_HXX #define SC_VBA_CHECKBOX_HXX #include <cppuhelper/implbase2.hxx> -#include <ooo/vba/msforms/XRadioButton.hpp> +#include <ooo/vba/msforms/XCheckBox.hpp> #include "vbacontrol.hxx" #include <vbahelper/vbahelper.hxx> -typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > CheckBoxImpl_BASE; +typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XCheckBox, css::script::XDefaultProperty > CheckBoxImpl_BASE; class ScVbaCheckbox : public CheckBoxImpl_BASE { @@ -43,6 +43,7 @@ public: virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // XDefaultProperty rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } //XHelperInterface diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx index 0b5f1af30bb7..9a75fa5cbaa1 100644 --- a/vbahelper/source/msforms/vbacombobox.cxx +++ b/vbahelper/source/msforms/vbacombobox.cxx @@ -24,8 +24,15 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbacombobox.hxx" -#include <vector> +#include "vbanewfont.hxx" +#include <ooo/vba/msforms/fmStyle.hpp> +#include <ooo/vba/msforms/fmDropButtonStyle.hpp> +#include <ooo/vba/msforms/fmDragBehavior.hpp> +#include <ooo/vba/msforms/fmEnterFieldBehavior.hpp> +#include <ooo/vba/msforms/fmListStyle.hpp> +#include <ooo/vba/msforms/fmTextAlign.hpp> using namespace com::sun::star; using namespace ooo::vba; @@ -41,9 +48,17 @@ const static rtl::OUString CONTROLSOURCEPROP( RTL_CONSTASCII_USTRINGPARAM("DataF ScVbaComboBox::ScVbaComboBox( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialogType ) : ComboBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialogType( bDialogType ) { - mpListHelper.reset( new ListControlHelper( m_xProps ) ); - // grab the default value property name - m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName; + mpListHelper.reset( new ListControlHelper( m_xProps ) ); + try + { + // grab the default value property name + m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName; + } + catch( uno::Exception& ) + { + } + if( sSourceName.getLength() == 0 ) + sSourceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ); } // Attributes @@ -103,7 +118,8 @@ ScVbaComboBox::getListIndex() throw (uno::RuntimeException) void SAL_CALL ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException) { - m_xProps->setPropertyValue( sSourceName, _value ); + // booleans are converted to uppercase strings + m_xProps->setPropertyValue( sSourceName, uno::Any( extractStringFromAny( _value, ::rtl::OUString(), true ) ) ); } // see Value @@ -131,22 +147,22 @@ ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) void SAL_CALL ScVbaComboBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException) - { +{ mpListHelper->removeItem( index ); } void SAL_CALL ScVbaComboBox::Clear( ) throw (uno::RuntimeException) - { +{ mpListHelper->Clear(); - } +} void SAL_CALL ScVbaComboBox::setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException) { ScVbaControl::setRowSource( _rowsource ); mpListHelper->setRowSource( _rowsource ); - } +} sal_Int32 SAL_CALL ScVbaComboBox::getListCount() throw (uno::RuntimeException) @@ -158,7 +174,71 @@ uno::Any SAL_CALL ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException) { return mpListHelper->List( pvargIndex, pvarColumn ); - } +} + +sal_Int32 SAL_CALL ScVbaComboBox::getStyle() throw (uno::RuntimeException) +{ + return msforms::fmStyle::fmStyleDropDownCombo; +} + +void SAL_CALL ScVbaComboBox::setStyle( sal_Int32 /*nStyle*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getDropButtonStyle() throw (uno::RuntimeException) +{ + return msforms::fmDropButtonStyle::fmDropButtonStyleArrow; +} + +void SAL_CALL ScVbaComboBox::setDropButtonStyle( sal_Int32 /*nDropButtonStyle*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getDragBehavior() throw (uno::RuntimeException) +{ + return msforms::fmDragBehavior::fmDragBehaviorDisabled; +} + +void SAL_CALL ScVbaComboBox::setDragBehavior( sal_Int32 /*nDragBehavior*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getEnterFieldBehavior() throw (uno::RuntimeException) +{ + return msforms::fmEnterFieldBehavior::fmEnterFieldBehaviorSelectAll; +} + +void SAL_CALL ScVbaComboBox::setEnterFieldBehavior( sal_Int32 /*nEnterFieldBehavior*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getListStyle() throw (uno::RuntimeException) +{ + return msforms::fmListStyle::fmListStylePlain; +} + +void SAL_CALL ScVbaComboBox::setListStyle( sal_Int32 /*nListStyle*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getTextAlign() throw (uno::RuntimeException) +{ + return msforms::fmTextAlign::fmTextAlignLeft; +} + +void SAL_CALL ScVbaComboBox::setTextAlign( sal_Int32 /*nTextAlign*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getTextLength() throw (uno::RuntimeException) +{ + return getText().getLength(); +} + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaComboBox::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} rtl::OUString& ScVbaComboBox::getServiceImplName() diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx index 28215d16dcd7..c73b617a743b 100644 --- a/vbahelper/source/msforms/vbacombobox.hxx +++ b/vbahelper/source/msforms/vbacombobox.hxx @@ -58,6 +58,20 @@ public: virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException); virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setStyle( sal_Int32 nStyle ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDropButtonStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setDropButtonStyle( sal_Int32 nDropButtonStyle ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDragBehavior() throw (css::uno::RuntimeException); + virtual void SAL_CALL setDragBehavior( sal_Int32 nDragBehavior ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getEnterFieldBehavior() throw (css::uno::RuntimeException); + virtual void SAL_CALL setEnterFieldBehavior( sal_Int32 nEnterFieldBehavior ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getListStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setListStyle( sal_Int32 nListStyle ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTextAlign() throw (css::uno::RuntimeException); + virtual void SAL_CALL setTextAlign( sal_Int32 nTextAlign ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // Methods virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index ed9f83a7c647..780191885049 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -43,8 +43,8 @@ #ifdef VBA_OOBUILD_HACK #include <svtools/bindablecontrolhelper.hxx> #endif -#include"vbacontrol.hxx" -#include"vbacombobox.hxx" +#include "vbacontrol.hxx" +#include "vbacombobox.hxx" #include "vbabutton.hxx" #include "vbalabel.hxx" #include "vbatextbox.hxx" @@ -397,99 +397,104 @@ void SAL_CALL ScVbaControl::setTag( const ::rtl::OUString& aTag ) m_aControlTag = aTag; } - -//ScVbaControlFactory - -ScVbaControlFactory::ScVbaControlFactory( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel ): m_xContext( xContext ), m_xControl( xControl ), m_xModel( xModel ) +sal_Int32 SAL_CALL ScVbaControl::getTabIndex() throw (uno::RuntimeException) { + return 1; } -ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException) +void SAL_CALL ScVbaControl::setTabIndex( sal_Int32 /*nTabIndex*/ ) throw (uno::RuntimeException) { - uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ); - if ( xControlShape.is() ) // form controls - return createControl( xControlShape, xParent ); - uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY ); - if ( !xControl.is() ) - throw uno::RuntimeException(); // really we should be more informative - return createControl( xControl, xParent ); } -ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< uno::XInterface >& /*xParent*/ ) throw (uno::RuntimeException) +//ScVbaControlFactory + +/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createShapeControl( + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< drawing::XControlShape >& xControlShape, + const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps( xControlShape->getControl(), uno::UNO_QUERY_THROW ); sal_Int32 nClassId = -1; const static rtl::OUString sClassId( RTL_CONSTASCII_USTRINGPARAM("ClassId") ); xProps->getPropertyValue( sClassId ) >>= nClassId; uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess + uno::Reference< drawing::XShape > xShape( xControlShape, uno::UNO_QUERY_THROW ); + ::std::auto_ptr< ConcreteXShapeGeometryAttributes > xGeoHelper( new ConcreteXShapeGeometryAttributes( xContext, xShape ) ); + switch( nClassId ) { case form::FormComponentType::COMBOBOX: - return new ScVbaComboBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaComboBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::COMMANDBUTTON: - return new ScVbaButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::FIXEDTEXT: - return new ScVbaLabel( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaLabel( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::TEXTFIELD: - return new ScVbaTextBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaTextBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::RADIOBUTTON: - return new ScVbaRadioButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaRadioButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::LISTBOX: - return new ScVbaListBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaListBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::SPINBUTTON: - return new ScVbaSpinButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaSpinButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::IMAGECONTROL: - return new ScVbaImage( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - default: - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Donot support this Control Type." ), uno::Reference< uno::XInterface >() ); + return new ScVbaImage( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); } + throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() ); } -ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException) +/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createUserformControl( + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< awt::XControl >& xControl, + const uno::Reference< awt::XControl >& xDialog, + const uno::Reference< frame::XModel >& xModel, + double fOffsetX, double fOffsetY ) throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps( xControl->getModel(), uno::UNO_QUERY_THROW ); uno::Reference< lang::XServiceInfo > xServiceInfo( xProps, uno::UNO_QUERY_THROW ); - ScVbaControl* pControl = NULL; + uno::Reference< msforms::XControl > xVBAControl; uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess + ::std::auto_ptr< UserFormGeometryHelper > xGeoHelper( new UserFormGeometryHelper( xContext, xControl, fOffsetX, fOffsetY ) ); + if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) ) - pControl = new ScVbaCheckbox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaCheckbox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) ) - pControl = new ScVbaRadioButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaRadioButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) ) - pControl = new ScVbaTextBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true ); + xVBAControl.set( new ScVbaTextBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), true ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) ) { sal_Bool bToggle = sal_False; xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toggle") ) ) >>= bToggle; if ( bToggle ) - pControl = new ScVbaToggleButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaToggleButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else - pControl = new ScVbaButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); } else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) ) - pControl = new ScVbaComboBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true ); + xVBAControl.set( new ScVbaComboBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), true ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) - pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaListBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) ) - pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaLabel( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) ) - pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaImage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) ) - pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaProgressBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) - pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaFrame( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) ) - pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaScrollBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) ) - pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent ); + xVBAControl.set( new ScVbaMultiPage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) ) - pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaSpinButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) ) - pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else - throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() ); - return pControl; + xVBAControl.set( new VbaSystemAXControl( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); + + if( xVBAControl.is() ) + return xVBAControl; + throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() ); } rtl::OUString& @@ -520,7 +525,6 @@ class ControlProviderImpl : public ControlProvider_BASE public: ControlProviderImpl( const uno::Reference< uno::XComponentContext >& xCtx ) : m_xCtx( xCtx ) {} virtual uno::Reference< msforms::XControl > SAL_CALL createControl( const uno::Reference< drawing::XControlShape >& xControl, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException); - virtual uno::Reference< msforms::XControl > SAL_CALL createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException); }; uno::Reference< msforms::XControl > SAL_CALL @@ -528,27 +532,10 @@ ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape { uno::Reference< msforms::XControl > xControlToReturn; if ( xControlShape.is() ) - { - ScVbaControlFactory controlFactory( m_xCtx, xControlShape, xDocOwner ); - xControlToReturn.set( controlFactory.createControl( xDocOwner ) ); - } + xControlToReturn = ScVbaControlFactory::createShapeControl( m_xCtx, xControlShape, xDocOwner ); return xControlToReturn; } -uno::Reference< msforms::XControl > SAL_CALL -ControlProviderImpl::createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException) -{ - uno::Reference< msforms::XControl > xControlToReturn; - if ( xControl.is() && xDialog.is() ) - { - - ScVbaControlFactory controlFactory( m_xCtx, xControl, xDocOwner ); - xControlToReturn.set( controlFactory.createControl( xDialog->getModel() ) ); - ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xControlToReturn.get() ); - pControl->setGeometryHelper( new UserFormGeometryHelper( m_xCtx, xControl ) ); - } - return xControlToReturn; -} namespace controlprovider { diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx index 247eabfe95e8..e421f919b6a4 100644 --- a/vbahelper/source/msforms/vbacontrol.hxx +++ b/vbahelper/source/msforms/vbacontrol.hxx @@ -93,6 +93,8 @@ public: virtual void SAL_CALL setControlTipText( const rtl::OUString& ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getTag() throw (css::uno::RuntimeException); virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException); + virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException); //remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape virtual void removeResouce() throw( css::uno::RuntimeException ); //XHelperInterface @@ -104,15 +106,21 @@ public: class ScVbaControlFactory { public: - ScVbaControlFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext, - const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel ); - ScVbaControl* createControl( const css::uno::Reference< css::uno::XInterface >& xParent ) throw ( css::uno::RuntimeException ); + static css::uno::Reference< ov::msforms::XControl > createShapeControl( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::drawing::XControlShape >& xControlShape, + const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException); + + static css::uno::Reference< ov::msforms::XControl > createUserformControl( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::awt::XControl >& xControl, + const css::uno::Reference< css::awt::XControl >& xDialog, + const css::uno::Reference< css::frame::XModel >& xModel, + double fOffsetX, double fOffsetY ) throw (css::uno::RuntimeException); + private: - ScVbaControl* createControl( const css::uno::Reference< css::awt::XControl >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException ); - ScVbaControl* createControl( const css::uno::Reference< css::drawing::XControlShape >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException ); - css::uno::Reference< css::uno::XComponentContext > m_xContext; - css::uno::Reference< css::uno::XInterface > m_xControl; - css::uno::Reference< css::frame::XModel > m_xModel; + ScVbaControlFactory(); + ~ScVbaControlFactory(); }; #endif//SC_VBA_CONTROL_HXX diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 8d01687ef905..7411f7ad9463 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -27,13 +27,18 @@ #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/awt/FontStrikeout.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/script/XInvocation.hpp> #include <com/sun/star/lang/WrappedTargetException.hpp> #include "vbacontrols.hxx" +#include "vbacontrol.hxx" #include <cppuhelper/implbase2.hxx> -#include <ooo/vba//XControlProvider.hpp> +#include <ooo/vba/XControlProvider.hpp> #include <hash_map> using namespace com::sun::star; @@ -153,11 +158,28 @@ class ControlsEnumWrapper : public EnumerationHelper_BASE uno::Reference<uno::XComponentContext > m_xContext; uno::Reference<container::XIndexAccess > m_xIndexAccess; uno::Reference<awt::XControl > m_xDlg; + uno::Reference< frame::XModel > m_xModel; + double mfOffsetX; + double mfOffsetY; sal_Int32 nIndex; public: - ControlsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< awt::XControl >& xDlg ) : m_xParent( xParent ), m_xContext( xContext), m_xIndexAccess( xIndexAccess ), m_xDlg( xDlg ), nIndex( 0 ) {} + ControlsEnumWrapper( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< container::XIndexAccess >& xIndexAccess, + const uno::Reference< awt::XControl >& xDlg, + const uno::Reference< frame::XModel >& xModel, + double fOffsetX, double fOffsetY ) : + m_xParent( xParent ), + m_xContext( xContext), + m_xIndexAccess( xIndexAccess ), + m_xDlg( xDlg ), + m_xModel( xModel ), + mfOffsetX( fOffsetX ), + mfOffsetY( fOffsetY ), + nIndex( 0 ) {} virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) { @@ -168,14 +190,12 @@ public: { if ( nIndex < m_xIndexAccess->getCount() ) { - uno::Reference< frame::XModel > xModel; uno::Reference< awt::XControl > xControl; m_xIndexAccess->getByIndex( nIndex++ ) >>= xControl; - uno::Reference<lang::XMultiComponentFactory > xServiceManager( m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), m_xContext ), uno::UNO_QUERY_THROW ); - - uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, m_xDlg, xModel ) ); + uno::Reference< msforms::XControl > xVBAControl; + if ( xControl.is() && m_xDlg.is() ) + xVBAControl = ScVbaControlFactory::createUserformControl( m_xContext, xControl, m_xDlg, m_xModel, mfOffsetX, mfOffsetY ); return uno::makeAny( xVBAControl ); } throw container::NoSuchElementException(); @@ -190,17 +210,24 @@ lcl_controlsWrapper( const uno::Reference< awt::XControl >& xDlg ) return new ControlArrayWrapper( xDlg ); } -ScVbaControls::ScVbaControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, - const css::uno::Reference< awt::XControl >& xDialog ) - : ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ) +ScVbaControls::ScVbaControls( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const css::uno::Reference< awt::XControl >& xDialog, + const uno::Reference< frame::XModel >& xModel, + double fOffsetX, double fOffsetY ) : + ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ), + mxDialog( xDialog ), + mxModel( xModel ), + mfOffsetX( fOffsetX ), + mfOffsetY( fOffsetY ) { - mxDialog.set( xDialog, uno::UNO_QUERY ); } uno::Reference< container::XEnumeration > ScVbaControls::createEnumeration() throw (uno::RuntimeException) { - uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog ) ); + uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog, mxModel, mfOffsetX, mfOffsetY ) ); if ( !xEnum.is() ) throw uno::RuntimeException(); return xEnum; @@ -210,15 +237,9 @@ uno::Any ScVbaControls::createCollectionObject( const css::uno::Any& aSource ) { // Create control from awt::XControl - uno::Reference< awt::XControl > xControl; - aSource >>= xControl; - uno::Reference< frame::XModel > xModel; - uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW ); - - uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, mxDialog, xModel ) ); - - return uno::makeAny( xVBAControl ); + uno::Reference< awt::XControl > xControl( aSource, uno::UNO_QUERY_THROW ); + uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, mxDialog, mxModel, mfOffsetX, mfOffsetY ); + return uno::Any( xVBAControl ); } void SAL_CALL @@ -261,23 +282,117 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) ); sal_Int32 nInd = 0; - while( xDialogContainer->hasByName( aNewName ) && nInd < SAL_MAX_INT32 ) + while( xDialogContainer->hasByName( aNewName ) && (nInd < SAL_MAX_INT32) ) { aNewName = aComServiceName; - aNewName += ::rtl::OUString::valueOf( nInd ); + aNewName += ::rtl::OUString::valueOf( nInd++ ); } } + double fDefWidth = 72.0, fDefHeight = 18.0; if ( aComServiceName.getLength() ) { - uno::Reference< awt::XControlModel > xNewModel( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW ); + // create a UNO control model based on the passed control type + uno::Reference< awt::XControlModel > xNewModel; + bool bFontSupport = false; + bool bNativeAX = false; + if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CommandButton.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 24.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Label.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Image.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 72.0; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CheckBox.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 108.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.OptionButton.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 108.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.TextBox.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ListBox.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ComboBox.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ) ), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW ); + xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dropdown" ) ), uno::Any( true ) ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ToggleButton.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW ); + xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Toggle" ) ), uno::Any( true ) ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Frame.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 216.0; fDefHeight = 144.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.SpinButton.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlSpinButtonModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 12.75; fDefHeight = 25.5; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ScrollBar.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 12.75; fDefHeight = 63.8; + } + else + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 18.0; + bNativeAX = true; + } + // need to set a few font properties to get rid of the default DONT_KNOW values + if( bFontSupport ) + { + uno::Reference< beans::XPropertySet > xModelProps( xNewModel, uno::UNO_QUERY_THROW ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ), uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Tahoma" ) ) ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ), uno::Any( float( 8.0 ) ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ), uno::Any( awt::FontWeight::NORMAL ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ), uno::Any( awt::FontSlant_NONE ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ), uno::Any( awt::FontUnderline::NONE ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ), uno::Any( awt::FontStrikeout::NONE ) ); + } xDialogContainer->insertByName( aNewName, uno::makeAny( xNewModel ) ); uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW ); xNewControl = xControlContainer->getControl( aNewName ); - try + if( bNativeAX ) try { uno::Reference< script::XInvocation > xControlInvoke( xNewControl, uno::UNO_QUERY_THROW ); @@ -299,6 +414,11 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St UpdateCollectionIndex( lcl_controlsWrapper( mxDialog ) ); aResult <<= xNewControl; aResult = createCollectionObject( aResult ); + uno::Reference< msforms::XControl > xVBAControl( aResult, uno::UNO_QUERY_THROW ); + if( fDefWidth > 0.0 ) + xVBAControl->setWidth( fDefWidth ); + if( fDefHeight > 0.0 ) + xVBAControl->setHeight( fDefHeight ); } else throw uno::RuntimeException(); @@ -376,21 +496,5 @@ ScVbaControls::getElementType() throw (uno::RuntimeException) { return ooo::vba::msforms::XControl::static_type(0); } -rtl::OUString& -ScVbaControls::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControls") ); - return sImplName; -} -uno::Sequence< rtl::OUString > -ScVbaControls::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Controls" ) ); - } - return aServiceNames; -} +VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaControls, "ooo.vba.msforms.Controls" ) diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx index a72506609531..4b4838a45a8e 100644 --- a/vbahelper/source/msforms/vbacontrols.hxx +++ b/vbahelper/source/msforms/vbacontrols.hxx @@ -38,19 +38,17 @@ typedef CollTestImplHelper< ov::msforms::XControls > ControlsImpl_BASE; class ScVbaControls : public ControlsImpl_BASE { - css::uno::Reference< css::awt::XControl > mxDialog; - -protected: - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); - public: - ScVbaControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, - const css::uno::Reference< css::awt::XControl >& xDialog ); + ScVbaControls( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::awt::XControl >& xDialog, + const css::uno::Reference< css::frame::XModel >& xModel, + double fOffsetX, double fOffsetY ); // XControls virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL Add( const ::com::sun::star::uno::Any& Object, const ::com::sun::star::uno::Any& StringKey, const ::com::sun::star::uno::Any& Before, const ::com::sun::star::uno::Any& After ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL Remove( const ::com::sun::star::uno::Any& StringKeyOrIndex ) throw (::com::sun::star::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Object, const css::uno::Any& StringKey, const css::uno::Any& Before, const css::uno::Any& After ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Remove( const css::uno::Any& StringKeyOrIndex ) throw (css::uno::RuntimeException); // XEnumerationAccess virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); @@ -59,6 +57,15 @@ public: // ScVbaCollectionBaseImpl virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); + // XHelperInterface + VBAHELPER_DECL_XHELPERINTERFACE + +private: + css::uno::Reference< css::awt::XControl > mxDialog; + css::uno::Reference< css::frame::XModel > mxModel; + double mfOffsetX; + double mfOffsetY; }; + #endif //SC_VBA_OLEOBJECTS_HXX diff --git a/vbahelper/source/msforms/vbaframe.cxx b/vbahelper/source/msforms/vbaframe.cxx index c470ee0097e4..4a1fe6a58b49 100644 --- a/vbahelper/source/msforms/vbaframe.cxx +++ b/vbahelper/source/msforms/vbaframe.cxx @@ -24,62 +24,83 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbaframe.hxx" -#include <vector> +#include "vbanewfont.hxx" +#include "vbacontrols.hxx" +#include <ooo/vba/msforms/fmBorderStyle.hpp> +#include <ooo/vba/msforms/fmSpecialEffect.hpp> using namespace com::sun::star; using namespace ooo::vba; const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); -ScVbaFrame::ScVbaFrame( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) + +ScVbaFrame::ScVbaFrame( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< uno::XInterface >& xControl, + const uno::Reference< frame::XModel >& xModel, + ov::AbstractGeometryAttributes* pGeomHelper, + const css::uno::Reference< css::awt::XControl >& xDialog ) : + FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), + mxDialog( xDialog ) { } -// Attributes -rtl::OUString SAL_CALL -ScVbaFrame::getCaption() throw (css::uno::RuntimeException) +// XFrame attributes + +rtl::OUString SAL_CALL ScVbaFrame::getCaption() throw (css::uno::RuntimeException) { rtl::OUString Label; m_xProps->getPropertyValue( LABEL ) >>= Label; return Label; } -void SAL_CALL -ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) { m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); } -uno::Any SAL_CALL -ScVbaFrame::getValue() throw (css::uno::RuntimeException) +sal_Int32 SAL_CALL ScVbaFrame::getSpecialEffect() throw (uno::RuntimeException) { - return uno::makeAny( getCaption() ); + return msforms::fmSpecialEffect::fmSpecialEffectEtched; } -void SAL_CALL -ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL ScVbaFrame::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException) { - rtl::OUString sCaption; - _value >>= sCaption; - setCaption( sCaption ); } -rtl::OUString& -ScVbaFrame::getServiceImplName() +sal_Int32 SAL_CALL ScVbaFrame::getBorderStyle() throw (uno::RuntimeException) { - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFrame") ); - return sImplName; + return msforms::fmBorderStyle::fmBorderStyleNone; } -uno::Sequence< rtl::OUString > -ScVbaFrame::getServiceNames() +void SAL_CALL ScVbaFrame::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException) { - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Frame" ) ); - } - return aServiceNames; } + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaFrame::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + +// XFrame methods + +uno::Any SAL_CALL ScVbaFrame::Controls( const uno::Any& rIndex ) throw (uno::RuntimeException) +{ + // horizontal anchor of frame children is inside border line (add one unit to compensate border line width) + double fOffsetX = mpGeometryHelper->getOffsetX() + getLeft() + 1.0; + // vertical anchor of frame children is inside border line (add half of text height and one unit to compensate border line width) + double fOffsetY = mpGeometryHelper->getOffsetY() + getTop() + (getFont()->getSize() / 2.0) + 1.0; + + uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, mxDialog, m_xModel, fOffsetX, fOffsetY ) ); + if( rIndex.hasValue() ) + return uno::Any( xControls->Item( rIndex, uno::Any() ) ); + return uno::Any( xControls ); +} + +// XHelperInterface + +VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaFrame, "ooo.vba.msforms.Frame" ) diff --git a/vbahelper/source/msforms/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx index 567e58b57272..d76f31230bba 100644 --- a/vbahelper/source/msforms/vbaframe.hxx +++ b/vbahelper/source/msforms/vbaframe.hxx @@ -27,24 +27,39 @@ #ifndef SC_VBA_FRAME_HXX #define SC_VBA_FRAME_HXX #include <cppuhelper/implbase1.hxx> -#include <ooo/vba/msforms/XLabel.hpp> +#include <ooo/vba/msforms/XFrame.hpp> #include "vbacontrol.hxx" #include <vbahelper/vbahelper.hxx> -typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XLabel > FrameImpl_BASE; +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XFrame > FrameImpl_BASE; class ScVbaFrame : public FrameImpl_BASE { public: - ScVbaFrame( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ); - // Attributes - virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); - virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); + ScVbaFrame( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::uno::XInterface >& xControl, + const css::uno::Reference< css::frame::XModel >& xModel, + ov::AbstractGeometryAttributes* pGeomHelper, + const css::uno::Reference< css::awt::XControl >& xDialog ); + + // XFrame attributes virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); + // XFrame methods + css::uno::Any SAL_CALL Controls( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); + +private: + css::uno::Reference< css::awt::XControl > mxDialog; }; #endif //SC_VBA_LABEL_HXX diff --git a/vbahelper/source/msforms/vbalabel.cxx b/vbahelper/source/msforms/vbalabel.cxx index 9bf7a7e001bf..d5aa1176e3d3 100644 --- a/vbahelper/source/msforms/vbalabel.cxx +++ b/vbahelper/source/msforms/vbalabel.cxx @@ -24,8 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbalabel.hxx" -#include <vector> +#include "vbanewfont.hxx" using namespace com::sun::star; using namespace ooo::vba; @@ -64,6 +65,10 @@ ScVbaLabel::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::Run setCaption( sCaption ); } +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaLabel::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} rtl::OUString& ScVbaLabel::getServiceImplName() diff --git a/vbahelper/source/msforms/vbalabel.hxx b/vbahelper/source/msforms/vbalabel.hxx index af3bc074c54d..2dcee186d58b 100644 --- a/vbahelper/source/msforms/vbalabel.hxx +++ b/vbahelper/source/msforms/vbalabel.hxx @@ -44,6 +44,7 @@ public: virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx index 17f8c8341588..8829c8ae7256 100644 --- a/vbahelper/source/msforms/vbalistbox.cxx +++ b/vbahelper/source/msforms/vbalistbox.cxx @@ -24,12 +24,12 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <com/sun/star/form/validation/XValidatableFormComponent.hpp> #include "vbalistbox.hxx" -#include <vector> +#include "vbanewfont.hxx" #include <comphelper/anytostring.hxx> #include <com/sun/star/script/ArrayWrapper.hpp> +#include <com/sun/star/form/validation/XValidatableFormComponent.hpp> using namespace com::sun::star; using namespace ooo::vba; @@ -267,6 +267,11 @@ ScVbaListBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) t return mpListHelper->List( pvargIndex, pvarColumn ); } +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaListBox::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaListBox::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbalistbox.hxx b/vbahelper/source/msforms/vbalistbox.hxx index 3d0797e2b7b2..7dbda1837cb0 100644 --- a/vbahelper/source/msforms/vbalistbox.hxx +++ b/vbahelper/source/msforms/vbalistbox.hxx @@ -60,9 +60,10 @@ public: virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getMultiSelect() throw (css::uno::RuntimeException); virtual void SAL_CALL setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // Methods + virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException); virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException); virtual void SAL_CALL removeItem( const css::uno::Any& index ) throw (css::uno::RuntimeException); virtual void SAL_CALL Clear( ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx index b6587c9b2367..78590f0fd85b 100644 --- a/vbahelper/source/msforms/vbamultipage.cxx +++ b/vbahelper/source/msforms/vbamultipage.cxx @@ -68,9 +68,16 @@ ScVbaMultiPage::getPages( sal_Int32 nPages ) return new PagesImpl( nPages ); } -ScVbaMultiPage::ScVbaMultiPage( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, const uno::Reference< uno::XInterface >& xDialog ) : MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +ScVbaMultiPage::ScVbaMultiPage( + const uno::Reference< ov::XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< uno::XInterface >& xControl, + const uno::Reference< frame::XModel >& xModel, + AbstractGeometryAttributes* pGeomHelper, + const uno::Reference< awt::XControl >& xDialog ) : + MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) { - mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW ); + mxDialogProps.set( xDialog->getModel(), uno::UNO_QUERY_THROW ); // set dialog step to value of multipage pseudo model setValue(getValue()); } diff --git a/vbahelper/source/msforms/vbamultipage.hxx b/vbahelper/source/msforms/vbamultipage.hxx index 4a54525cf95f..328a71b61592 100644 --- a/vbahelper/source/msforms/vbamultipage.hxx +++ b/vbahelper/source/msforms/vbamultipage.hxx @@ -42,7 +42,14 @@ class ScVbaMultiPage : public MultiPageImpl_BASE css::uno::Reference< css::container::XIndexAccess > getPages( sal_Int32 nPages ); css::uno::Reference< css::beans::XPropertySet > mxDialogProps; public: - ScVbaMultiPage( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper, const css::uno::Reference< css::uno::XInterface >& xDialog ); + ScVbaMultiPage( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::uno::XInterface >& xControl, + const css::uno::Reference< css::frame::XModel >& xModel, + ov::AbstractGeometryAttributes* pGeomHelper, + const css::uno::Reference< css::awt::XControl >& xDialog ); + // Attributes virtual sal_Int32 SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue( sal_Int32 _value ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/msforms/vbanewfont.cxx b/vbahelper/source/msforms/vbanewfont.cxx new file mode 100755 index 000000000000..f487b4e6919c --- /dev/null +++ b/vbahelper/source/msforms/vbanewfont.cxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <vbanewfont.hxx> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/awt/FontStrikeout.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> + +using namespace ::com::sun::star; +using namespace ::ooo::vba; + +// ============================================================================ + +VbaNewFont::VbaNewFont( + const uno::Reference< XHelperInterface >& rxParent, + const uno::Reference< uno::XComponentContext >& rxContext, + const uno::Reference< beans::XPropertySet >& rxModelProps ) throw (uno::RuntimeException) : + VbaNewFont_BASE( rxParent, rxContext ), + mxProps( rxModelProps, uno::UNO_SET_THROW ) +{ +} + +// XNewFont attributes + +::rtl::OUString SAL_CALL VbaNewFont::getName() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ) ); + return aAny.get< ::rtl::OUString >(); +} + +void SAL_CALL VbaNewFont::setName( const ::rtl::OUString& rName ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ), + uno::Any( rName ) ); +} + +double SAL_CALL VbaNewFont::getSize() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ) ); + return aAny.get< float >(); +} + +void SAL_CALL VbaNewFont::setSize( double fSize ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ), + uno::Any( static_cast< float >( fSize ) ) ); +} + +sal_Int16 SAL_CALL VbaNewFont::getCharset() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ) ); + return rtl_getBestWindowsCharsetFromTextEncoding( static_cast< rtl_TextEncoding >( aAny.get< sal_Int16 >() ) ); +} + +void SAL_CALL VbaNewFont::setCharset( sal_Int16 nCharset ) throw (uno::RuntimeException) +{ + rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW; + if( (0 <= nCharset) && (nCharset <= SAL_MAX_UINT8) ) + eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( nCharset ) ); + if( eFontEnc == RTL_TEXTENCODING_DONTKNOW ) + throw uno::RuntimeException(); + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ), + uno::Any( static_cast< sal_Int16 >( eFontEnc ) ) ); +} + +sal_Int16 SAL_CALL VbaNewFont::getWeight() throw (uno::RuntimeException) +{ + return getBold() ? 700 : 400; +} + +void SAL_CALL VbaNewFont::setWeight( sal_Int16 nWeight ) throw (uno::RuntimeException) +{ + setBold( nWeight >= 700 ); +} + +sal_Bool SAL_CALL VbaNewFont::getBold() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ) ); + return aAny.get< float >() > awt::FontWeight::NORMAL; +} + +void SAL_CALL VbaNewFont::setBold( sal_Bool bBold ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ), + uno::Any( bBold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) ); +} + +sal_Bool SAL_CALL VbaNewFont::getItalic() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ) ); + return aAny.get< awt::FontSlant >() != awt::FontSlant_NONE; +} + +void SAL_CALL VbaNewFont::setItalic( sal_Bool bItalic ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ), + uno::Any( bItalic ? awt::FontSlant_ITALIC : awt::FontSlant_NONE ) ); +} + +sal_Bool SAL_CALL VbaNewFont::getUnderline() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ) ); + return aAny.get< sal_Int16 >() != awt::FontUnderline::NONE; +} + +void SAL_CALL VbaNewFont::setUnderline( sal_Bool bUnderline ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ), + uno::Any( bUnderline ? awt::FontUnderline::SINGLE : awt::FontUnderline::NONE ) ); +} + +sal_Bool SAL_CALL VbaNewFont::getStrikethrough() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ) ); + return aAny.get< sal_Int16 >() != awt::FontStrikeout::NONE; +} + +void SAL_CALL VbaNewFont::setStrikethrough( sal_Bool bStrikethrough ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ), + uno::Any( bStrikethrough ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) ); +} + +// XHelperInterface + +VBAHELPER_IMPL_XHELPERINTERFACE( VbaNewFont, "ooo.vba.msforms.NewFont" ) + +// ============================================================================ diff --git a/vbahelper/source/msforms/vbanewfont.hxx b/vbahelper/source/msforms/vbanewfont.hxx new file mode 100755 index 000000000000..d59d5caa139c --- /dev/null +++ b/vbahelper/source/msforms/vbanewfont.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VBAHELPER_MSFORMS_VBANEWFONT_HXX +#define VBAHELPER_MSFORMS_VBANEWFONT_HXX + +#include <ooo/vba/msforms/XNewFont.hpp> +#include <vbahelper/vbahelperinterface.hxx> + +// ============================================================================ + +typedef InheritedHelperInterfaceImpl1< ov::msforms::XNewFont > VbaNewFont_BASE; + +class VbaNewFont : public VbaNewFont_BASE +{ +public: + VbaNewFont( + const css::uno::Reference< ov::XHelperInterface >& rxParent, + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::beans::XPropertySet >& rxModelProps ) throw (css::uno::RuntimeException); + + // XNewFont attributes + virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); + virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getSize() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSize( double fSize ) throw (css::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getCharset() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCharset( sal_Int16 nCharset ) throw (css::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getWeight() throw (css::uno::RuntimeException); + virtual void SAL_CALL setWeight( sal_Int16 nWeight ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBold() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBold( sal_Bool bBold ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getItalic() throw (css::uno::RuntimeException); + virtual void SAL_CALL setItalic( sal_Bool bItalic ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getUnderline() throw (css::uno::RuntimeException); + virtual void SAL_CALL setUnderline( sal_Bool bUnderline ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getStrikethrough() throw (css::uno::RuntimeException); + virtual void SAL_CALL setStrikethrough( sal_Bool bStrikethrough ) throw (css::uno::RuntimeException); + + // XHelperInterface + VBAHELPER_DECL_XHELPERINTERFACE + +private: + css::uno::Reference< css::beans::XPropertySet > mxProps; +}; + +// ============================================================================ + +#endif diff --git a/vbahelper/source/msforms/vbaradiobutton.cxx b/vbahelper/source/msforms/vbaradiobutton.cxx index 94d12c5823ba..12ee1ad8ae41 100644 --- a/vbahelper/source/msforms/vbaradiobutton.cxx +++ b/vbahelper/source/msforms/vbaradiobutton.cxx @@ -24,8 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbaradiobutton.hxx" -#include <vector> +#include "vbanewfont.hxx" using namespace com::sun::star; using namespace ooo::vba; @@ -84,6 +85,11 @@ ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExceptio m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) ); } +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaRadioButton::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaRadioButton::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbaradiobutton.hxx b/vbahelper/source/msforms/vbaradiobutton.hxx index a0de21ae5d0e..3da00eb0765e 100644 --- a/vbahelper/source/msforms/vbaradiobutton.hxx +++ b/vbahelper/source/msforms/vbaradiobutton.hxx @@ -42,6 +42,7 @@ public: virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue(const com::sun::star::uno::Any&) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx index 2d83d41d77c3..b6aedcdceaf6 100644 --- a/vbahelper/source/msforms/vbatextbox.cxx +++ b/vbahelper/source/msforms/vbatextbox.cxx @@ -24,16 +24,16 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <com/sun/star/text/XTextRange.hpp> #include "vbatextbox.hxx" -#include <vector> +#include "vbanewfont.hxx" +#include <com/sun/star/text/XTextRange.hpp> +#include <ooo/vba/msforms/fmBorderStyle.hpp> +#include <ooo/vba/msforms/fmSpecialEffect.hpp> using namespace com::sun::star; using namespace ooo::vba; - - ScVbaTextBox::ScVbaTextBox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialog ) : TextBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialog( bDialog ) { } @@ -48,7 +48,8 @@ ScVbaTextBox::getValue() throw (css::uno::RuntimeException) void SAL_CALL ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException) { - rtl::OUString sVal = getAnyAsString( _value ); + // booleans are converted to uppercase strings + rtl::OUString sVal = extractStringFromAny( _value, true ); setText( sVal ); } @@ -114,6 +115,34 @@ ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeExcept (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue); } +sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect() throw (uno::RuntimeException) +{ + return msforms::fmSpecialEffect::fmSpecialEffectSunken; +} + +void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle() throw (uno::RuntimeException) +{ + return msforms::fmBorderStyle::fmBorderStyleNone; +} + +void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaTextBox::getTextLength() throw (uno::RuntimeException) +{ + return getText().getLength(); +} + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaTextBox::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx index 0553e047488e..586bceb607a0 100644 --- a/vbahelper/source/msforms/vbatextbox.hxx +++ b/vbahelper/source/msforms/vbatextbox.hxx @@ -47,6 +47,12 @@ public: virtual void SAL_CALL setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getMultiline() throw (css::uno::RuntimeException); virtual void SAL_CALL setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // XDefaultProperty rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } //XHelperInterface diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx index 071651ff8a36..d1a3b40d6eb7 100644 --- a/vbahelper/source/msforms/vbatogglebutton.cxx +++ b/vbahelper/source/msforms/vbatogglebutton.cxx @@ -24,8 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbatogglebutton.hxx" -#include <vector> +#include "vbanewfont.hxx" using namespace com::sun::star; using namespace ooo::vba; @@ -79,6 +80,56 @@ ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExcepti m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) ); } +sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException) +{ +} + +sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException) +{ +} + +sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException) +{ + return 0; +} + +void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException) +{ + return 0; +} + +void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException) +{ +} + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaToggleButton::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbatogglebutton.hxx b/vbahelper/source/msforms/vbatogglebutton.hxx index bfdd68d09642..d2bf4c6b7f17 100644 --- a/vbahelper/source/msforms/vbatogglebutton.hxx +++ b/vbahelper/source/msforms/vbatogglebutton.hxx @@ -43,9 +43,19 @@ public: // Attributes virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); - virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException); + virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException); + virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index 16bc97babd7d..3eb799205389 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -54,7 +54,7 @@ ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Refer m_xDialog.set( m_xControl, uno::UNO_QUERY_THROW ); uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW ); m_xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW ); - setGeometryHelper( new UserFormGeometryHelper( xContext, xControl ) ); + setGeometryHelper( new UserFormGeometryHelper( xContext, xControl, 0.0, 0.0 ) ); } ScVbaUserForm::~ScVbaUserForm() @@ -105,18 +105,38 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException) } rtl::OUString SAL_CALL -ScVbaUserForm::getCaption() throw (::com::sun::star::uno::RuntimeException) +ScVbaUserForm::getCaption() throw (uno::RuntimeException) { rtl::OUString sCaption; m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ) ) >>= sCaption; return sCaption; } void -ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) +ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException) { m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) ); } +double SAL_CALL ScVbaUserForm::getInnerWidth() throw (uno::RuntimeException) +{ + return mpGeometryHelper->getInnerWidth(); +} + +void SAL_CALL ScVbaUserForm::setInnerWidth( double fInnerWidth ) throw (uno::RuntimeException) +{ + mpGeometryHelper->setInnerWidth( fInnerWidth ); +} + +double SAL_CALL ScVbaUserForm::getInnerHeight() throw (uno::RuntimeException) +{ + return mpGeometryHelper->getInnerHeight(); +} + +void SAL_CALL ScVbaUserForm::setInnerHeight( double fInnerHeight ) throw (uno::RuntimeException) +{ + mpGeometryHelper->setInnerHeight( fInnerHeight ); +} + void SAL_CALL ScVbaUserForm::Hide( ) throw (uno::RuntimeException) { @@ -202,13 +222,7 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW ); uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName ); if ( xControl.is() ) - { - ScVbaControlFactory aFac( mxContext, xControl, m_xModel ); - uno::Reference< msforms::XControl > xVBAControl( aFac.createControl( xDialogControl->getModel() ) ); - ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() ); - pControl->setGeometryHelper( new UserFormGeometryHelper( mxContext, xControl ) ); - aResult = uno::makeAny( xVBAControl ); - } + aResult <<= ScVbaControlFactory::createUserformControl( mxContext, xControl, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() ); } return aResult; @@ -225,7 +239,7 @@ ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException) // if the dialog already closed we should do nothing, but the VBA will call methods of the Controls objects // thus we have to provide a dummy object in this case uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY ); - uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) ); + uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() ) ); if ( index.hasValue() ) return uno::makeAny( xControls->Item( index, uno::Any() ) ); return uno::makeAny( xControls ); diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx index 71e8b4f62aa9..1777a979b9f2 100644 --- a/vbahelper/source/msforms/vbauserform.hxx +++ b/vbahelper/source/msforms/vbauserform.hxx @@ -50,18 +50,22 @@ public: // XUserForm virtual void SAL_CALL RePaint( ) throw (css::uno::RuntimeException); virtual void SAL_CALL Show( ) throw (css::uno::RuntimeException); - // XIntrospection - virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException); virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getCaption() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getInnerWidth() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInnerWidth( double fInnerWidth ) throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getInnerHeight() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInnerHeight( double fInnerHeight ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL Hide( ) throw (css::uno::RuntimeException); virtual void SAL_CALL UnloadObject( ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& index ) throw (css::uno::RuntimeException); + // XIntrospection + virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); diff --git a/vbahelper/source/vbahelper/collectionbase.cxx b/vbahelper/source/vbahelper/collectionbase.cxx new file mode 100755 index 000000000000..16fc673f54d5 --- /dev/null +++ b/vbahelper/source/vbahelper/collectionbase.cxx @@ -0,0 +1,332 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2011 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <vbahelper/collectionbase.hxx> + +#include <map> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <cppuhelper/implbase2.hxx> + +namespace vbahelper { + +using namespace ::com::sun::star; +using namespace ::ooo::vba; + +// ============================================================================ + +namespace { + +// ---------------------------------------------------------------------------- + +class CollectionEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration > +{ +public: + explicit CollectionEnumeration( const ::rtl::Reference< CollectionBase >& rxCollection ); + virtual sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + +private: + ::rtl::Reference< CollectionBase > mxCollection; + sal_Int32 mnCurrIndex; +}; + +CollectionEnumeration::CollectionEnumeration( const ::rtl::Reference< CollectionBase >& rxCollection ) : + mxCollection( rxCollection ), + mnCurrIndex( 1 ) // collection expects one-based indexes +{ +} + +sal_Bool SAL_CALL CollectionEnumeration::hasMoreElements() throw (uno::RuntimeException) +{ + return mnCurrIndex <= mxCollection->getCount(); +} + +uno::Any SAL_CALL CollectionEnumeration::nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( hasMoreElements() ) + return mxCollection->getItemByIndex( mnCurrIndex++ ); + throw container::NoSuchElementException(); +} + +// ---------------------------------------------------------------------------- + +struct IsLessIgnoreCase +{ + inline bool operator()( const ::rtl::OUString& rName1, const ::rtl::OUString& rName2 ) const + { return ::rtl_ustr_compareIgnoreAsciiCase_WithLength( rName1.getStr(), rName1.getLength(), rName2.getStr(), rName2.getLength() ) < 0; } +}; + +// ---------------------------------------------------------------------------- + +class SequenceToContainer : public ::cppu::WeakImplHelper2< container::XIndexAccess, container::XNameAccess > +{ +public: + explicit SequenceToContainer( const ::std::vector< uno::Reference< container::XNamed > >& rElements, const uno::Type& rElementType ); + explicit SequenceToContainer( const ::std::vector< beans::NamedValue >& rElements, const uno::Type& rElementType ); + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException); + // XNameAccess + virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& rName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException); + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); + +private: + typedef uno::Sequence< ::rtl::OUString > ElementNameSequence; + typedef ::std::vector< uno::Any > ElementVector; + typedef ::std::map< ::rtl::OUString, uno::Any, IsLessIgnoreCase > ElementMap; + + ElementNameSequence maElementNames; + ElementVector maElements; + ElementMap maElementMap; + uno::Type maElementType; +}; + +SequenceToContainer::SequenceToContainer( const ::std::vector< uno::Reference< container::XNamed > >& rElements, const uno::Type& rElementType ) : + maElementType( rElementType ) +{ + maElementNames.realloc( static_cast< sal_Int32 >( rElements.size() ) ); + maElements.reserve( rElements.size() ); + ::rtl::OUString* pElementName = maElementNames.getArray(); + for( ::std::vector< uno::Reference< container::XNamed > >::const_iterator aIt = rElements.begin(), aEnd = rElements.end(); aIt != aEnd; ++aIt, ++pElementName ) + { + uno::Reference< container::XNamed > xNamed = *aIt; + *pElementName = xNamed->getName(); + maElements.push_back( uno::Any( xNamed ) ); + // same name may occur multiple times, VBA returns first occurance + if( maElementMap.count( *pElementName ) == 0 ) + maElementMap[ *pElementName ] <<= xNamed; + } +} + +SequenceToContainer::SequenceToContainer( const ::std::vector< beans::NamedValue >& rElements, const uno::Type& rElementType ) : + maElementType( rElementType ) +{ + maElementNames.realloc( static_cast< sal_Int32 >( rElements.size() ) ); + maElements.reserve( rElements.size() ); + ::rtl::OUString* pElementName = maElementNames.getArray(); + for( ::std::vector< beans::NamedValue >::const_iterator aIt = rElements.begin(), aEnd = rElements.end(); aIt != aEnd; ++aIt, ++pElementName ) + { + *pElementName = aIt->Name; + maElements.push_back( aIt->Value ); + // same name may occur multiple times, VBA returns first occurance + if( maElementMap.count( *pElementName ) == 0 ) + maElementMap[ *pElementName ] = aIt->Value; + } +} + +sal_Int32 SAL_CALL SequenceToContainer::getCount() throw (uno::RuntimeException) +{ + return static_cast< sal_Int32 >( maElements.size() ); +} + +uno::Any SAL_CALL SequenceToContainer::getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( (0 <= nIndex) && (nIndex < getCount()) ) + return maElements[ static_cast< size_t >( nIndex ) ]; + throw lang::IndexOutOfBoundsException(); +} + +uno::Any SAL_CALL SequenceToContainer::getByName( const ::rtl::OUString& rName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + ElementMap::iterator aIt = maElementMap.find( rName ); + if( aIt != maElementMap.end() ) + return aIt->second; + throw container::NoSuchElementException(); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL SequenceToContainer::getElementNames() throw (uno::RuntimeException) +{ + return maElementNames; +} + +sal_Bool SAL_CALL SequenceToContainer::hasByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException) +{ + return maElementMap.count( rName ) > 0; +} + +uno::Type SAL_CALL SequenceToContainer::getElementType() throw (uno::RuntimeException) +{ + return maElementType; +} + +sal_Bool SAL_CALL SequenceToContainer::hasElements() throw (uno::RuntimeException) +{ + return !maElements.empty(); +} + +} // namespace + +// ============================================================================ + +CollectionBase::CollectionBase( const uno::Type& rElementType ) : + maElementType( rElementType ), + mbConvertOnDemand( false ) +{ +} + +sal_Int32 SAL_CALL CollectionBase::getCount() throw (uno::RuntimeException) +{ + if( mxIndexAccess.is() ) + return mxIndexAccess->getCount(); + if( mxNameAccess.is() ) + return mxNameAccess->getElementNames().getLength(); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 ); +} + +uno::Reference< container::XEnumeration > SAL_CALL CollectionBase::createEnumeration() throw (uno::RuntimeException) +{ + return new CollectionEnumeration( this ); +} + +uno::Type SAL_CALL CollectionBase::getElementType() throw (uno::RuntimeException) +{ + return maElementType; +} + +sal_Bool SAL_CALL CollectionBase::hasElements() throw (uno::RuntimeException) +{ + if( mxIndexAccess.is() ) + return mxIndexAccess->hasElements(); + if( mxNameAccess.is() ) + return mxNameAccess->hasElements(); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 ); +} + +::rtl::OUString SAL_CALL CollectionBase::getDefaultMethodName() throw (uno::RuntimeException) +{ + static ::rtl::OUString saDefMethodName( RTL_CONSTASCII_USTRINGPARAM( "Item" ) ); + return saDefMethodName; +} + +// ---------------------------------------------------------------------------- + +void CollectionBase::initContainer( + const uno::Reference< container::XElementAccess >& rxElementAccess, + ContainerType eContainerType ) throw (uno::RuntimeException) +{ + mxIndexAccess.set( rxElementAccess, uno::UNO_QUERY ); + mxNameAccess.set( rxElementAccess, uno::UNO_QUERY ); + switch( eContainerType ) + { + case CONTAINER_NATIVE_VBA: + mbConvertOnDemand = false; + break; + case CONTAINER_CONVERT_ON_DEMAND: + mbConvertOnDemand = true; + break; + } +} + +void CollectionBase::initElements( const ::std::vector< uno::Reference< container::XNamed > >& rElements, ContainerType eContainerType ) throw (uno::RuntimeException) +{ + // SequenceToContainer derives twice from XElementAccess, need to resolve ambiguity + initContainer( static_cast< container::XIndexAccess* >( new SequenceToContainer( rElements, maElementType ) ), eContainerType ); +} + +void CollectionBase::initElements( const ::std::vector< beans::NamedValue >& rElements, ContainerType eContainerType ) throw (uno::RuntimeException) +{ + // SequenceToContainer derives twice from XElementAccess, need to resolve ambiguity + initContainer( static_cast< container::XIndexAccess* >( new SequenceToContainer( rElements, maElementType ) ), eContainerType ); +} + +uno::Any CollectionBase::createCollectionItem( const uno::Any& rElement, const uno::Any& rIndex ) throw (css::uno::RuntimeException) +{ + uno::Any aItem = mbConvertOnDemand ? implCreateCollectionItem( rElement, rIndex ) : rElement; + if( aItem.hasValue() ) + return aItem; + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item." ) ), 0 ); +} + +uno::Any CollectionBase::getItemByIndex( sal_Int32 nIndex ) throw (uno::RuntimeException) +{ + if( mxIndexAccess.is() ) + { + if( (1 <= nIndex) && (nIndex <= mxIndexAccess->getCount()) ) + // createCollectionItem() will convert from container element to VBA item + return createCollectionItem( mxIndexAccess->getByIndex( nIndex - 1 ), uno::Any( nIndex ) ); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Index out of bounds." ) ), 0 ); + } + if( mxNameAccess.is() ) + { + uno::Sequence< ::rtl::OUString > aElementNames = mxNameAccess->getElementNames(); + if( (1 <= nIndex) && (nIndex <= aElementNames.getLength()) ) + // createCollectionItem() will convert from container element to VBA item + return createCollectionItem( mxNameAccess->getByName( aElementNames[ nIndex - 1 ] ), uno::Any( aElementNames[ nIndex - 1 ] ) ); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Index out of bounds." ) ), 0 ); + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 ); +} + +uno::Any CollectionBase::getItemByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException) +{ + if( mxNameAccess.is() ) + { + if( rName.getLength() > 0 ) + // createCollectionItem() will convert from container element to VBA item + return createCollectionItem( mxNameAccess->getByName( rName ), uno::Any( rName ) ); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item name." ) ), 0 ); + } + if( mxIndexAccess.is() ) + { + for( sal_Int32 nIndex = 0, nSize = mxIndexAccess->getCount(); nIndex < nSize; ++nIndex ) + { + uno::Any aElement = mxIndexAccess->getByIndex( nIndex ); + uno::Reference< container::XNamed > xNamed( aElement, uno::UNO_QUERY ); + if( xNamed.is() && xNamed->getName().equalsIgnoreAsciiCase( rName ) ) + // createCollectionItem() will convert from container element to VBA item + return createCollectionItem( aElement, uno::Any( nIndex ) ); + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item name." ) ), 0 ); + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 ); +} + +uno::Any CollectionBase::getAnyItemOrThis( const uno::Any& rIndex ) throw (uno::RuntimeException) +{ + if( !rIndex.hasValue() ) + return uno::Any( uno::Reference< XCollectionBase >( this ) ); + if( rIndex.has< ::rtl::OUString >() ) + return getItemByName( rIndex.get< ::rtl::OUString >() ); + // extractIntFromAny() throws if no index can be extracted + return getItemByIndex( extractIntFromAny( rIndex ) ); +} + +// protected ------------------------------------------------------------------ + +uno::Any CollectionBase::implCreateCollectionItem( const uno::Any& /*rElement*/, const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException) +{ + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Creation of VBA implementation object not implemented." ) ), 0 ); +} + +// ============================================================================ + +} // namespace vbahelper diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 54d280094f2c..5ae0a2c23890 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -387,12 +387,12 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException) { try // return empty object on error { - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); - aArgs[ 1 ] <<= getCurrentDocument(); + // "VBE" object does not have a parent, but pass document model to be able to determine application type + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= getCurrentDocument(); uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); uno::Reference< uno::XInterface > xVBE = xServiceManager->createInstanceWithArgumentsAndContext( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBE" ) ), aArgs, mxContext ); + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.vbide.VBE" ) ), aArgs, mxContext ); return uno::Any( xVBE ); } catch( uno::Exception& ) @@ -401,25 +401,6 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException) return uno::Any(); } -uno::Any SAL_CALL -VbaApplicationBase::getVBProjects() throw (uno::RuntimeException) -{ - try // return empty object on error - { - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); - aArgs[ 1 ] <<= getCurrentDocument(); - uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); - uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProjects" ) ), aArgs, mxContext ); - return uno::Any( xVBProjects ); - } - catch( uno::Exception& ) - { - } - return uno::Any(); -} - rtl::OUString& VbaApplicationBase::getServiceImplName() { diff --git a/vbahelper/source/vbahelper/vbacommandbar.cxx b/vbahelper/source/vbahelper/vbacommandbar.cxx index 1e8d21d53583..11cbacb79894 100644 --- a/vbahelper/source/vbahelper/vbacommandbar.cxx +++ b/vbahelper/source/vbahelper/vbacommandbar.cxx @@ -154,14 +154,7 @@ ScVbaCommandBar::Delete( ) throw (script::BasicErrorException, uno::RuntimeExce uno::Any SAL_CALL ScVbaCommandBar::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException) { - uno::Reference< awt::XMenu > xMenu; - if( m_bIsMenu ) - { - uno::Reference< frame::XLayoutManager > xLayoutManager = pCBarHelper->getLayoutManager(); - uno::Reference< beans::XPropertySet > xPropertySet( xLayoutManager->getElement( m_sResourceUrl ), uno::UNO_QUERY_THROW ); - xMenu.set( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("XMenuBar") ), uno::UNO_QUERY ); - } - uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) ); + uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl ) ); if( aIndex.hasValue() ) { return xCommandBarControls->Item( aIndex, uno::Any() ); diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx index 157d54eca7d5..d57bc00644a5 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx @@ -91,50 +91,37 @@ ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (u ::sal_Bool SAL_CALL ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException) { - /*sal_Bool bVisible = sal_True; - uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") ); + sal_Bool bVisible = sal_True; + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ) ); if( aValue.hasValue() ) aValue >>= bVisible; - return bVisible;*/ - return getEnabled(); - + return bVisible; } void SAL_CALL ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException) { - /*uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") ); + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ) ); if( aValue.hasValue() ) { - setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible"), uno::makeAny( _visible ) ); + setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ), uno::makeAny( _visible ) ); ApplyChange(); - }*/ - setEnabled( _visible); + } } ::sal_Bool SAL_CALL ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException) { sal_Bool bEnabled = sal_True; - rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___"); - rtl::OUString aCommandURL ; - if( m_xParentMenu.is() ) + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ) ); + if( aValue.hasValue() ) { - // currently only the menu in the MenuBat support Enable/Disable - // FIXME: how to support the menu item in Toolbar - bEnabled = m_xParentMenu->isItemEnabled( m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ) ); + aValue >>= bEnabled; } else { // emulated with Visible - //bEnabled = getVisible(); - uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") ); - if (aValue >>= aCommandURL){ - if (0 == aCommandURL.indexOf(aCommandURLappendix)){ - bEnabled = sal_False; - } - } - + bEnabled = getVisible(); } return bEnabled; } @@ -142,30 +129,16 @@ ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException) void SAL_CALL ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException) { - rtl::OUString aCommandURL ; - rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___"); - rtl::OUStringBuffer aCommandURLSringBuffer; - if( m_xParentMenu.is() ) + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ) ); + if( aValue.hasValue() ) { - // currently only the menu in the MenuBat support Enable/Disable - m_xParentMenu->enableItem( m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ), _enabled ); + setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ), uno::makeAny( _enabled ) ); + ApplyChange(); } else { - uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") ); - if (aValue >>= aCommandURL){ - if (0 == aCommandURL.indexOf(aCommandURLappendix)){ - aCommandURL = aCommandURL.copy(3); - } - if (false == _enabled){ - aCommandURLSringBuffer = aCommandURLappendix; - } - aCommandURLSringBuffer.append(aCommandURL); - setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURLSringBuffer.makeStringAndClear()) ); - ApplyChange(); - } // emulated with Visible - //setVisible( _enabled ); + setVisible( _enabled ); } } @@ -206,14 +179,7 @@ ScVbaCommandBarControl::Controls( const uno::Any& aIndex ) throw (script::BasicE if( !xSubMenu.is() ) throw uno::RuntimeException(); - uno::Reference< awt::XMenu > xMenu; - if( m_xParentMenu.is() ) - { - sal_Int16 nItemId = m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ); - xMenu.set( m_xParentMenu->getPopupMenu( nItemId ), uno::UNO_QUERY ); - } - - uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) ); + uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl ) ); if( aIndex.hasValue() ) { return xCommandBarControls->Item( aIndex, uno::Any() ); @@ -241,12 +207,11 @@ ScVbaCommandBarControl::getServiceNames() } //////////// ScVbaCommandBarPopup ////////////////////////////// -ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl ) +ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl ) { m_nPosition = nPosition; m_bTemporary = bTemporary; m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues; - m_xParentMenu = xMenu; } rtl::OUString& @@ -268,12 +233,11 @@ ScVbaCommandBarPopup::getServiceNames() } //////////// ScVbaCommandBarButton ////////////////////////////// -ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl ) +ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl ) { m_nPosition = nPosition; m_bTemporary = bTemporary; m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues; - m_xParentMenu = xMenu; } rtl::OUString& diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx index a165f8e1cccd..5066ba75eea0 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx @@ -43,10 +43,9 @@ class ScVbaCommandBarControl : public CommandBarControl_BASE protected: VbaCommandBarHelperRef pCBarHelper; rtl::OUString m_sResourceUrl; - css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings; - css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; - css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues; - css::uno::Reference< css::awt::XMenu > m_xParentMenu; + css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings; + css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; + css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues; sal_Int32 m_nPosition; sal_Bool m_bTemporary; @@ -87,7 +86,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarPop class ScVbaCommandBarPopup : public CommandBarPopup_BASE { public: - ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException); + ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException) { @@ -102,7 +101,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarBut class ScVbaCommandBarButton : public CommandBarButton_BASE { public: - ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException); + ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException) { diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx index 634b4a0e9395..da218d007736 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx @@ -55,14 +55,20 @@ public: } }; -ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl, const uno::Reference< awt::XMenu >& xMenu ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl ), m_xMenu( xMenu ) +ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl ) { m_bIsMenu = sResourceUrl.equalsAscii( ITEM_MENUBAR_URL ) ? sal_True : sal_False; } -uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const uno::Any& aSubMenu ) +uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL, + const rtl::OUString& sHelpURL, + const rtl::OUString& sLabel, + sal_uInt16 nType, + const uno::Any& aSubMenu, + sal_Bool isVisible, + sal_Bool isEnabled ) { - uno::Sequence< beans::PropertyValue > aProps(5); + uno::Sequence< beans::PropertyValue > aProps(7); aProps[0].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_COMMANDURL ); aProps[0].Value <<= sCommandURL; @@ -74,6 +80,10 @@ uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemDat aProps[3].Value <<= nType; aProps[4].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER ); aProps[4].Value = aSubMenu; + aProps[5].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ); + aProps[5].Value <<= isVisible; + aProps[6].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ); + aProps[6].Value <<= isEnabled; return aProps; } @@ -124,9 +134,9 @@ ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource ) getPropertyValue( aProps, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER ) ) >>= xSubMenu; ScVbaCommandBarControl* pNewCommandBarControl = NULL; if( xSubMenu.is() ) - pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu ); + pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True ); else - pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu ); + pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True ); return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) ); } @@ -202,7 +212,7 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un sal_uInt16 nItemType = 0; if( IsMenu() ) { - aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu ); + aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu, true, true ); } else { @@ -217,12 +227,11 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings ); - // sometimes it would crash if passing m_xMenu instead of uno::Reference< awt::XMenu >() in Linux. ScVbaCommandBarControl* pNewCommandBarControl = NULL; if( nType == office::MsoControlType::msoControlPopup ) - pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() ); + pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary ); else - pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() ); + pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary ); return uno::Reference< XCommandBarControl >( pNewCommandBarControl ); } diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx index 0b35773660d1..79a4a8c5a5fe 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx @@ -38,17 +38,22 @@ typedef CollTestImplHelper< ov::XCommandBarControls > CommandBarControls_BASE; class ScVbaCommandBarControls : public CommandBarControls_BASE { private: - VbaCommandBarHelperRef pCBarHelper; - css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; - rtl::OUString m_sResourceUrl; - css::uno::Reference< css::awt::XMenu > m_xMenu; - sal_Bool m_bIsMenu; + VbaCommandBarHelperRef pCBarHelper; + css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; + rtl::OUString m_sResourceUrl; + sal_Bool m_bIsMenu; - css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu ); + css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL, + const rtl::OUString& sHelpURL, + const rtl::OUString& sLabel, + sal_uInt16 nType, + const css::uno::Any& aSubMenu, + sal_Bool isVisible, + sal_Bool isEnabled ); css::uno::Sequence< css::beans::PropertyValue > CreateToolbarItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu, sal_Bool isVisible, sal_Int32 nStyle ); public: - ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw( css::uno::RuntimeException ); + ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl ) throw( css::uno::RuntimeException ); sal_Bool IsMenu(){ return m_bIsMenu; } // XEnumerationAccess diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx index 1fa41d7141b3..93c6e5f55457 100644 --- a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx +++ b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx @@ -47,6 +47,7 @@ static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible"; static const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL"; static const char ITEM_DESCRIPTOR_UINAME[] = "UIName"; +static const char ITEM_DESCRIPTOR_ENABLED[] = "Enabled"; static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar"; static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/"; diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index 087e7188c8f6..291bc6ad2931 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/document/XEmbeddedScripts.hpp> //Michael E. Bohn #include <com/sun/star/beans/XPropertySet.hpp> +#include <ooo/vba/XApplicationBase.hpp> #include <cppuhelper/exc_hlp.hxx> #include <comphelper/unwrapargs.hxx> @@ -265,20 +266,21 @@ VbaDocumentBase::Activate() throw (uno::RuntimeException) uno::Any SAL_CALL VbaDocumentBase::getVBProject() throw (uno::RuntimeException) { - try // return empty object on error + if( !mxVBProject.is() ) try { + uno::Reference< XApplicationBase > xApp( Application(), uno::UNO_QUERY_THROW ); + uno::Reference< XInterface > xVBE( xApp->getVBE(), uno::UNO_QUERY_THROW ); uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); - aArgs[ 1 ] <<= getModel(); + aArgs[ 0 ] <<= xVBE; // the VBE + aArgs[ 1 ] <<= getModel(); // document model for script container access uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); - uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProject" ) ), aArgs, mxContext ); - return uno::Any( xVBProjects ); + mxVBProject = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.vbide.VBProject" ) ), aArgs, mxContext ); } catch( uno::Exception& ) { } - return uno::Any(); + return uno::Any( mxVBProject ); } rtl::OUString& diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx index 8000a7cdf66e..5e2cf949c473 100755 --- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx +++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx @@ -26,34 +26,40 @@ ************************************************************************/ #include "vbahelper/vbaeventshelperbase.hxx" +#include <com/sun/star/document/XEventBroadcaster.hpp> +#include <com/sun/star/script/ModuleType.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <com/sun/star/util/XChangesNotifier.hpp> #include <filter/msfilter/msvbahelper.hxx> +#include <unotools/eventcfg.hxx> using namespace ::com::sun::star; using namespace ::ooo::vba; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + // ============================================================================ VbaEventsHelperBase::VbaEventsHelperBase( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& /*xContext*/ ) : mpShell( 0 ), - mbDisposed( false ) + mbDisposed( true ) { try { mxModel = getXSomethingFromArgs< frame::XModel >( rArgs, 0, false ); mpShell = getSfxObjShell( mxModel ); - - // add dispose listener - uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW ); - xComponent->addEventListener( this ); } catch( uno::Exception& ) { } + mbDisposed = mpShell == 0; + startListening(); } VbaEventsHelperBase::~VbaEventsHelperBase() { - stopListening(); + OSL_ENSURE( mbDisposed, "VbaEventsHelperBase::~VbaEventsHelperBase - missing disposing notification" ); } sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) @@ -65,8 +71,8 @@ sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, c return getEventHandlerPath( rInfo, rArgs ).getLength() > 0; } -void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) - throw (lang::IllegalArgumentException, script::provider::ScriptFrameworkErrorException, util::VetoException, uno::RuntimeException) +sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) + throw (lang::IllegalArgumentException, util::VetoException, uno::RuntimeException) { /* Derived classes may add new event identifiers to be processed while processing the original event. All unprocessed events are collected in @@ -79,9 +85,9 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un handler receives the Cancel value of the previous event handler. */ bool bCancel = false; - /* bSuccess will change to true if at least one event handler has been - executed successfully. */ - bool bSuccess = false; + /* bExecuted will change to true if at least one event handler has been + found and executed. */ + bool bExecuted = false; /* Loop as long as there are more events to be processed. Derived classes may add new events to be processed in the virtual implPrepareEvent() @@ -98,15 +104,15 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un const EventHandlerInfo& rInfo = getEventHandlerInfo( aEventQueue.front().mnEventId ); uno::Sequence< uno::Any > aEventArgs = aEventQueue.front().maArgs; aEventQueue.pop_front(); + OSL_TRACE( "VbaEventsHelperBase::processVbaEvent( \"%s\" )", ::rtl::OUStringToOString( rInfo.maMacroName, RTL_TEXTENCODING_UTF8 ).getStr() ); /* Let derived classes prepare the event, they may add new events for next iteration. If false is returned, the event handler must not be called. */ - bool bEventSuccess = false; if( implPrepareEvent( aEventQueue, rInfo, aEventArgs ) ) { // search the event handler macro in the document - ::rtl::OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs ); + OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs ); if( aMacroPath.getLength() > 0 ) { // build the argument list @@ -120,96 +126,225 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un } // execute the event handler uno::Any aRet, aCaller; - bEventSuccess = executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller ); - // extract new cancel value + executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller ); + // extract new cancel value (may be boolean or any integer type) if( rInfo.mnCancelIndex >= 0 ) { - if( rInfo.mnCancelIndex >= aVbaArgs.getLength() ) - throw lang::IllegalArgumentException(); - // cancel value may be boolean or any integer type, Any(bool) does not extract to sal_Int32 - bool bNewCancel = false; - sal_Int32 nNewCancel = 0; - if( aVbaArgs[ rInfo.mnCancelIndex ] >>= bNewCancel ) - bCancel = bNewCancel; - else if( aVbaArgs[ rInfo.mnCancelIndex ] >>= nNewCancel ) - bCancel = nNewCancel != 0; + checkArgument( aVbaArgs, rInfo.mnCancelIndex ); + bCancel = extractBoolFromAny( aVbaArgs[ rInfo.mnCancelIndex ] ); } + // event handler has been found + bExecuted = true; } - // global success, if at least one event handler succeeded - bSuccess |= bEventSuccess; } // post processing (also, if event handler does not exist, or disabled, or on error - implPostProcessEvent( aEventQueue, rInfo, bEventSuccess, bCancel ); + implPostProcessEvent( aEventQueue, rInfo, bCancel ); } // if event handlers want to cancel the event, do so regardless of any errors if( bCancel ) throw util::VetoException(); - // if no event handler finished successfully, throw - if( !bSuccess ) - throw script::provider::ScriptFrameworkErrorException(); + // return true, if at least one event handler has been found + return bExecuted; } -void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& /*aSource*/ ) throw (uno::RuntimeException) +void SAL_CALL VbaEventsHelperBase::notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException) { - OSL_TRACE( "VbaEventsHelperBase::disposing" ); - stopListening(); - mbDisposed = true; + OSL_TRACE( "VbaEventsHelperBase::notifyEvent( \"%s\" )", ::rtl::OUStringToOString( rEvent.EventName, RTL_TEXTENCODING_UTF8 ).getStr() ); + if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ) ) + stopListening(); +} + +void SAL_CALL VbaEventsHelperBase::changesOccurred( const util::ChangesEvent& rEvent ) throw (uno::RuntimeException) +{ + // make sure the VBA library exists + try + { + ensureVBALibrary(); + } + catch( uno::Exception& ) + { + return; + } + + // check that the sender of the event is the VBA library + uno::Reference< script::vba::XVBAModuleInfo > xSender( rEvent.Base, uno::UNO_QUERY ); + if( mxModuleInfos.get() != xSender.get() ) + return; + + // process all changed modules + for( sal_Int32 nIndex = 0, nLength = rEvent.Changes.getLength(); nIndex < nLength; ++nIndex ) + { + const util::ElementChange& rChange = rEvent.Changes[ nIndex ]; + OUString aModuleName; + if( (rChange.Accessor >>= aModuleName) && (aModuleName.getLength() > 0) ) try + { + // invalidate event handler path map depending on module type + if( getModuleType( aModuleName ) == script::ModuleType::NORMAL ) + // paths to global event handlers are stored with empty key (will be searched in all normal code modules) + maEventPaths.erase( OUString() ); + else + // paths to class/form/document event handlers are keyed by module name + maEventPaths.erase( aModuleName ); + } + catch( uno::Exception& ) + { + } + } +} + +void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& rEvent ) throw (uno::RuntimeException) +{ + uno::Reference< frame::XModel > xSender( rEvent.Source, uno::UNO_QUERY ); + if( xSender.is() ) + stopListening(); +} + +void VbaEventsHelperBase::processVbaEventNoThrow( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) +{ + try + { + processVbaEvent( nEventId, rArgs ); + } + catch( uno::Exception& ) + { + } } // protected ------------------------------------------------------------------ -void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId, - const sal_Char* pcMacroName, EventHandlerType eType, sal_Int32 nCancelIndex, const uno::Any& rUserData ) +void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId, sal_Int32 nModuleType, + const sal_Char* pcMacroName, sal_Int32 nCancelIndex, const uno::Any& rUserData ) { - EventHandlerInfo& rInfo = maEvents[ nEventId ]; + EventHandlerInfo& rInfo = maEventInfos[ nEventId ]; rInfo.mnEventId = nEventId; - rInfo.maMacroName = ::rtl::OUString::createFromAscii( pcMacroName ); - rInfo.meType = eType; + rInfo.mnModuleType = nModuleType; + rInfo.maMacroName = OUString::createFromAscii( pcMacroName ); rInfo.mnCancelIndex = nCancelIndex; rInfo.maUserData = rUserData; } // private -------------------------------------------------------------------- +void VbaEventsHelperBase::startListening() +{ + if( mbDisposed ) + return; + + uno::Reference< document::XEventBroadcaster > xEventBroadcaster( mxModel, uno::UNO_QUERY ); + if( xEventBroadcaster.is() ) + try { xEventBroadcaster->addEventListener( this ); } catch( uno::Exception& ) {} +} + +void VbaEventsHelperBase::stopListening() +{ + if( mbDisposed ) + return; + + uno::Reference< document::XEventBroadcaster > xEventBroadcaster( mxModel, uno::UNO_QUERY ); + if( xEventBroadcaster.is() ) + try { xEventBroadcaster->removeEventListener( this ); } catch( uno::Exception& ) {} + + mxModel.clear(); + mpShell = 0; + maEventInfos.clear(); + mbDisposed = true; +} + const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandlerInfo( sal_Int32 nEventId ) const throw (lang::IllegalArgumentException) { - EventHandlerMap::const_iterator aIt = maEvents.find( nEventId ); - if( aIt == maEvents.end() ) + EventHandlerInfoMap::const_iterator aIt = maEventInfos.find( nEventId ); + if( aIt == maEventInfos.end() ) throw lang::IllegalArgumentException(); return aIt->second; } -::rtl::OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo, - const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException) +OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo, + const uno::Sequence< uno::Any >& rArgs ) throw (lang::IllegalArgumentException, uno::RuntimeException) { - ::rtl::OUString aMacroName; - switch( rInfo.meType ) + OUString aModuleName; + switch( rInfo.mnModuleType ) { - case EVENTHANDLER_GLOBAL: - aMacroName = rInfo.maMacroName; + // global event handlers may exist in any standard code module + case script::ModuleType::NORMAL: break; - case EVENTHANDLER_DOCUMENT: - aMacroName = ::rtl::OUStringBuffer( implGetDocumentModuleName( rInfo, rArgs ) ). - append( sal_Unicode( '.' ) ).append( rInfo.maMacroName ).makeStringAndClear(); + + // document event: get name of the code module associated to the event sender + case script::ModuleType::DOCUMENT: + aModuleName = implGetDocumentModuleName( rInfo, rArgs ); + if( aModuleName.getLength() == 0 ) + throw lang::IllegalArgumentException(); break; + + default: + throw uno::RuntimeException(); // unsupported module type } - MacroResolvedInfo aMacroInfo = resolveVBAMacro( mpShell, aMacroName, false ); - return aMacroInfo.mbFound ? ::rtl::OUString( aMacroInfo.msResolvedMacro ) : ::rtl::OUString(); + + /* Performance improvement: Check the list of existing event handlers + instead of searching in Basic source code every time. */ + EventHandlerPathMap::iterator aIt = maEventPaths.find( aModuleName ); + ModulePathMap& rPathMap = (aIt == maEventPaths.end()) ? updateModulePathMap( aModuleName ) : aIt->second; + return rPathMap[ rInfo.mnEventId ]; } -void VbaEventsHelperBase::stopListening() +void VbaEventsHelperBase::ensureVBALibrary() throw (uno::RuntimeException) { - if( !mbDisposed ) try + if( !mxModuleInfos.is() ) try { - uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW ); - xComponent->removeEventListener( this ); + maLibraryName = getDefaultProjectName( mpShell ); + if( maLibraryName.getLength() == 0 ) + throw uno::RuntimeException(); + uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW ); + uno::Reference< container::XNameAccess > xBasicLibs( xModelProps->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW ); + mxModuleInfos.set( xBasicLibs->getByName( maLibraryName ), uno::UNO_QUERY_THROW ); + // listen to changes in the VBA source code + uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModuleInfos, uno::UNO_QUERY_THROW ); + xChangesNotifier->addChangesListener( this ); } catch( uno::Exception& ) { + // error accessing the Basic library, so this object is useless + stopListening(); + throw uno::RuntimeException(); + } +} + +sal_Int32 VbaEventsHelperBase::getModuleType( const OUString& rModuleName ) throw (uno::RuntimeException) +{ + // make sure the VBA library exists + ensureVBALibrary(); + + // no module specified: global event handler in standard code modules + if( rModuleName.getLength() == 0 ) + return script::ModuleType::NORMAL; + + // get module type from module info + try + { + return mxModuleInfos->getModuleInfo( rModuleName ).ModuleType; + } + catch( uno::Exception& ) + { + } + throw uno::RuntimeException(); +} + +VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( const ::rtl::OUString& rModuleName ) throw (uno::RuntimeException) +{ + // get type of the specified module (throws on error) + sal_Int32 nModuleType = getModuleType( rModuleName ); + // search for all event handlers + ModulePathMap& rPathMap = maEventPaths[ rModuleName ]; + for( EventHandlerInfoMap::iterator aIt = maEventInfos.begin(), aEnd = maEventInfos.end(); aIt != aEnd; ++aIt ) + { + const EventHandlerInfo& rInfo = aIt->second; + if( rInfo.mnModuleType == nModuleType ) + rPathMap[ rInfo.mnEventId ] = resolveVBAMacro( mpShell, maLibraryName, rModuleName, rInfo.maMacroName ); } + return rPathMap; } // ============================================================================ diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index cfce8b49e3d1..2a13124a741e 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -628,82 +628,87 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const uno:: dispatchExecute( pViewShell, SID_VIEWSHELL1 ); } -bool extractBoolFromAny( bool& rbValue, const uno::Any& rAny ) +sal_Int32 extractIntFromAny( const uno::Any& rAny ) throw (uno::RuntimeException) { - if( rAny >>= rbValue ) return true; - - sal_Int64 nSigned = 0; - if( rAny >>= nSigned ) { rbValue = nSigned != 0; return true; } - - sal_uInt64 nUnsigned = 0; - if( rAny >>= nUnsigned ) { rbValue = nUnsigned > 0; return true; } - - double fDouble = 0.0; - if( rAny >>= fDouble ) { rbValue = fDouble != 0.0; return true; } + switch( rAny.getValueType().getTypeClass() ) + { + case uno::TypeClass_FLOAT: + return static_cast< sal_Int32 >( rAny.get< float >() ); + case uno::TypeClass_DOUBLE: + return static_cast< sal_Int32 >( rAny.get< double >() ); + case uno::TypeClass_BYTE: + case uno::TypeClass_SHORT: + case uno::TypeClass_LONG: + return rAny.get< sal_Int32 >(); + default:; + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to integer." ) ), 0 ); +} - return false; +sal_Int32 extractIntFromAny( const uno::Any& rAny, sal_Int32 nDefault ) throw (uno::RuntimeException) +{ + return rAny.hasValue() ? extractIntFromAny( rAny ) : nDefault; } bool extractBoolFromAny( const uno::Any& rAny ) throw (uno::RuntimeException) { - bool bValue = false; - if( extractBoolFromAny( bValue, rAny ) ) - return bValue; - throw uno::RuntimeException(); + switch( rAny.getValueType().getTypeClass() ) + { + case uno::TypeClass_BOOLEAN: + return rAny.get< bool >(); + case uno::TypeClass_FLOAT: + return rAny.get< float >() != 0.0; + case uno::TypeClass_DOUBLE: + return rAny.get< double >() != 0.0; + case uno::TypeClass_BYTE: + case uno::TypeClass_SHORT: + case uno::TypeClass_LONG: + return rAny.get< sal_Int32 >() != 0; + case uno::TypeClass_HYPER: + return rAny.get< sal_Int64 >() != 0; + default:; + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to boolean." ) ), 0 ); } -rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException ) +bool extractBoolFromAny( const uno::Any& rAny, bool bDefault ) throw (uno::RuntimeException) +{ + return rAny.hasValue() ? extractBoolFromAny( rAny ) : bDefault; +} + +::rtl::OUString extractStringFromAny( const uno::Any& rAny, bool bUppercaseBool ) throw (uno::RuntimeException) { - uno::Type aType = pvargItem.getValueType(); - uno::TypeClass eTypeClass = aType.getTypeClass(); - rtl::OUString sString; - switch ( eTypeClass ) + switch( rAny.getValueType().getTypeClass() ) { - case uno::TypeClass_BOOLEAN: - { - sal_Bool bBool = sal_False; - pvargItem >>= bBool; - sString = rtl::OUString::valueOf( bBool ); - break; - } case uno::TypeClass_STRING: - pvargItem >>= sString; - break; + return rAny.get< ::rtl::OUString >(); + case uno::TypeClass_BOOLEAN: + return bUppercaseBool ? + (rAny.get< bool >() ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TRUE" ) ) : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FALSE" ) )) : + ::rtl::OUString::valueOf( (sal_Bool)rAny.get< bool >() ); case uno::TypeClass_FLOAT: - { - float aFloat = 0; - pvargItem >>= aFloat; - sString = rtl::OUString::valueOf( aFloat ); - break; - } + return ::rtl::OUString::valueOf( rAny.get< float >() ); case uno::TypeClass_DOUBLE: - { - double aDouble = 0; - pvargItem >>= aDouble; - sString = rtl::OUString::valueOf( aDouble ); - break; - } + return ::rtl::OUString::valueOf( rAny.get< double >() ); + case uno::TypeClass_BYTE: case uno::TypeClass_SHORT: case uno::TypeClass_LONG: - case uno::TypeClass_BYTE: - { - sal_Int32 aNum = 0; - pvargItem >>= aNum; - sString = rtl::OUString::valueOf( aNum ); - break; - } - + return ::rtl::OUString::valueOf( rAny.get< sal_Int32 >() ); case uno::TypeClass_HYPER: - { - sal_Int64 aHyper = 0; - pvargItem >>= aHyper; - sString = rtl::OUString::valueOf( aHyper ); - break; - } - default: - throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid type, can't convert" ), uno::Reference< uno::XInterface >() ); + return ::rtl::OUString::valueOf( rAny.get< sal_Int64 >() ); + default:; } - return sString; + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to string." ) ), 0 ); +} + +::rtl::OUString extractStringFromAny( const uno::Any& rAny, const ::rtl::OUString& rDefault, bool bUppercaseBool ) throw (uno::RuntimeException) +{ + return rAny.hasValue() ? extractStringFromAny( rAny, bUppercaseBool ) : rDefault; +} + +rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException ) +{ + return extractStringFromAny( pvargItem ); } @@ -840,7 +845,7 @@ rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike ) return sResult.makeStringAndClear( ); } -double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical) +double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical) { double fConvertFactor = 1.0; if( bVertical ) @@ -854,12 +859,12 @@ double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt: return fConvertFactor; } -double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical) +double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical) { double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); return PointsToHmm( fPoints ) * fConvertFactor; } -double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical) +double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical) { double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); return HmmToPoints( fPixels/fConvertFactor ); @@ -994,128 +999,176 @@ sal_Bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const r // ====UserFormGeomentryHelper==== //--------------------------------------------- -UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl ) -: mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() ) +UserFormGeometryHelper::UserFormGeometryHelper( + const uno::Reference< uno::XComponentContext >& /*xContext*/, + const uno::Reference< awt::XControl >& xControl, + double fOffsetX, double fOffsetY ) : + mfOffsetX( fOffsetX ), + mfOffsetY( fOffsetY ), + mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() ) { if ( !xControl.is() ) throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No control is provided!" ) ), uno::Reference< uno::XInterface >() ); mxWindow.set( xControl->getPeer(), uno::UNO_QUERY_THROW ); + mxModelProps.set( xControl->getModel(), uno::UNO_QUERY_THROW ); + mxUnitConv.set( mxWindow, uno::UNO_QUERY_THROW ); } -//--------------------------------------------- -double UserFormGeometryHelper::getLeft() +double UserFormGeometryHelper::getLeft() const { - return mxWindow->getPosSize().X; + return implGetPos( false ); } -//--------------------------------------------- -void UserFormGeometryHelper::setLeft( double nLeft ) +void UserFormGeometryHelper::setLeft( double fLeft ) { - mxWindow->setPosSize( nLeft, mxWindow->getPosSize().Y, 0, 0, awt::PosSize::POS ); + implSetPos( fLeft, false ); } -//--------------------------------------------- -double UserFormGeometryHelper::getTop() +double UserFormGeometryHelper::getTop() const { - return mxWindow->getPosSize().Y; + return implGetPos( true ); } -//--------------------------------------------- -void UserFormGeometryHelper::setTop( double nTop ) +void UserFormGeometryHelper::setTop( double fTop ) { - mxWindow->setPosSize( mxWindow->getPosSize().X, nTop, 0, 0, awt::PosSize::POS ); + implSetPos( fTop, true ); } -//--------------------------------------------- -double UserFormGeometryHelper::getWidth() +double UserFormGeometryHelper::getWidth() const { - if ( mbDialog ) - { - const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ); - if ( pWindow ) - { - // get the size with decoration - Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL ); - return aResult.getWidth(); - } - } + return implGetSize( false, true ); +} + +void UserFormGeometryHelper::setWidth( double fWidth ) +{ + implSetSize( fWidth, false, true ); +} - return mxWindow->getPosSize().Width; +double UserFormGeometryHelper::getHeight() const +{ + return implGetSize( true, true ); } -//--------------------------------------------- -void UserFormGeometryHelper::setWidth( double nWidth ) +void UserFormGeometryHelper::setHeight( double fHeight ) { - sal_Int64 nNewWidth = nWidth; + implSetSize( fHeight, true, true ); +} - if ( mbDialog ) - { - const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ); - if ( pWindow ) - { - // set the size with decoration - Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL ); - if ( !aRDecor.IsEmpty() ) - { - sal_Int64 nDecor = aRDecor.getWidth(); - sal_Int64 nUnDecor = mxWindow->getPosSize().Width; - if ( nWidth < nDecor - nUnDecor ) - nUnDecor = nDecor - nWidth; // avoid negative size - nNewWidth = nWidth + nUnDecor - nDecor; - } - } - } +double UserFormGeometryHelper::getInnerWidth() const +{ + return implGetSize( false, false ); +} - mxWindow->setPosSize( 0, 0, nNewWidth, 0, awt::PosSize::WIDTH ); +void UserFormGeometryHelper::setInnerWidth( double fWidth ) +{ + implSetSize( fWidth, false, false ); } -//--------------------------------------------- -double UserFormGeometryHelper::getHeight() +double UserFormGeometryHelper::getInnerHeight() const +{ + return implGetSize( true, false ); +} + +void UserFormGeometryHelper::setInnerHeight( double fHeight ) +{ + implSetSize( fHeight, true, false ); +} + +double UserFormGeometryHelper::getOffsetX() const +{ + return mfOffsetX; +} + +double UserFormGeometryHelper::getOffsetY() const +{ + return mfOffsetY; +} + +// ---------------------------------------------------------------------------- + +static const ::rtl::OUString saPosXName( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ); +static const ::rtl::OUString saPosYName( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ); +static const ::rtl::OUString saWidthName( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ); +static const ::rtl::OUString saHeightName( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ); + +double UserFormGeometryHelper::implGetPos( bool bPosY ) const +{ + sal_Int32 nPosAppFont = mxModelProps->getPropertyValue( bPosY ? saPosYName : saPosXName ).get< sal_Int32 >(); + // appfont to pixel + awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosAppFont, nPosAppFont ), util::MeasureUnit::APPFONT ); + // pixel to VBA points + awt::Point aPosPoint = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::POINT ); + return bPosY ? (aPosPoint.Y - mfOffsetY) : (aPosPoint.X - mfOffsetX); +} + +void UserFormGeometryHelper::implSetPos( double fPos, bool bPosY ) { - if ( mbDialog ) + // convert passed VBA points to pixels + sal_Int32 nPosPixel = static_cast< sal_Int32 >( fPos + (bPosY ? mfOffsetY : mfOffsetX) ); + awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosPixel, nPosPixel ), util::MeasureUnit::POINT ); + // pixel to appfont + awt::Point aPosAppFont = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::APPFONT ); + mxModelProps->setPropertyValue( bPosY ? saPosYName : saPosXName, uno::Any( bPosY ? aPosAppFont.Y : aPosAppFont.X ) ); +} + +double UserFormGeometryHelper::implGetSize( bool bHeight, bool bOuter ) const +{ + sal_Int32 nSizeAppFont = mxModelProps->getPropertyValue( bHeight ? saHeightName : saWidthName ).get< sal_Int32 >(); + // appfont to pixel + awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSizeAppFont, nSizeAppFont ), util::MeasureUnit::APPFONT ); + + /* The VBA symbols 'Width' and 'Height' return the outer size including + window decoration (in difference to the symbols 'InnerWidth' and + 'InnerHeight'), but the window API returns the inner size. */ + if( mbDialog && bOuter ) { - const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ); - if ( pWindow ) + if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) ) { - // get the size with decoration - Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL ); - return aResult.getHeight(); + Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL ); + aSizePixel = awt::Size( aOuterRect.getWidth(), aOuterRect.getHeight() ); } } - return mxWindow->getPosSize().Height; + // pixel to VBA points + awt::Size aSizePoint = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::POINT ); + return bHeight ? aSizePoint.Height : aSizePoint.Width; } -//--------------------------------------------- -void UserFormGeometryHelper::setHeight( double nHeight ) +void UserFormGeometryHelper::implSetSize( double fSize, bool bHeight, bool bOuter ) { - sal_Int64 nNewHeight = nHeight; - if ( mbDialog ) + // convert passed VBA points to pixels + sal_Int32 nSize = static_cast< sal_Int32 >( fSize ); + awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSize, nSize ), util::MeasureUnit::POINT ); + + /* The VBA symbols 'Width' and 'Height' set the outer size (in difference + to the symbols 'InnerWidth' and 'InnerHeight'), but the dialog model + expects the inner size. We have to remove the window extents from the + pixel height to get the same result. */ + if ( mbDialog && bOuter ) { - const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ); - if ( pWindow ) + if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) ) { - // set the size with decoration - Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL ); - if ( !aRDecor.IsEmpty() ) + Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL ); + if( !aOuterRect.IsEmpty() ) { - sal_Int64 nDecor = aRDecor.getHeight(); - sal_Int64 nUnDecor = mxWindow->getPosSize().Height; - if ( nHeight < nDecor - nUnDecor ) - nUnDecor = nDecor - nHeight; // avoid negative size - nNewHeight = nHeight + nUnDecor - nDecor; + awt::Rectangle aInnerRect = mxWindow->getPosSize(); + sal_Int32 nDecorWidth = aOuterRect.getWidth() - aInnerRect.Width; + sal_Int32 nDecorHeight = aOuterRect.getHeight() - aInnerRect.Height; + aSizePixel.Width = ::std::max< sal_Int32 >( aSizePixel.Width - nDecorWidth, 1 ); + aSizePixel.Height = ::std::max< sal_Int32 >( aSizePixel.Height - nDecorHeight, 1 ); } } } - mxWindow->setPosSize( 0, 0, 0, nNewHeight, awt::PosSize::HEIGHT ); + awt::Size aSizeAppFont = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::APPFONT ); + mxModelProps->setPropertyValue( bHeight ? saHeightName : saWidthName, uno::Any( bHeight ? aSizeAppFont.Height : aSizeAppFont.Width ) ); } -// ============ +// ============================================================================ - double ConcreteXShapeGeometryAttributes::getLeft() + double ConcreteXShapeGeometryAttributes::getLeft() const { return m_pShapeHelper->getLeft(); } @@ -1123,7 +1176,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) { m_pShapeHelper->setLeft( nLeft ); } - double ConcreteXShapeGeometryAttributes::getTop() + double ConcreteXShapeGeometryAttributes::getTop() const { return m_pShapeHelper->getTop(); } @@ -1132,7 +1185,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) m_pShapeHelper->setTop( nTop ); } - double ConcreteXShapeGeometryAttributes::getHeight() + double ConcreteXShapeGeometryAttributes::getHeight() const { return m_pShapeHelper->getHeight(); } @@ -1140,7 +1193,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) { m_pShapeHelper->setHeight( nHeight ); } - double ConcreteXShapeGeometryAttributes::getWidth() + double ConcreteXShapeGeometryAttributes::getWidth() const { return m_pShapeHelper->getWidth(); } @@ -1156,7 +1209,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) throw css::uno::RuntimeException( rtl::OUString::createFromAscii("No valid shape for helper"), css::uno::Reference< css::uno::XInterface >() ); } - double ShapeHelper::getHeight() + double ShapeHelper::getHeight() const { return Millimeter::getInPoints(xShape->getSize().Height); } @@ -1177,7 +1230,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) } - double ShapeHelper::getWidth() + double ShapeHelper::getWidth() const { return Millimeter::getInPoints(xShape->getSize().Width); } @@ -1197,7 +1250,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) } - double ShapeHelper::getLeft() + double ShapeHelper::getLeft() const { return Millimeter::getInPoints(xShape->getPosition().X); } @@ -1211,7 +1264,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) } - double ShapeHelper::getTop() + double ShapeHelper::getTop() const { return Millimeter::getInPoints(xShape->getPosition().Y); } @@ -1279,38 +1332,50 @@ void UserFormGeometryHelper::setHeight( double nHeight ) return points; } - uno::Reference< uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ) - { - uno::Reference< uno::XInterface > xIf; - if ( pShell ) - { - rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") ); - BasicManager* pBasMgr = pShell->GetBasicManager(); - if ( pBasMgr && pBasMgr->GetName().Len() ) - sProj = pShell->GetBasicManager()->GetName(); - StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ); - if ( pBasic ) - { - SbModule* pMod = pBasic->FindModule( aModName ); - if ( pMod ) - xIf = pMod->GetUnoModule(); - } - } - return xIf; - } +uno::Reference< XHelperInterface > getVBADocument( const uno::Reference< frame::XModel >& xModel ) +{ + uno::Reference< XHelperInterface > xIf; + try + { + uno::Reference< beans::XPropertySet > xDocProps( xModel, uno::UNO_QUERY_THROW ); + ::rtl::OUString aCodeName; + xDocProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CodeName" ) ) ) >>= aCodeName; + xIf = getUnoDocModule( aCodeName, getSfxObjShell( xModel ) ); + } + catch( uno::Exception& ) + { + } + return xIf; +} - SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) - { - SfxObjectShell* pFoundShell = NULL; - if ( xModel.is() ) - { - uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY_THROW ); - pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId())); - } - if ( !pFoundShell ) - throw uno::RuntimeException(); - return pFoundShell; - } +uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ) +{ + uno::Reference< XHelperInterface > xIf; + if ( pShell ) + { + rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") ); + BasicManager* pBasMgr = pShell->GetBasicManager(); + if ( pBasMgr && pBasMgr->GetName().Len() ) + sProj = pBasMgr->GetName(); + if( StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ) ) + if( SbModule* pMod = pBasic->FindModule( aModName ) ) + xIf.set( pMod->GetUnoModule(), uno::UNO_QUERY ); + } + return xIf; +} + +SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) +{ + SfxObjectShell* pFoundShell = NULL; + if ( xModel.is() ) + { + uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY_THROW ); + pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId())); + } + if ( !pFoundShell ) + throw uno::RuntimeException(); + return pFoundShell; +} } // openoffice } //org diff --git a/vbahelper/source/vbahelper/vbawindowbase.cxx b/vbahelper/source/vbahelper/vbawindowbase.cxx index 54546a394690..132caef8b5e1 100644 --- a/vbahelper/source/vbahelper/vbawindowbase.cxx +++ b/vbahelper/source/vbahelper/vbawindowbase.cxx @@ -24,137 +24,113 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <vbahelper/helperdecl.hxx> -#include <vbahelper/vbawindowbase.hxx> -#include <com/sun/star/awt/XWindow.hpp> -#include <com/sun/star/awt/XWindow2.hpp> + +#include "vbahelper/vbawindowbase.hxx" +#include "vbahelper/helperdecl.hxx" #include <com/sun/star/awt/PosSize.hpp> using namespace ::com::sun::star; using namespace ::ooo::vba; -VbaWindowBase::VbaWindowBase( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowBaseImpl_BASE( xParent, xContext ), m_xModel( xModel ) +VbaWindowBase::VbaWindowBase( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const css::uno::Reference< css::frame::XModel >& xModel, + const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) : + WindowBaseImpl_BASE( xParent, xContext ), + m_xModel( xModel, uno::UNO_SET_THROW ) { + construct( xController ); } -VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xContext ) - : WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), - m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ) +VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args, + uno::Reference< uno::XComponentContext > const & xContext ) throw (uno::RuntimeException) : + WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0, false ), xContext ), + m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1, false ) ) { + construct( getXSomethingFromArgs< frame::XController >( args, 2 ) ); } sal_Bool SAL_CALL VbaWindowBase::getVisible() throw (uno::RuntimeException) { - sal_Bool bVisible = sal_True; - uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow2 > xWindow2 (xWindow, uno::UNO_QUERY_THROW ); - if( xWindow2.is() ) - { - bVisible = xWindow2->isVisible(); - } - return bVisible; + return getWindow2()->isVisible(); } void SAL_CALL -VbaWindowBase::setVisible(sal_Bool _visible) throw (uno::RuntimeException) -{ - uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - if( xWindow.is() ) - { - xWindow->setVisible( _visible ); - } -} - -css::awt::Rectangle getPosSize( const uno::Reference< frame::XModel >& xModel ) +VbaWindowBase::setVisible( sal_Bool _visible ) throw (uno::RuntimeException) { - css::awt::Rectangle aRect; - uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - if( xWindow.is() ) - { - aRect = xWindow->getPosSize(); - } - return aRect; + getWindow2()->setVisible( _visible ); } -void setPosSize( const uno::Reference< frame::XModel >& xModel, sal_Int32 nValue, sal_uInt16 nFlag ) +void setPosSize( const uno::Reference< awt::XWindow >& xWindow, sal_Int32 nValue, sal_Int16 nFlag ) { - uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - if( xWindow.is() ) + css::awt::Rectangle aRect = xWindow->getPosSize(); + switch( nFlag ) { - css::awt::Rectangle aRect = xWindow->getPosSize(); - switch( nFlag ) - { - case css::awt::PosSize::X: - xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X ); - break; - case css::awt::PosSize::Y: - xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y ); - break; - case css::awt::PosSize::WIDTH: - xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH ); - break; - case css::awt::PosSize::HEIGHT: - xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT ); - break; - default: - break; - } + case css::awt::PosSize::X: + xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X ); + break; + case css::awt::PosSize::Y: + xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y ); + break; + case css::awt::PosSize::WIDTH: + xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH ); + break; + case css::awt::PosSize::HEIGHT: + xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT ); + break; + default: + break; } } sal_Int32 SAL_CALL VbaWindowBase::getHeight() throw (uno::RuntimeException) { - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.Height; + return getWindow()->getPosSize().Height; } void SAL_CALL VbaWindowBase::setHeight( sal_Int32 _height ) throw (uno::RuntimeException) { - setPosSize(m_xModel, _height, css::awt::PosSize::HEIGHT); + setPosSize( getWindow(), _height, css::awt::PosSize::HEIGHT ); } sal_Int32 SAL_CALL VbaWindowBase::getLeft() throw (uno::RuntimeException) { - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.X; + return getWindow()->getPosSize().X; } void SAL_CALL VbaWindowBase::setLeft( sal_Int32 _left ) throw (uno::RuntimeException) { - setPosSize(m_xModel, _left, css::awt::PosSize::X); + setPosSize( getWindow(), _left, css::awt::PosSize::X ); } + sal_Int32 SAL_CALL VbaWindowBase::getTop() throw (uno::RuntimeException) { - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.Y; + return getWindow()->getPosSize().Y; } void SAL_CALL VbaWindowBase::setTop( sal_Int32 _top ) throw (uno::RuntimeException) { - setPosSize(m_xModel, _top, css::awt::PosSize::Y); + setPosSize( getWindow(), _top, css::awt::PosSize::Y ); } + sal_Int32 SAL_CALL VbaWindowBase::getWidth() throw (uno::RuntimeException) { - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.Width; + return getWindow()->getPosSize().Width; } void SAL_CALL VbaWindowBase::setWidth( sal_Int32 _width ) throw (uno::RuntimeException) { - setPosSize(m_xModel, _width, css::awt::PosSize::WIDTH); + setPosSize( getWindow(), _width, css::awt::PosSize::WIDTH ); } rtl::OUString& @@ -175,3 +151,27 @@ VbaWindowBase::getServiceNames() } return aServiceNames; } + +uno::Reference< frame::XController > VbaWindowBase::getController() throw (css::uno::RuntimeException) +{ + return uno::Reference< frame::XController >( m_xController, uno::UNO_SET_THROW ); +} + +uno::Reference< awt::XWindow > VbaWindowBase::getWindow() throw (uno::RuntimeException) +{ + return uno::Reference< awt::XWindow >( m_xWindow, uno::UNO_SET_THROW ); +} + +uno::Reference< awt::XWindow2 > VbaWindowBase::getWindow2() throw (uno::RuntimeException) +{ + return uno::Reference< awt::XWindow2 >( getWindow(), uno::UNO_QUERY_THROW ); +} + +void VbaWindowBase::construct( const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) +{ + if( !xController.is() ) throw uno::RuntimeException(); + uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW ); + uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); + m_xController = xController; + m_xWindow = xWindow; +} diff --git a/xmloff/source/style/PageMasterExportPropMapper.cxx b/xmloff/source/style/PageMasterExportPropMapper.cxx index d803b79b50a1..6514a644aaa7 100644 --- a/xmloff/source/style/PageMasterExportPropMapper.cxx +++ b/xmloff/source/style/PageMasterExportPropMapper.cxx @@ -141,27 +141,7 @@ void XMLPropertyStateBuffer::ContextFilter( ::std::vector< XMLPropertyState >& ) { if (pPMMarginAll) { - if (pPMMarginTop && pPMMarginBottom && pPMMarginLeft && pPMMarginRight) - { - sal_Int32 nTop = 0, nBottom = 0, nLeft = 0, nRight = 0; - - pPMMarginTop->maValue >>= nTop; - pPMMarginBottom->maValue >>= nBottom; - pPMMarginLeft->maValue >>= nLeft; - pPMMarginRight->maValue >>= nRight; - - if ((nTop == nBottom) && (nBottom == nLeft) && (nLeft == nRight)) - { - lcl_RemoveState( pPMMarginTop ); - lcl_RemoveState( pPMMarginBottom ); - lcl_RemoveState( pPMMarginLeft ); - lcl_RemoveState( pPMMarginRight ); - } - else - lcl_RemoveState( pPMMarginAll ); - } - else - lcl_RemoveState( pPMMarginAll ); + lcl_RemoveState(pPMMarginAll); // #i117696# do not write fo:margin } if( pPMBorderAll ) diff --git a/xmloff/source/transform/ActionMapTypesOOo.hxx b/xmloff/source/transform/ActionMapTypesOOo.hxx index ff8081b025cf..a9ed15ecb74a 100644 --- a/xmloff/source/transform/ActionMapTypesOOo.hxx +++ b/xmloff/source/transform/ActionMapTypesOOo.hxx @@ -86,6 +86,7 @@ enum ActionMapTypesOOo OOO_SOURCE_SERVICE_ACTIONS, OOO_DRAW_AREA_POLYGON_ACTIONS, OOO_SCRIPT_ACTIONS, + OOO_ANIMATION_ACTIONS, MAX_OOO_ACTIONS }; diff --git a/xmloff/source/transform/AttrTransformerAction.hxx b/xmloff/source/transform/AttrTransformerAction.hxx index ffcd8b43ada0..0cfb6a116c2c 100644 --- a/xmloff/source/transform/AttrTransformerAction.hxx +++ b/xmloff/source/transform/AttrTransformerAction.hxx @@ -135,6 +135,7 @@ enum XMLAttrTransformerAction XML_ATACTION_GAMMA_OOO, // converts double value to percentage XML_ATACTION_DECODE_ID, // converts strings with non numeric characters to only numeric character ids XML_ATACTION_OPACITY_FIX, // converts transparency to opacity and back + XML_ATACTION_SHAPEID, // convert shape id XML_ATACTION_USER_DEFINED=0x40000000,// user defined actions start here XML_ATACTION_END=XML_TACTION_END }; diff --git a/xmloff/source/transform/OOo2Oasis.cxx b/xmloff/source/transform/OOo2Oasis.cxx index 103202c48866..b678da6b2304 100644 --- a/xmloff/source/transform/OOo2Oasis.cxx +++ b/xmloff/source/transform/OOo2Oasis.cxx @@ -573,6 +573,14 @@ static XMLTransformerActionInit aActionTable[] = ENTRY1( TABLE, SOURCE_SERVICE, XML_ETACTION_PROC_ATTRS, OOO_SOURCE_SERVICE_ACTIONS ), + // fix id strings in old animation elements + ENTRY1( PRESENTATION, DIM, XML_ETACTION_PROC_ATTRS, OOO_ANIMATION_ACTIONS ), + ENTRY1( PRESENTATION, PLAY, XML_ETACTION_PROC_ATTRS, OOO_ANIMATION_ACTIONS ), + ENTRY1( PRESENTATION, SHOW_TEXT, XML_ETACTION_PROC_ATTRS, OOO_ANIMATION_ACTIONS ), + ENTRY1( PRESENTATION, SHOW_SHAPE, XML_ETACTION_PROC_ATTRS, OOO_ANIMATION_ACTIONS ), + ENTRY1( PRESENTATION, HIDE_TEXT, XML_ETACTION_PROC_ATTRS, OOO_ANIMATION_ACTIONS ), + ENTRY1( PRESENTATION, HIDE_SHAPE, XML_ETACTION_PROC_ATTRS, OOO_ANIMATION_ACTIONS ), + ENTRY0( OFFICE, TOKEN_INVALID, XML_ETACTION_EOT ) }; @@ -755,6 +763,9 @@ static XMLTransformerActionInit aShapeActionTable[] = ENTRY2( CHART, LEGEND_POSITION, XML_ATACTION_RENAME_ATTRIBUTE, RENAME_ENTRY( XML_LEFT, XML_START ), RENAME_ENTRY( XML_RIGHT, XML_END )), + ENTRY0( DRAW, ID, XML_ATACTION_SHAPEID ), + ENTRY0( DRAW, START_SHAPE, XML_ATACTION_SHAPEID ), + ENTRY0( DRAW, END_SHAPE, XML_ATACTION_SHAPEID ), ENTRY0( OFFICE, TOKEN_INVALID, XML_ATACTION_EOT ) }; @@ -778,6 +789,7 @@ static XMLTransformerActionInit aConnectorActionTable[] = ENTRY1Q( FORM, ID, XML_ATACTION_RENAME, XML_NAMESPACE_DRAW, XML_CONTROL ), ENTRY1( XLINK, HREF, XML_ATACTION_URI_OOO, sal_True ), + ENTRY0( DRAW, ID, XML_ATACTION_SHAPEID ), ENTRY0( OFFICE, TOKEN_INVALID, XML_ATACTION_EOT ) }; @@ -1036,6 +1048,14 @@ static XMLTransformerActionInit aSourceServiceActionTable[] = ENTRY0( OFFICE, TOKEN_INVALID, XML_ATACTION_EOT ) }; +// OOO_ANIMATION_ACTIONS +static XMLTransformerActionInit aAnimationsActionTable[] = +{ + ENTRY0( DRAW, SHAPE_ID, XML_ATACTION_SHAPEID ), + ENTRY0( PRESENTATION, PATH_ID, XML_ATACTION_SHAPEID ), + ENTRY0( OFFICE, TOKEN_INVALID, XML_ATACTION_EOT ) +}; + // OOO_DRAW_AREA_POLYGON_ACTIONS (to be added to OOO_SHAPE_ACTIONS) static XMLTransformerActionInit aDrawAreaPolygonActionTable[] = { @@ -1777,6 +1797,10 @@ XMLTransformerActions *OOo2OasisTransformer::GetUserDefinedActions( m_aActions[OOO_SCRIPT_ACTIONS] = new XMLTransformerActions( aScriptActionTable ); break; + case OOO_ANIMATION_ACTIONS: + m_aActions[OOO_ANIMATION_ACTIONS] = + new XMLTransformerActions( aAnimationsActionTable ); + break; } } pActions = m_aActions[n]; diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx index 61bb73120da6..f2d7af5585c0 100644 --- a/xmloff/source/transform/TransformerBase.cxx +++ b/xmloff/source/transform/TransformerBase.cxx @@ -248,6 +248,9 @@ void SAL_CALL XMLTransformerBase::startElement( const OUString& rName, { SvXMLNamespaceMap *pRewindMap = 0; + bool bRect = rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "presentation:show-shape" ) ); + (void)bRect; + // Process namespace attributes. This must happen before creating the // context, because namespace decaration apply to the element name itself. XMLMutableAttributeList *pMutableAttrList = 0; @@ -888,6 +891,14 @@ XMLMutableAttributeList *XMLTransformerBase::ProcessAttrList( } break; // <-- + case XML_ATACTION_SHAPEID: + { + OUString sNewValue( RTL_CONSTASCII_USTRINGPARAM( "shape" ) ); + sNewValue += rAttrValue; + pMutableAttrList->SetValueByIndex( i, sNewValue ); + break; + } + default: OSL_ENSURE( !this, "unknown action" ); break; |