diff options
author | Daniel Boelzle <dbo@openoffice.org> | 2001-04-04 13:35:09 +0000 |
---|---|---|
committer | Daniel Boelzle <dbo@openoffice.org> | 2001-04-04 13:35:09 +0000 |
commit | cf5ace8b4f8bde7a123239ff592b2dcc535d2352 (patch) | |
tree | efff08250ec857194a23c08bd792ed08830e7c74 /xmlscript/source | |
parent | 366bc9051891fba91d76a02d8c2b94e16db2e0fc (diff) |
#85648# fixed dialog model properties
Diffstat (limited to 'xmlscript/source')
-rw-r--r-- | xmlscript/source/xml_helper/xml_impctx.cxx | 6 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/exp_share.hxx | 5 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/imp_share.hxx | 51 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx | 44 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_export.cxx | 124 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx | 129 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_import.cxx | 123 |
7 files changed, 246 insertions, 236 deletions
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx index f9d0a0a600c5..a33b83db9f46 100644 --- a/xmlscript/source/xml_helper/xml_impctx.cxx +++ b/xmlscript/source/xml_helper/xml_impctx.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xml_impctx.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: dbo $ $Date: 2001-03-14 16:39:58 $ + * last change: $Author: dbo $ $Date: 2001-04-04 14:35:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,7 +68,7 @@ #include <rtl/ustrbuf.hxx> #include <cppuhelper/implbase1.hxx> -#include <xmlscript/xml_helper.hxx> +#include <xmlscript/xml_import.hxx> #include <com/sun/star/xml/sax2/XExtendedAttributes.hpp> diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx index e1e7a43e1b96..24969388d09d 100644 --- a/xmlscript/source/xmldlg_imexp/exp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx @@ -2,9 +2,9 @@ * * $RCSfile: exp_share.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: dbo $ $Date: 2001-03-15 14:44:15 $ + * last change: $Author: dbo $ $Date: 2001-04-04 14:35:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -151,6 +151,7 @@ public: // void readEvents() SAL_THROW( (Exception) ); // + void readDialogModel( StyleBag * all_styles ) SAL_THROW( (Exception) ); void readButtonModel( StyleBag * all_styles ) SAL_THROW( (Exception) ); void readEditModel( StyleBag * all_styles ) SAL_THROW( (Exception) ); void readCheckBoxModel( StyleBag * all_styles ) SAL_THROW( (Exception) ); diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx index 4d20bf8015ee..27b795f02669 100644 --- a/xmlscript/source/xmldlg_imexp/imp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx @@ -2,9 +2,9 @@ * * $RCSfile: imp_share.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: ab $ $Date: 2001-03-27 17:44:31 $ + * last change: $Author: dbo $ $Date: 2001-04-04 14:35:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -91,7 +91,7 @@ inline sal_Int32 toInt32( OUString const & rStr ) SAL_THROW( () ) sal_Int32 nVal; if (rStr.getLength() > 2 && rStr[ 0 ] == '0' && rStr[ 1 ] == 'x') { - nVal = rStr.toInt32( 16 ); + nVal = rStr.copy( 2 ).toInt32( 16 ); } else { @@ -145,13 +145,13 @@ inline bool getLongAttr( return false; } -class ControlImportContext; +class ImportContext; //================================================================================================== struct DialogImport : public ::cppu::WeakImplHelper1< xml::XImporter > { - friend class ControlImportContext; + friend class ImportContext; vector< OUString > _styleNames; vector< Reference< xml::XImportContext > > _styles; @@ -341,33 +341,21 @@ public: SAL_THROW( () ); }; //================================================================================================== -class ControlImportContext +class ImportContext { - DialogImport * _pImport; - OUString _aId; - +protected: Reference< beans::XPropertySet > _xControlModel; public: - inline ControlImportContext( DialogImport * pImport, - OUString const & rId, OUString const & rControlName ) - : _pImport( pImport ) - , _aId( rId ) - , _xControlModel( pImport->_xDialogModelFactory->createInstance( rControlName ), UNO_QUERY ) + inline ImportContext( Reference< beans::XPropertySet > const & xControlModel_ ) + : _xControlModel( xControlModel_ ) { OSL_ASSERT( _xControlModel.is() ); } - inline ~ControlImportContext() - { _pImport->_xDialogModel->insertByName( _aId, makeAny( Reference< awt::XControlModel >::query( _xControlModel ) ) ); } inline Reference< beans::XPropertySet > getControlModel() { return _xControlModel; } void importEvents( vector< Reference< xml::sax2::XExtendedAttributes > > const & rEvents ); - - void importDefaults( - sal_Int32 nBaseX, sal_Int32 nBaseY, - Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); - bool importStringProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); @@ -398,6 +386,27 @@ public: Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); }; //================================================================================================== +class ControlImportContext : public ImportContext +{ + DialogImport * _pImport; + OUString _aId; +public: + inline ControlImportContext( DialogImport * pImport, + OUString const & rId, OUString const & rControlName ) + : ImportContext( Reference< beans::XPropertySet >( + pImport->_xDialogModelFactory->createInstance( rControlName ), UNO_QUERY ) ) + , _pImport( pImport ) + , _aId( rId ) + {} + inline ~ControlImportContext() + { _pImport->_xDialogModel->insertByName( _aId, makeAny( Reference< awt::XControlModel >::query( _xControlModel ) ) ); } + + void importDefaults( + sal_Int32 nBaseX, sal_Int32 nBaseY, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); +}; + +//================================================================================================== class WindowElement : public ControlElement { diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx index 60079f06193f..e3a94f253bf5 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_expmodels.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: dbo $ $Date: 2001-03-15 14:44:15 $ + * last change: $Author: dbo $ $Date: 2001-04-04 14:35:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -680,5 +680,45 @@ void ElementDescriptor::readPatternFieldModel( StyleBag * all_styles ) OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":literal-mask") ) ); readEvents(); } +//__________________________________________________________________________________________________ +void ElementDescriptor::readDialogModel( StyleBag * all_styles ) + SAL_THROW( (Exception) ) +{ + // collect elements + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_DIALOGS_PREFIX) ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_URI) ) ); + readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ) ); + + // collect styles + Style aStyle( 0x1 | 0x4 | 0x8 ); + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor) + aStyle._set |= 0x1; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("Border") ) ) >>= aStyle._border) + aStyle._set |= 0x4; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ) ) >>= aStyle._descr) + aStyle._set |= 0x8; + if (aStyle._set) + { + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), + all_styles->getStyleId( aStyle ) ); + } + + readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":left") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":top") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":page") ) ); + readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tag") ) ); + readEvents(); +} }; diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx index bd3c97a06289..7e1a0eb8045d 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_export.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: tbe $ $Date: 2001-04-03 13:13:48 $ + * last change: $Author: dbo $ $Date: 2001-04-04 14:35:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -652,14 +652,32 @@ void ElementDescriptor::readDefaults() OSL_ENSURE( 0, "unexpected property type for \"Enabled\": not bool!" ); } - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":left") ) ); - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":top") ) ); - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ) ); - readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ) ); + // force writing of pos/size + a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ) ); + if (a.getValueTypeClass() == TypeClass_LONG) + { + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":left") ), + OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue() ) ); + } + a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ) ); + if (a.getValueTypeClass() == TypeClass_LONG) + { + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":top") ), + OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue() ) ); + } + a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) ); + if (a.getValueTypeClass() == TypeClass_LONG) + { + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ), + OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue() ) ); + } + a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ) ); + if (a.getValueTypeClass() == TypeClass_LONG) + { + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ), + OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue() ) ); + } + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":printable") ) ); readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ), @@ -667,7 +685,9 @@ void ElementDescriptor::readDefaults() readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tag") ) ); readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":helptext") ) ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-text") ) ); + readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-url") ) ); } //__________________________________________________________________________________________________ void ElementDescriptor::readEvents() @@ -1043,67 +1063,45 @@ void SAL_CALL exportDialogModel( xOut->startDocument(); - if (! all_elements.empty()) // dump out - { - // window - Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY ); - OSL_ASSERT( xProps.is() ); - Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); - OSL_ASSERT( xPropState.is() ); + // 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 ); - Reference< xml::sax::XAttributeList > xWindow( pWindow ); - pWindow->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_DIALOGS_PREFIX) ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_URI) ) ); - pWindow->readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ) ); - pWindow->readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ) ); - pWindow->readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":left") ) ); - pWindow->readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":top") ) ); - pWindow->readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ) ); - pWindow->readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ) ); - pWindow->readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":page") ) ); - pWindow->readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tag") ) ); - //pWindow->readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ), - // OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":helptext") ) ); - xOut->ignorableWhitespace( OUString() ); - xOut->startElement( aWindowName, xWindow ); + OUString aWindowName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":window") ); + ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName ); + Reference< xml::sax::XAttributeList > xWindow( pWindow ); + pWindow->readDialogModel( &all_styles ); + xOut->ignorableWhitespace( OUString() ); + xOut->startElement( aWindowName, xWindow ); - // dump out stylebag - all_styles.dump( xOut ); + // dump out stylebag + all_styles.dump( xOut ); - if (! all_elements.empty()) - { - // 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 ( size_t nPos = 0; nPos < all_elements.size(); ++nPos ) - { - ElementDescriptor * pElem = static_cast< ElementDescriptor * >( all_elements[ nPos ].get() ); - pElem->dump( xOut ); - } + if (! all_elements.empty()) + { + // open up bulletinboard + OUString aBBoardName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") ); + xOut->ignorableWhitespace( OUString() ); + xOut->startElement( aBBoardName, Reference< xml::sax::XAttributeList >() ); - // end bulletinboard - xOut->ignorableWhitespace( OUString() ); - xOut->endElement( aBBoardName ); + // export control elements + for ( size_t nPos = 0; nPos < all_elements.size(); ++nPos ) + { + ElementDescriptor * pElem = static_cast< ElementDescriptor * >( all_elements[ nPos ].get() ); + pElem->dump( xOut ); } - // end window + // end bulletinboard xOut->ignorableWhitespace( OUString() ); - xOut->endElement( aWindowName ); + xOut->endElement( aBBoardName ); } + // end window + xOut->ignorableWhitespace( OUString() ); + xOut->endElement( aWindowName ); + xOut->endDocument(); } diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx index a4342ce5bbc2..0bfc7a458c65 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_impmodels.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: dbo $ $Date: 2001-03-22 15:43:07 $ + * last change: $Author: dbo $ $Date: 2001-04-04 14:35:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -796,20 +796,13 @@ void TitledBoxElement::endElement() OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), xAttributes ); - sal_Int16 nVal; - sal_Bool bTriState = sal_False; - sal_Bool bChecked = sal_False; - getBoolAttr( &bTriState, OUString( RTL_CONSTASCII_USTRINGPARAM("tristate") ), xAttributes ); - if (getBoolAttr( &bChecked, OUString( RTL_CONSTASCII_USTRINGPARAM("checked") ), xAttributes )) + sal_Int16 nVal = 0; + sal_Bool bChecked; + if (getBoolAttr( &bChecked, OUString( RTL_CONSTASCII_USTRINGPARAM("checked") ), xAttributes ) && + bChecked) { - // has "checked" attribute - nVal = (bChecked ? 1 : 0); + nVal = 1; } - else - { - nVal = (bTriState ? 2 : 0); // if tristate set, but checked omitted => dont know! - } - xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ), makeAny( nVal ) ); @@ -907,20 +900,13 @@ void RadioGroupElement::endElement() OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), xAttributes ); - sal_Int16 nVal; - sal_Bool bTriState = sal_False; - sal_Bool bChecked = sal_False; - getBoolAttr( &bTriState, OUString( RTL_CONSTASCII_USTRINGPARAM("tristate") ), xAttributes ); - if (getBoolAttr( &bChecked, OUString( RTL_CONSTASCII_USTRINGPARAM("checked") ), xAttributes )) + sal_Int16 nVal = 0; + sal_Bool bChecked; + if (getBoolAttr( &bChecked, OUString( RTL_CONSTASCII_USTRINGPARAM("checked") ), xAttributes ) && + bChecked) { - // has "checked" attribute - nVal = (bChecked ? 1 : 0); + nVal = 1; } - else - { - nVal = (bTriState ? 2 : 0); // if tristate set, but checked omitted => dont know! - } - xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ), makeAny( nVal ) ); @@ -1510,79 +1496,52 @@ void WindowElement::endElement() throw (xml::sax::SAXException, RuntimeException) { Reference< beans::XPropertySet > xProps( _pImport->_xDialogModel, UNO_QUERY ); - OSL_ASSERT( xProps.is() ); + ImportContext ctx( xProps ); - OUString aValue( _xAttributes->getValueByUidName( - XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("id") ) ) ); - if (aValue.getLength()) - { - xProps->setPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ), - makeAny( aValue ) ); - } - aValue = _xAttributes->getValueByUidName( - XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("title") ) ); - if (aValue.getLength()) + Reference< xml::XImportContext > xStyle( getStyle( _xAttributes ) ); + if (xStyle.is()) { - xProps->setPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), - makeAny( aValue ) ); + StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () ); + pStyle->importBackgroundColorStyle( xProps ); + pStyle->importBorderStyle( xProps ); + pStyle->importFontStyle( xProps ); } - sal_Int32 nLong; - - if (getLongAttr( &nLong, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ), _xAttributes )) - { - xProps->setPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ), - makeAny( nLong ) ); - } - if (getLongAttr( &nLong, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ), _xAttributes )) - { - xProps->setPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ), - makeAny( nLong ) ); - } - if (getLongAttr( &nLong, OUString( RTL_CONSTASCII_USTRINGPARAM("width") ), _xAttributes )) - { - xProps->setPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), - makeAny( nLong ) ); - } - if (getLongAttr( &nLong, OUString( RTL_CONSTASCII_USTRINGPARAM("height") ), _xAttributes )) - { - xProps->setPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), - makeAny( nLong ) ); - } + ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("id") ), + _xAttributes ); + ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("title") ), + _xAttributes ); + ctx.importLongProperty( 0, + OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("left") ), + _xAttributes ); + ctx.importLongProperty( 0, + OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("top") ), + _xAttributes ); + ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("width") ), + _xAttributes ); + ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("height") ), + _xAttributes ); + sal_Int32 nLong; if (! getLongAttr( &nLong, OUString( RTL_CONSTASCII_USTRINGPARAM("page") ), _xAttributes )) { nLong = 0; } - xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ), makeAny( nLong ) ); - aValue = _xAttributes->getValueByUidName( - XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("tag") ) ); - if (aValue.getLength()) - { - xProps->setPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ), - makeAny( aValue ) ); - } + ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("tag") ), + _xAttributes ); - aValue = _xAttributes->getValueByUidName( - XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("helptext") ) ); - if (aValue.getLength()) - { - xProps->setPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ), - makeAny( aValue ) ); - } + ctx.importEvents( _events ); } - }; diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx index 4907aefcf070..64522952e4cf 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_import.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: dbo $ $Date: 2001-03-28 10:50:37 $ + * last change: $Author: dbo $ $Date: 2001-04-04 14:35:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,7 +64,7 @@ #include <rtl/ustrbuf.hxx> -#include <xmlscript/xml_helper.hxx> +#include <xmlscript/xml_import.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/awt/CharSet.hpp> @@ -582,7 +582,7 @@ bool StyleElement::importFontStyle( //################################################################################################## //__________________________________________________________________________________________________ -bool ControlImportContext::importStringProperty( +bool ImportContext::importStringProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) { @@ -595,7 +595,7 @@ bool ControlImportContext::importStringProperty( return false; } //__________________________________________________________________________________________________ -bool ControlImportContext::importDoubleProperty( +bool ImportContext::importDoubleProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) { @@ -608,7 +608,7 @@ bool ControlImportContext::importDoubleProperty( return false; } //__________________________________________________________________________________________________ -bool ControlImportContext::importBooleanProperty( +bool ImportContext::importBooleanProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) { @@ -621,7 +621,7 @@ bool ControlImportContext::importBooleanProperty( return false; } //__________________________________________________________________________________________________ -bool ControlImportContext::importLongProperty( +bool ImportContext::importLongProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) { @@ -634,7 +634,7 @@ bool ControlImportContext::importLongProperty( return false; } //__________________________________________________________________________________________________ -bool ControlImportContext::importLongProperty( +bool ImportContext::importLongProperty( sal_Int32 nOffset, OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) @@ -648,7 +648,7 @@ bool ControlImportContext::importLongProperty( return false; } //__________________________________________________________________________________________________ -bool ControlImportContext::importShortProperty( +bool ImportContext::importShortProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) { @@ -661,7 +661,7 @@ bool ControlImportContext::importShortProperty( return false; } //__________________________________________________________________________________________________ -bool ControlImportContext::importAlignProperty( +bool ImportContext::importAlignProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) { @@ -698,7 +698,7 @@ bool ControlImportContext::importAlignProperty( return false; } //__________________________________________________________________________________________________ -bool ControlImportContext::importDateFormatProperty( +bool ImportContext::importDateFormatProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) { @@ -767,7 +767,7 @@ bool ControlImportContext::importDateFormatProperty( return false; } //__________________________________________________________________________________________________ -bool ControlImportContext::importTimeFormatProperty( +bool ImportContext::importTimeFormatProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) { @@ -812,6 +812,53 @@ bool ControlImportContext::importTimeFormatProperty( return false; } //__________________________________________________________________________________________________ +void ImportContext::importEvents( + vector< Reference< xml::sax2::XExtendedAttributes > > const & rEvents ) +{ + Reference< script::XScriptEventsSupplier > xSupplier( _xControlModel, UNO_QUERY ); + if (xSupplier.is()) + { + Reference< container::XNameContainer > xEvents( xSupplier->getEvents() ); + if (xEvents.is()) + { + for ( size_t nPos = 0; nPos < rEvents.size(); ++nPos ) + { + script::ScriptEventDescriptor descr; + Reference< xml::sax2::XExtendedAttributes > xEvent( rEvents[ nPos ] ); + + if (!getStringAttr( &descr.ListenerType, + OUString( RTL_CONSTASCII_USTRINGPARAM("listener-type") ), + xEvent ) || + !getStringAttr( &descr.EventMethod, + OUString( RTL_CONSTASCII_USTRINGPARAM("event-method") ), + xEvent )) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type | event attribute(s)!") ), + Reference< XInterface >(), Any() ); + } + + getStringAttr( &descr.ScriptType, + OUString( RTL_CONSTASCII_USTRINGPARAM("script-type") ), + xEvent ); + getStringAttr( &descr.ScriptCode, + OUString( RTL_CONSTASCII_USTRINGPARAM("script-code") ), + xEvent ); + getStringAttr( &descr.AddListenerParam, + OUString( RTL_CONSTASCII_USTRINGPARAM("param") ), + xEvent ); + + OUStringBuffer buf( 32 ); + buf.append( descr.ListenerType ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") ); + buf.append( descr.EventMethod ); + + xEvents->insertByName( buf.makeStringAndClear(), makeAny( descr ) ); + } + } + } +} +//__________________________________________________________________________________________________ void ControlImportContext::importDefaults( sal_Int32 nBaseX, sal_Int32 nBaseY, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) @@ -869,55 +916,11 @@ void ControlImportContext::importDefaults( OUString( RTL_CONSTASCII_USTRINGPARAM("tag") ), xAttributes ); importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ), - OUString( RTL_CONSTASCII_USTRINGPARAM("helptext") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("help-text") ), + xAttributes ); + importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("help-url") ), xAttributes ); -} -//__________________________________________________________________________________________________ -void ControlImportContext::importEvents( - vector< Reference< xml::sax2::XExtendedAttributes > > const & rEvents ) -{ - Reference< script::XScriptEventsSupplier > xSupplier( _xControlModel, UNO_QUERY ); - if (xSupplier.is()) - { - Reference< container::XNameContainer > xEvents( xSupplier->getEvents() ); - if (xEvents.is()) - { - for ( size_t nPos = 0; nPos < rEvents.size(); ++nPos ) - { - script::ScriptEventDescriptor descr; - Reference< xml::sax2::XExtendedAttributes > xEvent( rEvents[ nPos ] ); - - if (!getStringAttr( &descr.ListenerType, - OUString( RTL_CONSTASCII_USTRINGPARAM("listener-type") ), - xEvent ) || - !getStringAttr( &descr.EventMethod, - OUString( RTL_CONSTASCII_USTRINGPARAM("event-method") ), - xEvent )) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type | event attribute(s)!") ), - Reference< XInterface >(), Any() ); - } - - getStringAttr( &descr.ScriptType, - OUString( RTL_CONSTASCII_USTRINGPARAM("script-type") ), - xEvent ); - getStringAttr( &descr.ScriptCode, - OUString( RTL_CONSTASCII_USTRINGPARAM("script-code") ), - xEvent ); - getStringAttr( &descr.AddListenerParam, - OUString( RTL_CONSTASCII_USTRINGPARAM("param") ), - xEvent ); - - OUStringBuffer buf( 32 ); - buf.append( descr.ListenerType ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") ); - buf.append( descr.EventMethod ); - - xEvents->insertByName( buf.makeStringAndClear(), makeAny( descr ) ); - } - } - } } //################################################################################################## |