Kaydet (Commit) aee9de28 authored tarafından Vladimir Glazounov's avatar Vladimir Glazounov

INTEGRATION: CWS eforms4 (1.2.6); FILE MERGED

2004/12/29 10:53:12 fs 1.2.6.5: renamed a method
2004/12/28 09:39:26 fs 1.2.6.4: #i39451# derive from another PropertySet helper class, which also allows listener handling
2004/12/15 12:01:50 mbu 1.2.6.3: .
2004/12/15 11:03:18 dvo 1.2.6.2: #i35397# use model namespaces (when possible)
Issue number:
Submitted by:
Reviewed by:
2004/12/14 16:08:28 dvo 1.2.6.1: #i36765# use Interaction Handler for submission warning & submission itself
Issue number:
Submitted by:
Reviewed by:
üst 76ad7bf7
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: model.cxx,v $ * $RCSfile: model.cxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: obo $ $Date: 2004-11-16 10:53:47 $ * last change: $Author: vg $ $Date: 2005-03-23 11:37:03 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#include "evaluationcontext.hxx" #include "evaluationcontext.hxx"
#include "xmlhelper.hxx" #include "xmlhelper.hxx"
#include "datatyperepository.hxx" #include "datatyperepository.hxx"
#include "NameContainer.hxx"
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
...@@ -89,7 +90,6 @@ ...@@ -89,7 +90,6 @@
#include <com/sun/star/xml/dom/XDocumentBuilder.hpp> #include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
#include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XInputStream.hpp>
...@@ -149,9 +149,10 @@ Model::Model() : ...@@ -149,9 +149,10 @@ Model::Model() :
mxBindings( mpBindings ), mxBindings( mpBindings ),
mxSubmissions( mpSubmissions ), mxSubmissions( mpSubmissions ),
mxInstances( mpInstances ), mxInstances( mpInstances ),
mxNamespaces( new NameContainer<OUString>() ),
mbInitialized( false ) mbInitialized( false )
{ {
setInfo( _getPropertySetInfo() ); initializePropertySet();
// initialize bindings collections // initialize bindings collections
// (not in initializer list to avoid use of incomplete 'this') // (not in initializer list to avoid use of incomplete 'this')
...@@ -206,7 +207,8 @@ EvaluationContext Model::getEvaluationContext() ...@@ -206,7 +207,8 @@ EvaluationContext Model::getEvaluationContext()
OSL_ENSURE( xElement.is() && OSL_ENSURE( xElement.is() &&
xElement->getNodeType() == NodeType_ELEMENT_NODE, xElement->getNodeType() == NodeType_ELEMENT_NODE,
"no element in evaluation context" ); "no element in evaluation context" );
return EvaluationContext( xElement, this, 0, 1 );
return EvaluationContext( xElement, this, mxNamespaces, 0, 1 );
} }
...@@ -236,6 +238,17 @@ void Model::setSchemaRef( const rtl::OUString& rSchemaRef ) ...@@ -236,6 +238,17 @@ void Model::setSchemaRef( const rtl::OUString& rSchemaRef )
msSchemaRef = rSchemaRef; msSchemaRef = rSchemaRef;
} }
Model::XNameContainer_t Model::getNamespaces() const
{
return mxNamespaces;
}
void Model::setNamespaces( const XNameContainer_t& rNamespaces )
{
if( rNamespaces.is() )
mxNamespaces = rNamespaces;
}
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
void Model::dbg_assertInvariant() const void Model::dbg_assertInvariant() const
...@@ -501,6 +514,20 @@ bool Model::isInitialized() const ...@@ -501,6 +514,20 @@ bool Model::isInitialized() const
return mbInitialized; return mbInitialized;
} }
bool Model::isValid() const
{
bool bValid = true;
sal_Int32 nCount = mpBindings->countItems();
for( sal_Int32 i = 0; bValid && i < nCount; i++ )
{
Binding* pBind = Binding::getBinding( mpBindings->Collection<XPropertySet_t>::getItem( i ) );
OSL_ENSURE( pBind != NULL, "binding?" );
bValid = pBind->isValid();
}
return bValid;
}
// //
// implement xforms::XModel // implement xforms::XModel
...@@ -561,15 +588,15 @@ void Model::refresh() ...@@ -561,15 +588,15 @@ void Model::refresh()
} }
void SAL_CALL Model::submitWithInteraction( const ::rtl::OUString& sID, const XInteraction_t& _rxHandler ) void SAL_CALL Model::submitWithInteraction(
throw( VetoException, WrappedTargetException, RuntimeException ) const rtl::OUString& sID,
const XInteractionHandler_t& _rxHandler )
throw( VetoException,
WrappedTargetException,
RuntimeException )
{ {
DBG_INVARIANT(); DBG_INVARIANT();
bool bResult = false;
try
{
// TODO: error handling!
if( mpSubmissions->hasItem( sID ) ) if( mpSubmissions->hasItem( sID ) )
{ {
Submission* pSubmission = Submission* pSubmission =
...@@ -577,27 +604,10 @@ void SAL_CALL Model::submitWithInteraction( const ::rtl::OUString& sID, const XI ...@@ -577,27 +604,10 @@ void SAL_CALL Model::submitWithInteraction( const ::rtl::OUString& sID, const XI
OSL_ENSURE( pSubmission != NULL, "no submission?" ); OSL_ENSURE( pSubmission != NULL, "no submission?" );
OSL_ENSURE( pSubmission->getModel() == Reference<XModel>( this ), OSL_ENSURE( pSubmission->getModel() == Reference<XModel>( this ),
"wrong model" ); "wrong model" );
bResult = pSubmission->doSubmit( _rxHandler );
}
}
catch( const RuntimeException& )
{
// allowed to leave
throw;
}
catch( const VetoException& )
{
OSL_ENSURE( sal_False, "Model::submit: Hmm. How can a single submission have a veto right?" );
// allowed to leave
throw;
}
catch( const Exception& e )
{
throw WrappedTargetException( ::rtl::OUString::createFromAscii( "The submission failed. Sorry." ), *this, makeAny( e ) );
}
if( ! bResult ) // submit. All exceptions are allowed to leave.
throw WrappedTargetException( ::rtl::OUString::createFromAscii( "The submission failed. Sorry, no further info is available." ), *this, Any() ); pSubmission->submitWithInteraction( _rxHandler );
}
} }
void Model::submit( const rtl::OUString& sID ) void Model::submit( const rtl::OUString& sID )
...@@ -741,99 +751,24 @@ Model::XSet_t Model::getSubmissions() ...@@ -741,99 +751,24 @@ Model::XSet_t Model::getSubmissions()
#define HANDLE_InstanceURL 2 #define HANDLE_InstanceURL 2
#define HANDLE_ForeignSchema 3 #define HANDLE_ForeignSchema 3
#define HANDLE_SchemaRef 4 #define HANDLE_SchemaRef 4
#define HANDLE_Namespaces 5
#define ENTRY_FLAGS(NAME,TYPE,FLAGS) { #NAME, sizeof(#NAME)-1, HANDLE_##NAME, &getCppuType(static_cast<TYPE*>(NULL)), FLAGS, 0 } #define REGISTER_PROPERTY( property, type ) \
#define ENTRY(NAME,TYPE) ENTRY_FLAGS(NAME,TYPE,0) registerProperty( PROPERTY( property, type ), \
#define ENTRY_RO(NAME,TYPE) ENTRY_FLAGS(NAME,TYPE,com::sun::star::beans::PropertyAttribute::READONLY) new DirectPropertyAccessor< Model, type >( this, &Model::set##property, &Model::get##property ) );
#define ENTRY_END { NULL, 0, NULL, 0, 0}
comphelper::PropertySetInfo* Model::_getPropertySetInfo()
{
static comphelper::PropertySetInfo* pInfo = NULL;
static comphelper::PropertyMapEntry pEntries[] = #define REGISTER_PROPERTY_API( property, type ) \
{ registerProperty( PROPERTY( property, type ), \
ENTRY( ID, OUString ), new APIPropertyAccessor< Model, type >( this, &Model::set##property, &Model::get##property ) );
ENTRY( ForeignSchema, XDocument_t ),
ENTRY( SchemaRef, OUString ),
ENTRY_END
};
if( pInfo == NULL ) void Model::initializePropertySet()
{
pInfo = new comphelper::PropertySetInfo( pEntries );
pInfo->acquire();
}
return pInfo;
}
void Model::_setPropertyValues(
const comphelper::PropertyMapEntry** ppEntries,
const Any_t* pValues )
throw( UnknownPropertyException,
PropertyVetoException,
IllegalArgumentException,
WrappedTargetException )
{
DBG_INVARIANT();
// iterate over all PropertyMapEntry/Any pairs
for( ; *ppEntries != NULL; ppEntries++, pValues++ )
{
// delegate each property to the suitable handler method
switch( (*ppEntries)->mnHandle )
{
case HANDLE_ID:
setAny( this, &Model::setID, *pValues );
break;
case HANDLE_ForeignSchema:
setAny( this, &Model::setForeignSchema, *pValues );
break;
case HANDLE_SchemaRef:
setAny( this, &Model::setSchemaRef, *pValues );
break;
default:
OSL_ENSURE( false, "Unknown HANDLE" );
break;
}
}
}
void Model::_getPropertyValues(
const comphelper::PropertyMapEntry** ppEntries,
Any_t* pValues )
throw( UnknownPropertyException,
WrappedTargetException )
{ {
DBG_INVARIANT(); REGISTER_PROPERTY_API( ID, OUString );
REGISTER_PROPERTY ( ForeignSchema, XDocument_t );
// iterate over all PropertyMapEntry/Any pairs REGISTER_PROPERTY ( SchemaRef, OUString );
for( ; *ppEntries != NULL; ppEntries++, pValues++ ) REGISTER_PROPERTY ( Namespaces, XNameContainer_t );
{
// delegate each property to the suitable handler method
switch( (*ppEntries)->mnHandle )
{
case HANDLE_ID:
getAny( this, &Model::getID, *pValues );
break;
case HANDLE_ForeignSchema:
getAny( this, &Model::getForeignSchema, *pValues );
break;
case HANDLE_SchemaRef:
getAny( this, &Model::getSchemaRef, *pValues );
break;
default:
OSL_ENSURE( false, "Unknown HANDLE" );
break;
}
}
} }
void Model::update() void Model::update()
throw( RuntimeException ) throw( RuntimeException )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment