xref: /aoo41x/main/forms/source/xforms/submission.hxx (revision 2d785d7e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SUBMISSION_HXX
25 #define _SUBMISSION_HXX
26 
27 
28 // includes for parent classes
29 #include <cppuhelper/implbase2.hxx>
30 #include <propertysetbase.hxx>
31 #include <com/sun/star/util/XModifyBroadcaster.hpp>
32 #include <com/sun/star/container/XNamed.hpp>
33 #include <com/sun/star/xml/dom/events/XEventListener.hpp>
34 #include <com/sun/star/lang/XUnoTunnel.hpp>
35 #include <com/sun/star/xml/dom/XNode.hpp>
36 #include <com/sun/star/xml/dom/XDocument.hpp>
37 #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
38 #include <com/sun/star/xml/xpath/XXPathObject.hpp>
39 #include <com/sun/star/xforms/XSubmission.hpp>
40 
41 // includes for member variables
42 #include <com/sun/star/uno/Reference.hxx>
43 #include <com/sun/star/uno/Sequence.hxx>
44 #include <computedexpression.hxx>
45 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 
47 // forward declaractions
48 namespace com { namespace sun { namespace star {
49     namespace xforms { class XModel; }
50     namespace uno { class Any; }
51     namespace beans { class UnknownPropertyException;
52                       class PropertyVetoException; }
53     namespace lang { class IllegalArgumentException;
54                      class WrappedTargetException; }
55 } } }
56 namespace xforms { class Model; }
57 
58 
59 namespace xforms
60 {
61 
62 /** An XForms submission.
63  *
64  * See http://www.w3.org/TR/xforms/ for more information.
65  */
66 typedef cppu::ImplInheritanceHelper2<
67     PropertySetBase,
68     com::sun::star::lang::XUnoTunnel,
69     com::sun::star::xforms::XSubmission
70 > Submission_t;
71 
72 class Submission : public Submission_t
73 {
74     // submission properties
75     rtl::OUString msID;
76     rtl::OUString msBind;
77     ComputedExpression maRef;
78     rtl::OUString msAction;
79     rtl::OUString msMethod;
80     rtl::OUString msVersion;
81     bool mbIndent;
82     rtl::OUString msMediaType;
83     rtl::OUString msEncoding;
84     bool mbOmitXmlDeclaration;
85     bool mbStandalone;
86     rtl::OUString msCDataSectionElement;
87     rtl::OUString msReplace;
88     rtl::OUString msSeparator;
89     com::sun::star::uno::Sequence< rtl::OUString > msIncludeNamespacePrefixes;
90 
91 private:
92 
93     /// the Model to which this Submission belongs; may be NULL
94     com::sun::star::uno::Reference<com::sun::star::xforms::XModel> mxModel;
95 
96     // this will extract the document from the model that will be submitted
97     com::sun::star::uno::Reference< com::sun::star::xml::dom::XDocumentFragment >
98         createSubmissionDocument(const com::sun::star::uno::Reference< com::sun::star::xml::xpath::XXPathObject >& aObject,
99                                  sal_Bool bRemoveWSNodes = sal_False);
100     com::sun::star::uno::Reference< com::sun::star::xml::dom::XDocument >
101         getInstanceDocument(const com::sun::star::uno::Reference< com::sun::star::xml::xpath::XXPathObject >& aObject);
102 
103     com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory > m_aFactory;
104 public:
105     Submission();
106     virtual ~Submission() throw();
107 
108     //
109     // property methods: get/set value
110     //
111 
112     /// get XForms model
113     com::sun::star::uno::Reference<com::sun::star::xforms::XModel>
114         getModel() const;
115 
116     /// set XForms model
117     void setModel(
118         const com::sun::star::uno::Reference<com::sun::star::xforms::XModel>& );
119 
120     rtl::OUString getID() const;         /// get ID for this submission
121     void setID( const rtl::OUString& );  /// set ID for this submission
122 
123     rtl::OUString getBind() const;
124     void setBind( const rtl::OUString& );
125 
126     rtl::OUString getRef() const;
127     void setRef( const rtl::OUString& );
128 
129     rtl::OUString getAction() const;
130     void setAction( const rtl::OUString& );
131 
132     rtl::OUString getMethod() const;
133     void setMethod( const rtl::OUString& );
134 
135     rtl::OUString getVersion() const;
136     void setVersion( const rtl::OUString& );
137 
138     bool getIndent() const;
139     void setIndent( bool );
140 
141     rtl::OUString getMediaType() const;
142     void setMediaType( const rtl::OUString& );
143 
144     rtl::OUString getEncoding() const;
145     void setEncoding( const rtl::OUString& );
146 
147     bool getOmitXmlDeclaration() const;
148     void setOmitXmlDeclaration( bool );
149 
150     bool getStandalone() const;
151     void setStandalone( bool );
152 
153     rtl::OUString getCDataSectionElement() const;
154     void setCDataSectionElement( const rtl::OUString& );
155 
156     rtl::OUString getReplace() const;
157     void setReplace( const rtl::OUString& );
158 
159     rtl::OUString getSeparator() const;
160     void setSeparator( const rtl::OUString& );
161 
162     com::sun::star::uno::Sequence< rtl::OUString > getIncludeNamespacePrefixes() const;
163     void setIncludeNamespacePrefixes( const com::sun::star::uno::Sequence< rtl::OUString >& );
164 
165 
166 	/** perform the submission
167 	 * @returns if submission was successful */
168 	bool doSubmit( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler );
169 
170 
171     /// release the model (note: Binding is unusable without model)
172     void releaseModel();
173 
174 
175     // helpers for UNO tunnel
176     static com::sun::star::uno::Sequence<sal_Int8> getUnoTunnelID();
177     static Submission* getSubmission( const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& );
178 
179 
180 
181 private:
182 
183     /// check whether object is live, and throw suitable exception if not
184     /// (to be used be API methods before acting on the object)
185     void liveCheck()
186         throw( com::sun::star::uno::RuntimeException );
187 
188     /// get the model implementation
189     xforms::Model* getModelImpl() const;
190     xforms::Model* getModelImpl( const com::sun::star::uno::Reference<com::sun::star::xforms::XModel>& xModel ) const;
191 
192 
193 
194 protected:
195 
196     //
197     // XPropertySet & friends:
198     //   implement abstract methods from PropertySetHelper
199     //
200 
201     virtual sal_Bool SAL_CALL convertFastPropertyValue(
202         com::sun::star::uno::Any& rConvertedValue,
203         com::sun::star::uno::Any& rOldValue,
204         sal_Int32 nHandle,
205         const com::sun::star::uno::Any& rValue )
206 		throw ( com::sun::star::lang::IllegalArgumentException );
207 
208 private:
209     void initializePropertySet();
210 
211 
212 public:
213 
214     //
215     // XNamed:
216     //   get/set name
217     //
218 
219     virtual rtl::OUString SAL_CALL getName()
220         throw( com::sun::star::uno::RuntimeException );
221 
222     virtual void SAL_CALL setName( const rtl::OUString& )
223         throw( com::sun::star::uno::RuntimeException );
224 
225 
226 
227     //
228     // XUnoTunnel
229     //
230 
231     virtual sal_Int64 SAL_CALL getSomething(
232         const com::sun::star::uno::Sequence<sal_Int8>& )
233         throw( com::sun::star::uno::RuntimeException );
234 
235 
236     //
237     // XSubmission
238     //
239 
240     virtual void SAL_CALL submit(  )
241         throw ( com::sun::star::util::VetoException,
242                 com::sun::star::lang::WrappedTargetException,
243                 com::sun::star::uno::RuntimeException );
244     virtual void SAL_CALL submitWithInteraction(
245         const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler )
246         throw ( com::sun::star::util::VetoException,
247                 com::sun::star::lang::WrappedTargetException,
248                 com::sun::star::uno::RuntimeException );
249     virtual void SAL_CALL addSubmissionVetoListener(
250         const ::com::sun::star::uno::Reference< ::com::sun::star::form::submission::XSubmissionVetoListener >& listener )
251         throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
252     virtual void SAL_CALL removeSubmissionVetoListener(
253         const ::com::sun::star::uno::Reference< ::com::sun::star::form::submission::XSubmissionVetoListener >& listener )
254         throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
255 
256     //
257     // XPropertySet
258     // (need to disambiguate this)
259 
260     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
261     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
262     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
263     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
264     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
265     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
266     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
267 };
268 
269 
270 } // namespace xforms
271 
272 #endif
273