further impl

This commit is contained in:
Daniel Boelzle 2001-02-20 15:51:32 +00:00
parent d926e6be6d
commit 743e30840e
6 changed files with 412 additions and 117 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: exp_share.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: dbo $ $Date: 2001-02-20 14:05:25 $
* last change: $Author: dbo $ $Date: 2001-02-20 16:51:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -158,6 +158,9 @@ public:
inline void addAttr( OUString const & rAttrName, OUString const & rValue );
inline void addBoolAttr( OUString const & rAttrName, sal_Bool bValue );
//
void addEvents()
throw (Exception);
//
void readButtonModel( StyleBag * all_styles )
throw (Exception);

View file

@ -2,9 +2,9 @@
*
* $RCSfile: imp_share.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: dbo $ $Date: 2001-02-20 14:05:25 $
* last change: $Author: dbo $ $Date: 2001-02-20 16:51:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -311,14 +311,20 @@ public:
class ControlElement
: public ElementBase
{
friend class EventElement;
protected:
sal_Int32 _nBasePosX, _nBasePosY;
vector< Reference< xml::sax2::XExtendedAttributes > > _events;
OUString getControlId(
Reference< xml::sax2::XExtendedAttributes > const & xAttributes );
Reference< xml::XImportContext > getStyle(
Reference< xml::sax2::XExtendedAttributes > const & xAttributes );
public:
vector< Reference< xml::sax2::XExtendedAttributes > > const * getEvents() throw ()
{ return &_events; }
ControlElement(
OUString const & rLocalName,
@ -347,6 +353,9 @@ public:
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 );
@ -371,7 +380,6 @@ public:
OUString const & rPropName, OUString const & rAttrName,
Reference< xml::sax2::XExtendedAttributes > const & xAttributes );
};
//==================================================================================================
class WindowElement
: public ControlElement
@ -393,6 +401,22 @@ public:
{}
};
//==================================================================================================
class EventElement
: public ElementBase
{
public:
virtual void SAL_CALL endElement()
throw (xml::sax::SAXException, RuntimeException);
EventElement(
OUString const & rLocalName,
Reference< xml::sax2::XExtendedAttributes > const & xAttributes,
ElementBase * pParent, DialogImport * pImport )
throw ()
: ElementBase( rLocalName, xAttributes, pParent, pImport )
{}
};
//==================================================================================================
class BulletinBoardElement
: public ControlElement
{
@ -491,7 +515,7 @@ public:
{}
};
//==================================================================================================
class RadioGroupElement
class RadioElement
: public ControlElement
{
public:
@ -500,6 +524,27 @@ public:
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
throw (xml::sax::SAXException, RuntimeException);
RadioElement(
OUString const & rLocalName,
Reference< xml::sax2::XExtendedAttributes > const & xAttributes,
ElementBase * pParent, DialogImport * pImport )
throw ()
: ControlElement( rLocalName, xAttributes, pParent, pImport )
{}
};
//==================================================================================================
class RadioGroupElement
: public ControlElement
{
vector< Reference< xml::XImportContext > > _radios;
public:
virtual Reference< xml::XImportContext > SAL_CALL createChildContext(
sal_Int32 nUid, OUString const & rLocalName,
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
throw (xml::sax::SAXException, RuntimeException);
void SAL_CALL endElement()
throw (xml::sax::SAXException, RuntimeException);
RadioGroupElement(
OUString const & rLocalName,
Reference< xml::sax2::XExtendedAttributes > const & xAttributes,
@ -513,7 +558,7 @@ class TitledBoxElement
: public BulletinBoardElement
{
OUString _label;
vector< Reference< xml::sax2::XExtendedAttributes > > _radios;
vector< Reference< xml::XImportContext > > _radios;
public:
virtual Reference< xml::XImportContext > SAL_CALL createChildContext(
sal_Int32 nUid, OUString const & rLocalName,
@ -531,6 +576,26 @@ public:
{}
};
//==================================================================================================
class TextElement
: public ControlElement
{
public:
virtual Reference< xml::XImportContext > SAL_CALL createChildContext(
sal_Int32 nUid, OUString const & rLocalName,
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
throw (xml::sax::SAXException, RuntimeException);
virtual void SAL_CALL endElement()
throw (xml::sax::SAXException, RuntimeException);
TextElement(
OUString const & rLocalName,
Reference< xml::sax2::XExtendedAttributes > const & xAttributes,
ElementBase * pParent, DialogImport * pImport )
throw ()
: ControlElement( rLocalName, xAttributes, pParent, pImport )
{}
};
//==================================================================================================
class TextFieldElement
: public ControlElement
{

View file

@ -2,9 +2,9 @@
*
* $RCSfile: xmldlg_export.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: dbo $ $Date: 2001-02-20 14:05:25 $
* last change: $Author: dbo $ $Date: 2001-02-20 16:51:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -74,6 +74,9 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/script/XScriptEventsSupplier.hpp>
#include <com/sun/star/script/ScriptEventDescriptor.hpp>
namespace xmlscript
{
@ -614,6 +617,65 @@ void ElementDescriptor::readDefaults()
readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ),
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ) );
}
//__________________________________________________________________________________________________
void ElementDescriptor::addEvents()
throw (Exception)
{
Reference< script::XScriptEventsSupplier > xSupplier( _xProps, UNO_QUERY );
if (xSupplier.is())
{
Reference< container::XNameContainer > xEvents( xSupplier->getEvents() );
if (xEvents.is())
{
Sequence< OUString > aNames( xEvents->getElementNames() );
OUString const * pNames = aNames.getConstArray();
for ( sal_Int32 nPos = 0; nPos < aNames.getLength(); ++nPos )
{
script::ScriptEventDescriptor descr;
if (xEvents->getByName( pNames[ nPos ] ) >>= descr)
{
ElementDescriptor * pElem = new ElementDescriptor(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":event") ) );
Reference< xml::sax::XAttributeList > xElem( pElem );
OSL_ENSURE( descr.ListenerType.getLength() > 0 &&
descr.EventMethod.getLength() > 0,
"### invalid listener/ event method descr!" );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":listener-type") ),
descr.ListenerType );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":event-method") ),
descr.EventMethod );
if (descr.ScriptType.getLength())
{
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":script-type") ),
descr.ScriptType );
}
if (descr.ScriptCode.getLength())
{
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":script-code") ),
descr.ScriptCode );
}
if (descr.AddListenerParam.getLength())
{
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":param") ),
descr.AddListenerParam );
}
addSubElem( xElem );
}
else
{
OSL_ENSURE( 0, "### unexpected event type in container!" );
}
}
}
}
}
//##################################################################################################
@ -806,9 +868,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radio") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readRadioButtonModel( &all_styles );
pElem->addEvents();
pRadioGroup->addSubElem( xElem );
}
else // no radio
@ -821,9 +884,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readButtonModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ))
{
@ -831,9 +895,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checkbox") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readCheckBoxModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ))
{
@ -841,9 +906,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readComboBoxModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ))
{
@ -851,9 +917,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readListBoxModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ))
{
@ -861,9 +928,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":titledbox") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readGroupBoxModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ))
{
@ -871,9 +939,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readFixedTextModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlEditModel") ))
{
@ -881,9 +950,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textfield") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readEditModel( &all_styles );
pElem->addEvents();
}
@ -895,9 +965,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readCurrencyFieldModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") ))
{
@ -905,9 +976,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readDateFieldModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ))
{
@ -915,9 +987,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readFileControlModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ))
{
@ -925,9 +998,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readImageControlModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") ))
{
@ -935,9 +1009,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readNumericFieldModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") ))
{
@ -945,9 +1020,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readPatternFieldModel( &all_styles );
pElem->addEvents();
}
else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") ))
{
@ -955,9 +1031,10 @@ void exportDialogModel(
xProps, xPropState,
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) );
xElem = static_cast< xml::sax::XAttributeList * >( pElem );
pElem->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
rName );
pElem->addAttr(
OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), rName );
pElem->readTimeFieldModel( &all_styles );
pElem->addEvents();
}
//

View file

@ -2,9 +2,9 @@
*
* $RCSfile: xmldlg_impmodels.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: dbo $ $Date: 2001-02-20 14:05:25 $
* last change: $Author: dbo $ $Date: 2001-02-20 16:51:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -72,6 +72,67 @@ namespace xmlscript
//##################################################################################################
// fixed text
//__________________________________________________________________________________________________
Reference< xml::XImportContext > TextElement::createChildContext(
sal_Int32 nUid, OUString const & rLocalName,
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
throw (xml::sax::SAXException, RuntimeException)
{
if (XMLNS_DIALOGS_UID != nUid)
{
throw xml::sax::SAXException(
OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
Reference< XInterface >(), Any() );
}
// event
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
{
return new EventElement( rLocalName, xAttributes, this, _pImport );
}
else
{
throw xml::sax::SAXException(
OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
Reference< XInterface >(), Any() );
}
}
//__________________________________________________________________________________________________
void TextElement::endElement()
throw (xml::sax::SAXException, RuntimeException)
{
ControlImportContext ctx(
_pImport, getControlId( _xAttributes ),
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) );
Reference< xml::XImportContext > xStyle( getStyle( _xAttributes ) );
if (xStyle.is())
{
StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
pStyle->importBackgroundColorStyle( xControlModel );
pStyle->importTextColorStyle( xControlModel );
pStyle->importBorderStyle( xControlModel );
pStyle->importFontStyle( xControlModel );
}
ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
_xAttributes );
ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
_xAttributes );
ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
_xAttributes );
ctx.importEvents( _events );
}
//##################################################################################################
// edit
//__________________________________________________________________________________________________
Reference< xml::XImportContext > TextFieldElement::createChildContext(
@ -85,11 +146,11 @@ Reference< xml::XImportContext > TextFieldElement::createChildContext(
OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
Reference< XInterface >(), Any() );
}
// // event
// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
// {
// return new EventElement( rLocalName, xAttributes, this, _pImport );
// }
// event
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
{
return new EventElement( rLocalName, xAttributes, this, _pImport );
}
else
{
throw xml::sax::SAXException(
@ -151,6 +212,8 @@ void TextFieldElement::endElement()
xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("EchoChar") ),
makeAny( nChar ) );
}
ctx.importEvents( _events );
}
//##################################################################################################
@ -180,14 +243,16 @@ Reference< xml::XImportContext > TitledBoxElement::createChildContext(
{
// dont create radios here, => titledbox must be inserted first due to radio grouping,
// possible predecessors!
_radios.push_back( xAttributes );
return new ElementBase( rLocalName, xAttributes, this, _pImport );
Reference< xml::XImportContext > xRet(
new RadioElement( rLocalName, xAttributes, this, _pImport ) );
_radios.push_back( xRet );
return xRet;
}
// event
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
{
return new EventElement( rLocalName, xAttributes, this, _pImport );
}
// // event
// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
// {
// return new EventElement( rLocalName, xAttributes, this, _pImport );
// }
else
{
return BulletinBoardElement::createChildContext( nUid, rLocalName, xAttributes );
@ -244,7 +309,9 @@ void TitledBoxElement::endElement()
// create radios AFTER group box!
for ( size_t nPos = 0; nPos < _radios.size(); ++nPos )
{
Reference< xml::sax2::XExtendedAttributes > xAttributes( _radios[ nPos ] );
Reference< xml::XImportContext > xRadio( _radios[ nPos ] );
Reference< xml::sax2::XExtendedAttributes > xAttributes( xRadio->getAttributes() );
ControlImportContext ctx(
_pImport, getControlId( xAttributes ),
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) );
@ -280,6 +347,36 @@ void TitledBoxElement::endElement()
xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ),
makeAny( nVal ) );
ctx.importEvents( * static_cast< RadioElement * >( xRadio.get() )->getEvents() );
}
}
//##################################################################################################
// radio
//__________________________________________________________________________________________________
Reference< xml::XImportContext > RadioElement::createChildContext(
sal_Int32 nUid, OUString const & rLocalName,
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
throw (xml::sax::SAXException, RuntimeException)
{
if (XMLNS_DIALOGS_UID != nUid)
{
throw xml::sax::SAXException(
OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
Reference< XInterface >(), Any() );
}
// event
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
{
return new EventElement( rLocalName, xAttributes, this, _pImport );
}
else
{
throw xml::sax::SAXException(
OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
Reference< XInterface >(), Any() );
}
}
@ -301,6 +398,29 @@ Reference< xml::XImportContext > RadioGroupElement::createChildContext(
// radio
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("radio") ))
{
// dont create radios here, => titledbox must be inserted first due to radio grouping,
// possible predecessors!
Reference< xml::XImportContext > xRet(
new RadioElement( rLocalName, xAttributes, this, _pImport ) );
_radios.push_back( xRet );
return xRet;
}
else
{
throw xml::sax::SAXException(
OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
Reference< XInterface >(), Any() );
}
}
//__________________________________________________________________________________________________
void RadioGroupElement::endElement()
throw (xml::sax::SAXException, RuntimeException)
{
for ( size_t nPos = 0; nPos < _radios.size(); ++nPos )
{
Reference< xml::XImportContext > xRadio( _radios[ nPos ] );
Reference< xml::sax2::XExtendedAttributes > xAttributes( xRadio->getAttributes() );
ControlImportContext ctx(
_pImport, getControlId( xAttributes ),
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) );
@ -337,18 +457,7 @@ Reference< xml::XImportContext > RadioGroupElement::createChildContext(
xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ),
makeAny( nVal ) );
return new ElementBase( rLocalName, xAttributes, this, _pImport );
}
// // event
// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
// {
// return new EventElement( rLocalName, xAttributes, this, _pImport );
// }
else
{
throw xml::sax::SAXException(
OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
Reference< XInterface >(), Any() );
ctx.importEvents( * static_cast< RadioElement * >( xRadio.get() )->getEvents() );
}
}
@ -437,11 +546,11 @@ Reference< xml::XImportContext > MenuListElement::createChildContext(
_popup = new MenuPopupElement( rLocalName, xAttributes, this, _pImport );
return _popup;
}
// // event
// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
// {
// return new EventElement( rLocalName, xAttributes, this, _pImport );
// }
// event
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
{
return new EventElement( rLocalName, xAttributes, this, _pImport );
}
else
{
throw xml::sax::SAXException(
@ -485,6 +594,8 @@ void MenuListElement::endElement()
makeAny( p->getItemValues() ) );
xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ),
makeAny( p->getSelectedItems() ) );
ctx.importEvents( _events );
}
//##################################################################################################
@ -508,11 +619,11 @@ Reference< xml::XImportContext > ComboBoxElement::createChildContext(
_popup = new MenuPopupElement( rLocalName, xAttributes, this, _pImport );
return _popup;
}
// // event
// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
// {
// return new EventElement( rLocalName, xAttributes, this, _pImport );
// }
// event
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
{
return new EventElement( rLocalName, xAttributes, this, _pImport );
}
else
{
throw xml::sax::SAXException(
@ -564,6 +675,8 @@ void ComboBoxElement::endElement()
ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
_xAttributes );
ctx.importEvents( _events );
}
//##################################################################################################
@ -581,11 +694,11 @@ Reference< xml::XImportContext > CheckBoxElement::createChildContext(
OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
Reference< XInterface >(), Any() );
}
// // event
// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
// {
// return new EventElement( rLocalName, xAttributes, this, _pImport );
// }
// event
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
{
return new EventElement( rLocalName, xAttributes, this, _pImport );
}
else
{
throw xml::sax::SAXException(
@ -636,6 +749,8 @@ void CheckBoxElement::endElement()
xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ),
makeAny( nVal ) );
}
ctx.importEvents( _events );
}
//##################################################################################################
@ -653,11 +768,11 @@ Reference< xml::XImportContext > ButtonElement::createChildContext(
OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
Reference< XInterface >(), Any() );
}
// // event
// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
// {
// return new EventElement( rLocalName, xAttributes, this, _pImport );
// }
// event
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
{
return new EventElement( rLocalName, xAttributes, this, _pImport );
}
else
{
throw xml::sax::SAXException(
@ -691,6 +806,8 @@ void ButtonElement::endElement()
ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultButton") ),
OUString( RTL_CONSTASCII_USTRINGPARAM("default") ),
_xAttributes );
ctx.importEvents( _events );
}
//##################################################################################################
@ -741,34 +858,7 @@ Reference< xml::XImportContext > BulletinBoardElement::createChildContext(
// text
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("text") ))
{
ControlImportContext ctx(
_pImport, getControlId( xAttributes ),
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) );
Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
Reference< xml::XImportContext > xStyle( getStyle( xAttributes ) );
if (xStyle.is())
{
StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
pStyle->importBackgroundColorStyle( xControlModel );
pStyle->importTextColorStyle( xControlModel );
pStyle->importBorderStyle( xControlModel );
pStyle->importFontStyle( xControlModel );
}
ctx.importDefaults( _nBasePosX, _nBasePosY, xAttributes );
ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
xAttributes );
ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
xAttributes );
ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
xAttributes );
// dummy
return new ElementBase( rLocalName, xAttributes, this, _pImport );
return new TextElement( rLocalName, xAttributes, this, _pImport );
}
// textfield
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("textfield") ))

View file

@ -2,9 +2,9 @@
*
* $RCSfile: xmldlg_import.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: dbo $ $Date: 2001-02-20 14:05:25 $
* last change: $Author: dbo $ $Date: 2001-02-20 16:51:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -77,12 +77,21 @@
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/awt/FontWidth.hpp>
#include <com/sun/star/script/XScriptEventsSupplier.hpp>
#include <com/sun/star/script/ScriptEventDescriptor.hpp>
using namespace ::osl;
namespace xmlscript
{
//__________________________________________________________________________________________________
void EventElement::endElement()
throw (xml::sax::SAXException, RuntimeException)
{
static_cast< ControlElement * >( _pParent )->_events.push_back( _xAttributes );
}
//__________________________________________________________________________________________________
ControlElement::ControlElement(
OUString const & rLocalName,
@ -712,6 +721,53 @@ void ControlImportContext::importDefaults(
OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
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.ScriptType,
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 ) );
}
}
}
}
//##################################################################################################

View file

@ -13,7 +13,11 @@
<button dlg:id="button1" ns:value="hallo" dlg:left="50" ns:top="50" width="50" height="50"
style-id="bla3"
xmlns:ns="http://openoffice.org/2000/dialog"/>
xmlns:ns="http://openoffice.org/2000/dialog">
<event listener-type="type" event-method="clicked"
script-type="basic" script-code="code" param="testi"/>
</button>
<button dlg:id="button3" ns:value="hallo2" dlg:left="250" ns:top="50" width="50" height="50"
style-id="bla"