Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_FORMS_SOURCE_XFORMS_SUBMISSION_HXX
21 : #define INCLUDED_FORMS_SOURCE_XFORMS_SUBMISSION_HXX
22 :
23 : #include <cppuhelper/implbase2.hxx>
24 : #include <propertysetbase.hxx>
25 : #include <com/sun/star/util/XModifyBroadcaster.hpp>
26 : #include <com/sun/star/container/XNamed.hpp>
27 : #include <com/sun/star/xml/dom/events/XEventListener.hpp>
28 : #include <com/sun/star/lang/XUnoTunnel.hpp>
29 : #include <com/sun/star/xml/dom/XNode.hpp>
30 : #include <com/sun/star/xml/dom/XDocument.hpp>
31 : #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
32 : #include <com/sun/star/xml/xpath/XXPathObject.hpp>
33 : #include <com/sun/star/xforms/XSubmission.hpp>
34 :
35 : #include <com/sun/star/uno/Reference.hxx>
36 : #include <com/sun/star/uno/Sequence.hxx>
37 : #include <computedexpression.hxx>
38 :
39 : // forward declaractions
40 : namespace com { namespace sun { namespace star {
41 : namespace xforms { class XModel; }
42 : namespace uno { class Any; }
43 : namespace beans { class UnknownPropertyException;
44 : class PropertyVetoException; }
45 : namespace lang { class IllegalArgumentException;
46 : class WrappedTargetException; }
47 : } } }
48 : namespace xforms { class Model; }
49 :
50 :
51 : namespace xforms
52 : {
53 :
54 : /** An XForms submission.
55 : *
56 : * See http://www.w3.org/TR/xforms/ for more information.
57 : */
58 : typedef cppu::ImplInheritanceHelper2<
59 : PropertySetBase,
60 : com::sun::star::lang::XUnoTunnel,
61 : com::sun::star::xforms::XSubmission
62 : > Submission_t;
63 :
64 : class Submission : public Submission_t
65 : {
66 : // submission properties
67 : OUString msID;
68 : OUString msBind;
69 : ComputedExpression maRef;
70 : OUString msAction;
71 : OUString msMethod;
72 : OUString msVersion;
73 : bool mbIndent;
74 : OUString msMediaType;
75 : OUString msEncoding;
76 : bool mbOmitXmlDeclaration;
77 : bool mbStandalone;
78 : OUString msCDataSectionElement;
79 : OUString msReplace;
80 : OUString msSeparator;
81 : com::sun::star::uno::Sequence< OUString > msIncludeNamespacePrefixes;
82 :
83 : private:
84 :
85 : /// the Model to which this Submission belongs; may be NULL
86 : com::sun::star::uno::Reference<com::sun::star::xforms::XModel> mxModel;
87 :
88 : // this will extract the document from the model that will be submitted
89 : com::sun::star::uno::Reference< com::sun::star::xml::dom::XDocumentFragment >
90 : createSubmissionDocument(const com::sun::star::uno::Reference< com::sun::star::xml::xpath::XXPathObject >& aObject,
91 : bool bRemoveWSNodes = false);
92 : com::sun::star::uno::Reference< com::sun::star::xml::dom::XDocument >
93 : getInstanceDocument(const com::sun::star::uno::Reference< com::sun::star::xml::xpath::XXPathObject >& aObject);
94 :
95 : public:
96 : Submission();
97 : virtual ~Submission() throw();
98 :
99 :
100 : // property methods: get/set value
101 :
102 :
103 : /// get XForms model
104 : com::sun::star::uno::Reference<com::sun::star::xforms::XModel>
105 0 : getModel() const { return mxModel;}
106 :
107 : /// set XForms model
108 : void setModel(
109 : const com::sun::star::uno::Reference<com::sun::star::xforms::XModel>& );
110 :
111 0 : OUString getID() const { return msID;} /// get ID for this submission
112 : void setID( const OUString& ); /// set ID for this submission
113 :
114 0 : OUString getBind() const { return msBind;}
115 : void setBind( const OUString& );
116 :
117 : OUString getRef() const;
118 : void setRef( const OUString& );
119 :
120 0 : OUString getAction() const { return msAction;}
121 : void setAction( const OUString& );
122 :
123 0 : OUString getMethod() const { return msMethod;}
124 : void setMethod( const OUString& );
125 :
126 0 : OUString getVersion() const { return msVersion;}
127 : void setVersion( const OUString& );
128 :
129 0 : bool getIndent() const { return mbIndent;}
130 : void setIndent( bool );
131 :
132 0 : OUString getMediaType() const { return msMediaType;}
133 : void setMediaType( const OUString& );
134 :
135 0 : OUString getEncoding() const { return msEncoding;}
136 : void setEncoding( const OUString& );
137 :
138 0 : bool getOmitXmlDeclaration() const { return mbOmitXmlDeclaration;}
139 : void setOmitXmlDeclaration( bool );
140 :
141 0 : bool getStandalone() const { return mbStandalone;}
142 : void setStandalone( bool );
143 :
144 0 : OUString getCDataSectionElement() const { return msCDataSectionElement;}
145 : void setCDataSectionElement( const OUString& );
146 :
147 0 : OUString getReplace() const { return msReplace;}
148 : void setReplace( const OUString& );
149 :
150 0 : OUString getSeparator() const { return msSeparator;}
151 : void setSeparator( const OUString& );
152 :
153 0 : com::sun::star::uno::Sequence< OUString > getIncludeNamespacePrefixes() const { return msIncludeNamespacePrefixes;}
154 : void setIncludeNamespacePrefixes( const com::sun::star::uno::Sequence< OUString >& );
155 :
156 :
157 : /** perform the submission
158 : * @returns if submission was successful */
159 : bool doSubmit( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler );
160 :
161 :
162 : /// release the model (note: Binding is unusable without model)
163 : void releaseModel();
164 :
165 :
166 : // helpers for UNO tunnel
167 : static com::sun::star::uno::Sequence<sal_Int8> getUnoTunnelID();
168 : static Submission* getSubmission( const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& );
169 :
170 :
171 :
172 : private:
173 :
174 : /// check whether object is live, and throw suitable exception if not
175 : /// (to be used be API methods before acting on the object)
176 : void liveCheck()
177 : throw( com::sun::star::uno::RuntimeException );
178 :
179 : /// get the model implementation
180 : xforms::Model* getModelImpl() const;
181 : xforms::Model* getModelImpl( const com::sun::star::uno::Reference<com::sun::star::xforms::XModel>& xModel ) const;
182 :
183 :
184 :
185 : protected:
186 :
187 :
188 : // XPropertySet & friends:
189 : // implement abstract methods from PropertySetHelper
190 :
191 :
192 : virtual sal_Bool SAL_CALL convertFastPropertyValue(
193 : com::sun::star::uno::Any& rConvertedValue,
194 : com::sun::star::uno::Any& rOldValue,
195 : sal_Int32 nHandle,
196 : const com::sun::star::uno::Any& rValue )
197 : throw ( com::sun::star::lang::IllegalArgumentException ) SAL_OVERRIDE;
198 :
199 : private:
200 : void initializePropertySet();
201 :
202 :
203 : public:
204 :
205 :
206 : // XNamed:
207 : // get/set name
208 :
209 :
210 : virtual OUString SAL_CALL getName()
211 : throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
212 :
213 : virtual void SAL_CALL setName( const OUString& )
214 : throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
215 :
216 :
217 :
218 :
219 : // XUnoTunnel
220 :
221 :
222 : virtual sal_Int64 SAL_CALL getSomething(
223 : const com::sun::star::uno::Sequence<sal_Int8>& )
224 : throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
225 :
226 :
227 :
228 : // XSubmission
229 :
230 :
231 : virtual void SAL_CALL submit( )
232 : throw ( com::sun::star::util::VetoException,
233 : com::sun::star::lang::WrappedTargetException,
234 : com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
235 : virtual void SAL_CALL submitWithInteraction(
236 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler )
237 : throw ( com::sun::star::util::VetoException,
238 : com::sun::star::lang::WrappedTargetException,
239 : com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
240 : virtual void SAL_CALL addSubmissionVetoListener(
241 : const ::com::sun::star::uno::Reference< ::com::sun::star::form::submission::XSubmissionVetoListener >& listener )
242 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
243 : virtual void SAL_CALL removeSubmissionVetoListener(
244 : const ::com::sun::star::uno::Reference< ::com::sun::star::form::submission::XSubmissionVetoListener >& listener )
245 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
246 :
247 :
248 : // XPropertySet
249 : // (need to disambiguate this)
250 :
251 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
252 : virtual void SAL_CALL setPropertyValue( const 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, std::exception) SAL_OVERRIDE;
253 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
254 : virtual void SAL_CALL addPropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
255 : virtual void SAL_CALL removePropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
256 : virtual void SAL_CALL addVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
257 : virtual void SAL_CALL removeVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
258 : };
259 :
260 :
261 : } // namespace xforms
262 :
263 : #endif
264 :
265 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|