diff options
author | Noel Power <noel.power@novell.com> | 2010-10-06 10:16:27 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2010-10-06 10:16:27 +0100 |
commit | 0b21b8b146fc4b982c7c9bbb866b9ff18a29332a (patch) | |
tree | 9b36a1dee6f92703604bcc86564568eefe711c22 /xmlscript | |
parent | 8d4d17664c9c6207fa35458075559d1fbfbfa2a5 (diff) |
initial commit for vba blob ( not including container_control stuff )
Diffstat (limited to 'xmlscript')
-rw-r--r-- | xmlscript/inc/xmlscript/xmldlg_imexp.hxx | 18 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/exp_share.hxx | 14 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/imp_share.hxx | 54 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx | 11 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx | 191 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_export.cxx | 29 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx | 418 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_import.cxx | 34 | ||||
-rw-r--r-- | xmlscript/util/makefile.mk | 1 |
9 files changed, 722 insertions, 48 deletions
diff --git a/xmlscript/inc/xmlscript/xmldlg_imexp.hxx b/xmlscript/inc/xmlscript/xmldlg_imexp.hxx index fca73bc0144a..2e1654adb1b1 100644 --- a/xmlscript/inc/xmlscript/xmldlg_imexp.hxx +++ b/xmlscript/inc/xmlscript/xmldlg_imexp.hxx @@ -27,6 +27,8 @@ #ifndef _XMLSCRIPT_XMLDLG_IMEXP_HXX_ #define _XMLSCRIPT_XMLDLG_IMEXP_HXX_ +#include <com/sun/star/frame/XModel.hpp> + #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HXX_ #include <com/sun/star/container/XNameContainer.hpp> #endif @@ -51,7 +53,9 @@ void SAL_CALL exportDialogModel( ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut, ::com::sun::star::uno::Reference< - ::com::sun::star::container::XNameContainer > const & xDialogModel ) + ::com::sun::star::container::XNameContainer > const & xDialogModel, + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > const & xDocument ) SAL_THROW( (::com::sun::star::uno::Exception) ); //============================================================================== @@ -60,7 +64,9 @@ SAL_CALL importDialogModel( ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > const & xDialogModel, ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext > const & xContext ) + ::com::sun::star::uno::XComponentContext > const & xContext, + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > const & xDocument ) SAL_THROW( (::com::sun::star::uno::Exception) ); // additional functions for convenience @@ -71,7 +77,9 @@ SAL_CALL exportDialogModel( ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > const & xDialogModel, ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext > const & xContext ) + ::com::sun::star::uno::XComponentContext > const & xContext, + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > const & xDocument ) SAL_THROW( (::com::sun::star::uno::Exception) ); //============================================================================== @@ -81,7 +89,9 @@ void SAL_CALL importDialogModel( ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > const & xDialogModel, ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext > const & xContext ) + ::com::sun::star::uno::XComponentContext > const & xContext, + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > const & xDocument ) SAL_THROW( (::com::sun::star::uno::Exception) ); } diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx index a53d02393ae6..f96186448ea4 100644 --- a/xmlscript/source/xmldlg_imexp/exp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx @@ -171,15 +171,17 @@ public: // void readDialogModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); + void readMultiPageModel( 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 ) + void readRadioButtonModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) SAL_THROW( (css::uno::Exception) ); - void readComboBoxModel( StyleBag * all_styles ) + void readComboBoxModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) SAL_THROW( (css::uno::Exception) ); void readCurrencyFieldModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); @@ -193,9 +195,9 @@ public: SAL_THROW( (css::uno::Exception) ); void readGroupBoxModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); - void readImageControlModel( StyleBag * all_styles ) + void readImageControlModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) SAL_THROW( (css::uno::Exception) ); - void readListBoxModel( StyleBag * all_styles ) + void readListBoxModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) SAL_THROW( (css::uno::Exception) ); void readNumericFieldModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); @@ -209,7 +211,9 @@ public: SAL_THROW( (css::uno::Exception) ); void readProgressBarModel( StyleBag * all_styles ) SAL_THROW( (css::uno::Exception) ); - void readScrollBarModel( StyleBag * all_styles ) + void readScrollBarModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) + SAL_THROW( (css::uno::Exception) ); + void readSpinButtonModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) 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 29966392e7a5..a13a205a7bf7 100644 --- a/xmlscript/source/xmldlg_imexp/imp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx @@ -42,6 +42,7 @@ #include <com/sun/star/awt/FontEmphasisMark.hpp> #include <com/sun/star/awt/FontRelief.hpp> #include <com/sun/star/xml/input/XRoot.hpp> +#include <com/sun/star/script/XLibraryContainer.hpp> #include <vector> @@ -128,6 +129,8 @@ struct DialogImport css::uno::Reference< css::container::XNameContainer > _xDialogModel; css::uno::Reference< css::lang::XMultiServiceFactory > _xDialogModelFactory; + css::uno::Reference< css::frame::XModel > _xDoc; + css::uno::Reference< css::script::XLibraryContainer > _xScriptLibraryContainer; sal_Int32 XMLNS_DIALOGS_UID, XMLNS_SCRIPT_UID; @@ -161,16 +164,20 @@ public: inline DialogImport( css::uno::Reference<css::uno::XComponentContext> const & xContext, css::uno::Reference<css::container::XNameContainer> - const & xDialogModel ) + const & xDialogModel, + css::uno::Reference<css::frame::XModel> const & xDoc ) SAL_THROW( () ) : _xContext( xContext ) , _xDialogModel( xDialogModel ) - , _xDialogModelFactory( xDialogModel, css::uno::UNO_QUERY_THROW ) + , _xDialogModelFactory( xDialogModel, css::uno::UNO_QUERY_THROW ), _xDoc( xDoc ) { OSL_ASSERT( _xDialogModel.is() && _xDialogModelFactory.is() && _xContext.is() ); } virtual ~DialogImport() SAL_THROW( () ); + inline css::uno::Reference< css::frame::XModel > getDocOwner() { return _xDoc; } + + css::uno::Reference< css::script::XLibraryContainer > getScriptLibraryContainer(); // XRoot virtual void SAL_CALL startDocument( css::uno::Reference< css::xml::input::XNamespaceMapping > @@ -996,6 +1003,49 @@ public: }; //============================================================================== +class SpinButtonElement + : public ControlElement +{ +public: + virtual css::uno::Reference< css::xml::input::XElement > + SAL_CALL startChildElement( + sal_Int32 nUid, ::rtl::OUString const & rLocalName, + css::uno::Reference<css::xml::input::XAttributes> const & xAttributes ) + throw (css::xml::sax::SAXException, css::uno::RuntimeException); + virtual void SAL_CALL endElement() + throw (css::xml::sax::SAXException, css::uno::RuntimeException); + + inline SpinButtonElement( + ::rtl::OUString const & rLocalName, + css::uno::Reference< css::xml::input::XAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + SAL_THROW( () ) + : ControlElement( rLocalName, xAttributes, pParent, pImport ) + {} +}; + +//============================================================================== +class MultiPage + : public ControlElement +{ +public: + virtual css::uno::Reference< css::xml::input::XElement > + SAL_CALL startChildElement( + sal_Int32 nUid, ::rtl::OUString const & rLocalName, + css::uno::Reference<css::xml::input::XAttributes> const & xAttributes ) + throw (css::xml::sax::SAXException, css::uno::RuntimeException); + virtual void SAL_CALL endElement() + 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 ) + {} +}; + class ProgressBarElement : public ControlElement { diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx index 22c472ac1782..5e9937f061b0 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx @@ -41,6 +41,7 @@ using namespace ::rtl; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; namespace xmlscript { @@ -70,7 +71,8 @@ Reference< io::XInputStream > InputStreamProvider::createInputStream() //================================================================================================== Reference< io::XInputStreamProvider > SAL_CALL exportDialogModel( Reference< container::XNameContainer > const & xDialogModel, - Reference< XComponentContext > const & xContext ) + Reference< XComponentContext > const & xContext, + Reference< XModel > const & xDocument ) SAL_THROW( (Exception) ) { Reference< lang::XMultiComponentFactory > xSMgr( xContext->getServiceManager() ); @@ -95,7 +97,7 @@ Reference< io::XInputStreamProvider > SAL_CALL exportDialogModel( Reference< io::XActiveDataSource > xSource( xHandler, UNO_QUERY ); xSource->setOutputStream( createOutputStream( &aBytes ) ); - exportDialogModel( xHandler, xDialogModel ); + exportDialogModel( xHandler, xDialogModel, xDocument ); return new InputStreamProvider( aBytes ); } @@ -104,7 +106,8 @@ Reference< io::XInputStreamProvider > SAL_CALL exportDialogModel( void SAL_CALL importDialogModel( Reference< io::XInputStream > xInput, Reference< container::XNameContainer > const & xDialogModel, - Reference< XComponentContext > const & xContext ) + Reference< XComponentContext > const & xContext, + Reference< XModel > const & xDocument ) SAL_THROW( (Exception) ) { Reference< lang::XMultiComponentFactory > xSMgr( xContext->getServiceManager() ); @@ -126,7 +129,7 @@ void SAL_CALL importDialogModel( } // error handler, entity resolver omitted for this helper function - xParser->setDocumentHandler( importDialogModel( xDialogModel, xContext ) ); + xParser->setDocumentHandler( importDialogModel( xDialogModel, xContext, xDocument ) ); xml::sax::InputSource source; source.aInputStream = xInput; diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx index 1d9e67d23d28..3cd7ff985eef 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx @@ -29,7 +29,16 @@ #include "precompiled_xmlscript.hxx" #include "exp_share.hxx" +#include <com/sun/star/form/binding/XListEntrySink.hpp> +#include <com/sun/star/form/binding/XBindableValue.hpp> +#include <com/sun/star/form/binding/XValueBinding.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> +#include <com/sun/star/document/XGraphicObjectResolver.hpp> +#include <comphelper/componentcontext.hxx> +#include <comphelper/processfactory.hxx> using namespace ::com::sun::star; @@ -39,6 +48,66 @@ 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 ) { @@ -65,6 +134,42 @@ static inline bool readFontProps( ElementDescriptor * element, Style & style ) } //__________________________________________________________________________________________________ +void ElementDescriptor::readMultiPageModel( StyleBag * all_styles ) +{ + // collect styles + Style aStyle( 0x2 | 0x8 | 0x20 ); + 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(); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-max") ) ); + + OUString aTitle; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ) ) >>= aTitle) + { + ElementDescriptor * title = new ElementDescriptor( + _xProps, _xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ) ); + title->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ), + aTitle ); + addSubElement( title ); + } + + readEvents(); +} void ElementDescriptor::readButtonModel( StyleBag * all_styles ) SAL_THROW( (Exception) ) { @@ -206,7 +311,7 @@ void ElementDescriptor::readCheckBoxModel( StyleBag * all_styles ) readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readComboBoxModel( StyleBag * all_styles ) +void ElementDescriptor::readComboBoxModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument ) SAL_THROW( (Exception) ) { // collect styles @@ -247,7 +352,8 @@ void ElementDescriptor::readComboBoxModel( StyleBag * all_styles ) OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":maxlength") ) ); readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linecount") ) ); - + // Cell Range, Ref Cell etc. + lclExportBindableAndListSourceBits( xDocument, _xProps, *this ); // string item list Sequence< OUString > itemValues; if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ) ) >>= itemValues) && @@ -273,7 +379,7 @@ void ElementDescriptor::readComboBoxModel( StyleBag * all_styles ) readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readListBoxModel( StyleBag * all_styles ) +void ElementDescriptor::readListBoxModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument ) SAL_THROW( (Exception) ) { // collect styles @@ -308,7 +414,7 @@ void ElementDescriptor::readListBoxModel( StyleBag * all_styles ) 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 ); // string item list Sequence< OUString > itemValues; if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ) ) >>= itemValues) && @@ -348,7 +454,7 @@ void ElementDescriptor::readListBoxModel( StyleBag * all_styles ) readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles ) +void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument ) SAL_THROW( (Exception) ) { // collect styles @@ -385,6 +491,8 @@ void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles ) OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-position") ) ); readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiline") ) ); + readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("GroupName") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":group-name") ) ); sal_Int16 nState = 0; if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ) ) >>= nState) @@ -404,6 +512,7 @@ void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles ) break; } } + lclExportBindableAndListSourceBits( xDocument, _xProps, *this ); readEvents(); } //__________________________________________________________________________________________________ @@ -576,7 +685,7 @@ void ElementDescriptor::readEditModel( StyleBag * all_styles ) readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readImageControlModel( StyleBag * all_styles ) +void ElementDescriptor::readImageControlModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument ) SAL_THROW( (Exception) ) { // collect styles @@ -595,8 +704,31 @@ void ElementDescriptor::readImageControlModel( StyleBag * all_styles ) readDefaults(); readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleImage") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scale-image") ) ); - readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":src") ) ); + 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") ) ); readEvents(); @@ -1073,7 +1205,7 @@ void ElementDescriptor::readProgressBarModel( StyleBag * all_styles ) readEvents(); } //__________________________________________________________________________________________________ -void ElementDescriptor::readScrollBarModel( StyleBag * all_styles ) +void ElementDescriptor::readScrollBarModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument ) SAL_THROW( (Exception) ) { // collect styles @@ -1111,6 +1243,47 @@ void ElementDescriptor::readScrollBarModel( StyleBag * all_styles ) 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 ); readEvents(); } //__________________________________________________________________________________________________ diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx index 365355375808..be4643f35222 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -1325,7 +1325,8 @@ void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOu //================================================================================================== void SAL_CALL exportDialogModel( Reference< xml::sax::XExtendedDocumentHandler > const & xOut, - Reference< container::XNameContainer > const & xDialogModel ) + Reference< container::XNameContainer > const & xDialogModel, + Reference< frame::XModel > const & xDocument ) SAL_THROW( (Exception) ) { StyleBag all_styles; @@ -1373,7 +1374,7 @@ void SAL_CALL exportDialogModel( xProps, xPropState, OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radio") ) ); xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readRadioButtonModel( &all_styles ); + pElem->readRadioButtonModel( &all_styles, xDocument ); pRadioGroup->addSubElement( xElem ); } else // no radio @@ -1402,7 +1403,7 @@ void SAL_CALL exportDialogModel( xProps, xPropState, OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ) ); xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readComboBoxModel( &all_styles ); + pElem->readComboBoxModel( &all_styles, xDocument ); } else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) { @@ -1410,7 +1411,7 @@ void SAL_CALL exportDialogModel( xProps, xPropState, OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ) ); xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readListBoxModel( &all_styles ); + pElem->readListBoxModel( &all_styles, xDocument ); } else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) { @@ -1420,6 +1421,14 @@ void SAL_CALL exportDialogModel( 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( @@ -1451,7 +1460,7 @@ void SAL_CALL exportDialogModel( xProps, xPropState, OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":img") ) ); xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readImageControlModel( &all_styles ); + pElem->readImageControlModel( &all_styles, xDocument ); } else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ) ) ) { @@ -1531,7 +1540,15 @@ void SAL_CALL exportDialogModel( xProps, xPropState, OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scrollbar") ) ); xElem = static_cast< xml::sax::XAttributeList * >( pElem ); - pElem->readScrollBarModel( &all_styles ); + 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") ) ) ) { diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx index a0968eb007d5..420adb39787d 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx @@ -28,17 +28,195 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmlscript.hxx" #include "imp_share.hxx" - +#include <com/sun/star/form/binding/XBindableValue.hpp> +#include <com/sun/star/form/binding/XValueBinding.hpp> +#include <com/sun/star/form/binding/XListEntrySink.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> +#include <com/sun/star/document/XGraphicObjectResolver.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> - +#include <comphelper/componentcontext.hxx> +#include <comphelper/processfactory.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using ::rtl::OUString; namespace xmlscript { +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("title") )) + { + getStringAttr( &_label, + OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), + xAttributes, + _pImport->XMLNS_DIALOGS_UID ); + + return new ElementBase( + _pImport->XMLNS_DIALOGS_UID, + rLocalName, xAttributes, this, _pImport ); + } + else + { + + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ + +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 > 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 + ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), + _xAttributes ); + ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("value-max") ), + _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 ) +{ + // 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; + } + + return true; +} + +void importBindableAndListRangeBits( DialogImport* _pImport, const rtl::OUString sLinkedCell, const rtl::OUString & sCellRange, ControlImportContext& ctx ) +{ + 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; + + uno::Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments( OUSTR("com.sun.star.table.CellValueBinding" ), aArgs ), uno::UNO_QUERY ); + xBindable->setValueBinding( xBinding ); + + } + } + // 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 ); + + } + } + } +} + +sal_Bool isVBACompatibilityMode( DialogImport* _pImport ) +{ + sal_Bool bVBAMode = sal_False; + Reference< script::vba::XVBACompatibility > xVBACompat( _pImport->getScriptLibraryContainer(), UNO_QUERY ); + if( xVBACompat.is() ) + { + bVBAMode = xVBACompat->getVBACompatibilityMode(); + } + return bVBAMode; +} // progessmeter //__________________________________________________________________________________________________ @@ -119,9 +297,23 @@ 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 ), - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ); + sService ); Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); if (xStyle.is()) @@ -165,6 +357,92 @@ void ScrollBarElement::endElement() OUString( RTL_CONSTASCII_USTRINGPARAM("symbol-color") ), _xAttributes ); + // import cell-link + OUString sCellRange; + importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx ); + + ctx.importEvents( _events ); + // avoid ring-reference: + // vector< event elements > holding event elements holding this (via _pParent) + _events.clear(); +} + +//################################################################################################## + +// spinbutton +//__________________________________________________________________________________________________ +Reference< xml::input::XElement > SpinButtonElement::startChildElement( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::input::XAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + // event + if (_pImport->isEventElement( nUid, rLocalName )) + { + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ +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") ) ); + + Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); + if (xStyle.is()) + { + StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () ); + Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); + pStyle->importBackgroundColorStyle( xControlModel ); + pStyle->importBorderStyle( xControlModel ); + } + + ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes ); + ctx.importOrientationProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("align") ), + _xAttributes ); + ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinIncrement") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("increment") ), + _xAttributes ); + ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValue") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("curval") ), + _xAttributes ); + ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValueMax") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("maxval") ), + _xAttributes ); + ctx.importLongProperty( OUSTR("SpinValueMin"), OUSTR("minval"), + _xAttributes ); + ctx.importLongProperty( OUSTR("Repeat"), OUSTR("repeat"), + _xAttributes ); + ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat-delay"), + _xAttributes ); + ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), + 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 ); + ctx.importEvents( _events ); // avoid ring-reference: // vector< event elements > holding event elements holding this (via _pParent) @@ -1003,9 +1281,37 @@ void ImageControlElement::endElement() ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleImage") ), OUString( RTL_CONSTASCII_USTRINGPARAM("scale-image") ), _xAttributes ); - ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("src") ), - _xAttributes ); + 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.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ), _xAttributes ); @@ -1338,10 +1644,24 @@ 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 ), - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ); + sService ); Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); Reference< xml::input::XElement > xStyle( getStyle( xAttributes ) ); @@ -1377,6 +1697,9 @@ void TitledBoxElement::endElement() ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ), OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ), xAttributes ); + ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("GroupName") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("group-name") ), + xAttributes ); sal_Int16 nVal = 0; sal_Bool bChecked = sal_False; @@ -1390,7 +1713,7 @@ void TitledBoxElement::endElement() } xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ), makeAny( nVal ) ); - + importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx ); ::std::vector< Reference< xml::input::XElement > > * radioEvents = static_cast< RadioElement * >( xRadio.get() )->getEvents(); ctx.importEvents( *radioEvents ); @@ -1466,10 +1789,23 @@ 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 ), - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ); + sService ); Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); Reference< xml::input::XElement > xStyle( getStyle( xAttributes ) ); @@ -1505,6 +1841,9 @@ void RadioGroupElement::endElement() ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ), OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ), xAttributes ); + ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("GroupName") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("group-name") ), + xAttributes ); sal_Int16 nVal = 0; sal_Bool bChecked = sal_False; if (getBoolAttr( &bChecked, @@ -1518,6 +1857,7 @@ void RadioGroupElement::endElement() xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ), makeAny( nVal ) ); + importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx ); ::std::vector< Reference< xml::input::XElement > > * radioEvents = static_cast< RadioElement * >( xRadio.get() )->getEvents(); ctx.importEvents( *radioEvents ); @@ -1638,9 +1978,26 @@ 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") ) ); + //OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ); + sListBoxService ); Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); @@ -1673,13 +2030,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 ); if (_popup.is()) { MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() ); - xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ), + if ( !sCellRange.getLength() ) + xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ), makeAny( p->getItemValues() ) ); - xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ), + if ( !sLinkedCell.getLength() ) + xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ), makeAny( p->getSelectedItems() ) ); } ctx.importEvents( _events ); @@ -1725,9 +2085,26 @@ 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 ), - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ); + sService ); Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) ); @@ -1769,8 +2146,10 @@ 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()) + if (_popup.is() && !sCellRange.getLength() ) { MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() ); xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ), @@ -2096,11 +2475,20 @@ Reference< xml::input::XElement > BulletinBoardElement::startChildElement( { return new ScrollBarElement( rLocalName, xAttributes, this, _pImport ); } + // spinbutton + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("spinbutton") ) && isVBACompatibilityMode( _pImport ) ) + { + return new SpinButtonElement( rLocalName, xAttributes, this, _pImport ); + } // progressmeter else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("progressmeter") )) { return new ProgressBarElement( rLocalName, xAttributes, this, _pImport ); } + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("multipage") )) + { + return new MultiPage( rLocalName, xAttributes, this, _pImport ); + } // bulletinboard else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") )) { diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx index 5fb2a39c6913..fb57c5acb769 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx @@ -57,9 +57,13 @@ #include <com/sun/star/script/ScriptEventDescriptor.hpp> #include <com/sun/star/view/SelectionType.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> +#include <com/sun/star/script/DocumentScriptLibraryContainer.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; using ::rtl::OUString; namespace xmlscript @@ -1888,18 +1892,42 @@ Reference< xml::input::XElement > DialogImport::getStyle( } return 0; } +//__________________________________________________________________________________________________ +Reference< script::XLibraryContainer > DialogImport::getScriptLibraryContainer() +{ + if( !_xScriptLibraryContainer.is() ) + { + try + { + Reference< beans::XPropertySet > xProps( _xDoc, UNO_QUERY ); + if( xProps.is() ) + _xScriptLibraryContainer.set( xProps->getPropertyValue( OUSTR("BasicLibraries") ), UNO_QUERY ); + } + catch( const Exception& ) + { + } + } + + return _xScriptLibraryContainer; +} //################################################################################################## //================================================================================================== Reference< xml::sax::XDocumentHandler > SAL_CALL importDialogModel( Reference< container::XNameContainer > const & xDialogModel, - Reference< XComponentContext > const & xContext ) + Reference< XComponentContext > const & xContext, + Reference< XModel > const & xDocument ) SAL_THROW( (Exception) ) { + DialogImport* pImport = new DialogImport( xContext, xDialogModel, xDocument ); + uno::Reference< script::vba::XVBACompatibility > xVBAModeSource( pImport->getScriptLibraryContainer(), uno::UNO_QUERY ); + + uno::Reference< beans::XPropertySet > xDlgProps( xDialogModel, uno::UNO_QUERY ); + if ( xVBAModeSource.is() && xDlgProps.is() && xVBAModeSource->getVBACompatibilityMode() ) + xDlgProps->setPropertyValue( OUSTR("VBAForm"), uno::makeAny( sal_True ) ); return ::xmlscript::createDocumentHandler( - static_cast< xml::input::XRoot * >( - new DialogImport( xContext, xDialogModel ) ) ); + static_cast< xml::input::XRoot * >( pImport ) ); } } diff --git a/xmlscript/util/makefile.mk b/xmlscript/util/makefile.mk index 3ccf63dc3b89..7a391cdcaaa9 100644 --- a/xmlscript/util/makefile.mk +++ b/xmlscript/util/makefile.mk @@ -54,6 +54,7 @@ SHL1LIBS= \ $(LIB1TARGET) SHL1STDLIBS= \ + $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(SALLIB) |