22 #include <com/sun/star/uno/Reference.hxx>
23 #include <com/sun/star/frame/XModule.hpp>
24 #include <com/sun/star/xforms/Model.hpp>
25 #include <com/sun/star/xforms/XModel2.hpp>
26 #include <com/sun/star/xforms/XFormsUIHelper1.hpp>
27 #include <com/sun/star/xforms/XForms.hpp>
29 #include <osl/diagnose.h>
30 #include <com/sun/star/container/XIndexAccess.hpp>
38 using xforms::XModel2;
40 using xforms::XFormsUIHelper1;
41 using com::sun::star::container::XIndexAccess;
51 OSL_ENSURE( !
isXForms(),
"please initialize only once" );
59 Reference< XModule > xModule;
62 xModule.set(pShell->
GetModel(), css::uno::UNO_QUERY);
63 OSL_ENSURE( xModule.is(),
"SwDoc::initXForms: no XModule at the document!" );
65 xModule->setIdentifier(
"com.sun.star.xforms.XMLFormDocument" );
68 if( bCreateDefaultModel &&
mxXForms.is() )
70 OUString
sName(
"Model 1");
72 xModel->setID( sName );
73 Reference<XFormsUIHelper1>( xModel, uno::UNO_QUERY_THROW )->newInstance(
78 OSL_ENSURE(
mxXForms->hasElements(),
"can't create XForms model" );
81 OSL_ENSURE(
isXForms(),
"initialization failed" );
96 const uno::Sequence<OUString> aNames =
mxXForms->getElementNames();
97 for(
const OUString& rName : aNames )
99 Reference< xforms::XModel >
xModel(
100 mxXForms->getByName( rName ), UNO_QUERY );
105 Reference< XIndexAccess > xBindings(
106 xModel->getBindings(), UNO_QUERY );
109 int nCount = xBindings->getCount();
110 for(
int i = nCount-1;
i >= 0;
i-- )
112 xModel->getBindings()->remove(xBindings->getByIndex(
i ));
116 Reference< XIndexAccess > xSubmissions(
117 xModel->getSubmissions(), UNO_QUERY );
120 nCount = xSubmissions->getCount();
121 for(
int i = nCount-1;
i >= 0;
i-- )
123 xModel->getSubmissions()->remove(xSubmissions->getByIndex(
i ));
SwDocShell * GetDocShell()
css::uno::Reference< css::frame::XModel > GetModel() const
css::uno::Reference< css::container::XNameContainer > mxXForms
void initXForms(bool bCreateDefaultModel)
Reference< XComponentContext > getProcessComponentContext()
Reference< XModel > xModel
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)