From 928159ff71d19a3910d1fd1e472a11ef1c89415b Mon Sep 17 00:00:00 2001 From: Noel Power Date: Tue, 2 Nov 2010 16:22:07 +0000 Subject: initial import of latest cws container_controls --- basic/source/classes/sbxmod.cxx | 11 +- basic/source/inc/namecont.hxx | 3 + basic/source/uno/dlgcont.cxx | 80 +++ basic/source/uno/namecont.cxx | 12 + scripting/prj/build.lst | 2 +- scripting/source/dlgprov/dlgevtatt.cxx | 76 ++- scripting/source/dlgprov/dlgevtatt.hxx | 1 + scripting/source/vbaevents/eventhelper.cxx | 66 +-- vbahelper/prj/build.lst | 2 +- vbahelper/source/msforms/vbacontrol.cxx | 23 +- vbahelper/source/msforms/vbacontrols.cxx | 14 +- vbahelper/source/msforms/vbamultipage.cxx | 24 +- vbahelper/source/msforms/vbauserform.cxx | 41 +- vbahelper/source/msforms/vbauserform.hxx | 2 + xmlscript/source/xmldlg_imexp/common.hxx | 1 + xmlscript/source/xmldlg_imexp/exp_share.hxx | 26 +- xmlscript/source/xmldlg_imexp/imp_share.hxx | 103 +++- xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx | 551 +++++++++++++++------ xmlscript/source/xmldlg_imexp/xmldlg_export.cxx | 390 +++++---------- xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx | 463 +++++++---------- xmlscript/source/xmldlg_imexp/xmldlg_import.cxx | 144 +++++- xmlscript/util/makefile.mk | 1 + 22 files changed, 1244 insertions(+), 792 deletions(-) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 089a963cf05c..b87672981184 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -2505,8 +2505,15 @@ void SbUserFormModule::InitObject() aArgs[ 0 ] <<= m_xModel; rtl::OUString sDialogUrl( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.script:" ) ); rtl::OUString sProjectName( RTL_CONSTASCII_USTRINGPARAM("Standard") ); - if ( this->GetParent()->GetName().Len() ) - sProjectName = this->GetParent()->GetName(); + + try + { + Reference< beans::XPropertySet > xProps( m_xModel, UNO_QUERY_THROW ); + uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY_THROW ); + sProjectName = xVBAMode->getProjectName(); + } + catch( Exception& /*e*/) {} + sDialogUrl = sDialogUrl.concat( sProjectName ).concat( rtl::OUString( '.') ).concat( GetName() ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?location=document") ) ); uno::Reference< awt::XDialogProvider > xProvider( xFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.DialogProvider")), aArgs ), uno::UNO_QUERY_THROW ); diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 2b3b65f74eca..3b253952fb67 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -225,6 +225,7 @@ class SfxLibraryContainer :public LibraryContainerHelper ,public ::utl::OEventListenerAdapter { sal_Bool mbVBACompat; + rtl::OUString msProjectName; protected: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > mxSFI; @@ -514,6 +515,8 @@ public: // Methods XVBACompatibility virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProjectName() throw (::com::sun::star::uno::RuntimeException) { return msProjectName; } + virtual void SAL_CALL setProjectName( const ::rtl::OUString& _projectname ) throw (::com::sun::star::uno::RuntimeException); }; class LibraryContainerMethodGuard diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx index 449a0ee86584..0f6e577794c6 100644 --- a/basic/source/uno/dlgcont.cxx +++ b/basic/source/uno/dlgcont.cxx @@ -41,6 +41,7 @@ #include #include "com/sun/star/resource/XStringResourceWithStorage.hpp" #include "com/sun/star/resource/XStringResourceWithLocation.hpp" +#include "com/sun/star/document/XGraphicObjectResolver.hpp" #include "dlgcont.hxx" #include "sbmodule.hxx" #include @@ -74,6 +75,8 @@ using namespace osl; using com::sun::star::uno::Reference; +#define GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:" + //============================================================================ // Implementation class SfxDialogLibraryContainer @@ -225,6 +228,35 @@ void SAL_CALL SfxDialogLibraryContainer::writeLibraryElement xInput->closeInput(); } +void lcl_deepInspectForEmbeddedImages( const Reference< XInterface >& xIf, std::vector< rtl::OUString >& rvEmbedImgUrls ) +{ + static rtl::OUString sImageURL= OUString(RTL_CONSTASCII_USTRINGPARAM( "ImageURL" ) ); + Reference< beans::XPropertySet > xProps( xIf, UNO_QUERY ); + if ( xProps.is() ) + { + + if ( xProps->getPropertySetInfo()->hasPropertyByName( sImageURL ) ) + { + rtl::OUString sURL; + xProps->getPropertyValue( sImageURL ) >>= sURL; + if ( sURL.getLength() && sURL.compareToAscii( GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( GRAPHOBJ_URLPREFIX ) ) == 0 ) + rvEmbedImgUrls.push_back( sURL ); + } + } + Reference< XNameContainer > xContainer( xIf, UNO_QUERY ); + if ( xContainer.is() ) + { + Sequence< rtl::OUString > sNames = xContainer->getElementNames(); + sal_Int32 nContainees = sNames.getLength(); + for ( sal_Int32 index = 0; index < nContainees; ++index ) + { + Reference< XInterface > xCtrl; + xContainer->getByName( sNames[ index ] ) >>= xCtrl; + lcl_deepInspectForEmbeddedImages( xCtrl, rvEmbedImgUrls ); + } + } +} + void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< embed::XStorage >& xStorage ) throw ( RuntimeException ) { LibraryContainerMethodGuard aGuard( *this ); @@ -253,6 +285,54 @@ void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< e SfxLibraryContainer::storeLibrariesToStorage( xStorage ); + // we need to export out any embedded image object(s) + // associated with any Dialogs. First, we need to actually gather any such urls + // for each dialog in this container + Sequence< OUString > sLibraries = getElementNames(); + for ( sal_Int32 i=0; i < sLibraries.getLength(); ++i ) + { + // libraries will already be loaded from above + Reference< XNameContainer > xLib; + getByName( sLibraries[ i ] ) >>= xLib; + if ( xLib.is() ) + { + Sequence< OUString > sDialogs = xLib->getElementNames(); + sal_Int32 nDialogs( sDialogs.getLength() ); + for ( sal_Int32 j=0; j < nDialogs; ++j ) + { + // Each Dialog has an associated xISP + Reference< io::XInputStreamProvider > xISP; + xLib->getByName( sDialogs[ j ] ) >>= xISP; + if ( xISP.is() ) + { + Reference< io::XInputStream > xInput( xISP->createInputStream() ); + Reference< XNameContainer > xDialogModel( mxMSF->createInstance + ( OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY ); + Reference< XComponentContext > xContext; + Reference< beans::XPropertySet > xProps( mxMSF, UNO_QUERY ); + OSL_ASSERT( xProps.is() ); + OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); + ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, mxOwnerDocument ); + std::vector< rtl::OUString > vEmbeddedImageURLs; + lcl_deepInspectForEmbeddedImages( Reference< XInterface >( xDialogModel, UNO_QUERY ), vEmbeddedImageURLs ); + if ( vEmbeddedImageURLs.size() ) + { + // Export the images to the storage + Sequence< Any > aArgs( 1 ); + aArgs[ 0 ] <<= xStorage; + Reference< document::XGraphicObjectResolver > xGraphicResolver( mxMSF->createInstanceWithArguments( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Svx.GraphicExportHelper" ) ), aArgs ), UNO_QUERY ); + std::vector< rtl::OUString >::iterator it = vEmbeddedImageURLs.begin(); + std::vector< rtl::OUString >::iterator it_end = vEmbeddedImageURLs.end(); + if ( xGraphicResolver.is() ) + { + for ( sal_Int32 count = 0; it != it_end; ++it, ++count ) + xGraphicResolver->resolveGraphicObjectURL( *it ); + } + } + } + } + } + } mbOasis2OOoFormat = sal_False; } diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index 06461e1ed756..3d5d71509762 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -2824,6 +2824,18 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa mbVBACompat = _vbacompatmodeon; } +void SAL_CALL SfxLibraryContainer::setProjectName( const ::rtl::OUString& _projectname ) throw (RuntimeException) +{ + msProjectName = _projectname; + BasicManager* pBasMgr = getBasicManager(); + // Temporary HACK + // Some parts of the VBA handling ( e.g. in core basic ) + // code expect the name of the VBA project to be set as the name of + // the basic manager. Provide fail back here. + if( pBasMgr ) + pBasMgr->SetName( msProjectName ); +} + // Methods XServiceInfo ::sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) diff --git a/scripting/prj/build.lst b/scripting/prj/build.lst index 7d5162173eae..28fcdbc2e6f7 100755 --- a/scripting/prj/build.lst +++ b/scripting/prj/build.lst @@ -1,4 +1,4 @@ -tc scripting : oovbaapi vbahelper bridges rdbmaker vcl xmlscript basic sfx2 rhino BSH:beanshell javaunohelper NULL +tc scripting : filter oovbaapi vbahelper bridges rdbmaker vcl xmlscript basic sfx2 rhino BSH:beanshell javaunohelper NULL tc scripting usr1 - all tc1_mkout NULL tc scripting\inc nmake - all tc1_inc NULL tc scripting\source\provider nmake - all tc1_scriptingprovider tc1_inc NULL diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx index 836d723a14c1..d3bb20db13aa 100644 --- a/scripting/source/dlgprov/dlgevtatt.cxx +++ b/scripting/source/dlgprov/dlgevtatt.cxx @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -232,6 +233,9 @@ namespace dlgprov Reference< container::XNameContainer > xEventCont = xEventsSupplier->getEvents(); Reference< XControlModel > xControlModel = xControl->getModel(); + Reference< XPropertySet > xProps( xControlModel, uno::UNO_QUERY ); + rtl::OUString sName; + xProps->getPropertyValue( rtl::OUString::createFromAscii("Name") ) >>= sName; if ( xEventCont.is() ) { Sequence< ::rtl::OUString > aNames = xEventCont->getElementNames(); @@ -288,6 +292,51 @@ namespace dlgprov } } + + void DialogEventsAttacherImpl::nestedAttachEvents( const Sequence< Reference< XInterface > >& Objects, const Any& Helper, rtl::OUString& sDialogCodeName ) + { + const Reference< XInterface >* pObjects = Objects.getConstArray(); + sal_Int32 nObjCount = Objects.getLength(); + + for ( sal_Int32 i = 0; i < nObjCount; ++i ) + { + // We know that we have to do with instances of XControl. + // Otherwise this is not the right implementation for + // XScriptEventsAttacher and we have to give up. + Reference< XControl > xControl( pObjects[ i ], UNO_QUERY ); + Reference< XControlContainer > xControlContainer( xControl, UNO_QUERY ); + Reference< XDialog > xDialog( xControl, UNO_QUERY ); + if ( !xControl.is() ) + throw IllegalArgumentException(); + + // get XEventsSupplier from control model + Reference< XControlModel > xControlModel = xControl->getModel(); + Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY ); + attachEventsToControl( xControl, xEventsSupplier, Helper ); + if ( mbUseFakeVBAEvents ) + { + xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) ); + Any newHelper(xControl ); + attachEventsToControl( xControl, xEventsSupplier, newHelper ); + } + if ( xControlContainer.is() && !xDialog.is() ) + { + Sequence< Reference< XControl > > aControls = xControlContainer->getControls(); + sal_Int32 nControlCount = aControls.getLength(); + + Sequence< Reference< XInterface > > aObjects( nControlCount ); + Reference< XInterface >* pObjectsModify = aObjects.getArray(); + const Reference< XControl >* pControls = aControls.getConstArray(); + + for ( sal_Int32 j = 0; j < nControlCount; ++j ) + { + pObjectsModify[j] = Reference< XInterface >( pControls[j], UNO_QUERY ); + } + nestedAttachEvents( aObjects, Helper, sDialogCodeName ); + } + } + } + // ----------------------------------------------------------------------------- // XScriptEventsAttacher // ----------------------------------------------------------------------------- @@ -320,12 +369,9 @@ namespace dlgprov } } - - // go over all objects - const Reference< XInterface >* pObjects = Objects.getConstArray(); + rtl::OUString sDialogCodeName; sal_Int32 nObjCount = Objects.getLength(); Reference< awt::XControl > xDlgControl( Objects[ nObjCount - 1 ], uno::UNO_QUERY ); // last object is the dialog - rtl::OUString sDialogCodeName; if ( xDlgControl.is() ) { Reference< XPropertySet > xProps( xDlgControl->getModel(), UNO_QUERY ); @@ -335,26 +381,8 @@ namespace dlgprov } catch( Exception& ){} } - - for ( sal_Int32 i = 0; i < nObjCount; ++i ) - { - // We know that we have to do with instances of XControl. - // Otherwise this is not the right implementation for - // XScriptEventsAttacher and we have to give up. - Reference< XControl > xControl( pObjects[ i ], UNO_QUERY ); - if ( !xControl.is() ) - throw IllegalArgumentException(); - - // get XEventsSupplier from control model - Reference< XControlModel > xControlModel = xControl->getModel(); - Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY ); - attachEventsToControl( xControl, xEventsSupplier, Helper ); - if ( mbUseFakeVBAEvents ) - { - xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) ); - attachEventsToControl( xControl, xEventsSupplier, Helper ); - } - } + // go over all objects + nestedAttachEvents( Objects, Helper, sDialogCodeName ); } diff --git a/scripting/source/dlgprov/dlgevtatt.hxx b/scripting/source/dlgprov/dlgevtatt.hxx index 437abc668838..dc24f1410a2f 100644 --- a/scripting/source/dlgprov/dlgevtatt.hxx +++ b/scripting/source/dlgprov/dlgevtatt.hxx @@ -69,6 +69,7 @@ namespace dlgprov ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacher > m_xEventAttacher; ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > getScriptListenerForKey( const rtl::OUString& sScriptName ) throw ( ::com::sun::star::uno::RuntimeException ); ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier > getFakeVbaEventsSupplier( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, rtl::OUString& sCodeName ); + void nestedAttachEvents( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& Objects, const ::com::sun::star::uno::Any& Helper, rtl::OUString& sDialogCodeName ); void SAL_CALL attachEventsToControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier >& events, const ::com::sun::star::uno::Any& Helper ); public: DialogEventsAttacherImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index cfd1dad6b6cc..165b5f86a045 100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -56,6 +56,7 @@ #include #include #include +#include #include @@ -688,9 +689,9 @@ private: Reference< XComponentContext > m_xContext; Reference< frame::XModel > m_xModel; - SfxObjectShell* mpShell; sal_Bool m_bDocClosed; - + SfxObjectShell* mpShell; + rtl::OUString msProject; }; EventListener::EventListener( const Reference< XComponentContext >& rxContext ) : @@ -698,7 +699,7 @@ OPropertyContainer(GetBroadcastHelper()), m_xContext( rxContext ), m_bDocClosed( { registerProperty( EVENTLSTNR_PROPERTY_MODEL, EVENTLSTNR_PROPERTY_ID_MODEL, beans::PropertyAttribute::TRANSIENT, &m_xModel, ::getCppuType( &m_xModel ) ); - + msProject = rtl::OUString::createFromAscii("Standard"); } void @@ -716,6 +717,14 @@ EventListener::setShellFromModel() } pShell = SfxObjectShell::GetNext( *pShell ); } + // set ProjectName from model + try + { + uno::Reference< beans::XPropertySet > xProps( m_xModel, UNO_QUERY_THROW ); + uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY_THROW ); + msProject = xVBAMode->getProjectName(); + } + catch ( uno::Exception& ) {} } //XEventListener @@ -772,13 +781,13 @@ EventListener::approveFiring(const ScriptEvent& evt) throw(reflection::Invocatio // XCloseListener void SAL_CALL -EventListener::queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException) +EventListener::queryClosing( const lang::EventObject& /*Source*/, ::sal_Bool /*GetsOwnership*/ ) throw (util::CloseVetoException, uno::RuntimeException) { //Nothing to do } void SAL_CALL -EventListener::notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException) +EventListener::notifyClosing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException) { m_bDocClosed = sal_True; uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( m_xModel, uno::UNO_QUERY ); @@ -931,36 +940,34 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce uno::Reference< awt::XDialog > xDlg( aEvent.Source, uno::UNO_QUERY ); if ( !xDlg.is() ) { - OSL_TRACE("Getting Control"); + OSL_TRACE("Getting Control"); // evt.Source is // a) Dialog // b) xShapeControl ( from api (sheet control) ) // c) eventmanager ( I guess ) // d) vba control ( from api also ) - uno::Reference< drawing::XControlShape > xCntrlShape( evt.Source, uno::UNO_QUERY ); - uno::Reference< awt::XControl > xControl( aEvent.Source, uno::UNO_QUERY ); - if ( xCntrlShape.is() ) - { - // for sheet controls ( that fire from the api ) we don't - // have the real control ( thats only available from the view ) - // api code creates just a control instance that is transferred - // via aEvent.Arguments[ 0 ] that control though has no - // info like name etc. - uno::Reference< drawing::XControlShape > xCntrlShape( evt.Source, UNO_QUERY_THROW ); - OSL_TRACE("Got control shape"); - uno::Reference< container::XNamed > xName( xCntrlShape->getControl(), uno::UNO_QUERY_THROW ); - OSL_TRACE("Got xnamed "); - sName = xName->getName(); - } - else + uno::Reference< drawing::XControlShape > xCntrlShape( evt.Source, uno::UNO_QUERY ); + uno::Reference< awt::XControl > xControl( aEvent.Source, uno::UNO_QUERY ); + if ( xCntrlShape.is() ) { - // Userform control ( fired from the api or from event manager ) - uno::Reference< beans::XPropertySet > xProps; - OSL_TRACE("Getting properties"); - xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW ); - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= sName; - } - + // for sheet controls ( that fire from the api ) we don't + // have the real control ( thats only available from the view ) + // api code creates just a control instance that is transferred + // via aEvent.Arguments[ 0 ] that control though has no + // info like name etc. + OSL_TRACE("Got control shape"); + uno::Reference< container::XNamed > xName( xCntrlShape->getControl(), uno::UNO_QUERY_THROW ); + OSL_TRACE("Got xnamed "); + sName = xName->getName(); + } + else + { + // Userform control ( fired from the api or from event manager ) + uno::Reference< beans::XPropertySet > xProps; + OSL_TRACE("Getting properties"); + xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW ); + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= sName; + } } //dumpEvent( evt ); EventInfoHash& infos = getEventTransInfo(); @@ -984,7 +991,6 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce eventInfo_it->second.begin(); std::list< TranslateInfo >::const_iterator txInfo_end = eventInfo_it->second.end(); - StarBASIC* pBasic = mpShell->GetBasic(); BasicManager* pBasicManager = mpShell->GetBasicManager(); rtl::OUString sProject; rtl::OUString sScriptCode( evt.ScriptCode ); diff --git a/vbahelper/prj/build.lst b/vbahelper/prj/build.lst index 20001db859c8..ded9ee23b3fc 100644 --- a/vbahelper/prj/build.lst +++ b/vbahelper/prj/build.lst @@ -1,4 +1,4 @@ -vba vbahelper : oovbaapi basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal NULL +vba vbahelper : oovbaapi oox basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal NULL vba vbahelper usr1 - all vba_mkout NULL #vba vbahelper\inc nmake - all vba_inc NULL vba vbahelper\source\vbahelper nmake - all vba_vbahelper NULL diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index 599ef3336dcc..fcc9a4a1f3df 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -573,23 +573,28 @@ ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XCo else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) ) pControl = new ScVbaComboBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) - pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) ) - pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) ) - pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) ) - pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) - pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) ) - pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) ) - pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent ); + pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent ); + // #FIXME implement a page control + else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoPageModel") ) ) ) + pControl = new ScVbaControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoFrameModel") ) ) ) + pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) ) - pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) ) - pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() ); return pControl; diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index b4c2f6a6f497..75688413a57a 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -71,7 +71,19 @@ private: mIndices[ msNames[ nIndex ] ] = nIndex; } } - + void getNestedControls( ControlVec& vControls, uno::Reference< awt::XControlContainer >& xContainer ) + { + uno::Sequence< uno::Reference< awt::XControl > > aControls = xContainer->getControls(); + const uno::Reference< awt::XControl >* pCtrl = aControls.getConstArray(); + const uno::Reference< awt::XControl >* pCtrlsEnd = pCtrl + aControls.getLength(); + for ( ; pCtrl < pCtrlsEnd; ++pCtrl ) + { + uno::Reference< awt::XControlContainer > xC( *pCtrl, uno::UNO_QUERY ); + vControls.push_back( *pCtrl ); + if ( xC.is() ) + getNestedControls( vControls, xC ); + } + } public: ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog ) { diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx index 2d657440a7c3..ac613ccdfaca 100644 --- a/vbahelper/source/msforms/vbamultipage.cxx +++ b/vbahelper/source/msforms/vbamultipage.cxx @@ -29,14 +29,12 @@ #include #include "vbapages.hxx" #include +#include using namespace com::sun::star; using namespace ooo::vba; -// uno servicename com.sun.star.awt.UnoControlProgressBarMode -const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ); -const rtl::OUString SVALUEMAX( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ); -const rtl::OUString SSTEP( RTL_CONSTASCII_USTRINGPARAM("Step") ); +const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("MultiPageValue") ); typedef cppu::WeakImplHelper1< container::XIndexAccess > PagesImpl_Base; class PagesImpl : public PagesImpl_Base @@ -72,8 +70,6 @@ ScVbaMultiPage::getPages( sal_Int32 nPages ) ScVbaMultiPage::ScVbaMultiPage( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, const uno::Reference< uno::XInterface >& xDialog ) : MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) { mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW ); - // set dialog step to value of multipage pseudo model - setValue(getValue()); } // Attributes @@ -82,17 +78,17 @@ ScVbaMultiPage::getValue() throw (css::uno::RuntimeException) { sal_Int32 nValue = 0; m_xProps->getPropertyValue( SVALUE ) >>= nValue; - return nValue; + // VBA 0 based tab index + return nValue - 1; } void SAL_CALL ScVbaMultiPage::setValue( const sal_Int32 _value ) throw (::com::sun::star::uno::RuntimeException) { - // track change in dialog ( dialog value is 1 based, 0 is a special value ) - sal_Int32 nVal = _value; // will be _value + 1 when cws container_controls is integrated + // Openoffice 1 based tab index + sal_Int32 nVal = _value + 1; sal_Int32 nOldVal = getValue(); - m_xProps->setPropertyValue( SVALUE, uno::makeAny( _value ) ); - mxDialogProps->setPropertyValue( SSTEP, uno::makeAny( _value + 1) ); + m_xProps->setPropertyValue( SVALUE, uno::makeAny( nVal ) ); if ( nVal != nOldVal ) fireChangeEvent(); } @@ -108,9 +104,9 @@ ScVbaMultiPage::getServiceImplName() uno::Any SAL_CALL ScVbaMultiPage::Pages( const uno::Any& index ) throw (uno::RuntimeException) { - sal_Int32 nValue = 0; - m_xProps->getPropertyValue( SVALUEMAX ) >>= nValue; - uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, getPages( nValue ) ) ); + // get the container model + uno::Reference< container::XNameContainer > xContainer( m_xProps, uno::UNO_QUERY_THROW ); + uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, getPages( xContainer->getElementNames().getLength() ) ) ); if ( !index.hasValue() ) return uno::makeAny( xColl ); return xColl->Item( uno::makeAny( index ), uno::Any() ); diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index dadb8656e6e4..ec3bcb7bac23 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -191,6 +192,30 @@ ScVbaUserForm::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& a } } +uno::Reference< awt::XControl > +ScVbaUserForm::nestedSearch( const rtl::OUString& aPropertyName, uno::Reference< awt::XControlContainer >& xContainer ) +{ + uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName ); + if ( !xControl.is() ) + { + uno::Sequence< uno::Reference< awt::XControl > > aControls = xContainer->getControls(); + const uno::Reference< awt::XControl >* pCtrl = aControls.getConstArray(); + const uno::Reference< awt::XControl >* pCtrlsEnd = pCtrl + aControls.getLength(); + + for ( ; pCtrl < pCtrlsEnd; ++pCtrl ) + { + uno::Reference< awt::XControlContainer > xC( *pCtrl, uno::UNO_QUERY ); + if ( xC.is() ) + { + xControl.set( nestedSearch( aPropertyName, xC ) ); + if ( xControl.is() ) + break; + } + } + } + return xControl; +} + uno::Any SAL_CALL ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException) { @@ -201,7 +226,8 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un { uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW ); uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW ); - uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName ); + uno::Reference< awt::XControl > xControl = nestedSearch( aPropertyName, xContainer ); + xContainer->getControl( aPropertyName ); ScVbaControlFactory aFac( mxContext, xControl, m_xModel ); uno::Reference< msforms::XControl > xVBAControl( aFac.createControl( xDialogControl->getModel() ) ); ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() ); @@ -235,13 +261,18 @@ ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException) ScVbaUserForm::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException) { uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY ); + OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is() ); if ( xControl.is() ) { - uno::Reference< container::XNameAccess > xNameAccess( xControl->getModel(), uno::UNO_QUERY_THROW ); - sal_Bool bRes = xNameAccess->hasByName( aName ); - OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is(), bRes ); - return bRes; + uno::Reference< beans::XPropertySet > xDlgProps( xControl->getModel(), uno::UNO_QUERY ); + if ( xDlgProps.is() ) + { + uno::Reference< container::XNameContainer > xAllChildren( xDlgProps->getPropertyValue( rtl::OUString::createFromAscii("AllDialogChildren" ) ), uno::UNO_QUERY_THROW ); + sal_Bool bRes = xAllChildren->hasByName( aName ); + OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xAllChildren.is(), bRes ); + return bRes; + } } return sal_False; } diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx index 6389557b1afa..700f1017bffd 100644 --- a/vbahelper/source/msforms/vbauserform.hxx +++ b/vbahelper/source/msforms/vbauserform.hxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,7 @@ protected: public: ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException ); virtual ~ScVbaUserForm(); + static css::uno::Reference< css::awt::XControl > nestedSearch( const rtl::OUString& aPropertyName, css::uno::Reference< css::awt::XControlContainer >& xContainer ); virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException); // XUserForm diff --git a/xmlscript/source/xmldlg_imexp/common.hxx b/xmlscript/source/xmldlg_imexp/common.hxx index e391fb619ed4..7395c1034f95 100644 --- a/xmlscript/source/xmldlg_imexp/common.hxx +++ b/xmlscript/source/xmldlg_imexp/common.hxx @@ -40,6 +40,7 @@ const sal_Int16 BORDER_SIMPLE_COLOR = 3; } +#define XMLSCRIPT_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:" #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx index ffb97055dff4..aaf6bd6aeef6 100644 --- a/xmlscript/source/xmldlg_imexp/exp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx @@ -91,16 +91,18 @@ class ElementDescriptor { css::uno::Reference< css::beans::XPropertySet > _xProps; css::uno::Reference< css::beans::XPropertyState > _xPropState; + css::uno::Reference< css::frame::XModel > _xDocument; public: inline ElementDescriptor( css::uno::Reference< css::beans::XPropertySet > const & xProps, css::uno::Reference< css::beans::XPropertyState > const & xPropState, - ::rtl::OUString const & name ) + ::rtl::OUString const & name, css::uno::Reference< css::frame::XModel > const & xDocument ) SAL_THROW( () ) : XMLElement( name ) , _xProps( xProps ) , _xPropState( xPropState ) + , _xDocument( xDocument ) {} inline ElementDescriptor( ::rtl::OUString const & name ) @@ -142,6 +144,8 @@ public: ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName ); void readVerticalAlignAttr( ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName ); + void readImageURLAttr( + ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName ); void readImageAlignAttr( ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName ); void readImagePositionAttr( @@ -159,6 +163,8 @@ public: void readSelectionTypeAttr( ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName ); // + void readDataAwareAttr( + ::rtl::OUString const & rAttrName ); inline void addBoolAttr( ::rtl::OUString const & rAttrName, sal_Bool bValue ) { addAttribute( rAttrName, ::rtl::OUString::valueOf(bValue) ); } @@ -172,17 +178,23 @@ public: // void readDialogModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); + void readBullitinBoard( StyleBag * all_styles ) + SAL_THROW( (css::uno::Exception) ); void readMultiPageModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); + void readFrameModel( StyleBag * all_styles ) + SAL_THROW( (css::uno::Exception) ); + void readPageModel( StyleBag * all_styles ) + SAL_THROW( (css::uno::Exception) ); void readButtonModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); void readEditModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); void readCheckBoxModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); - void readRadioButtonModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) + void readRadioButtonModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); - void readComboBoxModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) + void readComboBoxModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); void readCurrencyFieldModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); @@ -196,9 +208,9 @@ public: SAL_THROW( (css::uno::Exception) ); void readGroupBoxModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); - void readImageControlModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) + void readImageControlModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); - void readListBoxModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) + void readListBoxModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); void readNumericFieldModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); @@ -212,9 +224,9 @@ public: SAL_THROW( (css::uno::Exception) ); void readProgressBarModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); - void readScrollBarModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) + void readScrollBarModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); - void readSpinButtonModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) + void readSpinButtonModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); void readFixedHyperLinkModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx index 27929a349bfe..5523fe05440b 100644 --- a/xmlscript/source/xmldlg_imexp/imp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx @@ -45,7 +45,7 @@ #include #include #include - +#include namespace css = ::com::sun::star; @@ -117,16 +117,19 @@ inline bool getLongAttr( class ImportContext; //============================================================================== +typedef ::cppu::WeakImplHelper1< css::xml::input::XRoot > DialogImport_Base; struct DialogImport - : public ::cppu::WeakImplHelper1< css::xml::input::XRoot > + : DialogImport_Base { friend class ImportContext; css::uno::Reference< css::uno::XComponentContext > _xContext; css::uno::Reference< css::util::XNumberFormatsSupplier > _xSupplier; - ::std::vector< ::rtl::OUString > _styleNames; - ::std::vector< css::uno::Reference< css::xml::input::XElement > > _styles; + ::boost::shared_ptr< ::std::vector< ::rtl::OUString > > _pStyleNames; + ::boost::shared_ptr< ::std::vector< css::uno::Reference< css::xml::input::XElement > > > _pStyles; + ::std::vector< ::rtl::OUString >& _styleNames; + ::std::vector< css::uno::Reference< css::xml::input::XElement > >& _styles; css::uno::Reference< css::container::XNameContainer > _xDialogModel; css::uno::Reference< css::lang::XMultiServiceFactory > _xDialogModelFactory; @@ -166,13 +169,32 @@ public: css::uno::Reference const & xContext, css::uno::Reference const & xDialogModel, + ::boost::shared_ptr< ::std::vector< ::rtl::OUString > >& pStyleNames, + ::boost::shared_ptr< ::std::vector< css::uno::Reference< css::xml::input::XElement > > >& pStyles, css::uno::Reference const & xDoc ) SAL_THROW( () ) : _xContext( xContext ) + , _pStyleNames( pStyleNames ) + , _pStyles( pStyles ) + , _styleNames( *_pStyleNames ) + , _styles( *_pStyles ) , _xDialogModel( xDialogModel ) , _xDialogModelFactory( xDialogModel, css::uno::UNO_QUERY_THROW ), _xDoc( xDoc ) { OSL_ASSERT( _xDialogModel.is() && _xDialogModelFactory.is() && _xContext.is() ); } + inline DialogImport( const DialogImport& rOther ) : DialogImport_Base() + , _xContext( rOther._xContext ) + , _xSupplier( rOther._xSupplier ) + , _pStyleNames( rOther._pStyleNames ) + , _pStyles( rOther._pStyles ) + , _styleNames( *_pStyleNames ) + , _styles( *_pStyles ) + , _xDialogModel( rOther._xDialogModel ) + , _xDialogModelFactory( rOther._xDialogModelFactory ) + , _xDoc( rOther._xDoc ) + , XMLNS_DIALOGS_UID( rOther.XMLNS_DIALOGS_UID ) + , XMLNS_SCRIPT_UID( rOther.XMLNS_SCRIPT_UID ) {} + virtual ~DialogImport() SAL_THROW( () ); @@ -365,6 +387,9 @@ protected: ::rtl::OUString getControlId( css::uno::Reference const & xAttributes ); + ::rtl::OUString getControlModelName( + rtl::OUString const& rDefaultModel, + css::uno::Reference const & xAttributes ); css::uno::Reference< css::xml::input::XElement > getStyle( css::uno::Reference const & xAttributes ); public: @@ -435,6 +460,8 @@ public: bool importVerticalAlignProperty( ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName, css::uno::Reference const & xAttributes ); + bool importImageURLProperty( rtl::OUString const & rPropName, rtl::OUString const & rAttrName, + css::uno::Reference< css::xml::input::XAttributes > const & xAttributes ); bool importImageAlignProperty( ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName, css::uno::Reference const & xAttributes ); @@ -459,6 +486,9 @@ public: bool importSelectionTypeProperty( ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName, css::uno::Reference const & xAttributes ); + bool importDataAwareProperty( + ::rtl::OUString const & rPropName, + css::uno::Reference const & xAttributes ); }; //============================================================================== @@ -474,6 +504,14 @@ public: pImport->_xDialogModelFactory->createInstance( rControlName ), css::uno::UNO_QUERY_THROW ), rId ) {} + inline ControlImportContext( + DialogImport * pImport, + const css::uno::Reference< css::beans::XPropertySet >& xProps, ::rtl::OUString const & rControlName ) + : ImportContext( + pImport, + xProps, + rControlName ) + {} inline ~ControlImportContext() { _pImport->_xDialogModel->insertByName( @@ -1004,6 +1042,7 @@ public: }; //============================================================================== + class SpinButtonElement : public ControlElement { @@ -1039,14 +1078,70 @@ public: throw (css::xml::sax::SAXException, css::uno::RuntimeException); inline MultiPage( + ::rtl::OUString const & rLocalName, + css::uno::Reference< css::xml::input::XAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + SAL_THROW( () ) + : ControlElement( rLocalName, xAttributes, pParent, pImport ) + { + m_xContainer.set( _pImport->_xDialogModelFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ), css::uno::UNO_QUERY ); + } +private: + css::uno::Reference< css::container::XNameContainer > m_xContainer; +}; + +//============================================================================== +class Frame + : public ControlElement +{ + ::rtl::OUString _label; +public: + virtual css::uno::Reference< css::xml::input::XElement > + SAL_CALL startChildElement( + sal_Int32 nUid, ::rtl::OUString const & rLocalName, + css::uno::Reference const & xAttributes ) + throw (css::xml::sax::SAXException, css::uno::RuntimeException); + virtual void SAL_CALL endElement() + throw (css::xml::sax::SAXException, css::uno::RuntimeException); + + inline Frame( ::rtl::OUString const & rLocalName, css::uno::Reference< css::xml::input::XAttributes > const & xAttributes, ElementBase * pParent, DialogImport * pImport ) SAL_THROW( () ) : ControlElement( rLocalName, xAttributes, pParent, pImport ) {} +private: + css::uno::Reference< css::container::XNameContainer > m_xContainer; }; +//============================================================================== +class Page + : public ControlElement +{ +public: + virtual css::uno::Reference< css::xml::input::XElement > + SAL_CALL startChildElement( + sal_Int32 nUid, ::rtl::OUString const & rLocalName, + css::uno::Reference const & xAttributes ) + throw (css::xml::sax::SAXException, css::uno::RuntimeException); + virtual void SAL_CALL endElement() + throw (css::xml::sax::SAXException, css::uno::RuntimeException); + + inline Page( + ::rtl::OUString const & rLocalName, + css::uno::Reference< css::xml::input::XAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + SAL_THROW( () ) + : ControlElement( rLocalName, xAttributes, pParent, pImport ) + { + m_xContainer.set( _pImport->_xDialogModelFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoPageModel") ) ), css::uno::UNO_QUERY ); + } +private: + css::uno::Reference< css::container::XNameContainer > m_xContainer; +}; + + class ProgressBarElement : public ControlElement { diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx index a2abb08d5c0f..2d955fd5c5d5 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx @@ -39,8 +39,7 @@ #include #include #include -#include - +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -49,66 +48,6 @@ using ::rtl::OUString; namespace xmlscript { -void lclExportBindableAndListSourceBits( Reference< frame::XModel > const & xDocument, const Reference< beans::XPropertySet >& _xProps, ElementDescriptor& rModel ) -{ - Reference< lang::XMultiServiceFactory > xFac; - if ( xDocument.is() ) - xFac.set( xDocument, uno::UNO_QUERY ); - - Reference< form::binding::XBindableValue > xBinding( _xProps, UNO_QUERY ); - - if ( xFac.is() && xBinding.is() ) - { - try - { - Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellAddressConversion" )), uno::UNO_QUERY ); - Reference< beans::XPropertySet > xBindable( xBinding->getValueBinding(), UNO_QUERY ); - if ( xBindable.is() ) - { - table::CellAddress aAddress; - xBindable->getPropertyValue( OUSTR("BoundCell") ) >>= aAddress; - xConvertor->setPropertyValue( OUSTR("Address"), makeAny( aAddress ) ); - rtl::OUString sAddress; - xConvertor->getPropertyValue( OUSTR("PersistentRepresentation") ) >>= sAddress; - if ( sAddress.getLength() > 0 ) - rModel.addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":linked-cell"), sAddress ); - - OSL_TRACE( "*** Bindable value %s", rtl::OUStringToOString( sAddress, RTL_TEXTENCODING_UTF8 ).getStr() ); - - } - } - catch( uno::Exception& ) - { - } - } - Reference< form::binding::XListEntrySink > xEntrySink( _xProps, UNO_QUERY ); - if ( xEntrySink.is() ) - { - Reference< beans::XPropertySet > xListSource( xEntrySink->getListEntrySource(), UNO_QUERY ); - if ( xListSource.is() ) - { - try - { - Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellRangeAddressConversion" )), uno::UNO_QUERY ); - - table::CellRangeAddress aAddress; - xListSource->getPropertyValue( OUSTR( "CellRange" ) ) >>= aAddress; - - rtl::OUString sAddress; - xConvertor->setPropertyValue( OUSTR("Address"), makeAny( aAddress ) ); - xConvertor->getPropertyValue( OUSTR("PersistentRepresentation") ) >>= sAddress; - OSL_TRACE("**** cell range source list %s", - rtl::OUStringToOString( sAddress, RTL_TEXTENCODING_UTF8 ).getStr() ); - if ( sAddress.getLength() > 0 ) - rModel.addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":source-cell-range"), sAddress ); - } - catch( uno::Exception& ) - { - } - } - } - -} static inline bool readBorderProps( ElementDescriptor * element, Style & style ) { @@ -138,7 +77,9 @@ static inline bool readFontProps( ElementDescriptor * element, Style & style ) void ElementDescriptor::readMultiPageModel( StyleBag * all_styles ) { // collect styles - Style aStyle( 0x2 | 0x8 | 0x20 ); + Style aStyle( 0x1 | 0x2 | 0x8 | 0x20 ); + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor) + aStyle._set |= 0x1; if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor) aStyle._set |= 0x2; if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor) @@ -153,24 +94,101 @@ void ElementDescriptor::readMultiPageModel( StyleBag * all_styles ) // collect elements readDefaults(); - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ), + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiPageValue") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) ); - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-max") ) ); + Any aDecorationAny( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Decoration") ) ) ); + bool bDecoration = sal_True; + if ( (aDecorationAny >>= bDecoration) && !bDecoration ) + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":withtabs") ), OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) ); + + readEvents(); + uno::Reference< container::XNameContainer > xPagesContainer( _xProps, uno::UNO_QUERY ); + if ( xPagesContainer.is() && xPagesContainer->getElementNames().getLength() ) + { + ElementDescriptor * pElem = new ElementDescriptor( _xProps, _xPropState, OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") ), _xDocument ); + pElem->readBullitinBoard( all_styles ); + addSubElement( pElem ); + } +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readFrameModel( StyleBag * all_styles ) +{ + // collect styles + Style aStyle( 0x1 | 0x2 | 0x8 | 0x20 ); +/* + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor) + aStyle._set |= 0x1; +*/ + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor) + aStyle._set |= 0x2; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor) + aStyle._set |= 0x20; + if (readFontProps( this, aStyle )) + aStyle._set |= 0x8; + if (aStyle._set) + { + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), + all_styles->getStyleId( aStyle ) ); + } + // collect elements + readDefaults(); OUString aTitle; - if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ) ) >>= aTitle) + + if ( readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ) ) >>= aTitle) { ElementDescriptor * title = new ElementDescriptor( _xProps, _xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ) ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ), _xDocument ); title->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ), aTitle ); addSubElement( title ); } + uno::Reference< container::XNameContainer > xControlContainer( _xProps, uno::UNO_QUERY ); + if ( xControlContainer.is() && xControlContainer->getElementNames().getLength() ) + { + ElementDescriptor * pElem = new ElementDescriptor( _xProps, _xPropState, OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") ), _xDocument ); + pElem->readBullitinBoard( all_styles ); + addSubElement( pElem ); + } + readEvents(); +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readPageModel( StyleBag * all_styles ) +{ + // collect styles + Style aStyle( 0x1 | 0x2 | 0x8 | 0x20 ); + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor) + aStyle._set |= 0x1; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor) + aStyle._set |= 0x2; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor) + aStyle._set |= 0x20; + if (readFontProps( this, aStyle )) + aStyle._set |= 0x8; + if (aStyle._set) + { + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), + all_styles->getStyleId( aStyle ) ); + } + + // collect elements + readDefaults(); + rtl::OUString aTitle; + readStringAttr( + OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ) ); + uno::Reference< container::XNameContainer > xControlContainer( _xProps, uno::UNO_QUERY ); + if ( xControlContainer.is() && xControlContainer->getElementNames().getLength() ) + { + ElementDescriptor * pElem = new ElementDescriptor( _xProps, _xPropState, OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") ), _xDocument ); + pElem->readBullitinBoard( all_styles ); + addSubElement( pElem ); + } readEvents(); } + void ElementDescriptor::readButtonModel( StyleBag * all_styles ) SAL_THROW( (Exception) ) { @@ -204,8 +222,10 @@ void ElementDescriptor::readButtonModel( StyleBag * all_styles ) OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":valign") ) ); readButtonTypeAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PushButtonType") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button-type") ) ); - readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) ); + readImageURLAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) ); + + readImagePositionAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-position") ) ); readImageAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageAlign") ), @@ -275,8 +295,8 @@ void ElementDescriptor::readCheckBoxModel( StyleBag * all_styles ) OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) ); readVerticalAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":valign") ) ); - readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) ); + readImageURLAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) ); readImagePositionAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-position") ) ); readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ), @@ -312,7 +332,7 @@ void ElementDescriptor::readCheckBoxModel( StyleBag * all_styles ) readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readComboBoxModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument ) +void ElementDescriptor::readComboBoxModel( StyleBag * all_styles ) SAL_THROW( (Exception) ) { // collect styles @@ -354,7 +374,9 @@ void ElementDescriptor::readComboBoxModel( StyleBag * all_styles, Reference< fra readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linecount") ) ); // Cell Range, Ref Cell etc. - lclExportBindableAndListSourceBits( xDocument, _xProps, *this ); + readDataAwareAttr( OUSTR(XMLNS_DIALOGS_PREFIX ":linked-cell") ); + readDataAwareAttr( OUSTR( XMLNS_DIALOGS_PREFIX ":source-cell-range") ); + // string item list Sequence< OUString > itemValues; if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ) ) >>= itemValues) && @@ -362,14 +384,14 @@ void ElementDescriptor::readComboBoxModel( StyleBag * all_styles, Reference< fra { ElementDescriptor * popup = new ElementDescriptor( _xProps, _xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menupopup") ) ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menupopup") ), _xDocument ); OUString const * pItemValues = itemValues.getConstArray(); for ( sal_Int32 nPos = 0; nPos < itemValues.getLength(); ++nPos ) { ElementDescriptor * item = new ElementDescriptor( _xProps, _xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menuitem") ) ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menuitem") ), _xDocument ); item->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ), pItemValues[ nPos ] ); popup->addSubElement( item ); @@ -380,7 +402,7 @@ void ElementDescriptor::readComboBoxModel( StyleBag * all_styles, Reference< fra readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readListBoxModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument ) +void ElementDescriptor::readListBoxModel( StyleBag * all_styles ) SAL_THROW( (Exception) ) { // collect styles @@ -415,7 +437,8 @@ void ElementDescriptor::readListBoxModel( StyleBag * all_styles, Reference< fram OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linecount") ) ); readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) ); - lclExportBindableAndListSourceBits( xDocument, _xProps, *this ); + readDataAwareAttr( OUSTR(XMLNS_DIALOGS_PREFIX ":linked-cell") ); + readDataAwareAttr( OUSTR( XMLNS_DIALOGS_PREFIX ":source-cell-range") ); // string item list Sequence< OUString > itemValues; if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ) ) >>= itemValues) && @@ -423,7 +446,7 @@ void ElementDescriptor::readListBoxModel( StyleBag * all_styles, Reference< fram { ElementDescriptor * popup = new ElementDescriptor( _xProps, _xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menupopup") ) ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menupopup") ), _xDocument ); OUString const * pItemValues = itemValues.getConstArray(); sal_Int32 nPos; @@ -431,7 +454,7 @@ void ElementDescriptor::readListBoxModel( StyleBag * all_styles, Reference< fram { ElementDescriptor * item = new ElementDescriptor( _xProps, _xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menuitem") ) ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menuitem") ), _xDocument ); item->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ), pItemValues[ nPos ] ); popup->addSubElement( item ); @@ -455,7 +478,7 @@ void ElementDescriptor::readListBoxModel( StyleBag * all_styles, Reference< fram readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument ) +void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles ) SAL_THROW( (Exception) ) { // collect styles @@ -486,8 +509,8 @@ void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles, Reference< OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) ); readVerticalAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":valign") ) ); - readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) ); + readImageURLAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) ); readImagePositionAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-position") ) ); readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ), @@ -513,7 +536,7 @@ void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles, Reference< break; } } - lclExportBindableAndListSourceBits( xDocument, _xProps, *this ); + readDataAwareAttr( OUSTR(XMLNS_DIALOGS_PREFIX ":linked-cell") ); readEvents(); } //__________________________________________________________________________________________________ @@ -542,7 +565,7 @@ void ElementDescriptor::readGroupBoxModel( StyleBag * all_styles ) { ElementDescriptor * title = new ElementDescriptor( _xProps, _xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ) ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ), _xDocument ); title->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ), aTitle ); addSubElement( title ); @@ -683,10 +706,11 @@ void ElementDescriptor::readEditModel( StyleBag * all_styles ) addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":echochar") ), OUString( &cEcho, 1 ) ); } + readDataAwareAttr( OUSTR(XMLNS_DIALOGS_PREFIX ":linked-cell") ); readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readImageControlModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) +void ElementDescriptor::readImageControlModel( StyleBag * all_styles ) SAL_THROW( (Exception) ) { // collect styles @@ -705,33 +729,10 @@ void ElementDescriptor::readImageControlModel( StyleBag * all_styles, com::sun:: readDefaults(); readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleImage") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scale-image") ) ); - rtl::OUString sURL; - _xProps->getPropertyValue( OUSTR("ImageURL") ) >>= sURL; - - if ( sURL.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) ) ) == 0 ) - { - Reference< document::XStorageBasedDocument > xDocStorage( xDocument, UNO_QUERY ); - - if ( xDocStorage.is() ) - { - uno::Sequence< Any > aArgs( 1 ); - aArgs[ 0 ] <<= xDocStorage->getDocumentStorage(); - - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - uno::Reference< document::XGraphicObjectResolver > xGraphicResolver; - aContext.createComponentWithArguments( OUSTR( "com.sun.star.comp.Svx.GraphicExportHelper" ), aArgs, xGraphicResolver ); - if ( xGraphicResolver.is() ) - { - sURL = xGraphicResolver->resolveGraphicObjectURL( sURL ); - } - } - } - if ( sURL.getLength() > 0 ) - { - addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":src"), sURL ); - } readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) ); + readImageURLAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":src") ) ); readEvents(); } //__________________________________________________________________________________________________ @@ -1151,6 +1152,45 @@ void ElementDescriptor::readFormattedFieldModel( StyleBag * all_styles ) readEvents(); } + +void ElementDescriptor::readSpinButtonModel( StyleBag * all_styles ) + SAL_THROW( (Exception) ) +{ + // collect styles + Style aStyle( 0x1 | 0x4 ); + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor) + aStyle._set |= 0x1; + if (readBorderProps( this, aStyle )) + aStyle._set |= 0x4; + if (aStyle._set) + { + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), + all_styles->getStyleId( aStyle ) ); + } + + // collect elements + readDefaults(); + readOrientationAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinIncrement") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":increment") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValue") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":curval") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValueMax") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":maxval") ) ); + readLongAttr( OUSTR("SpinValueMin"), + OUSTR(XMLNS_DIALOGS_PREFIX ":minval") ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Repeat") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":repeat") ) ); + readLongAttr( OUSTR("RepeatDelay"), OUSTR(XMLNS_DIALOGS_PREFIX ":repeat-delay") ); + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) ); + readHexLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SymbolColor") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":symbol-color") ) ); + readDataAwareAttr( OUSTR(XMLNS_DIALOGS_PREFIX ":linked-cell") ); + readEvents(); +} + //__________________________________________________________________________________________________ void ElementDescriptor::readFixedLineModel( StyleBag * all_styles ) SAL_THROW( (Exception) ) @@ -1206,7 +1246,7 @@ void ElementDescriptor::readProgressBarModel( StyleBag * all_styles ) readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readScrollBarModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument ) +void ElementDescriptor::readScrollBarModel( StyleBag * all_styles ) SAL_THROW( (Exception) ) { // collect styles @@ -1244,47 +1284,7 @@ void ElementDescriptor::readScrollBarModel( StyleBag * all_styles, Reference< fr OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":live-scroll") ) ); readHexLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SymbolColor") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":symbol-color") ) ); - // Cell Range, Ref Cell etc. - lclExportBindableAndListSourceBits( xDocument, _xProps, *this ); - readEvents(); -} -//__________________________________________________________________________________________________ -void ElementDescriptor::readSpinButtonModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument ) - SAL_THROW( (Exception) ) -{ - // collect styles - Style aStyle( 0x1 | 0x4 ); - if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor) - aStyle._set |= 0x1; - if (readBorderProps( this, aStyle )) - aStyle._set |= 0x4; - if (aStyle._set) - { - addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), - all_styles->getStyleId( aStyle ) ); - } - - // collect elements - readDefaults(); - readOrientationAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) ); - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinIncrement") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":increment") ) ); - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValue") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":curval") ) ); - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValueMax") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":maxval") ) ); - readLongAttr( OUSTR("SpinValueMin"), - OUSTR(XMLNS_DIALOGS_PREFIX ":minval") ); - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Repeat") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":repeat") ) ); - readLongAttr( OUSTR("RepeatDelay"), OUSTR(XMLNS_DIALOGS_PREFIX ":repeat-delay") ); - readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) ); - readHexLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SymbolColor") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":symbol-color") ) ); - // Cell Range, Ref Cell etc. - lclExportBindableAndListSourceBits( xDocument, _xProps, *this ); + readDataAwareAttr( OUSTR(XMLNS_DIALOGS_PREFIX ":linked-cell") ); readEvents(); } //__________________________________________________________________________________________________ @@ -1340,6 +1340,251 @@ void ElementDescriptor::readDialogModel( StyleBag * all_styles ) readEvents(); } +void ElementDescriptor::readBullitinBoard( StyleBag * all_styles ) + SAL_THROW( (Exception) ) +{ + // collect elements + ::std::vector< ElementDescriptor* > all_elements; + // read out all props + Reference< container::XNameContainer > xDialogModel( _xProps, UNO_QUERY ); + if ( !xDialogModel.is() ) + return; // #TODO throw??? + Sequence< OUString > aElements( xDialogModel->getElementNames() ); + OUString const * pElements = aElements.getConstArray(); + + ElementDescriptor * pRadioGroup = 0; + + sal_Int32 nPos; + for ( nPos = 0; nPos < aElements.getLength(); ++nPos ) + { + Any aControlModel( xDialogModel->getByName( pElements[ nPos ] ) ); + Reference< beans::XPropertySet > xProps; + OSL_VERIFY( aControlModel >>= xProps ); + if (! xProps.is()) + continue; + Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); + OSL_ENSURE( xPropState.is(), "no XPropertyState!" ); + if (! xPropState.is()) + continue; + Reference< lang::XServiceInfo > xServiceInfo( xProps, UNO_QUERY ); + OSL_ENSURE( xServiceInfo.is(), "no XServiceInfo!" ); + if (! xServiceInfo.is()) + continue; + + ElementDescriptor * pElem = 0; + + // group up radio buttons + if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) ) + { + if (! pRadioGroup) // open radiogroup + { + pRadioGroup = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radiogroup") ), _xDocument ); + all_elements.push_back( pRadioGroup ); + } + + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radio") ), _xDocument ); + pElem->readRadioButtonModel( all_styles ); + pRadioGroup->addSubElement( pElem ); + } + else // no radio + { + pRadioGroup = 0; // close radiogroup + + if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button") ), _xDocument ); + pElem->readButtonModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checkbox") ), _xDocument ); + pElem->readCheckBoxModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ), _xDocument ); + pElem->readComboBoxModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ), _xDocument ); + pElem->readListBoxModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":titledbox") ), _xDocument ); + pElem->readGroupBoxModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multipage") ), _xDocument ); + pElem->readMultiPageModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoFrameModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":frame") ), _xDocument ); + pElem->readFrameModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoPageModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":page") ), _xDocument ); + pElem->readPageModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ), _xDocument ); + pElem->readFixedTextModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textfield") ), _xDocument ); + pElem->readEditModel( all_styles ); + } + // FixedHyperLink + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedHyperlinkModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linklabel") ), _xDocument ); + pElem->readFixedHyperLinkModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":img") ), _xDocument ); + pElem->readImageControlModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":filecontrol") ), _xDocument ); + pElem->readFileControlModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.TreeControlModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":treecontrol") ), _xDocument ); + pElem->readTreeControlModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCurrencyFieldModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":currencyfield") ), _xDocument ); + pElem->readCurrencyFieldModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":datefield") ), _xDocument ); + pElem->readDateFieldModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":numericfield") ), _xDocument ); + pElem->readNumericFieldModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":timefield") ) , _xDocument); + pElem->readTimeFieldModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":patternfield") ), _xDocument ); + pElem->readPatternFieldModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":formattedfield") ), _xDocument ); + pElem->readFormattedFieldModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fixedline") ), _xDocument ); + pElem->readFixedLineModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scrollbar") ), _xDocument ); + pElem->readScrollBarModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spinbutton") ), _xDocument ); + pElem->readSpinButtonModel( all_styles ); + } + else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) ) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":progressmeter") ), _xDocument ); + pElem->readProgressBarModel( all_styles ); + } + // + + if (pElem) + { + all_elements.push_back( pElem ); + } + else + { + OSL_ENSURE( sal_False, "unknown control type!" ); + continue; + } + } + } + if (! all_elements.empty()) + { + for ( std::size_t n = 0; n < all_elements.size(); ++n ) + { + addSubElement( all_elements[ n ] ); + } + } +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx index cec44ca50a04..4ae2ebdabc11 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -47,6 +47,8 @@ #include #include +#include + #include #include @@ -58,6 +60,17 @@ #include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -777,6 +790,33 @@ void ElementDescriptor::readVerticalAlignAttr( OUString const & rPropName, OUStr } } //__________________________________________________________________________________________________ +void ElementDescriptor::readImageURLAttr( OUString const & rPropName, OUString const & rAttrName ) +{ + if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) + { + rtl::OUString sURL; + _xProps->getPropertyValue( rPropName ) >>= sURL; + + if ( sURL.getLength() && sURL.compareToAscii( XMLSCRIPT_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( XMLSCRIPT_GRAPHOBJ_URLPREFIX ) ) == 0 ) + { + Reference< document::XStorageBasedDocument > xDocStorage( _xDocument, UNO_QUERY ); + if ( xDocStorage.is() ) + { + uno::Sequence< Any > aArgs( 1 ); + aArgs[ 0 ] <<= xDocStorage->getDocumentStorage(); + + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + uno::Reference< document::XGraphicObjectResolver > xGraphicResolver; + aContext.createComponentWithArguments( OUSTR( "com.sun.star.comp.Svx.GraphicExportHelper" ), aArgs, xGraphicResolver ); + if ( xGraphicResolver.is() ) + sURL = xGraphicResolver->resolveGraphicObjectURL( sURL ); + } + } + if ( sURL.getLength() ) + addAttribute( rAttrName, sURL ); + } +} +//__________________________________________________________________________________________________ void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString const & rAttrName ) { if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) @@ -940,6 +980,66 @@ void ElementDescriptor::readLineEndFormatAttr( OUString const & rPropName, OUStr } } //__________________________________________________________________________________________________ +void ElementDescriptor::readDataAwareAttr( OUString const & rAttrName ) +{ + Reference< lang::XMultiServiceFactory > xFac; + if ( _xDocument.is() ) + xFac.set( _xDocument, uno::UNO_QUERY ); + + Reference< form::binding::XBindableValue > xBinding( _xProps, UNO_QUERY ); + + if ( xFac.is() && xBinding.is() && rAttrName.equals( OUSTR(XMLNS_DIALOGS_PREFIX ":linked-cell") ) ) + { + try + { + Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellAddressConversion" )), uno::UNO_QUERY ); + Reference< beans::XPropertySet > xBindable( xBinding->getValueBinding(), UNO_QUERY ); + if ( xBindable.is() ) + { + table::CellAddress aAddress; + xBindable->getPropertyValue( OUSTR("BoundCell") ) >>= aAddress; + xConvertor->setPropertyValue( OUSTR("Address"), makeAny( aAddress ) ); + rtl::OUString sAddress; + xConvertor->getPropertyValue( OUSTR("PersistentRepresentation") ) >>= sAddress; + if ( sAddress.getLength() > 0 ) + addAttribute( rAttrName, sAddress ); + + OSL_TRACE( "*** Bindable value %s", rtl::OUStringToOString( sAddress, RTL_TEXTENCODING_UTF8 ).getStr() ); + + } + } + catch( uno::Exception& ) + { + } + } + Reference< form::binding::XListEntrySink > xEntrySink( _xProps, UNO_QUERY ); + if ( xEntrySink.is() && rAttrName.equals( OUSTR( XMLNS_DIALOGS_PREFIX ":source-cell-range") ) ) + { + Reference< beans::XPropertySet > xListSource( xEntrySink->getListEntrySource(), UNO_QUERY ); + if ( xListSource.is() ) + { + try + { + Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellRangeAddressConversion" )), uno::UNO_QUERY ); + + table::CellRangeAddress aAddress; + xListSource->getPropertyValue( OUSTR( "CellRange" ) ) >>= aAddress; + + rtl::OUString sAddress; + xConvertor->setPropertyValue( OUSTR("Address"), makeAny( aAddress ) ); + xConvertor->getPropertyValue( OUSTR("PersistentRepresentation") ) >>= sAddress; + OSL_TRACE("**** cell range source list %s", + rtl::OUStringToOString( sAddress, RTL_TEXTENCODING_UTF8 ).getStr() ); + if ( sAddress.getLength() > 0 ) + addAttribute( rAttrName, sAddress ); + } + catch( uno::Exception& ) + { + } + } + } +} +//__________________________________________________________________________________________________ void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUString const & rAttrName ) { if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) @@ -976,6 +1076,28 @@ void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUStr void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible ) { Any a( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) ); + + // The following is a hack to allow 'form' controls to override the default + // control supported by dialogs. This should work well for both vba support and + // normal openoffice ( when normal 'Dialogs' decide to support form control models ) + // In the future VBA support might require custom models ( and not the just the form + // variant of a control that we currently use ) In this case the door is still open, + // we just need to define a new way for the 'ServiceName' to be extracted from the + // incomming model. E.g. the use of supporting service + // "com.sun.star.form.FormComponent", 'ServiceName' and XPersistObject + // is only an implementation detail here, in the future some other + // method ( perhaps a custom prop ) could be used instead. + Reference< lang::XServiceInfo > xSrvInfo( _xProps, UNO_QUERY ); + if ( xSrvInfo.is() && xSrvInfo->supportsService( OUSTR("com.sun.star.form.FormComponent" ) ) ) + { + Reference< io::XPersistObject > xPersist( _xProps, UNO_QUERY ); + if ( xPersist.is() ) + { + OUString sCtrlName = xPersist->getServiceName(); + if ( sCtrlName.getLength() ) + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":control-implementation") ), sCtrlName ); + } + } addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), * reinterpret_cast< const OUString * >( a.getValue() ) ); readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ), @@ -1331,248 +1453,17 @@ void SAL_CALL exportDialogModel( SAL_THROW( (Exception) ) { StyleBag all_styles; - ::std::vector< Reference< xml::sax::XAttributeList > > all_elements; - - // read out all props - - Sequence< OUString > aElements( xDialogModel->getElementNames() ); - OUString const * pElements = aElements.getConstArray(); - - ElementDescriptor * pRadioGroup = 0; - - sal_Int32 nPos; - for ( nPos = 0; nPos < aElements.getLength(); ++nPos ) - { - Any aControlModel( xDialogModel->getByName( pElements[ nPos ] ) ); - Reference< beans::XPropertySet > xProps; - OSL_VERIFY( aControlModel >>= xProps ); - if (! xProps.is()) - continue; - Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); - OSL_ENSURE( xPropState.is(), "no XPropertyState!" ); - if (! xPropState.is()) - continue; - Reference< lang::XServiceInfo > xServiceInfo( xProps, UNO_QUERY ); - OSL_ENSURE( xServiceInfo.is(), "no XServiceInfo!" ); - if (! xServiceInfo.is()) - continue; - - ElementDescriptor * pElem = 0; - Reference< xml::sax::XAttributeList > xElem; - - // group up radio buttons - if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) ) - { - if (! pRadioGroup) // open radiogroup - { - pRadioGroup = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radiogroup") ) ); - all_elements.push_back( pRadioGroup ); - } - - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radio") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readRadioButtonModel( &all_styles, xDocument ); - pRadioGroup->addSubElement( xElem ); - } - else // no radio - { - pRadioGroup = 0; // close radiogroup + // window + Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY ); + OSL_ASSERT( xProps.is() ); + Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); + OSL_ASSERT( xPropState.is() ); - if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readButtonModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checkbox") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readCheckBoxModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readComboBoxModel( &all_styles, xDocument ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readListBoxModel( &all_styles, xDocument ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":titledbox") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readGroupBoxModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multipage") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readMultiPageModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readFixedTextModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textfield") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readEditModel( &all_styles ); - } - // FixedHyperLink - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedHyperlinkModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linklabel") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readFixedHyperLinkModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":img") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readImageControlModel( &all_styles, xDocument ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":filecontrol") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readFileControlModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.TreeControlModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":treecontrol") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readTreeControlModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCurrencyFieldModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":currencyfield") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readCurrencyFieldModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":datefield") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readDateFieldModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":numericfield") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readNumericFieldModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") ) ) ) - { - pElem = new ElementDescriptor( + ElementDescriptor * pElem = new ElementDescriptor( xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":timefield") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readTimeFieldModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":patternfield") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readPatternFieldModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":formattedfield") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readFormattedFieldModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fixedline") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readFixedLineModel( &all_styles ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scrollbar") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readScrollBarModel( &all_styles, xDocument ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spinbutton") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readSpinButtonModel( &all_styles, xDocument ); - } - else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) ) - { - pElem = new ElementDescriptor( - xProps, xPropState, - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":progressmeter") ) ); - xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readProgressBarModel( &all_styles ); - } - // - - OSL_ASSERT( xElem.is() ); - if (xElem.is()) - { - all_elements.push_back( xElem ); - } - else - { - OSL_ENSURE( sal_False, "unknown control type!" ); - continue; - } - } - } + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") ), xDocument ); + Reference< xml::sax::XAttributeList > xElem( pElem ); + pElem->readBullitinBoard( &all_styles ); xOut->startDocument(); @@ -1582,14 +1473,9 @@ void SAL_CALL exportDialogModel( xOut->unknown( aDocTypeStr ); xOut->ignorableWhitespace( OUString() ); - // window - Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY ); - OSL_ASSERT( xProps.is() ); - Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); - OSL_ASSERT( xPropState.is() ); OUString aWindowName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":window") ); - ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName ); + ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName, xDocument ); Reference< xml::sax::XAttributeList > xWindow( pWindow ); pWindow->readDialogModel( &all_styles ); xOut->ignorableWhitespace( OUString() ); @@ -1599,20 +1485,14 @@ void SAL_CALL exportDialogModel( // dump out stylebag all_styles.dump( xOut ); - if (! all_elements.empty()) + if ( xDialogModel->getElementNames().getLength() ) { // open up bulletinboard OUString aBBoardName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") ); xOut->ignorableWhitespace( OUString() ); - xOut->startElement( aBBoardName, Reference< xml::sax::XAttributeList >() ); - - // export control elements - for ( std::size_t n = 0; n < all_elements.size(); ++n ) - { - ElementDescriptor * pElem = static_cast< ElementDescriptor * >( all_elements[ n ].get() ); - pElem->dump( xOut.get() ); - } + xOut->startElement( aBBoardName, xElem ); + pElem->dumpSubElements( xOut.get() ); // end bulletinboard xOut->ignorableWhitespace( OUString() ); xOut->endElement( aBBoardName ); diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx index 901aeac8127a..4baa8f2a9710 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx @@ -49,30 +49,102 @@ using ::rtl::OUString; namespace xmlscript { -Reference< xml::input::XElement > MultiPage::startChildElement( + +Reference< xml::input::XElement > Frame::startChildElement( sal_Int32 nUid, OUString const & rLocalName, Reference< xml::input::XAttributes > const & xAttributes ) - throw (xml::sax::SAXException, RuntimeException) + throw (xml::sax::SAXException, RuntimeException) { + if ( !m_xContainer.is() ) + m_xContainer.set( _pImport->_xDialogModelFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoFrameModel") ) ), UNO_QUERY ); // event -rtl::OUString _label = rtl::OUString::createFromAscii("foo"); if (_pImport->isEventElement( nUid, rLocalName )) { - return new EventElement( + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") )) + { + // Create new DialogImport for this container + DialogImport* pFrameImport = new DialogImport( *_pImport ); + pFrameImport->_xDialogModel = m_xContainer; + return new BulletinBoardElement( rLocalName, xAttributes, this, pFrameImport ); + } else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("title") )) { getStringAttr( &_label, - OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), - xAttributes, - _pImport->XMLNS_DIALOGS_UID ); + OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), + xAttributes, + _pImport->XMLNS_DIALOGS_UID ); return new ElementBase( _pImport->XMLNS_DIALOGS_UID, rLocalName, xAttributes, this, _pImport ); } else + { + OSL_TRACE("****** ARGGGGG!!!! **********"); + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ + +void Frame::endElement() + throw (xml::sax::SAXException, RuntimeException) +{ + if ( !m_xContainer.is() ) + m_xContainer.set( _pImport->_xDialogModelFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoFrameModel") ) ), UNO_QUERY ); + Reference< beans::XPropertySet > xProps( m_xContainer, UNO_QUERY_THROW ); + // _pImport is what we need to add to ( e.g. the dialog in this case ) + ControlImportContext ctx( _pImport, xProps, getControlId( _xAttributes ) ); + + Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); + + Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); + if (xStyle.is()) + { + StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () ); + pStyle->importTextColorStyle( xControlModel ); + pStyle->importTextLineColorStyle( xControlModel ); + pStyle->importFontStyle( xControlModel ); + } + + ctx.importDefaults( 0, 0, _xAttributes ); // inherited from BulletinBoardElement + if (_label.getLength()) + { + xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ), + makeAny( _label ) ); + } + ctx.importEvents( _events ); + // avoid ring-reference: + // vector< event elements > holding event elements holding this (via _pParent) + _events.clear(); +} + +//=== +Reference< xml::input::XElement > MultiPage::startChildElement( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::input::XAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + // event +rtl::OUString _label = rtl::OUString::createFromAscii("foo"); + if (_pImport->isEventElement( nUid, rLocalName )) + { + return new EventElement( + nUid, rLocalName, xAttributes, this, _pImport ); + } + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") )) + { + // Create new DialogImport for this container + + DialogImport* pMultiPageImport = new DialogImport( *_pImport ); + pMultiPageImport->_xDialogModel = m_xContainer; + return new BulletinBoardElement( rLocalName, xAttributes, this, pMultiPageImport ); + } + else { throw xml::sax::SAXException( @@ -85,10 +157,10 @@ rtl::OUString _label = rtl::OUString::createFromAscii("foo"); void MultiPage::endElement() throw (xml::sax::SAXException, RuntimeException) { - ControlImportContext ctx( - _pImport, getControlId( _xAttributes ), - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ); -// OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ); + Reference< beans::XPropertySet > xProps( m_xContainer, UNO_QUERY_THROW ); + // _pImport is what we need to add to ( e.g. the dialog in this case ) + ControlImportContext ctx( _pImport, xProps, getControlId( _xAttributes )); + Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); @@ -98,125 +170,76 @@ void MultiPage::endElement() pStyle->importTextColorStyle( xControlModel ); pStyle->importTextLineColorStyle( xControlModel ); pStyle->importFontStyle( xControlModel ); + pStyle->importBackgroundColorStyle( xControlModel ); } ctx.importDefaults( 0, 0, _xAttributes ); // inherited from BulletinBoardElement - ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ), + ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiPageValue") ), OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), _xAttributes ); - ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("value-max") ), - _xAttributes ); + ctx.importBooleanProperty( + OUString( RTL_CONSTASCII_USTRINGPARAM("Decoration") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("withtabs") ), + _xAttributes ); ctx.importEvents( _events ); // avoid ring-reference: // vector< event elements > holding event elements holding this (via _pParent) _events.clear(); } -// #FIXME cut'n'pasted from xmloff/source/core/xmlimp.cxx:1251 -// of course we need to find a common home for this helper - -bool IsPackageURL( const ::rtl::OUString& rURL ) +Reference< xml::input::XElement > Page::startChildElement( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::input::XAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) { - // Some quick tests: Some may rely on the package structure! - sal_Int32 nLen = rURL.getLength(); - if( (nLen > 0 && '/' == rURL[0]) ) - // RFC2396 net_path or abs_path - return false; - else if( nLen > 1 && '.' == rURL[0] ) - { - if( '.' == rURL[1] ) - // ../: We are never going up one level, so we know - // it's not an external URI - return false; - else if( '/' == rURL[1] ) - // we are remaining on a level, so it's an package URI - return true; - } - - // Now check for a RFC2396 schema - sal_Int32 nPos = 1; - while( nPos < nLen ) - { - switch( rURL[nPos] ) - { - case '/': - // a relative path segement - return true; - case ':': - // a schema - return false; - default: - break; - // we don't care about any other characters - } - ++nPos; + // event + if (_pImport->isEventElement( nUid, rLocalName )) + { + return new EventElement( + nUid, rLocalName, xAttributes, this, _pImport ); + } + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") )) + { + + DialogImport* pPageImport = new DialogImport( *_pImport ); + pPageImport->_xDialogModel = m_xContainer; + return new BulletinBoardElement( rLocalName, xAttributes, this, pPageImport ); } + else + { - return true; + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + Reference< XInterface >(), Any() ); + } } +//__________________________________________________________________________________________________ -void importBindableAndListRangeBits( DialogImport* _pImport, const rtl::OUString sLinkedCell, const rtl::OUString & sCellRange, ControlImportContext& ctx ) +void Page::endElement() + throw (xml::sax::SAXException, RuntimeException) { - Reference< lang::XMultiServiceFactory > xFac( _pImport->getDocOwner(), UNO_QUERY ); - if ( xFac.is() && ( sLinkedCell.getLength() || sCellRange.getLength() ) ) - { - // Set up Celllink - if ( sLinkedCell.getLength() ) - { - Reference< form::binding::XBindableValue > xBindable( ctx.getControlModel(), uno::UNO_QUERY ); - Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellAddressConversion" )), uno::UNO_QUERY ); - if ( xBindable.is() && xConvertor.is() ) - { - table::CellAddress aAddress; - xConvertor->setPropertyValue( OUSTR( "PersistentRepresentation" ), uno::makeAny( sLinkedCell ) ); - xConvertor->getPropertyValue( OUSTR( "Address" ) ) >>= aAddress; - beans::NamedValue aArg1; - aArg1.Name = OUSTR("BoundCell"); - aArg1.Value <<= aAddress; - - uno::Sequence< uno::Any > aArgs(1); - aArgs[ 0 ] <<= aArg1; + Reference< beans::XPropertySet > xProps( m_xContainer, UNO_QUERY_THROW ); - uno::Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments( OUSTR("com.sun.star.table.CellValueBinding" ), aArgs ), uno::UNO_QUERY ); - xBindable->setValueBinding( xBinding ); + ControlImportContext ctx( _pImport, xProps, getControlId( _xAttributes )); - } - } - // Set up CelllRange - if ( sCellRange.getLength() ) - { - Reference< form::binding::XListEntrySink > xListEntrySink( ctx.getControlModel(), uno::UNO_QUERY ); - Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellRangeAddressConversion" )), uno::UNO_QUERY ); - if ( xListEntrySink.is() && xConvertor.is() ) - { - table::CellRangeAddress aAddress; - xConvertor->setPropertyValue( OUSTR( "PersistentRepresentation" ), uno::makeAny( sCellRange ) ); - xConvertor->getPropertyValue( OUSTR( "Address" ) ) >>= aAddress; - beans::NamedValue aArg1; - aArg1.Name = OUSTR("CellRange"); - aArg1.Value <<= aAddress; - - uno::Sequence< uno::Any > aArgs(1); - aArgs[ 0 ] <<= aArg1; - - uno::Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments( OUSTR("com.sun.star.table.CellRangeListSource" ), aArgs ), uno::UNO_QUERY ); - xListEntrySink->setListEntrySource( xSource ); - - } - } - } -} + Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); -sal_Bool isVBACompatibilityMode( DialogImport* _pImport ) -{ - sal_Bool bVBAMode = sal_False; - Reference< script::vba::XVBACompatibility > xVBACompat( _pImport->getScriptLibraryContainer(), UNO_QUERY ); - if( xVBACompat.is() ) + Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); + if (xStyle.is()) { - bVBAMode = xVBACompat->getVBACompatibilityMode(); + StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () ); + pStyle->importTextColorStyle( xControlModel ); + pStyle->importTextLineColorStyle( xControlModel ); + pStyle->importFontStyle( xControlModel ); + pStyle->importBackgroundColorStyle( xControlModel ); } - return bVBAMode; + + ctx.importDefaults( 0, 0, _xAttributes ); // inherited from BulletinBoardElement + ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), OUString( RTL_CONSTASCII_USTRINGPARAM("title") ), _xAttributes ); + ctx.importEvents( _events ); + // avoid ring-reference: + // vector< event elements > holding event elements holding this (via _pParent) + _events.clear(); } // progessmeter @@ -298,23 +321,9 @@ Reference< xml::input::XElement > ScrollBarElement::startChildElement( void ScrollBarElement::endElement() throw (xml::sax::SAXException, RuntimeException) { - OUString sService( OUSTR("com.sun.star.awt.UnoControlScrollBarModel") ); - // we should probably limit this to vba mode also ( leave for now ) - if ( isVBACompatibilityMode( _pImport ) ) - sService = OUSTR("com.sun.star.form.component.ScrollBar"); - - OUString sLinkedCell; - try - { - sLinkedCell = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) ); - } - catch( Exception& /*e*/ ) - { - } - ControlImportContext ctx( _pImport, getControlId( _xAttributes ), - sService ); + getControlModelName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ), _xAttributes ) ); Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); if (xStyle.is()) @@ -358,10 +367,7 @@ void ScrollBarElement::endElement() OUString( RTL_CONSTASCII_USTRINGPARAM("symbol-color") ), _xAttributes ); - // import cell-link - OUString sCellRange; - importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx ); - + ctx.importDataAwareProperty( OUSTR("linked-cell" ), _xAttributes ); ctx.importEvents( _events ); // avoid ring-reference: // vector< event elements > holding event elements holding this (via _pParent) @@ -393,18 +399,9 @@ Reference< xml::input::XElement > SpinButtonElement::startChildElement( void SpinButtonElement::endElement() throw (xml::sax::SAXException, RuntimeException) { - OUString sLinkedCell; - try - { - sLinkedCell = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) ); - } - catch( Exception& /*e*/ ) - { - } - ControlImportContext ctx( - _pImport, getControlId( _xAttributes ), - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.SpinButton") ) ); + _pImport, getControlId( _xAttributes ), + getControlModelName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ), _xAttributes ) ); Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); if (xStyle.is()) @@ -417,33 +414,25 @@ void SpinButtonElement::endElement() ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes ); ctx.importOrientationProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("align") ), - _xAttributes ); + OUString( RTL_CONSTASCII_USTRINGPARAM("align") ), + _xAttributes ); ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinIncrement") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("increment") ), - _xAttributes ); + OUString( RTL_CONSTASCII_USTRINGPARAM("increment") ), + _xAttributes ); ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValue") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("curval") ), - _xAttributes ); + OUString( RTL_CONSTASCII_USTRINGPARAM("curval") ),_xAttributes ); ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValueMax") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("maxval") ), - _xAttributes ); + OUString( RTL_CONSTASCII_USTRINGPARAM("maxval") ), _xAttributes ); ctx.importLongProperty( OUSTR("SpinValueMin"), OUSTR("minval"), - _xAttributes ); - ctx.importLongProperty( OUSTR("Repeat"), OUSTR("repeat"), - _xAttributes ); + _xAttributes ); + ctx.importLongProperty( OUSTR("Repeat"), OUSTR("repeat"), _xAttributes ); ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat-delay"), - _xAttributes ); +_xAttributes ); ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ), - _xAttributes ); + OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ), _xAttributes ); ctx.importHexLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SymbolColor") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("symbol-color") ), - _xAttributes ); - // import cell-link - OUString sCellRange; - importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx ); - + OUString( RTL_CONSTASCII_USTRINGPARAM("symbol-color") ), _xAttributes ); + ctx.importDataAwareProperty( OUSTR("linked-cell" ), _xAttributes ); ctx.importEvents( _events ); // avoid ring-reference: // vector< event elements > holding event elements holding this (via _pParent) @@ -746,6 +735,7 @@ void FormattedFieldElement::endElement() OUString( RTL_CONSTASCII_USTRINGPARAM("enforce-format") ), _xAttributes ); + ctx.importDataAwareProperty( OUSTR("linked-cell" ), _xAttributes ); ctx.importEvents( _events ); // avoid ring-reference: // vector< event elements > holding event elements holding this (via _pParent) @@ -1285,34 +1275,7 @@ void ImageControlElement::endElement() rtl::OUString sURL = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "src" ) ); Reference< document::XStorageBasedDocument > xDocStorage( _pImport->getDocOwner(), UNO_QUERY ); - if ( xDocStorage.is() && IsPackageURL( sURL ) ) - { - uno::Sequence< Any > aArgs( 1 ); - aArgs[ 0 ] <<= xDocStorage->getDocumentStorage(); - - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - uno::Reference< document::XGraphicObjectResolver > xGraphicResolver; - aContext.createComponentWithArguments( OUSTR( "com.sun.star.comp.Svx.GraphicImportHelper" ), aArgs, xGraphicResolver ); - - if ( xGraphicResolver.is() ) - { - rtl::OUString aTmp( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) ); - aTmp += sURL; - sURL = xGraphicResolver->resolveGraphicObjectURL( aTmp ); - Reference< beans::XPropertySet > xProps( ctx.getControlModel(), UNO_QUERY ); - // we must set the url while the graphic object ( held by the resolver is in scope ) - if ( xProps.is() ) - xProps->setPropertyValue( OUSTR("ImageURL"), makeAny( sURL ) ); - } - } - - else if ( sURL.getLength() > 0 ) - { - Reference< beans::XPropertySet > xProps( ctx.getControlModel(), UNO_QUERY ); - if ( xProps.is() ) - xProps->setPropertyValue( OUSTR("ImageURL"), makeAny( sURL ) ); - } - + ctx.importImageURLProperty( OUSTR( "ImageURL" ), OUSTR( "src" ), _xAttributes ); ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ), _xAttributes ); @@ -1645,24 +1608,10 @@ void TitledBoxElement::endElement() Reference< xml::input::XElement > xRadio( _radios[ nPos ] ); Reference< xml::input::XAttributes > xAttributes( xRadio->getAttributes() ); - OUString sLinkedCell; - OUString sCellRange; - OUString sService( OUSTR("com.sun.star.awt.UnoControlRadioButtonModel") ); - try - { - sLinkedCell = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) ); - // we should probably limit this to vba mode also ( leave for now ) - if ( isVBACompatibilityMode( _pImport ) ) - sService = OUSTR("com.sun.star.form.component.RadioButton"); - } - catch( Exception& /*e*/ ) - { - } - ControlImportContext ctx( _pImport, getControlId( xAttributes ), - sService ); + getControlModelName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ), xAttributes ) ); Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); Reference< xml::input::XElement > xStyle( getStyle( xAttributes ) ); @@ -1689,9 +1638,7 @@ void TitledBoxElement::endElement() ctx.importVerticalAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ), OUString( RTL_CONSTASCII_USTRINGPARAM("valign") ), xAttributes ); - ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ), - xAttributes ); + ctx.importImageURLProperty( OUSTR( "ImageURL" ), OUSTR( "image-src" ), _xAttributes ); ctx.importImagePositionProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ), OUString( RTL_CONSTASCII_USTRINGPARAM("image-position") ), xAttributes ); @@ -1714,7 +1661,7 @@ void TitledBoxElement::endElement() } xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ), makeAny( nVal ) ); - importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx ); + ctx.importDataAwareProperty( OUSTR("linked-cell" ), xAttributes ); ::std::vector< Reference< xml::input::XElement > > * radioEvents = static_cast< RadioElement * >( xRadio.get() )->getEvents(); ctx.importEvents( *radioEvents ); @@ -1790,23 +1737,10 @@ void RadioGroupElement::endElement() Reference< xml::input::XElement > xRadio( _radios[ nPos ] ); Reference< xml::input::XAttributes > xAttributes( xRadio->getAttributes() ); - OUString sLinkedCell; - OUString sCellRange; - OUString sService( OUSTR("com.sun.star.awt.UnoControlRadioButtonModel") ); - try - { - sLinkedCell = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) ); - // we should probably limit this to vba mode also ( leave for now ) - if ( isVBACompatibilityMode( _pImport ) ) - sService = OUSTR("com.sun.star.form.component.RadioButton"); - } - catch( Exception& /*e*/ ) - { - } ControlImportContext ctx( _pImport, getControlId( xAttributes ), - sService ); + getControlModelName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ), xAttributes ) ); Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); Reference< xml::input::XElement > xStyle( getStyle( xAttributes ) ); @@ -1833,9 +1767,7 @@ void RadioGroupElement::endElement() ctx.importVerticalAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ), OUString( RTL_CONSTASCII_USTRINGPARAM("valign") ), xAttributes ); - ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ), - xAttributes ); + ctx.importImageURLProperty( OUSTR( "ImageURL" ), OUSTR( "image-src" ), xAttributes ); ctx.importImagePositionProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ), OUString( RTL_CONSTASCII_USTRINGPARAM("image-position") ), xAttributes ); @@ -1858,7 +1790,8 @@ void RadioGroupElement::endElement() xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ), makeAny( nVal ) ); - importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx ); + ctx.importDataAwareProperty( OUSTR("linked-cell" ), xAttributes ); + ::std::vector< Reference< xml::input::XElement > > * radioEvents = static_cast< RadioElement * >( xRadio.get() )->getEvents(); ctx.importEvents( *radioEvents ); @@ -1979,26 +1912,10 @@ Reference< xml::input::XElement > MenuListElement::startChildElement( void MenuListElement::endElement() throw (xml::sax::SAXException, RuntimeException) { - OUString sLinkedCell; - OUString sCellRange; - OUString sListBoxService( OUSTR("com.sun.star.awt.UnoControlListBoxModel") ); - - // we should probably limit this to vba mode also ( leave for now ) - if ( isVBACompatibilityMode( _pImport ) ) - sListBoxService = OUSTR("com.sun.star.form.component.ListBox"); - - try - { - sLinkedCell = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) ); - sCellRange = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "source-cell-range" ) ); - } - catch( Exception& /*e*/ ) - { - } ControlImportContext ctx( _pImport, getControlId( _xAttributes ), - //OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ); - sListBoxService ); + + getControlModelName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ), _xAttributes ) ); Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); @@ -2031,17 +1948,16 @@ void MenuListElement::endElement() ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ), OUString( RTL_CONSTASCII_USTRINGPARAM("align") ), _xAttributes ); - // import cell-link and cell source range - importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx ); + bool bHasLinkedCell = ctx.importDataAwareProperty( OUSTR("linked-cell" ), _xAttributes ); + bool bHasSrcRange = ctx.importDataAwareProperty( OUSTR("source-cell-range" ), _xAttributes ); if (_popup.is()) { MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() ); - if ( !sCellRange.getLength() ) - xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ), - makeAny( p->getItemValues() ) ); - if ( !sLinkedCell.getLength() ) - xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ), - makeAny( p->getSelectedItems() ) ); + if ( !bHasSrcRange ) + xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ), makeAny( p->getItemValues() ) ); + if ( !bHasLinkedCell ) + xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ), makeAny( p->getSelectedItems() ) ); + } ctx.importEvents( _events ); // avoid ring-reference: @@ -2086,26 +2002,9 @@ Reference< xml::input::XElement > ComboBoxElement::startChildElement( void ComboBoxElement::endElement() throw (xml::sax::SAXException, RuntimeException) { - OUString sService( OUSTR("com.sun.star.awt.UnoControlComboBoxModel") ); - - // we should probably limit this to vba mode also ( leave for now ) - if ( isVBACompatibilityMode( _pImport ) ) - sService = OUSTR("com.sun.star.form.component.ComboBox"); - - OUString sLinkedCell; - OUString sCellRange; - try - { - sLinkedCell = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) ); - sCellRange = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "source-cell-range" ) ); - } - catch( Exception& /*e*/ ) - { - } - ControlImportContext ctx( _pImport, getControlId( _xAttributes ), - sService ); + getControlModelName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ), _xAttributes ) ); Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); @@ -2147,10 +2046,9 @@ void ComboBoxElement::endElement() ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ), OUString( RTL_CONSTASCII_USTRINGPARAM("align") ), _xAttributes ); - // import cell-link and cell source range - importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx ); - - if (_popup.is() && !sCellRange.getLength() ) + ctx.importDataAwareProperty( OUSTR("linked-cell" ), _xAttributes ); + bool bHasSrcRange = ctx.importDataAwareProperty( OUSTR("source-cell-range" ), _xAttributes ); + if (_popup.is() && !bHasSrcRange ) { MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() ); xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ), @@ -2217,9 +2115,7 @@ void CheckBoxElement::endElement() ctx.importVerticalAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ), OUString( RTL_CONSTASCII_USTRINGPARAM("valign") ), _xAttributes ); - ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ), - _xAttributes ); + ctx.importImageURLProperty( OUSTR( "ImageURL" ), OUSTR( "image-src" ), _xAttributes ); ctx.importImagePositionProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ), OUString( RTL_CONSTASCII_USTRINGPARAM("image-position") ), _xAttributes ); @@ -2320,9 +2216,7 @@ void ButtonElement::endElement() ctx.importButtonTypeProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("PushButtonType") ), OUString( RTL_CONSTASCII_USTRINGPARAM("button-type") ), _xAttributes ); - ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ), - _xAttributes ); + ctx.importImageURLProperty( OUSTR( "ImageURL" ), OUSTR( "image-src" ), _xAttributes ); ctx.importImagePositionProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ), OUString( RTL_CONSTASCII_USTRINGPARAM("image-position") ), _xAttributes ); @@ -2477,7 +2371,7 @@ Reference< xml::input::XElement > BulletinBoardElement::startChildElement( return new ScrollBarElement( rLocalName, xAttributes, this, _pImport ); } // spinbutton - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("spinbutton") ) && isVBACompatibilityMode( _pImport ) ) + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("spinbutton") ) ) { return new SpinButtonElement( rLocalName, xAttributes, this, _pImport ); } @@ -2490,6 +2384,14 @@ Reference< xml::input::XElement > BulletinBoardElement::startChildElement( { return new MultiPage( rLocalName, xAttributes, this, _pImport ); } + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("frame") )) + { + return new Frame( rLocalName, xAttributes, this, _pImport ); + } + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("page") )) + { + return new Page( rLocalName, xAttributes, this, _pImport ); + } // bulletinboard else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") )) { @@ -2665,10 +2567,7 @@ void WindowElement::endElement() OUString( RTL_CONSTASCII_USTRINGPARAM("Decoration") ), OUString( RTL_CONSTASCII_USTRINGPARAM("withtitlebar") ), _xAttributes ); - ctx.importStringProperty( - OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ), - _xAttributes ); + ctx.importImageURLProperty( OUSTR( "ImageURL" ), OUSTR( "image-src" ), _xAttributes ); ctx.importEvents( _events ); // avoid ring-reference: // vector< event elements > holding event elements holding this (via _pParent) diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx index 81ba97c6a955..02a74f2be0cb 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx @@ -58,10 +58,20 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; @@ -129,6 +139,20 @@ OUString ControlElement::getControlId( return aId; } +OUString ControlElement::getControlModelName( + OUString const& rDefaultModel, + Reference< xml::input::XAttributes > const & xAttributes ) +{ + OUString aModel; + aModel = xAttributes->getValueByUidName( + _pImport->XMLNS_DIALOGS_UID, + OUString( RTL_CONSTASCII_USTRINGPARAM("control-implementation") ) ); + if (! aModel.getLength()) + aModel = rDefaultModel; + return aModel; +} + + //################################################################################################## //__________________________________________________________________________________________________ @@ -820,6 +844,7 @@ bool ImportContext::importDoubleProperty( } return false; } + //__________________________________________________________________________________________________ bool ImportContext::importBooleanProperty( OUString const & rPropName, OUString const & rAttrName, @@ -971,6 +996,115 @@ bool ImportContext::importVerticalAlignProperty( return false; } //__________________________________________________________________________________________________ +bool ImportContext::importImageURLProperty( + OUString const & rPropName, OUString const & rAttrName, + Reference< xml::input::XAttributes > const & xAttributes ) +{ + rtl::OUString sURL = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, rAttrName ); + if ( sURL.getLength() ) + { + Reference< document::XStorageBasedDocument > xDocStorage( _pImport->getDocOwner(), UNO_QUERY ); + + uno::Reference< document::XGraphicObjectResolver > xGraphicResolver; + if ( xDocStorage.is() ) + { + uno::Sequence< Any > aArgs( 1 ); + aArgs[ 0 ] <<= xDocStorage->getDocumentStorage(); + ::comphelper::ComponentContext aContext( _pImport->getComponentContext() ); + aContext.createComponentWithArguments( OUSTR( "com.sun.star.comp.Svx.GraphicImportHelper" ), aArgs, xGraphicResolver ); + if ( xGraphicResolver.is() ) + { + rtl::OUString aTmp( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) ); + aTmp += sURL; + try + { + aTmp = xGraphicResolver->resolveGraphicObjectURL( aTmp ); + if ( aTmp.getLength() ) + sURL = aTmp; + } + catch( uno::Exception& e ) + { + (void)e; + return false; + } + + } + } + if ( sURL.getLength() > 0 ) + { + Reference< beans::XPropertySet > xProps( getControlModel(), UNO_QUERY ); + if ( xProps.is() ) + { + xProps->setPropertyValue( rPropName, makeAny( sURL ) ); + return true; + } + } + } + return false; +} +//__________________________________________________________________________________________________ + bool ImportContext::importDataAwareProperty( + ::rtl::OUString const & rPropName, + Reference const & xAttributes ) +{ + OUString sLinkedCell; + OUString sCellRange; + if ( rPropName.equals( OUSTR("linked-cell" ) ) ) + sLinkedCell = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, rPropName ); + if ( rPropName.equals( OUSTR( "source-cell-range" ) ) ) + sCellRange = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, rPropName ); + bool bRes = false; + Reference< lang::XMultiServiceFactory > xFac( _pImport->getDocOwner(), UNO_QUERY ); + if ( xFac.is() && ( sLinkedCell.getLength() || sCellRange.getLength() ) ) + { + // Set up Celllink + if ( sLinkedCell.getLength() ) + { + Reference< form::binding::XBindableValue > xBindable( getControlModel(), uno::UNO_QUERY ); + Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellAddressConversion" )), uno::UNO_QUERY ); + if ( xBindable.is() && xConvertor.is() ) + { + table::CellAddress aAddress; + xConvertor->setPropertyValue( OUSTR( "PersistentRepresentation" ), uno::makeAny( sLinkedCell ) ); + xConvertor->getPropertyValue( OUSTR( "Address" ) ) >>= aAddress; + beans::NamedValue aArg1; + aArg1.Name = OUSTR("BoundCell"); + aArg1.Value <<= aAddress; + + uno::Sequence< uno::Any > aArgs(1); + aArgs[ 0 ] <<= aArg1; + + uno::Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments( OUSTR("com.sun.star.table.CellValueBinding" ), aArgs ), uno::UNO_QUERY ); + xBindable->setValueBinding( xBinding ); + bRes = true; + } + } + // Set up CelllRange + if ( sCellRange.getLength() ) + { + Reference< form::binding::XListEntrySink > xListEntrySink( getControlModel(), uno::UNO_QUERY ); + Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellRangeAddressConversion" )), uno::UNO_QUERY ); + if ( xListEntrySink.is() && xConvertor.is() ) + { + table::CellRangeAddress aAddress; + xConvertor->setPropertyValue( OUSTR( "PersistentRepresentation" ), uno::makeAny( sCellRange ) ); + xConvertor->getPropertyValue( OUSTR( "Address" ) ) >>= aAddress; + beans::NamedValue aArg1; + aArg1.Name = OUSTR("CellRange"); + aArg1.Value <<= aAddress; + + uno::Sequence< uno::Any > aArgs(1); + aArgs[ 0 ] <<= aArg1; + + uno::Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments( OUSTR("com.sun.star.table.CellRangeListSource" ), aArgs ), uno::UNO_QUERY ); + xListEntrySink->setListEntrySource( xSource ); + bRes = true; + } + } + } + return bRes; +} +//__________________________________________________________________________________________________ bool ImportContext::importImageAlignProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::input::XAttributes > const & xAttributes ) @@ -1921,11 +2055,13 @@ Reference< xml::sax::XDocumentHandler > SAL_CALL importDialogModel( Reference< XModel > const & xDocument ) SAL_THROW( (Exception) ) { - DialogImport* pImport = new DialogImport( xContext, xDialogModel, xDocument ); - return ::xmlscript::createDocumentHandler( - static_cast< xml::input::XRoot * >( pImport ) ); + // single set of styles and stylenames apply to all containees + :: boost::shared_ptr< ::std::vector< ::rtl::OUString > > pStyleNames( new ::std::vector< ::rtl::OUString > ); + :: boost::shared_ptr< ::std::vector< css::uno::Reference< css::xml::input::XElement > > > pStyles( new ::std::vector< css::uno::Reference< css::xml::input::XElement > > ); + return ::xmlscript::createDocumentHandler( + static_cast< xml::input::XRoot * >( + new DialogImport( xContext, xDialogModel, pStyleNames, pStyles, xDocument ) ) ); } - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlscript/util/makefile.mk b/xmlscript/util/makefile.mk index bc259db75455..dd21c16cd558 100644 --- a/xmlscript/util/makefile.mk +++ b/xmlscript/util/makefile.mk @@ -56,6 +56,7 @@ SHL1LIBS= \ SHL1STDLIBS= \ $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ + $(COMPHELPERLIB) \ $(CPPULIB) \ $(SALLIB) -- cgit