Update ooo320-m1
[ooovba.git] / forms / source / xforms / submission / submission.hxx
blobe707b4030c2d5f282e81c5e521fea47675ab4f45
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: submission.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __SUBMISSION_HXX
32 #define __SUBMISSION_HXX
34 #include <tools/urlobj.hxx>
35 #include <rtl/ustring.h>
36 #include <osl/conditn.hxx>
37 #include <osl/mutex.hxx>
38 #include <unotools/processfactory.hxx>
39 #include <com/sun/star/uno/Reference.hxx>
40 #include <com/sun/star/uno/Any.hxx>
41 #include <com/sun/star/uno/Exception.hpp>
42 #include <com/sun/star/uno/RuntimeException.hpp>
43 #include <com/sun/star/xml/xpath/XXPathObject.hpp>
44 #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
45 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
47 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
48 #include <com/sun/star/ucb/XProgressHandler.hpp>
50 #include <com/sun/star/task/XInteractionHandler.hpp>
52 #include <com/sun/star/frame/XFrame.hpp>
54 #include <cppuhelper/implbase1.hxx>
55 #include <cppuhelper/implbase2.hxx>
56 #include <cppuhelper/implbase3.hxx>
58 #include "serialization.hxx"
60 namespace CSS = com::sun::star;
62 class CSubmissionPut;
63 class CSubmissionPost;
64 class CSubmissionGet;
66 class CCommandEnvironmentHelper : public cppu::WeakImplHelper1< CSS::ucb::XCommandEnvironment >
68 friend class CSubmissionPut;
69 friend class CSubmissionPost;
70 friend class CSubmissionGet;
71 friend class CSubmission;
73 protected:
74 CSS::uno::Reference< CSS::task::XInteractionHandler > m_aInteractionHandler;
75 CSS::uno::Reference< CSS::ucb::XProgressHandler > m_aProgressHandler;
77 public:
78 virtual CSS::uno::Reference< CSS::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (CSS::uno::RuntimeException)
80 return m_aInteractionHandler;
82 virtual CSS::uno::Reference< CSS::ucb::XProgressHandler > SAL_CALL getProgressHandler() throw (CSS::uno::RuntimeException)
84 return m_aProgressHandler;
88 class CProgressHandlerHelper : public cppu::WeakImplHelper1< CSS::ucb::XProgressHandler >
90 friend class CSubmissionPut;
91 friend class CSubmissionPost;
92 friend class CSubmissionGet;
93 protected:
94 osl::Condition m_cFinished;
95 osl::Mutex m_mLock;
96 sal_Int32 m_count;
97 public:
98 CProgressHandlerHelper()
99 : m_count(0)
101 virtual void SAL_CALL push( const com::sun::star::uno::Any& /*aStatus*/) throw(com::sun::star::uno::RuntimeException)
103 m_mLock.acquire();
104 m_count++;
105 m_mLock.release();
107 virtual void SAL_CALL update(const com::sun::star::uno::Any& /*aStatus*/) throw(com::sun::star::uno::RuntimeException)
110 virtual void SAL_CALL pop() throw(com::sun::star::uno::RuntimeException)
112 m_mLock.acquire();
113 m_count--;
114 if (m_count == 0)
115 m_cFinished.set();
116 m_mLock.release();
120 class CSubmission
123 protected:
124 INetURLObject m_aURLObj;
125 CSS::uno::Reference< CSS::xml::xpath::XXPathObject > m_aXPathObject;
126 CSS::uno::Reference< CSS::xml::dom::XDocumentFragment > m_aFragment;
127 CSS::uno::Reference< CSS::io::XInputStream > m_aResultStream;
128 CSS::uno::Reference< CSS::lang::XMultiServiceFactory > m_aFactory;
129 rtl::OUString m_aEncoding;
131 ::std::auto_ptr< CSerialization > createSerialization(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler
132 ,com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment>& _rOutEnv);
134 public:
135 enum SubmissionResult {
136 SUCCESS,
137 INVALID_METHOD,
138 INVALID_URL,
139 INVALID_ENCODING,
140 E_TRANSMISSION,
141 UNKNOWN_ERROR
144 CSubmission(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment)
145 : m_aURLObj(aURL)
146 , m_aFragment(aFragment)
147 , m_aFactory(::utl::getProcessServiceFactory())
150 virtual ~CSubmission() {}
152 // virtual CSS::uno::Sequence< rtl::OUString > getSupportedEncodings() = 0;
153 virtual void setEncoding(const rtl::OUString& aEncoding)
155 m_aEncoding = aEncoding;
157 virtual SubmissionResult submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& ) = 0;
159 virtual SubmissionResult replace(const rtl::OUString&, const CSS::uno::Reference< CSS::xml::dom::XDocument >&, const CSS::uno::Reference< CSS::frame::XFrame>&);
163 #endif