33#include <rtl/ustring.hxx>
34#include <rtl/ustrbuf.hxx>
44#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
45#include <com/sun/star/xml/dom/XDocument.hpp>
46#include <com/sun/star/xml/dom/XCharacterData.hpp>
47#include <com/sun/star/xml/dom/NodeType.hpp>
48#include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
49#include <com/sun/star/uno/Sequence.hxx>
50#include <com/sun/star/beans/PropertyValue.hpp>
51#include <com/sun/star/ucb/SimpleFileAccess.hpp>
52#include <com/sun/star/io/XInputStream.hpp>
56using com::sun::star::beans::PropertyValue;
57using com::sun::star::ucb::SimpleFileAccess;
58using com::sun::star::io::XInputStream;
65#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
66#define DBG_INVARIANT_TYPE(TYPE) class DBG_##TYPE { const TYPE* mpT; void check() { mpT->dbg_assertInvariant(); } public: DBG_##TYPE(const TYPE* pT) : mpT(pT) { check(); } ~DBG_##TYPE() { check(); } } _DBG_##TYPE(this);
68#define DBG_INVARIANT() DBG_INVARIANT_TYPE(Model)
70#define DBG_INVARIANT()
77void Model::ensureAtLeastOneInstance()
92 mbExternalData( true )
117 if( ! xElement.is() )
119 xElement.set( xInstance->createElement(
"instanceData" ), UNO_QUERY_THROW );
120 xInstance->appendChild( xElement );
123 OSL_ENSURE( xElement.is() &&
124 xElement->getNodeType() == NodeType_ELEMENT_NODE,
125 "no element in evaluation context" );
145 if( rNamespaces.is() )
155#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
168 OSL_ENSURE( pTag !=
nullptr,
"empty tag?" );
169 OSL_ENSURE( xNode.is(),
"no node" );
171 MIPs_t::value_type aValue( xNode, ::std::pair<void*,MIP>( pTag, rMIP ) );
177 OSL_ENSURE( pTag !=
nullptr,
"empty tag?" );
179 for( MIPs_t::iterator aIter =
maMIPs.begin();
182 if( aIter->second.first == pTag )
184 aIter =
maMIPs.erase( aIter );
197 xCurrent = xCurrent->getParentNode() )
201 MIPs_t::const_iterator aEnd =
maMIPs.upper_bound( xCurrent );
202 MIPs_t::const_iterator aIter =
maMIPs.lower_bound( xCurrent );
203 for( ; aIter != aEnd; ++aIter )
204 aMIP.
join( aIter->second.second );
207 if( xCurrent == xNode )
225 Binding* pBind = comphelper::getFromUnoTunnel<Binding>(
mxBindings->Collection<XPropertySet_t>::getItem(
i ) );
226 OSL_ENSURE( pBind !=
nullptr,
"binding?" );
238 Binding* pBind = comphelper::getFromUnoTunnel<Binding>(
mxBindings->Collection<XPropertySet_t>::getItem(
i ) );
239 OSL_ENSURE( pBind !=
nullptr,
"binding?" );
246 const OUString& sValue )
248 OSL_ENSURE( xConstNode.is(),
"need node to set data" );
251 if( xConstNode.is() )
256 switch( xNode->getNodeType() )
258 case NodeType_ELEMENT_NODE:
262 for( xChild = xNode->getFirstChild();
263 xChild.is() && xChild->getNodeType() != NodeType_TEXT_NODE;
264 xChild = xChild->getNextSibling() )
271 xNode->getOwnerDocument()->createTextNode( OUString() ),
273 xNode->appendChild( xChild );
277 OSL_ENSURE( xNode.is() &&
278 xNode->getNodeType() == NodeType_TEXT_NODE,
279 "text node creation failed?" );
283 case NodeType_TEXT_NODE:
284 case NodeType_ATTRIBUTE_NODE:
287 if( xNode->getNodeValue() != sValue )
290 xNode->setNodeValue( sValue );
299 OSL_FAIL(
"bound to unknown node type?" );
324 SimpleFileAccess::create( ::comphelper::getProcessComponentContext() )->openFileRead( sURL );
333 bOnce ? &
sEmpty : &sURL,
nullptr);
347 const sal_Int32 nInstances =
mxInstances->countItems();
348 for( sal_Int32 nInstance = 0; nInstance < nInstances; nInstance++ )
359 for( sal_Int32
i = 0; bValid &&
i <
nCount;
i++ )
361 Binding* pBind = comphelper::getFromUnoTunnel<Binding>(
mxBindings->Collection<XPropertySet_t>::getItem(
i ) );
362 OSL_ENSURE( pBind !=
nullptr,
"binding?" );
422 const css::uno::Reference<css::task::XInteractionHandler>& _rxHandler )
430 assert(pSubmission &&
"no submission?");
466 if( nInstance != -1 )
468 nullptr, &aInstance,
nullptr,
nullptr );
491css::uno::Reference<css::beans::XPropertySet>
Model::cloneBinding(
const css::uno::Reference<css::beans::XPropertySet>& xBinding )
495 copy( xBinding, xNewBinding );
521css::uno::Reference<css::xforms::XSubmission>
Model::cloneSubmission(
const css::uno::Reference<css::beans::XPropertySet>& xSubmission)
524 css::uno::Reference<css::xforms::XSubmission> xNewSubmission =
createSubmission();
526 copy( xSubmission, xAsPropertySet );
527 return xNewSubmission;
533 css::uno::Reference<css::xforms::XSubmission> xSubmission;
550#define HANDLE_ForeignSchema 3
551#define HANDLE_SchemaRef 4
552#define HANDLE_Namespaces 5
553#define HANDLE_ExternalData 6
559 registerProperty( css::beans::Property(
"ForeignSchema",
HANDLE_ForeignSchema,
cppu::UnoType<css::uno::Reference<css::xml::dom::XDocument>>::get(), css::beans::PropertyAttribute::BOUND ),
565 registerProperty( css::beans::Property(
"Namespaces",
HANDLE_Namespaces,
cppu::UnoType<css::uno::Reference<css::container::XNameContainer>>::get(), css::beans::PropertyAttribute::BOUND ),
580 return css::uno::Sequence<sal_Int8>();
585 return "com.sun.star.form.Model";
595 return {
"com.sun.star.xforms.Model"};
598extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
600 css::uno::Sequence<css::uno::Any>
const &)
helper class for implementing property accessors via UNO methods
helper class for implementing non-UNO accessors to a boolean property
helper class for implementing property accessors via non-UNO methods
define the context for the evaluation of an XPath expression
#define DBG_ASSERT(sCon, aError)
#define HANDLE_Namespaces
#define HANDLE_ExternalData
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_form_Model_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
#define HANDLE_ForeignSchema
class SAL_NO_VTABLE XPropertySet
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Reference< XDocumentBuilder > getDocumentBuilder()