LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / forms / source / xforms / submission.hxx
blob1e7f17e4cfc71da6fbf4f2671a0bfc926d72e566
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <cppuhelper/implbase.hxx>
23 #include "propertysetbase.hxx"
24 #include <com/sun/star/lang/XUnoTunnel.hpp>
25 #include <com/sun/star/xml/dom/XDocument.hpp>
26 #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
27 #include <com/sun/star/xml/xpath/XXPathObject.hpp>
28 #include <com/sun/star/xforms/XSubmission.hpp>
30 #include <com/sun/star/uno/Reference.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include "computedexpression.hxx"
34 // forward declaractions
35 namespace com::sun::star {
36 namespace xforms { class XModel; }
37 namespace uno { class Any; }
38 namespace beans { class UnknownPropertyException;
39 class PropertyVetoException; }
40 namespace lang { class IllegalArgumentException;
41 class WrappedTargetException; }
43 namespace xforms { class Model; }
46 namespace xforms
49 /** An XForms submission.
51 * See http://www.w3.org/TR/xforms/ for more information.
53 typedef cppu::ImplInheritanceHelper<
54 PropertySetBase,
55 css::lang::XUnoTunnel,
56 css::xforms::XSubmission
57 > Submission_t;
59 class Submission : public Submission_t
61 // submission properties
62 OUString msID;
63 OUString msBind;
64 ComputedExpression maRef;
65 OUString msAction;
66 OUString msMethod;
67 OUString msVersion;
68 bool mbIndent;
69 OUString msMediaType;
70 OUString msEncoding;
71 bool mbOmitXmlDeclaration;
72 bool mbStandalone;
73 OUString msCDataSectionElement;
74 OUString msReplace;
75 OUString msSeparator;
76 css::uno::Sequence< OUString > msIncludeNamespacePrefixes;
78 private:
80 /// the Model to which this Submission belongs; may be NULL
81 css::uno::Reference<css::xforms::XModel> mxModel;
83 // this will extract the document from the model that will be submitted
84 css::uno::Reference< css::xml::dom::XDocumentFragment >
85 createSubmissionDocument(const css::uno::Reference< css::xml::xpath::XXPathObject >& aObject,
86 bool bRemoveWSNodes);
87 static css::uno::Reference< css::xml::dom::XDocument >
88 getInstanceDocument(const css::uno::Reference< css::xml::xpath::XXPathObject >& aObject);
90 public:
91 Submission();
92 virtual ~Submission() noexcept override;
95 // property methods: get/set value
98 /// get XForms model
99 css::uno::Reference<css::xforms::XModel>
100 getModel() const { return mxModel;}
102 /// set XForms model
103 void setModel(
104 const css::uno::Reference<css::xforms::XModel>& );
106 OUString getID() const { return msID;} /// get ID for this submission
107 void setID( const OUString& ); /// set ID for this submission
109 OUString getBind() const { return msBind;}
110 void setBind( const OUString& );
112 OUString getRef() const;
113 void setRef( const OUString& );
115 OUString getAction() const { return msAction;}
116 void setAction( const OUString& );
118 OUString getMethod() const { return msMethod;}
119 void setMethod( const OUString& );
121 OUString getVersion() const { return msVersion;}
122 void setVersion( const OUString& );
124 bool getIndent() const { return mbIndent;}
125 void setIndent( bool );
127 OUString getMediaType() const { return msMediaType;}
128 void setMediaType( const OUString& );
130 OUString getEncoding() const { return msEncoding;}
131 void setEncoding( const OUString& );
133 bool getOmitXmlDeclaration() const { return mbOmitXmlDeclaration;}
134 void setOmitXmlDeclaration( bool );
136 bool getStandalone() const { return mbStandalone;}
137 void setStandalone( bool );
139 OUString getCDataSectionElement() const { return msCDataSectionElement;}
140 void setCDataSectionElement( const OUString& );
142 OUString getReplace() const { return msReplace;}
143 void setReplace( const OUString& );
145 OUString getSeparator() const { return msSeparator;}
146 void setSeparator( const OUString& );
148 css::uno::Sequence< OUString > getIncludeNamespacePrefixes() const { return msIncludeNamespacePrefixes;}
149 void setIncludeNamespacePrefixes( const css::uno::Sequence< OUString >& );
151 /** perform the submission
152 * @returns if submission was successful */
153 bool doSubmit( const css::uno::Reference< css::task::XInteractionHandler >& aHandler );
155 // helpers for UNO tunnel
156 static css::uno::Sequence<sal_Int8> getUnoTunnelId();
158 private:
160 /// check whether object is live, and throw suitable exception if not
161 /// (to be used be API methods before acting on the object)
163 /// @throws css::uno::RuntimeException
164 void liveCheck();
166 /// get the model implementation
167 xforms::Model* getModelImpl() const;
169 protected:
172 // XPropertySet & friends:
173 // implement abstract methods from PropertySetHelper
176 virtual sal_Bool SAL_CALL convertFastPropertyValue(
177 css::uno::Any& rConvertedValue,
178 css::uno::Any& rOldValue,
179 sal_Int32 nHandle,
180 const css::uno::Any& rValue ) override;
182 private:
183 void initializePropertySet();
186 public:
189 // XNamed:
190 // get/set name
193 virtual OUString SAL_CALL getName() override;
195 virtual void SAL_CALL setName( const OUString& ) override;
198 // XUnoTunnel
201 virtual sal_Int64 SAL_CALL getSomething(
202 const css::uno::Sequence<sal_Int8>& ) override;
205 // XSubmission
208 virtual void SAL_CALL submit( ) override;
209 virtual void SAL_CALL submitWithInteraction(
210 const css::uno::Reference< css::task::XInteractionHandler >& aHandler ) override;
211 virtual void SAL_CALL addSubmissionVetoListener(
212 const css::uno::Reference< css::form::submission::XSubmissionVetoListener >& listener ) override;
213 virtual void SAL_CALL removeSubmissionVetoListener(
214 const css::uno::Reference< css::form::submission::XSubmissionVetoListener >& listener ) override;
217 // XPropertySet
218 // (need to disambiguate this)
220 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
221 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
222 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
223 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
224 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
225 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
226 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
230 } // namespace xforms
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */