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