30#include <rtl/ustring.hxx>
31#include <com/sun/star/lang/NoSupportException.hpp>
32#include <com/sun/star/uno/Sequence.hxx>
33#include <com/sun/star/uno/Reference.hxx>
34#include <com/sun/star/xforms/XModel.hpp>
35#include <com/sun/star/uno/RuntimeException.hpp>
36#include <com/sun/star/xml/dom/XNodeList.hpp>
37#include <com/sun/star/xml/dom/XDocument.hpp>
38#include <com/sun/star/xml/dom/DocumentBuilder.hpp>
39#include <com/sun/star/xml/dom/XDocumentFragment.hpp>
40#include <com/sun/star/xml/dom/NodeType.hpp>
41#include <com/sun/star/task/XInteractionHandler.hpp>
42#include <com/sun/star/task/XInteractionRequest.hpp>
43#include <com/sun/star/task/XInteractionContinuation.hpp>
44#include <com/sun/star/xforms/InvalidDataOnSubmitException.hpp>
45#include <com/sun/star/form/runtime/XFormController.hpp>
46#include <com/sun/star/frame/XFrame.hpp>
58using com::sun::star::util::VetoException;
59using com::sun::star::form::submission::XSubmissionVetoListener;
60using com::sun::star::lang::WrappedTargetException;
61using com::sun::star::lang::NoSupportException;
62using com::sun::star::task::XInteractionHandler;
63using com::sun::star::xforms::XModel;
64using com::sun::star::xforms::InvalidDataOnSubmitException;
65using com::sun::star::xml::xpath::XXPathObject;
66using com::sun::star::frame::XFrame;
75Submission::Submission() :
77 mbOmitXmlDeclaration(),
92 assert(
bool(
mxModel)==
bool(
xModel) &&
"we only support an instance of Model here");
199 if( pBinding !=
nullptr )
209 aEvalContext =
mxModel->getEvaluationContext();
214 aEvalContext =
mxModel->getEvaluationContext();
216 aExpression.
evaluate( aEvalContext );
218 OSL_ENSURE( xResult.is(),
"no result?" );
230 xResult, aMethod.equalsIgnoreAsciiCase(
"get"));
233 std::unique_ptr<CSubmission> xSubmission;
234 if (aMethod.equalsIgnoreAsciiCase(
"PUT"))
236 else if (aMethod.equalsIgnoreAsciiCase(
"post"))
238 else if (aMethod.equalsIgnoreAsciiCase(
"get"))
242 OSL_FAIL(
"Unsupported xforms submission method");
246 const INetURLObject& rURLObject = xSubmission->GetURLObject();
251 if (eProtocol != INetProtocol::Http && eProtocol != INetProtocol::Https)
253 if (eProtocol != INetProtocol::File)
261 OUString aFileName(rURLObject.
getFSysPath(FSysStyle::Detect));
263 VclMessageType::Question, VclButtonsType::YesNo,
265 xQueryBox->set_default_response(
RET_NO);
267 if (xQueryBox->run() !=
RET_YES)
288 throw RuntimeException();
303#define HANDLE_Action 3
304#define HANDLE_Method 4
305#define HANDLE_Version 5
306#define HANDLE_Indent 6
307#define HANDLE_MediaType 7
308#define HANDLE_Encoding 8
309#define HANDLE_OmitXmlDeclaration 9
310#define HANDLE_Standalone 10
311#define HANDLE_CDataSectionElement 11
312#define HANDLE_Replace 12
313#define HANDLE_Separator 13
314#define HANDLE_IncludeNamespacePrefixes 14
315#define HANDLE_Model 15
373 Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle,
const Any& rValue )
380 if ( rValue >>= sTokenList )
382 std::vector< OUString > aPrefixes;
385 aPrefixes.push_back( sTokenList.getToken( 0,
',',
p ) );
406static OUString
lcl_message( std::u16string_view rID, std::u16string_view rText )
408 OUString aMessage = OUString::Concat(
"XForms submission '") + rID +
"' failed" + rText +
".";
418 OUString sID(
msID );
421 throw RuntimeException(
422 "This is not a valid submission object.",
428 bool bValid =
xModel->isValid();
431 InvalidDataOnSubmitException aInvalidDataException(
434 if( _rxHandler.is() )
439 Any( aInvalidDataException ) );
443 pRequest->addContinuation( pContinue );
447 pRequest->addContinuation( pCancel );
450 _rxHandler->handle( pRequest );
451 OSL_ENSURE( pContinue->wasSelected() || pCancel->wasSelected(),
452 "handler didn't select" );
455 if( pContinue->wasSelected() )
461 throw aInvalidDataException;
465 bool bResult =
false;
470 catch(
const VetoException& )
472 OSL_FAIL(
"Model::submit: Hmm. How can a single submission have a veto right?" );
480 throw WrappedTargetException(
488 throw WrappedTargetException(
502 throw NoSupportException();
508 throw NoSupportException();
514 if (aNode->getNodeType() == NodeType_TEXT_NODE)
516 OUString aTrimmedValue = aNode->getNodeValue().trim();
517 if (aTrimmedValue.isEmpty())
return true;
526 if (!source.is())
return;
539 imported = dstDoc->importNode(cur,
false);
540 imported = dstParent->appendChild(imported);
542 for( cur = cur->getFirstChild(); cur.is(); cur = cur->getNextSibling() )
543 cloneNodes(aModel, imported, cur, bRemoveWSNodes);
548 using namespace css::xml::xpath;
552 if (aObj->getObjectType() == XPathObjectType_XPATH_NODESET)
555 if (aList->getLength() > 0)
556 aDocument = aList->item(0)->getOwnerDocument();
563 using namespace css::xml::xpath;
569 if (aObj->getObjectType() == XPathObjectType_XPATH_NODESET)
573 for (sal_Int32
i=0;
i < aList->getLength();
i++)
575 aListItem = aList->item(
i);
576 if (aListItem->getNodeType()==NodeType_DOCUMENT_NODE)
593 PropertySetBase::setPropertyValue( aPropertyName, aValue );
597 return PropertySetBase::getPropertyValue( PropertyName );
601 PropertySetBase::addPropertyChangeListener( aPropertyName, xListener );
605 PropertySetBase::removePropertyChangeListener( aPropertyName, aListener );
609 PropertySetBase::addVetoableChangeListener( PropertyName, aListener );
613 PropertySetBase::removeVetoableChangeListener( PropertyName, aListener );
constexpr OUStringLiteral sMediaType
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
helper class for implementing non-UNO accessors to a boolean property
helper class for implementing property accessors via non-UNO methods
INetProtocol GetProtocol() const
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
OPropertysetHelper methods.
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
define the context for the evaluation of an XPath expression
OInteraction< css::task::XInteractionDisapprove > OInteractionDisapprove
OInteraction< css::task::XInteractionApprove > OInteractionApprove
Reference< XComponentContext > getProcessComponentContext()
Any SAL_CALL getCaughtException()
OUString loadString(TranslateId aResId)
loads the string with the specified resource id from the FormLayer mo file
Reference< XModel > xModel
static bool isIgnorable(const Reference< XNode > &aNode)
#define HANDLE_IncludeNamespacePrefixes
#define HANDLE_OmitXmlDeclaration
#define HANDLE_Standalone
static void cloneNodes(Model &aModel, const Reference< XNode > &dstParent, const Reference< XNode > &source, bool bRemoveWSNodes)
#define HANDLE_CDataSectionElement
static OUString lcl_message(std::u16string_view rID, std::u16string_view rText)