1*2d785d7eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2d785d7eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2d785d7eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2d785d7eSAndrew Rist * distributed with this work for additional information 6*2d785d7eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2d785d7eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2d785d7eSAndrew Rist * "License"); you may not use this file except in compliance 9*2d785d7eSAndrew Rist * with the License. You may obtain a copy of the License at 10*2d785d7eSAndrew Rist * 11*2d785d7eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2d785d7eSAndrew Rist * 13*2d785d7eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2d785d7eSAndrew Rist * software distributed under the License is distributed on an 15*2d785d7eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2d785d7eSAndrew Rist * KIND, either express or implied. See the License for the 17*2d785d7eSAndrew Rist * specific language governing permissions and limitations 18*2d785d7eSAndrew Rist * under the License. 19*2d785d7eSAndrew Rist * 20*2d785d7eSAndrew Rist *************************************************************/ 21*2d785d7eSAndrew Rist 22*2d785d7eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef __SUBMISSION_HXX 25cdf0e10cSrcweir #define __SUBMISSION_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/urlobj.hxx> 28cdf0e10cSrcweir #include <rtl/ustring.h> 29cdf0e10cSrcweir #include <osl/conditn.hxx> 30cdf0e10cSrcweir #include <osl/mutex.hxx> 31cdf0e10cSrcweir #include <unotools/processfactory.hxx> 32cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx> 33cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 34cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp> 35cdf0e10cSrcweir #include <com/sun/star/uno/RuntimeException.hpp> 36cdf0e10cSrcweir #include <com/sun/star/xml/xpath/XXPathObject.hpp> 37cdf0e10cSrcweir #include <com/sun/star/xml/dom/XDocumentFragment.hpp> 38cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp> 41cdf0e10cSrcweir #include <com/sun/star/ucb/XProgressHandler.hpp> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 46cdf0e10cSrcweir 47cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 48cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 49cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 50cdf0e10cSrcweir 51cdf0e10cSrcweir #include "serialization.hxx" 52cdf0e10cSrcweir 53cdf0e10cSrcweir namespace CSS = com::sun::star; 54cdf0e10cSrcweir 55cdf0e10cSrcweir class CSubmissionPut; 56cdf0e10cSrcweir class CSubmissionPost; 57cdf0e10cSrcweir class CSubmissionGet; 58cdf0e10cSrcweir 59cdf0e10cSrcweir class CCommandEnvironmentHelper : public cppu::WeakImplHelper1< CSS::ucb::XCommandEnvironment > 60cdf0e10cSrcweir { 61cdf0e10cSrcweir friend class CSubmissionPut; 62cdf0e10cSrcweir friend class CSubmissionPost; 63cdf0e10cSrcweir friend class CSubmissionGet; 64cdf0e10cSrcweir friend class CSubmission; 65cdf0e10cSrcweir 66cdf0e10cSrcweir protected: 67cdf0e10cSrcweir CSS::uno::Reference< CSS::task::XInteractionHandler > m_aInteractionHandler; 68cdf0e10cSrcweir CSS::uno::Reference< CSS::ucb::XProgressHandler > m_aProgressHandler; 69cdf0e10cSrcweir 70cdf0e10cSrcweir public: getInteractionHandler()71cdf0e10cSrcweir virtual CSS::uno::Reference< CSS::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (CSS::uno::RuntimeException) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir return m_aInteractionHandler; 74cdf0e10cSrcweir } getProgressHandler()75cdf0e10cSrcweir virtual CSS::uno::Reference< CSS::ucb::XProgressHandler > SAL_CALL getProgressHandler() throw (CSS::uno::RuntimeException) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir return m_aProgressHandler; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir }; 80cdf0e10cSrcweir 81cdf0e10cSrcweir class CProgressHandlerHelper : public cppu::WeakImplHelper1< CSS::ucb::XProgressHandler > 82cdf0e10cSrcweir { 83cdf0e10cSrcweir friend class CSubmissionPut; 84cdf0e10cSrcweir friend class CSubmissionPost; 85cdf0e10cSrcweir friend class CSubmissionGet; 86cdf0e10cSrcweir protected: 87cdf0e10cSrcweir osl::Condition m_cFinished; 88cdf0e10cSrcweir osl::Mutex m_mLock; 89cdf0e10cSrcweir sal_Int32 m_count; 90cdf0e10cSrcweir public: CProgressHandlerHelper()91cdf0e10cSrcweir CProgressHandlerHelper() 92cdf0e10cSrcweir : m_count(0) 93cdf0e10cSrcweir {} push(const com::sun::star::uno::Any &)94cdf0e10cSrcweir virtual void SAL_CALL push( const com::sun::star::uno::Any& /*aStatus*/) throw(com::sun::star::uno::RuntimeException) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir m_mLock.acquire(); 97cdf0e10cSrcweir m_count++; 98cdf0e10cSrcweir m_mLock.release(); 99cdf0e10cSrcweir } update(const com::sun::star::uno::Any &)100cdf0e10cSrcweir virtual void SAL_CALL update(const com::sun::star::uno::Any& /*aStatus*/) throw(com::sun::star::uno::RuntimeException) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir } pop()103cdf0e10cSrcweir virtual void SAL_CALL pop() throw(com::sun::star::uno::RuntimeException) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir m_mLock.acquire(); 106cdf0e10cSrcweir m_count--; 107cdf0e10cSrcweir if (m_count == 0) 108cdf0e10cSrcweir m_cFinished.set(); 109cdf0e10cSrcweir m_mLock.release(); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir }; 112cdf0e10cSrcweir 113cdf0e10cSrcweir class CSubmission 114cdf0e10cSrcweir { 115cdf0e10cSrcweir 116cdf0e10cSrcweir protected: 117cdf0e10cSrcweir INetURLObject m_aURLObj; 118cdf0e10cSrcweir CSS::uno::Reference< CSS::xml::xpath::XXPathObject > m_aXPathObject; 119cdf0e10cSrcweir CSS::uno::Reference< CSS::xml::dom::XDocumentFragment > m_aFragment; 120cdf0e10cSrcweir CSS::uno::Reference< CSS::io::XInputStream > m_aResultStream; 121cdf0e10cSrcweir CSS::uno::Reference< CSS::lang::XMultiServiceFactory > m_aFactory; 122cdf0e10cSrcweir rtl::OUString m_aEncoding; 123cdf0e10cSrcweir 124cdf0e10cSrcweir ::std::auto_ptr< CSerialization > createSerialization(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler 125cdf0e10cSrcweir ,com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment>& _rOutEnv); 126cdf0e10cSrcweir 127cdf0e10cSrcweir public: 128cdf0e10cSrcweir enum SubmissionResult { 129cdf0e10cSrcweir SUCCESS, 130cdf0e10cSrcweir INVALID_METHOD, 131cdf0e10cSrcweir INVALID_URL, 132cdf0e10cSrcweir INVALID_ENCODING, 133cdf0e10cSrcweir E_TRANSMISSION, 134cdf0e10cSrcweir UNKNOWN_ERROR 135cdf0e10cSrcweir }; 136cdf0e10cSrcweir CSubmission(const rtl::OUString & aURL,const CSS::uno::Reference<CSS::xml::dom::XDocumentFragment> & aFragment)137cdf0e10cSrcweir CSubmission(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment) 138cdf0e10cSrcweir : m_aURLObj(aURL) 139cdf0e10cSrcweir , m_aFragment(aFragment) 140cdf0e10cSrcweir , m_aFactory(::utl::getProcessServiceFactory()) 141cdf0e10cSrcweir {} 142cdf0e10cSrcweir ~CSubmission()143cdf0e10cSrcweir virtual ~CSubmission() {} 144cdf0e10cSrcweir 145cdf0e10cSrcweir // virtual CSS::uno::Sequence< rtl::OUString > getSupportedEncodings() = 0; setEncoding(const rtl::OUString & aEncoding)146cdf0e10cSrcweir virtual void setEncoding(const rtl::OUString& aEncoding) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir m_aEncoding = aEncoding; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir virtual SubmissionResult submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& ) = 0; 151cdf0e10cSrcweir 152cdf0e10cSrcweir virtual SubmissionResult replace(const rtl::OUString&, const CSS::uno::Reference< CSS::xml::dom::XDocument >&, const CSS::uno::Reference< CSS::frame::XFrame>&); 153cdf0e10cSrcweir 154cdf0e10cSrcweir }; 155cdf0e10cSrcweir 156cdf0e10cSrcweir #endif 157