diff options
210 files changed, 6659 insertions, 1467 deletions
diff --git a/avmedia/prj/build.lst b/avmedia/prj/build.lst index 1ef04ca0f7d5..6651d9d74f8f 100644 --- a/avmedia/prj/build.lst +++ b/avmedia/prj/build.lst @@ -6,6 +6,6 @@ av avmedia\source\viewer nmake - all av_viewer NULL av avmedia\source\framework nmake - all av_framework NULL av avmedia\source\win nmake - all av_win NULL av avmedia\source\java nmake - all av_java NULL -av avmedia\source\xine nmake - all av_xine NULL av avmedia\source\quicktime nmake - all av_quicktime NULL -av avmedia\util nmake - all av_util av_viewer av_framework av_win av_java av_quicktime av_xine NULL +av avmedia\source\gstreamer nmake - all av_gstreamer NULL +av avmedia\util nmake - all av_util av_viewer av_framework av_win av_java av_quicktime av_gstreamer NULL diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx index a71b5268abd7..2eb18cb164d9 100644 --- a/avmedia/source/framework/mediacontrol.cxx +++ b/avmedia/source/framework/mediacontrol.cxx @@ -91,8 +91,6 @@ MediaControl::MediaControl( Window* pParent, MediaControlStyle eControlStyle ) : if( MEDIACONTROLSTYLE_SINGLELINE != meControlStyle ) { - - maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_OPEN, implGetImage( AVMEDIA_IMG_OPEN ), String( AVMEDIA_RESID( AVMEDIA_STR_OPEN ) ) ); maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_OPEN, HID_AVMEDIA_TOOLBOXITEM_OPEN ); @@ -103,8 +101,6 @@ MediaControl::MediaControl( Window* pParent, MediaControlStyle eControlStyle ) : } else { - maTimeSlider.SetBackground(); - maVolumeSlider.SetBackground(); mpZoomListBox->SetBackground(); maZoomToolBox.SetBackground(); diff --git a/avmedia/source/gstreamer/exports.dxp b/avmedia/source/gstreamer/exports.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/avmedia/source/gstreamer/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/avmedia/source/gstreamer/gstcommon.hxx b/avmedia/source/gstreamer/gstcommon.hxx new file mode 100644 index 000000000000..83bb818aefdc --- /dev/null +++ b/avmedia/source/gstreamer/gstcommon.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * 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 _GSTCOMMON_HXX +#define _GSTCOMMON_HXX + +#include <osl/mutex.hxx> +#include <rtl/ustring.hxx> +#include <tools/debug.hxx> +#include <tools/stream.hxx> +#include <tools/string.hxx> +#include <tools/urlobj.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/factory.hxx> + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/awt/Rectangle.hpp> +#include <com/sun/star/awt/KeyModifier.hpp> +#include <com/sun/star/awt/MouseButton.hpp> +#include <com/sun/star/media/XManager.hpp> + +#include <memory> + +#define AVMEDIA_GSTREAMER_MANAGER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Manager_GStreamer" +#define AVMEDIA_GSTREAMER_MANAGER_SERVICENAME "com.sun.star.media.Manager_GStreamer" + +#define AVMEDIA_GSTREAMER_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_GStreamer" +#define AVMEDIA_GSTREAMER_PLAYER_SERVICENAME "com.sun.star.media.Player_GStreamer" + +#define AVMEDIA_GSTREAMER_WINDOW_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Window_GStreamer" +#define AVMEDIA_GSTREAMER_WINDOW_SERVICENAME "com.sun.star.media.Window_GStreamer" + +#define AVMEDIA_GSTREAMER_FRAMEGRABBER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.FrameGrabber_GStreamer" +#define AVMEDIA_GSTREAMER_FRAMEGRABBER_SERVICENAME "com.sun.star.media.FrameGrabber_GStreamer" + +#endif // _GSTCOMMOM_HXX diff --git a/avmedia/source/gstreamer/gstframegrabber.cxx b/avmedia/source/gstreamer/gstframegrabber.cxx new file mode 100644 index 000000000000..bd55e11f8afe --- /dev/null +++ b/avmedia/source/gstreamer/gstframegrabber.cxx @@ -0,0 +1,307 @@ +/************************************************************************* + * + * 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 "gstframegrabber.hxx" +#include "gstplayer.hxx" + +#include <vcl/graph.hxx> +#include <vcl/bmpacc.hxx> + +using namespace ::com::sun::star; + +namespace avmedia { namespace gst { + +const gulong GRAB_TIMEOUT = 10000000; + +// ---------------- +// - FrameGrabber - +// ---------------- + +FrameGrabber::FrameGrabber( GString* pURI ) : + Player( pURI ), + mpFrameMutex( g_mutex_new() ), + mpFrameCond( g_cond_new() ), + mpLastPixbuf( NULL ), + mbIsInGrabMode( false ) +{ +} + +// ------------------------------------------------------------------------------ + +FrameGrabber::~FrameGrabber() +{ + if( g_atomic_pointer_get( &mpPlayer ) ) + { + implQuitThread(); + } + + // thread has ended, so that no more synchronization is necessary + if( mpLastPixbuf ) + { + g_object_unref( mpLastPixbuf ); + mpLastPixbuf = NULL; + } + + g_cond_free( mpFrameCond ); + g_mutex_free( mpFrameMutex ); +} + +// ------------------------------------------------------------------------------ + +FrameGrabber* FrameGrabber::create( const GString* pURI ) +{ + FrameGrabber* pFrameGrabber = NULL; + + if( pURI && pURI->len ) + { + // safely initialize GLib threading framework + try + { + if( !g_thread_supported() ) + { + g_thread_init( NULL ); + } + } + catch( ... ) + {} + + if( g_thread_supported() ) + { + pFrameGrabber = new FrameGrabber( g_string_new( pURI->str ) ); + + // wait until thread signals that it has finished initialization + if( pFrameGrabber->mpThread ) + { + g_mutex_lock( pFrameGrabber->mpMutex ); + + while( !pFrameGrabber->implIsInitialized() ) + { + g_cond_wait( pFrameGrabber->mpCond, pFrameGrabber->mpMutex ); + } + + g_mutex_unlock( pFrameGrabber->mpMutex ); + } + + GstElement* pPixbufSink = gst_element_factory_make( "gdkpixbufsink", NULL ); + + // check if player pipeline and GdkPixbufSink could be initialized + if( !pFrameGrabber->mpPlayer || !pPixbufSink ) + { + delete pFrameGrabber; + pFrameGrabber = NULL; + } + else + { + g_object_set( pFrameGrabber->mpPlayer, "audio-sink", gst_element_factory_make( "fakesink", NULL ), NULL ); + g_object_set( pFrameGrabber->mpPlayer, "video-sink", pPixbufSink, NULL ); + } + } + } + + return( pFrameGrabber ); +} + +// ------------------------------------------------------------------------------ + +gboolean FrameGrabber::busCallback( GstBus* pBus, GstMessage* pMsg ) +{ + bool bDone = false; + + if( pMsg && pMsg->structure ) + { + GstStructure* pStruct = pMsg->structure; + const gchar* pStructName = gst_structure_get_name( pStruct ); + + if( ( ::std::string( pStructName ).find( "pixbuf" ) != ::std::string::npos ) && + gst_structure_has_field ( pStruct, "pixbuf") ) + { + bool bFrameGrabbed = false; + + g_mutex_lock( mpFrameMutex ); + + if( mbIsInGrabMode && ( getMediaTime() >= mfGrabTime ) ) + { + OSL_TRACE( "Grabbing frame at %fs", getMediaTime() ); + + if( mpLastPixbuf ) + { + g_object_unref( mpLastPixbuf ); + mpLastPixbuf = NULL; + } + + mpLastPixbuf = GDK_PIXBUF( g_value_dup_object( gst_structure_get_value( pStruct, "pixbuf" ) ) ); + bFrameGrabbed = true; + } + + g_mutex_unlock( mpFrameMutex ); + + if( bFrameGrabbed ) + { + g_cond_signal( mpFrameCond ); + } + + bDone = true; + } + } + + return( bDone || Player::busCallback( pBus, pMsg ) ); +} + +// ------------------------------------------------------------------------------ + +uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMediaTime ) + throw (uno::RuntimeException) +{ + uno::Reference< graphic::XGraphic > xRet; + + if( implInitPlayer() ) + { + OSL_TRACE( "Trying to grab frame at %fs", fMediaTime ); + + GTimeVal aTimeoutTime; + + g_get_current_time( &aTimeoutTime ); + g_time_val_add( &aTimeoutTime, GRAB_TIMEOUT ); + setMediaTime( fMediaTime ); + start(); + + if( isPlaying() ) + { + g_mutex_lock( mpFrameMutex ); + + mbIsInGrabMode = true; + mfGrabTime = fMediaTime; + g_cond_timed_wait( mpFrameCond, mpFrameMutex, &aTimeoutTime ); + mbIsInGrabMode = false; + + g_mutex_unlock( mpFrameMutex ); + + stop(); + } + + OSL_ENSURE( g_atomic_pointer_get( &mpLastPixbuf ), "FrameGrabber timed out without receiving a Pixbuf" ); + + if( g_atomic_pointer_get( &mpLastPixbuf ) ) + { + OSL_TRACE( "FrameGrabber received a GdkPixbuf"); + + g_mutex_lock( mpFrameMutex ); + + const int nWidth = gdk_pixbuf_get_width( mpLastPixbuf ); + const int nHeight = gdk_pixbuf_get_height( mpLastPixbuf ); + const int nChannels = gdk_pixbuf_get_n_channels( mpLastPixbuf ); + const guchar* pBuffer = gdk_pixbuf_get_pixels( mpLastPixbuf ); + + if( pBuffer && ( nWidth > 0 ) && ( nHeight > 0 ) ) + { + Bitmap aFrame( Size( nWidth, nHeight), 24 ); + bool bInit = false; + + if( ( gdk_pixbuf_get_colorspace( mpLastPixbuf ) == GDK_COLORSPACE_RGB ) && + ( nChannels >= 3 ) && ( nChannels <= 4 ) && + ( gdk_pixbuf_get_bits_per_sample( mpLastPixbuf ) == 8 ) ) + { + BitmapWriteAccess* pAcc = aFrame.AcquireWriteAccess(); + + if( pAcc ) + { + BitmapColor aPixel( 0, 0, 0 ); + const int nRowStride = gdk_pixbuf_get_rowstride( mpLastPixbuf ); + const bool bAlpha = ( nChannels == 4 ); + + for( int nRow = 0; nRow < nHeight; ++nRow ) + { + guchar* pCur = const_cast< guchar* >( pBuffer + nRow * nRowStride ); + + for( int nCol = 0; nCol < nWidth; ++nCol ) + { + aPixel.SetRed( *pCur++ ); + aPixel.SetGreen( *pCur++ ); + aPixel.SetBlue( *pCur++ ); + + // ignore alpha channel + if( bAlpha ) + { + ++pCur; + } + + pAcc->SetPixel( nRow, nCol, aPixel ); + } + } + + aFrame.ReleaseAccess( pAcc ); + bInit = true; + } + } + + if( !bInit ) + { + aFrame.Erase( Color( COL_BLACK ) ); + } + + xRet = Graphic( aFrame ).GetXGraphic(); + } + + g_object_unref( mpLastPixbuf ); + mpLastPixbuf = NULL; + + g_mutex_unlock( mpFrameMutex ); + } + } + + return xRet; +} + +// ------------------------------------------------------------------------------ + +::rtl::OUString SAL_CALL FrameGrabber::getImplementationName( ) + throw (uno::RuntimeException) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GSTREAMER_FRAMEGRABBER_IMPLEMENTATIONNAME ) ); +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL FrameGrabber::supportsService( const ::rtl::OUString& ServiceName ) + throw (uno::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_GSTREAMER_FRAMEGRABBER_SERVICENAME ) ); +} + +// ------------------------------------------------------------------------------ + +uno::Sequence< ::rtl::OUString > SAL_CALL FrameGrabber::getSupportedServiceNames( ) + throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aRet(1); + aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_GSTREAMER_FRAMEGRABBER_SERVICENAME ) ); + + return aRet; +} + +} // namespace win +} // namespace avmedia diff --git a/avmedia/source/gstreamer/gstframegrabber.hxx b/avmedia/source/gstreamer/gstframegrabber.hxx new file mode 100644 index 000000000000..9a7ec1b74102 --- /dev/null +++ b/avmedia/source/gstreamer/gstframegrabber.hxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * 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 _FRAMEGRABBER_HXX +#define _FRAMEGRABBER_HXX + +#include "gstplayer.hxx" +#include <gdk-pixbuf/gdk-pixbuf.h> + +#ifndef _COM_SUN_STAR_MEDIA_XFRAMEGRABBER_HDL_ +#include "com/sun/star/media/XFrameGrabber.hdl" +#endif + +namespace avmedia { namespace gst { + +// ---------------- +// - FrameGrabber - +// ---------------- + +class FrameGrabber : public Player, + public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XFrameGrabber, + ::com::sun::star::lang::XServiceInfo > +{ +public: + + // static create method instead of public Ctor + static FrameGrabber* create( const GString* pUri ); + + ~FrameGrabber(); + + // XFrameGrabber + virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL grabFrame( double fMediaTime ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + 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); + +protected: FrameGrabber( GString* pURI = NULL ); + + virtual gboolean busCallback( GstBus* pBus, + GstMessage* pMsg ); + +private: FrameGrabber( const FrameGrabber& ); + FrameGrabber& operator=( const FrameGrabber& ); + + GMutex* mpFrameMutex; + GCond* mpFrameCond; + GdkPixbuf* mpLastPixbuf; + double mfGrabTime; + bool mbIsInGrabMode; +}; + +} // namespace gst +} // namespace avmedia + +#endif // _FRAMEGRABBER_HXX diff --git a/avmedia/source/gstreamer/gstmanager.cxx b/avmedia/source/gstreamer/gstmanager.cxx new file mode 100644 index 000000000000..61ee4ce22cd8 --- /dev/null +++ b/avmedia/source/gstreamer/gstmanager.cxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * 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 "gstmanager.hxx" +#include "gstplayer.hxx" + +using namespace ::com::sun::star; + +namespace avmedia +{ +namespace gst +{ +// ---------------- +// - Manager - +// ---------------- + +Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : + mxMgr( rxMgr ) +{} + +// ------------------------------------------------------------------------------ + +Manager::~Manager() +{} + +// ------------------------------------------------------------------------------ + +uno::Reference< media::XPlayer > SAL_CALL Manager::createPlayer( const ::rtl::OUString& rURL ) + throw( uno::RuntimeException ) +{ + return( ::avmedia::gst::Player::create( rURL ) ); +} + +// ------------------------------------------------------------------------------ + +::rtl::OUString SAL_CALL Manager::getImplementationName() + throw( uno::RuntimeException ) +{ + return( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GSTREAMER_MANAGER_IMPLEMENTATIONNAME ) ) ); +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Manager::supportsService( const ::rtl::OUString& ServiceName ) + throw( uno::RuntimeException ) +{ + return( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( AVMEDIA_GSTREAMER_MANAGER_SERVICENAME ) ) ); +} + +// ------------------------------------------------------------------------------ + +uno::Sequence< ::rtl::OUString > SAL_CALL Manager::getSupportedServiceNames() + throw( uno::RuntimeException ) +{ + uno::Sequence< ::rtl::OUString > aRet( 1 ); + aRet[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GSTREAMER_MANAGER_SERVICENAME ) ); + + return( aRet ); +} +} // namespace gst +} // namespace avmedia diff --git a/avmedia/source/gstreamer/gstmanager.hxx b/avmedia/source/gstreamer/gstmanager.hxx new file mode 100644 index 000000000000..9f80e8c1a901 --- /dev/null +++ b/avmedia/source/gstreamer/gstmanager.hxx @@ -0,0 +1,74 @@ +/************************************************************************* + * + * 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 _GSTMANAGER_HXX +#define _GSTMANAGER_HXX + +#include "gstcommon.hxx" + +#ifndef _COM_SUN_STAR_MEDIA_XMANAGER_HDL_ +#include "com/sun/star/media/XManager.hdl" +#endif + +// ----------- +// - Manager - +// ----------- + +namespace avmedia +{ +namespace gst +{ +class Manager : public ::cppu::WeakImplHelper2< ::com::sun::star::media::XManager, + ::com::sun::star::lang::XServiceInfo > +{ +public: Manager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMgr ); + ~Manager(); + + // XManager + virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > SAL_CALL createPlayer( + const ::rtl::OUString& aURL ) + throw( ::com::sun::star::uno::RuntimeException ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw( ::com::sun::star::uno::RuntimeException ); + + 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 ); + + +private: + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr; +}; +} // namespace gst +} // namespace avmedia + +#endif // _GSTMANAGER_HXX diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx new file mode 100644 index 000000000000..f082cfc5c513 --- /dev/null +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -0,0 +1,938 @@ +/************************************************************************* + * + * 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 "gstplayer.hxx" +#include "gstwindow.hxx" +#include "gstframegrabber.hxx" +#include <stdio.h> +#include <unistd.h> +#include <math.h> +#include <string> +#include <gst/gstelement.h> +#include <gst/interfaces/xoverlay.h> + + +// maximum timeout time in nanoseconds +#define GST_MAX_TIMEOUT (2500 * GST_MSECOND) + +using namespace ::com::sun::star; + +namespace avmedia +{ +namespace gst +{ +const double NANO_TIME_FACTOR = 1000000000.0; + +const long VIDEO_DEFAULT_WIDTH = 256; +const long VIDEO_DEFAULT_HEIGHT = 192; + +// ---------------- +// - GstBusSource - +// ---------------- + +struct GstBusSource : public GSource +{ + GstBus* mpBus; + + GstBusSource() : + mpBus( NULL ) + {} + + ~GstBusSource() + {} +}; + +// --------------- +// - Player - +// --------------- +Player::Player( GString* pURI ) : + mpMutex( g_mutex_new() ), + mpCond( g_cond_new() ), + mpThread( NULL ), + mpContext( NULL ), + mpLoop( NULL ), + mpPlayer( NULL ), + mpURI( pURI ), + mpPlayerWindow( NULL ), + mnIsVideoSource( 0 ), + mnVideoWidth( 0 ), + mnVideoHeight( 0 ), + mnInitialized( 0 ), + mnVolumeDB( 0 ), + mnLooping( 0 ), + mnQuit( 0 ), + mnVideoWindowSet( 0 ), + mnInitFail( 0 ) +{ + // initialize GStreamer framework only once + static bool bGstInitialized = false; + + if( !bGstInitialized ) + { + gst_init( NULL, NULL ); + bGstInitialized = true; + } + + if( pURI ) + { + OSL_TRACE( ">>> --------------------------------" ); + OSL_TRACE( ">>> Creating Player object with URL: %s", pURI->str ); + + mpThread = g_thread_create( Player::implThreadFunc, this, true, NULL ); + } +} + +// ------------------------------------------------------------------------------ + +Player::~Player() +{ + if( g_atomic_pointer_get( &mpPlayer ) ) + { + implQuitThread(); + } + + // cleanup + g_cond_free( mpCond ); + g_mutex_free( mpMutex ); + g_string_free( mpURI, false ); +} + +// ------------------------------------------------------------------------------ +Player* Player::create( const ::rtl::OUString& rURL ) +{ + Player* pPlayer = NULL; + + if( rURL.getLength() ) + { + // safely initialize GLib threading framework + try + { + if( !g_thread_supported() ) + { + g_thread_init( NULL ); + } + } + catch( ... ) + {} + + if( g_thread_supported() ) + { + const INetURLObject aURL( rURL ); + + if( aURL.GetProtocol() != INET_PROT_NOT_VALID ) + { + GString* pURI = g_string_new( ::rtl::OUStringToOString( + aURL.GetMainURL( INetURLObject::NO_DECODE ), + RTL_TEXTENCODING_UTF8 ).getStr() ); + + if( pURI->len ) + { + pPlayer = new Player( pURI ); + + // wait until thread signals that it has finished initialization + if( pPlayer->mpThread ) + { + g_mutex_lock( pPlayer->mpMutex ); + + while( !pPlayer->implIsInitialized() ) + { + g_cond_wait( pPlayer->mpCond, pPlayer->mpMutex ); + } + + g_mutex_unlock( pPlayer->mpMutex ); + } + + // check if player pipeline could be initialized + if( !pPlayer->mpPlayer ) + { + delete pPlayer; + pPlayer = NULL; + } + } + else + { + g_string_free( pURI, false ); + } + } + } + } + + return( pPlayer ); +} + +// ------------------------------------------------------------------------------ +void SAL_CALL Player::start() + throw( uno::RuntimeException ) +{ + if( implInitPlayer() && !isPlaying() ) + { + gst_element_set_state( mpPlayer, GST_STATE_PLAYING ); + } +} + +// ------------------------------------------------------------------------------ +void SAL_CALL Player::stop() + throw( uno::RuntimeException ) +{ + if( implInitPlayer() && isPlaying() ) + { + gst_element_set_state( mpPlayer, GST_STATE_PAUSED ); + } +} + +// ------------------------------------------------------------------------------ +sal_Bool SAL_CALL Player::isPlaying() + throw( uno::RuntimeException ) +{ + GstState aState = GST_STATE_NULL; + + if( mpPlayer ) + { + gst_element_get_state( mpPlayer, &aState, NULL, GST_MAX_TIMEOUT ); + } + + return( GST_STATE_PLAYING == aState ); +} + +// ------------------------------------------------------------------------------ +double SAL_CALL Player::getDuration() + throw( uno::RuntimeException ) +{ + gint64 nDuration = 0; + + if( implInitPlayer() ) + { + GstFormat aFormat = GST_FORMAT_TIME; + + if( !gst_element_query_duration( mpPlayer, &aFormat, &nDuration ) || + ( GST_FORMAT_TIME != aFormat ) || + ( nDuration < 0 ) ) + { + nDuration = 0; + } + } + + return( static_cast< double >( nDuration ) / NANO_TIME_FACTOR ); +} + +// ------------------------------------------------------------------------------ +void SAL_CALL Player::setMediaTime( double fTime ) + throw( uno::RuntimeException ) +{ + if( implInitPlayer() ) + { + fTime = ::std::min( ::std::max( fTime, 0.0 ), getDuration() ); + + gst_element_seek_simple( mpPlayer, GST_FORMAT_TIME, + (GstSeekFlags) ( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT ), + static_cast< gint64 >( fTime * NANO_TIME_FACTOR ) ); + } +} + +// ------------------------------------------------------------------------------ +double SAL_CALL Player::getMediaTime() + throw( uno::RuntimeException ) +{ + double fRet = 0.0; + + if( implInitPlayer() ) + { + GstFormat aFormat = GST_FORMAT_TIME; + gint64 nCurTime = 0; + + if( gst_element_query_position( mpPlayer, &aFormat, &nCurTime ) && + ( GST_FORMAT_TIME == aFormat ) && + ( nCurTime >= 0 ) ) + { + fRet = static_cast< double >( nCurTime ) / NANO_TIME_FACTOR; + } + } + + return( fRet ); +} + +// ------------------------------------------------------------------------------ +void SAL_CALL Player::setStopTime( double /* fTime */ ) + throw( uno::RuntimeException ) +{ + OSL_TRACE( "GStreamer method avmedia::gst::Player::setStopTime needs to be implemented" ); + + /* Currently no need for implementation since higher levels of code don't use this method at all + !!! TODO: needs to be implemented if this functionality is needed at a later point of time + if( implInitPlayer() ) + { + } + + */ +} + +// ------------------------------------------------------------------------------ +double SAL_CALL Player::getStopTime() + throw( uno::RuntimeException ) +{ + /* + 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 + */ + + return( getDuration() ); +} + +// ------------------------------------------------------------------------------ +void SAL_CALL Player::setRate( double /* fRate */ ) + throw( uno::RuntimeException ) +{ + OSL_TRACE( "GStreamer method avmedia::gst::Player::setRate needs to be implemented" ); + + /* Currently no need for implementation since higher levels of code don't use this method at all + !!! TODO: needs to be implemented if this functionality is needed at a later point of time + */ +} + +// ------------------------------------------------------------------------------ +double SAL_CALL Player::getRate() + throw( uno::RuntimeException ) +{ + /* + Currently no need for implementation since higher levels of code don't set a different rate than 1 ATM + !!! TODO: needs to be fully implemented if this functionality is needed at a later point of time + */ + + return( 1.0 ); +} + +// ------------------------------------------------------------------------------ +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 ); +} + +// ------------------------------------------------------------------------------ +sal_Bool SAL_CALL Player::isPlaybackLoop() + throw( uno::RuntimeException ) +{ + return( g_atomic_int_get( &mnLooping ) > 0 ); +} + +// ------------------------------------------------------------------------------ +void SAL_CALL Player::setMute( sal_Bool bSet ) + throw( uno::RuntimeException ) +{ + if( implInitPlayer() && ( bSet != isMute() ) ) + { + if( bSet ) + { + g_object_set( mpPlayer, "volume", 0.0, NULL ); + } + else + { + setVolumeDB( mnVolumeDB ); + } + } +} + +// ------------------------------------------------------------------------------ +sal_Bool SAL_CALL Player::isMute() + throw( uno::RuntimeException ) +{ + gdouble fGstVolume = 1.0; + + if( implInitPlayer() ) + { + g_object_get( mpPlayer, "volume", &fGstVolume, NULL ); + } + + return( 0.0 == fGstVolume ); +} + +// ------------------------------------------------------------------------------ +void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) + throw( uno::RuntimeException ) +{ + if( implInitPlayer() ) + { + g_mutex_lock( mpMutex ); + mnVolumeDB = nVolumeDB; + g_mutex_unlock( mpMutex ); + + // maximum gain for gstreamer volume is 10 + double fGstVolume = pow( 10.0, static_cast< double >( ::std::min( + nVolumeDB, static_cast< sal_Int16 >( 20 ) ) / 20.0 ) ); + + g_object_set( mpPlayer, "volume", fGstVolume, NULL ); + } +} + +// ------------------------------------------------------------------------------ +sal_Int16 SAL_CALL Player::getVolumeDB() + throw( uno::RuntimeException ) +{ + return( static_cast< sal_Int16 >( g_atomic_int_get( &mnVolumeDB ) ) ); +} + +// ------------------------------------------------------------------------------ +awt::Size SAL_CALL Player::getPreferredPlayerWindowSize() + throw( uno::RuntimeException ) +{ + awt::Size aSize( 0, 0 ); + + if( implInitPlayer() && ( g_atomic_int_get( &mnIsVideoSource ) > 0 ) ) + { + aSize.Width = g_atomic_int_get( &mnVideoWidth ); + aSize.Height = g_atomic_int_get( &mnVideoHeight ); + + // if we have a video source, but no size is given => use default size + if( ( aSize.Width <= 0 ) || ( aSize.Height <= 0 ) ) + { + aSize.Width = VIDEO_DEFAULT_WIDTH; + aSize.Height = VIDEO_DEFAULT_HEIGHT; + } + } + + OSL_TRACE( ">>> Requested preferred video size is: %d x %d pixel", aSize.Width, aSize.Height ); + + return( aSize ); +} + +// ------------------------------------------------------------------------------ +uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( + const uno::Sequence< uno::Any >& rArguments ) + throw( uno::RuntimeException ) +{ + uno::Reference< ::media::XPlayerWindow > xRet; + awt::Size aSize( getPreferredPlayerWindowSize() ); + + OSL_ENSURE( !g_atomic_pointer_get( &mpPlayerWindow ), "::avmedia::gst::Player already has a player window" ); + + if( ( aSize.Width > 0 ) && ( aSize.Height > 0 ) ) + { + Window* pPlayerWindow = new Window( *this ); + + xRet = pPlayerWindow; + + if( !pPlayerWindow->create( rArguments ) ) + { + xRet.clear(); + } + else + { + // try to use gconf user configurable video sink first + GstElement* pVideoSink = gst_element_factory_make( "gconfvideosink", NULL ); + + if( ( NULL != pVideoSink ) || + ( NULL != ( pVideoSink = gst_element_factory_make( "autovideosink", NULL ) ) ) || + ( NULL != ( pVideoSink = gst_element_factory_make( "xvimagesink", NULL ) ) ) || + ( NULL != ( pVideoSink = gst_element_factory_make( "ximagesink", NULL ) ) ) ) + { + GstState aOldState = GST_STATE_NULL; + + mpPlayerWindow = pPlayerWindow; + gst_element_get_state( mpPlayer, &aOldState, NULL, GST_MAX_TIMEOUT ); + gst_element_set_state( mpPlayer, GST_STATE_READY ); + g_object_set( mpPlayer, "video-sink", pVideoSink, NULL ); + gst_element_set_state( mpPlayer, aOldState ); + } + } + } + + return( xRet ); +} + +// ------------------------------------------------------------------------------ +uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber() + throw( ::com::sun::star::uno::RuntimeException ) +{ + FrameGrabber* pFrameGrabber = NULL; + const awt::Size aPrefSize( getPreferredPlayerWindowSize() ); + + if( ( aPrefSize.Width > 0 ) && ( aPrefSize.Height > 0 ) ) + { + pFrameGrabber = FrameGrabber::create( mpURI ); + } + + return( pFrameGrabber ); +} + +// ------------------------------------------------------------------------------ +void SAL_CALL Player::dispose() + throw( uno::RuntimeException ) +{ + if( mpPlayer ) + { + stop(); + implQuitThread(); + } + + OSL_ASSERT( NULL == mpPlayer ); +} + +// ------------------------------------------------------------------------------ +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 ) +{ + return( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GSTREAMER_PLAYER_IMPLEMENTATIONNAME ) ) ); +} + +// ------------------------------------------------------------------------------ +sal_Bool SAL_CALL Player::supportsService( const ::rtl::OUString& ServiceName ) + throw( uno::RuntimeException ) +{ + return( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( AVMEDIA_GSTREAMER_PLAYER_SERVICENAME ) ) ); +} + +// ------------------------------------------------------------------------------ +uno::Sequence< ::rtl::OUString > SAL_CALL Player::getSupportedServiceNames() + throw( uno::RuntimeException ) +{ + uno::Sequence< ::rtl::OUString > aRet( 1 ); + aRet[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GSTREAMER_PLAYER_SERVICENAME ) ); + + return( aRet ); +} + +// ------------------------------------------------------------------------------ +void Player::implQuitThread() +{ + if( mpThread ) + { + // set quit flag to 1 so that the main loop will be quit in idle + // handler the next time it is called from the thread's main loop + g_atomic_int_inc( &mnQuit ); + + // wait until loop and as such the thread has quit + g_thread_join( mpThread ); + mpThread = NULL; + } +} + +// ------------------------------------------------------------------------------ +bool Player::implInitPlayer() +{ + bool bRet = false; + + if( mpPlayer && (mnInitFail < 3) ) + { + GstState aState = GST_STATE_NULL; + + if( gst_element_get_state( mpPlayer, &aState, NULL, GST_MAX_TIMEOUT ) == GST_STATE_CHANGE_SUCCESS ) + { + bRet = ( GST_STATE_PAUSED == aState ) || ( GST_STATE_PLAYING == aState ); + + if( !bRet ) + { + gst_element_set_state( mpPlayer, GST_STATE_PAUSED ); + bRet = ( gst_element_get_state( mpPlayer, &aState, NULL, + GST_MAX_TIMEOUT ) == GST_STATE_CHANGE_SUCCESS ) && + ( GST_STATE_PAUSED == aState ); + } + } + + if( ! bRet ) + mnInitFail++; + } + + return( bRet ); +} + +// ------------------------------------------------------------------------------ +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 ) +{ + if( pMsg && mpLoop ) + { + switch( GST_MESSAGE_TYPE( pMsg ) ) + { + case ( GST_MESSAGE_EOS ): + { + if( g_atomic_int_get( &mnLooping ) > 0 ) + { + setMediaTime( 0.0 ); + start(); + } + else + { + stop(); + } + } + break; + + case ( GST_MESSAGE_ERROR ): + { + gchar* pDebug; + GError* pErr; + + gst_message_parse_error( pMsg, &pErr, &pDebug ); + fprintf( stderr, "Error: %s\n", pErr->message ); + + g_free( pDebug ); + g_error_free( pErr ); + } + break; + + default: + { + break; + } + } + } + + return( true ); +} + +// ------------------------------------------------------------------------------ +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 ) +{ + if( pElement ) + { +#ifdef DEBUG + gchar* pElementName = gst_element_get_name( pElement ); + + if( pElementName ) + { + OSL_TRACE( ">>> Bin has element: %s", pElementName ); + g_free( pElementName ); + } +#endif + + if( GST_IS_BIN( pElement ) ) + { + // set this handler in case we have a GstBin element + g_signal_connect( GST_BIN( pElement ), "element-added", + G_CALLBACK( Player::implHandleNewElementFunc ), pData ); + } + + // watch for all pads that are going to be added to this element; + g_signal_connect( pElement, "pad-added", + G_CALLBACK( Player::implHandleNewPadFunc ), pData ); + } +} + +// ------------------------------------------------------------------------------ +void Player::implHandleNewPadFunc( GstElement* pElement, + GstPad* pPad, + gpointer pData ) +{ + Player* pPlayer = static_cast< Player* >( pData ); + + if( pPlayer && pElement && pPad ) + { +#ifdef DEBUG + gchar* pElementName = gst_element_get_name( pElement ); + gchar* pPadName = gst_pad_get_name( pPad ); + + OSL_TRACE( ">>> Element %s has pad: %s", pElementName, pPadName ); + + g_free( pPadName ); + g_free( pElementName ); +#endif + + GstCaps* pCaps = gst_pad_get_caps( pPad ); + + // we are interested only in getting video properties + // width and height or if we have a video source at all + if( pCaps ) + { + for( gint i = 0, nSize = gst_caps_get_size( pCaps ); i < nSize; ++i ) + { + const GstStructure* pStruct = gst_caps_get_structure( pCaps, i ); + + if( pStruct ) + { + const gchar* pStructName = gst_structure_get_name( pStruct ); + +#ifdef DEBUG + OSL_TRACE( "\t>>> Pad has structure: %s", pStructName ); + + for( gint n = 0, nFields = gst_structure_n_fields( pStruct ); n < nFields; ++n ) + { + OSL_TRACE( "\t\t>>> Structure has field: %s", gst_structure_nth_field_name( pStruct, n ) ); + } +#endif + + // just look for structures having 'video' in their names + if( ::std::string( pStructName ).find( "video" ) != ::std::string::npos ) + { + g_atomic_int_inc( &pPlayer->mnIsVideoSource ); + + for( gint n = 0, nFields = gst_structure_n_fields( pStruct ); n < nFields; ++n ) + { + const gchar* pFieldName = gst_structure_nth_field_name( pStruct, n ); + gint nValue; + + if( ( ::std::string( pFieldName ).find( "width" ) != ::std::string::npos ) && + gst_structure_get_int( pStruct, pFieldName, &nValue ) ) + { + const gint nDiff = nValue - g_atomic_int_get( &pPlayer->mnVideoWidth ); + g_atomic_int_add( &pPlayer->mnVideoWidth, ::std::max( nDiff, 0 ) ); + } + else if( ( ::std::string( pFieldName ).find( "height" ) != ::std::string::npos ) && + gst_structure_get_int( pStruct, pFieldName, &nValue ) ) + { + const gint nDiff = nValue - g_atomic_int_get( &pPlayer->mnVideoHeight ); + g_atomic_int_add( &pPlayer->mnVideoHeight, ::std::max( nDiff, 0 ) ); + } + } + } + } + } + + gst_caps_unref( pCaps ); + } + } +} + +// ------------------------------------------------------------------------------ +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 ); + + 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 ); + } + + // don't eat up all cpu time + usleep( 1000 ); + + return( true ); +} + +// ------------------------------------------------------------------------------ +gpointer Player::run() +{ + static GSourceFuncs aSourceFuncs = + { + Player::implBusPrepare, + Player::implBusCheck, + Player::implBusDispatch, + Player::implBusFinalize, + NULL, + NULL + }; + + if( NULL != ( mpPlayer = gst_element_factory_make( "playbin", NULL ) ) ) + { + // initialization + // no mutex necessary since initialization + // is synchronous until loop is started + mpContext = g_main_context_new(); + mpLoop = g_main_loop_new( mpContext, false ); + + // add idle callback + GSource* pIdleSource = g_idle_source_new(); + g_source_set_callback( pIdleSource, Player::implIdleFunc, this, NULL ); + g_source_attach( pIdleSource, mpContext ); + + // add bus callback + GSource* pBusSource = g_source_new( &aSourceFuncs, sizeof( GstBusSource ) ); + static_cast< GstBusSource* >( pBusSource )->mpBus = gst_pipeline_get_bus( GST_PIPELINE( mpPlayer ) ); + g_source_set_callback( pBusSource, NULL, this, NULL ); + g_source_attach( pBusSource, mpContext ); + + // 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 ); + + // watch for all elements (and pads) that will be added to the playbin, + // in order to retrieve properties like video width and height + g_signal_connect( GST_BIN( mpPlayer ), "element-added", + G_CALLBACK( Player::implHandleNewElementFunc ), this ); + + // set source URI for player + g_object_set( mpPlayer, "uri", mpURI->str, NULL ); + + // set video fake sink first, since we only create a player without window here + // and don't want to have the gstreamer default window appearing + g_object_set( mpPlayer, "video-sink", gst_element_factory_make( "fakesink", NULL ), NULL ); + + // set state of player to READY or destroy object in case of FAILURE + if( gst_element_set_state( mpPlayer, GST_STATE_READY ) == GST_STATE_CHANGE_FAILURE ) + { + gst_object_unref( mpPlayer ); + mpPlayer = NULL; + } + + g_atomic_int_add( &mnInitialized, 1 ); + g_cond_signal( mpCond ); + + // run the main loop + g_main_loop_run( mpLoop ); + + // clenanup + // no mutex necessary since other thread joined us (this thread) + // after setting the quit flag + if( mpPlayer ) + { + gst_element_set_state( mpPlayer, GST_STATE_NULL ); + gst_object_unref( mpPlayer ); + mpPlayer = NULL; + } + + g_main_loop_unref( mpLoop ); + mpLoop = NULL; + + g_source_destroy( pBusSource ); + g_source_unref( pBusSource ); + + g_source_destroy( pIdleSource ); + g_source_unref( pIdleSource ); + + g_main_context_unref( mpContext ); + mpContext = NULL; + } + else + { + g_atomic_int_add( &mnInitialized, 1 ); + g_cond_signal( mpCond ); + } + + return( NULL ); +} + +// ------------------------------------------------------------------------------ +GstBusSyncReply Player::handleCreateWindow( GstBus* /* pBus */, + GstMessage* pMsg ) +{ + GstBusSyncReply eRet = GST_BUS_PASS; + + if( pMsg && + ( GST_MESSAGE_TYPE( pMsg ) == GST_MESSAGE_ELEMENT ) && + gst_structure_has_name( pMsg->structure, "prepare-xwindow-id" ) && + g_atomic_pointer_get( &mpPlayerWindow ) ) + { + OSL_TRACE( ">>> Got Request to create XOverlay" ); + + gst_x_overlay_set_xwindow_id( GST_X_OVERLAY( GST_MESSAGE_SRC( pMsg ) ), + static_cast< Window* >( g_atomic_pointer_get( + &mpPlayerWindow ) )->getXWindowHandle() ); + + gst_message_unref( pMsg ); + eRet = GST_BUS_DROP; + } + + return( eRet ); +} +} // namespace gst +} // namespace avmedia diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx new file mode 100644 index 000000000000..d751e381258d --- /dev/null +++ b/avmedia/source/gstreamer/gstplayer.hxx @@ -0,0 +1,236 @@ +/************************************************************************* + * + * 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 _GSTPLAYER_HXX +#define _GSTPLAYER_HXX + +#include "gstcommon.hxx" +#include <glib.h> +#include <glib/gatomic.h> + +// necessary for mixed environments with GStreamer-0.10 and GLib versions < 2.8 +#ifndef G_GNUC_NULL_TERMINATED +#if __GNUC__ >= 4 +#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) +#else +#define G_GNUC_NULL_TERMINATED +#endif +#endif + +struct _GOptionGroup; +typedef struct _GOptionGroup GOptionGroup; + +#include <gst/gst.h> +#include "com/sun/star/media/XPlayer.hdl" + +namespace avmedia +{ +namespace gst +{ +class Window; + +// --------------- +// - Player_Impl - +// --------------- + +class Player : public ::cppu::WeakImplHelper3< ::com::sun::star::media::XPlayer, + ::com::sun::star::lang::XComponent, + ::com::sun::star::lang::XServiceInfo > +{ +public: + + // static create method instead of public Ctor + static Player* create( const ::rtl::OUString& rURL ); + + ~Player(); + + // XPlayer + virtual void SAL_CALL start() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL stop() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL isPlaying() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual double SAL_CALL getDuration() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setMediaTime( double fTime ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual double SAL_CALL getMediaTime() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setStopTime( double fTime ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual double SAL_CALL getStopTime() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setRate( double fRate ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual double SAL_CALL getRate() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setPlaybackLoop( sal_Bool bSet ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL isPlaybackLoop() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setMute( sal_Bool bSet ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL isMute() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setVolumeDB( sal_Int16 nVolumeDB ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual sal_Int16 SAL_CALL getVolumeDB() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual ::com::sun::star::awt::Size SAL_CALL getPreferredPlayerWindowSize() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > SAL_CALL createPlayerWindow( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) + throw( ::com::sun::star::uno::RuntimeException ); + + 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 ); + + 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 ); + + +protected: + + Player( GString* pURI = NULL ); + + virtual gboolean busCallback( GstBus* pBus, + GstMessage* pMsg ); + + virtual gboolean idle(); + + virtual gpointer run(); + + virtual GstBusSyncReply handleCreateWindow( GstBus* pBus, + GstMessage* pMsg ); + + void implQuitThread(); + + bool implInitPlayer(); + + bool implIsInitialized() const + { + return( g_atomic_int_get( &mnInitialized ) > 0 ); + } + + +private: + + Player( const Player& ); + + 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 ); + + static void implHandleNewPadFunc( GstElement* pElem, + GstPad* pPad, + gpointer pData ); + +protected: + + GMutex* mpMutex; + GCond* mpCond; + GThread* mpThread; + GMainContext* mpContext; + GMainLoop* mpLoop; + GstElement* mpPlayer; + GString* mpURI; + +private: + + ::avmedia::gst::Window* mpPlayerWindow; + gint mnIsVideoSource; + gint mnVideoWidth; + gint mnVideoHeight; + gint mnInitialized; + gint mnVolumeDB; + gint mnLooping; + gint mnQuit; + gint mnVideoWindowSet; + gint mnInitFail; +}; +} // namespace gst +} // namespace avmedia + +#endif // _GSTPLAYER_HXX diff --git a/avmedia/source/gstreamer/gstuno.cxx b/avmedia/source/gstreamer/gstuno.cxx new file mode 100644 index 000000000000..adcda63fcd9c --- /dev/null +++ b/avmedia/source/gstreamer/gstuno.cxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * 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 "gstcommon.hxx" +#include "gstmanager.hxx" + +using namespace ::com::sun::star; + +// ------------------- +// - factory methods - +// ------------------- + +static uno::Reference< uno::XInterface > SAL_CALL create_MediaPlayer( const uno::Reference< lang::XMultiServiceFactory >& rxFact ) +{ + return uno::Reference< uno::XInterface >( *new ::avmedia::gst::Manager( rxFact ) ); +} + +// ------------------------------------------ +// - component_getImplementationEnvironment - +// ------------------------------------------ + +extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +// ----------------------- +// - component_writeInfo - +// ----------------------- + +extern "C" sal_Bool SAL_CALL component_writeInfo( void* /* pServiceManager */, void* pRegistryKey ) +{ + sal_Bool bRet = sal_False; + + if( pRegistryKey ) + { + try + { + uno::Reference< registry::XRegistryKey > xNewKey1( + static_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( + ::rtl::OUString::createFromAscii( + "/" AVMEDIA_GSTREAMER_MANAGER_IMPLEMENTATIONNAME "/UNO/SERVICES/" + AVMEDIA_GSTREAMER_MANAGER_SERVICENAME ) ) ); + + bRet = sal_True; + } + catch( registry::InvalidRegistryException& ) + { + OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + } + } + + return bRet; +} + +// ------------------------ +// - component_getFactory - +// ------------------------ + +extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ ) +{ + uno::Reference< lang::XSingleServiceFactory > xFactory; + void* pRet = 0; + + if( rtl_str_compare( pImplName, AVMEDIA_GSTREAMER_MANAGER_IMPLEMENTATIONNAME ) == 0 ) + { + const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( AVMEDIA_GSTREAMER_MANAGER_SERVICENAME ) ); + + xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory( + reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ), + ::rtl::OUString::createFromAscii( AVMEDIA_GSTREAMER_MANAGER_IMPLEMENTATIONNAME ), + create_MediaPlayer, uno::Sequence< ::rtl::OUString >( &aServiceName, 1 ) ) ); + } + + if( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + + return pRet; +} diff --git a/avmedia/source/gstreamer/gstwindow.cxx b/avmedia/source/gstreamer/gstwindow.cxx new file mode 100644 index 000000000000..12606ad5e88b --- /dev/null +++ b/avmedia/source/gstreamer/gstwindow.cxx @@ -0,0 +1,668 @@ +/************************************************************************* + * + * 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 <tools/prex.h> +#include <tools/postx.h> + +#include <com/sun/star/awt/SystemPointer.hdl> + +#include "gstwindow.hxx" +#include "gstplayer.hxx" +#include <vcl/syschild.hxx> +#include <vcl/sysdata.hxx> + +using namespace ::com::sun::star; + +namespace avmedia +{ +namespace gst +{ +// --------------------- +// - PlayerChildWindow - +// --------------------- + +class PlayerChildWindow : public SystemChildWindow +{ +public: + + PlayerChildWindow( Window* pParent ); + ~PlayerChildWindow(); + +protected: + + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void Command( const CommandEvent& rCEvt ); +}; + +// --------------------------------------------------------------------- + +PlayerChildWindow::PlayerChildWindow( Window* pParent ) : + SystemChildWindow( pParent, WB_CLIPCHILDREN ) +{ +} + +// --------------------------------------------------------------------- + +PlayerChildWindow::~PlayerChildWindow() +{ +} + +// --------------------------------------------------------------------- + +void PlayerChildWindow::MouseMove( const MouseEvent& rMEvt ) +{ + const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), + rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); + + SystemChildWindow::MouseMove( rMEvt ); + GetParent()->MouseMove( aTransformedEvent ); +} + +// --------------------------------------------------------------------- + +void PlayerChildWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), + rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); + + SystemChildWindow::MouseButtonDown( rMEvt ); + GetParent()->MouseButtonDown( aTransformedEvent ); +} + +// --------------------------------------------------------------------- + +void PlayerChildWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), + rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); + + SystemChildWindow::MouseButtonUp( rMEvt ); + GetParent()->MouseButtonUp( aTransformedEvent ); +} + +// --------------------------------------------------------------------- + +void PlayerChildWindow::KeyInput( const KeyEvent& rKEvt ) +{ + SystemChildWindow::KeyInput( rKEvt ); + GetParent()->KeyInput( rKEvt ); +} + +// --------------------------------------------------------------------- + +void PlayerChildWindow::KeyUp( const KeyEvent& rKEvt ) +{ + SystemChildWindow::KeyUp( rKEvt ); + GetParent()->KeyUp( rKEvt ); +} + +// --------------------------------------------------------------------- + +void PlayerChildWindow::Command( const CommandEvent& rCEvt ) +{ + const CommandEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ), + rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() ); + + SystemChildWindow::Command( rCEvt ); + GetParent()->Command( aTransformedEvent ); +} + +// --------------- +// - Window - +// --------------- +Window::Window( ::avmedia::gst::Player& rPlayer ) : + maListeners( maMutex ), + maWindowRect( 0, 0, 0, 0 ), + mrPlayer( rPlayer ), + mpPlayerWindow( NULL ), + meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ), + mnPointerType( awt::SystemPointer::ARROW ) +{} + +// ------------------------------------------------------------------------------ + +Window::~Window() +{ + dispose(); +} + +// ------------------------------------------------------------------------------ + +void Window::implLayoutVideoWindow() +{ + if( mpPlayerWindow && ( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel ) ) + { + awt::Size aPrefSize( mrPlayer.getPreferredPlayerWindowSize() ); + awt::Rectangle aRect = getPosSize(); + int nW = aRect.Width, nH = aRect.Height; + int nVideoW = nW, nVideoH = nH; + int nX = 0, nY = 0, nWidth = 0, nHeight = 0; + bool bDone = false, bZoom = false; + + if( media::ZoomLevel_ORIGINAL == meZoomLevel ) + { + bZoom = true; + } + else if( media::ZoomLevel_ZOOM_1_TO_4 == meZoomLevel ) + { + aPrefSize.Width >>= 2; + aPrefSize.Height >>= 2; + bZoom = true; + } + else if( media::ZoomLevel_ZOOM_1_TO_2 == meZoomLevel ) + { + aPrefSize.Width >>= 1; + aPrefSize.Height >>= 1; + bZoom = true; + } + else if( media::ZoomLevel_ZOOM_2_TO_1 == meZoomLevel ) + { + aPrefSize.Width <<= 1; + aPrefSize.Height <<= 1; + bZoom = true; + } + else if( media::ZoomLevel_ZOOM_4_TO_1 == meZoomLevel ) + { + aPrefSize.Width <<= 2; + aPrefSize.Height <<= 2; + bZoom = true; + } + else if( media::ZoomLevel_FIT_TO_WINDOW == meZoomLevel ) + { + nWidth = nVideoW; + nHeight = nVideoH; + bDone = true; + } + + if( bZoom ) + { + if( ( aPrefSize.Width <= nVideoW ) && ( aPrefSize.Height <= nVideoH ) ) + { + nX = ( nVideoW - aPrefSize.Width ) >> 1; + nY = ( nVideoH - aPrefSize.Height ) >> 1; + nWidth = aPrefSize.Width; + nHeight = aPrefSize.Height; + bDone = true; + } + } + + if( !bDone ) + { + if( ( aPrefSize.Width > 0 ) && ( aPrefSize.Height > 0 ) && ( nVideoW > 0 ) && ( nVideoH > 0 ) ) + { + double fPrefWH = (double) aPrefSize.Width / aPrefSize.Height; + + if( fPrefWH < ( (double) nVideoW / nVideoH ) ) + { + nVideoW = (int) ( nVideoH * fPrefWH ); + } + else + { + nVideoH = (int) ( nVideoW / fPrefWH ); + } + + nX = ( nW - nVideoW ) >> 1; + nY = ( nH - nVideoH ) >> 1; + nWidth = nVideoW; + nHeight = nVideoH; + } + else + { + nX = nY = nWidth = nHeight = 0; + } + } + + mpPlayerWindow->SetPosSizePixel( Point( nX, nY ), Size( nWidth, nHeight ) ); + } +} + +// ------------------------------------------------------------------------------ + +bool Window::create( const uno::Sequence< uno::Any >& rArguments ) +{ + OSL_ASSERT( !mpPlayerWindow ); + OSL_ENSURE( rArguments.getLength() > 2, +"::avmedia::gst::Windiow::create: GStreamer backend needs \ +valid parent SystemChildWindow pointer (sal_IntPtr) as third Any \ +value in sequence of arguments" ); + + bool bRet = false; + + if( !mpPlayerWindow && ( rArguments.getLength() > 2 ) ) + { + SystemChildWindow* pParentWindow = NULL; + sal_IntPtr pIntPtr = 0; + + // we are not interested in the first argument, which is a pure X11 window handle; + // this backend relies on a SystemChildWindow as parent for the PlayerWindow, given + // as third Sal_IntPtr value within the argument Sequence + rArguments[ 1 ] >>= maWindowRect; + + rArguments[ 2 ] >>= pIntPtr; + pParentWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr ); + + if( pParentWindow ) + { + meZoomLevel = media::ZoomLevel_ORIGINAL; + + mpPlayerWindow = new PlayerChildWindow( pParentWindow ); + mpPlayerWindow->SetBackground( Color( COL_BLACK ) ); + mpPlayerWindow->SetPosSizePixel( Point( maWindowRect.X, maWindowRect.Y ), + Size( maWindowRect.Width, maWindowRect.Height ) ); + mpPlayerWindow->Show(); + + bRet = true; + } + } + + return( bRet ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::update() + throw( uno::RuntimeException ) +{ + if( mpPlayerWindow ) + { + mpPlayerWindow->Invalidate( INVALIDATE_UPDATE ); + mpPlayerWindow->Sync(); + } +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel eZoomLevel ) + throw(uno::RuntimeException) +{ + bool bRet = false; + + if( ( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel ) && + ( media::ZoomLevel_NOT_AVAILABLE != eZoomLevel ) ) + { + if( eZoomLevel != meZoomLevel ) + { + meZoomLevel = eZoomLevel; + implLayoutVideoWindow(); + } + + bRet = true; + } + + return( bRet ); +} + +// ------------------------------------------------------------------------------ + +media::ZoomLevel SAL_CALL Window::getZoomLevel() + throw( uno::RuntimeException ) +{ + return( meZoomLevel ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setPointerType( sal_Int32 nPointerType ) + throw( uno::RuntimeException ) +{ + if( mpPlayerWindow ) + { + Pointer ePointer = POINTER_ARROW; + + switch( nPointerType ) + { + case (awt::SystemPointer::CROSS) : + { + ePointer = POINTER_CROSS; + } + break; + + case (awt::SystemPointer::HAND) : + { + ePointer = POINTER_HAND; + } + break; + + case (awt::SystemPointer::MOVE) : + { + ePointer = POINTER_MOVE; + } + break; + + case (awt::SystemPointer::WAIT) : + { + ePointer = POINTER_WAIT; + } + break; + + default: + break; + } + + mpPlayerWindow->SetPointer( ePointer ); + } +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setPosSize( sal_Int32 nX, + sal_Int32 nY, + sal_Int32 nWidth, + sal_Int32 nHeight, + sal_Int16 /* Flags */ ) + throw( uno::RuntimeException ) +{ + maWindowRect.X = nX; + maWindowRect.Y = nY; + maWindowRect.Width = nWidth; + maWindowRect.Height = nHeight; + + implLayoutVideoWindow(); +} + +// ------------------------------------------------------------------------------ + +awt::Rectangle SAL_CALL Window::getPosSize() + throw( uno::RuntimeException ) +{ + return( maWindowRect ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setVisible( sal_Bool bVisible ) + throw( uno::RuntimeException ) +{ + if( mpPlayerWindow ) + { + bVisible ? mpPlayerWindow->Show() : mpPlayerWindow->Hide(); + } +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setEnable( sal_Bool bEnable ) + throw( uno::RuntimeException ) +{ + if( mpPlayerWindow ) + { + mpPlayerWindow->Enable( bEnable ); + } +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setFocus() + throw( uno::RuntimeException ) +{ + if( mpPlayerWindow ) + { + mpPlayerWindow->GrabFocus(); + } +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::dispose() + throw( uno::RuntimeException ) +{ + delete mpPlayerWindow; + mpPlayerWindow = NULL; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) + throw( uno::RuntimeException ) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeEventListener( const uno::Reference< lang::XEventListener >& + xListener ) + throw( uno::RuntimeException ) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void Window::fireMousePressedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = + maListeners.getContainer( getCppuType( ( uno::Reference< awt::XMouseListener >* ) 0 ) ); + + if( pContainer ) + { + ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); + + while( aIter.hasMoreElements() ) + { + uno::Reference< awt::XMouseListener >( aIter.next(), + uno::UNO_QUERY )->mousePressed( rEvt ); + } + } +} + +// ----------------------------------------------------------------------------- + +void Window::fireMouseReleasedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = + maListeners.getContainer( getCppuType( ( uno::Reference< awt::XMouseListener >* ) 0 ) ); + + if( pContainer ) + { + ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); + + while( aIter.hasMoreElements() ) + { + uno::Reference< awt::XMouseListener >( aIter.next(), + uno::UNO_QUERY )->mouseReleased( rEvt ); + } + } +} + +// ----------------------------------------------------------------------------- + +void Window::fireMouseMovedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = + maListeners.getContainer( getCppuType( ( uno::Reference< awt::XMouseMotionListener >* ) + 0 ) ); + + if( pContainer ) + { + ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); + + while( aIter.hasMoreElements() ) + { + uno::Reference< awt::XMouseMotionListener >( aIter.next(), + uno::UNO_QUERY )->mouseMoved( rEvt ); + } + } +} + +// ----------------------------------------------------------------------------- + +void Window::fireSetFocusEvent( const ::com::sun::star::awt::FocusEvent& rEvt ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = + maListeners.getContainer( getCppuType( ( uno::Reference< awt::XFocusListener >* ) 0 ) ); + + if( pContainer ) + { + ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); + + while( aIter.hasMoreElements() ) + { + uno::Reference< awt::XFocusListener >( aIter.next(), + uno::UNO_QUERY )->focusGained( rEvt ); + } + } +} + +// ------------------------------------------------------------------------------ + +long Window::getXWindowHandle() const +{ + return( mpPlayerWindow ? mpPlayerWindow->GetSystemData()->aWindow : 0 ); +} + + +// ------------------------------------------------------------------------------ + +::rtl::OUString SAL_CALL Window::getImplementationName() + throw( uno::RuntimeException ) +{ + return( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + AVMEDIA_GSTREAMER_WINDOW_IMPLEMENTATIONNAME ) ) ); +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName ) + throw( uno::RuntimeException ) +{ + return( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( + AVMEDIA_GSTREAMER_WINDOW_SERVICENAME ) ) ); +} + +// ------------------------------------------------------------------------------ + +uno::Sequence< ::rtl::OUString > SAL_CALL Window::getSupportedServiceNames() + throw( uno::RuntimeException ) +{ + uno::Sequence< ::rtl::OUString > aRet( 1 ); + aRet[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GSTREAMER_WINDOW_SERVICENAME ) ); + + return( aRet ); +} +} // namespace gst +} // namespace avmedia diff --git a/avmedia/source/gstreamer/gstwindow.hxx b/avmedia/source/gstreamer/gstwindow.hxx new file mode 100644 index 000000000000..3a55fca9c8bf --- /dev/null +++ b/avmedia/source/gstreamer/gstwindow.hxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * 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 _GSTWINDOW_HXX +#define _GSTWINDOW_HXX + +#include "gstcommon.hxx" +#include <cppuhelper/interfacecontainer.h> + +#ifndef _COM_SUN_STAR_MEDIA_XPLAYERWINDOW_HDL_ +#include "com/sun/star/media/XPlayerWindow.hdl" +#endif + +namespace avmedia +{ +namespace gst +{ + +class PlayerChildWindow; + +// --------------- +// - Window - +// --------------- + +class Player; + +class Window : public ::cppu::WeakImplHelper2< ::com::sun::star::media::XPlayerWindow, + ::com::sun::star::lang::XServiceInfo > +{ + friend class Player; + +public: Window( ::avmedia::gst::Player& rPlayer ); + ~Window(); + + bool create( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ); + + // XPlayerWindow + virtual void SAL_CALL update() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL setZoomLevel( ::com::sun::star::media::ZoomLevel ZoomLevel ) + throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::media::ZoomLevel SAL_CALL getZoomLevel() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setPointerType( sal_Int32 nPointerType ) + throw( ::com::sun::star::uno::RuntimeException ); + + // XWindow + virtual void SAL_CALL setPosSize( sal_Int32 X, + sal_Int32 Y, + sal_Int32 Width, + sal_Int32 Height, + sal_Int16 Flags ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setVisible( sal_Bool Visible ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setEnable( sal_Bool Enable ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setFocus() + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL addWindowListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL removeWindowListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL addFocusListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL removeFocusListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL addKeyListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL removeKeyListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL addMouseListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL removeMouseListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL addMouseMotionListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL removeMouseMotionListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL addPaintListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL removePaintListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) + 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 ); + + 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 ); + + +public: + + void fireMousePressedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ); + + void fireMouseReleasedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ); + + void fireMouseMovedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ); + + void fireKeyPressedEvent( const ::com::sun::star::awt::KeyEvent& rEvt ); + + void fireKeyReleasedEvent( const ::com::sun::star::awt::KeyEvent& rEvt ); + + void fireSetFocusEvent( const ::com::sun::star::awt::FocusEvent& rEvt ); + +protected: + + long getXWindowHandle() const; + +private: + + ::osl::Mutex maMutex; + ::cppu::OMultiTypeInterfaceContainerHelper maListeners; + ::com::sun::star::awt::Rectangle maWindowRect; + Player& mrPlayer; + PlayerChildWindow* mpPlayerWindow; + ::com::sun::star::media::ZoomLevel meZoomLevel; + sal_Int32 mnPointerType; + + void implLayoutVideoWindow(); +}; +} // namespace gst +} // namespace avmedia + +#endif // _GSTWINDOW_HXX diff --git a/avmedia/source/gstreamer/makefile.mk b/avmedia/source/gstreamer/makefile.mk new file mode 100644 index 000000000000..2f22c7333778 --- /dev/null +++ b/avmedia/source/gstreamer/makefile.mk @@ -0,0 +1,71 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=avmediagst +TARGET=avmediagst + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +.IF "$(verbose)"!="" || "$(VERBOSE)"!="" +CDEFS+= -DVERBOSE +.ENDIF + +# --- Files ---------------------------------- + +.IF "$(GUI)" == "UNX" && "$(GUIBASE)"!="aqua" && "$(ENABLE_GSTREAMER)" != "" + +PKGCONFIG_MODULES=gtk+-2.0 gstreamer-0.10 gstreamer-interfaces-0.10 +.INCLUDE : pkg_config.mk + +SLOFILES= \ + $(SLO)$/gstuno.obj \ + $(SLO)$/gstmanager.obj \ + $(SLO)$/gstwindow.obj \ + $(SLO)$/gstplayer.obj \ + $(SLO)$/gstframegrabber.obj + +EXCEPTIONSFILES= \ + $(SLO)$/gstuno.obj \ + $(SLO)$/gstplayer.obj \ + $(SLO)$/gstframegrabber.obj + +SHL1TARGET=$(TARGET) +SHL1STDLIBS= $(CPPULIB) $(SALLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(TOOLSLIB) $(VCLLIB) +SHL1STDLIBS+=$(PKGCONFIG_LIBS) +SHL1IMPLIB=i$(TARGET) +SHL1LIBS=$(SLB)$/$(TARGET).lib +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE=exports.dxp + +.ENDIF + +.INCLUDE : target.mk diff --git a/avmedia/source/inc/mediamisc.hxx b/avmedia/source/inc/mediamisc.hxx index fd89e9d4abde..f33bd46568c8 100644 --- a/avmedia/source/inc/mediamisc.hxx +++ b/avmedia/source/inc/mediamisc.hxx @@ -30,12 +30,30 @@ class ResMgr; #define AVMEDIA_RESID( nId ) ResId( nId, * ::avmedia::GetResMgr() ) #ifdef WNT -#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.media.Manager_DirectX" + +#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.comp.avmedia.Manager_DirectX" +#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED sal_False + +#define AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1 "" +#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1 sal_False + #else #ifdef QUARTZ -#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.comp.avmedia.Manager_QuickTime" + +#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.comp.avmedia.Manager_QuickTime" +#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED sal_False + +#define AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1 "" +#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1 sal_False + #else -#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.media.Manager_Java" + +#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.comp.avmedia.Manager_GStreamer" +#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED sal_False + +#define AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1 "com.sun.star.comp.avmedia.Manager_Java" +#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1 sal_True + #endif #endif diff --git a/avmedia/source/java/PlayerWindow.java b/avmedia/source/java/PlayerWindow.java index 229c651d9f54..2229e4f1644b 100644 --- a/avmedia/source/java/PlayerWindow.java +++ b/avmedia/source/java/PlayerWindow.java @@ -67,9 +67,7 @@ public class PlayerWindow implements java.awt.event.KeyListener, maFrame = new WindowAdapter( AnyConverter.toInt( aArgs[ 0 ] ) ); maFrame.setPosSize( aBoundRect.X, aBoundRect.Y, aBoundRect.Width, aBoundRect.Height, (short) 0 ); - - if( aArgs.length > 2 ) - mbShowControls = AnyConverter.toBoolean( aArgs[ 2 ] ); + mbShowControls = false; java.awt.Panel aPanel = new java.awt.Panel( new java.awt.BorderLayout() ); diff --git a/avmedia/source/java/avmedia.jar b/avmedia/source/java/avmedia.jar Binary files differindex 55576baa5b34..85a98bbcf33c 100644 --- a/avmedia/source/java/avmedia.jar +++ b/avmedia/source/java/avmedia.jar diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx index b2d1e5162cb5..5005446633f4 100644 --- a/avmedia/source/viewer/mediawindow.cxx +++ b/avmedia/source/viewer/mediawindow.cxx @@ -162,7 +162,9 @@ Size MediaWindow::getPreferredSize() const void MediaWindow::setPosSize( const Rectangle& rNewRect ) { if( mpImpl ) + { mpImpl->setPosSize( rNewRect ); + } } // ------------------------------------------------------------------------- @@ -368,6 +370,7 @@ void MediaWindow::getMediaFilters( FilterNameVector& rFilterNameVector ) "AU Audio", "au", "AVI", "avi", "CD Audio", "cda", + "Matroska Media", "mkv", "MIDI Audio", "mid;midi", "MPEG Audio", "mp2;mp3;mpa", "MPEG Video", "mpg;mpeg;mpv;mp4", @@ -464,39 +467,28 @@ bool MediaWindow::isMediaURL( const ::rtl::OUString& rURL, bool bDeep, Size* pPr { if( bDeep || pPreferredSizePixel ) { - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - - if( xFactory.is() ) + try { - try - { - fprintf(stderr, "-->%s uno reference \n\n",AVMEDIA_MANAGER_SERVICE_NAME); + sal_Bool bIsJavaBasedMediaWindow; + uno::Reference< media::XPlayer > xPlayer( priv::MediaWindowImpl::createPlayer( + aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), + bIsJavaBasedMediaWindow ) ); - uno::Reference< ::com::sun::star::media::XManager > xManager( - xFactory->createInstance( ::rtl::OUString::createFromAscii( AVMEDIA_MANAGER_SERVICE_NAME ) ), - uno::UNO_QUERY ); + if( xPlayer.is() ) + { + bRet = true; - if( xManager.is() ) + if( pPreferredSizePixel ) { - uno::Reference< media::XPlayer > xPlayer( xManager->createPlayer( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) ); - - if( xPlayer.is() ) - { - bRet = true; + const awt::Size aAwtSize( xPlayer->getPreferredPlayerWindowSize() ); - if( pPreferredSizePixel ) - { - const awt::Size aAwtSize( xPlayer->getPreferredPlayerWindowSize() ); - - pPreferredSizePixel->Width() = aAwtSize.Width; - pPreferredSizePixel->Height() = aAwtSize.Height; - } - } + pPreferredSizePixel->Width() = aAwtSize.Width; + pPreferredSizePixel->Height() = aAwtSize.Height; } } - catch( ... ) - { - } + } + catch( ... ) + { } } else @@ -525,7 +517,8 @@ bool MediaWindow::isMediaURL( const ::rtl::OUString& rURL, bool bDeep, Size* pPr uno::Reference< media::XPlayer > MediaWindow::createPlayer( const ::rtl::OUString& rURL ) { - return priv::MediaWindowImpl::createPlayer( rURL ); + sal_Bool bJavaBased = sal_False; + return priv::MediaWindowImpl::createPlayer( rURL, bJavaBased ); } // ------------------------------------------------------------------------- diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index 553eea6196c1..15c830cb97a6 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -1,4 +1,4 @@ -/************************************************************************* +/************************************************************************ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -94,7 +94,7 @@ void MediaWindowControl::execute( const MediaItem& rItem ) // -------------------- MediaChildWindow::MediaChildWindow( Window* pParent ) : - JavaChildWindow( pParent, WB_CLIPCHILDREN ) + SystemChildWindow( pParent, WB_CLIPCHILDREN ) { } @@ -111,7 +111,7 @@ void MediaChildWindow::MouseMove( const MouseEvent& rMEvt ) const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); - JavaChildWindow::MouseMove( rMEvt ); + SystemChildWindow::MouseMove( rMEvt ); GetParent()->MouseMove( aTransformedEvent ); } @@ -122,7 +122,7 @@ void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt ) const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); - JavaChildWindow::MouseButtonDown( rMEvt ); + SystemChildWindow::MouseButtonDown( rMEvt ); GetParent()->MouseButtonDown( aTransformedEvent ); } @@ -133,7 +133,7 @@ void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt ) const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); - JavaChildWindow::MouseButtonUp( rMEvt ); + SystemChildWindow::MouseButtonUp( rMEvt ); GetParent()->MouseButtonUp( aTransformedEvent ); } @@ -141,7 +141,7 @@ void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt ) void MediaChildWindow::KeyInput( const KeyEvent& rKEvt ) { - JavaChildWindow::KeyInput( rKEvt ); + SystemChildWindow::KeyInput( rKEvt ); GetParent()->KeyInput( rKEvt ); } @@ -149,7 +149,7 @@ void MediaChildWindow::KeyInput( const KeyEvent& rKEvt ) void MediaChildWindow::KeyUp( const KeyEvent& rKEvt ) { - JavaChildWindow::KeyUp( rKEvt ); + SystemChildWindow::KeyUp( rKEvt ); GetParent()->KeyUp( rKEvt ); } @@ -160,7 +160,7 @@ void MediaChildWindow::Command( const CommandEvent& rCEvt ) const CommandEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ), rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() ); - JavaChildWindow::Command( rCEvt ); + SystemChildWindow::Command( rCEvt ); GetParent()->Command( aTransformedEvent ); } @@ -179,6 +179,7 @@ MediaWindowImpl::MediaWindowImpl( Window* pParent, MediaWindow* pMediaWindow, bo mpEmptyBmpEx( NULL ), mpAudioBmpEx( NULL ) { + maChildWindow.SetBackground( Color( COL_BLACK ) ); maChildWindow.SetHelpId( HID_AVMEDIA_PLAYERWINDOW ); maChildWindow.Hide(); @@ -229,19 +230,24 @@ void MediaWindowImpl::onURLChanged() { if( getPlayer().is() ) { - uno::Sequence< uno::Any > aArgs( 2 ); uno::Reference< media::XPlayerWindow > xPlayerWindow; - const Point aPoint; - const Size aSize( maChildWindow.GetSizePixel() ); - const sal_IntPtr nWndHandle = static_cast< sal_IntPtr >( maChildWindow.getParentWindowHandleForJava() ); - aArgs[ 0 ] = uno::makeAny( nWndHandle ); - aArgs[ 1 ] = uno::makeAny( awt::Rectangle( aPoint.X(), aPoint.Y(), aSize.Width(), aSize.Height() ) ); + const Point aPoint; + const Size aSize( maChildWindow.GetSizePixel() ); + const sal_IntPtr nWndHandle = (sal_IntPtr) maChildWindow.GetParentWindowHandle( isMediaWindowJavaBased() ); try { if( nWndHandle != 0 ) + { + uno::Sequence< uno::Any > aArgs( 3 ); + + aArgs[ 0 ] = uno::makeAny( nWndHandle ); + aArgs[ 1 ] = uno::makeAny( awt::Rectangle( aPoint.X(), aPoint.Y(), aSize.Width(), aSize.Height() ) ); + aArgs[ 2 ] = uno::makeAny( reinterpret_cast< sal_IntPtr >( &maChildWindow ) ); + xPlayerWindow = getPlayer()->createPlayerWindow( aArgs ); + } } catch( uno::RuntimeException ) { @@ -273,8 +279,6 @@ void MediaWindowImpl::onURLChanged() updateMediaItem( aItem ); mpMediaWindowControl->setState( aItem ); } - - Invalidate(); } // --------------------------------------------------------------------- @@ -291,7 +295,7 @@ void MediaWindowImpl::update() void MediaWindowImpl::setPosSize( const Rectangle& rRect ) { - SetPosSizePixel( rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight() ); + SetPosSizePixel( rRect.TopLeft(), rRect.GetSize() ); } // --------------------------------------------------------------------- @@ -305,7 +309,6 @@ void MediaWindowImpl::setPointer( const Pointer& rPointer ) if( xPlayerWindow.is() ) { - long nPointer; switch( rPointer.GetStyle() ) @@ -355,10 +358,10 @@ void MediaWindowImpl::Resize() mpMediaWindowControl->SetPosSizePixel( Point( nOffset, nControlY ), Size( aCurSize.Width() - ( nOffset << 1 ), nControlHeight ) ); } - maChildWindow.SetPosSizePixel( Point( nOffset, nOffset ), aPlayerWindowSize ); - if( xPlayerWindow.is() ) xPlayerWindow->setPosSize( 0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0 ); + + maChildWindow.SetPosSizePixel( Point( nOffset, nOffset ), aPlayerWindowSize ); } // --------------------------------------------------------------------- @@ -405,7 +408,7 @@ void MediaWindowImpl::Paint( const Rectangle& ) pLogo = mpEmptyBmpEx; } - else if ( !getPlayerWindow().is() ) + else if( !getPlayerWindow().is() ) { if( !mpAudioBmpEx ) mpAudioBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_AUDIOLOGO ) ); @@ -446,8 +449,6 @@ void MediaWindowImpl::Paint( const Rectangle& ) aBasePos.Y() + ( ( aVideoRect.GetHeight() - aLogoSize.Height() ) >> 1 ) ), aLogoSize, *pLogo ); } - - update(); } // --------------------------------------------------------------------- diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx index 679b864af6b7..9008e499647d 100644 --- a/avmedia/source/viewer/mediawindow_impl.hxx +++ b/avmedia/source/viewer/mediawindow_impl.hxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: mediawindow_impl.hxx,v $ + * $Revision: 1.3 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -29,7 +32,7 @@ #define _AVMEDIA_MEDIAWINDOW_IMPL_HXX #include <svtools/transfer.hxx> -#include <vcl/javachild.hxx> +#include <vcl/syschild.hxx> #include "mediawindowbase_impl.hxx" #include "mediacontrol.hxx" @@ -61,7 +64,7 @@ namespace avmedia // - MediaChildWindow - // -------------------- - class MediaChildWindow : public JavaChildWindow + class MediaChildWindow : public SystemChildWindow { public: diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx index ea28121e3609..94a6c36ed064 100644 --- a/avmedia/source/viewer/mediawindowbase_impl.cxx +++ b/avmedia/source/viewer/mediawindowbase_impl.cxx @@ -47,8 +47,18 @@ namespace avmedia { namespace priv { // - MediaWindowBaseImpl - // ----------------------- +struct ServiceManager +{ + const char* pServiceName; + sal_Bool bIsJavaBased; +}; + +// --------------------------------------------------------------------- + + MediaWindowBaseImpl::MediaWindowBaseImpl( MediaWindow* pMediaWindow ) : - mpMediaWindow( pMediaWindow ) + mpMediaWindow( pMediaWindow ), + mbIsMediaWindowJavaBased( sal_False ) { } @@ -61,35 +71,53 @@ MediaWindowBaseImpl::~MediaWindowBaseImpl() // ------------------------------------------------------------------------- -uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl::OUString& rURL ) +uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl::OUString& rURL, sal_Bool& rbJavaBased ) { uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); uno::Reference< media::XPlayer > xPlayer; + rbJavaBased = sal_False; + if( xFactory.is() ) { - try + static const ServiceManager aServiceManagers[] = + { + { AVMEDIA_MANAGER_SERVICE_NAME, AVMEDIA_MANAGER_SERVICE_IS_JAVABASED }, + { AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1, AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1 } + }; + + for( sal_uInt32 i = 0; !xPlayer.is() && ( i < ( sizeof( aServiceManagers ) / sizeof( ServiceManager ) ) ); ++i ) { + const String aServiceName( aServiceManagers[ i ].pServiceName, RTL_TEXTENCODING_ASCII_US ); + + if( aServiceName.Len() ) + { + OSL_TRACE( "Trying to create media manager service %s", aServiceManagers[ i ].pServiceName ); - uno::Reference< ::com::sun::star::media::XManager > xManager( - xFactory->createInstance( ::rtl::OUString::createFromAscii( AVMEDIA_MANAGER_SERVICE_NAME ) ), - uno::UNO_QUERY ); + try + { + uno::Reference< media::XManager > xManager( xFactory->createInstance( aServiceName ), uno::UNO_QUERY ); + + if( xManager.is() ) + { + xPlayer = uno::Reference< media::XPlayer >( xManager->createPlayer( rURL ), uno::UNO_QUERY ); + } + } + catch( ... ) + { + } + } - if( xManager.is() ) + if( xPlayer.is() ) { - xPlayer = uno::Reference< ::com::sun::star::media::XPlayer >( - xManager->createPlayer( rURL ), uno::UNO_QUERY ); + rbJavaBased = aServiceManagers[ i ].bIsJavaBased; } } - catch( ... ) - { - } } return xPlayer; } - // --------------------------------------------------------------------- void MediaWindowBaseImpl::setURL( const ::rtl::OUString& rURL ) @@ -112,7 +140,7 @@ void MediaWindowBaseImpl::setURL( const ::rtl::OUString& rURL ) if( aURL.GetProtocol() != INET_PROT_NOT_VALID ) maFileURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ); - mxPlayer = createPlayer( maFileURL ); + mxPlayer = createPlayer( maFileURL, mbIsMediaWindowJavaBased ); onURLChanged(); } } @@ -143,10 +171,7 @@ void MediaWindowBaseImpl::stopPlayingInternal( bool bStop ) { if( isPlaying() ) { - if( bStop ) - mxPlayer->stop(); - else - mxPlayer->start(); + bStop ? mxPlayer->stop() : mxPlayer->start(); } } diff --git a/avmedia/source/viewer/mediawindowbase_impl.hxx b/avmedia/source/viewer/mediawindowbase_impl.hxx index 0b0f160b6e3c..028b7c6ed079 100644 --- a/avmedia/source/viewer/mediawindowbase_impl.hxx +++ b/avmedia/source/viewer/mediawindowbase_impl.hxx @@ -61,7 +61,8 @@ namespace avmedia virtual void cleanUp(); virtual void onURLChanged(); - static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL ); + static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL, + sal_Bool& rbJavaBased ); public: @@ -112,6 +113,7 @@ namespace avmedia void stopPlayingInternal( bool ); MediaWindow* getMediaWindow() const; + inline sal_Bool isMediaWindowJavaBased() const { return( mbIsMediaWindowJavaBased ); } ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > getPlayer() const; @@ -124,6 +126,7 @@ namespace avmedia ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer; ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow; MediaWindow* mpMediaWindow; + sal_Bool mbIsMediaWindowJavaBased; }; } } diff --git a/avmedia/source/win/winuno.cxx b/avmedia/source/win/winuno.cxx index 4b06fd10727f..645871290413 100644 --- a/avmedia/source/win/winuno.cxx +++ b/avmedia/source/win/winuno.cxx @@ -62,7 +62,7 @@ extern "C" sal_Bool SAL_CALL component_writeInfo( void*, void* pRegistryKey ) { uno::Reference< registry::XRegistryKey > xNewKey1( static_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( - ::rtl::OUString::createFromAscii( "/com.sun.star.comp.media.Manager_DirectX/UNO/SERVICES/com.sun.star.media.Manager_DirectX" ) ) ); + ::rtl::OUString::createFromAscii( "/com.sun.star.comp.avmedia.Manager_DirectX/UNO/SERVICES/com.sun.star.media.Manager_DirectX" ) ) ); bRet = sal_True; } @@ -84,13 +84,13 @@ extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* uno::Reference< lang::XSingleServiceFactory > xFactory; void* pRet = 0; - if( rtl_str_compare( pImplName, "com.sun.star.comp.media.Manager_DirectX" ) == 0 ) + if( rtl_str_compare( pImplName, "com.sun.star.comp.avmedia.Manager_DirectX" ) == 0 ) { const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( "com.sun.star.media.Manager_DirectX" ) ); xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ), - ::rtl::OUString::createFromAscii( "com.sun.star.comp.media.Manager_DirectX" ), + ::rtl::OUString::createFromAscii( "com.sun.star.comp.avmedia.Manager_DirectX" ), create_MediaPlayer, uno::Sequence< ::rtl::OUString >( &aServiceName, 1 ) ) ); } diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index cf888adf9dcf..bccf8212f10e 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -28,10 +28,12 @@ #ifndef _SB_SBMOD_HXX #define _SB_SBMOD_HXX +#include <com/sun/star/script/XInvocation.hpp> #include <basic/sbdef.hxx> #include <basic/sbxobj.hxx> #include <basic/sbxdef.hxx> #include <rtl/ustring.hxx> +#include <vector> class SbMethod; class SbProperty; @@ -55,8 +57,10 @@ class SbModule : public SbxObject friend class SbClassModuleObject; SbModuleImpl* mpSbModuleImpl; // Impl data + std::vector< String > mModuleVariableNames; protected: + com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper; ::rtl::OUString aOUSource; String aComment; SbiImage* pImage; // the Image @@ -131,6 +135,9 @@ public: INT32 GetModuleType() { return mnType; } void SetModuleType( INT32 nType ) { mnType = nType; } bool GetIsProxyModule() { return bIsProxyModule; } + void AddVarName( const String& aName ); + void RemoveVars(); + ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); }; diff --git a/basic/inc/basic/sbobjmod.hxx b/basic/inc/basic/sbobjmod.hxx index 3d638a475f9a..9ff46d1931f3 100644 --- a/basic/inc/basic/sbobjmod.hxx +++ b/basic/inc/basic/sbobjmod.hxx @@ -36,6 +36,7 @@ #ifndef _SB_OBJMOD_HXX #define _SB_OBJMOD_HXX +#include <rtl/ref.hxx> #include <basic/sbmod.hxx> #include <basic/sbstar.hxx> #include <com/sun/star/script/ModuleInfo.hpp> @@ -60,10 +61,12 @@ public: void SetUnoObject( const com::sun::star::uno::Any& aObj )throw ( com::sun::star::uno::RuntimeException ) ; }; +class FormObjEventListenerImpl; + class SbUserFormModule : public SbObjModule { com::sun::star::script::ModuleInfo m_mInfo; - css::uno::Reference<css::lang::XEventListener> m_DialogListener; + ::rtl::Reference< FormObjEventListenerImpl > m_DialogListener; css::uno::Reference<css::awt::XDialog> m_xDialog; css::uno::Reference<css::frame::XModel> m_xModel; String sFormName; @@ -76,16 +79,19 @@ class SbUserFormModule : public SbObjModule public: TYPEINFO(); SbUserFormModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat ); + virtual ~SbUserFormModule(); virtual SbxVariable* Find( const XubString& rName, SbxClassType t ); void ResetApiObj(); void Unload(); - void load(); + void Load(); void triggerMethod( const String& ); void triggerMethod( const String&, css::uno::Sequence< css::uno::Any >& ); void triggerActivateEvent(); - void triggerDeActivateEvent(); + void triggerDeactivateEvent(); void triggerInitializeEvent(); void triggerTerminateEvent(); + void triggerLayoutEvent(); + void triggerResizeEvent(); class SbUserFormModuleInstance* CreateInstance(); }; diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index b76a2b5e249e..84763468e64c 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -67,8 +67,8 @@ #include <com/sun/star/script/XStarBasicLibraryInfo.hpp> #include <com/sun/star/script/XLibraryContainerPassword.hpp> #include <com/sun/star/script/ModuleInfo.hpp> -#include <com/sun/star/script/XVBAModuleInfo.hpp> -#include <com/sun/star/script/XVBACompat.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> #include <cppuhelper/implbase1.hxx> @@ -240,7 +240,7 @@ void BasMgrContainerListenerImpl::addLibraryModulesImpl( BasicManager* pMgr, Any aElement = xLibNameAccess->getByName( aModuleName ); ::rtl::OUString aMod; aElement >>= aMod; - Reference< XVBAModuleInfo > xVBAModuleInfo( xLibNameAccess, UNO_QUERY ); + Reference< vba::XVBAModuleInfo > xVBAModuleInfo( xLibNameAccess, UNO_QUERY ); if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( aModuleName ) ) { ModuleInfo mInfo = xVBAModuleInfo->getModuleInfo( aModuleName ); @@ -285,9 +285,9 @@ void SAL_CALL BasMgrContainerListenerImpl::elementInserted( const ContainerEvent StarBASIC* pLib = mpMgr->GetLib( aName ); if ( pLib ) { - Reference<XVBACompat> xVBACompat( xScriptCont, UNO_QUERY ); + Reference< vba::XVBACompatibility > xVBACompat( xScriptCont, UNO_QUERY ); if ( xVBACompat.is() ) - pLib->SetVBAEnabled( xVBACompat->getVBACompatModeOn() ); + pLib->SetVBAEnabled( xVBACompat->getVBACompatibilityMode() ); } } else @@ -302,7 +302,7 @@ void SAL_CALL BasMgrContainerListenerImpl::elementInserted( const ContainerEvent { ::rtl::OUString aMod; Event.Element >>= aMod; - Reference< XVBAModuleInfo > xVBAModuleInfo( Event.Source, UNO_QUERY ); + Reference< vba::XVBAModuleInfo > xVBAModuleInfo( Event.Source, UNO_QUERY ); if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( aName ) ) { ModuleInfo mInfo = xVBAModuleInfo->getModuleInfo( aName ); diff --git a/basic/source/classes/disas.cxx b/basic/source/classes/disas.cxx index 7317005d74fe..a837a3dc4f24 100644 --- a/basic/source/classes/disas.cxx +++ b/basic/source/classes/disas.cxx @@ -35,6 +35,7 @@ #include "sb.hxx" #include "iosys.hxx" #include "disas.hxx" +#include "sbtrace.hxx" static const char* pOp1[] = { @@ -153,6 +154,7 @@ static const char* pOp3[] = { "DCREATE_REDIMP", // Change dimensions of a user defined Object-Array (+StringId+StringId) "FIND_CM", // Search inside a class module (CM) to enable global search in time "PUBLIC_P", // Module global Variable (persisted between calls)(+StringID+Typ) + "FIND_STATIC", // local static var lookup (+StringID+Typ) }; static const char** pOps[3] = { pOp1, pOp2, pOp3 }; @@ -220,6 +222,7 @@ static const Func pOperand3[] = { &SbiDisas::Str2Op, // Redimensionate User defined Object-Array (+StringId+StringId) &SbiDisas::VarOp, // FIND_CM &SbiDisas::VarDefOp, // PUBLIC_P + &SbiDisas::VarOp, // FIND_STATIC }; // TODO: Why as method? Isn't a simple define sufficient? @@ -359,6 +362,11 @@ BOOL SbiDisas::DisasLine( String& rText ) rText.Erase(); if( !Fetch() ) return FALSE; + +#ifdef DBG_TRACE_BASIC + String aTraceStr_STMNT; +#endif + // New line? if( eOp == _STMNT && nOp1 != nLine ) { @@ -391,8 +399,13 @@ BOOL SbiDisas::DisasLine( String& rText ) rText.AppendAscii( "; " ); rText += s; rText.AppendAscii( _crlf() ); + +#ifdef DBG_TRACE_BASIC + aTraceStr_STMNT = s; +#endif } } + // Label? const char* p = ""; if( cLabels[ nPC >> 3 ] & ( 1 << ( nPC & 7 ) ) ) @@ -430,20 +443,29 @@ BOOL SbiDisas::DisasLine( String& rText ) rText.AppendAscii( _crlf() ); } snprintf( cBuf, sizeof(cBuf), pMask[ nParts ], nPC, (USHORT) eOp, nOp1, nOp2 ); - rText.AppendAscii( cBuf ); + + String aPCodeStr; + aPCodeStr.AppendAscii( cBuf ); int n = eOp; if( eOp >= SbOP2_START ) n -= SbOP2_START; else if( eOp >= SbOP1_START ) n -= SbOP1_START; - rText += '\t'; - rText.AppendAscii( pOps[ nParts-1 ][ n ] ); - rText += '\t'; + aPCodeStr += '\t'; + aPCodeStr.AppendAscii( pOps[ nParts-1 ][ n ] ); + aPCodeStr += '\t'; switch( nParts ) { - case 2: (this->*( pOperand2[ n ] ) )( rText ); break; - case 3: (this->*( pOperand3[ n ] ) )( rText ); break; + case 2: (this->*( pOperand2[ n ] ) )( aPCodeStr ); break; + case 3: (this->*( pOperand3[ n ] ) )( aPCodeStr ); break; } + + rText += aPCodeStr; + +#ifdef DBG_TRACE_BASIC + dbg_RegisterTraceTextForPC( pMod, nPC, aTraceStr_STMNT, aPCodeStr ); +#endif + return TRUE; } diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 79c5f78601ea..e28b0a304f28 100755 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -339,27 +339,18 @@ SbxBase* SbFormFactory::Create( UINT16, UINT32 ) SbxObject* SbFormFactory::CreateObject( const String& rClassName ) { - static String aLoadMethodName( RTL_CONSTASCII_USTRINGPARAM("load") ); - - SbxObject* pRet = NULL; - SbModule* pMod = pMOD; - if( pMod ) + if( SbModule* pMod = pMOD ) { - SbxVariable* pVar = pMod->Find( rClassName, SbxCLASS_OBJECT ); - if( pVar ) + if( SbxVariable* pVar = pMod->Find( rClassName, SbxCLASS_OBJECT ) ) { - SbxBase* pObj = pVar->GetObject(); - SbUserFormModule* pFormModule = PTR_CAST( SbUserFormModule, pObj ); - - if( pFormModule != NULL ) + if( SbUserFormModule* pFormModule = PTR_CAST( SbUserFormModule, pVar->GetObject() ) ) { - pFormModule->load(); - SbUserFormModuleInstance* pFormInstance = pFormModule->CreateInstance(); - pRet = pFormInstance; + pFormModule->Load(); + return pFormModule->CreateInstance(); } } } - return pRet; + return 0; } @@ -569,11 +560,13 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) } } SetModuleType( ModuleType::CLASS ); + mbVBACompat = pClassModule->mbVBACompat; } SbClassModuleObject::~SbClassModuleObject() { - triggerTerminateEvent(); + if( StarBASIC::IsRunning() ) + triggerTerminateEvent(); // Must be deleted by base class dtor because this data // is not owned by the SbClassModuleObject object @@ -606,7 +599,28 @@ void SbClassModuleObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType { SbxValues aVals; aVals.eType = SbxVARIANT; - pMeth->Get( aVals ); + + SbxArray* pArg = pVar->GetParameters(); + USHORT nVarParCount = (pArg != NULL) ? pArg->Count() : 0; + if( nVarParCount > 1 ) + { + SbxArrayRef xMethParameters = new SbxArray; + xMethParameters->Put( pMeth, 0 ); // Method as parameter 0 + for( USHORT i = 1 ; i < nVarParCount ; ++i ) + { + SbxVariable* pPar = pArg->Get( i ); + xMethParameters->Put( pPar, i ); + } + + pMeth->SetParameters( xMethParameters ); + pMeth->Get( aVals ); + pMeth->SetParameters( NULL ); + } + else + { + pMeth->Get( aVals ); + } + pVar->Put( aVals ); } } diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 1b2b0048b34c..9ee07fde1413 100644..100755 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -911,7 +911,7 @@ Type getUnoTypeForSbxBaseType( SbxDataType eType ) case SbxVARIANT: aRetType = ::getCppuType( (Any*)0 ); break; //case SbxDATAOBJECT: break; case SbxCHAR: aRetType = ::getCppuType( (sal_Unicode*)0 ); break; - case SbxBYTE: aRetType = ::getCppuType( (sal_Int16*)0 ); break; + case SbxBYTE: aRetType = ::getCppuType( (sal_Int8*)0 ); break; case SbxUSHORT: aRetType = ::getCppuType( (sal_uInt16*)0 ); break; case SbxULONG: aRetType = ::getCppuType( (sal_uInt32*)0 ); break; //case SbxLONG64: break; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 1b49a376c9bd..8b1069bbeab3 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -45,6 +45,7 @@ #include "runtime.hxx" #include "token.hxx" #include "sbunoobj.hxx" +#include "sbtrace.hxx" //#include <basic/hilight.hxx> @@ -53,9 +54,10 @@ #include <basic/basrdll.hxx> #include <vos/mutex.hxx> #include <basic/sbobjmod.hxx> +#include <cppuhelper/implbase2.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/script/ModuleType.hpp> -#include <com/sun/star/script/XVBACompat.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <com/sun/star/beans/XPropertySet.hpp> using namespace com::sun::star; @@ -76,15 +78,362 @@ using namespace com::sun::star; #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/processfactory.hxx> #include <vcl/svapp.hxx> +#include <map> +#include <com/sun/star/reflection/XProxyFactory.hpp> +#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; +using namespace com::sun::star::script; + #include <com/sun/star/script/XLibraryContainer.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/awt/XDialogProvider.hpp> #include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/awt/XControl.hpp> #include <cppuhelper/implbase1.hxx> #include <comphelper/anytostring.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> + +typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE; +typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap; +::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar ); +void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue ); + +class DocObjectWrapper : public DocObjectWrapper_BASE +{ + Reference< XAggregation > m_xAggProxy; + Reference< XInvocation > m_xAggInv; + Reference< XTypeProvider > m_xAggregateTypeProv; + Sequence< Type > m_Types; + SbModule* m_pMod; + SbMethodRef getMethod( const rtl::OUString& aName ) throw (RuntimeException); + SbPropertyRef getProperty( const rtl::OUString& aName ) throw (RuntimeException); + String mName; // for debugging + +public: + DocObjectWrapper( SbModule* pMod ); + virtual ~DocObjectWrapper(); + + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (RuntimeException) + { + if( !m_xAggregateTypeProv.is() ) + throw RuntimeException(); + return m_xAggregateTypeProv->getImplementationId(); + } + + virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (RuntimeException); + + virtual Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const Sequence< Any >& aParams, Sequence< ::sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException); + virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException); + virtual Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (UnknownPropertyException, RuntimeException); + virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (RuntimeException); + virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (RuntimeException); + virtual Any SAL_CALL queryInterface( const Type& aType ) throw ( RuntimeException ); + + virtual Sequence< Type > SAL_CALL getTypes() throw ( RuntimeException ); +}; + +DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pVar->GetName() ) +{ + SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); + if ( pMod ) + { + if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) + { + Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); + // Use proxy factory service to create aggregatable proxy. + SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pMod->GetObject() ); + Reference< XInterface > xIf; + if ( pUnoObj ) + { + Any aObj = pUnoObj->getUnoAny(); + aObj >>= xIf; + if ( xIf.is() ) + { + m_xAggregateTypeProv.set( xIf, UNO_QUERY ); + m_xAggInv.set( xIf, UNO_QUERY ); + } + } + if ( xIf.is() ) + { + try + { + Reference< XMultiComponentFactory > xMFac( xFactory, UNO_QUERY_THROW ); + Reference< XPropertySet> xPSMPropertySet( xMFac, UNO_QUERY_THROW ); + Reference< XComponentContext > xCtx; + xPSMPropertySet->getPropertyValue( + String( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xCtx; + Reference< XProxyFactory > xProxyFac( xMFac->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.reflection.ProxyFactory" ) ), xCtx ), UNO_QUERY_THROW ); + m_xAggProxy = xProxyFac->createProxy( xIf ); + } + catch( Exception& ) + { + OSL_ENSURE( false, "DocObjectWrapper::DocObjectWrapper: Caught exception!" ); + } + } + + if ( m_xAggProxy.is() ) + { + osl_incrementInterlockedCount( &m_refCount ); + + /* i35609 - Fix crash on Solaris. The setDelegator call needs + to be in its own block to ensure that all temporary Reference + instances that are acquired during the call are released + before m_refCount is decremented again */ + { + m_xAggProxy->setDelegator( static_cast< cppu::OWeakObject * >( this ) ); + } + + osl_decrementInterlockedCount( &m_refCount ); + } + } + } +} + +void SAL_CALL +DocObjectWrapper::acquire() throw () +{ + osl_incrementInterlockedCount( &m_refCount ); + OSL_TRACE("DocObjectWrapper::acquire(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount ); +} +void SAL_CALL +DocObjectWrapper::release() throw () +{ + if ( osl_decrementInterlockedCount( &m_refCount ) == 0 ) + { + OSL_TRACE("DocObjectWrapper::release(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount ); + delete this; + } + else + OSL_TRACE("DocObjectWrapper::release(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount ); +} + +DocObjectWrapper::~DocObjectWrapper() +{ +} + +Sequence< Type > SAL_CALL DocObjectWrapper::getTypes() + throw ( RuntimeException ) +{ + if ( m_Types.getLength() == 0 ) + { + Sequence< Type > sTypes; + if ( m_xAggregateTypeProv.is() ) + sTypes = m_xAggregateTypeProv->getTypes(); + m_Types.realloc( sTypes.getLength() + 1 ); + Type* pPtr = m_Types.getArray(); + for ( int i=0; i<m_Types.getLength(); ++i, ++pPtr ) + { + if ( i == 0 ) + *pPtr = XInvocation::static_type( NULL ); + else + *pPtr = sTypes[ i - 1 ]; + } + } + return m_Types; +} + +Reference< XIntrospectionAccess > SAL_CALL +DocObjectWrapper::getIntrospection( ) throw (RuntimeException) +{ + return NULL; +} + +Any SAL_CALL +DocObjectWrapper::invoke( const ::rtl::OUString& aFunctionName, const Sequence< Any >& aParams, Sequence< ::sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasMethod( aFunctionName ) ) + return m_xAggInv->invoke( aFunctionName, aParams, aOutParamIndex, aOutParam ); + SbMethodRef pMethod = getMethod( aFunctionName ); + if ( !pMethod ) + throw RuntimeException(); + // check number of parameters + sal_Int32 nParamsCount = aParams.getLength(); + SbxInfo* pInfo = pMethod->GetInfo(); + if ( pInfo ) + { + sal_Int32 nSbxOptional = 0; + USHORT n = 1; + for ( const SbxParamInfo* pParamInfo = pInfo->GetParam( n ); pParamInfo; pParamInfo = pInfo->GetParam( ++n ) ) + { + if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != 0 ) + ++nSbxOptional; + else + nSbxOptional = 0; + } + sal_Int32 nSbxCount = n - 1; + if ( nParamsCount < nSbxCount - nSbxOptional ) + { + throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "wrong number of parameters!" ) ), Reference< XInterface >() ); + } + } + // set parameters + SbxArrayRef xSbxParams; + if ( nParamsCount > 0 ) + { + xSbxParams = new SbxArray; + const Any* pParams = aParams.getConstArray(); + for ( sal_Int32 i = 0; i < nParamsCount; ++i ) + { + SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT ); + unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), pParams[i] ); + xSbxParams->Put( xSbxVar, static_cast< USHORT >( i ) + 1 ); + + // Enable passing by ref + if ( xSbxVar->GetType() != SbxVARIANT ) + xSbxVar->SetFlag( SBX_FIXED ); + } + } + if ( xSbxParams.Is() ) + pMethod->SetParameters( xSbxParams ); + + // call method + SbxVariableRef xReturn = new SbxVariable; + ErrCode nErr = SbxERR_OK; + + nErr = pMethod->Call( xReturn ); + Any aReturn; + // get output parameters + if ( xSbxParams.Is() ) + { + SbxInfo* pInfo_ = pMethod->GetInfo(); + if ( pInfo_ ) + { + OutParamMap aOutParamMap; + for ( USHORT n = 1, nCount = xSbxParams->Count(); n < nCount; ++n ) + { + const SbxParamInfo* pParamInfo = pInfo_->GetParam( n ); + if ( pParamInfo && ( pParamInfo->eType & SbxBYREF ) != 0 ) + { + SbxVariable* pVar = xSbxParams->Get( n ); + if ( pVar ) + { + SbxVariableRef xVar = pVar; + aOutParamMap.insert( OutParamMap::value_type( n - 1, sbxToUnoValue( xVar ) ) ); + } + } + } + sal_Int32 nOutParamCount = aOutParamMap.size(); + aOutParamIndex.realloc( nOutParamCount ); + aOutParam.realloc( nOutParamCount ); + sal_Int16* pOutParamIndex = aOutParamIndex.getArray(); + Any* pOutParam = aOutParam.getArray(); + for ( OutParamMap::iterator aIt = aOutParamMap.begin(); aIt != aOutParamMap.end(); ++aIt, ++pOutParamIndex, ++pOutParam ) + { + *pOutParamIndex = aIt->first; + *pOutParam = aIt->second; + } + } + } + + // get return value + aReturn = sbxToUnoValue( xReturn ); + + pMethod->SetParameters( NULL ); + + return aReturn; +} + +void SAL_CALL +DocObjectWrapper::setValue( const ::rtl::OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasProperty( aPropertyName ) ) + return m_xAggInv->setValue( aPropertyName, aValue ); + + SbPropertyRef pProperty = getProperty( aPropertyName ); + if ( !pProperty.Is() ) + throw UnknownPropertyException(); + unoToSbxValue( (SbxVariable*) pProperty, aValue ); +} + +Any SAL_CALL +DocObjectWrapper::getValue( const ::rtl::OUString& aPropertyName ) throw (UnknownPropertyException, RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasProperty( aPropertyName ) ) + return m_xAggInv->getValue( aPropertyName ); + + SbPropertyRef pProperty = getProperty( aPropertyName ); + if ( !pProperty.Is() ) + throw UnknownPropertyException(); + + SbxVariable* pProp = ( SbxVariable* ) pProperty; + if ( pProp->GetType() == SbxEMPTY ) + pProperty->Broadcast( SBX_HINT_DATAWANTED ); + + Any aRet = sbxToUnoValue( pProp ); + return aRet; +} + +::sal_Bool SAL_CALL +DocObjectWrapper::hasMethod( const ::rtl::OUString& aName ) throw (RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasMethod( aName ) ) + return sal_True; + return getMethod( aName ).Is(); +} + +::sal_Bool SAL_CALL +DocObjectWrapper::hasProperty( const ::rtl::OUString& aName ) throw (RuntimeException) +{ + sal_Bool bRes = sal_False; + if ( m_xAggInv.is() && m_xAggInv->hasProperty( aName ) ) + bRes = sal_True; + else bRes = getProperty( aName ).Is(); + return bRes; +} + +Any SAL_CALL DocObjectWrapper::queryInterface( const Type& aType ) + throw ( RuntimeException ) +{ + Any aRet = DocObjectWrapper_BASE::queryInterface( aType ); + if ( aRet.hasValue() ) + return aRet; + else if ( m_xAggProxy.is() ) + aRet = m_xAggProxy->queryAggregation( aType ); + return aRet; +} + +SbMethodRef DocObjectWrapper::getMethod( const rtl::OUString& aName ) throw (RuntimeException) +{ + SbMethodRef pMethod = NULL; + if ( m_pMod ) + { + USHORT nSaveFlgs = m_pMod->GetFlags(); + // Limit search to this module + m_pMod->ResetFlag( SBX_GBLSEARCH ); + pMethod = (SbMethod*) m_pMod->SbModule::Find( aName, SbxCLASS_METHOD ); + m_pMod->SetFlags( nSaveFlgs ); + } + + return pMethod; +} + +SbPropertyRef DocObjectWrapper::getProperty( const rtl::OUString& aName ) throw (RuntimeException) +{ + SbPropertyRef pProperty = NULL; + if ( m_pMod ) + { + USHORT nSaveFlgs = m_pMod->GetFlags(); + // Limit search to this module. + m_pMod->ResetFlag( SBX_GBLSEARCH ); + pProperty = (SbProperty*)m_pMod->SbModule::Find( aName, SbxCLASS_PROPERTY ); + m_pMod->SetFlag( nSaveFlgs ); + } + + return pProperty; +} TYPEINIT1(SbModule,SbxObject) TYPEINIT1(SbMethod,SbxMethod) @@ -112,9 +461,9 @@ bool getDefaultVBAMode( StarBASIC* pb ) uno::Reference< beans::XPropertySet > xProp( aDoc, uno::UNO_QUERY ); if ( xProp.is() ) { - uno::Reference< script::XVBACompat > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY ); + uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY ); if ( xVBAMode.is() ) - bResult = ( xVBAMode->getVBACompatModeOn() == sal_True ); + bResult = xVBAMode->getVBACompatibilityMode() == sal_True; } } } @@ -199,12 +548,24 @@ SbModule::SbModule( const String& rName, BOOL bVBACompat ) SbModule::~SbModule() { + OSL_TRACE("Module named %s is destructing", rtl::OUStringToOString( GetName(), RTL_TEXTENCODING_UTF8 ).getStr() ); if( pImage ) delete pImage; if( pBreaks ) delete pBreaks; if( pClassData ) delete pClassData; + mxWrapper = NULL; +} + +uno::Reference< script::XInvocation > +SbModule::GetUnoModule() +{ + if ( !mxWrapper.is() ) + mxWrapper = new DocObjectWrapper( this ); + + OSL_TRACE("Module named %s returning wrapper mxWrapper (0x%x)", rtl::OUStringToOString( GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), mxWrapper.get() ); + return mxWrapper; } BOOL SbModule::IsCompiled() const @@ -684,6 +1045,9 @@ USHORT SbModule::Run( SbMethod* pMeth ) StarBASICRef xBasic; if( bDelInst ) { +#ifdef DBG_TRACE_BASIC + dbg_InitTrace(); +#endif // #32779: Basic waehrend der Ausfuehrung festhalten xBasic = (StarBASIC*) GetParent(); @@ -762,18 +1126,28 @@ USHORT SbModule::Run( SbMethod* pMeth ) SbModule* pOldMod = pMOD; pMOD = this; SbiRuntime* pRt = new SbiRuntime( this, pMeth, pMeth->nStart ); + +#ifdef DBG_TRACE_BASIC + dbg_traceNotifyCall( this, pMeth, pINST->nCallLvl ); +#endif + pRt->pNext = pINST->pRun; if( pRt->pNext ) pRt->pNext->block(); pINST->pRun = pRt; if ( mbVBACompat ) - { + { pINST->EnableCompatibility( TRUE ); - } + } while( pRt->Step() ) {} if( pRt->pNext ) pRt->pNext->unblock(); +#ifdef DBG_TRACE_BASIC + bool bLeave = true; + dbg_traceNotifyCall( this, pMeth, pINST->nCallLvl, bLeave ); +#endif + // #63710 Durch ein anderes Thread-Handling bei Events kann es passieren, // dass show-Aufruf an einem Dialog zurueckkehrt (durch schliessen des // Dialogs per UI), BEVOR ein per Event ausgeloester weitergehender Call, @@ -867,9 +1241,20 @@ void SbModule::RunInit() pMOD = this; // Der Init-Code beginnt immer hier SbiRuntime* pRt = new SbiRuntime( this, NULL, 0 ); + +#ifdef DBG_TRACE_BASIC + dbg_traceNotifyCall( this, NULL, 0 ); +#endif + pRt->pNext = pINST->pRun; pINST->pRun = pRt; while( pRt->Step() ) {} + +#ifdef DBG_TRACE_BASIC + bool bLeave = true; + dbg_traceNotifyCall( this, NULL, 0, bLeave ); +#endif + pINST->pRun = pRt->pNext; delete pRt; pMOD = pOldMod; @@ -884,6 +1269,33 @@ void SbModule::RunInit() } // Mit private/dim deklarierte Variablen loeschen + +void SbModule::AddVarName( const String& aName ) +{ + // see if the name is added allready + std::vector< String >::iterator it_end = mModuleVariableNames.end(); + for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it ) + { + if ( aName == *it ) + return; + } + mModuleVariableNames.push_back( aName ); +} + +void SbModule::RemoveVars() +{ + std::vector< String >::iterator it_end = mModuleVariableNames.end(); + for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it ) + { + // We don't want a Find being called in a derived class ( e.g. + // SbUserform because it could trigger say an initialise event + // which would cause basic to be re-run in the middle of the init ( and remember RemoveVars is called from compile and we don't want code to run as part of the compile ) + SbxVariableRef p = SbModule::Find( *it, SbxCLASS_PROPERTY ); + if( p.Is() ) + Remove (p); + } +} + void SbModule::ClearPrivateVars() { for( USHORT i = 0 ; i < pProps->Count() ; i++ ) @@ -1600,9 +2012,9 @@ SbObjModule::Find( const XubString& rName, SbxClassType t ) return pVar; } -typedef ::cppu::WeakImplHelper1< awt::XTopWindowListener > EventListener_BASE; +typedef ::cppu::WeakImplHelper2< awt::XTopWindowListener, awt::XWindowListener > FormObjEventListener_BASE; -class FormObjEventListenerImpl : public EventListener_BASE +class FormObjEventListenerImpl : public FormObjEventListener_BASE { SbUserFormModule* mpUserForm; uno::Reference< lang::XComponent > mxComponent; @@ -1612,39 +2024,57 @@ class FormObjEventListenerImpl : public EventListener_BASE sal_Bool mbShowing; FormObjEventListenerImpl(); // not defined FormObjEventListenerImpl(const FormObjEventListenerImpl&); // not defined + public: - FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : mpUserForm( pUserForm ), mxComponent( xComponent) , mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False ), mbShowing( sal_False ) + FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : + mpUserForm( pUserForm ), mxComponent( xComponent) , + mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False ), mbShowing( sal_False ) { if ( mxComponent.is() ) { - uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; - OSL_TRACE("*********** Registering the listener"); - xList->addTopWindowListener( this ); + OSL_TRACE("*********** Registering the listeners"); + try + { + uno::Reference< awt::XTopWindow >( mxComponent, uno::UNO_QUERY_THROW )->addTopWindowListener( this ); + } + catch( uno::Exception& ) {} + try + { + uno::Reference< awt::XWindow >( mxComponent, uno::UNO_QUERY_THROW )->addWindowListener( this ); + } + catch( uno::Exception& ) {} } } - ~FormObjEventListenerImpl() + virtual ~FormObjEventListenerImpl() { removeListener(); } - sal_Bool isShowing() { return mbShowing; } + + sal_Bool isShowing() const { return mbShowing; } + void removeListener() { - try + if ( mxComponent.is() && !mbDisposed ) { - if ( mxComponent.is() && !mbDisposed ) + OSL_TRACE("*********** Removing the listeners"); + try + { + uno::Reference< awt::XTopWindow >( mxComponent, uno::UNO_QUERY_THROW )->removeTopWindowListener( this ); + } + catch( uno::Exception& ) {} + try { - uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; - OSL_TRACE("*********** Removing the listener"); - xList->removeTopWindowListener( this ); - mxComponent = NULL; + uno::Reference< awt::XWindow >( mxComponent, uno::UNO_QUERY_THROW )->removeWindowListener( this ); } + catch( uno::Exception& ) {} } - catch( uno::Exception& ) {} + mxComponent.clear(); } + virtual void SAL_CALL windowOpened( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { - if ( mpUserForm ) + if ( mpUserForm ) { mbOpened = sal_True; mbShowing = sal_True; @@ -1691,12 +2121,23 @@ public: } //liuchen 2009-7-21 - virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { mbOpened = sal_False; mbShowing = sal_False; } - virtual void SAL_CALL windowMinimized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) {} - virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException){} + virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + mbOpened = sal_False; + mbShowing = sal_False; + } + + virtual void SAL_CALL windowMinimized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } + + virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } + virtual void SAL_CALL windowActivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { - if ( mpUserForm ) + if ( mpUserForm ) { mbActivated = sal_True; if ( mbOpened ) @@ -1709,18 +2150,38 @@ public: virtual void SAL_CALL windowDeactivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { - if ( mpUserForm ) - mpUserForm->triggerDeActivateEvent(); + if ( mpUserForm ) + mpUserForm->triggerDeactivateEvent(); + } + + virtual void SAL_CALL windowResized( const awt::WindowEvent& /*e*/ ) throw (uno::RuntimeException) + { + if ( mpUserForm ) + { + mpUserForm->triggerResizeEvent(); + mpUserForm->triggerLayoutEvent(); + } } + virtual void SAL_CALL windowMoved( const awt::WindowEvent& /*e*/ ) throw (uno::RuntimeException) + { + if ( mpUserForm ) + mpUserForm->triggerLayoutEvent(); + } + + virtual void SAL_CALL windowShown( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } + + virtual void SAL_CALL windowHidden( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } - virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (uno::RuntimeException) + virtual void SAL_CALL disposing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException) { OSL_TRACE("** Userform/Dialog disposing"); mbDisposed = true; - uno::Any aSource; - aSource <<= Source; - mxComponent = NULL; + mxComponent.clear(); if ( mpUserForm ) mpUserForm->ResetApiObj(); } @@ -1734,6 +2195,10 @@ SbUserFormModule::SbUserFormModule( const String& rName, const com::sun::star::s m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW ); } +SbUserFormModule::~SbUserFormModule() +{ +} + void SbUserFormModule::ResetApiObj() { if ( m_xDialog.is() ) // probably someone close the dialog window @@ -1796,23 +2261,22 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any void SbUserFormModule::triggerActivateEvent( void ) { - OSL_TRACE("**** entering SbUserFormModule::triggerActivate"); - triggerMethod( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserForm_activate") ) ); - OSL_TRACE("**** leaving SbUserFormModule::triggerActivate"); + OSL_TRACE("**** entering SbUserFormModule::triggerActivate"); + triggerMethod( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserForm_Activate") ) ); + OSL_TRACE("**** leaving SbUserFormModule::triggerActivate"); } -void SbUserFormModule::triggerDeActivateEvent( void ) +void SbUserFormModule::triggerDeactivateEvent( void ) { - OSL_TRACE("**** SbUserFormModule::triggerDeActivate"); - triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_DeActivate") ) ); + OSL_TRACE("**** SbUserFormModule::triggerDeactivate"); + triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_Deactivate") ) ); } void SbUserFormModule::triggerInitializeEvent( void ) - { if ( mbInit ) return; - OSL_TRACE("**** SbUserFormModule::triggerInitializeEvent"); + OSL_TRACE("**** SbUserFormModule::triggerInitializeEvent"); static String aInitMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Initialize") ); triggerMethod( aInitMethodName ); mbInit = true; @@ -1820,12 +2284,24 @@ void SbUserFormModule::triggerInitializeEvent( void ) void SbUserFormModule::triggerTerminateEvent( void ) { - OSL_TRACE("**** SbUserFormModule::triggerTerminateEvent"); + OSL_TRACE("**** SbUserFormModule::triggerTerminateEvent"); static String aTermMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Terminate") ); triggerMethod( aTermMethodName ); mbInit=false; } +void SbUserFormModule::triggerLayoutEvent( void ) +{ + static String aMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Layout") ); + triggerMethod( aMethodName ); +} + +void SbUserFormModule::triggerResizeEvent( void ) +{ + static String aMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Resize") ); + triggerMethod( aMethodName ); +} + SbUserFormModuleInstance* SbUserFormModule::CreateInstance() { SbUserFormModuleInstance* pInstance = new SbUserFormModuleInstance( this, GetName(), m_mInfo, IsVBACompat() ); @@ -1853,7 +2329,7 @@ SbxVariable* SbUserFormModuleInstance::Find( const XubString& rName, SbxClassTyp } -void SbUserFormModule::load() +void SbUserFormModule::Load() { OSL_TRACE("** load() "); // forces a load @@ -1891,21 +2367,20 @@ void SbUserFormModule::Unload() if( pMeth ) { OSL_TRACE("Attempting too run the UnloadObjectMethod"); - m_xDialog = NULL; //release ref to the uno object + m_xDialog.clear(); //release ref to the uno object SbxValues aVals; - FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() ); bool bWaitForDispose = true; // assume dialog is showing - if ( pFormListener ) + if ( m_DialogListener.get() ) { - bWaitForDispose = pFormListener->isShowing(); + bWaitForDispose = m_DialogListener->isShowing(); OSL_TRACE("Showing %d", bWaitForDispose ); } pMeth->Get( aVals); - if ( !bWaitForDispose ) - { - // we've either already got a dispose or we'er never going to get one + if ( !bWaitForDispose ) + { + // we've either already got a dispose or we'er never going to get one ResetApiObj(); - } // else wait for dispose + } // else wait for dispose OSL_TRACE("UnloadObject completed ( we hope )"); } } @@ -1943,9 +2418,8 @@ void SbUserFormModule::InitObject() pDocObject = new SbUnoObject( GetName(), uno::makeAny( xVBAFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.UserForm")), aArgs ) ) ); uno::Reference< lang::XComponent > xComponent( aArgs[ 1 ], uno::UNO_QUERY_THROW ); // remove old listener if it exists - FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() ); - if ( pFormListener ) - pFormListener->removeListener(); + if ( m_DialogListener.get() ) + m_DialogListener->removeListener(); m_DialogListener = new FormObjEventListenerImpl( this, xComponent ); triggerInitializeEvent(); diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index 0cf0d9870378..42969b98d0d8 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -1009,13 +1009,8 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa else pExpr = new SbiExpression( pParser ); - if( bByVal ) - { - if( !pExpr->IsLvalue() ) - pParser->Error( SbERR_LVALUE_EXPECTED ); - else - pExpr->SetByVal(); - } + if( bByVal && pExpr->IsLvalue() ) + pExpr->SetByVal(); //pExpr = bConst ? new SbiConstExpression( pParser ) // : new SbiExpression( pParser ); diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 6e4f7ddf126e..e6fe73177dd2 100644..100755 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -31,10 +31,310 @@ #include <basic/sbx.hxx> #include "sbcomp.hxx" #include "image.hxx" +#include "sbtrace.hxx" +//========================================================================== +// Tracing, for debugging only + +// To activate tracing enable in sbtrace.hxx +#ifdef DBG_TRACE_BASIC + +#include <hash_map> + +// Trace Settings +static const char* GpTraceFileName = "d:\\zBasic.Asm\\BasicTrace.txt"; +static const bool GbIncludePCodes = false; +static const int GnIndentPerCallLevel = 4; +static const int GnIndentForPCode = 2; + +struct TraceTextData +{ + rtl::OString m_aTraceStr_STMNT; + rtl::OString m_aTraceStr_PCode; +}; +typedef std::hash_map< sal_Int32, TraceTextData > PCToTextDataMap; +typedef std::hash_map< ::rtl::OUString, PCToTextDataMap*, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleTraceMap; + +ModuleTraceMap GaModuleTraceMap; +ModuleTraceMap& rModuleTraceMap = GaModuleTraceMap; + +static void lcl_PrepareTraceForModule( SbModule* pModule ) +{ + String aModuleName = pModule->GetName(); + ModuleTraceMap::iterator it = rModuleTraceMap.find( aModuleName ); + if( it != rModuleTraceMap.end() ) + { + PCToTextDataMap* pInnerMap = it->second; + delete pInnerMap; + rModuleTraceMap.erase( it ); + } + + String aDisassemblyStr; + pModule->Disassemble( aDisassemblyStr ); +} + +static void lcl_lineOut( const char* pFileName, const char* pStr, const char* pPreStr = NULL ) +{ + const char* pPrintFirst = (pPreStr != NULL) ? pPreStr : ""; + FILE* pFile = fopen( pFileName, "a+" ); + if( pFile != NULL ) + { + fprintf( pFile, "%s%s\n", pPrintFirst, pStr ); + fclose( pFile ); + } +} + +const char* lcl_getSpaces( int nSpaceCount ) +{ + static sal_Char Spaces[] = " " + " " + " "; + static int nAvailableSpaceCount = strlen( Spaces ); + static sal_Char* pSpacesEnd = Spaces + nAvailableSpaceCount; + + if( nSpaceCount > nAvailableSpaceCount ) + nSpaceCount = nAvailableSpaceCount; + + return pSpacesEnd - nSpaceCount; +} + +static rtl::OString lcl_toOStringSkipLeadingWhites( const String& aStr ) +{ + static sal_Char Buffer[1000]; + + rtl::OString aOStr = OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ); + const sal_Char* pStr = aOStr.getStr(); + + // Skip whitespace + sal_Char c = *pStr; + while( c == ' ' || c == '\t' ) + { + pStr++; + c = *pStr; + } + + int nLen = strlen( pStr ); + strncpy( Buffer, pStr, nLen ); + Buffer[nLen] = 0; + + rtl::OString aORetStr( Buffer ); + return aORetStr; +} + +String dumpMethodParameters( SbMethod* pMethod ) +{ + String aStr; + if( pMethod == NULL ) + return aStr; + + SbxError eOld = SbxBase::GetError(); + + SbxArray* pParams = pMethod->GetParameters(); + SbxInfo* pInfo = pMethod->GetInfo(); + if ( pParams ) + { + aStr += '('; + // 0 is sub itself + for ( USHORT nParam = 1; nParam < pParams->Count(); nParam++ ) + { + SbxVariable* pVar = pParams->Get( nParam ); + DBG_ASSERT( pVar, "Parameter?!" ); + if ( pVar->GetName().Len() ) + aStr += pVar->GetName(); + else if ( pInfo ) + { + const SbxParamInfo* pParam = pInfo->GetParam( nParam ); + if ( pParam ) + aStr += pParam->aName; + } + aStr += '='; + if( pVar->GetType() & SbxARRAY ) + aStr += String( RTL_CONSTASCII_USTRINGPARAM( "..." ) ); + else + aStr += pVar->GetString(); + if ( nParam < ( pParams->Count() - 1 ) ) + aStr += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) ); + } + aStr += ')'; + } + + SbxBase::ResetError(); + if( eOld != SbxERR_OK ) + SbxBase::SetError( eOld ); + + return aStr; +} + +// Public functions +void dbg_InitTrace( void ) +{ + FILE* pFile = fopen( GpTraceFileName, "w" ); + if( pFile != NULL ) + fclose( pFile ); +} + +void dbg_traceStep( SbModule* pModule, UINT32 nPC, INT32 nCallLvl ) +{ + SbModule* pTraceMod = pModule; + if( pTraceMod->ISA(SbClassModuleObject) ) + { + SbClassModuleObject* pClassModuleObj = (SbClassModuleObject*)(SbxBase*)pTraceMod; + pTraceMod = pClassModuleObj->getClassModule(); + } + + String aModuleName = pTraceMod->GetName(); + ModuleTraceMap::iterator it = rModuleTraceMap.find( aModuleName ); + if( it == rModuleTraceMap.end() ) + { + 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 ); + return; + } + + PCToTextDataMap* pInnerMap = it->second; + if( pInnerMap == NULL ) + { + lcl_lineOut( GpTraceFileName, "TRACE INTERNAL ERROR: No inner map" ); + return; + } + + PCToTextDataMap::iterator itInner = pInnerMap->find( nPC ); + if( itInner == pInnerMap->end() ) + { + 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\"", nPC, pModuleNameStr ); + lcl_lineOut( GpTraceFileName, Buffer ); + return; + } + + //nCallLvl--; + //if( nCallLvl < 0 ) + // nCallLvl = 0; + int nIndent = nCallLvl * GnIndentPerCallLevel; + + const TraceTextData& rTraceTextData = itInner->second; + const rtl::OString& rStr_STMNT = rTraceTextData.m_aTraceStr_STMNT; + if( rStr_STMNT.getLength() ) + lcl_lineOut( GpTraceFileName, rStr_STMNT.getStr(), lcl_getSpaces( nIndent ) ); + + if( !GbIncludePCodes ) + 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 ) ); +} + +void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl, bool bLeave ) +{ + static const char* pSeparator = "' ================================================================================"; + + SbModule* pTraceMod = pModule; + SbClassModuleObject* pClassModuleObj = NULL; + if( pTraceMod->ISA(SbClassModuleObject) ) + { + pClassModuleObj = (SbClassModuleObject*)(SbxBase*)pTraceMod; + pTraceMod = pClassModuleObj->getClassModule(); + } + + if( nCallLvl > 0 ) + nCallLvl--; + int nIndent = nCallLvl * GnIndentPerCallLevel; + if( !bLeave ) + { + lcl_lineOut( GpTraceFileName, "" ); + lcl_lineOut( GpTraceFileName, pSeparator, lcl_getSpaces( nIndent ) ); + } + + String aStr; + if( bLeave ) + { + lcl_lineOut( GpTraceFileName, "}", lcl_getSpaces( nIndent ) ); + aStr.AppendAscii( "' Leaving " ); + } + else + { + aStr.AppendAscii( "Entering " ); + } + String aModuleName = pModule->GetName(); + aStr += aModuleName; + if( pMethod != NULL ) + { + aStr.AppendAscii( "::" ); + String aMethodName = pMethod->GetName(); + aStr += aMethodName; + } + else + { + aStr.AppendAscii( "/RunInit" ); + } + + if( pClassModuleObj != NULL ) + { + aStr.AppendAscii( "[this=" ); + aStr += pClassModuleObj->GetName(); + aStr.AppendAscii( "]" ); + } + if( !bLeave ) + aStr += dumpMethodParameters( pMethod ); + + lcl_lineOut( GpTraceFileName, OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) ); + if( !bLeave ) + lcl_lineOut( GpTraceFileName, "{", lcl_getSpaces( nIndent ) ); + + if( bLeave ) + lcl_lineOut( GpTraceFileName, "" ); +} + +void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, INT32 nCallLvl ) +{ + rtl::OString aOTraceErrMsg = OUStringToOString( rtl::OUString( aTraceErrMsg ), RTL_TEXTENCODING_ASCII_US ); + + char Buffer[200]; + 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 ) ); +} + +void dbg_RegisterTraceTextForPC( SbModule* pModule, UINT32 nPC, + const String& aTraceStr_STMNT, const String& aTraceStr_PCode ) +{ + String aModuleName = pModule->GetName(); + ModuleTraceMap::iterator it = rModuleTraceMap.find( aModuleName ); + PCToTextDataMap* pInnerMap; + if( it == rModuleTraceMap.end() ) + { + pInnerMap = new PCToTextDataMap(); + rModuleTraceMap[ aModuleName ] = pInnerMap; + } + else + { + pInnerMap = it->second; + } + + TraceTextData aData; + + rtl::OString aOTraceStr_STMNT = lcl_toOStringSkipLeadingWhites( aTraceStr_STMNT ); + aData.m_aTraceStr_STMNT = aOTraceStr_STMNT; + + rtl::OString aOTraceStr_PCode = lcl_toOStringSkipLeadingWhites( aTraceStr_PCode ); + aData.m_aTraceStr_PCode = aOTraceStr_PCode; + + (*pInnerMap)[nPC] = aData; +} + +#endif + + +//========================================================================== // For debugging only -// #define DBG_SAVE_DISASSEMBLY +//#define DBG_SAVE_DISASSEMBLY #ifdef DBG_SAVE_DISASSEMBLY static bool dbg_bDisassemble = true; @@ -67,7 +367,7 @@ void dbg_SaveDisassembly( SbModule* pModule ) ( OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY ); if( xSFI.is() ) { - String aFile( RTL_CONSTASCII_USTRINGPARAM("file:///d:/BasicAsm_") ); + String aFile( RTL_CONSTASCII_USTRINGPARAM("file:///d:/zBasic.Asm/Asm_") ); StarBASIC* pBasic = (StarBASIC*)pModule->GetParent(); if( pBasic ) { @@ -99,6 +399,7 @@ void dbg_SaveDisassembly( SbModule* pModule ) } #endif + // Diese Routine ist hier definiert, damit der Compiler als eigenes Segment // geladen werden kann. @@ -131,6 +432,7 @@ BOOL SbModule::Compile() if( bRet ) { pBasic->ClearAllModuleVars(); + RemoveVars(); // remove 'this' Modules variables // clear all method statics for( USHORT i = 0; i < pMethods->Count(); i++ ) { @@ -154,6 +456,10 @@ BOOL SbModule::Compile() dbg_SaveDisassembly( this ); #endif +#ifdef DBG_TRACE_BASIC + lcl_PrepareTraceForModule( this ); +#endif + return bRet; } diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index ac1199f6c233..7fd6eb06f607 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -60,7 +60,7 @@ #include <cppuhelper/implbase2.hxx> #include <cppuhelper/compbase8.hxx> #include <cppuhelper/interfacecontainer.hxx> -#include <com/sun/star/script/XVBACompat.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> class BasicManager; @@ -74,7 +74,7 @@ typedef ::cppu::WeakComponentImplHelper8< ::com::sun::star::script::XLibraryContainerExport, ::com::sun::star::script::XLibraryContainer3, ::com::sun::star::container::XContainer, - ::com::sun::star::script::XVBACompat, + ::com::sun::star::script::vba::XVBACompatibility, ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper; typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer, @@ -507,9 +507,9 @@ public: throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0; - // Methods XVBACompat - virtual ::sal_Bool SAL_CALL getVBACompatModeOn() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setVBACompatModeOn( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); + // 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); }; class LibraryContainerMethodGuard diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx new file mode 100755 index 000000000000..e8a482c2f6e9 --- /dev/null +++ b/basic/source/inc/sbtrace.hxx @@ -0,0 +1,42 @@ +/************************************************************************* + * + * 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 _SBTRACE_HXX +#define _SBTRACE_HXX + +// #define DBG_TRACE_BASIC + +#ifdef DBG_TRACE_BASIC +void dbg_InitTrace( void ); +void dbg_traceStep( SbModule* pModule, UINT32 nPC, INT32 nCallLvl ); +void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl, bool bLeave = false ); +void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, INT32 nCallLvl ); +void dbg_RegisterTraceTextForPC( SbModule* pModule, UINT32 nPC, + const String& aTraceStr_STMNT, const String& aTraceStr_PCode ); +#endif + +#endif diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx index d184a2d558e2..091fbc24cdbe 100644 --- a/basic/source/inc/scriptcont.hxx +++ b/basic/source/inc/scriptcont.hxx @@ -30,7 +30,7 @@ #include "namecont.hxx" #include <basic/basmgr.hxx> -#include <com/sun/star/script/XVBAModuleInfo.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> #include <comphelper/uno3.hxx> class BasicManager; @@ -141,7 +141,7 @@ 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::XVBAModuleInfo +typedef ::cppu::ImplHelper1 < ::com::sun::star::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE; class SfxScriptLibrary : public SfxLibrary diff --git a/basic/source/runtime/dllmgr.cxx b/basic/source/runtime/dllmgr.cxx index bc08a8cb64bc..04f1ee0a8acc 100644 --- a/basic/source/runtime/dllmgr.cxx +++ b/basic/source/runtime/dllmgr.cxx @@ -684,7 +684,7 @@ Dll * SbiDllMgr::Impl::getDll(rtl::OUString const & name) { Dlls::iterator i(dlls.find(name)); if (i == dlls.end()) { i = dlls.insert(Dlls::value_type(name, new Dll)).first; - HMODULE h = LoadLibraryW(name); + HMODULE h = LoadLibraryW(reinterpret_cast<LPCWSTR>(name.getStr())); if (h == 0) { dlls.erase(i); return 0; diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 7f492ced6aeb..97f6ed227d47 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -4101,8 +4101,7 @@ RTLFUNC(Load) { if( pObj->IsA( TYPE( SbUserFormModule ) ) ) { - SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj; - pFormModule->load(); + ((SbUserFormModule*)pObj)->Load(); } else if( pObj->IsA( TYPE( SbxObject ) ) ) { diff --git a/basic/source/runtime/props.cxx b/basic/source/runtime/props.cxx index cec74444e7a2..663d12fbcd72 100644 --- a/basic/source/runtime/props.cxx +++ b/basic/source/runtime/props.cxx @@ -76,6 +76,13 @@ RTLFUNC(False) rPar.Get(0)->PutBool( FALSE ); } +RTLFUNC(Empty) +{ + (void)pBasic; + (void)bWrite; + (void)rPar; +} + RTLFUNC(Nothing) { (void)pBasic; diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx index 1a1ae4f32283..5437654f69a0 100644 --- a/basic/source/runtime/rtlproto.hxx +++ b/basic/source/runtime/rtlproto.hxx @@ -38,6 +38,7 @@ extern RTLFUNC(Date); extern RTLFUNC(Err); extern RTLFUNC(Erl); extern RTLFUNC(False); +extern RTLFUNC(Empty); extern RTLFUNC(Nothing); extern RTLFUNC(Null); extern RTLFUNC(True); diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index c3419adbfdb3..1bb6fb82e113 100755 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -44,6 +44,7 @@ #include <com/sun/star/container/XEnumerationAccess.hpp> #include "sbunoobj.hxx" #include "errobject.hxx" +#include "sbtrace.hxx" using namespace ::com::sun::star; @@ -720,6 +721,12 @@ BOOL SbiRuntime::Step() if( pInst->IsReschedule() && bStaticGlobalEnableReschedule ) Application::Reschedule(); } + +#ifdef DBG_TRACE_BASIC + UINT32 nPC = ( pCode - (const BYTE* )pImg->GetCode() ); + dbg_traceStep( pMod, nPC, pINST->nCallLvl ); +#endif + SbiOpcode eOp = (SbiOpcode ) ( *pCode++ ); UINT32 nOp1, nOp2; if( eOp <= SbOP0_END ) @@ -756,6 +763,11 @@ BOOL SbiRuntime::Step() // (insbesondere nicht nach Compiler-Fehlern zur Laufzeit) if( nError && bRun ) { +#ifdef DBG_TRACE_BASIC + SbError nTraceErr = nError; + String aTraceErrMsg = GetSbData()->aErrMsg; + bool bTraceErrHandled = true; +#endif SbError err = nError; ClearExprStack(); nError = 0; @@ -836,12 +848,19 @@ BOOL SbiRuntime::Step() // Kein Error-Hdl gefunden -> altes Vorgehen else { +#ifdef DBG_TRACE_BASIC + bTraceErrHandled = false; +#endif pInst->Abort(); } // ALT: Nur // pInst->Abort(); } + +#ifdef DBG_TRACE_BASIC + dbg_traceNotifyError( nTraceErr, aTraceErrMsg, bTraceErrHandled, pINST->nCallLvl ); +#endif } } return bRun; diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 60d2e9cf448d..4455901bfeba 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -221,6 +221,7 @@ static Methods aMethods[] = { { "FileSpec", SbxSTRING, 0,NULL,0 }, { "DumpAll", SbxINTEGER, _OPT, NULL,0 }, +{ "Empty", SbxVARIANT, _CPROP, RTLNAME(Empty),0 }, { "EqualUnoObjects",SbxBOOL, 2 | _FUNCTION, RTLNAME(EqualUnoObjects),0 }, { "Variant", SbxVARIANT, 0,NULL,0 }, { "Variant", SbxVARIANT, 0,NULL,0 }, diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 21e52b20029b..ea40f0c65877 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -305,9 +305,21 @@ void SbiRuntime::StepIS() { SbxVariableRef refVar1 = PopVar(); SbxVariableRef refVar2 = PopVar(); - BOOL bRes = BOOL( - refVar1->GetType() == SbxOBJECT - && refVar2->GetType() == SbxOBJECT ); + + SbxDataType eType1 = refVar1->GetType(); + SbxDataType eType2 = refVar2->GetType(); + if ( eType1 == SbxEMPTY ) + { + refVar1->Broadcast( SBX_HINT_DATAWANTED ); + eType1 = refVar1->GetType(); + } + if ( eType2 == SbxEMPTY ) + { + refVar2->Broadcast( SBX_HINT_DATAWANTED ); + eType2 = refVar2->GetType(); + } + + BOOL bRes = BOOL( eType1 == SbxOBJECT && eType2 == SbxOBJECT ); if ( bVBAEnabled && !bRes ) Error( SbERR_INVALID_USAGE_OBJECT ); bRes = ( bRes && refVar1->GetObject() == refVar2->GetObject() ); @@ -513,9 +525,10 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b // Handle withevents BOOL bWithEvents = refVar->IsSet( SBX_WITH_EVENTS ); - Reference< XInterface > xComListener; - if( bWithEvents ) + if ( bWithEvents ) { + Reference< XInterface > xComListener; + SbxBase* pObj = refVal->GetObject(); SbUnoObject* pUnoObj = (pObj != NULL) ? PTR_CAST(SbUnoObject,pObj) : NULL; if( pUnoObj != NULL ) @@ -526,13 +539,17 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b ::rtl::OUString aPrefix = refVar->GetName(); SbxObjectRef xScopeObj = refVar->GetParent(); xComListener = createComListener( aControlAny, aVBAType, aPrefix, xScopeObj ); - } - } - *refVar = *refVal; + refVal->SetDeclareClassName( aDeclareClassName ); + refVal->SetComListener( xComListener ); // Hold reference + } - if( bWithEvents ) - refVar->SetComListener( xComListener ); // Hold reference + *refVar = *refVal; + } + else + { + *refVar = *refVal; + } // lhs is a property who's value is currently (Empty e.g. no broadcast yet) // in this case if there is a default prop involved the value of the diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index 72ea67dd8db4..587b0ae7a590 100644..100755 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -263,8 +263,10 @@ SbxVariable* SbiRuntime::FindElement pElem = pNew; } // Index-Access bei UnoObjekten beruecksichtigen - /* - else if( pElem->ISA(SbUnoProperty) ) + // definitely we want this for VBA where properties are often + // collections ( which need index access ), but lets only do + // this if we actually have params following + else if( bVBAEnabled && pElem->ISA(SbUnoProperty) && pElem->GetParameters() ) { // pElem auf eine Ref zuweisen, um ggf. eine Temp-Var zu loeschen SbxVariableRef refTemp = pElem; @@ -274,7 +276,6 @@ SbxVariable* SbiRuntime::FindElement pElem->SetParameters( NULL ); // sonst bleibt Ref auf sich selbst pElem = pNew; } - */ } return CheckArray( pElem ); } @@ -377,7 +378,8 @@ void SbiRuntime::SetupArgs( SbxVariable* p, UINT32 nOp1 ) bool bError_ = true; SbUnoMethod* pUnoMethod = PTR_CAST(SbUnoMethod,p); - if( pUnoMethod ) + SbUnoProperty* pUnoProperty = PTR_CAST(SbUnoProperty,p); + if( pUnoMethod || pUnoProperty ) { SbUnoObject* pParentUnoObj = PTR_CAST( SbUnoObject,p->GetParent() ); if( pParentUnoObj ) @@ -677,7 +679,18 @@ void SbiRuntime::StepPARAM( UINT32 nOp1, UINT32 nOp2 ) while( iLoop >= nParamCount ) { p = new SbxVariable(); - p->PutErr( 448 ); // Wie in VB: Error-Code 448 (SbERR_NAMED_NOT_FOUND) + + if( SbiRuntime::isVBAEnabled() && + (t == SbxOBJECT || t == SbxSTRING) ) + { + if( t == SbxOBJECT ) + p->PutObject( NULL ); + else + p->PutString( String() ); + } + else + p->PutErr( 448 ); // Wie in VB: Error-Code 448 (SbERR_NAMED_NOT_FOUND) + refParams->Put( p, iLoop ); iLoop--; } @@ -1157,15 +1170,26 @@ void SbiRuntime::StepGLOBAL( UINT32 nOp1, UINT32 nOp2 ) StepPUBLIC_Impl( nOp1, nOp2, true ); String aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); - SbxDataType t = (SbxDataType)(SbxDataType)(nOp2 & 0xffff);; - BOOL bFlag = rBasic.IsSet( SBX_NO_MODIFY ); + SbxDataType t = (SbxDataType)(nOp2 & 0xffff); + + // Store module scope variables at module scope + // in non vba mode these are stored at the library level :/ + // not sure if this really should not be enabled for ALL basic + SbxObject* pStorage = &rBasic; + if ( SbiRuntime::isVBAEnabled() ) + { + pStorage = pMod; + pMod->AddVarName( aName ); + } + + BOOL bFlag = pStorage->IsSet( SBX_NO_MODIFY ); rBasic.SetFlag( SBX_NO_MODIFY ); - SbxVariableRef p = rBasic.Find( aName, SbxCLASS_PROPERTY ); + SbxVariableRef p = pStorage->Find( aName, SbxCLASS_PROPERTY ); if( p.Is() ) - rBasic.Remove (p); - p = rBasic.Make( aName, SbxCLASS_PROPERTY, t ); + pStorage->Remove (p); + p = pStorage->Make( aName, SbxCLASS_PROPERTY, t ); if( !bFlag ) - rBasic.ResetFlag( SBX_NO_MODIFY ); + pStorage->ResetFlag( SBX_NO_MODIFY ); if( p ) { p->SetFlag( SBX_DONTSTORE ); diff --git a/basic/source/runtime/wnt-mingw.s b/basic/source/runtime/wnt-mingw.s index 7868ddd386f0..8c332c1a8ce8 100644 --- a/basic/source/runtime/wnt-mingw.s +++ b/basic/source/runtime/wnt-mingw.s @@ -44,8 +44,8 @@ _DllMgr_callFp: shr ecx, 2 rep movsd $1: call DWORD PTR [ebp+8] - ; for extra safety, do not trust esp after call (in case the Basic Declare - ; signature is wrong): + # for extra safety, do not trust esp after call (in case the Basic Declare + # signature is wrong): mov edi, [ebp-8] mov esi, [ebp-4] mov esp, ebp diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index e1ad8b6b4308..c31aed1f8ef7 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -2793,7 +2793,6 @@ OUString SfxLibraryContainer::expand_url( const OUString& url ) } } - //XLibraryContainer3 OUString SAL_CALL SfxLibraryContainer::getOriginalLibraryLinkURL( const OUString& Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException) @@ -2808,12 +2807,13 @@ OUString SAL_CALL SfxLibraryContainer::getOriginalLibraryLinkURL( const OUString } -::sal_Bool SAL_CALL SfxLibraryContainer::getVBACompatModeOn() throw (RuntimeException) +// XVBACompatibility +::sal_Bool SAL_CALL SfxLibraryContainer::getVBACompatibilityMode() throw (RuntimeException) { return mbVBACompat; } -void SAL_CALL SfxLibraryContainer::setVBACompatModeOn( ::sal_Bool _vbacompatmodeon ) throw (RuntimeException) +void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (RuntimeException) { BasicManager* pBasMgr = getBasicManager(); if( pBasMgr ) diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index 5622adc19af1..f7091d1c1a0b 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -216,8 +216,7 @@ void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement Any aElement = xLib->getByName( aElementName ); aElement >>= aMod.aCode; - Reference < script::XVBAModuleInfo > xModInfo( xLib, UNO_QUERY ); - + Reference< script::vba::XVBAModuleInfo > xModInfo( xLib, UNO_QUERY ); if( xModInfo.is() && xModInfo->hasModuleInfo( aElementName ) ) { script::ModuleInfo aModInfo = xModInfo->getModuleInfo( aElementName ); @@ -312,9 +311,9 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement // aMod.aName ignored if( aMod.aModuleType.getLength() > 0 ) { - if( !getVBACompatModeOn() ) + if( !getVBACompatibilityMode() ) { - setVBACompatModeOn( sal_True ); + setVBACompatibilityMode( sal_True ); Any aGlobs; Sequence< Any > aArgs(1); @@ -381,8 +380,7 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement } } - Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, - UNO_QUERY ); + Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); if( xVBAModuleInfo.is() ) { if( xVBAModuleInfo->hasModuleInfo( aElementName ) ) diff --git a/configmgr/source/rootaccess.cxx b/configmgr/source/rootaccess.cxx index 95a346d720c2..f5d0bb137202 100644 --- a/configmgr/source/rootaccess.cxx +++ b/configmgr/source/rootaccess.cxx @@ -96,11 +96,12 @@ void RootAccess::initBroadcaster( for (ChangesListeners::iterator i(changesListeners_.begin()); i != changesListeners_.end(); ++i) { + cppu::OWeakObject* pSource = static_cast< cppu::OWeakObject * >(this); + css::uno::Reference< css::uno::XInterface > xBase( pSource, css::uno::UNO_QUERY ); broadcaster->addChangesNotification( *i, css::util::ChangesEvent( - static_cast< cppu::OWeakObject * >(this), - css::uno::makeAny(pathRepresentation_), set)); + pSource, makeAny( xBase ), set)); } } } diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx index eda478b18b70..cd1e6e55d085 100644 --- a/configmgr/source/xcuparser.cxx +++ b/configmgr/source/xcuparser.cxx @@ -196,6 +196,14 @@ bool XcuParser::startElement( { handleSetNode( reader, dynamic_cast< SetNode * >(state_.top().node.get())); + } else if (ns == XmlReader::NAMESPACE_NONE && + name.equals(RTL_CONSTASCII_STRINGPARAM("prop"))) + { + OSL_TRACE( + "configmgr bad set node <prop> member in %s", + rtl::OUStringToOString( + reader.getUrl(), RTL_TEXTENCODING_UTF8).getStr()); + state_.push(State(true)); // ignored } else { throw css::uno::RuntimeException( (rtl::OUString( diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 2884e6179aaa..aca181916b47 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -258,6 +258,7 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType) (*this) = getAny(); break; default: + (*this) = getAny(); OSL_ENSURE(0,"ORowSetValue:operator==(): UNSPUPPORTED TYPE!"); } } @@ -344,6 +345,19 @@ void ORowSetValue::free() TRACE_FREE( Any ) m_aValue.m_pValue = NULL; break; + case DataType::BIT: + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::BOOLEAN: + break; + default: + if ( m_aValue.m_pValue ) + { + delete (Any*)m_aValue.m_pValue; + TRACE_FREE( Any ) + m_aValue.m_pValue = NULL; + } + break; } m_bNull = sal_True; @@ -849,7 +863,9 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const bRet = false; break; default: + bRet = false; OSL_ENSURE(0,"ORowSetValue::operator==(): UNSPUPPORTED TYPE!"); + break; } return bRet; } @@ -942,6 +958,8 @@ Any ORowSetValue::makeAny() const break; default: OSL_ENSURE(0,"ORowSetValue::makeAny(): UNSPUPPORTED TYPE!"); + rValue = getAny(); + break; } } return rValue; @@ -1032,6 +1050,12 @@ Any ORowSetValue::makeAny() const } } break; + default: + { + Any aValue = getAny(); + aValue >>= aRet; + break; + } } } return aRet; @@ -1104,8 +1128,11 @@ sal_Bool ORowSetValue::getBool() const bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (*static_cast<sal_Int64*>(m_aValue.m_pValue) != sal_Int64(0)); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= bRet; + break; + } } } return bRet; @@ -1174,8 +1201,11 @@ sal_Int8 ORowSetValue::getInt8() const nRet = static_cast<sal_Int8>(*static_cast<sal_Int64*>(m_aValue.m_pValue)); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1244,8 +1274,11 @@ sal_Int16 ORowSetValue::getInt16() const nRet = static_cast<sal_Int16>(*static_cast<sal_Int64*>(m_aValue.m_pValue)); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1314,8 +1347,11 @@ sal_Int32 ORowSetValue::getInt32() const nRet = static_cast<sal_Int32>(*static_cast<sal_Int64*>(m_aValue.m_pValue)); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1384,8 +1420,11 @@ sal_Int64 ORowSetValue::getLong() const nRet = *(sal_Int64*)m_aValue.m_pValue; break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1458,8 +1497,11 @@ float ORowSetValue::getFloat() const nRet = float(*(sal_Int64*)m_aValue.m_pValue); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1534,8 +1576,11 @@ double ORowSetValue::getDouble() const nRet = double(*(sal_Int64*)m_aValue.m_pValue); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1626,6 +1671,11 @@ void ORowSetValue::setFromDouble(const double& _rVal,sal_Int32 _nDatatype) TRACE_ALLOC( sal_Int64 ) } break; + default: + { + m_aValue.m_pValue = new Any(_rVal); + break; + } } m_eTypeKind = _nDatatype; } @@ -1692,7 +1742,11 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const aSeq = *static_cast< Sequence<sal_Int8>*>(m_aValue.m_pValue); break; default: - ; + { + Any aValue = getAny(); + aValue >>= aSeq; + break; + } } } return aSeq; @@ -1734,8 +1788,11 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const } break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aAnyValue = getAny(); + aAnyValue >>= aValue; + break; + } } } return aValue; @@ -1776,8 +1833,11 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const aValue = *static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aAnyValue = getAny(); + aAnyValue >>= aValue; + break; + } } } return aValue; @@ -1826,8 +1886,11 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const aValue = *static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aAnyValue = getAny(); + aAnyValue >>= aValue; + break; + } } } return aValue; @@ -2094,7 +2157,7 @@ void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const break; default: OSL_ENSURE( false, "ORowSetValue::fill: unsupported type!" ); - bReadData = false; + (*this) = _rValueSource.getObject(); break; } if ( bReadData && _bNullable && _rValueSource.wasNull() ) diff --git a/connectivity/source/drivers/adabas/BDriver.cxx b/connectivity/source/drivers/adabas/BDriver.cxx index fe6ce66bcb3f..fc92ebb38b0c 100644 --- a/connectivity/source/drivers/adabas/BDriver.cxx +++ b/connectivity/source/drivers/adabas/BDriver.cxx @@ -462,8 +462,10 @@ void SAL_CALL ODriver::createCatalog( const Sequence< PropertyValue >& info ) th { TDatabaseStruct aDBInfo; fillInfo(info,aDBInfo); - static char envName[] = "DBSERVICE=0"; - putenv( envName ); + + ::rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("DBSERVICE")); + ::rtl::OUString envData(RTL_CONSTASCII_USTRINGPARAM("0")); + osl_setEnvironment(envVar.pData, envData.pData); m_sDbRunDir = m_sDbWorkURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/wrk/")) + aDBInfo.sDBName; String sTemp; diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index c71d620d527c..0c5db12c3355 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -692,6 +692,10 @@ void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeExcept void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException) { + // ::osl::MutexGuard aGuard( m_aMutex ); + //checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + // if ( getResultSetConcurrency() == ResultSetConcurrency::READ_ONLY ) + // throw SQLException(); } // ------------------------------------------------------------------------- @@ -977,7 +981,7 @@ Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& ro sal_Int32 OResultSet::getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { - sal_Int32 nValue=0; + sal_Int32 nValue=ResultSetConcurrency::READ_ONLY; LockTypeEnum eRet; if(!SUCCEEDED(m_pRecordSet->get_LockType(&eRet))) { diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 7cc0cee80109..011d0e89ce7a 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -2599,7 +2599,7 @@ void ODbaseTable::throwInvalidDbaseFormat() // no dbase file const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution( - STR_SQL_NAME_ERROR, + STR_INVALID_DBASE_FILE, "$filename$", getEntry(m_pConnection,m_Name) ) ); ::dbtools::throwGenericSQLException( sError, *this ); diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 94d65cc8a1bc..305e26d386e0 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -1195,7 +1195,9 @@ BOOL OResultSet::Move(IResultSetHelper::Movement eCursorPosition, INT32 nOffset, break; } - if (m_nRowPos == 0) + if ( m_nRowPos < 0 ) + goto Error; + else if (m_nRowPos == 0) { // COUNT(*) in Ergebnisrow packen // (muss die erste und einzige Variable in der Row sein) diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index eff2464ce533..70be592405eb 100644 --- a/connectivity/source/drivers/flat/ETable.cxx +++ b/connectivity/source/drivers/flat/ETable.cxx @@ -159,7 +159,10 @@ void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) (m_cStringDelimiter && m_cStringDelimiter == aField.GetChar(0))) { bNumeric = FALSE; - nStartPosFirstLine2 = nStartPosFirstLine; + if ( m_cStringDelimiter != '\0' ) + aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine2,m_cFieldDelimiter,m_cStringDelimiter); + else + nStartPosFirstLine2 = nStartPosFirstLine; } else { diff --git a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx index 1452df992a74..e7fab6acb6c0 100644 --- a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx @@ -234,7 +234,7 @@ jint read_from_storage_stream_into_buffer( JNIEnv * env, jobject /*obj_this*/,js if ( xIn.is() ) { jsize nLen = env->GetArrayLength(buffer); - if ( nLen < len ) + if ( nLen < len || len <= 0 ) { ThrowException( env, "java/io/IOException", @@ -439,21 +439,17 @@ void write_to_storage_stream_from_buffer( JNIEnv* env, jobject /*obj_this*/, jst if ( xOut.is() ) { jbyte *buf = env->GetByteArrayElements(buffer,NULL); -#ifdef HSQLDB_DBG - OSL_ENSURE(len <= env->GetArrayLength(buffer),"Length is greater than the buffer!"); -#endif - if (JNI_FALSE != env->ExceptionCheck()) { env->ExceptionClear(); OSL_ENSURE(0,"ExceptionClear"); } OSL_ENSURE(buf,"buf is NULL"); - if ( buf ) + if ( buf && len > 0 && len <= env->GetArrayLength(buffer)) { Sequence< ::sal_Int8 > aData(buf + off,len); - xOut->writeBytes(aData); env->ReleaseByteArrayElements(buffer, buf, JNI_ABORT); + xOut->writeBytes(aData); #ifdef HSQLDB_DBG if ( logger ) logger->write( aData.getConstArray(), len ); diff --git a/connectivity/source/drivers/hsqldb/HStorageMap.cxx b/connectivity/source/drivers/hsqldb/HStorageMap.cxx index 0b1ec85697fa..91626906a906 100644 --- a/connectivity/source/drivers/hsqldb/HStorageMap.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx @@ -61,14 +61,15 @@ namespace connectivity { try { - m_xStream.clear(); - m_xSeek.clear(); + m_xStream.clear(); + m_xSeek.clear(); if ( m_xInputStream.is() ) { m_xInputStream->closeInput(); - m_xInputStream.clear(); + m_xInputStream.clear(); } - if ( m_xOutputStream.is() ) + // this is done implicity by the closing of the input stream + else if ( m_xOutputStream.is() ) { m_xOutputStream->closeOutput(); try @@ -83,11 +84,12 @@ namespace connectivity OSL_UNUSED( e ); OSL_ENSURE(0,"Could not dispose OutputStream"); } - m_xOutputStream.clear(); + m_xOutputStream.clear(); } } - catch(Exception& ) + catch(Exception& ex) { + OSL_UNUSED( ex ); OSL_ENSURE(0,"Exception catched!"); } } diff --git a/connectivity/source/drivers/jdbc/Boolean.cxx b/connectivity/source/drivers/jdbc/Boolean.cxx index 2df75283a14b..fd52f3092c0e 100644 --- a/connectivity/source/drivers/jdbc/Boolean.cxx +++ b/connectivity/source/drivers/jdbc/Boolean.cxx @@ -49,20 +49,3 @@ jclass java_lang_Boolean::getMyClass() const { return st_getMyClass(); } - -java_lang_Boolean::java_lang_Boolean( sal_Bool _par0 ): java_lang_Object( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - // Java-Call fuer den Konstruktor absetzen - // temporaere Variable initialisieren - static const char * cSignature = "(Z)V"; - jobject tempObj; - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, "<init>",cSignature, mID); - tempObj = t.pEnv->NewObject( getMyClass(), mID, _par0 ); - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); - // und aufraeumen -} - - diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx index 4866781d23dd..4f5670ace8aa 100644 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -166,14 +166,6 @@ void java_lang_Object::saveRef( JNIEnv * pXEnv, jobject myObj ) } -java_lang_Class * java_lang_Object::getClass() -{ - SDBThreadAttach t; - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getClass","()Ljava/lang/Class;", mID); - return out ? new java_lang_Class( t.pEnv, out ) : NULL; -} - ::rtl::OUString java_lang_Object::toString() const { static jmethodID mID(NULL); diff --git a/connectivity/source/drivers/jdbc/String.cxx b/connectivity/source/drivers/jdbc/String.cxx index e6102fc3a471..f32b0cce4325 100644 --- a/connectivity/source/drivers/jdbc/String.cxx +++ b/connectivity/source/drivers/jdbc/String.cxx @@ -52,26 +52,6 @@ jclass java_lang_String::st_getMyClass() } //-------------------------------------------------------------------------- -java_lang_String::java_lang_String( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - if( !t.pEnv ) - return; - jvalue args[1]; - // Parameter konvertieren - args[0].l = convertwchar_tToJavaString(t.pEnv,_par0); - // Java-Call fuer den Konstruktor absetzen - // temporaere Variable initialisieren - static const char * cSignature = "(Ljava/lang/String;)V"; - jobject tempObj; - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, "<init>",cSignature, mID); - tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args ); - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); - t.pEnv->DeleteLocalRef((jstring)args[0].l); -} -//-------------------------------------------------------------------------- java_lang_String::operator ::rtl::OUString() { SDBThreadAttach t; diff --git a/connectivity/source/drivers/kab/makefile.mk b/connectivity/source/drivers/kab/makefile.mk index 2a0dc5cd8999..219bdd6cd020 100644 --- a/connectivity/source/drivers/kab/makefile.mk +++ b/connectivity/source/drivers/kab/makefile.mk @@ -46,6 +46,9 @@ CFLAGS+=$(KDE_CFLAGS) .IF "$(KDE_ROOT)"!="" EXTRALIBPATHS+=-L$(KDE_ROOT)$/lib +.IF "$(OS)$(CPU)" == "LINUXX" +EXTRALIBPATHS+=-L$(KDE_ROOT)$/lib64 +.ENDIF .ENDIF # === KAB base library ========================== diff --git a/connectivity/source/inc/java/lang/Boolean.hxx b/connectivity/source/inc/java/lang/Boolean.hxx index f1f8081d9780..35655f8c1934 100644 --- a/connectivity/source/inc/java/lang/Boolean.hxx +++ b/connectivity/source/inc/java/lang/Boolean.hxx @@ -44,7 +44,6 @@ namespace connectivity // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: java_lang_Boolean( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} - java_lang_Boolean( sal_Bool _par0 ); static jclass st_getMyClass(); }; } diff --git a/connectivity/source/inc/java/lang/Object.hxx b/connectivity/source/inc/java/lang/Object.hxx index f0bacc2ee840..c00c5e67e06d 100644 --- a/connectivity/source/inc/java/lang/Object.hxx +++ b/connectivity/source/inc/java/lang/Object.hxx @@ -118,8 +118,6 @@ namespace connectivity void clearObject(JNIEnv& rEnv); void clearObject(); - java_lang_Class * getClass(); - virtual ::rtl::OUString toString() const; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() { return m_xFactory; } diff --git a/connectivity/source/inc/java/lang/String.hxx b/connectivity/source/inc/java/lang/String.hxx index 64584dab5e76..3e4bfd6c1399 100644 --- a/connectivity/source/inc/java/lang/String.hxx +++ b/connectivity/source/inc/java/lang/String.hxx @@ -42,7 +42,6 @@ namespace connectivity // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: java_lang_String( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} - java_lang_String( const ::rtl::OUString& _par0 ); operator ::rtl::OUString(); static jclass st_getMyClass(); diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 486d280311d9..8867a940a6ad 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -75,7 +75,8 @@ class Desktop : public Application BE_USERINSTALL_FAILED, BE_LANGUAGE_MISSING, BE_USERINSTALL_NOTENOUGHDISKSPACE, - BE_USERINSTALL_NOWRITEACCESS + BE_USERINSTALL_NOWRITEACCESS, + BE_OFFICECONFIG_BROKEN }; enum BootstrapStatus { diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst index 8029b6ecc9f7..dc5d7a99b2d6 100644 --- a/desktop/prj/build.lst +++ b/desktop/prj/build.lst @@ -3,7 +3,7 @@ dt desktop usr1 - all dt_mkout NULL dt desktop\inc nmake - all dt_inc NULL dt desktop\prj get - all dt_prj NULL dt desktop\res get - all dt_res NULL -dt desktop\source\app nmake - all dt_app dt_migr dt_inc NULL +dt desktop\source\app nmake - all dt_app dt_migr dt_inc dt_dp_misc NULL dt desktop\source\migration nmake - all dt_migr dt_inc NULL dt desktop\source\migration\services nmake - all dt_services dt_inc dt_dp_misc NULL dt desktop\source\so_comp nmake - all dt_so_comp dt_inc NULL @@ -35,7 +35,7 @@ dt desktop\source\deployment\registry\configuration nmake - all dt_dp_registry_c dt desktop\source\deployment\registry\help nmake - all dt_dp_registry_help dt_inc NULL dt desktop\source\deployment\registry\executable nmake - all dt_dp_registry_executable dt_inc NULL dt desktop\scripts nmake - u dt_scripts dt_inc NULL -dt desktop\util nmake - all dt_util dt_app dt_so_comp dt_spl dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr dt_rebase.w NULL +dt desktop\util nmake - all dt_util dt_app dt_pagein.u dt_so_comp dt_spl dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr dt_rebase.w NULL dt desktop\zipintro nmake - all dt_zipintro NULL dt desktop\registry\data\org\openoffice\Office nmake - all sn_regconfig NULL dt desktop\source\registration\com\sun\star\servicetag\resources get - all sn_svctagres NULL diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index bd70305326b4..b60af4ede03e 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -28,6 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" +#include <cstdlib> +#include <vector> + #include <memory> #include <unistd.h> #include "app.hxx" @@ -119,6 +122,7 @@ #include <osl/file.hxx> #include <osl/signal.h> #include <rtl/uuid.h> +#include <rtl/uri.hxx> #include <unotools/pathoptions.hxx> #include <svl/languageoptions.hxx> #include <unotools/internaloptions.hxx> @@ -155,6 +159,11 @@ #include "langselect.hxx" +#if defined MACOSX +#include <errno.h> +#include <sys/wait.h> +#endif + #define DEFINE_CONST_UNICODE(CONSTASCII) UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII)) #define U2S(STRING) ::rtl::OUStringToOString(STRING, RTL_TEXTENCODING_UTF8) @@ -460,6 +469,194 @@ void ReplaceStringHookProc( UniString& rStr ) } } +static const char pLastSyncFileName[] = "lastsynchronized"; +static const sal_Int32 nStrLenLastSync = 16; + +static bool needsSynchronization( + ::rtl::OUString const & baseSynchronizedURL, ::rtl::OUString const & userSynchronizedURL ) +{ + bool bNeedsSync( false ); + + ::osl::DirectoryItem itemUserFile; + ::osl::File::RC err1 = + ::osl::DirectoryItem::get(userSynchronizedURL, itemUserFile); + + //If it does not exist, then there is nothing to be done + if (err1 == ::osl::File::E_NOENT) + { + return true; + } + else if (err1 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access lastsynchronized in user layer"); + return true; //sync just in case + } + + //If last synchronized does not exist in base layer, then do nothing + ::osl::DirectoryItem itemBaseFile; + ::osl::File::RC err2 = ::osl::DirectoryItem::get(baseSynchronizedURL, itemBaseFile); + if (err2 == ::osl::File::E_NOENT) + { + return true; + + } + else if (err2 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access file lastsynchronized in base layer"); + return true; //sync just in case + } + + //compare the modification time of the extension folder and the last + //modified file + ::osl::FileStatus statUser(FileStatusMask_ModifyTime); + ::osl::FileStatus statBase(FileStatusMask_ModifyTime); + if (itemUserFile.getFileStatus(statUser) == ::osl::File::E_None) + { + if (itemBaseFile.getFileStatus(statBase) == ::osl::File::E_None) + { + TimeValue timeUser = statUser.getModifyTime(); + TimeValue timeBase = statBase.getModifyTime(); + + if (timeUser.Seconds < timeBase.Seconds) + bNeedsSync = true; + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + + return bNeedsSync; +} + +static ::rtl::OUString getBrandSharePreregBundledPathURL() +{ + ::rtl::OUString url( + RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/share/prereg/bundled")); + + ::rtl::Bootstrap::expandMacros(url); + return url; +} + +static ::rtl::OUString getUserBundledExtPathURL() +{ + ::rtl::OUString folder( RTL_CONSTASCII_USTRINGPARAM( "$BUNDLED_EXTENSIONS_USER" )); + ::rtl::Bootstrap::expandMacros(folder); + + return folder; +} + +static ::rtl::OUString getLastSyncFileURLFromBrandInstallation() +{ + ::rtl::OUString aURL = getBrandSharePreregBundledPathURL(); + ::sal_Int32 nLastIndex = aURL.lastIndexOf('/'); + + ::rtl::OUStringBuffer aTmp( aURL ); + + if ( nLastIndex != aURL.getLength()-1 ) + aTmp.appendAscii( "/" ); + aTmp.appendAscii( pLastSyncFileName ); + + return aTmp.makeStringAndClear(); +} + +static ::rtl::OUString getLastSyncFileURLFromUserInstallation() +{ + ::rtl::OUString aUserBundledPathURL = getUserBundledExtPathURL(); + ::sal_Int32 nLastIndex = aUserBundledPathURL.lastIndexOf('/'); + + ::rtl::OUStringBuffer aTmp( aUserBundledPathURL ); + + if ( nLastIndex != aUserBundledPathURL.getLength()-1 ) + aTmp.appendAscii( "/" ); + aTmp.appendAscii( pLastSyncFileName ); + + return aTmp.makeStringAndClear(); +} + +static osl::FileBase::RC copy_bundled_recursive( + const rtl::OUString& srcUnqPath, + const rtl::OUString& dstUnqPath, + sal_Int32 TypeToCopy ) +throw() +{ + osl::FileBase::RC err = osl::FileBase::E_None; + + if( TypeToCopy == -1 ) // Document + { + err = osl::File::copy( srcUnqPath,dstUnqPath ); + } + else if( TypeToCopy == +1 ) // Folder + { + osl::Directory aDir( srcUnqPath ); + aDir.open(); + + err = osl::Directory::create( dstUnqPath ); + osl::FileBase::RC next = err; + if( err == osl::FileBase::E_None || + err == osl::FileBase::E_EXIST ) + { + err = osl::FileBase::E_None; + sal_Int32 n_Mask = FileStatusMask_FileURL | FileStatusMask_FileName | FileStatusMask_Type; + + osl::DirectoryItem aDirItem; + + while( err == osl::FileBase::E_None && ( next = aDir.getNextItem( aDirItem ) ) == osl::FileBase::E_None ) + { + sal_Bool IsDoc = false; + sal_Bool bFilter = false; + osl::FileStatus aFileStatus( n_Mask ); + aDirItem.getFileStatus( aFileStatus ); + if( aFileStatus.isValid( FileStatusMask_Type ) ) + IsDoc = aFileStatus.getFileType() == osl::FileStatus::Regular; + + // Getting the information for the next recursive copy + sal_Int32 newTypeToCopy = IsDoc ? -1 : +1; + + rtl::OUString newSrcUnqPath; + if( aFileStatus.isValid( FileStatusMask_FileURL ) ) + newSrcUnqPath = aFileStatus.getFileURL(); + + rtl::OUString newDstUnqPath = dstUnqPath; + rtl::OUString tit; + if( aFileStatus.isValid( FileStatusMask_FileName ) ) + { + ::rtl::OUString aFileName = aFileStatus.getFileName(); + tit = rtl::Uri::encode( aFileName, + rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ); + + // Special treatment for "lastsychronized" file. Must not be + // copied from the bundled folder! + if ( IsDoc && aFileName.equalsAscii( pLastSyncFileName )) + bFilter = true; + } + + if( newDstUnqPath.lastIndexOf( sal_Unicode('/') ) != newDstUnqPath.getLength()-1 ) + newDstUnqPath += rtl::OUString::createFromAscii( "/" ); + + newDstUnqPath += tit; + + if (( newSrcUnqPath != dstUnqPath ) && !bFilter ) + err = copy_bundled_recursive( newSrcUnqPath,newDstUnqPath, newTypeToCopy ); + } + + if( err == osl::FileBase::E_None && next != osl::FileBase::E_NOENT ) + err = next; + } + aDir.close(); + } + + return err; +} + Desktop::Desktop() : m_bServicesRegistered( false ) , m_aBootstrapError( BE_OK ) @@ -477,6 +674,24 @@ void Desktop::Init() RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Init" ); SetBootstrapStatus(BS_OK); + // Check for lastsynchronized file for bundled extensions in the user directory + // and test if synchronzation is necessary! + { + ::rtl::OUString aUserLastSyncFilePathURL = getLastSyncFileURLFromUserInstallation(); + ::rtl::OUString aPreregSyncFilePathURL = getLastSyncFileURLFromBrandInstallation(); + + if ( needsSynchronization( aPreregSyncFilePathURL, aUserLastSyncFilePathURL )) + { + rtl::OUString aUserPath = getUserBundledExtPathURL(); + rtl::OUString aPreregBundledPath = getBrandSharePreregBundledPathURL(); + + // copy bundled folder to the user directory + osl::FileBase::RC rc = osl::Directory::createPath(aUserPath); + (void) rc; + copy_bundled_recursive( aPreregBundledPath, aUserPath, +1 ); + } + } + // create service factory... Reference < XMultiServiceFactory > rSMgr = CreateApplicationServiceManager(); if( rSMgr.is() ) @@ -492,7 +707,12 @@ void Desktop::Init() { // prepare language if ( !LanguageSelection::prepareLanguage() ) - SetBootstrapError( BE_LANGUAGE_MISSING ); + { + if ( LanguageSelection::getStatus() == LanguageSelection::LS_STATUS_CANNOT_DETERMINE_LANGUAGE ) + SetBootstrapError( BE_LANGUAGE_MISSING ); + else + SetBootstrapError( BE_OFFICECONFIG_BROKEN ); + } } if ( GetBootstrapError() == BE_OK ) @@ -873,6 +1093,17 @@ void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError ) FatalError( aMessage); } + else if ( aBootstrapError == BE_OFFICECONFIG_BROKEN ) + { + OUString aMessage; + OUStringBuffer aDiagnosticMessage( 100 ); + OUString aErrorMsg; + aErrorMsg = GetMsgString( STR_CONFIG_ERR_ACCESS_GENERAL, + OUString( RTL_CONSTASCII_USTRINGPARAM( "A general error occurred while accessing your central configuration." )) ); + aDiagnosticMessage.append( aErrorMsg ); + aMessage = MakeStartupErrorMessage( aDiagnosticMessage.makeStringAndClear() ); + FatalError(aMessage); + } else if ( aBootstrapError == BE_USERINSTALL_FAILED ) { OUString aMessage; @@ -1101,28 +1332,79 @@ sal_Bool Desktop::SaveTasks() sal_False); } -#ifdef MACOSX -static void DoRestart() -{ - oslProcess process; - oslProcessError error; - OUString sExecutableFile; - - osl_getExecutableFile( &sExecutableFile.pData ); - - error = osl_executeProcess( - sExecutableFile.pData, - NULL, - 0, - 0, - NULL, - NULL, - NULL, - 0, - &process - ); -} +namespace { + +void restartOnMac(bool passArguments) { +#if defined MACOSX + OfficeIPCThread::DisableOfficeIPCThread(); + rtl::OUString execUrl; + OSL_VERIFY(osl_getExecutableFile(&execUrl.pData) == osl_Process_E_None); + rtl::OUString execPath; + rtl::OString execPath8; + if ((osl::FileBase::getSystemPathFromFileURL(execUrl, execPath) + != osl::FileBase::E_None) || + !execPath.convertToString( + &execPath8, osl_getThreadTextEncoding(), + (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | + RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))) + { + std::abort(); + } + std::vector< rtl::OString > args; + args.push_back(execPath8); + bool wait = false; + if (passArguments) { + sal_uInt32 n = osl_getCommandArgCount(); + for (sal_uInt32 i = 0; i < n; ++i) { + rtl::OUString arg; + OSL_VERIFY(osl_getCommandArg(i, &arg.pData) == osl_Process_E_None); + if (arg.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("-accept="))) { + wait = true; + } + rtl::OString arg8; + if (!arg.convertToString( + &arg8, osl_getThreadTextEncoding(), + (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | + RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))) + { + std::abort(); + } + args.push_back(arg8); + } + } + std::vector< char const * > argPtrs; + for (std::vector< rtl::OString >::iterator i(args.begin()); i != args.end(); + ++i) + { + argPtrs.push_back(i->getStr()); + } + argPtrs.push_back(0); + execv(execPath8.getStr(), const_cast< char ** >(&argPtrs[0])); + if (errno == ENOTSUP) { // happens when multithreaded on OS X < 10.6 + pid_t pid = fork(); + if (pid == 0) { + execv(execPath8.getStr(), const_cast< char ** >(&argPtrs[0])); + } else if (pid > 0) { + // Two simultaneously running soffice processes lead to two dock + // icons, so avoid waiting here unless it must be assumed that the + // process invoking soffice itself wants to wait for soffice to + // finish: + if (!wait) { + return; + } + int stat; + if (waitpid(pid, &stat, 0) == pid && WIFEXITED(stat)) { + _exit(WEXITSTATUS(stat)); + } + } + } + std::abort(); +#else + (void) passArguments; // avoid warnings #endif +} + +} USHORT Desktop::Exception(USHORT nError) { @@ -1193,9 +1475,7 @@ USHORT Desktop::Exception(USHORT nError) OfficeIPCThread::DisableOfficeIPCThread(); if( pSignalHandler ) DELETEZ( pSignalHandler ); -#ifdef MACOSX - DoRestart(); -#endif + restartOnMac(false); _exit( ExitHelper::E_CRASH_WITH_RESTART ); } else @@ -1278,6 +1558,9 @@ void Desktop::Main() std::auto_ptr<SvtLanguageOptions> pLanguageOptions; std::auto_ptr<SvtPathOptions> pPathOptions; + sal_Bool bRestartRequested( sal_False ); + sal_Bool bUseSystemFileDialog(sal_True); + int nAcquireCount( 0 ); Reference < css::document::XEventListener > xGlobalBroadcaster; try { @@ -1407,6 +1690,13 @@ void Desktop::Main() ( xSMgr->createInstance( DEFINE_CONST_UNICODE( "com.sun.star.frame.GlobalEventBroadcaster" ) ), UNO_QUERY ); + /* ensure existance of a default window that messages can be dispatched to + This is for the benefit of testtool which uses PostUserEvent extensively + and else can deadlock while creating this window from another tread while + the main thread is not yet in the event loop. + */ + Application::GetDefaultDevice(); + // initialize test-tool library (if available) RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ tools::InitTestToolLib" ); tools::InitTestToolLib(); @@ -1471,58 +1761,80 @@ void Desktop::Main() impl_checkRecoveryState(bCrashed, bExistsRecoveryData, bExistsSessionData); RTL_LOGFILE_CONTEXT_TRACE( aLog, "} impl_checkRecoveryState" ); - if ( - (pCmdLineArgs->IsEmptyOrAcceptOnly() ) && - (SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SSTARTMODULE)) && - (!bExistsRecoveryData ) && - (!bExistsSessionData ) && - (!Application::AnyInput( INPUT_APPEVENT ) ) - ) + Reference< ::com::sun::star::task::XRestartManager > xRestartManager; { - RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create BackingComponent" ); - Reference< XFrame > xDesktopFrame( xSMgr->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY ); - if (xDesktopFrame.is()) + ::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 + bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); + + if ( pCmdLineArgs->IsHeadless() ) + { + // Ensure that we use not the system file dialogs as + // headless mode relies on Application::EnableHeadlessMode() + // which does only work for VCL dialogs!! + SvtMiscOptions aMiscOptions; + bUseSystemFileDialog = aMiscOptions.UseSystemFileDialog(); + aMiscOptions.SetUseSystemFileDialog( sal_False ); + } + + if ( !bRestartRequested ) + { + if ( + (pCmdLineArgs->IsEmptyOrAcceptOnly() ) && + (SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SSTARTMODULE)) && + (!bExistsRecoveryData ) && + (!bExistsSessionData ) && + (!Application::AnyInput( INPUT_APPEVENT ) ) + ) { -// SetSplashScreenProgress(60); - Reference< XFrame > xBackingFrame; - Reference< ::com::sun::star::awt::XWindow > xContainerWindow; - - xBackingFrame = xDesktopFrame->findFrame(OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" )), 0); - if (xBackingFrame.is()) - xContainerWindow = xBackingFrame->getContainerWindow(); - if (xContainerWindow.is()) + RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create BackingComponent" ); + Reference< XFrame > xDesktopFrame( xSMgr->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY ); + if (xDesktopFrame.is()) { - // set the WB_EXT_DOCUMENT style. Normally, this is done by the TaskCreator service when a "_blank" - // frame/window is created. Since we do not use the TaskCreator here, we need to mimic its behavior, - // otherwise documents loaded into this frame will later on miss functionality depending on the style. - Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); - OSL_ENSURE( pContainerWindow, "Desktop::Main: no implementation access to the frame's container window!" ); - pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT ); - - SetSplashScreenProgress(75); - Sequence< Any > lArgs(1); - lArgs[0] <<= xContainerWindow; - - Reference< XController > xBackingComp( - xSMgr->createInstanceWithArguments(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule") ), lArgs), - UNO_QUERY); -// SetSplashScreenProgress(80); - if (xBackingComp.is()) + // SetSplashScreenProgress(60); + Reference< XFrame > xBackingFrame; + Reference< ::com::sun::star::awt::XWindow > xContainerWindow; + + xBackingFrame = xDesktopFrame->findFrame(OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" )), 0); + if (xBackingFrame.is()) + xContainerWindow = xBackingFrame->getContainerWindow(); + if (xContainerWindow.is()) { - Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY); - // Attention: You MUST(!) call setComponent() before you call attachFrame(). - // Because the backing component set the property "IsBackingMode" of the frame - // to true inside attachFrame(). But setComponent() reset this state everytimes ... - xBackingFrame->setComponent(xBackingWin, xBackingComp); - SetSplashScreenProgress(100); - xBackingComp->attachFrame(xBackingFrame); - CloseSplashScreen(); - xContainerWindow->setVisible(sal_True); + // set the WB_EXT_DOCUMENT style. Normally, this is done by the TaskCreator service when a "_blank" + // frame/window is created. Since we do not use the TaskCreator here, we need to mimic its behavior, + // otherwise documents loaded into this frame will later on miss functionality depending on the style. + Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); + OSL_ENSURE( pContainerWindow, "Desktop::Main: no implementation access to the frame's container window!" ); + pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT ); + + SetSplashScreenProgress(75); + Sequence< Any > lArgs(1); + lArgs[0] <<= xContainerWindow; + + Reference< XController > xBackingComp( + xSMgr->createInstanceWithArguments(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule") ), lArgs), + UNO_QUERY); + // SetSplashScreenProgress(80); + if (xBackingComp.is()) + { + Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY); + // Attention: You MUST(!) call setComponent() before you call attachFrame(). + // Because the backing component set the property "IsBackingMode" of the frame + // to true inside attachFrame(). But setComponent() reset this state everytimes ... + xBackingFrame->setComponent(xBackingWin, xBackingComp); + SetSplashScreenProgress(100); + xBackingComp->attachFrame(xBackingFrame); + CloseSplashScreen(); + xContainerWindow->setVisible(sal_True); + } } } + RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create BackingComponent" ); } - RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create BackingComponent" ); } } catch ( com::sun::star::lang::WrappedTargetException& wte ) @@ -1557,108 +1869,83 @@ void Desktop::Main() aOptions.SetVCLSettings(); // SetSplashScreenProgress(60); - Application::SetFilterHdl( LINK( this, Desktop, ImplInitFilterHdl ) ); - - sal_Bool bTerminateRequested = sal_False; - - // Preload function depends on an initialized sfx application! - SetSplashScreenProgress(75); - - sal_Bool bUseSystemFileDialog(sal_True); - if ( pCmdLineArgs->IsHeadless() ) + if ( !bRestartRequested ) { - // Ensure that we use not the system file dialogs as - // headless mode relies on Application::EnableHeadlessMode() - // which does only work for VCL dialogs!! - SvtMiscOptions aMiscOptions; - bUseSystemFileDialog = aMiscOptions.UseSystemFileDialog(); - aMiscOptions.SetUseSystemFileDialog( sal_False ); - } + Application::SetFilterHdl( LINK( this, Desktop, ImplInitFilterHdl ) ); - // use system window dialogs - Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_DIALOG ); + sal_Bool bTerminateRequested = sal_False; -// SetSplashScreenProgress(80); + // Preload function depends on an initialized sfx application! + SetSplashScreenProgress(75); - if ( !bTerminateRequested && !pCmdLineArgs->IsInvisible() && - !pCmdLineArgs->IsNoQuickstart() ) - InitializeQuickstartMode( xSMgr ); + // use system window dialogs + Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_DIALOG ); - RTL_LOGFILE_CONTEXT( aLog2, "desktop (cd100003) createInstance com.sun.star.frame.Desktop" ); - try - { - Reference< XDesktop > xDesktop( xSMgr->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY ); - if ( xDesktop.is() ) - xDesktop->addTerminateListener( new OfficeIPCThreadController ); - SetSplashScreenProgress(100); - } - catch ( com::sun::star::uno::Exception& e ) - { - FatalError( MakeStartupErrorMessage(e.Message) ); - return; - } - /* - catch ( ... ) - { - FatalError( MakeStartupErrorMessage( - OUString::createFromAscii( - "Unknown error during startup (TD/Desktop service).\nInstallation could be damaged."))); - return; - } - */ + // SetSplashScreenProgress(80); - // Release solar mutex just before we wait for our client to connect - int nAcquireCount = 0; - ::vos::IMutex& rMutex = Application::GetSolarMutex(); - if ( rMutex.tryToAcquire() ) - nAcquireCount = Application::ReleaseSolarMutex() - 1; + if ( !bTerminateRequested && !pCmdLineArgs->IsInvisible() && + !pCmdLineArgs->IsNoQuickstart() ) + InitializeQuickstartMode( xSMgr ); - // Post user event to startup first application component window - // We have to send this OpenClients message short before execute() to - // minimize the risk that this message overtakes type detection contruction!! - Application::PostUserEvent( LINK( this, Desktop, OpenClients_Impl ) ); + RTL_LOGFILE_CONTEXT( aLog2, "desktop (cd100003) createInstance com.sun.star.frame.Desktop" ); + try + { + Reference< XDesktop > xDesktop( xSMgr->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY ); + if ( xDesktop.is() ) + xDesktop->addTerminateListener( new OfficeIPCThreadController ); + SetSplashScreenProgress(100); + } + catch ( com::sun::star::uno::Exception& e ) + { + FatalError( MakeStartupErrorMessage(e.Message) ); + return; + } + /* + catch ( ... ) + { + FatalError( MakeStartupErrorMessage( + OUString::createFromAscii( + "Unknown error during startup (TD/Desktop service).\nInstallation could be damaged."))); + return; + } + */ - // Post event to enable acceptors - Application::PostUserEvent( LINK( this, Desktop, EnableAcceptors_Impl) ); + // Post user event to startup first application component window + // We have to send this OpenClients message short before execute() to + // minimize the risk that this message overtakes type detection contruction!! + Application::PostUserEvent( LINK( this, Desktop, OpenClients_Impl ) ); - // The configuration error handler currently is only for startup - aConfigErrHandler.deactivate(); + // Post event to enable acceptors + Application::PostUserEvent( LINK( this, Desktop, EnableAcceptors_Impl) ); - // Acquire solar mutex just before we enter our message loop - if ( nAcquireCount ) - Application::AcquireSolarMutex( nAcquireCount ); + // The configuration error handler currently is only for startup + aConfigErrHandler.deactivate(); - // call Application::Execute to process messages in vcl message loop - RTL_LOGFILE_PRODUCT_TRACE( "PERFORMANCE - enter Application::Execute()" ); + // call Application::Execute to process messages in vcl message loop + RTL_LOGFILE_PRODUCT_TRACE( "PERFORMANCE - enter Application::Execute()" ); - Reference< ::com::sun::star::task::XRestartManager > xRestartManager; - try - { - // The JavaContext contains an interaction handler which is used when - // the creation of a Java Virtual Machine fails - com::sun::star::uno::ContextLayer layer2( - new svt::JavaContext( com::sun::star::uno::getCurrentContext() ) ); + try + { + // The JavaContext contains an interaction handler which is used when + // the creation of a Java Virtual Machine fails + com::sun::star::uno::ContextLayer layer2( + new svt::JavaContext( com::sun::star::uno::getCurrentContext() ) ); - ::comphelper::ComponentContext aContext( xSMgr ); - xRestartManager.set( aContext.getSingleton( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.OfficeRestartManager" ) ) ), UNO_QUERY ); - if ( !xRestartManager.is() || !xRestartManager->isRestartRequested( sal_True ) ) Execute(); - } - catch(const com::sun::star::document::CorruptedFilterConfigurationException& exFilterCfg) - { - OfficeIPCThread::SetDowning(); - FatalError( MakeStartupErrorMessage(exFilterCfg.Message) ); - } - catch(const com::sun::star::configuration::CorruptedConfigurationException& exAnyCfg) - { - OfficeIPCThread::SetDowning(); - FatalError( MakeStartupErrorMessage(exAnyCfg.Message) ); + } + catch(const com::sun::star::document::CorruptedFilterConfigurationException& exFilterCfg) + { + OfficeIPCThread::SetDowning(); + FatalError( MakeStartupErrorMessage(exFilterCfg.Message) ); + } + catch(const com::sun::star::configuration::CorruptedConfigurationException& exAnyCfg) + { + OfficeIPCThread::SetDowning(); + FatalError( MakeStartupErrorMessage(exAnyCfg.Message) ); + } } - // check whether the shutdown is caused by restart - sal_Bool bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); - if (xGlobalBroadcaster.is()) { css::document::EventObject aEvent; @@ -1693,9 +1980,7 @@ void Desktop::Main() RTL_LOGFILE_CONTEXT_TRACE( aLog, "FINISHED WITH Destop::Main" ); if ( bRestartRequested ) { -#ifdef MACOSX - DoRestart(); -#endif + restartOnMac(true); // wouldn't the solution be more clean if SalMain returns the exit code to the system? _exit( ExitHelper::E_NORMAL_RESTART ); } diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index 5e2145b03729..9df8d82a37ff 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -64,10 +64,12 @@ namespace desktop { static char const SOFFICE_BOOTSTRAP[] = "Bootstrap"; static char const SOFFICE_STARTLANG[] = "STARTLANG"; + sal_Bool LanguageSelection::bFoundLanguage = sal_False; OUString LanguageSelection::aFoundLanguage; -const OUString LanguageSelection::usFallbackLanguage = OUString::createFromAscii("en-US"); +LanguageSelection::LanguageSelectionStatus LanguageSelection::m_eStatus = LS_STATUS_OK; +const OUString LanguageSelection::usFallbackLanguage = OUString::createFromAscii("en-US"); static sal_Bool existsURL( OUString const& sURL ) { @@ -122,6 +124,7 @@ Locale LanguageSelection::IsoStringToLocale(const OUString& str) bool LanguageSelection::prepareLanguage() { + m_eStatus = LS_STATUS_OK; OUString sConfigSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"); Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); Reference< XLocalizable > theConfigProvider; @@ -131,7 +134,9 @@ bool LanguageSelection::prepareLanguage() } catch(const Exception&) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } + if(!theConfigProvider.is()) return false; @@ -149,6 +154,7 @@ bool LanguageSelection::prepareLanguage() } catch(const Exception&) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } // #i32939# use system locale to set document default locale @@ -162,6 +168,7 @@ bool LanguageSelection::prepareLanguage() } catch (Exception&) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } // get the selected UI language as string @@ -350,8 +357,10 @@ OUString LanguageSelection::getLanguageString() aFoundLanguage = usFallbackLanguage; return aFoundLanguage; } + // fallback didn't work use first installed language aUserLanguage = getFirstInstalledLanguage(); + bFoundLanguage = sal_True; aFoundLanguage = aUserLanguage; return aFoundLanguage; @@ -455,7 +464,7 @@ sal_Bool LanguageSelection::isInstalledLanguage(OUString& usLocale, sal_Bool bEx // requested locale starts with the installed locale // (i.e. installed locale has index 0 in requested locale) bInstalled = sal_True; - usLocale = seqLanguages[i]; + usLocale = seqLanguages[i]; break; } } @@ -484,10 +493,12 @@ OUString LanguageSelection::getUserLanguage() } catch ( NoSuchElementException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } catch ( WrappedTargetException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } } @@ -506,10 +517,12 @@ OUString LanguageSelection::getSystemLanguage() } catch ( NoSuchElementException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } catch ( WrappedTargetException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } } @@ -533,9 +546,13 @@ void LanguageSelection::resetUserLanguage() { OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); OSL_ENSURE(sal_False, aMsg.getStr()); + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } - } +LanguageSelection::LanguageSelectionStatus LanguageSelection::getStatus() +{ + return m_eStatus; +} } // namespace desktop diff --git a/desktop/source/app/langselect.hxx b/desktop/source/app/langselect.hxx index 60308164690f..bdf3cd6364de 100644 --- a/desktop/source/app/langselect.hxx +++ b/desktop/source/app/langselect.hxx @@ -40,10 +40,24 @@ namespace desktop class LanguageSelection { +public: + enum LanguageSelectionStatus + { + LS_STATUS_OK, + LS_STATUS_CANNOT_DETERMINE_LANGUAGE, + LS_STATUS_CONFIGURATIONACCESS_BROKEN + }; + + static com::sun::star::lang::Locale IsoStringToLocale(const rtl::OUString& str); + static rtl::OUString getLanguageString(); + static bool prepareLanguage(); + static LanguageSelectionStatus getStatus(); + private: static const rtl::OUString usFallbackLanguage; static rtl::OUString aFoundLanguage; static sal_Bool bFoundLanguage; + static LanguageSelectionStatus m_eStatus; static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getConfigAccess(const sal_Char* pPath, sal_Bool bUpdate=sal_False); @@ -55,11 +69,6 @@ private: static rtl::OUString getSystemLanguage(); static void resetUserLanguage(); static void setDefaultLanguage(const rtl::OUString&); - -public: - static com::sun::star::lang::Locale IsoStringToLocale(const rtl::OUString& str); - static rtl::OUString getLanguageString(); - static bool prepareLanguage(); }; } //namespace desktop diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 1a66ff38e4a4..78b29624b16e 100755..100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -372,11 +372,13 @@ MENU_COMMAND ExtBoxWithBtns_Impl::ShowPopupMenu( const Point & rPos, const long if ( ! GetEntryData( nPos )->m_bLocked ) { - if ( GetEntryData( nPos )->m_eState == REGISTERED ) - aPopup.InsertItem( CMD_DISABLE, DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) ); - else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE ) - aPopup.InsertItem( CMD_ENABLE, DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) ); - + if ( GetEntryData( nPos )->m_bUser ) + { + if ( GetEntryData( nPos )->m_eState == REGISTERED ) + aPopup.InsertItem( CMD_DISABLE, DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) ); + else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE ) + aPopup.InsertItem( CMD_ENABLE, DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) ); + } aPopup.InsertItem( CMD_REMOVE, DialogHelper::getResourceString( RID_CTX_ITEM_REMOVE ) ); } @@ -1147,13 +1149,13 @@ void ExtMgrDialog::Resize() { ImplControlValue aValue; bool bNativeOK; - Region aControlRegion( Rectangle( (const Point&)Point(), m_aProgressBar.GetSizePixel() ) ); - Region aNativeControlRegion, aNativeContentRegion; + Rectangle aControlRegion( Point( 0, 0 ), m_aProgressBar.GetSizePixel() ); + Rectangle aNativeControlRegion, aNativeContentRegion; if( (bNativeOK = GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) != FALSE ) { - nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + nProgressHeight = aNativeControlRegion.GetHeight(); } } @@ -1590,13 +1592,13 @@ void UpdateRequiredDialog::Resize() { ImplControlValue aValue; bool bNativeOK; - Region aControlRegion( Rectangle( (const Point&)Point(), m_aProgressBar.GetSizePixel() ) ); - Region aNativeControlRegion, aNativeContentRegion; + Rectangle aControlRegion( Point( 0, 0 ), m_aProgressBar.GetSizePixel() ); + Rectangle aNativeControlRegion, aNativeContentRegion; if( (bNativeOK = GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) != FALSE ) { - nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + nProgressHeight = aNativeControlRegion.GetHeight(); } } diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 24b47aa223e3..24b47aa223e3 100644..100755 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx index 762f50296690..762f50296690 100644..100755 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index de9d97db2b48..c82973f1b680 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -1136,6 +1136,14 @@ sal_Bool ExtensionManager::synchronize( bModified |= m_bundledRepository->synchronize(xAbortChannel, xCmdEnv); progressBundled.update(OUSTR("\n\n")); + //Always determine the active extension. This is necessary for the + //first-start optimization. The setup creates the registration data for the + //bundled extensions (brand_layer/share/prereg/bundled), which is copied to the user + //installation (user_installation/extension/bundled) when a user starts OOo + //for the first time after running setup. All bundled extensions are registered + //at that moment. However, extensions with the same identifier can be in the + //shared or user repository, in which case the respective bundled extensions must + //be revoked. try { const uno::Sequence<uno::Sequence<Reference<deploy::XPackage> > > diff --git a/desktop/source/deployment/manager/dp_properties.cxx b/desktop/source/deployment/manager/dp_properties.cxx index df579944c6e4..9a181d1573e5 100644 --- a/desktop/source/deployment/manager/dp_properties.cxx +++ b/desktop/source/deployment/manager/dp_properties.cxx @@ -2,7 +2,7 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * diff --git a/desktop/source/deployment/manager/dp_properties.hxx b/desktop/source/deployment/manager/dp_properties.hxx index 97fc8b8c5394..a1b953ce8376 100644 --- a/desktop/source/deployment/manager/dp_properties.hxx +++ b/desktop/source/deployment/manager/dp_properties.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dp_manager.h,v $ - * $Revision: 1.17 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index fe3490903043..cfdac4068130 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -589,6 +589,11 @@ void TRACE(::rtl::OString const & sText) void syncRepositories(Reference<ucb::XCommandEnvironment> const & xCmdEnv) { + OUString sDisable; + ::rtl::Bootstrap::get( OUSTR( "DISABLE_EXTENSION_SYNCHRONIZATION" ), sDisable, OUString() ); + if (sDisable.getLength() > 0) + return; + Reference<deployment::XExtensionManager> xExtensionManager; //synchronize shared before bundled otherewise there are //more revoke and registration calls. diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 9ea6e8227340..3c6680065db5 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -359,16 +359,11 @@ void BackendImpl::configmgrini_verify_init( do { OUString token( line.getToken( 0, ' ', index ).trim() ); if (token.getLength() > 0) { - // cleanup, check if existing: - if (create_ucb_content( - 0, expandUnoRcTerm(token), xCmdEnv, - false /* no throw */ )) { - //The file may not exist anymore if a shared or bundled - //extension was removed, but it can still be in the configmgrini. - //After running XExtensionManager::synchronize, the configmgrini is - //cleaned up - m_xcs_files.push_back( token ); - } + //The file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the configmgrini. + //After running XExtensionManager::synchronize, the configmgrini is + //cleaned up + m_xcs_files.push_back( token ); } } while (index >= 0); @@ -378,31 +373,15 @@ void BackendImpl::configmgrini_verify_init( sal_Int32 index = sizeof ("DATA=") - 1; do { OUString token( line.getToken( 0, ' ', index ).trim() ); - if (token.getLength() > 0) { + if (token.getLength() > 0) + { if (token[ 0 ] == '?') token = token.copy( 1 ); - // cleanup, check if existing: - if (create_ucb_content( - 0, expandUnoRcTerm(token), - xCmdEnv, false /* no throw */ )) { - //The file may not exist anymore if a shared or bundled - //extension was removed, but it can still be in the configmgrini. - //After running XExtensionManager::synchronize, the configmgrini is - //cleaned up - m_xcu_files.push_back( token ); - } - else - { - //Check if it was removed. Only when the file contained %origin, so that - //a new file was writen in the user installation (e.g. $BUNDLED_EXTENSIONS_USER) - //See also ConfigurationBackendDb.iniEntry - ::std::list<OUString> iniEntries = getAllIniEntries(); - if (::std::find(iniEntries.begin(), iniEntries.end(), token) - != iniEntries.end()) - m_xcu_files.push_back( token ); - else - OSL_ENSURE(0, "Extension manager: Invalid configmgr.ini entry."); - } + //The file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the configmgrini. + //After running XExtensionManager::synchronize, the configmgrini is + //cleaned up + m_xcu_files.push_back( token ); } } while (index >= 0); @@ -502,6 +481,8 @@ bool BackendImpl::removeFromConfigmgrIni( { //in case the xcu contained %origin% then the configmr.ini contains the //url to the file in the user installation (e.g. $BUNDLED_EXTENSIONS_USER) + //However, m_url (getURL()) contains the URL for the file in the actual + //extension installatation. ::boost::optional<ConfigurationBackendDb::Data> data = readDataFromDb(url_); if (data) i = std::find(rSet.begin(), rSet.end(), data->iniEntry); @@ -757,10 +738,17 @@ void BackendImpl::PackageImpl::processPackage_( } that->m_registeredPackages->erase(i->first); } - ::ucbhelper::Content( - makeURL( that->getCachePath(), OUSTR("registry") ), - xCmdEnv ).executeCommand( - OUSTR("delete"), Any( true /* delete physically */ ) ); + try + { + ::ucbhelper::Content( + makeURL( that->getCachePath(), OUSTR("registry") ), + xCmdEnv ).executeCommand( + OUSTR("delete"), Any( true /* delete physically */ ) ); + } + catch(Exception&) + { + OSL_ASSERT(0); + } } that->deleteDataFromDb(getURL()); diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx index 845ba88cb813..2a02c6d8efa0 100644 --- a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dp_package.cxx,v $ - * $Revision: 1.34.16.2 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx index 1b6c4f8973a4..7023897bd8de 100644 --- a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx +++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dp_backend.h,v $ - * $Revision: 1.18 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index c5e440a2a825..0f309a5b729f 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -129,7 +129,9 @@ public: virtual Reference<deployment::XPackage> SAL_CALL bindPackage( OUString const & url, OUString const & mediaType, sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) - throw (deployment::DeploymentException, CommandFailedException, + throw (deployment::DeploymentException, + deployment::InvalidRemovedParameterException, + CommandFailedException, lang::IllegalArgumentException, RuntimeException); virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); @@ -461,7 +463,8 @@ void PackageRegistryImpl::update() throw (RuntimeException) Reference<deployment::XPackage> PackageRegistryImpl::bindPackage( OUString const & url, OUString const & mediaType_, sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) - throw (deployment::DeploymentException, CommandFailedException, + throw (deployment::DeploymentException, deployment::InvalidRemovedParameterException, + CommandFailedException, lang::IllegalArgumentException, RuntimeException) { check(); diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx index 976a6281a2bd..ff1044910985 100644 --- a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dp_package.cxx,v $ - * $Revision: 1.34.16.2 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx index 4f17eeda24a6..80cd33771a34 100644 --- a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dp_backend.h,v $ - * $Revision: 1.18 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index 3bf67e0c050b..8ec9a39d5050 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dp_package.cxx,v $ - * $Revision: 1.34.16.2 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx index edf7dfdfc284..c7b730fd1b99 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dp_backend.h,v $ - * $Revision: 1.18 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 2ad6478b665c..feb55d0af3bf 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -866,14 +866,10 @@ void BackendImpl::PackageImpl::processPackage_( try { xPackage->registerPackage( startup, xSubAbortChannel, xCmdEnv ); } - catch (RuntimeException &) { - throw; - } - catch (ucb::CommandAbortedException &) { - throw; - } - catch (Exception &) { - // CommandFailedException, DeploymentException: + catch (Exception &) + { + //We even try a rollback if the user cancelled the action (CommandAbortedException) + //in order to prevent invalid database entries. Any exc( ::cppu::getCaughtException() ); // try to handle exception, notify: bool approve = false, abort = false; @@ -904,14 +900,8 @@ void BackendImpl::PackageImpl::processPackage_( bundle[ pos ]->revokePackage( xSubAbortChannel, xCmdEnv ); } - catch (RuntimeException &) { - throw; - } - catch (ucb::CommandAbortedException &) { - throw; - } - catch (Exception &) { - // bundle rollback error: + catch (Exception &) + { OSL_ENSURE( 0, ::rtl::OUStringToOString( ::comphelper::anyToString( ::cppu::getCaughtException() ), diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx index ce0d3029084d..9a84a7286027 100644 --- a/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx +++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dp_package.cxx,v $ - * $Revision: 1.34.16.2 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx index 9d227f8b64b8..7feaeba5568b 100644 --- a/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx +++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dp_backend.h,v $ - * $Revision: 1.18 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/migration/services/cexportsoo3.cxx b/desktop/source/migration/services/cexportsoo3.cxx index 20b8232044e9..695b6b810808 100755 --- a/desktop/source/migration/services/cexportsoo3.cxx +++ b/desktop/source/migration/services/cexportsoo3.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: cexports.cxx,v $ - * $Revision: 1.9 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index 2e3a8d1d518c..3e9836fa2e84 100755 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: extensionmigration.cxx,v $ - * $Revision: 1.2 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/migration/services/oo3extensionmigration.hxx b/desktop/source/migration/services/oo3extensionmigration.hxx index 03995652888c..fb58692c81ee 100755 --- a/desktop/source/migration/services/oo3extensionmigration.hxx +++ b/desktop/source/migration/services/oo3extensionmigration.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: extensionmigration.hxx,v $ - * $Revision: 1.2 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index a9a0c8271373..4545ed862271 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -39,6 +39,7 @@ #include "osl/thread.h" #include "osl/process.h" #include "osl/conditn.hxx" +#include "osl/file.hxx" #include "cppuhelper/implbase1.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/anytostring.hxx" @@ -377,6 +378,29 @@ extern "C" int unopkg_main() if (e != osl_File_E_None && e != osl_File_E_NOENT) throw Exception(OUSTR("Could not delete ") + extensionUnorc, 0); } + else if (subCommand.equals(OUSTR("sync"))) + { + //sync is private!!!! Only for bundled extensions!!! + //For performance reasons unopkg sync is called during the setup and + //creates the registration data for the repository of the bundled + //extensions. It is then copied to the user installation during + //startup of OOo (userdata/extensions/bundled). The registration + //data is in the brand installation and must be removed when + //uninstalling OOo. We do this here, before UNO is + //bootstrapped. Otherwies files could be locked by this process. + + //If there is no folder left in + //$BRAND_BASE_DIR/share/extensions + //then we can delete the registration data at + //$BUNDLED_EXTENSIONS_USER + if (hasNoFolder(OUSTR("$BRAND_BASE_DIR/share/extensions"))) + { + removeFolder(OUSTR("$BUNDLED_EXTENSIONS_USER")); + //return otherwise we create the registration data again + return 0; + } + + } xComponentContext = getUNO( disposeGuard, option_verbose, option_shared, subcmd_gui, @@ -587,6 +611,15 @@ extern "C" int unopkg_main() xDialog->startExecuteModal(xListener); dialogEnded.wait(); } + else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("sync"))) + { + //This sub command may be removed later and is only there to have a + //possibility to start extension synching without any output. + //This is just here so we do not get an error, because of an unknown + //sub-command. We do synching before + //the sub-commands are processed. + + } else { dp_misc::writeConsoleError( diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx index 3272810afee2..d7b6e1ca2336 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx @@ -528,5 +528,110 @@ Reference<XComponentContext> getUNO( return xComponentContext; } +//Determines if a folder does not contains a folder. +//Return false may also mean that the status could not be determined +//because some error occurred. +bool hasNoFolder(OUString const & folderUrl) +{ + bool ret = false; + OUString url = folderUrl; + ::rtl::Bootstrap::expandMacros(url); + ::osl::Directory dir(url); + osl::File::RC rc = dir.open(); + if (rc == osl::File::E_None) + { + bool bFolderExist = false; + osl::DirectoryItem i; + osl::File::RC rcNext = osl::File::E_None; + while ( (rcNext = dir.getNextItem(i)) == osl::File::E_None) + { + osl::FileStatus stat(FileStatusMask_Type); + if (i.getFileStatus(stat) == osl::File::E_None) + { + if (stat.getFileType() == osl::FileStatus::Directory) + { + bFolderExist = true; + break; + } + } + else + { + dp_misc::writeConsole( + OUSTR("unopkg: Error while investigating ") + url + OUSTR("\n")); + break; + } + i = osl::DirectoryItem(); + } + + if (rcNext == osl::File::E_NOENT || + rcNext == osl::File::E_None) + { + if (!bFolderExist) + ret = true; + } + else + { + dp_misc::writeConsole( + OUSTR("unopkg: Error while investigating ") + url + OUSTR("\n")); + } + + dir.close(); + } + else + { + dp_misc::writeConsole( + OUSTR("unopkg: Error while investigating ") + url + OUSTR("\n")); + } + return ret; } +void removeFolder(OUString const & folderUrl) +{ + OUString url = folderUrl; + ::rtl::Bootstrap::expandMacros(url); + ::osl::Directory dir(url); + ::osl::File::RC rc = dir.open(); + if (rc == osl::File::E_None) + { + ::osl::DirectoryItem i; + ::osl::File::RC rcNext = ::osl::File::E_None; + while ( (rcNext = dir.getNextItem(i)) == ::osl::File::E_None) + { + ::osl::FileStatus stat(FileStatusMask_Type | FileStatusMask_FileURL); + if (i.getFileStatus(stat) == ::osl::File::E_None) + { + ::osl::FileStatus::Type t = stat.getFileType(); + if (t == ::osl::FileStatus::Directory) + { + //remove folder + removeFolder(stat.getFileURL()); + } + else if (t == ::osl::FileStatus::Regular) + { + //remove file + ::osl::File::remove(stat.getFileURL()); + } + else + { + OSL_ASSERT(0); + } + } + else + { + dp_misc::writeConsole( + OUSTR("unopkg: Error while investigating ") + url + OUSTR("\n")); + break; + } + i = ::osl::DirectoryItem(); + } + dir.close(); + ::osl::Directory::remove(url); + } + else + { + dp_misc::writeConsole( + OUSTR("unopkg: Error while removing ") + url + OUSTR("\n")); + } +} + +} diff --git a/desktop/source/pkgchk/unopkg/unopkg_shared.h b/desktop/source/pkgchk/unopkg/unopkg_shared.h index 43f77513b10c..4975cc4c087b 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_shared.h +++ b/desktop/source/pkgchk/unopkg/unopkg_shared.h @@ -178,5 +178,11 @@ css::uno::Reference<css::uno::XComponentContext> getUNO( DisposeGuard & disposeGuard, bool verbose, bool shared, bool bGui, css::uno::Reference<css::uno::XComponentContext> & out_LocalComponentContext); +bool hasNoFolder(::rtl::OUString const & folderUrl); + +void removeFolder(::rtl::OUString const & folderUrl); + } + + diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 381a98ce008f..c6a185b8e54d 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -640,20 +640,18 @@ void SplashScreen::Paint( const Rectangle&) ImplControlValue aValue( _iProgress * _barwidth / _iMax); Rectangle aDrawRect( Point(_tlx, _tly), Size( _barwidth, _barheight ) ); - Region aControlRegion( aDrawRect ); - Region aNativeControlRegion, aNativeContentRegion; + Rectangle aNativeControlRegion, aNativeContentRegion; - if( GetNativeControlRegion( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aControlRegion, + if( GetNativeControlRegion( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) { - long nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + long nProgressHeight = aNativeControlRegion.GetHeight(); aDrawRect.Top() -= (nProgressHeight - _barheight)/2; aDrawRect.Bottom() += (nProgressHeight - _barheight)/2; - aControlRegion = Region( aDrawRect ); } - if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aControlRegion, + if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect, CTRL_STATE_ENABLED, aValue, _sProgressText )) != FALSE ) { return; diff --git a/desktop/test/deployment/boxt/makefile.mk b/desktop/test/deployment/boxt/makefile.mk index 63f123fcc608..11d736448d44 100644 --- a/desktop/test/deployment/boxt/makefile.mk +++ b/desktop/test/deployment/boxt/makefile.mk @@ -33,11 +33,9 @@ ENABLE_EXCEPTIONS = TRUE .INCLUDE: settings.mk .INCLUDE: rtlbootstrap.mk +.INCLUDE: versionlist.mk -#TODO: The underlying OOo base version needed here is currently only available -# as instsetoo_native/util/openoffice.lst OOOBASEVERSION, so hard-coding it here -# for now (see issue 110653): -my_version = 3.3 +my_version = $(OOOBASEVERSIONMAJOR).$(OOOBASEVERSIONMINOR) DLLPRE = diff --git a/desktop/util/ooverinfo2.rc b/desktop/util/ooverinfo2.rc index f149ec6474e7..8bc39767f04a 100644 --- a/desktop/util/ooverinfo2.rc +++ b/desktop/util/ooverinfo2.rc @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -25,26 +25,26 @@ * *************************************************************************/ -#define VERSION 3 -#define SUBVERSION 2 -//#define VERVARIANT 0 +#define VERSION 3 +#define SUBVERSION 3 +//#define VERVARIANT 0 // .0 + VER_CONCEPT // .100 + VER_ALPHA // .200 + VER_BETA // .300 + VER_GAMMA // .500 + VER_FINAL -//#define VER_CONCEPT 0 -//#define VER_BETA 6 -#define VER_FINAL 0 +//#define VER_CONCEPT 0 +//#define VER_BETA 6 +#define VER_FINAL 0 -#define VER_DAY 1 -#define VER_MONTH 9 -#define VER_YEAR 2009 +#define VER_DAY 1 +#define VER_MONTH 1 +#define VER_YEAR 2010 // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// language/character set specification table +// language/character set specification table // ----------------------------------------------------------------------- diff --git a/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx index bd8c3be1fbbd..71c4cc6ffe1e 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx @@ -56,7 +56,7 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rTransformation, const Primitive2DSequence& rChildren); - // get data + /// data read access const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& getChartModel() const { return mxChartModel; } const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 7872ad825496..c60257551c28 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -90,7 +90,7 @@ #define PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 47) #define PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 48) #define PRIMITIVE2D_ID_CHARTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 49) -#define PRIMITIVE2D_ID_STRUCTURETAGRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 50) +#define PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 50) #define PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 51) #define PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 52) #define PRIMITIVE2D_ID_INVERTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 53) diff --git a/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx index ce49995c999d..d651af24047d 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx @@ -101,7 +101,7 @@ namespace drawinglayer double fShadowSlant, const basegfx::B3DRange& rScene3DRange); - /// get data + /// data read access const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; } const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx index 237ae00a4642..e2323765b2e5 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx @@ -94,8 +94,8 @@ namespace drawinglayer double fDiscreteDashLength); /// data read access - const basegfx::B2DPoint getPosition() const { return maPosition; } - const basegfx::B2DVector getDirection() const { return maDirection; } + const basegfx::B2DPoint& getPosition() const { return maPosition; } + const basegfx::B2DVector& getDirection() const { return maDirection; } HelplineStyle2D getStyle() const { return meStyle; } const basegfx::BColor& getRGBColA() const { return maRGBColA; } const basegfx::BColor& getRGBColB() const { return maRGBColB; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx index 80e281ede05c..ee5de781be86 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx @@ -189,7 +189,7 @@ namespace drawinglayer const attribute::LineAttribute& rLineAttribute); /// data read access - basegfx::B2DPolygon getB2DPolygon() const { return maPolygon; } + const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; } const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx index 18743937b6bc..4a48ae0d3e59 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx @@ -69,7 +69,7 @@ namespace drawinglayer PolyPolygonHairlinePrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBColor); /// data read access - basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const basegfx::BColor& getBColor() const { return maBColor; } /// compare operator @@ -123,7 +123,7 @@ namespace drawinglayer double fDiscreteDashLength); // data read access - basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const basegfx::BColor& getRGBColorA() const { return maRGBColorA; } const basegfx::BColor& getRGBColorB() const { return maRGBColorB; } double getDiscreteDashLength() const { return mfDiscreteDashLength; } @@ -182,7 +182,7 @@ namespace drawinglayer const attribute::LineAttribute& rLineAttribute); /// data read access - basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx index 4c95972ca67d..278a1b0bfff2 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx @@ -136,7 +136,7 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rObjectTransformation, const geometry::ViewInformation3D& rViewInformation3D); - /// data ead access + /// data read access const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; } const attribute::SdrSceneAttribute& getSdrSceneAttribute() const { return maSdrSceneAttribute; } const attribute::SdrLightingAttribute& getSdrLightingAttribute() const { return maSdrLightingAttribute; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx index 6ae691cbcff9..5c1093bc333a 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx @@ -129,8 +129,8 @@ namespace drawinglayer TextStrikeout getTextStrikeout() const { return meTextStrikeout; } TextEmphasisMark getTextEmphasisMark() const { return meTextEmphasisMark; } TextRelief getTextRelief() const { return meTextRelief; } - basegfx::BColor getOverlineColor() const { return maOverlineColor; } - basegfx::BColor getTextlineColor() const { return maTextlineColor; } + const basegfx::BColor& getOverlineColor() const { return maOverlineColor; } + const basegfx::BColor& getTextlineColor() const { return maTextlineColor; } bool getUnderlineAbove() const { return mbUnderlineAbove; } bool getWordLineMode() const { return mbWordLineMode; } bool getEmphasisMarkAbove() const { return mbEmphasisMarkAbove; } diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index 6fa1cef2d23f..0d57e566ef8a 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -2301,35 +2301,48 @@ namespace { const Gradient& rGradient = pA->GetGradient(); const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + basegfx::B2DPolyPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); if(aAttribute.getStartColor() == aAttribute.getEndColor()) { // not really a gradient. Create filled rectangle - const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); - createFillPrimitive(basegfx::B2DPolyPolygon(aOutline), rTargetHolders.Current(), rPropertyHolders.Current()); + createFillPrimitive( + aOutline, + rTargetHolders.Current(), + rPropertyHolders.Current()); } else { // really a gradient aRange.transform(rPropertyHolders.Current().getTransformation()); + drawinglayer::primitive2d::Primitive2DSequence xGradient(1); if(rPropertyHolders.Current().isRasterOpInvert()) { // use a special version of FillGradientPrimitive2D which creates // non-overlapping geometry on decomposition to makethe old XOR // paint 'trick' work. - rTargetHolders.Current().append( + xGradient[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::NonOverlappingFillGradientPrimitive2D( aRange, aAttribute)); } else { - rTargetHolders.Current().append( + xGradient[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::FillGradientPrimitive2D( aRange, aAttribute)); } + + // #i112300# clip against polygon representing the rectangle from + // the action. This is implicitely done using a temp Clipping in VCL + // when a MetaGradientAction is executed + aOutline.transform(rPropertyHolders.Current().getTransformation()); + rTargetHolders.Current().append( + new drawinglayer::primitive2d::MaskPrimitive2D( + aOutline, + xGradient)); } } } diff --git a/drawinglayer/source/primitive2d/structuretagprimitive2d.cxx b/drawinglayer/source/primitive2d/structuretagprimitive2d.cxx index 0ead7302ba38..8adcb6a10b82 100644 --- a/drawinglayer/source/primitive2d/structuretagprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/structuretagprimitive2d.cxx @@ -50,7 +50,7 @@ namespace drawinglayer } // provide unique ID - ImplPrimitrive2DIDBlock(StructureTagPrimitive2D, PRIMITIVE2D_ID_STRUCTURETAGRIMITIVE2D) + ImplPrimitrive2DIDBlock(StructureTagPrimitive2D, PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D) } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 983cc8f58d4f..dc954de7bb2a 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -94,6 +94,147 @@ using namespace com::sun::star; ////////////////////////////////////////////////////////////////////////////// +// #112245# definition for maximum allowed point count due to Metafile target. +// To be on the safe side with the old tools polygon, use slightly less then +// the theoretical maximum (bad experiences with tools polygon) + +#define MAX_POLYGON_POINT_COUNT_METAFILE (0x0000fff0) + +////////////////////////////////////////////////////////////////////////////// + +namespace +{ + // #112245# helper to split line polygon in half + void splitLinePolygon( + const basegfx::B2DPolygon& rBasePolygon, + basegfx::B2DPolygon& o_aLeft, + basegfx::B2DPolygon& o_aRight) + { + const sal_uInt32 nCount(rBasePolygon.count()); + + if(nCount) + { + const sal_uInt32 nHalfCount((nCount - 1) >> 1); + + o_aLeft = basegfx::B2DPolygon(rBasePolygon, 0, nHalfCount + 1); + o_aLeft.setClosed(false); + + o_aRight = basegfx::B2DPolygon(rBasePolygon, nHalfCount, nCount - nHalfCount); + o_aRight.setClosed(false); + + if(rBasePolygon.isClosed()) + { + o_aRight.append(rBasePolygon.getB2DPoint(0)); + + if(rBasePolygon.areControlPointsUsed()) + { + o_aRight.setControlPoints( + o_aRight.count() - 1, + rBasePolygon.getPrevControlPoint(0), + rBasePolygon.getNextControlPoint(0)); + } + } + } + else + { + o_aLeft.clear(); + o_aRight.clear(); + } + } + + // #112245# helper to evtl. split filled polygons to maximum metafile point count + bool fillPolyPolygonNeededToBeSplit(basegfx::B2DPolyPolygon& rPolyPolygon) + { + bool bRetval(false); + const sal_uInt32 nPolyCount(rPolyPolygon.count()); + + if(nPolyCount) + { + basegfx::B2DPolyPolygon aSplitted; + + for(sal_uInt32 a(0); a < nPolyCount; a++) + { + const basegfx::B2DPolygon aCandidate(rPolyPolygon.getB2DPolygon(a)); + const sal_uInt32 nPointCount(aCandidate.count()); + bool bNeedToSplit(false); + + if(aCandidate.areControlPointsUsed()) + { + // compare with the maximum for bezier curved polygons + bNeedToSplit = nPointCount > ((MAX_POLYGON_POINT_COUNT_METAFILE / 3L) - 1L); + } + else + { + // compare with the maximum for simple point polygons + bNeedToSplit = nPointCount > (MAX_POLYGON_POINT_COUNT_METAFILE - 1); + } + + if(bNeedToSplit) + { + // need to split the partial polygon + const basegfx::B2DRange aRange(aCandidate.getB2DRange()); + const basegfx::B2DPoint aCenter(aRange.getCenter()); + + if(aRange.getWidth() > aRange.getHeight()) + { + // clip in left and right + const basegfx::B2DPolyPolygon aLeft( + basegfx::tools::clipPolygonOnParallelAxis( + aCandidate, + false, + true, + aCenter.getX(), + false)); + const basegfx::B2DPolyPolygon aRight( + basegfx::tools::clipPolygonOnParallelAxis( + aCandidate, + false, + false, + aCenter.getX(), + false)); + + aSplitted.append(aLeft); + aSplitted.append(aRight); + } + else + { + // clip in top and bottom + const basegfx::B2DPolyPolygon aTop( + basegfx::tools::clipPolygonOnParallelAxis( + aCandidate, + true, + true, + aCenter.getY(), + false)); + const basegfx::B2DPolyPolygon aBottom( + basegfx::tools::clipPolygonOnParallelAxis( + aCandidate, + true, + false, + aCenter.getY(), + false)); + + aSplitted.append(aTop); + aSplitted.append(aBottom); + } + } + else + { + aSplitted.append(aCandidate); + } + } + + if(aSplitted.count() != nPolyCount) + { + rPolyPolygon = aSplitted; + } + } + + return bRetval; + } +} // end of anonymous namespace + +////////////////////////////////////////////////////////////////////////////// namespace drawinglayer { @@ -982,26 +1123,65 @@ namespace drawinglayer } case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D : { - // direct draw of hairline; use default processing - // also support SvtGraphicStroke MetaCommentAction const primitive2d::PolygonHairlinePrimitive2D& rHairlinePrimitive = static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate); - const basegfx::BColor aLineColor(maBColorModifierStack.getModifiedColor(rHairlinePrimitive.getBColor())); - SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke(rHairlinePrimitive.getB2DPolygon(), &aLineColor, 0, 0, 0, 0); + const basegfx::B2DPolygon& rBasePolygon = rHairlinePrimitive.getB2DPolygon(); - impStartSvtGraphicStroke(pSvtGraphicStroke); - RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate), false); - impEndSvtGraphicStroke(pSvtGraphicStroke); + if(rBasePolygon.count() > (MAX_POLYGON_POINT_COUNT_METAFILE - 1)) + { + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. If there are more, split the polygon in half and call recursively + basegfx::B2DPolygon aLeft, aRight; + splitLinePolygon(rBasePolygon, aLeft, aRight); + const primitive2d::PolygonHairlinePrimitive2D aPLeft(aLeft, rHairlinePrimitive.getBColor()); + const primitive2d::PolygonHairlinePrimitive2D aPRight(aRight, rHairlinePrimitive.getBColor()); + + processBasePrimitive2D(aPLeft); + processBasePrimitive2D(aPRight); + } + else + { + // direct draw of hairline; use default processing + // support SvtGraphicStroke MetaCommentAction + const basegfx::BColor aLineColor(maBColorModifierStack.getModifiedColor(rHairlinePrimitive.getBColor())); + SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke( + rHairlinePrimitive.getB2DPolygon(), + &aLineColor, + 0, 0, 0, 0); + + impStartSvtGraphicStroke(pSvtGraphicStroke); + RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate), false); + impEndSvtGraphicStroke(pSvtGraphicStroke); + } break; } case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D : { - // support SvtGraphicStroke MetaCommentAction const primitive2d::PolygonStrokePrimitive2D& rStrokePrimitive = static_cast< const primitive2d::PolygonStrokePrimitive2D& >(rCandidate); - SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke(rStrokePrimitive.getB2DPolygon(), 0, &rStrokePrimitive.getLineAttribute(), - &rStrokePrimitive.getStrokeAttribute(), 0, 0); + const basegfx::B2DPolygon& rBasePolygon = rStrokePrimitive.getB2DPolygon(); - if(true) + if(rBasePolygon.count() > (MAX_POLYGON_POINT_COUNT_METAFILE - 1)) { + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. If there are more, split the polygon in half and call recursively + basegfx::B2DPolygon aLeft, aRight; + splitLinePolygon(rBasePolygon, aLeft, aRight); + const primitive2d::PolygonStrokePrimitive2D aPLeft( + aLeft, rStrokePrimitive.getLineAttribute(), rStrokePrimitive.getStrokeAttribute()); + const primitive2d::PolygonStrokePrimitive2D aPRight( + aRight, rStrokePrimitive.getLineAttribute(), rStrokePrimitive.getStrokeAttribute()); + + processBasePrimitive2D(aPLeft); + processBasePrimitive2D(aPRight); + } + else + { + // support SvtGraphicStroke MetaCommentAction + SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke( + rBasePolygon, 0, + &rStrokePrimitive.getLineAttribute(), + &rStrokePrimitive.getStrokeAttribute(), + 0, 0); + impStartSvtGraphicStroke(pSvtGraphicStroke); const attribute::LineAttribute& rLine = rStrokePrimitive.getLineAttribute(); @@ -1013,12 +1193,12 @@ namespace drawinglayer if(0.0 == rStroke.getFullDotDashLen()) { - aHairLinePolyPolygon.append(rStrokePrimitive.getB2DPolygon()); + aHairLinePolyPolygon.append(rBasePolygon); } else { basegfx::tools::applyLineDashing( - rStrokePrimitive.getB2DPolygon(), rStroke.getDotDashArray(), + rBasePolygon, rStroke.getDotDashArray(), &aHairLinePolyPolygon, 0, rStroke.getFullDotDashLen()); } @@ -1048,93 +1228,52 @@ namespace drawinglayer impEndSvtGraphicStroke(pSvtGraphicStroke); } - else - { - // Adapt OutDev's DrawMode if special ones were used - const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); - adaptLineToFillDrawMode(); - - impStartSvtGraphicStroke(pSvtGraphicStroke); - - // #i101491# - // Change default of fat line generation for MetaFiles: Create MetaPolyLineAction - // instead of decomposing all geometries when the polygon has more than given amount of - // points; else the decomposition will get too expensive quiclky. OTOH - // the decomposition provides the better quality e.g. taking edge roundings - // into account which will NOT be taken into account with LineInfo-based actions - const sal_uInt32 nSubPolygonCount(rStrokePrimitive.getB2DPolygon().count()); - bool bDone(0 == nSubPolygonCount); - - if(!bDone && nSubPolygonCount > 1000) - { - // create MetaPolyLineActions, but without LINE_DASH - const attribute::LineAttribute& rLine = rStrokePrimitive.getLineAttribute(); - - if(basegfx::fTools::more(rLine.getWidth(), 0.0)) - { - const attribute::StrokeAttribute& rStroke = rStrokePrimitive.getStrokeAttribute(); - basegfx::B2DPolyPolygon aHairLinePolyPolygon; - - if(0.0 == rStroke.getFullDotDashLen()) - { - aHairLinePolyPolygon.append(rStrokePrimitive.getB2DPolygon()); - } - else - { - basegfx::tools::applyLineDashing( - rStrokePrimitive.getB2DPolygon(), rStroke.getDotDashArray(), - &aHairLinePolyPolygon, 0, rStroke.getFullDotDashLen()); - } - - const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLine.getColor())); - mpOutputDevice->SetLineColor(Color(aHairlineColor)); - mpOutputDevice->SetFillColor(); - - aHairLinePolyPolygon.transform(maCurrentTransformation); - - const LineInfo aLineInfo(LINE_SOLID, basegfx::fround(rLine.getWidth())); - - for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++) - { - const basegfx::B2DPolygon aCandidate(aHairLinePolyPolygon.getB2DPolygon(a)); - - if(aCandidate.count() > 1) - { - const Polygon aToolsPolygon(aCandidate); - - mpMetaFile->AddAction(new MetaPolyLineAction(aToolsPolygon, aLineInfo)); - } - } - - bDone = true; - } - } - - if(!bDone) - { - // use decomposition (creates line geometry as filled polygon - // geometry) - process(rCandidate.get2DDecomposition(getViewInformation2D())); - } - - impEndSvtGraphicStroke(pSvtGraphicStroke); - - // restore DrawMode - mpOutputDevice->SetDrawMode(nOriginalDrawMode); - } break; } case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D : { - // support SvtGraphicStroke MetaCommentAction const primitive2d::PolygonStrokeArrowPrimitive2D& rStrokeArrowPrimitive = static_cast< const primitive2d::PolygonStrokeArrowPrimitive2D& >(rCandidate); - SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke(rStrokeArrowPrimitive.getB2DPolygon(), 0, &rStrokeArrowPrimitive.getLineAttribute(), - &rStrokeArrowPrimitive.getStrokeAttribute(), &rStrokeArrowPrimitive.getStart(), &rStrokeArrowPrimitive.getEnd()); + const basegfx::B2DPolygon& rBasePolygon = rStrokeArrowPrimitive.getB2DPolygon(); + + if(rBasePolygon.count() > (MAX_POLYGON_POINT_COUNT_METAFILE - 1)) + { + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. If there are more, split the polygon in half and call recursively + basegfx::B2DPolygon aLeft, aRight; + splitLinePolygon(rBasePolygon, aLeft, aRight); + const attribute::LineStartEndAttribute aEmpty; + const primitive2d::PolygonStrokeArrowPrimitive2D aPLeft( + aLeft, + rStrokeArrowPrimitive.getLineAttribute(), + rStrokeArrowPrimitive.getStrokeAttribute(), + rStrokeArrowPrimitive.getStart(), + aEmpty); + const primitive2d::PolygonStrokeArrowPrimitive2D aPRight( + aRight, + rStrokeArrowPrimitive.getLineAttribute(), + rStrokeArrowPrimitive.getStrokeAttribute(), + aEmpty, + rStrokeArrowPrimitive.getEnd()); + + processBasePrimitive2D(aPLeft); + processBasePrimitive2D(aPRight); + } + else + { + // support SvtGraphicStroke MetaCommentAction + SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke( + rBasePolygon, 0, + &rStrokeArrowPrimitive.getLineAttribute(), + &rStrokeArrowPrimitive.getStrokeAttribute(), + &rStrokeArrowPrimitive.getStart(), + &rStrokeArrowPrimitive.getEnd()); + + impStartSvtGraphicStroke(pSvtGraphicStroke); + process(rCandidate.get2DDecomposition(getViewInformation2D())); + impEndSvtGraphicStroke(pSvtGraphicStroke); + } - impStartSvtGraphicStroke(pSvtGraphicStroke); - process(rCandidate.get2DDecomposition(getViewInformation2D())); - impEndSvtGraphicStroke(pSvtGraphicStroke); break; } case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : @@ -1146,16 +1285,26 @@ namespace drawinglayer case PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D : { // need to handle PolyPolygonBitmapPrimitive2D here to support XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END - SvtGraphicFill* pSvtGraphicFill = 0; + const primitive2d::PolyPolygonBitmapPrimitive2D& rBitmapCandidate = static_cast< const primitive2d::PolyPolygonBitmapPrimitive2D& >(rCandidate); + basegfx::B2DPolyPolygon aLocalPolyPolygon(rBitmapCandidate.getB2DPolyPolygon()); + + if(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) + { + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. If there are more use the splitted polygon and call recursively + const primitive2d::PolyPolygonBitmapPrimitive2D aSplitted( + aLocalPolyPolygon, + rBitmapCandidate.getFillBitmap()); - if(!mnSvtGraphicFillCount) + processBasePrimitive2D(aSplitted); + } + else { - const primitive2d::PolyPolygonBitmapPrimitive2D& rBitmapCandidate = static_cast< const primitive2d::PolyPolygonBitmapPrimitive2D& >(rCandidate); - basegfx::B2DPolyPolygon aLocalPolyPolygon(rBitmapCandidate.getB2DPolyPolygon()); - aLocalPolyPolygon.transform(maCurrentTransformation); + SvtGraphicFill* pSvtGraphicFill = 0; - if(aLocalPolyPolygon.count()) + if(!mnSvtGraphicFillCount && aLocalPolyPolygon.count()) { + aLocalPolyPolygon.transform(maCurrentTransformation); // calculate transformation. Get real object size, all values in FillBitmapAttribute // are relative to the unified object const attribute::FillBitmapAttribute& rFillBitmapAttribute = rBitmapCandidate .getFillBitmap(); @@ -1212,78 +1361,81 @@ namespace drawinglayer 0, aFillGraphic); } - } - // Do use decomposition; encapsulate with SvtGraphicFill - impStartSvtGraphicFill(pSvtGraphicFill); - process(rCandidate.get2DDecomposition(getViewInformation2D())); - impEndSvtGraphicFill(pSvtGraphicFill); + // Do use decomposition; encapsulate with SvtGraphicFill + impStartSvtGraphicFill(pSvtGraphicFill); + process(rCandidate.get2DDecomposition(getViewInformation2D())); + impEndSvtGraphicFill(pSvtGraphicFill); + } break; } case PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D : { // need to handle PolyPolygonHatchPrimitive2D here to support XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END - SvtGraphicFill* pSvtGraphicFill = 0; const primitive2d::PolyPolygonHatchPrimitive2D& rHatchCandidate = static_cast< const primitive2d::PolyPolygonHatchPrimitive2D& >(rCandidate); - const attribute::FillHatchAttribute& rFillHatchAttribute = rHatchCandidate.getFillHatch(); basegfx::B2DPolyPolygon aLocalPolyPolygon(rHatchCandidate.getB2DPolyPolygon()); + + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. Split polygon until there are less than that + while(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) + ; + + SvtGraphicFill* pSvtGraphicFill = 0; + const attribute::FillHatchAttribute& rFillHatchAttribute = rHatchCandidate.getFillHatch(); aLocalPolyPolygon.transform(maCurrentTransformation); - if(!mnSvtGraphicFillCount) + if(!mnSvtGraphicFillCount && aLocalPolyPolygon.count()) { - if(aLocalPolyPolygon.count()) - { - // re-create a VCL hatch as base data - SvtGraphicFill::HatchType eHatch(SvtGraphicFill::hatchSingle); + // re-create a VCL hatch as base data + SvtGraphicFill::HatchType eHatch(SvtGraphicFill::hatchSingle); - switch(rFillHatchAttribute.getStyle()) + switch(rFillHatchAttribute.getStyle()) + { + default: // attribute::HATCHSTYLE_SINGLE : { - default: // attribute::HATCHSTYLE_SINGLE : - { - eHatch = SvtGraphicFill::hatchSingle; - break; - } - case attribute::HATCHSTYLE_DOUBLE : - { - eHatch = SvtGraphicFill::hatchDouble; - break; - } - case attribute::HATCHSTYLE_TRIPLE : - { - eHatch = SvtGraphicFill::hatchTriple; - break; - } + eHatch = SvtGraphicFill::hatchSingle; + break; + } + case attribute::HATCHSTYLE_DOUBLE : + { + eHatch = SvtGraphicFill::hatchDouble; + break; + } + case attribute::HATCHSTYLE_TRIPLE : + { + eHatch = SvtGraphicFill::hatchTriple; + break; } + } - SvtGraphicFill::Transform aTransform; + SvtGraphicFill::Transform aTransform; - // scale - aTransform.matrix[0] *= rFillHatchAttribute.getDistance(); - aTransform.matrix[4] *= rFillHatchAttribute.getDistance(); + // scale + aTransform.matrix[0] *= rFillHatchAttribute.getDistance(); + aTransform.matrix[4] *= rFillHatchAttribute.getDistance(); - // rotate (was never correct in impgrfll anyways, use correct angle now) - aTransform.matrix[0] *= cos(rFillHatchAttribute.getAngle()); - aTransform.matrix[1] *= -sin(rFillHatchAttribute.getAngle()); - aTransform.matrix[3] *= sin(rFillHatchAttribute.getAngle()); - aTransform.matrix[4] *= cos(rFillHatchAttribute.getAngle()); + // rotate (was never correct in impgrfll anyways, use correct angle now) + aTransform.matrix[0] *= cos(rFillHatchAttribute.getAngle()); + aTransform.matrix[1] *= -sin(rFillHatchAttribute.getAngle()); + aTransform.matrix[3] *= sin(rFillHatchAttribute.getAngle()); + aTransform.matrix[4] *= cos(rFillHatchAttribute.getAngle()); - pSvtGraphicFill = new SvtGraphicFill( - PolyPolygon(aLocalPolyPolygon), - Color(), - 0.0, - SvtGraphicFill::fillEvenOdd, - SvtGraphicFill::fillHatch, - aTransform, - false, - eHatch, - Color(rFillHatchAttribute.getColor()), - SvtGraphicFill::gradientLinear, - Color(), - Color(), - 0, - Graphic()); - } + pSvtGraphicFill = new SvtGraphicFill( + PolyPolygon(aLocalPolyPolygon), + Color(), + 0.0, + SvtGraphicFill::fillEvenOdd, + SvtGraphicFill::fillHatch, + aTransform, + false, + eHatch, + Color(rFillHatchAttribute.getColor()), + SvtGraphicFill::gradientLinear, + Color(), + Color(), + 0, + Graphic()); } // Do use decomposition; encapsulate with SvtGraphicFill @@ -1304,18 +1456,24 @@ namespace drawinglayer basegfx::fround(rFillHatchAttribute.getAngle() / F_PI1800))); impEndSvtGraphicFill(pSvtGraphicFill); + break; } case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D : { const primitive2d::PolyPolygonGradientPrimitive2D& rGradientCandidate = static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate); + basegfx::B2DPolyPolygon aLocalPolyPolygon(rGradientCandidate.getB2DPolyPolygon()); + + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. Split polygon until there are less than that + while(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) + ; // for support of MetaCommentActions of the form XGRAD_SEQ_BEGIN, XGRAD_SEQ_END // it is safest to use the VCL OutputDevice::DrawGradient method which creates those. // re-create a VCL-gradient from FillGradientPrimitive2D and the needed tools PolyPolygon Gradient aVCLGradient; impConvertFillGradientAttributeToVCLGradient(aVCLGradient, rGradientCandidate.getFillGradient(), false); - basegfx::B2DPolyPolygon aLocalPolyPolygon(rGradientCandidate.getB2DPolyPolygon()); aLocalPolyPolygon.transform(maCurrentTransformation); // #i82145# ATM VCL printing of gradients using curved shapes does not work, @@ -1373,13 +1531,20 @@ namespace drawinglayer // NO usage of common own gradient randerer, not used ATM for VCL MetaFile, see text above // RenderPolyPolygonGradientPrimitive2D(static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate)); + break; } case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D : { const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate)); - const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor())); basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); + + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. Split polygon until there are less than that + while(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) + ; + + const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor())); aLocalPolyPolygon.transform(maCurrentTransformation); // XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END support @@ -1547,6 +1712,13 @@ namespace drawinglayer // single transparent PolyPolygon identified, use directly const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(pPoPoColor->getBColor())); basegfx::B2DPolyPolygon aLocalPolyPolygon(pPoPoColor->getB2DPolyPolygon()); + + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. Split polygon until there are less than that + while(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) + ; + + // now transform aLocalPolyPolygon.transform(maCurrentTransformation); // XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END support @@ -1796,7 +1968,7 @@ namespace drawinglayer } break; } - case PRIMITIVE2D_ID_STRUCTURETAGRIMITIVE2D : + case PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D : { // structured tag primitive const primitive2d::StructureTagPrimitive2D& rStructureTagCandidate = static_cast< const primitive2d::StructureTagPrimitive2D& >(rCandidate); diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 642b5e0d9f17..664512df414e 100755 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -1044,7 +1044,8 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack ) { PopupMenu aPopupMenu( EditResId( RID_MENU_SPELL ) ); PopupMenu *pAutoMenu = aPopupMenu.GetPopupMenu( MN_AUTOCORR ); - PopupMenu *pInsertMenu = aPopupMenu.GetPopupMenu( MN_INSERT ); + PopupMenu *pInsertMenu = aPopupMenu.GetPopupMenu( MN_INSERT ); // add word to user-dictionaries + pInsertMenu->SetMenuFlags( MENU_FLAG_NOAUTOMNEMONICS ); //! necessary to retrieve the correct dictionary names later EditPaM aPaM2( aPaM ); aPaM2.GetIndex()++; @@ -1261,7 +1262,12 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack ) } else if ( nId >= MN_DICTSTART ) { - Reference< XDictionary > xDic( pDic[nId - MN_DICTSTART], UNO_QUERY ); + String aDicName ( pInsertMenu->GetItemText(nId) ); + + uno::Reference< linguistic2::XDictionary > xDic; + if (xDicList.is()) + xDic = xDicList->getDictionaryByName( aDicName ); + if (xDic.is()) xDic->add( aSelected, sal_False, String() ); // save modified user-dictionary if it is persistent diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 778942730e71..148ca08816ae 100755 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -4209,18 +4209,8 @@ long ImpEditEngine::GetXPos( ParaPortion* pParaPortion, EditLine* pLine, USHORT DBG_ERROR("svx::ImpEditEngine::GetXPos(), index out of range!"); } -#if 0 + // old code restored see #i112788 (which leaves #i74188 unfixed again) long nPosInPortion = pLine->GetCharPosArray().GetObject( nPos ); -#else - // #i74188# (positioning the cursor after deleting components of combined indic characters) - SvxFont aTmpFont( pParaPortion->GetNode()->GetCharAttribs().GetDefFont() ); - SeekCursor( pParaPortion->GetNode(), nPos+1, aTmpFont ); - aTmpFont.SetPhysFont( GetRefDevice() ); - ImplInitDigitMode( GetRefDevice(), 0, 0, 0, aTmpFont.GetLanguage() ); - String sSegment(*pParaPortion->GetNode(), pLine->GetStart(), nPos+1); - long nPosInPortion = aTmpFont.QuickGetTextSize( GetRefDevice(), - sSegment, 0, nPos+1, NULL ).Width(); -#endif if ( !pPortion->IsRightToLeft() ) { diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 482cd6d71338..5a54c054016b 100755..100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -1458,7 +1458,11 @@ Reference< XSpellChecker1 > ImpEditEngine::GetSpeller() SpellInfo * ImpEditEngine::CreateSpellInfo( const EditSelection &rSel, bool bMultipleDocs ) { - pSpellInfo = new SpellInfo; + if (!pSpellInfo) + pSpellInfo = new SpellInfo; + else + *pSpellInfo = SpellInfo(); // reset to default values + pSpellInfo->bMultipleDoc = bMultipleDocs; EditSelection aSentenceSel( SelectSentence( rSel ) ); // pSpellInfo->aSpellStart = CreateEPaM( aSentenceSel.Min() ); @@ -2023,7 +2027,6 @@ bool ImpEditEngine::SpellSentence(EditView& rEditView, #else bool bRet = false; EditSelection aCurSel( rEditView.pImpEditView->GetEditSelection() ); - //the pSpellInfo has to be created on demand if(!pSpellInfo) pSpellInfo = CreateSpellInfo( aCurSel, true ); pSpellInfo->aCurSentenceStart = aCurSel.Min(); @@ -2191,8 +2194,12 @@ void ImpEditEngine::ApplyChangedSentence(EditView& rEditView, { #ifdef SVX_LIGHT #else + // Note: rNewPortions.size() == 0 is valid and happens when the whole + // sentence got removed in the dialog + DBG_ASSERT(pSpellInfo, "pSpellInfo not initialized"); - if(pSpellInfo) + if (pSpellInfo && + pSpellInfo->aLastSpellPortions.size() > 0) // no portions -> no text to be changed { // get current paragraph length to calculate later on how the sentence length changed, // in order to place the cursor at the end of the sentence again @@ -2202,6 +2209,10 @@ void ImpEditEngine::ApplyChangedSentence(EditView& rEditView, UndoActionStart( EDITUNDO_INSERT ); if(pSpellInfo->aLastSpellPortions.size() == rNewPortions.size()) { + DBG_ASSERT( rNewPortions.size() > 0, "rNewPortions should not be empty here" ); + DBG_ASSERT( pSpellInfo->aLastSpellPortions.size() == pSpellInfo->aLastSpellContentSelections.size(), + "aLastSpellPortions and aLastSpellContentSelections size mismatch" ); + //the simple case: the same number of elements on both sides //each changed element has to be applied to the corresponding source element svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.end(); @@ -2252,6 +2263,8 @@ void ImpEditEngine::ApplyChangedSentence(EditView& rEditView, } else { + DBG_ASSERT( pSpellInfo->aLastSpellContentSelections.size() > 0, "aLastSpellContentSelections should not be empty here" ); + //select the complete sentence SpellContentSelections::const_iterator aCurrentEndPosition = pSpellInfo->aLastSpellContentSelections.end(); --aCurrentEndPosition; diff --git a/editeng/source/misc/unolingu.cxx b/editeng/source/misc/unolingu.cxx index e95ce560023b..ae92fd1a01b8 100644..100755 --- a/editeng/source/misc/unolingu.cxx +++ b/editeng/source/misc/unolingu.cxx @@ -1197,7 +1197,10 @@ uno::Reference< XDictionary > LinguMgr::GetStandard() // add new dictionary to list if (xTmp.is()) + { xTmpDicList->addDictionary( xTmp ); + xTmp->setActive( sal_True ); + } xDic = uno::Reference< XDictionary > ( xTmp, UNO_QUERY ); } #if OSL_DEBUG_LEVEL > 1 diff --git a/formula/inc/formula/errorcodes.hxx b/formula/inc/formula/errorcodes.hxx index f9b04e012fab..f08af17e095e 100644 --- a/formula/inc/formula/errorcodes.hxx +++ b/formula/inc/formula/errorcodes.hxx @@ -64,7 +64,8 @@ const USHORT errInterpOverflow = 527; // Not displayed, temporary for TrackFormulas, // Cell depends on another cell that has errCircularReference const USHORT errTrackFromCircRef = 528; -// Interpreter internal: existing cell has no value but value queried +// ScInterpreter internal: no numeric value but numeric queried. If this is +// set as mnStringNoValueError no error is generated but 0 returned. const USHORT errCellNoValue = 529; // Interpreter: needed AddIn not found const USHORT errNoAddin = 530; @@ -74,6 +75,11 @@ const USHORT errNoMacro = 531; const USHORT errDivisionByZero = 532; // #DIV/0! // Compiler: a non-simple (str,err,val) value was put in an array const USHORT errNestedArray = 533; +// ScInterpreter internal: no numeric value but numeric queried. If this is +// temporarily (!) set as mnStringNoValueError, the error is generated and can +// be used to distinguish that condition from all other (inherited) errors. Do +// not use for anything else! Never push or inherit the error otherwise! +const USHORT errNotNumericString = 534; // Interpreter: NA() not available condition, not a real error const USHORT NOTAVAILABLE = 0x7fff; diff --git a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx index c6b0acd6a33f..fdf4866daf24 100644 --- a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx @@ -33,13 +33,13 @@ //------------------------------------------------------------------------ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <cppuhelper/interfacecontainer.h> #include <osl/diagnose.h> +#include <osl/process.h> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/ControlActions.hpp> #include <com/sun/star/uno/Any.hxx> @@ -126,41 +126,8 @@ void SalGtkFilePicker::InitialMapping() gtk_widget_set_size_request (m_pPreview, -1, -1); } -static void lcl_setGTKLanguage(const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr) -{ - static bool bSet = false; - if (bSet) - return; - - OUString sUILocale; - try - { - uno::Reference<lang::XMultiServiceFactory> xConfigMgr = - uno::Reference<lang::XMultiServiceFactory>(xServiceMgr->createInstance( - OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), - UNO_QUERY_THROW ); - - Sequence< Any > theArgs(1); - theArgs[ 0 ] <<= OUString::createFromAscii("org.openoffice.Office.Linguistic/General"); - - uno::Reference< container::XNameAccess > xNameAccess = - uno::Reference< container::XNameAccess >(xConfigMgr->createInstanceWithArguments( - OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), theArgs ), - UNO_QUERY_THROW ); - - if (xNameAccess.is()) - xNameAccess->getByName(OUString::createFromAscii("UILocale")) >>= sUILocale; - } catch (...) {} - - if (sUILocale.getLength()) - { - sUILocale = rtl::OUString::createFromAscii("LANGUAGE=") + sUILocale.replace('-', '_'); - putenv(strdup(rtl::OUStringToOString(sUILocale, osl_getThreadTextEncoding()).getStr())); - } - bSet = true; -} - SalGtkFilePicker::SalGtkFilePicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr ) : + SalGtkPicker(xServiceMgr), cppu::WeakComponentImplHelper10< XFilterManager, XFilterGroupManager, @@ -184,8 +151,6 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference<lang::XMultiServiceFact m_PreviewImageWidth( 256 ), m_PreviewImageHeight( 256 ) { - lcl_setGTKLanguage(xServiceMgr); - int i; for( i = 0; i < TOGGLE_LAST; i++ ) @@ -935,6 +900,9 @@ uno::Sequence<rtl::OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw { static const OUString aStarDot = OUString::createFromAscii( "*." ); + ::rtl::OUString aNewFilter; + ::rtl::OUString aOldFilter = getCurrentFilter(); + sal_Bool bChangeFilter = sal_True; for ( FilterList::iterator aListIter = m_pFilterList->begin(); aListIter != m_pFilterList->end(); ++aListIter @@ -942,11 +910,17 @@ uno::Sequence<rtl::OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw { if( aListIter->getFilter().indexOf( aStarDot+sExtension ) >= 0 ) { - setCurrentFilter( aListIter->getTitle() ); + if( !aNewFilter.getLength() ) + aNewFilter = aListIter->getTitle(); + + if( aOldFilter == aListIter->getTitle() ) + bChangeFilter = sal_False; + bExtensionTypedIn = true; - break; } } + if( bChangeFilter ) + setCurrentFilter( aNewFilter ); } } diff --git a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx index f9c78d76639c..dd5d30d203a6 100644 --- a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx @@ -84,7 +84,8 @@ namespace // constructor //----------------------------------------------------------------------------------------- SalGtkFolderPicker::SalGtkFolderPicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr ) : - m_xServiceMgr( xServiceMgr ) + SalGtkPicker(xServiceMgr), + m_xServiceMgr(xServiceMgr) { CResourceProvider aResProvider; diff --git a/fpicker/source/unx/gnome/SalGtkPicker.cxx b/fpicker/source/unx/gnome/SalGtkPicker.cxx index 1a685e0981e6..6fd19b2f7f79 100644 --- a/fpicker/source/unx/gnome/SalGtkPicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkPicker.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/awt/XSystemDependentWindowPeer.hpp> #include <com/sun/star/awt/SystemDependentXWindow.hpp> #include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/container/XNameAccess.hpp> #include <comphelper/processfactory.hxx> #include <cppuhelper/interfacecontainer.h> #include <rtl/process.h> @@ -202,6 +203,46 @@ gint RunDialog::run() return nStatus; } +static void lcl_setGTKLanguage(const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr) +{ + static bool bSet = false; + if (bSet) + return; + + OUString sUILocale; + try + { + uno::Reference<lang::XMultiServiceFactory> xConfigMgr = + uno::Reference<lang::XMultiServiceFactory>(xServiceMgr->createInstance( + OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), + UNO_QUERY_THROW ); + + Sequence< Any > theArgs(1); + theArgs[ 0 ] <<= OUString::createFromAscii("org.openoffice.Office.Linguistic/General"); + + uno::Reference< container::XNameAccess > xNameAccess = + uno::Reference< container::XNameAccess >(xConfigMgr->createInstanceWithArguments( + OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), theArgs ), + UNO_QUERY_THROW ); + + if (xNameAccess.is()) + xNameAccess->getByName(OUString::createFromAscii("UILocale")) >>= sUILocale; + } catch (...) {} + + if (sUILocale.getLength()) + { + sUILocale = sUILocale.replace('-', '_'); + rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("LANGUAGE")); + osl_setEnvironment(envVar.pData, sUILocale.pData); + } + bSet = true; +} + +SalGtkPicker::SalGtkPicker(const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr) : m_pDialog(0) +{ + lcl_setGTKLanguage(xServiceMgr); +} + SalGtkPicker::~SalGtkPicker() { if (m_pDialog) diff --git a/fpicker/source/unx/gnome/SalGtkPicker.hxx b/fpicker/source/unx/gnome/SalGtkPicker.hxx index 6349d3ed4988..94e7a11de99a 100644 --- a/fpicker/source/unx/gnome/SalGtkPicker.hxx +++ b/fpicker/source/unx/gnome/SalGtkPicker.hxx @@ -53,7 +53,7 @@ class SalGtkPicker { public: - SalGtkPicker() : m_pDialog(0) {} + SalGtkPicker(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& xServiceMgr); virtual ~SalGtkPicker(); protected: osl::Mutex m_rbHelperMtx; diff --git a/fpicker/source/unx/kde4/KDE4FilePicker.cxx b/fpicker/source/unx/kde4/KDE4FilePicker.cxx index a7fa01a5ece6..eadc255f0ec0 100644 --- a/fpicker/source/unx/kde4/KDE4FilePicker.cxx +++ b/fpicker/source/unx/kde4/KDE4FilePicker.cxx @@ -46,6 +46,8 @@ #include <vcl/sysdata.hxx> #include <vcl/syswin.hxx> +#include "osl/file.h" + #include "KDE4FilePicker.hxx" #include "FPServiceInfo.hxx" @@ -246,7 +248,7 @@ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles() // kde file picker returns the file and directories for selectedFiles() // when a file is double clicked // make a true list of files - const QString dir = "file://" + KUrl(rawFiles[0]).directory(); + const QString dir = KUrl(rawFiles[0]).directory(); bool singleFile = true; if (rawFiles.size() > 1) @@ -262,7 +264,7 @@ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles() { // if the raw file is not the base directory (see above kde bug) // we add the file to list of avail files - if ((dir + "/") != ("file://" + rawFiles[i])) + if ((dir + "/") != ( rawFiles[i])) { QString filename = KUrl(rawFiles[i]).fileName(); @@ -280,7 +282,11 @@ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles() // add all files and leading directory to outgoing OO sequence uno::Sequence< ::rtl::OUString > seq(files.size()); for (int i = 0; i < files.size(); ++i) - seq[i] = toOUString(files[i]); + { + rtl::OUString aFile(toOUString(files[i])), aURL; + osl_getFileURLFromSystemPath(aFile.pData, &aURL.pData ); + seq[i] = aURL; + } return seq; } diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx index 15070eed7c98..b81ef5aecf0e 100644 --- a/framework/source/accelerators/acceleratorconfiguration.cxx +++ b/framework/source/accelerators/acceleratorconfiguration.cxx @@ -96,6 +96,8 @@ #include <svtools/acceleratorexecute.hxx> +#include <stdio.h> + //_______________________________________________ // const @@ -1248,7 +1250,6 @@ void SAL_CALL XCUBasedAcceleratorConfiguration::changesOccurred(const css::util: const sal_Int32 c = aEvent.Changes.getLength(); sal_Int32 i = 0; - for (i=0; i<c; ++i) { const css::util::ElementChange& aChange = aEvent.Changes[i]; @@ -1264,27 +1265,25 @@ void SAL_CALL XCUBasedAcceleratorConfiguration::changesOccurred(const css::util: aChange.Accessor >>= sOrgPath; sPath = sOrgPath; - ::rtl::OUString sPrimarySecondary = ::utl::extractFirstFromConfigurationPath(sPath); - sPath = ::utl::dropPrefixFromConfigurationPath(sPath, sPrimarySecondary); - - ::rtl::OUString sGlobalModules = ::utl::extractFirstFromConfigurationPath(sPath); - sPath = ::utl::dropPrefixFromConfigurationPath(sPath, sGlobalModules); + ::rtl::OUString sPrimarySecondary = ::utl::extractFirstFromConfigurationPath(sPath, &sPath); + ::rtl::OUString sGlobalModules = ::utl::extractFirstFromConfigurationPath(sPath, &sPath); if ( sGlobalModules.equals(CFG_ENTRY_GLOBAL) ) { ::rtl::OUString sModule; - sKey = ::utl::extractFirstFromConfigurationPath(sPath); - if ( sKey.getLength() ) + sKey = ::utl::extractFirstFromConfigurationPath(sPath, &sPath); + if (( sKey.getLength() > 0 ) && ( sPath.getLength() > 0 )) reloadChanged(sPrimarySecondary, sGlobalModules, sModule, sKey); } else if ( sGlobalModules.equals(CFG_ENTRY_MODULES) ) { - ::rtl::OUString sModule = ::utl::extractFirstFromConfigurationPath(sPath); - ::rtl::OUString sDropModule = ::rtl::OUString::createFromAscii("Module['") + sModule + ::rtl::OUString::createFromAscii("']"); - sPath = ::utl::dropPrefixFromConfigurationPath(sPath, sDropModule); - sKey = ::utl::extractFirstFromConfigurationPath(sPath); - if ( sKey.getLength() ) + ::rtl::OUString sModule = ::utl::extractFirstFromConfigurationPath(sPath, &sPath); + sKey = ::utl::extractFirstFromConfigurationPath(sPath, &sPath); + + if (( sKey.getLength() > 0 ) && ( sPath.getLength() > 0 )) + { reloadChanged(sPrimarySecondary, sGlobalModules, sModule, sKey); + } } } } @@ -1385,8 +1384,8 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( sal_Bool bPreferred, const aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD1; else if (sToken[k].equalsAscii("MOD2")) aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD2; - else if (sToken[k].equalsAscii("MOD3")) - aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD3; + else if (sToken[k].equalsAscii("MOD3")) + aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD3; else { bValid = sal_False; diff --git a/officecfg/registry/data/org/openoffice/Office/Math.xcu b/officecfg/registry/data/org/openoffice/Office/Math.xcu index 6778873e3386..b65c2422c433 100644..100755 --- a/officecfg/registry/data/org/openoffice/Office/Math.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Math.xcu @@ -48,6 +48,8 @@ <value>0</value> </prop> </node> + + <!-- only used for symbols with the 'Greek' symbol set name --> <node oor:name="Id2" oor:op="replace"> <prop oor:name="Name"> <value>OpenSymbol</value> @@ -65,10 +67,11 @@ <value>0</value> </prop> <prop oor:name="Italic"> - <value>2</value> + <value>0</value> </prop> </node> </node> + <node oor:name="SymbolList"> <node oor:name="alpha" oor:op="replace"> <prop oor:name="Char"> diff --git a/officecfg/registry/data/org/openoffice/Office/Paths.xcu b/officecfg/registry/data/org/openoffice/Office/Paths.xcu index 91a26137b24d..37eebe5c2a22 100644 --- a/officecfg/registry/data/org/openoffice/Office/Paths.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Paths.xcu @@ -169,7 +169,8 @@ <node oor:name="Fingerprint" oor:op="fuse" oor:mandatory="true"> <node oor:name="InternalPaths"> - <node oor:name="$(insturl)/share/fingerprint" oor:op="fuse" /> + <node install:module="internallibtextcatdata" oor:name="$(insturl)/share/fingerprint" oor:op="fuse"/> + <node install:module="externallibtextcatdata" oor:name="${SYSTEM_LIBTEXTCAT_DATA}" oor:op="fuse"/> </node> </node> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index 33e5109405d0..5c72d948436f 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE oor:component-data SYSTEM "../../../../../component-update.dtd"> <oor:component-data oor:name="CalcCommands" oor:package="org.openoffice.Office.UI" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <node oor:name="UserInterface"> @@ -160,6 +160,14 @@ <value xml:lang="en-US">~Select...</value> </prop> </node> + <node oor:name=".uno:TableEvents" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Sheet ~Events...</value> + </prop> + <prop oor:name="ContextLabel" oor:type="xs:string"> + <value xml:lang="en-US">~Events...</value> + </prop> + </node> <node oor:name=".uno:DataPilotFilter" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">DataPilot Filter</value> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index ebed194fcffc..479827565775 100644..100755 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -1463,9 +1463,6 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Find Text</value> </prop> - <prop oor:name="Properties" oor:type="xs:int"> - <value>1</value> - </prop> </node> <node oor:name=".uno:DownSearch" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> @@ -1487,9 +1484,6 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Focus to Findbar</value> </prop> - <prop oor:name="Properties" oor:type="xs:int"> - <value>1</value> - </prop> </node> <node oor:name=".uno:ExtendedHelp" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> @@ -2139,9 +2133,6 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Sentence case</value> </prop> - <prop oor:name="Properties" oor:type="xs:int"> - <value>1</value> - </prop> </node> <node oor:name=".uno:ChangeCaseToLower" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> @@ -2163,17 +2154,11 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Capitalize Every Word</value> </prop> - <prop oor:name="Properties" oor:type="xs:int"> - <value>1</value> - </prop> </node> <node oor:name=".uno:ChangeCaseToToggleCase" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~tOGGLE cASE</value> </prop> - <prop oor:name="Properties" oor:type="xs:int"> - <value>1</value> - </prop> </node> <node oor:name=".uno:ChangeCaseToHalfWidth" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> diff --git a/officecfg/registry/data/org/openoffice/Office/makefile.mk b/officecfg/registry/data/org/openoffice/Office/makefile.mk index e65b03371da3..2af1e8629bd9 100644 --- a/officecfg/registry/data/org/openoffice/Office/makefile.mk +++ b/officecfg/registry/data/org/openoffice/Office/makefile.mk @@ -87,6 +87,8 @@ MODULEFILES= \ Paths-macosx.xcu \ Paths-unxwnt.xcu \ Paths-unixdesktop.xcu \ + Paths-internallibtextcatdata.xcu \ + Paths-externallibtextcatdata.xcu \ Writer-cjk.xcu \ Impress-ogltrans.xcu \ Embedding-calc.xcu \ diff --git a/officecfg/registry/schema/org/openoffice/Office/Math.xcs b/officecfg/registry/schema/org/openoffice/Office/Math.xcs index caa8726b7c72..31f6e00a230a 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Math.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Math.xcs @@ -402,7 +402,28 @@ </info> <value>false</value> </prop> - <prop oor:name="ScaleNormalBracket" oor:type="xs:boolean"> + <prop oor:name="GreekCharStyle" oor:type="xs:short"> + <!-- UIHints: n/a yet --> + <info> + <author>TL</author> + <desc>Specifies the default layout for symbols from the 'Greek' symbol set.</desc> + <label>Greek character style</label> + </info> + <constraints> + <minInclusive oor:value="0"> + <info> + <desc>Specifies the minimum value allowed</desc> + </info> + </minInclusive> + <maxInclusive oor:value="2"> + <info> + <desc>Specifies the maximum value allowed</desc> + </info> + </maxInclusive> + </constraints> + <value>0</value> + </prop> + <prop oor:name="ScaleNormalBracket" oor:type="xs:boolean"> <!-- OldPath: Math/StandardFormat --> <!-- OldLocation: Soffice.cfg --> <!-- UIHints: Format - Spacing - Category - Brackets - Scale all brackets --> diff --git a/officecfg/registry/schema/org/openoffice/Office/OOoImprovement/Settings.xcs b/officecfg/registry/schema/org/openoffice/Office/OOoImprovement/Settings.xcs index 7b0b221f15a9..7ff91464727d 100755 --- a/officecfg/registry/schema/org/openoffice/Office/OOoImprovement/Settings.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/OOoImprovement/Settings.xcs @@ -15,7 +15,7 @@ OpenOffice.org Improvement Program. If this is zero the user will get asked. </desc> </info> - <value>2</value> + <value>1</value> </prop> <prop oor:name="InvitationAccepted" oor:type="xs:boolean"> <info> diff --git a/oovbaapi/ooo/vba/XApplicationBase.idl b/oovbaapi/ooo/vba/XApplicationBase.idl index 7f59ddb75247..d9d32e02f2ce 100644 --- a/oovbaapi/ooo/vba/XApplicationBase.idl +++ b/oovbaapi/ooo/vba/XApplicationBase.idl @@ -24,21 +24,15 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_XApplicationBase_idl__ #define __ooo_vba_XApplicationBase_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif - -#ifndef __ooo_vba_XHelperInterface_idl__ #include <ooo/vba/XHelperInterface.idl> -#endif module ooo { module vba { -//============================================================================= - +//============================================================================= interface XApplicationBase { @@ -47,8 +41,9 @@ interface XApplicationBase [attribute] boolean ScreenUpdating; [attribute] boolean DisplayStatusBar; [attribute] boolean Interactive; + [attribute] boolean Visible; + [attribute, readonly] string Version; - //mbn [attribute, readonly] any VBE; [attribute, readonly] any VBProjects; @@ -61,6 +56,8 @@ interface XApplicationBase void Undo(); }; +//============================================================================= + }; }; #endif diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl index 39693a37511c..6f513ae64577 100644 --- a/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/oovbaapi/ooo/vba/excel/XApplication.idl @@ -64,6 +64,7 @@ interface XApplication [attribute] any CutCopyMode; [attribute] any StatusBar; [attribute] long Cursor; + [attribute] boolean EnableEvents; void setDefaultFilePath([in] string DefaultFilePath) raises(com::sun::star::script::BasicErrorException); diff --git a/oovbaapi/ooo/vba/excel/XWorksheet.idl b/oovbaapi/ooo/vba/excel/XWorksheet.idl index 271cd81d4d0e..fb6261bc06c0 100644 --- a/oovbaapi/ooo/vba/excel/XWorksheet.idl +++ b/oovbaapi/ooo/vba/excel/XWorksheet.idl @@ -114,6 +114,7 @@ interface XWorksheet XRange Rows([in] any aIndex); XRange Columns([in] any aIndex); any Hyperlinks( [in] any aIndex ); + any Names( [in] any Index ); any Evaluate( [in] string Name); diff --git a/oovbaapi/ooo/vba/excel/makefile.mk b/oovbaapi/ooo/vba/excel/makefile.mk index 12dcf025e489..251588086701 100644 --- a/oovbaapi/ooo/vba/excel/makefile.mk +++ b/oovbaapi/ooo/vba/excel/makefile.mk @@ -29,7 +29,7 @@ PRJ=..$/..$/.. PRJNAME=oovapi TARGET=excel -PACKAGE=ooo$/vba$/Excel +PACKAGE=ooo$/vba$/excel # --- Settings ----------------------------------------------------- .INCLUDE : $(PRJ)$/util$/makefile.pmk diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk index 75f6465bf4c0..4f6d378cfe3f 100644 --- a/oovbaapi/ooo/vba/makefile.mk +++ b/oovbaapi/ooo/vba/makefile.mk @@ -61,9 +61,8 @@ IDLFILES=\ XFontBase.idl\ XDialogsBase.idl\ XDialogBase.idl\ - XPageSetupBase.idl \ - XVBAAppService.idl\ - XVBADocService.idl\ + XPageSetupBase.idl + # ------------------------------------------------------------------ .ENDIF .INCLUDE : target.mk diff --git a/oovbaapi/ooo/vba/word/makefile.mk b/oovbaapi/ooo/vba/word/makefile.mk index e3a19e678414..543e99f7c538 100644 --- a/oovbaapi/ooo/vba/word/makefile.mk +++ b/oovbaapi/ooo/vba/word/makefile.mk @@ -29,7 +29,7 @@ PRJ=..$/..$/.. PRJNAME=oovapi TARGET=word -PACKAGE=ooo$/vba$/Word +PACKAGE=ooo$/vba$/word # --- Settings ----------------------------------------------------- .INCLUDE : $(PRJ)$/util$/makefile.pmk diff --git a/oovbaapi/prj/d.lst b/oovbaapi/prj/d.lst index ac5924e2d684..86e801a15d93 100644 --- a/oovbaapi/prj/d.lst +++ b/oovbaapi/prj/d.lst @@ -8,7 +8,7 @@ mkdir: %COMMON_DEST%\idl%_EXT%\ooo\vba\word ..\%__SRC%\ucr\oovbaapi.db %_DEST%\bin%_EXT%\oovbaapi.rdb -..\ooo\vba\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\ +..\ooo\vba\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba ..\ooo\vba\constants\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\constants ..\ooo\vba\excel\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\excel ..\ooo\vba\msforms\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\msforms diff --git a/readlicense_oo/util/makefile.pmk b/readlicense_oo/util/makefile.pmk index 30e07779457b..0efd9712f11d 100755 --- a/readlicense_oo/util/makefile.pmk +++ b/readlicense_oo/util/makefile.pmk @@ -57,7 +57,7 @@ $(MISC)$/readme_text.xsl : virtual $(MISC)$/$(GUI)$/$(eq,$(GUI),WNT readme README)_%.html : 'virtual' @@-$(MKDIRHIER) $(@:d) - $(XSLTPROC) --nonet -o $@ \ + $(XSLTPROC) --nonet --novalid -o $@ \ --stringparam os1 $(OS) --stringparam gui1 $(GUI) --stringparam com1 $(COM) \ --stringparam cp1 $(CPUNAME) --stringparam type html --stringparam lang1 $* \ ..$/readme.xsl $(MERGEDXRM) @@ -67,7 +67,7 @@ $(MISC)$/$(GUI)$/$(eq,$(GUI),WNT readme README)_%.html : 'virtual' $(MISC)$/$(GUI)$/$(eq,$(GUI),OS2 readme README)_%.html : 'virtual' @@-$(MKDIRHIER) $(@:d) - $(XSLTPROC) --nonet -o $@ \ + $(XSLTPROC) --nonet --novalid -o $@ \ --stringparam os1 $(OS) --stringparam gui1 $(GUI) --stringparam com1 $(COM) \ --stringparam cp1 $(CPUNAME) --stringparam type html --stringparam lang1 $* \ ..$/readme.xsl $(MERGEDXRM) @@ -75,7 +75,7 @@ $(MISC)$/$(GUI)$/$(eq,$(GUI),OS2 readme README)_%.html : 'virtual' # no percent-rule to avoid ambiguous inference chains for README_<lang>.html $(SYSTEXTDOCS) : $(MISC)$/readme_text.xsl @@-$(MKDIRHIER) $(@:d) - $(XSLTPROC) --nonet -o $@ \ + $(XSLTPROC) --nonet --novalid -o $@ \ --stringparam os1 $(OS) --stringparam gui1 $(GUI) --stringparam com1 $(COM) \ --stringparam cp1 $(CPUNAME) --stringparam type text --stringparam lang1 $(@:b:s/readme_//:s/README_//) \ $< $(MERGEDXRM) diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx index aa6c6cfb966a..0fc0778c71d9 100644 --- a/scripting/source/dlgprov/dlgprov.cxx +++ b/scripting/source/dlgprov/dlgprov.cxx @@ -766,6 +766,31 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs return xDialog; } + Reference < XDialog > DialogProviderImpl::createDialogWithArguments( + const ::rtl::OUString& URL, const Sequence< NamedValue >& Arguments ) + throw (IllegalArgumentException, RuntimeException) + { + ::comphelper::NamedValueCollection aArguments( Arguments ); + + Reference< XWindowPeer > xParentPeer; + if ( aArguments.has( "ParentWindow" ) ) + { + const Any aParentWindow( aArguments.get( "ParentWindow" ) ); + if ( !( aParentWindow >>= xParentPeer ) ) + { + const Reference< XControl > xParentControl( aParentWindow, UNO_QUERY ); + if ( xParentControl.is() ) + xParentPeer = xParentControl->getPeer(); + } + } + + const Reference< XInterface > xHandler( aArguments.get( "EventHandler" ), UNO_QUERY ); + + Reference < XControl > xControl = DialogProviderImpl::createDialogImpl( URL, xHandler, xParentPeer, true ); + Reference< XDialog > xDialog( xControl, UNO_QUERY ); + return xDialog; + } + Reference< XWindow > DialogProviderImpl::createContainerWindow( const ::rtl::OUString& URL, const ::rtl::OUString& WindowType, const Reference< XWindowPeer >& xParent, const Reference< XInterface >& xHandler ) diff --git a/scripting/source/dlgprov/dlgprov.hxx b/scripting/source/dlgprov/dlgprov.hxx index f55239ff13e8..bc15831d2ff1 100644 --- a/scripting/source/dlgprov/dlgprov.hxx +++ b/scripting/source/dlgprov/dlgprov.hxx @@ -138,6 +138,11 @@ namespace dlgprov const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialogWithArguments( + const ::rtl::OUString& URL, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createContainerWindow( const ::rtl::OUString& URL, const ::rtl::OUString& WindowType, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent, diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py index 55c204f87dbf..6592a59d1843 100644 --- a/scripting/source/pyprov/mailmerge.py +++ b/scripting/source/pyprov/mailmerge.py @@ -153,8 +153,8 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): if len(textbody): mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType) - if mimeEncoding.find('charset=UTF-8') == -1: - mimeEncoding = mimeEncoding + "; charset=UTF-8" + if mimeEncoding.find('charset=UTF-8') == -1: + mimeEncoding = mimeEncoding + "; charset=UTF-8" textmsg['Content-Type'] = mimeEncoding textmsg['MIME-Version'] = '1.0' textmsg.set_payload(textbody) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 63eb9e8c876f..9473ac126bd7 100755..100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -293,6 +293,7 @@ public: sal_Bool IsReadOnlyUI() const; void SetNoName(); sal_Bool IsInModalMode() const; + sal_Bool IsInPrepareClose() const; //<!--Added by PengYunQuan for Validity Cell Range Picker virtual sal_Bool AcceptStateUpdate() const; //-->Added by PengYunQuan for Validity Cell Range Picker @@ -346,6 +347,9 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); virtual void UpdateLinks(); + // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action + virtual sal_Bool QuerySlotExecutable( USHORT nSlotId ); + sal_Bool SaveChildren(BOOL bObjectsOnly=FALSE); sal_Bool SaveAsChildren( SfxMedium &rMedium ); sal_Bool SwitchChildrenPersistance( diff --git a/sfx2/qa/cppunit/makefile.mk b/sfx2/qa/cppunit/makefile.mk index 2794c2ae92bb..dce0b86a0619 100644 --- a/sfx2/qa/cppunit/makefile.mk +++ b/sfx2/qa/cppunit/makefile.mk @@ -35,6 +35,13 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk +#building with stlport, but cppunit was not built with stlport +.IF "$(USE_SYSTEM_STL)"!="YES" +.IF "$(SYSTEM_CPPUNIT)"=="YES" +CFLAGSCXX+=-DADAPT_EXT_STL +.ENDIF +.ENDIF + CFLAGSCXX += $(CPPUNIT_CFLAGS) DLLPRE = # no leading "lib" on .so files diff --git a/sfx2/qa/cppunit/test_metadatable.cxx b/sfx2/qa/cppunit/test_metadatable.cxx index 903be6920327..6a0be13a9c53 100644 --- a/sfx2/qa/cppunit/test_metadatable.cxx +++ b/sfx2/qa/cppunit/test_metadatable.cxx @@ -27,10 +27,12 @@ #include "precompiled_sfx2.hxx" +#include "preextstl.h" #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/plugin/TestPlugIn.h> +#include "postextstl.h" #include <rtl/ustrbuf.hxx> diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 3d848d4d5648..3d848d4d5648 100755..100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index d32ee843cbf2..2ac8f6a43fee 100755..100644 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -245,6 +245,36 @@ SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rTabPage, const Sfx m_aRecordChangesCB.SetStyle( m_aRecordChangesCB.GetStyle() | WB_EARLYTOGGLE ); m_aRecordChangesCB.SetToggleHdl( LINK( this, SfxSecurityPage_Impl, RecordChangesCBToggleHdl ) ); m_aChangeProtectionPB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, ChangeProtectionPBHdl ) ); + + + // #i112277: for the time being (OOO 3.3) the following options should not + // be available. In the long run however it is planned to implement the yet + // missing functionality. Thus now we hide them and move the remaining ones up. + m_aNewPasswordToOpenFL.Hide(); + m_aNewPasswordToOpenFT.Hide(); + m_aNewPasswordToOpenED.Hide(); + m_aConfirmPasswordToOpenFT.Hide(); + m_aConfirmPasswordToOpenED.Hide(); + m_aNewPasswordInfoFT.Hide(); + m_aNewPasswordToModifyFL.Hide(); + m_aNewPasswordToModifyFT.Hide(); + m_aNewPasswordToModifyED.Hide(); + m_aConfirmPasswordToModifyFT.Hide(); + m_aConfirmPasswordToModifyED.Hide(); + const long nDelta = m_aOptionsFL.GetPosPixel().Y() - m_aNewPasswordToOpenFL.GetPosPixel().Y(); + Point aPos; + aPos = m_aOptionsFL.GetPosPixel(); + aPos.Y() -= nDelta; + m_aOptionsFL.SetPosPixel( aPos ); + aPos = m_aOpenReadonlyCB.GetPosPixel(); + aPos.Y() -= nDelta; + m_aOpenReadonlyCB.SetPosPixel( aPos ); + aPos = m_aRecordChangesCB.GetPosPixel(); + aPos.Y() -= nDelta; + m_aRecordChangesCB.SetPosPixel( aPos ); + aPos = m_aChangeProtectionPB.GetPosPixel(); + aPos.Y() -= nDelta; + m_aChangeProtectionPB.SetPosPixel( aPos ); } diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src index fee60404d01c..fee60404d01c 100755..100644 --- a/sfx2/source/dialog/securitypage.src +++ b/sfx2/source/dialog/securitypage.src diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index c063546da1c7..066f366b09bd 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -489,6 +489,13 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) case SID_SAVEASDOC: case SID_SAVEDOC: { + // derived class may decide to abort this + if( !QuerySlotExecutable( nId ) ) + { + rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) ); + return; + } + //!! detaillierte Auswertung eines Fehlercodes SfxObjectShellRef xLock( this ); @@ -895,7 +902,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) rReq.Done(); } -//-------------------------------------------------------------------- +//------------------------------------------------------------------------- void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) { diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 49188defc4f1..6c4bdf56ba26 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -195,6 +195,13 @@ sal_Bool SfxObjectShell::SaveAs( SfxMedium& rMedium ) //------------------------------------------------------------------------- +sal_Bool SfxObjectShell::QuerySlotExecutable( USHORT /*nSlotId*/ ) +{ + return sal_True; +} + +//------------------------------------------------------------------------- + sal_Bool GetPasswd_Impl( const SfxItemSet* pSet, ::rtl::OUString& rPasswd ) { const SfxPoolItem* pItem = NULL; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index f202266dd74e..b7567b89f02f 100755..100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -526,6 +526,13 @@ SfxObjectShell* SfxObjectShell::Current() return pFrame ? pFrame->GetObjectShell() : 0; } +//------------------------------------------------------------------------- + +sal_Bool SfxObjectShell::IsInPrepareClose() const +{ + return pImp->bInPrepareClose; +} + //------------------------------------------------------------------------ struct BoolEnv_Impl diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index b5a9536b12c5..7ef9fe0d2f19 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -977,6 +977,8 @@ sal_Bool SAL_CALL SfxBaseModel::attachResource( const ::rtl::OUString& aArgs.remove( "BreakMacroSignature" ); aArgs.remove( "Stream" ); aArgs.remove( "InputStream" ); + aArgs.remove( "URL" ); + aArgs.remove( "Frame" ); // TODO/LATER: all the parameters that are accepted by ItemSet of the DocShell must be removed here @@ -988,6 +990,10 @@ sal_Bool SAL_CALL SfxBaseModel::attachResource( const ::rtl::OUString& SfxAllItemSet aSet( pObjectShell->GetPool() ); TransformParameters( SID_OPENDOC, rArgs, aSet ); + // the arguments are not allowed to reach the medium + aSet.ClearItem( SID_FILE_NAME ); + aSet.ClearItem( SID_FILLFRAME ); + pMedium->GetItemSet()->Put( aSet ); SFX_ITEMSET_ARG( &aSet, pItem, SfxStringItem, SID_FILTER_NAME, sal_False ); if ( pItem ) diff --git a/sfx2/source/doc/syspathw32.cxx b/sfx2/source/doc/syspathw32.cxx index 73bd84f5249a..c0a163bed39c 100644 --- a/sfx2/source/doc/syspathw32.cxx +++ b/sfx2/source/doc/syspathw32.cxx @@ -74,7 +74,7 @@ typedef unsigned short sal_uInt16; extern "C" bool GetUserTemplateLocation(sal_Unicode* pFolder, int nSize) { #ifdef WNT - return _SHGetSpecialFolderW32( CSIDL_TEMPLATES, pFolder, nSize ); + return _SHGetSpecialFolderW32( CSIDL_TEMPLATES, reinterpret_cast<LPWSTR>(pFolder), nSize ); #else (void)pFolder; (void)nSize; diff --git a/sfx2/source/menu/mnumgr.cxx b/sfx2/source/menu/mnumgr.cxx index b264a5b47861..bc765b95340c 100755 --- a/sfx2/source/menu/mnumgr.cxx +++ b/sfx2/source/menu/mnumgr.cxx @@ -578,6 +578,7 @@ SfxPopupMenuManager* SfxPopupMenuManager::Popup( const ResId& rResId, SfxViewFra return 0; } + void SfxPopupMenuManager::ExecutePopup( const ResId& rResId, SfxViewFrame* pFrame, const Point& rPoint, Window* pWindow ) { PopupMenu *pSVMenu = new PopupMenu( rResId ); @@ -622,6 +623,12 @@ void SfxPopupMenuManager::ExecutePopup( const ResId& rResId, SfxViewFrame* pFram SfxPopupMenuManager aPop( pSVMenu, pFrame->GetBindings() ); aPop.RemoveDisabledEntries(); aPop.Execute( rPoint, pWindow ); + + // #i112646 avoid crash when context menu is closed. + // the (manually inserted) sub-menu needs to be destroyed before + // aPop gets destroyed. + delete pThesSubMenu; + pThesSubMenu = 0; } delete pThesSubMenu; @@ -631,3 +638,4 @@ Menu* SfxPopupMenuManager::GetSVMenu() { return (Menu*) GetMenu()->GetSVMenu(); } + diff --git a/sfx2/source/view/frame2.cxx b/sfx2/source/view/frame2.cxx index d99ad8733e03..d43512ac791d 100644 --- a/sfx2/source/view/frame2.cxx +++ b/sfx2/source/view/frame2.cxx @@ -280,10 +280,7 @@ SfxFrame* SfxFrame::Create( SfxObjectShell& rDoc, Window& rWindow, USHORT nViewI aLoadArgs = aArgs.getPropertyValues(); // load the doc into that frame - ::rtl::OUString sLoaderURL( rDoc.GetModel()->getURL() ); - if ( sLoaderURL.getLength() == 0 ) - sLoaderURL = rDoc.GetFactory().GetFactoryURL(); - + ::rtl::OUString sLoaderURL( RTL_CONSTASCII_USTRINGPARAM( "private:object" ) ); Reference< XComponentLoader > xLoader( xFrame, UNO_QUERY_THROW ); xLoader->loadComponentFromURL( sLoaderURL, diff --git a/sfx2/source/view/userinputinterception.cxx b/sfx2/source/view/userinputinterception.cxx index e716e604b649..ad910a944e0f 100644 --- a/sfx2/source/view/userinputinterception.cxx +++ b/sfx2/source/view/userinputinterception.cxx @@ -216,6 +216,13 @@ namespace sfx2 if ( e.Context == xHandler ) aIterator.remove(); } + catch( const RuntimeException& ) + { + throw; + } + catch( const Exception& ) + { + } } } break; @@ -247,6 +254,13 @@ namespace sfx2 if ( e.Context == xHandler ) aIterator.remove(); } + catch( const RuntimeException& ) + { + throw; + } + catch( const Exception& ) + { + } } } break; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 43df53612989..dcda416a3d16 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -813,6 +813,13 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) xNewObj->SetModifyPasswordEntered( sal_False ); xNewObj->SetReadOnly(); } + else if ( rReq.GetSlot() == SID_EDITDOC && bForEdit && !xNewObj->IsReadOnlyMedium() ) + { + // the filter might request setting of the document to readonly state + // but in case of SID_EDITDOC it should not happen if the document + // can be opened for editing + xNewObj->SetReadOnlyUI( sal_False ); + } if ( xNewObj->IsDocShared() ) { @@ -2137,6 +2144,8 @@ SfxViewShell* SfxViewFrame::LoadViewIntoFrame_Impl( const SfxObjectShell& i_rDoc aTransformLoadArgs.remove( "Hidden" ); ::rtl::OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "private:object" ) ); + if ( !sURL.getLength() ) + sURL = i_rDoc.GetFactory().GetFactoryURL(); Reference< XComponentLoader > xLoader( i_rFrame, UNO_QUERY_THROW ); xLoader->loadComponentFromURL( sURL, ::rtl::OUString::createFromAscii( "_self" ), 0, diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx index 1c9e219cf180..be20cd2f2a47 100644 --- a/sfx2/source/view/viewimp.hxx +++ b/sfx2/source/view/viewimp.hxx @@ -75,7 +75,7 @@ struct SfxViewShell_Impl ::svt::AcceleratorExecute* pAccExec; com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aPrintOpts; ::rtl::Reference< SfxClipboardChangeListener > xClipboardListener; - vcl::PrinterController* pPrinterController; + ::boost::shared_ptr< vcl::PrinterController > m_pPrinterController; SfxViewShell_Impl(); }; diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index f62ae4c1ddc7..4ed0173be8e1 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -332,7 +332,9 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt mpObjectShell->EnableSetModified( m_bOrigStatus ); if ( mpViewShell ) - mpViewShell->pImp->pPrinterController = 0; + { + mpViewShell->pImp->m_pPrinterController.reset(); + } } } @@ -643,7 +645,7 @@ void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro this, rProps ) ); - pImp->pPrinterController = pController.get(); + pImp->m_pPrinterController = pController; SfxObjectShell *pObjShell = GetObjectShell(); pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobName" ) ), @@ -661,7 +663,8 @@ void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro Printer* SfxViewShell::GetActivePrinter() const { - return pImp->pPrinterController ? pImp->pPrinterController->getPrinter().get() : 0; + return (pImp->m_pPrinterController) + ? pImp->m_pPrinterController->getPrinter().get() : 0; } void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) @@ -697,6 +700,14 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) case SID_PRINTDOCDIRECT: { SfxObjectShell* pDoc = GetObjectShell(); + + // derived class may decide to abort this + if( !pDoc->QuerySlotExecutable( nId ) ) + { + rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) ); + return; + } + bool bDetectHidden = ( !bSilent && pDoc ); if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES ) break; diff --git a/svx/inc/svx/dialogs.hrc b/svx/inc/svx/dialogs.hrc index d193652b57fc..fd7561bb7192 100755..100644 --- a/svx/inc/svx/dialogs.hrc +++ b/svx/inc/svx/dialogs.hrc @@ -956,7 +956,9 @@ #define RID_SVXSTR_OUTLINENUM_DESCRIPTION_6 (RID_SVXSTR_OUTLINENUM_DESCRIPTIONS + 6)//? #define RID_SVXSTR_OUTLINENUM_DESCRIPTION_7 (RID_SVXSTR_OUTLINENUM_DESCRIPTIONS + 7)//? -#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1190) +#define RID_SVXSTR_FINDBAR_FIND (RID_SVX_START + 1190) + +#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1191) // ---------------------------------------------------------------------------- // if we have _a_lot_ time, we should group the resource ids by type, instead diff --git a/svx/inc/svx/sdrmasterpagedescriptor.hxx b/svx/inc/svx/sdrmasterpagedescriptor.hxx index 612f2ab927ec..3a31c3d11206 100644 --- a/svx/inc/svx/sdrmasterpagedescriptor.hxx +++ b/svx/inc/svx/sdrmasterpagedescriptor.hxx @@ -35,6 +35,7 @@ // predeclarations class SdrObject; class SfxItemSet; +class SdrPageProperties; namespace sdr { @@ -89,6 +90,8 @@ namespace sdr // operators sal_Bool operator==(const MasterPageDescriptor& rCandidate) const; sal_Bool operator!=(const MasterPageDescriptor& rCandidate) const; + + const SdrPageProperties* getCorrectSdrPageProperties() const; }; } // end of namespace sdr diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx index 2da51b798fa7..b1bb7d74887f 100644 --- a/svx/inc/svx/svdmodel.hxx +++ b/svx/inc/svx/svdmodel.hxx @@ -276,7 +276,7 @@ public: SdrOutlinerCache* mpOutlinerCache; SdrModelImpl* mpImpl; UINT16 mnCharCompressType; - UINT16 nReserveUInt5; + UINT16 mnHandoutPageCount; UINT16 nReserveUInt6; UINT16 nReserveUInt7; FASTBOOL mbModelLocked; @@ -298,6 +298,10 @@ public: SvNumberFormatter* mpNumberFormatter; public: const SvNumberFormatter& GetNumberFormatter() const; + + UINT16 getHandoutPageCount() const { return mnHandoutPageCount; } + void setHandoutPageCount( UINT16 nHandoutPageCount ) { mnHandoutPageCount = nHandoutPageCount; } + protected: virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel(); diff --git a/svx/inc/svx/svdpage.hxx b/svx/inc/svx/svdpage.hxx index c601fddef181..784598d7d544 100644 --- a/svx/inc/svx/svdpage.hxx +++ b/svx/inc/svx/svdpage.hxx @@ -448,6 +448,7 @@ private: public: SdrPageProperties& getSdrPageProperties() { return *mpSdrPageProperties; } const SdrPageProperties& getSdrPageProperties() const { return *mpSdrPageProperties; } + const SdrPageProperties* getCorrectSdrPageProperties() const; protected: // new MasterPageDescriptorVector diff --git a/svx/source/gengal/gengal.cxx b/svx/source/gengal/gengal.cxx index bc8e6ef7c4bd..4120027c3e35 100644 --- a/svx/source/gengal/gengal.cxx +++ b/svx/source/gengal/gengal.cxx @@ -241,8 +241,9 @@ void GalApp::Init() #endif rtl::OUString baseBinDir = fileName.copy( 0, lastSlash ); rtl::OUString installPrefix = baseBinDir + rtl::OUString::createFromAscii( "/../.." ); - rtl::OUString assignment = rtl::OUString::createFromAscii( "OOO_INSTALL_PREFIX=" ) + installPrefix; - putenv( strdup( OUSTRING_CSTR( assignment ))); + + rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("OOO_INSTALL_PREFIX")); + osl_setEnvironment(envVar.pData, installPrefix.pData); } OSL_TRACE( "OOO_INSTALL_PREFIX=%s", getenv( "OOO_INSTALL_PREFIX" ) ); diff --git a/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx b/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx index cbe9c4a9c615..6ca5f1c4d172 100644 --- a/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx +++ b/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx @@ -62,23 +62,7 @@ namespace sdr { drawinglayer::primitive2d::Primitive2DSequence xRetval; drawinglayer::attribute::SdrFillAttribute aFill; - const SdrPage* pCorrectPage = &GetMasterPageDescriptor().GetOwnerPage(); - const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties(); - - if(XFILL_NONE == ((const XFillStyleItem&)pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue()) - { - pCorrectPage = &GetMasterPageDescriptor().GetUsedPage(); - pCorrectProperties = &pCorrectPage->getSdrPageProperties(); - } - - if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet()) - { - // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets, - // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all - // MasterPages should have a StyleSheet excactly for this reason, but historically - // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others). - pCorrectProperties = 0; - } + const SdrPageProperties* pCorrectProperties = GetMasterPageDescriptor().getCorrectSdrPageProperties(); if(pCorrectProperties) { diff --git a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx index 5ef26193d4b3..34731f100b5d 100644 --- a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx @@ -273,9 +273,16 @@ namespace sdr // init extractor, guarantee existance, set page there mpExtractor->SetStartPage(pPage); + // #i105548# also need to copy the VOCRedirector for sub-content creation + mpExtractor->SetViewObjectContactRedirector(GetObjectContact().GetViewObjectContactRedirector()); + // create page content xPageContent = mpExtractor->createPrimitive2DSequenceForPage(rDisplayInfo); + // #i105548# reset VOCRedirector to not accidentially have a pointer to a + // temporary class, so calls to it are avoided safely + mpExtractor->SetViewObjectContactRedirector(0); + // reset recursion flag bInCreatePrimitive2D = false; } diff --git a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx index 2320944afd03..089f75aa8ade 100644 --- a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx @@ -77,8 +77,16 @@ namespace if(pPage && pPage->GetModel()) { - const sal_uInt16 nPageCount(pPage->GetModel()->GetPageCount()); - nRetval = ((sal_Int16)nPageCount - 1) / 2; + if( (pPage->GetPageNum() == 0) && !pPage->IsMasterPage() ) + { + // handout page! + return pPage->GetModel()->getHandoutPageCount(); + } + else + { + const sal_uInt16 nPageCount(pPage->GetModel()->GetPageCount()); + nRetval = ((sal_Int16)nPageCount - 1) / 2; + } } return nRetval; diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx index 348c319e256e..091656e1f261 100644 --- a/svx/source/sdr/properties/textproperties.cxx +++ b/svx/source/sdr/properties/textproperties.cxx @@ -185,18 +185,21 @@ namespace sdr { SdrText* pText = rObj.getText( nCount ); OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject(); - rOutliner.SetText(*pParaObj); - sal_uInt32 nParaCount(rOutliner.GetParagraphCount()); - - if(nParaCount) + if( pParaObj ) { - ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL); - rOutliner.RemoveAttribs(aSelection, sal_True, 0); + rOutliner.SetText(*pParaObj); + sal_uInt32 nParaCount(rOutliner.GetParagraphCount()); - OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount); - rOutliner.Clear(); + if(nParaCount) + { + ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL); + rOutliner.RemoveAttribs(aSelection, sal_True, 0); - rObj.NbcSetOutlinerParaObjectForText( pTemp, pText ); + OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount); + rOutliner.Clear(); + + rObj.NbcSetOutlinerParaObjectForText( pTemp, pText ); + } } } } diff --git a/svx/source/svdraw/sdrmasterpagedescriptor.cxx b/svx/source/svdraw/sdrmasterpagedescriptor.cxx index 67b2de8b693c..eb757a8ee41c 100644 --- a/svx/source/svdraw/sdrmasterpagedescriptor.cxx +++ b/svx/source/svdraw/sdrmasterpagedescriptor.cxx @@ -113,6 +113,29 @@ namespace sdr || &maUsedPage != &rCandidate.maUsedPage || maVisibleLayers != rCandidate.maVisibleLayers); } + + const SdrPageProperties* MasterPageDescriptor::getCorrectSdrPageProperties() const + { + const SdrPage* pCorrectPage = &GetOwnerPage(); + const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties(); + + if(XFILL_NONE == ((const XFillStyleItem&)pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue()) + { + pCorrectPage = &GetUsedPage(); + pCorrectProperties = &pCorrectPage->getSdrPageProperties(); + } + + if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet()) + { + // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets, + // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all + // MasterPages should have a StyleSheet excactly for this reason, but historically + // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others). + pCorrectProperties = 0; + } + + return pCorrectProperties; + } } // end of namespace sdr ////////////////////////////////////////////////////////////////////////////// diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 2fcdfdffbb8a..8ab385fa329c 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -178,6 +178,7 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe mpOutlinerCache = NULL; mbKernAsianPunctuation = sal_False; mbAddExtLeading = sal_False; + mnHandoutPageCount = 0; SvxAsianConfig aAsian; mnCharCompressType = aAsian.GetCharDistanceCompression(); diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index fffcac00e46c..ee9e8f48634b 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -1063,8 +1063,7 @@ void SdrMarkView::AddDragModeHdl(SdrDragMode eMode) /** handle mouse over effects for handles */ BOOL SdrMarkView::MouseMove(const MouseEvent& rMEvt, Window* pWin) { - const ULONG nHdlCount = aHdl.GetHdlCount(); - if( nHdlCount ) + if(aHdl.GetHdlCount()) { SdrHdl* pMouseOverHdl = 0; if( !rMEvt.IsLeaveWindow() && pWin ) @@ -1074,6 +1073,8 @@ BOOL SdrMarkView::MouseMove(const MouseEvent& rMEvt, Window* pWin) } // notify last mouse over handle that he lost the mouse + const ULONG nHdlCount = aHdl.GetHdlCount(); + for(ULONG nHdl = 0; nHdl < nHdlCount; nHdl++ ) { SdrHdl* pCurrentHdl = GetHdl(nHdl); diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 2b495725c006..9d136ef82eae 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -2927,7 +2927,8 @@ sal_Bool SdrPathObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx:: aScale = aCorrectedRangeNoCurve.getRange(); // define matrix for move polygon to zero point - aMoveToZeroMatrix.translate(-aCorrectedRangeNoCurve.getMinX(), aCorrectedRangeNoCurve.getMinY()); + // #i112280# Added missing minus for Y-Translation + aMoveToZeroMatrix.translate(-aCorrectedRangeNoCurve.getMinX(), -aCorrectedRangeNoCurve.getMinY()); } else { diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 8da0b248f38b..592f41543132 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -1979,6 +1979,18 @@ void SdrPage::ReplaceCommentByIndex(sal_uInt32 nIndex, const sdr::Comment& rNew) } } +const SdrPageProperties* SdrPage::getCorrectSdrPageProperties() const +{ + if(mpMasterPageDescriptor) + { + return mpMasterPageDescriptor->getCorrectSdrPageProperties(); + } + else + { + return &getSdrPageProperties(); + } +} + ////////////////////////////////////////////////////////////////////////////// // use new redirector instead of pPaintProc diff --git a/svx/source/tbxctrls/makefile.mk b/svx/source/tbxctrls/makefile.mk index 73a178d97594..a9ea745f3cc0 100644 --- a/svx/source/tbxctrls/makefile.mk +++ b/svx/source/tbxctrls/makefile.mk @@ -74,6 +74,7 @@ SRC1FILES = \ lboxctrl.src \ linectrl.src \ tbcontrl.src \ + tbunosearchcontrollers.src \ tbxdraw.src \ grafctrl.src diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index f4f03170a90f..e446d3d3b9d5 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -29,6 +29,8 @@ #include "precompiled_svx.hxx" #include "tbunosearchcontrollers.hxx" +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> @@ -91,8 +93,8 @@ FindTextFieldControl::~FindTextFieldControl() void FindTextFieldControl::InitControls_Impl() { - SetText( String( ::rtl::OUString::createFromAscii("Find") ) ); - SetControlForeground(COL_GRAY); + SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) ); + SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor()); EnableAutocomplete(TRUE, TRUE); } @@ -117,7 +119,7 @@ void FindTextFieldControl::Modify() { ComboBox::Modify(); - SetControlForeground( Color( COL_BLACK ) ); + SetControlForeground( GetSettings().GetStyleSettings().GetWindowTextColor() ); } long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) @@ -135,7 +137,10 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode(); if ( (bCtrl && bAlt && KEY_F == nCode) || KEY_ESCAPE == nCode ) + { + nRet = 1; GrabFocusToDocument(); + } if ( KEY_RETURN == nCode ) { @@ -154,6 +159,7 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) lArgs[1].Value <<= sal_False; impl_executeSearch(m_xServiceManager, m_xFrame, lArgs); + nRet = 1; } break; } @@ -170,8 +176,8 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) case EVENT_LOSEFOCUS: if ( GetText().Len() == 0 ) { - SetText( String( ::rtl::OUString::createFromAscii("Find") ) ); - SetControlForeground(COL_GRAY); + SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) ); + SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor()); m_bToClearTextField = sal_True; } break; diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.src b/svx/source/tbxctrls/tbunosearchcontrollers.src new file mode 100644 index 000000000000..9a256ae0cabb --- /dev/null +++ b/svx/source/tbxctrls/tbunosearchcontrollers.src @@ -0,0 +1,33 @@ +/************************************************************************* + * + * 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 <svx/dialogs.hrc> + +String RID_SVXSTR_FINDBAR_FIND +{ + Text [ en-US ] = "Find" ; +}; diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index b80be1076b7e..c58e86f77fc3 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -634,10 +634,16 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, { if( rSettings.mbExportOnlyBackground ) { - pTempBackgroundShape = new SdrRectObj(Rectangle(Point(0,0), pPage->GetSize())); - pTempBackgroundShape->SetMergedItemSet(pPage->getSdrPageProperties().GetItemSet()); - pTempBackgroundShape->SetMergedItem(XLineStyleItem(XLINE_NONE)); - aShapes.push_back(pTempBackgroundShape); + const SdrPageProperties* pCorrectProperties = pPage->getCorrectSdrPageProperties(); + + if(pCorrectProperties) + { + pTempBackgroundShape = new SdrRectObj(Rectangle(Point(0,0), pPage->GetSize())); + pTempBackgroundShape->SetMergedItemSet(pCorrectProperties->GetItemSet()); + pTempBackgroundShape->SetMergedItem(XLineStyleItem(XLINE_NONE)); + pTempBackgroundShape->NbcSetStyleSheet(pCorrectProperties->GetStyleSheet(), true); + aShapes.push_back(pTempBackgroundShape); + } } else { diff --git a/sysui/desktop/debian/makefile.mk b/sysui/desktop/debian/makefile.mk index f0f4e4288639..45e0f331f714 100644 --- a/sysui/desktop/debian/makefile.mk +++ b/sysui/desktop/debian/makefile.mk @@ -45,7 +45,7 @@ TARGET=debian .IF "$(PKGFORMAT)"!="$(PKGFORMAT:s/deb//)" -DEBFILES=$(foreach,i,{$(PRODUCTLIST)} $(PKGDIR)$/$i3.3-$(TARGET)-menus_$(PKGVERSION.$i)-$(PKGREV)_all.deb) +DEBFILES=$(foreach,i,{$(PRODUCTLIST)} $(PKGDIR)$/$i3.4-$(TARGET)-menus_$(PKGVERSION.$i)-$(PKGREV)_all.deb) .ENDIF @@ -60,22 +60,22 @@ ALLTAR : $(DEBFILES) %/DEBIAN/control : $$(@:f) @$(MKDIRHIER) $(@:d) $*$/etc $*$/usr/share/applnk/Office $*$/usr/lib/menu - ln -sf /opt/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//)) $*$/etc$/ - /bin/sh -c -x "cd $(COMMONMISC)$/$(*:f:s/-/ /:1:s/3.3//) && DESTDIR=$(shell @cd $*; pwd) ICON_PREFIX=$(ICONPREFIX) KDEMAINDIR=/usr GNOMEDIR=/usr create_tree.sh" - @cat openoffice.org-debian-menus | sed -e 's/%PRODUCTNAME/$(PRODUCTNAME.$(*:f:s/-/ /:1:s/3.3//)) $(PRODUCTVERSION.$(*:f:s/-/ /:1:s/3.3//))/' -e 's/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//))/' -e 's/%ICONPREFIX/$(ICONPREFIX.$(*:f:s/-/ /:1:s/3.3//))/' > $*$/usr/lib/menu/$(*:f:s/_/ /:1:s/3.3//) - echo "Package: $(*:f:s/_/ /:1:s/3.3//)" > $@ - cat $(@:f) | tr -d "\015" | sed "s/%productname/$(PRODUCTNAME.$(*:f:s/-/ /:1:s/3.3//))/" >> $@ - echo "Version: $(PKGVERSION.$(*:f:s/-/ /:1:s/3.3//))-$(PKGREV)" >> $@ + ln -sf /opt/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.4//)) $*$/etc$/ + /bin/sh -c -x "cd $(COMMONMISC)$/$(*:f:s/-/ /:1:s/3.4//) && DESTDIR=$(shell @cd $*; pwd) ICON_PREFIX=$(ICONPREFIX) KDEMAINDIR=/usr GNOMEDIR=/usr create_tree.sh" + @cat openoffice.org-debian-menus | sed -e 's/%PRODUCTNAME/$(PRODUCTNAME.$(*:f:s/-/ /:1:s/3.4//)) $(PRODUCTVERSION.$(*:f:s/-/ /:1:s/3.4//))/' -e 's/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.4//))/' -e 's/%ICONPREFIX/$(ICONPREFIX.$(*:f:s/-/ /:1:s/3.4//))/' > $*$/usr/lib/menu/$(*:f:s/_/ /:1:s/3.4//) + echo "Package: $(*:f:s/_/ /:1:s/3.4//)" > $@ + cat $(@:f) | tr -d "\015" | sed "s/%productname/$(PRODUCTNAME.$(*:f:s/-/ /:1:s/3.4//))/" >> $@ + echo "Version: $(PKGVERSION.$(*:f:s/-/ /:1:s/3.4//))-$(PKGREV)" >> $@ @du -k -s $* | awk -F ' ' '{ printf "Installed-Size: %s\n", $$1 ; }' >> $@ %/DEBIAN/postinst : $$(@:f) - @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//))/g" > $@ + @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.4//))/g" > $@ %/DEBIAN/postrm : $$(@:f) - @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//))/g" > $@ + @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.4//))/g" > $@ %/DEBIAN/prerm : $$(@:f) - @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//))/g" > $@ + @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.4//))/g" > $@ # --- packaging --------------------------------------------------- diff --git a/sysui/desktop/productversion.mk b/sysui/desktop/productversion.mk index 24b1a2db042d..09141b2276bd 100644 --- a/sysui/desktop/productversion.mk +++ b/sysui/desktop/productversion.mk @@ -46,7 +46,7 @@ PKGDIR=$(BIN) PRODUCTLIST = openoffice.org broffice.org # default values to minimize maintainance effort -PRODUCTVERSION = 3.3 +PRODUCTVERSION = 3.4 PRODUCTVERSIONSHORT = 3 PKGVERSION = $(PRODUCTVERSION) # gnome-vfs treats everything behind the last '.' as an icon extension, diff --git a/sysui/desktop/slackware/makefile.mk b/sysui/desktop/slackware/makefile.mk index 6fde1caf6528..eeeb141c6397 100644 --- a/sysui/desktop/slackware/makefile.mk +++ b/sysui/desktop/slackware/makefile.mk @@ -40,7 +40,7 @@ TARGET=slackware # --- Files -------------------------------------------------------- -MENUFILES=$(PKGDIR)$/{$(PRODUCTLIST)}3.3-$(TARGET)-menus-$(PKGVERSION)-noarch-$(PKGREV).tgz +MENUFILES=$(PKGDIR)$/{$(PRODUCTLIST)}3.4-$(TARGET)-menus-$(PKGVERSION)-noarch-$(PKGREV).tgz # --- Targets ------------------------------------------------------- @@ -59,26 +59,26 @@ $(MISC)/$(TARGET)/usr/share/applications/ : # FIXME: removal of *-extension.* only to create identical packages to OOF680 %/usr/share/applications : @$(MKDIRHIER) $@ - /bin/sh -c "cd $(COMMONMISC)$/$(*:b:s/-/ /:1:s/3.3//); DESTDIR=$(shell @cd $*; pwd) GNOMEDIR="" ICON_PREFIX=$(ICONPREFIX.$(*:b:s/-/ /:1:s/3.3//)) KDEMAINDIR=/opt/kde .$/create_tree.sh" + /bin/sh -c "cd $(COMMONMISC)$/$(*:b:s/-/ /:1:s/3.4//); DESTDIR=$(shell @cd $*; pwd) GNOMEDIR="" ICON_PREFIX=$(ICONPREFIX.$(*:b:s/-/ /:1:s/3.4//)) KDEMAINDIR=/opt/kde .$/create_tree.sh" $(RM) $*$/opt$/kde$/share$/icons$/*$/*$/*$/*-extension.png $(RM) $*$/opt$/kde$/share$/mimelnk$/application$/*-extension.desktop $(RM) $*$/usr$/share$/applications$/*.desktop $(RM) $*$/usr$/bin$/soffice %$/install$/doinst.sh : update-script - @echo "( cd etc ; rm -rf $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//)) )" > $@ - @echo "( cd etc ; ln -snf /opt/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//):s/-//) $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//)) )" >> $@ + @echo "( cd etc ; rm -rf $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.4//)) )" > $@ + @echo "( cd etc ; ln -snf /opt/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.4//):s/-//) $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.4//)) )" >> $@ @echo "( cd usr/bin ; rm -rf soffice )" >> $@ - @echo "( cd usr/bin ; ln -sf /etc/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))/program/soffice soffice )" >> $@ - @echo -e $(foreach,i,$(shell @cat $(COMMONMISC)$/$(*:b:s/-/ /:1:s/3.3//)/launcherlist) "\n( cd usr/share/applications ; rm -rf $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))-$i )\n( cd usr/share/applications ; ln -sf /etc/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))/share/xdg/$i $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))-$i )") >> $@ + @echo "( cd usr/bin ; ln -sf /etc/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.4//))/program/soffice soffice )" >> $@ + @echo -e $(foreach,i,$(shell @cat $(COMMONMISC)$/$(*:b:s/-/ /:1:s/3.4//)/launcherlist) "\n( cd usr/share/applications ; rm -rf $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.4//))-$i )\n( cd usr/share/applications ; ln -sf /etc/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.4//))/share/xdg/$i $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.4//))-$i )") >> $@ @cat $< >> $@ %$/install$/slack-desc : slack-desc @$(MKDIRHIER) $(@:d) - @sed -e "s/PKGNAME/$(*:b:s/-/ /:1:s/3.3//)-$(TARGET)-menus/g" -e "s/PKGVERSION/$(PKGVERSION.$(*:b:s/-/ /:1:s/3.3//))/g" \ - -e "s/LONGPRODUCTNAME/$(PRODUCTNAME.$(*:b:s/-/ /:1:s/3.3//)) $(PRODUCTVERSION.$(*:b:s/-/ /:1:s/3.3//))/g" \ - -e "s/PRODUCTNAME/$(PRODUCTNAME.$(*:b:s/-/ /:1:s/3.3//))/g" \ - -e "s/UNIXFILENAME/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))/g" $< > $@ + @sed -e "s/PKGNAME/$(*:b:s/-/ /:1:s/3.4//)-$(TARGET)-menus/g" -e "s/PKGVERSION/$(PKGVERSION.$(*:b:s/-/ /:1:s/3.4//))/g" \ + -e "s/LONGPRODUCTNAME/$(PRODUCTNAME.$(*:b:s/-/ /:1:s/3.4//)) $(PRODUCTVERSION.$(*:b:s/-/ /:1:s/3.4//))/g" \ + -e "s/PRODUCTNAME/$(PRODUCTNAME.$(*:b:s/-/ /:1:s/3.4//))/g" \ + -e "s/UNIXFILENAME/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.4//))/g" $< > $@ # needed to satisfy the slackware package tools - they need # the entries like this diff --git a/ucb/source/core/cmdenv.cxx b/ucb/source/core/cmdenv.cxx index 0f425e814400..5c0136fab063 100644 --- a/ucb/source/core/cmdenv.cxx +++ b/ucb/source/core/cmdenv.cxx @@ -183,7 +183,7 @@ UcbCommandEnvironment::createServiceFactory( const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr ) { return uno::Reference< lang::XSingleServiceFactory >( - cppu::createOneInstanceFactory( + cppu::createSingleFactory( rxServiceMgr, UcbCommandEnvironment::getImplementationName_Static(), UcbCommandEnvironment_CreateInstance, diff --git a/ucb/source/ucp/package/makefile.mk b/ucb/source/ucp/package/makefile.mk index 8c6dcda31829..a8cdf7430703 100644 --- a/ucb/source/ucp/package/makefile.mk +++ b/ucb/source/ucp/package/makefile.mk @@ -68,6 +68,7 @@ SHL1IMPLIB=i$(TARGET) SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1STDLIBS=\ + $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(SALLIB) \ diff --git a/ucb/source/ucp/package/pkguri.cxx b/ucb/source/ucp/package/pkguri.cxx index feb8daec7905..8424ed906e92 100644 --- a/ucb/source/ucp/package/pkguri.cxx +++ b/ucb/source/ucp/package/pkguri.cxx @@ -36,6 +36,7 @@ #include "rtl/ustrbuf.hxx" #include "osl/diagnose.h" +#include "comphelper/storagehelper.hxx" #include "../inc/urihelper.hxx" @@ -85,7 +86,7 @@ void PackageUri::init() const if ( ( m_aUri.getLength() < PACKAGE_URL_SCHEME_LENGTH + 4 ) ) { // error, but remember that we did a init(). - m_aPath = rtl::OUString::createFromAscii( "/" ); + m_aPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); return; } @@ -100,7 +101,7 @@ void PackageUri::init() const != sal_Unicode( '/' ) ) ) { // error, but remember that we did a init(). - m_aPath = rtl::OUString::createFromAscii( "/" ); + m_aPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); return; } @@ -128,8 +129,8 @@ void PackageUri::init() const { m_aParam += ( m_aParam.getLength() - ? ::rtl::OUString::createFromAscii( "&purezip" ) - : ::rtl::OUString::createFromAscii( "?purezip" ) ); + ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "&purezip" ) ) + : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "?purezip" ) ) ); } aPureUri = aPureUri.replaceAt( 0, @@ -143,7 +144,7 @@ void PackageUri::init() const // Only <scheme>:/// - Empty authority // error, but remember that we did a init(). - m_aPath = rtl::OUString::createFromAscii( "/" ); + m_aPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); return; } else if ( nEnd == ( aPureUri.getLength() - 1 ) ) @@ -154,7 +155,7 @@ void PackageUri::init() const // Only <scheme>://// or <scheme>://<something>// // error, but remember that we did a init(). - m_aPath = rtl::OUString::createFromAscii( "/" ); + m_aPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); return; } @@ -175,7 +176,7 @@ void PackageUri::init() const nStart, aPureUri.getLength() - nStart, aNormPackage ); m_aPackage = ::ucb_impl::urihelper::decodeSegment( aNormPackage ); - m_aPath = rtl::OUString::createFromAscii( "/" ); + m_aPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); m_aUri = m_aUri.replaceAt( 0, ( nParam >= 0 ) ? nParam @@ -193,16 +194,19 @@ void PackageUri::init() const { m_aPath = aPureUri.copy( nEnd + 1 ); - // Empty path segments or encoded slashes? - if ( m_aPath.indexOf( - rtl::OUString::createFromAscii( "//" ) ) != -1 - || m_aPath.indexOf( - rtl::OUString::createFromAscii( "%2F" ) ) != -1 - || m_aPath.indexOf( - rtl::OUString::createFromAscii( "%2f" ) ) != -1 ) + // Unexpected sequences of characters: + // - empty path segments + // - encoded slashes + // - parent folder segments ".." + // - current folder segments "." + if ( m_aPath.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "//" ) ) ) != -1 + || m_aPath.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "%2F" ) ) ) != -1 + || m_aPath.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "%2f" ) ) ) != -1 + || ::comphelper::OStorageHelper::PathHasSegment( m_aPath, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".." ) ) ) + || ::comphelper::OStorageHelper::PathHasSegment( m_aPath, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ) ) { // error, but remember that we did a init(). - m_aPath = rtl::OUString::createFromAscii( "/" ); + m_aPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); return; } @@ -239,7 +243,7 @@ void PackageUri::init() const else { // error, but remember that we did a init(). - m_aPath = rtl::OUString::createFromAscii( "/" ); + m_aPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); } } } diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx index 872d45405735..e4617b7b9ea7 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx @@ -1201,8 +1201,7 @@ sal_Bool DAVResourceAccess::handleException( DAVException & e, int errorCount ) // if we have a bad connection try again. Up to three times. case DAVException::DAV_HTTP_ERROR: // retry up to three times, if not a client-side error. - if ( e.getStatus() > 0 && - ( e.getStatus() < 400 || e.getStatus() > 499 ) && + if ( ( e.getStatus() < 400 || e.getStatus() >= 500 ) && errorCount < 3 ) { return sal_True; diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index 73fa61f31ff4..6d65eb67055e 100755..100644 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -52,7 +52,6 @@ #include "logindlg.hxx" #include "masterpasscrtdlg.hxx" #include "masterpassworddlg.hxx" -#include "passcrtdlg.hxx" #include "passworddlg.hxx" #include "iahndl.hxx" diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index 0879e3574da3..ee233f5ac9de 100755 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -89,6 +89,7 @@ #include "newerverwarn.hxx" #include "iahndl.hxx" +#include "nameclashdlg.hxx" /** === begin UNO using === **/ using ::com::sun::star::uno::Sequence; @@ -867,8 +868,6 @@ UUIInteractionHelper::handleRequest_impl( if ( handleCertificateValidationRequest( rRequest ) ) return true; -// @@@ Todo #i29340#: activate! -#if 0 ucb::NameClashResolveRequest aNameClashResolveRequest; if (aAnyRequest >>= aNameClashResolveRequest) { @@ -876,7 +875,7 @@ UUIInteractionHelper::handleRequest_impl( rRequest->getContinuations()); return true; } -#endif + if ( handleMasterPasswordRequest( rRequest ) ) return true; @@ -1188,40 +1187,26 @@ executeMessageBox( return aResult; } -// @@@ Todo #i29340#: activate! -#if 0 -enum NameClashResolveDialogResult { ABORT, RENAME, OVERWRITE }; - -NameClashResolveDialogResult -executeNameClashResolveDialog( - Window * /*pParent*/, - rtl::OUString const & /*rTargetFolderURL*/, - rtl::OUString const & /*rClashingName*/, - rtl::OUString & /*rProposedNewName*/) +NameClashResolveDialogResult executeSimpleNameClashResolveDialog( Window *pParent, + rtl::OUString const & rTargetFolderURL, + rtl::OUString const & rClashingName, + rtl::OUString & rProposedNewName, + bool bAllowOverwrite ) { - // @@@ Todo DV: execute overwrite-rename dialog, deliver result - OSL_ENSURE( false, - "executeNameClashResolveDialog not yet implemented!" ); - return ABORT; -} + std::auto_ptr< ResMgr > xManager( ResMgr::CreateResMgr( CREATEVERSIONRESMGR_NAME( uui ) ) ); + if ( !xManager.get() ) + return ABORT; -NameClashResolveDialogResult -executeSimpleNameClashResolveDialog( - Window * /*pParent*/, - rtl::OUString const & /*rTargetFolderURL*/, - rtl::OUString const & /*rClashingName*/, - rtl::OUString & /*rProposedNewName*/) -{ - // @@@ Todo DV: execute rename-only dialog, deliver result - OSL_ENSURE( false, - "executeSimpleNameClashResolveDialog not yet implemented!" ); - return ABORT; + NameClashDialog aDialog( pParent, xManager.get(), rTargetFolderURL, + rClashingName, rProposedNewName, bAllowOverwrite ); + + NameClashResolveDialogResult eResult = (NameClashResolveDialogResult) aDialog.Execute(); + rProposedNewName = aDialog.getNewName(); + return eResult; } -#endif + } // namespace -// @@@ Todo #i29340#: activate! -#if 0 void UUIInteractionHelper::handleNameClashResolveRequest( ucb::NameClashResolveRequest const & rRequest, @@ -1251,18 +1236,12 @@ UUIInteractionHelper::handleNameClashResolveRequest( NameClashResolveDialogResult eResult = ABORT; rtl::OUString aProposedNewName( rRequest.ProposedNewName ); - if ( xReplaceExistingData.is() ) - eResult = executeNameClashResolveDialog( - getParentProperty(), - rRequest.TargetFolderURL, - rRequest.ClashingName, - aProposedNewName); - else - eResult = executeSimpleNameClashResolveDialog( - getParentProperty(), - rRequest.TargetFolderURL, - rRequest.ClashingName, - aProposedNewName); + + eResult = executeSimpleNameClashResolveDialog( getParentProperty(), + rRequest.TargetFolderURL, + rRequest.ClashingName, + aProposedNewName, + xReplaceExistingData.is() ); switch ( eResult ) { @@ -1282,14 +1261,8 @@ UUIInteractionHelper::handleNameClashResolveRequest( "No ReplaceExistingData continuation available!" ); xReplaceExistingData->select(); break; - - default: - OSL_ENSURE( false, "Unknown NameClashResolveDialogResult value. " - "Interaction Request not handled!" ); - break; } } -#endif void UUIInteractionHelper::handleGenericErrorRequest( diff --git a/uui/source/iahndl.hxx b/uui/source/iahndl.hxx index 581099462845..6402653d3bda 100755 --- a/uui/source/iahndl.hxx +++ b/uui/source/iahndl.hxx @@ -215,8 +215,6 @@ private: com::sun::star::task::XInteractionRequest > const & rRequest) SAL_THROW((com::sun::star::uno::RuntimeException)); -// @@@ Todo #i29340#: activate! -#if 0 void handleNameClashResolveRequest( com::sun::star::ucb::NameClashResolveRequest const & rRequest, @@ -225,7 +223,6 @@ private: com::sun::star::task::XInteractionContinuation > > const & rContinuations) SAL_THROW((com::sun::star::uno::RuntimeException)); -#endif bool handleMasterPasswordRequest( diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc index 796186fd5140..9be81479ef59 100755..100644 --- a/uui/source/ids.hrc +++ b/uui/source/ids.hrc @@ -48,13 +48,14 @@ #define DLG_FILTER_SELECT (RID_UUI_START + 10) // RID_UUI_START + 11 moved to ERRCODE_UUI_WRONGMEDIUM #define DLG_UUI_MASTERPASSWORD (RID_UUI_START + 12) +#define DLG_SIMPLE_NAME_CLASH (RID_UUI_START + 13) #define STR_ERROR_PASSWORDS_NOT_IDENTICAL (RID_UUI_START + 13) #define STR_ERROR_MASTERPASSWORD_WRONG (RID_UUI_START + 14) // RID_UUI_START + 15, 16, 17 are misused by syncaccess/source/ui/resids.hrc + #define RID_UUI_ERRHDL (RID_UUI_START + 20) #define DLG_UUI_MASTERPASSWORD_CRT (RID_UUI_START + 21) #define DLG_UUI_PASSWORD (RID_UUI_START + 22) -#define DLG_UUI_PASSWORD_CRT (RID_UUI_START + 23) #define STR_ERROR_PASSWORD_TO_OPEN_WRONG (RID_UUI_START + 24) #define STR_ERROR_PASSWORD_TO_MODIFY_WRONG (RID_UUI_START + 25) #define DLG_UUI_UNKNOWNAUTH (RID_UUI_START + 26) @@ -89,6 +90,9 @@ #define STR_WARNING_BROKENSIGNATURE_TITLE (RID_UUI_START + 55) #define STR_ENTER_PASSWORD_TO_OPEN (RID_UUI_START + 56) #define STR_ENTER_PASSWORD_TO_MODIFY (RID_UUI_START + 57) +#define STR_RENAME_OR_REPLACE (RID_UUI_START + 58) +#define STR_NAME_CLASH_RENAME_ONLY (RID_UUI_START + 59) +#define STR_SAME_NAME_USED (RID_UUI_START + 60) #define ERRCODE_UUI_IO_ABORT (ERRCODE_AREA_UUI + 0) #define ERRCODE_UUI_IO_ACCESSDENIED (ERRCODE_AREA_UUI + 1) @@ -176,7 +180,6 @@ #define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START + 3) #define HID_DLG_FILTER_SELECT (HID_UUI_START + 4) #define HID_DLG_PASSWORD_UUI (HID_UUI_START + 5) -#define HID_DLG_PASSWORD_CRT (HID_UUI_START + 6) #define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START + 7) #define HID_DLG_SSLWARN_UUI (HID_UUI_START + 8) #define HID_XMLSECDLG_MACROWARN (HID_UUI_START + 9) @@ -189,6 +192,7 @@ #define HID_LOGIN_DLG_ACCOUNT (HID_UUI_START +15) #define HID_LOGIN_DLG_REMEMBER_PASSWORD (HID_UUI_START +16) #define HID_LOGIN_DLG_USE_SYSTEM_CREDENTIALS (HID_UUI_START +17) +#define HID_DLG_SIMPLE_NAME_CLASH (HID_UUI_START +18) // HID_UUI_END (aka HID_CHAOS_NEW_DATABASE) is reserved in // sfx2/util/hidother.src diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx index ec1317dbd805..39bbfb7d820c 100755 --- a/uui/source/loginerr.hxx +++ b/uui/source/loginerr.hxx @@ -68,7 +68,7 @@ public: const String& GetUserName() const { return m_aUserName; } const String& GetPassword() const { return m_aPassword; } const String& GetPasswordToModify() const { return m_aPasswordToModify; } - const bool IsRecommendToOpenReadonly() const { return m_bRecommendToOpenReadonly; } + bool IsRecommendToOpenReadonly() const { return m_bRecommendToOpenReadonly; } const String& GetPath() const { return m_aPath; } const String& GetErrorText() const { return m_aErrorText; } BOOL GetCanRememberPassword() const { return ( m_nFlags & LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD ); } diff --git a/uui/source/makefile.mk b/uui/source/makefile.mk index 5c20e593046a..e09f5c01e967 100644..100755 --- a/uui/source/makefile.mk +++ b/uui/source/makefile.mk @@ -48,7 +48,6 @@ SLOFILES = \ $(SLO)$/masterpasscrtdlg.obj \ $(SLO)$/openlocked.obj \ $(SLO)$/passworddlg.obj \ - $(SLO)$/passcrtdlg.obj \ $(SLO)$/fltdlg.obj \ $(SLO)$/interactionhandler.obj \ $(SLO)$/requeststringresolver.obj \ @@ -60,6 +59,7 @@ SLOFILES = \ $(SLO)$/lockfailed.obj \ $(SLO)$/trylater.obj \ $(SLO)$/newerverwarn.obj \ + $(SLO)$/nameclashdlg.obj \ $(SLO)$/passwordcontainer.obj SRS1NAME=$(TARGET) @@ -71,7 +71,6 @@ SRC1FILES = \ masterpasscrtdlg.src \ openlocked.src \ passworddlg.src \ - passcrtdlg.src \ passworderrs.src \ fltdlg.src \ unknownauthdlg.src\ @@ -81,6 +80,7 @@ SRC1FILES = \ alreadyopen.src\ lockfailed.src\ trylater.src\ + nameclashdlg.src\ newerverwarn.src .INCLUDE: target.mk diff --git a/uui/source/nameclashdlg.cxx b/uui/source/nameclashdlg.cxx new file mode 100755 index 000000000000..593398d53640 --- /dev/null +++ b/uui/source/nameclashdlg.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * 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 "vcl/msgbox.hxx" +#include "osl/file.hxx" + +#include "ids.hrc" +#include "nameclashdlg.hrc" +#include "nameclashdlg.hxx" + +// NameClashDialog --------------------------------------------------------- + +IMPL_LINK( NameClashDialog, ButtonHdl_Impl, PushButton *, pBtn ) +{ + long nRet = (long) ABORT; + if ( &maBtnRename == pBtn ) + { + nRet = (long) RENAME; + rtl::OUString aNewName = maEDNewName.GetText(); + if ( ( aNewName == maNewName ) || !aNewName.getLength() ) + { + ErrorBox aError( NULL, WB_OK, maSameName ); + aError.Execute(); + return 1; + } + maNewName = aNewName; + } + else if ( &maBtnOverwrite == pBtn ) + nRet = (long) OVERWRITE; + + EndDialog( nRet ); + + return 1; +} + +// ----------------------------------------------------------------------- +NameClashDialog::NameClashDialog( Window* pParent, ResMgr* pResMgr, + rtl::OUString const & rTargetFolderURL, + rtl::OUString const & rClashingName, + rtl::OUString const & rProposedNewName, + bool bAllowOverwrite ) + : ModalDialog( pParent, ResId( DLG_SIMPLE_NAME_CLASH, *pResMgr ) ), + maFTMessage ( this, ResId( FT_FILE_EXISTS_WARNING, *pResMgr ) ), + maEDNewName ( this, ResId( EDIT_NEW_NAME, *pResMgr ) ), + maBtnOverwrite ( this, ResId( BTN_OVERWRITE, *pResMgr ) ), + maBtnRename ( this, ResId( BTN_RENAME, *pResMgr ) ), + maBtnCancel ( this, ResId( BTN_CANCEL, *pResMgr ) ), + maBtnHelp ( this, ResId( BTN_HELP, *pResMgr ) ), + maNewName ( rClashingName ) +{ + FreeResource(); + + Link aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) ); + maBtnOverwrite.SetClickHdl( aLink ); + maBtnRename.SetClickHdl( aLink ); + maBtnCancel.SetClickHdl( aLink ); + + String aInfo; + if ( bAllowOverwrite ) + { + aInfo = String( ResId( STR_RENAME_OR_REPLACE, *pResMgr ) ); + } + else + { + aInfo = String( ResId( STR_NAME_CLASH_RENAME_ONLY, *pResMgr ) ); + maBtnOverwrite.Hide(); + } + + rtl::OUString aPath; + if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( rTargetFolderURL, aPath ) ) + aPath = rTargetFolderURL; + + maSameName = String ( ResId( STR_SAME_NAME_USED, *pResMgr ) ); + + aInfo.SearchAndReplaceAscii( "%NAME", rClashingName ); + aInfo.SearchAndReplaceAscii( "%FOLDER", aPath ); + maFTMessage.SetText( aInfo ); + if ( rProposedNewName.getLength() ) + maEDNewName.SetText( rProposedNewName ); + else + maEDNewName.SetText( rClashingName ); +} + diff --git a/uui/source/passcrtdlg.hrc b/uui/source/nameclashdlg.hrc index 5a999aa99209..1bfdc01de5ab 100644..100755 --- a/uui/source/passcrtdlg.hrc +++ b/uui/source/nameclashdlg.hrc @@ -25,19 +25,17 @@ * ************************************************************************/ -#ifndef UUI_PASSCRTDLG_HRC -#define UUI_PASSCRTDLG_HRC +#ifndef UUI_NAMECLASHDLG_HRC +#define UUI_NAMECLASHDLG_HRC -// local identifiers -#define BTN_PASSCRT_CANCEL 1 -#define ED_PASSWORD_CRT 2 -#define FT_PASSWORD_REPEAT 3 -#define FT_PASSWORD_WARNING 4 -#define ED_PASSWORD_REPEAT 5 -#define FL_FIXED_LINE_1 6 -#define BTN_PASSCRT_OK 7 -#define BTN_PASSCRT_HELP 8 -#define FT_PASSWORD_CRT 9 -#define FT_MSPASSWORD_WARNING 10 +//============================================================================ + +#define FT_FILE_EXISTS_WARNING 20 +#define EDIT_NEW_NAME 21 +#define BTN_OVERWRITE 22 +#define BTN_RENAME 23 +#define BTN_CANCEL 24 +#define BTN_HELP 25 + +#endif // UUI_NAMECLASHDLG_HRC -#endif // UUI_PASSCRTDLG_HRC diff --git a/uui/source/passcrtdlg.hxx b/uui/source/nameclashdlg.hxx index 8ad19c59924d..1e234008a229 100644..100755 --- a/uui/source/passcrtdlg.hxx +++ b/uui/source/nameclashdlg.hxx @@ -25,39 +25,39 @@ * ************************************************************************/ -#ifndef UUI_PASSCRTDLG_HXX -#define UUI_PASSCRTDLG_HXX +#ifndef UUI_NAMECLASHDLG_HXX +#define UUI_NAMECLASHDLG_HXX -#include <com/sun/star/task/PasswordRequestMode.hpp> -#include <svtools/stdctrl.hxx> -#include <vcl/dialog.hxx> -#include <vcl/edit.hxx> -#include <vcl/fixed.hxx> -#include <vcl/button.hxx> +#include "vcl/button.hxx" +#include "vcl/dialog.hxx" +#include "vcl/fixed.hxx" +#include "vcl/edit.hxx" //============================================================================ -class PasswordCreateDialog : public ModalDialog + +enum NameClashResolveDialogResult { ABORT, RENAME, OVERWRITE }; + +class NameClashDialog : public ModalDialog { - FixedText aFTPasswordCrt; - Edit aEDPasswordCrt; - FixedText aFTPasswordRepeat; - Edit aEDPasswordRepeat; - FixedText aFTWarning; - FixedLine aFixedLine1; - OKButton aOKBtn; - CancelButton aCancelBtn; - HelpButton aHelpBtn; - - ResMgr* pResourceMgr; - sal_uInt16 nMinLen; - - DECL_LINK( OKHdl_Impl, OKButton * ); - DECL_LINK( EditHdl_Impl, Edit * ); + FixedText maFTMessage; + Edit maEDNewName; + PushButton maBtnOverwrite; + PushButton maBtnRename; + CancelButton maBtnCancel; + HelpButton maBtnHelp; + rtl::OUString maSameName; + rtl::OUString maNewName; -public: - PasswordCreateDialog( Window* pParent, ResMgr * pResMgr, bool bMSCryptoMode = false ); + DECL_LINK( ButtonHdl_Impl, PushButton * ); - String GetPassword() const { return aEDPasswordCrt.GetText(); } +public: + NameClashDialog( Window* pParent, ResMgr* pResMgr, + rtl::OUString const & rTargetFolderURL, + rtl::OUString const & rClashingName, + rtl::OUString const & rProposedNewName, + bool bAllowOverwrite ); + rtl::OUString getNewName() const { return maNewName; } }; -#endif // UUI_PASSCRTDLG_HXX +#endif // UUI_COOKIEDG_HXX + diff --git a/uui/source/nameclashdlg.src b/uui/source/nameclashdlg.src new file mode 100755 index 000000000000..de8cdb8e716d --- /dev/null +++ b/uui/source/nameclashdlg.src @@ -0,0 +1,113 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +#define __RSC + +#ifndef UUI_IDS_HRC +#include "ids.hrc" +#endif + +#ifndef UUI_NAMECLASHDLG_HRC +#include "nameclashdlg.hrc" +#endif + +#define DLG_WIDTH 250 +#define DLG_HEIGTH 75 +#define BORDER_OFFSET 6 +#define EDIT_HEIGTH 12 +#define BTN_WIDTH 50 +#define BTN_HEIGTH 14 + +ModalDialog DLG_SIMPLE_NAME_CLASH +{ + HelpId = HID_DLG_SIMPLE_NAME_CLASH ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( DLG_WIDTH , DLG_HEIGTH ) ; + Moveable = TRUE ; + Text [ en-US ] = "File Exists" ; + + FixedText FT_FILE_EXISTS_WARNING + { + Pos = MAP_APPFONT ( BORDER_OFFSET, BORDER_OFFSET ) ; + Size = MAP_APPFONT ( DLG_WIDTH - 2*BORDER_OFFSET, DLG_HEIGTH - EDIT_HEIGTH - BTN_HEIGTH - 4*BORDER_OFFSET ) ; + WordBreak = TRUE ; + }; + + Edit EDIT_NEW_NAME + { + Border = TRUE ; + Pos = MAP_APPFONT ( BORDER_OFFSET, DLG_HEIGTH - EDIT_HEIGTH - BTN_HEIGTH - 2*BORDER_OFFSET ) ; + Size = MAP_APPFONT ( DLG_WIDTH - 2*BORDER_OFFSET , EDIT_HEIGTH ) ; + }; + + PushButton BTN_OVERWRITE + { + Pos = MAP_APPFONT ( DLG_WIDTH - 3*(BTN_WIDTH + BORDER_OFFSET) , DLG_HEIGTH - BTN_HEIGTH - BORDER_OFFSET ) ; + Size = MAP_APPFONT ( BTN_WIDTH, BTN_HEIGTH ) ; + TabStop = TRUE ; + Text [ en-US ] = "Replace" ; + }; + + PushButton BTN_RENAME + { + Pos = MAP_APPFONT ( DLG_WIDTH - 2*(BTN_WIDTH + BORDER_OFFSET) , DLG_HEIGTH - BTN_HEIGTH - BORDER_OFFSET ) ; + Size = MAP_APPFONT ( BTN_WIDTH, BTN_HEIGTH ) ; + TabStop = TRUE ; + Text [ en-US ] = "Rename" ; + DefButton = TRUE ; + }; + + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( DLG_WIDTH - BTN_WIDTH - BORDER_OFFSET, DLG_HEIGTH - BTN_HEIGTH - BORDER_OFFSET ) ; + Size = MAP_APPFONT ( BTN_WIDTH, BTN_HEIGTH ) ; + TabStop = TRUE ; + }; + + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( BORDER_OFFSET, DLG_HEIGTH - BTN_HEIGTH - BORDER_OFFSET ) ; + Size = MAP_APPFONT ( BTN_WIDTH, BTN_HEIGTH ) ; + TabStop = TRUE ; + }; +}; + +String STR_RENAME_OR_REPLACE +{ + Text = "A file with the name \"%NAME\" already exists in the location \"%FOLDER\".\nChoose Replace to overwrite the existing file or provide a new name."; +}; + +String STR_NAME_CLASH_RENAME_ONLY +{ + Text = "A file with the name \"%NAME\" already exists in the location \"%FOLDER\".\nPlease enter a new name."; +}; + +String STR_SAME_NAME_USED +{ + Text = "Please provide a different file name!"; +}; diff --git a/uui/source/passcrtdlg.cxx b/uui/source/passcrtdlg.cxx deleted file mode 100644 index 1fc6024bcd19..000000000000 --- a/uui/source/passcrtdlg.cxx +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************************* - * - * 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 <svtools/filedlg.hxx> -#include <vcl/msgbox.hxx> - -#ifndef UUI_IDS_HRC -#include <ids.hrc> -#endif -#ifndef UUI_PASSCRTDLG_HRC -#include <passcrtdlg.hrc> -#endif -#include <passcrtdlg.hxx> - -// PasswordCreateDialog--------------------------------------------------- - -// ----------------------------------------------------------------------- - -IMPL_LINK( PasswordCreateDialog, EditHdl_Impl, Edit *, EMPTYARG ) -{ - aOKBtn.Enable( aEDPasswordCrt.GetText().Len() >= nMinLen ); - return 0; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( PasswordCreateDialog, OKHdl_Impl, OKButton *, EMPTYARG ) -{ - // compare both passwords and show message box if there are not equal!! - if( aEDPasswordCrt.GetText() == aEDPasswordRepeat.GetText() ) - EndDialog( RET_OK ); - else - { - String aErrorMsg( ResId( STR_ERROR_PASSWORDS_NOT_IDENTICAL, *pResourceMgr )); - ErrorBox aErrorBox( this, WB_OK, aErrorMsg ); - aErrorBox.Execute(); - aEDPasswordCrt.SetText( String() ); - aEDPasswordRepeat.SetText( String() ); - aEDPasswordCrt.GrabFocus(); - } - return 1; -} - -// ----------------------------------------------------------------------- - -PasswordCreateDialog::PasswordCreateDialog( Window* _pParent, ResMgr * pResMgr, bool bMSCryptoMode) - :ModalDialog( _pParent, ResId( DLG_UUI_PASSWORD_CRT, *pResMgr ) ) - ,aFTPasswordCrt ( this, ResId( FT_PASSWORD_CRT, *pResMgr ) ) - ,aEDPasswordCrt ( this, ResId( ED_PASSWORD_CRT, *pResMgr ) ) - ,aFTPasswordRepeat ( this, ResId( FT_PASSWORD_REPEAT, *pResMgr ) ) - ,aEDPasswordRepeat ( this, ResId( ED_PASSWORD_REPEAT, *pResMgr ) ) - ,aFTWarning ( this, ResId( bMSCryptoMode ? FT_MSPASSWORD_WARNING : FT_PASSWORD_WARNING, *pResMgr ) ) - ,aFixedLine1 ( this, ResId( FL_FIXED_LINE_1, *pResMgr ) ) - ,aOKBtn ( this, ResId( BTN_PASSCRT_OK, *pResMgr ) ) - ,aCancelBtn ( this, ResId( BTN_PASSCRT_CANCEL, *pResMgr ) ) - ,aHelpBtn ( this, ResId( BTN_PASSCRT_HELP, *pResMgr ) ) - ,pResourceMgr ( pResMgr ) - ,nMinLen(1) // if it should be changed for ODF, it must stay 1 for bMSCryptoMode -{ - FreeResource(); - - aOKBtn.SetClickHdl( LINK( this, PasswordCreateDialog, OKHdl_Impl ) ); - aEDPasswordCrt.SetModifyHdl( LINK( this, PasswordCreateDialog, EditHdl_Impl ) ); - - aOKBtn.Enable( sal_False ); - - if ( bMSCryptoMode ) - { - aEDPasswordCrt.SetMaxTextLen( 15 ); - aEDPasswordRepeat.SetMaxTextLen( 15 ); - } - - long nLabelWidth = aFTWarning.GetSizePixel().Width(); - long nLabelHeight = aFTWarning.GetSizePixel().Height(); - long nTextWidth = aFTWarning.GetCtrlTextWidth( aFTWarning.GetText() ); - long nTextHeight = aFTWarning.GetTextHeight(); - - Rectangle aLabelRect( aFTWarning.GetPosPixel(), aFTWarning.GetSizePixel() ); - Rectangle aRect = aFTWarning.GetTextRect( aLabelRect, aFTWarning.GetText() ); - - long nNewLabelHeight = 0; - for( nNewLabelHeight = ( nTextWidth / nLabelWidth + 1 ) * nTextHeight; - nNewLabelHeight < aRect.GetHeight(); - nNewLabelHeight += nTextHeight ) {} ; - - long nDelta = nNewLabelHeight - nLabelHeight; - - Size aNewDlgSize = GetSizePixel(); - aNewDlgSize.Height() += nDelta; - SetSizePixel( aNewDlgSize ); - - Size aNewWarningSize = aFTWarning.GetSizePixel(); - aNewWarningSize.Height() = nNewLabelHeight; - aFTWarning.SetPosSizePixel( aFTWarning.GetPosPixel(), aNewWarningSize ); - - Window* pControls[] = { &aFixedLine1, &aOKBtn, &aCancelBtn, &aHelpBtn }; - const sal_Int32 nCCount = sizeof( pControls ) / sizeof( pControls[0] ); - for ( int i = 0; i < nCCount; ++i ) - { - Point aNewPos =(*pControls[i]).GetPosPixel(); - aNewPos.Y() += nDelta; - pControls[i]->SetPosSizePixel( aNewPos, pControls[i]->GetSizePixel() ); - } -} diff --git a/uui/source/passcrtdlg.src b/uui/source/passcrtdlg.src deleted file mode 100644 index a74752ed589e..000000000000 --- a/uui/source/passcrtdlg.src +++ /dev/null @@ -1,108 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -#define __RSC - -#ifndef UUI_IDS_HRC -#include <ids.hrc> -#endif -#ifndef UUI_PASSCRTDLG_HRC -#include "passcrtdlg.hrc" -#endif - -ModalDialog DLG_UUI_PASSWORD_CRT -{ - HelpId = HID_DLG_PASSWORD_CRT ; - Border = TRUE ; - Moveable = TRUE ; - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT( 145, 129 ); - FixedText FT_PASSWORD_CRT - { - Pos = MAP_APPFONT( 3, 4 ); - Size = MAP_APPFONT( 139, 9 ); - Text [ en-US ] = "Enter password"; - }; - Edit ED_PASSWORD_CRT - { - Border = TRUE ; - Pos = MAP_APPFONT( 3, 17 ); - Size = MAP_APPFONT( 139, 13 ); - PassWord = TRUE ; - }; - Edit ED_PASSWORD_REPEAT - { - Border = TRUE ; - Pos = MAP_APPFONT( 3, 47 ); - Size = MAP_APPFONT( 139, 13 ); - PassWord = TRUE ; - }; - OKButton BTN_PASSCRT_OK - { - Pos = MAP_APPFONT( 27, 110 ); - Size = MAP_APPFONT( 37, 15 ); - DefButton = TRUE ; - }; - CancelButton BTN_PASSCRT_CANCEL - { - Pos = MAP_APPFONT( 66, 110 ); - Size = MAP_APPFONT( 37, 15 ); - }; - HelpButton BTN_PASSCRT_HELP - { - Pos = MAP_APPFONT( 105, 110 ); - Size = MAP_APPFONT( 37, 15 ); - }; - FixedText FT_PASSWORD_REPEAT - { - Pos = MAP_APPFONT( 3, 34 ); - Size = MAP_APPFONT( 139, 9 ); - Text [ en-US ] = "Reenter password"; - }; - FixedText FT_PASSWORD_WARNING - { - Pos = MAP_APPFONT( 4, 64 ); - Size = MAP_APPFONT( 137, 40 ); - Text [ en-US ] = "WARNING: If you lose or forget the password, it cannot be recovered. It is advisable to keep passwords in a safe place. Passwords are case-sensitive."; - WordBreak = TRUE; - }; - FixedText FT_MSPASSWORD_WARNING - { - Pos = MAP_APPFONT( 4, 64 ); - Size = MAP_APPFONT( 137, 40 ); - Text [ en-US ] = "WARNING: If you lose or forget the password, it cannot be recovered. It is advisable to keep passwords in a safe place. Passwords are case-sensitive and at most fifteen characters long."; - WordBreak = TRUE; - }; - FixedLine FL_FIXED_LINE_1 - { - Pos = MAP_APPFONT( 0, 104 ); - Size = MAP_APPFONT( 145, 6 ); - }; - Text [ en-US ] = "Enter Password"; -}; - diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx index e2a5a3bff5da..6902bc7b5042 100644 --- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx +++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx @@ -53,17 +53,20 @@ public: virtual void SAL_CALL setScreenUpdating(sal_Bool bUpdate) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getDisplayStatusBar() throw (css::uno::RuntimeException); virtual void SAL_CALL setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getInteractive() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getInteractive() throw (css::uno::RuntimeException); + virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( ::sal_Bool bVisible ) throw (css::uno::RuntimeException); 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 ::com::sun::star::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const ::com::sun::star::uno::Any& aLatestTime, const ::com::sun::star::uno::Any& aSchedule ) throw (::com::sun::star::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); virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Undo( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL Quit( ) throw (::com::sun::star::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL SAL_CALL getVBProjects() throw (css::uno::RuntimeException); + virtual void SAL_CALL Undo() throw (css::uno::RuntimeException); + virtual void SAL_CALL Quit() throw (css::uno::RuntimeException); // XHelperInterface virtual rtl::OUString& getServiceImplName(); diff --git a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx index 36102116c7b3..5bd58b44adaf 100644 --- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx +++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx @@ -133,11 +133,12 @@ protected: class VBAHELPER_DLLPUBLIC EnumerationHelperImpl : public EnumerationHelper_BASE { protected: + css::uno::WeakReference< ov::XHelperInterface > m_xParent; css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::container::XEnumeration > m_xEnumeration; public: - EnumerationHelperImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xContext( xContext ), m_xEnumeration( xEnumeration ) { } + EnumerationHelperImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration ) { } virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (css::uno::RuntimeException) { return m_xEnumeration->hasMoreElements(); } }; diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx index 7131e1963b26..2588b7da1720 100644 --- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx +++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx @@ -52,9 +52,7 @@ public: virtual ::rtl::OUString SAL_CALL getFullName() throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getSaved() throw (css::uno::RuntimeException); virtual void SAL_CALL setSaved( sal_Bool bSave ) throw (css::uno::RuntimeException); - - virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); // Michhael E. Bohn - + virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); // Methods virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges, diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx new file mode 100755 index 000000000000..89d355db71f9 --- /dev/null +++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx @@ -0,0 +1,162 @@ +/************************************************************************* + * + * 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_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 "vbahelper/vbahelper.hxx" + +namespace com { namespace sun { namespace star { + namespace uno { class XComponentContext; } +} } } + +// ============================================================================ + +typedef ::cppu::WeakImplHelper2< css::script::vba::XVBAEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE; + +class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE +{ +public: + VbaEventsHelperBase( + const css::uno::Sequence< css::uno::Any >& rArgs, + const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~VbaEventsHelperBase(); + + // 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); + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& aSource ) throw (css::uno::RuntimeException); + +protected: + // ------------------------------------------------------------------------ + + enum EventHandlerType { EVENTHANDLER_GLOBAL, EVENTHANDLER_DOCUMENT }; + struct EventHandlerInfo + { + sal_Int32 mnEventId; + ::rtl::OUString maMacroName; + EventHandlerType meType; + sal_Int32 mnCancelIndex; + css::uno::Any maUserData; + }; + + /** Registers a supported event handler. + + @param nEventId Event identifier from com.sun.star.script.vba.EventIdentifier. + @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, + const sal_Char* pcMacroName, + EventHandlerType eType = EVENTHANDLER_DOCUMENT, + sal_Int32 nCancelIndex = -1, + const css::uno::Any& rUserData = css::uno::Any() ); + + /** 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( rArgs.getLength() <= nIndex ) throw css::lang::IllegalArgumentException(); } + + /** Throws, if the passed sequence does not contain a value of a specific at the specified index. */ + template< typename Type > + static inline void checkArgumentType( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException) + { if( (rArgs.getLength() <= nIndex) || !rArgs[ nIndex ].has< Type >() ) throw css::lang::IllegalArgumentException(); } + + // ------------------------------------------------------------------------ + + struct EventQueueEntry + { + sal_Int32 mnEventId; + css::uno::Sequence< css::uno::Any > maArgs; + inline /*implicit*/ EventQueueEntry( sal_Int32 nEventId ) : mnEventId( nEventId ) {} + inline EventQueueEntry( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) : mnEventId( nEventId ), maArgs( rArgs ) {} + }; + typedef ::std::deque< EventQueueEntry > EventQueue; + + /** Derived classes return whether event processing is enabled. Throws if + the instance is in an invalid state. */ + virtual bool implEventsEnabled() throw (css::uno::RuntimeException) = 0; + + /** Derived classes do additional prpeparations and return whether the + event handler has to be called. */ + virtual bool implPrepareEvent( + EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException) = 0; + + /** Derived classes have to return the argument list for the specified VBA event handler. */ + virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException) = 0; + + /** Derived classes may do additional postprocessing. Called even if the + event handler does not exist, or if an error occured during execution. */ + 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. */ + virtual ::rtl::OUString implGetDocumentModuleName( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException) = 0; + +private: + /** 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); + + /** Removes this instance from all broadcasters. */ + void stopListening(); + +protected: + css::uno::Reference< css::frame::XModel > mxModel; + SfxObjectShell* mpShell; + +private: + typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerMap; + + EventHandlerMap maEvents; + bool mbDisposed; +}; + +// ============================================================================ + +#endif diff --git a/vbahelper/inc/vbahelper/vbaglobalbase.hxx b/vbahelper/inc/vbahelper/vbaglobalbase.hxx index e75cbb7e7af8..61aaa1d65657 100644 --- a/vbahelper/inc/vbahelper/vbaglobalbase.hxx +++ b/vbahelper/inc/vbahelper/vbaglobalbase.hxx @@ -32,16 +32,16 @@ typedef InheritedHelperInterfaceImpl1< ov::XGlobalsBase > Globals_BASE; class VBAHELPER_DLLPUBLIC VbaGlobalsBase : public Globals_BASE - { protected: + rtl::OUString msDocCtxName; bool hasServiceName( const rtl::OUString& serviceName ); void init( const css::uno::Sequence< css::beans::PropertyValue >& aInitArgs ); public: VbaGlobalsBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sDocCtxName ); - virtual ~VbaGlobalsBase(){}; + virtual ~VbaGlobalsBase(); // XMultiServiceFactory virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (css::uno::Exception, css::uno::RuntimeException); virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) throw (css::uno::Exception, css::uno::RuntimeException); diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index 33613bb76091..a1eca84bbdf8 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -63,6 +63,7 @@ namespace ooo throw css::lang::IllegalArgumentException(); return aSomething; } + VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > 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); diff --git a/vbahelper/inc/vbahelper/vbahelperinterface.hxx b/vbahelper/inc/vbahelper/vbahelperinterface.hxx index 21339631e1ed..b095b5cd2823 100644 --- a/vbahelper/inc/vbahelper/vbahelperinterface.hxx +++ b/vbahelper/inc/vbahelper/vbahelperinterface.hxx @@ -28,6 +28,8 @@ #define OOVBAAPI_VBA_HELPERINTERFACE_HXX #include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase3.hxx> #include <ooo/vba/XHelperInterface.hpp> #include <vbahelper/vbahelper.hxx> #include <com/sun/star/container/XNameAccess.hpp> @@ -68,6 +70,7 @@ protected: css::uno::Reference< css::uno::XComponentContext > mxContext; public: InheritedHelperInterfaceImpl() {} + InheritedHelperInterfaceImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxContext( xContext ) {} InheritedHelperInterfaceImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxParent( xParent ), mxContext( xContext ) {} virtual rtl::OUString& getServiceImplName() = 0; virtual css::uno::Sequence<rtl::OUString> getServiceNames() = 0; @@ -86,7 +89,6 @@ public: return xNameAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Application" ) ) ); } - // XServiceInfo Methods virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (css::uno::RuntimeException) { return getServiceImplName(); } virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (css::uno::RuntimeException) @@ -101,19 +103,39 @@ public: } virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (css::uno::RuntimeException) { - css::uno::Sequence< rtl::OUString > aNames = getServiceNames();; + css::uno::Sequence< rtl::OUString > aNames = getServiceNames(); return aNames; } }; template< typename Ifc1 > class VBAHELPER_DLLPUBLIC InheritedHelperInterfaceImpl1 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > +{ + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > Base; +public: + InheritedHelperInterfaceImpl1< Ifc1 >() {} + InheritedHelperInterfaceImpl1< Ifc1 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl1< Ifc1 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} +}; +template< typename Ifc1, typename Ifc2 > +class VBAHELPER_DLLPUBLIC InheritedHelperInterfaceImpl2 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper2< Ifc1, Ifc2 > > { -typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > Base; + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper2< Ifc1, Ifc2 > > Base; public: - InheritedHelperInterfaceImpl1< Ifc1 > ( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >() {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} +}; +template< typename Ifc1, typename Ifc2, typename Ifc3 > +class VBAHELPER_DLLPUBLIC InheritedHelperInterfaceImpl3 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper3< Ifc1, Ifc2, Ifc3 > > +{ + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper3< Ifc1, Ifc2, Ifc3 > > Base; +public: + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >() {} + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} }; // ============================================================================ diff --git a/vbahelper/prj/d.lst b/vbahelper/prj/d.lst index d683e97c8b90..2d20ab1f982d 100644 --- a/vbahelper/prj/d.lst +++ b/vbahelper/prj/d.lst @@ -26,3 +26,4 @@ mkdir: %_DEST%\inc%_EXT%\basic ..\inc\vbahelper\vbatextframe.hxx %_DEST%\inc%_EXT%\vbahelper\vbatextframe.hxx ..\inc\vbahelper\vbashaperange.hxx %_DEST%\inc%_EXT%\vbahelper\vbashaperange.hxx ..\inc\vbahelper\vbapagesetupbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbapagesetupbase.hxx +..\inc\vbahelper\vbaeventshelperbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbaeventshelperbase.hxx diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 1284b36be463..8d01687ef905 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -74,12 +74,20 @@ private: public: ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog ) { - mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); - uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls(); + try + { + mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls(); - msNames.realloc( sXControls.getLength() ); - for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i ) - SetArrayElementTo( sXControls[ i ], i ); + msNames.realloc( sXControls.getLength() ); + for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i ) + SetArrayElementTo( sXControls[ i ], i ); + } + catch( uno::Exception& ) + { + // accept the case when the dialog already does not exist + // in this case the wrapper should work in dummy mode + } } static rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl ) @@ -186,7 +194,7 @@ ScVbaControls::ScVbaControls( const uno::Reference< XHelperInterface >& xParent, const css::uno::Reference< awt::XControl >& xDialog ) : ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ) { - mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); + mxDialog.set( xDialog, uno::UNO_QUERY ); } uno::Reference< container::XEnumeration > @@ -349,13 +357,16 @@ void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex ) } catch( uno::RuntimeException& ) { - throw; + // the exceptions are not rethrown, impossibility to find or remove the control is currently not reported + // since in most cases it means just that the controls is already not there, the VBA seems to do it in the same way + + // throw; } catch( uno::Exception& e ) { - throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), - uno::Reference< uno::XInterface >(), - uno::makeAny( e ) ); + // throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), + // uno::Reference< uno::XInterface >(), + // uno::makeAny( e ) ); } } diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index 1ce403fc19c3..2a4cecfc2338 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -185,7 +185,9 @@ ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::Runtime uno::Any SAL_CALL ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException) { - uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW ); + // 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 ) ); if ( index.hasValue() ) return uno::makeAny( xControls->Item( index, uno::Any() ) ); diff --git a/vbahelper/source/vbahelper/makefile.mk b/vbahelper/source/vbahelper/makefile.mk index 47ad44b3d0ed..22ed40a3adfa 100644 --- a/vbahelper/source/vbahelper/makefile.mk +++ b/vbahelper/source/vbahelper/makefile.mk @@ -65,6 +65,8 @@ SLOFILES=\ $(SLO)$/vbashaperange.obj \ $(SLO)$/vbatextframe.obj \ $(SLO)$/vbapagesetupbase.obj \ + $(SLO)$/vbaeventshelperbase.obj + # --- Targets ------------------------------------------------------- .INCLUDE : target.mk diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 6d2c51066ca2..326c150edade 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -24,39 +24,37 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbahelper/vbaapplicationbase.hxx" + #include <com/sun/star/container/XIndexAccess.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> //Michael E. Bohn -#include <com/sun/star/lang/XMultiComponentFactory.hpp> //Michael E. Bohn -#include <com/sun/star/lang/XComponent.hpp> //Michael E. Bohn -#include <com/sun/star/container/XEnumeration.hpp> //Michael E. Bohn +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/container/XEnumeration.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/document/XDocumentInfoSupplier.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> -#include <com/sun/star/document/XEmbeddedScripts.hpp> //Michael E. Bohn -#include <ooo/vba/XVBAAppService.hpp> //Michael E. Bohn +#include <com/sun/star/document/XEmbeddedScripts.hpp> #include <com/sun/star/awt/XWindow2.hpp> - -#include "vbacommandbars.hxx" +#include <hash_map> #include <filter/msfilter/msvbahelper.hxx> #include <tools/datetime.hxx> -// start basic includes #include <basic/sbx.hxx> #include <basic/sbstar.hxx> #include <basic/sbuno.hxx> #include <basic/sbmeth.hxx> #include <basic/sbmod.hxx> -// end basic includes -#include <hash_map> +#include "vbacommandbars.hxx" -using namespace com::sun::star; -using namespace ooo::vba; +using namespace ::com::sun::star; +using namespace ::ooo::vba; #define OFFICEVERSION "11.0" @@ -162,6 +160,9 @@ typedef ::std::hash_map< VbaTimerInfo, VbaTimer*, VbaTimerInfoHash, ::std::equal struct VbaApplicationBase_Impl { VbaTimerHashMap m_aTimerHash; + sal_Bool mbVisible; + + inline VbaApplicationBase_Impl() : mbVisible( sal_True ) {} virtual ~VbaApplicationBase_Impl() { @@ -185,7 +186,6 @@ VbaApplicationBase::VbaApplicationBase( const uno::Reference< uno::XComponentCon VbaApplicationBase::~VbaApplicationBase() { - m_pImpl = 0; delete m_pImpl; } @@ -268,6 +268,16 @@ void SAL_CALL VbaApplicationBase::setInteractive( ::sal_Bool bInteractive ) xWindow->setEnable( bInteractive ); } +sal_Bool SAL_CALL VbaApplicationBase::getVisible() throw (uno::RuntimeException) +{ + return m_pImpl->mbVisible; // dummy implementation +} + +void SAL_CALL VbaApplicationBase::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException) +{ + m_pImpl->mbVisible = bVisible; // dummy implementation +} + uno::Any SAL_CALL VbaApplicationBase::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException) { @@ -407,63 +417,50 @@ float SAL_CALL VbaApplicationBase::CentimetersToPoints( float _Centimeters ) thr return ( _Centimeters * rate ); } -// inserted by Michael E. Bohn uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException) { - uno::Any aAny; - uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); - try - { - uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAAppService" )),mxContext); - uno::Reference < ::ooo::vba::XVBAAppService > xVBAAppService (xInterface, ::uno::UNO_QUERY_THROW ); - if (xVBAAppService.is()){ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - return xVBAAppService->getVBE( this, mxContext, xModel); - } - - }catch(uno::Exception* e) - { - } - return aAny; + 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 > xVBE = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBE" ) ), aArgs, mxContext ); + return uno::Any( xVBE ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); } uno::Any SAL_CALL VbaApplicationBase::getVBProjects() throw (uno::RuntimeException) { - uno::Any aAny; - uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); - try - { - uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAAppService" )),mxContext); - uno::Reference < ::ooo::vba::XVBAAppService > xVBAAppService (xInterface, ::uno::UNO_QUERY_THROW ); - if (xVBAAppService.is()){ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XEmbeddedScripts > xEnbeddedScripts ( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< script::XStorageBasedLibraryContainer > xMacroStorageBasedLibraryContainer = xEnbeddedScripts->getBasicLibraries(); - uno::Reference< script::XStorageBasedLibraryContainer > xDialogStorageBasedLibraryContainer = xEnbeddedScripts->getDialogLibraries(); - uno::Reference< script::XLibraryContainer > xMacroLibraryContainer ( xMacroStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - uno::Reference< script::XLibraryContainer > xDialogLibraryContainer( xDialogStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - return xVBAAppService->getVBProjects(this, mxContext, xModel, xMacroLibraryContainer, xDialogLibraryContainer); - } - - }catch(uno::Exception* e) - { - } - return aAny; - - - + 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() { static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaApplicationBase") ); return sImplName; } + uno::Sequence<rtl::OUString> VbaApplicationBase::getServiceNames() { diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index f27f2de53c8a..65f7f4bcfbeb 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -24,9 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <vbahelper/vbadocumentbase.hxx> -#include <vbahelper/helperdecl.hxx> -#include <comphelper/unwrapargs.hxx> + +#include "vbahelper/vbadocumentbase.hxx" +#include "vbahelper/helperdecl.hxx" #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/util/XProtectable.hpp> @@ -35,8 +35,8 @@ #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/XVBADocService.hpp> +#include <comphelper/unwrapargs.hxx> #include <tools/urlobj.hxx> #include <osl/file.hxx> @@ -206,40 +206,25 @@ VbaDocumentBase::Activate() throw (uno::RuntimeException) xFrame->activate(); } -// ---- Michael E.Bohn Start----- - uno::Any SAL_CALL VbaDocumentBase::getVBProject() throw (uno::RuntimeException) - { - uno::Any aAny; - uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); - try - { - uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBADocService" )),mxContext); - uno::Reference < ::ooo::vba::XVBADocService > xVBADocService (xInterface, ::uno::UNO_QUERY_THROW ); - if (xVBADocService.is()){ - uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XEmbeddedScripts > xEnbeddedScripts ( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< script::XStorageBasedLibraryContainer > xMacroStorageBasedLibraryContainer = xEnbeddedScripts->getBasicLibraries(); - uno::Reference< script::XStorageBasedLibraryContainer > xDialogStorageBasedLibraryContainer = xEnbeddedScripts->getDialogLibraries(); - uno::Reference< script::XLibraryContainer > xMacroLibraryContainer ( xMacroStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - uno::Reference< script::XLibraryContainer > xDialogLibraryContainer( xDialogStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - - return xVBADocService->getVBProject( this, mxContext, xModel, xMacroLibraryContainer, xDialogLibraryContainer ); - } - - }catch(uno::Exception* e) - { - } - return aAny; - + try // return empty object on error + { + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); + aArgs[ 1 ] <<= mxModel; + 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 ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); } - -// ---- Michael E.Bohn End ----- - - rtl::OUString& VbaDocumentBase::getServiceImplName() { diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx new file mode 100755 index 000000000000..16a8671df601 --- /dev/null +++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * 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 "vbahelper/vbaeventshelperbase.hxx" +#include <filter/msfilter/msvbahelper.hxx> + +using namespace ::com::sun::star; +using namespace ::ooo::vba; + +// ============================================================================ + +VbaEventsHelperBase::VbaEventsHelperBase( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& /*xContext*/ ) : + mpShell( 0 ), + mbDisposed( false ) +{ + 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& ) + { + } +} + +VbaEventsHelperBase::~VbaEventsHelperBase() +{ + stopListening(); +} + +sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + // getEventHandlerInfo() throws, if unknown event dentifier has been passed + const EventHandlerInfo& rInfo = getEventHandlerInfo( nEventId ); + // getEventHandlerPath() searches for the macro in the document + 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) +{ + /* Derived classes may add new event identifiers to be processed while + processing the original event. All unprocessed events are collected in + a queue. First element in the queue is the next event to be processed. */ + EventQueue aEventQueue; + aEventQueue.push_back( EventQueueEntry( nEventId, rArgs ) ); + + /* bEnabled will track if event processing is enabled. Every event handler + may disable handling of other events. */ + bool bEnabled = true; + + /* bCancel will contain the current Cancel value. It is possible that + multiple events will try to modify the Cancel value. Every event + 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; + + /* Loop as long as there are more events to be processed, and as event + handling is still enabled. Derived classes may add new events to be + processed in the virtual implPrepareEvent() function. */ + while( bEnabled && !aEventQueue.empty() ) + { + /* Check that all class members are available, and that we are not + disposed (this may have happened at any time during execution of + the last event handler). */ + if( mbDisposed || !mxModel.is() || !mpShell ) + throw uno::RuntimeException(); + + // get info for next event + const EventHandlerInfo& rInfo = getEventHandlerInfo( aEventQueue.front().mnEventId ); + uno::Sequence< uno::Any > aEventArgs = aEventQueue.front().maArgs; + aEventQueue.pop_front(); + + // let derived classes decide whether event processing is still enabled + bEnabled = implEventsEnabled(); + // let derived classes prepare the event, they may add new events for next iteration + if( bEnabled && implPrepareEvent( aEventQueue, rInfo, aEventArgs ) ) + { + // search the event handler macro in the document + ::rtl::OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs ); + bool bEventSuccess = false; + if( aMacroPath.getLength() > 0 ) + { + // build the argument list + uno::Sequence< uno::Any > aVbaArgs = implBuildArgumentList( rInfo, aEventArgs ); + // insert current cancel value + if( rInfo.mnCancelIndex >= 0 ) + { + if( rInfo.mnCancelIndex >= aVbaArgs.getLength() ) + throw lang::IllegalArgumentException(); + aVbaArgs[ rInfo.mnCancelIndex ] <<= bCancel; + } + // execute the event handler + uno::Any aRet, aCaller; + bEventSuccess = executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller ); + // extract new cancel value + 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; + } + } + // post processing (also, if event handler does not exist, or on error + implPostProcessEvent( aEventQueue, rInfo, bEventSuccess, bCancel ); + // global success, if at least one event handler succeeded + bSuccess |= bEventSuccess; + } + } + + // 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(); +} + +void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& /*aSource*/ ) throw (uno::RuntimeException) +{ + OSL_TRACE( "VbaEventsHelperBase::disposing" ); + stopListening(); + mbDisposed = true; +} + +// protected ------------------------------------------------------------------ + +void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId, + const sal_Char* pcMacroName, EventHandlerType eType, sal_Int32 nCancelIndex, const uno::Any& rUserData ) +{ + EventHandlerInfo& rInfo = maEvents[ nEventId ]; + rInfo.mnEventId = nEventId; + rInfo.maMacroName = ::rtl::OUString::createFromAscii( pcMacroName ); + rInfo.meType = eType; + rInfo.mnCancelIndex = nCancelIndex; + rInfo.maUserData = rUserData; +} + +// private -------------------------------------------------------------------- + +const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandlerInfo( + sal_Int32 nEventId ) const throw (lang::IllegalArgumentException) +{ + EventHandlerMap::const_iterator aIt = maEvents.find( nEventId ); + if( aIt == maEvents.end() ) + throw lang::IllegalArgumentException(); + return aIt->second; +} + +::rtl::OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo, + const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException) +{ + ::rtl::OUString aMacroName; + switch( rInfo.meType ) + { + case EVENTHANDLER_GLOBAL: + aMacroName = rInfo.maMacroName; + break; + case EVENTHANDLER_DOCUMENT: + aMacroName = ::rtl::OUStringBuffer( implGetDocumentModuleName( rInfo, rArgs ) ). + append( sal_Unicode( '.' ) ).append( rInfo.maMacroName ).makeStringAndClear(); + break; + } + return resolveVBAMacro( mpShell, aMacroName ).ResolvedMacro(); +} + +void VbaEventsHelperBase::stopListening() +{ + if( !mbDisposed ) try + { + uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW ); + xComponent->removeEventListener( this ); + } + catch( uno::Exception& ) + { + } +} + +// ============================================================================ diff --git a/vbahelper/source/vbahelper/vbaglobalbase.cxx b/vbahelper/source/vbahelper/vbaglobalbase.cxx index c7c33b93b1a3..e0df37583df5 100644 --- a/vbahelper/source/vbahelper/vbaglobalbase.cxx +++ b/vbahelper/source/vbahelper/vbaglobalbase.cxx @@ -35,22 +35,50 @@ using namespace ooo::vba; rtl::OUString sApplication( RTL_CONSTASCII_USTRINGPARAM("Application") ); +// special key to return the Application +rtl::OUString sAppService( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.Application") ); + VbaGlobalsBase::VbaGlobalsBase( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sDocCtxName ) -: Globals_BASE( xParent, xContext ) +: Globals_BASE( xParent, xContext ), msDocCtxName( sDocCtxName ) { // overwrite context with custom one ( that contains the application ) + // wrap the service manager as we don't want the disposing context to tear down the 'normal' ServiceManager ( or at least thats what the code appears like it wants to do ) + uno::Any aSrvMgr; + if ( xContext.is() && xContext->getServiceManager().is() ) + { + aSrvMgr = uno::makeAny( xContext->getServiceManager()->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.OServiceManagerWrapper") ), xContext ) ); + } + ::cppu::ContextEntry_Init aHandlerContextInfo[] = { ::cppu::ContextEntry_Init( sApplication, uno::Any() ), ::cppu::ContextEntry_Init( sDocCtxName, uno::Any() ), + ::cppu::ContextEntry_Init( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.lang.theServiceManager" ) ), aSrvMgr ) }; - - mxContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), xContext ); - + // don't pass a delegate, this seems to introduce yet another cyclic dependency ( and + // some strange behavior + mxContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), NULL ); } +VbaGlobalsBase::~VbaGlobalsBase() +{ + try + { + uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY ); + if ( xNameContainer.is() ) + { + // release document reference ( we don't wan't the component context trying to dispose that ) + xNameContainer->removeByName( msDocCtxName ); + // release application reference, as it is holding onto the context + xNameContainer->removeByName( sApplication ); + } + } + catch ( const uno::Exception& ) + { + } +} void VbaGlobalsBase::init( const uno::Sequence< beans::PropertyValue >& aInitArgs ) @@ -74,19 +102,30 @@ uno::Reference< uno::XInterface > SAL_CALL VbaGlobalsBase::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (uno::Exception, uno::RuntimeException) { uno::Reference< uno::XInterface > xReturn; - - if ( hasServiceName( aServiceSpecifier ) ) + if ( aServiceSpecifier.equals( sAppService ) ) + { + // try to extract the Application from the context + uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY ); + xNameContainer->getByName( sApplication ) >>= xReturn; + } + else if ( hasServiceName( aServiceSpecifier ) ) xReturn = mxContext->getServiceManager()->createInstanceWithContext( aServiceSpecifier, mxContext ); return xReturn; } uno::Reference< uno::XInterface > SAL_CALL -VbaGlobalsBase::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) throw (uno::Exception, uno::RuntimeException) +VbaGlobalsBase::createInstanceWithArguments( const ::rtl::OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) throw (uno::Exception, uno::RuntimeException) { uno::Reference< uno::XInterface > xReturn; - if ( hasServiceName( ServiceSpecifier ) ) - xReturn = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( ServiceSpecifier, Arguments, mxContext ); + if ( aServiceSpecifier.equals( sAppService ) ) + { + // try to extract the Application from the context + uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY ); + xNameContainer->getByName( sApplication ) >>= xReturn; + } + else if ( hasServiceName( aServiceSpecifier ) ) + xReturn = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( aServiceSpecifier, Arguments, mxContext ); return xReturn; } diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 1953d0772f3c..7cd82dff9536 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -1404,6 +1404,26 @@ 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; + } + SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { SfxObjectShell* pFoundShell = NULL; diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index d892c10f4f5d..f4843d54ace1 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -3107,6 +3107,9 @@ namespace xmloff { namespace token { XML_N_CHART_EXT, XML_COORDINATE_REGION, + XML_DIAGONAL_BL_TR_WIDTHS, + XML_DIAGONAL_TL_BR_WIDTHS, + XML_TOKEN_END }; diff --git a/xmloff/source/core/RDFaExportHelper.cxx b/xmloff/source/core/RDFaExportHelper.cxx index 593e2d1f29e6..f603d21258fd 100644 --- a/xmloff/source/core/RDFaExportHelper.cxx +++ b/xmloff/source/core/RDFaExportHelper.cxx @@ -37,6 +37,8 @@ #include <comphelper/stlunosequence.hxx> #include <comphelper/stl_types.hxx> +#include <com/sun/star/uri/XUriReference.hpp> +#include <com/sun/star/uri/XUriReferenceFactory.hpp> #include <com/sun/star/rdf/Statement.hpp> #include <com/sun/star/rdf/URIs.hpp> #include <com/sun/star/rdf/URI.hpp> @@ -85,6 +87,39 @@ makeCURIE(SvXMLExport * i_pExport, return buf.makeStringAndClear(); } +// #i112473# SvXMLExport::GetRelativeReference() not right for RDF on SaveAs +// because the URIs in the repository are not rewritten on SaveAs, the +// URI of the loaded document has to be used, not the URI of the target doc. +static ::rtl::OUString +getRelativeReference(SvXMLExport const& rExport, ::rtl::OUString const& rURI) +{ + uno::Reference< rdf::XURI > const xModelURI( + rExport.GetModel(), uno::UNO_QUERY_THROW ); + ::rtl::OUString const baseURI( xModelURI->getStringValue() ); + + uno::Reference<uno::XComponentContext> const xContext( + rExport.GetComponentContext()); + uno::Reference<lang::XMultiComponentFactory> const xServiceFactory( + xContext->getServiceManager(), uno::UNO_SET_THROW); + uno::Reference<uri::XUriReferenceFactory> const xUriFactory( + xServiceFactory->createInstanceWithContext( + ::rtl::OUString::createFromAscii( + "com.sun.star.uri.UriReferenceFactory"), xContext), + uno::UNO_QUERY_THROW); + + uno::Reference< uri::XUriReference > const xBaseURI( + xUriFactory->parse(baseURI), uno::UNO_SET_THROW ); + uno::Reference< uri::XUriReference > const xAbsoluteURI( + xUriFactory->parse(rURI), uno::UNO_SET_THROW ); + uno::Reference< uri::XUriReference > const xRelativeURI( + xUriFactory->makeRelative(xBaseURI, xAbsoluteURI, true, true, false), + uno::UNO_SET_THROW ); + ::rtl::OUString const relativeURI(xRelativeURI->getUriReference()); + + return relativeURI; +} + + //////////////////////////////////////////////////////////////////////////// RDFaExportHelper::RDFaExportHelper(SvXMLExport & i_rExport) @@ -145,7 +180,7 @@ RDFaExportHelper::AddRDFa( static const sal_Unicode s_OpenBracket ('['); static const sal_Unicode s_CloseBracket(']'); const ::rtl::OUString about( xSubjectURI.is() - ? m_rExport.GetRelativeReference(xSubjectURI->getStringValue()) + ? getRelativeReference(m_rExport, xSubjectURI->getStringValue()) : ::rtl::OUStringBuffer().append(s_OpenBracket).append( LookupBlankNode(xSubjectBNode)).append(s_CloseBracket) .makeStringAndClear() diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 2e92c4a6a97d..a3d4a0c48d02 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3107,6 +3107,9 @@ namespace xmloff { namespace token { TOKEN( "http://openoffice.org/2010/chart", XML_N_CHART_EXT ), TOKEN( "coordinate-region", XML_COORDINATE_REGION ), + TOKEN( "diagonal-bl-tr-widths", XML_DIAGONAL_BL_TR_WIDTHS ), + TOKEN( "diagonal-tl-br-widths", XML_DIAGONAL_TL_BR_WIDTHS ), + #if OSL_DEBUG_LEVEL > 0 { 0, NULL, NULL, XML_TOKEN_END } #else diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index 9d7856348516..98255edf68d0 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -708,6 +708,7 @@ void GetEnhancedPath( std::vector< com::sun::star::beans::PropertyValue >& rDest case '8' : case '9' : case '.' : + case '-' : { com::sun::star::drawing::EnhancedCustomShapeParameterPair aPair; if ( GetNextParameter( aPair.First, nIndex, rValue ) && diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index af51f5f56d98..00cdce37f4d5 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -116,6 +116,7 @@ XMLTextMarkImportContext::XMLTextMarkImportContext( const OUString& rLocalName ) : SvXMLImportContext(rImport, nPrefix, rLocalName) , m_rHelper(rHlp) + , m_bHaveAbout(false) { } |