masterfix DEV300: #i10000# build fix
[LibreOffice.git] / forms / source / xforms / submission / submission.hxx
blob53e37b4cd1315d34adea5872f1dd252b3a9a0c4c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef __SUBMISSION_HXX
29 #define __SUBMISSION_HXX
31 #include <tools/urlobj.hxx>
32 #include <rtl/ustring.h>
33 #include <osl/conditn.hxx>
34 #include <osl/mutex.hxx>
35 #include <unotools/processfactory.hxx>
36 #include <com/sun/star/uno/Reference.hxx>
37 #include <com/sun/star/uno/Any.hxx>
38 #include <com/sun/star/uno/Exception.hpp>
39 #include <com/sun/star/uno/RuntimeException.hpp>
40 #include <com/sun/star/xml/xpath/XXPathObject.hpp>
41 #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
42 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
45 #include <com/sun/star/ucb/XProgressHandler.hpp>
47 #include <com/sun/star/task/XInteractionHandler.hpp>
49 #include <com/sun/star/frame/XFrame.hpp>
51 #include <cppuhelper/implbase1.hxx>
52 #include <cppuhelper/implbase2.hxx>
53 #include <cppuhelper/implbase3.hxx>
55 #include "serialization.hxx"
57 namespace CSS = com::sun::star;
59 class CSubmissionPut;
60 class CSubmissionPost;
61 class CSubmissionGet;
63 class CCommandEnvironmentHelper : public cppu::WeakImplHelper1< CSS::ucb::XCommandEnvironment >
65 friend class CSubmissionPut;
66 friend class CSubmissionPost;
67 friend class CSubmissionGet;
68 friend class CSubmission;
70 protected:
71 CSS::uno::Reference< CSS::task::XInteractionHandler > m_aInteractionHandler;
72 CSS::uno::Reference< CSS::ucb::XProgressHandler > m_aProgressHandler;
74 public:
75 virtual CSS::uno::Reference< CSS::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (CSS::uno::RuntimeException)
77 return m_aInteractionHandler;
79 virtual CSS::uno::Reference< CSS::ucb::XProgressHandler > SAL_CALL getProgressHandler() throw (CSS::uno::RuntimeException)
81 return m_aProgressHandler;
85 class CProgressHandlerHelper : public cppu::WeakImplHelper1< CSS::ucb::XProgressHandler >
87 friend class CSubmissionPut;
88 friend class CSubmissionPost;
89 friend class CSubmissionGet;
90 protected:
91 osl::Condition m_cFinished;
92 osl::Mutex m_mLock;
93 sal_Int32 m_count;
94 public:
95 CProgressHandlerHelper()
96 : m_count(0)
98 virtual void SAL_CALL push( const com::sun::star::uno::Any& /*aStatus*/) throw(com::sun::star::uno::RuntimeException)
100 m_mLock.acquire();
101 m_count++;
102 m_mLock.release();
104 virtual void SAL_CALL update(const com::sun::star::uno::Any& /*aStatus*/) throw(com::sun::star::uno::RuntimeException)
107 virtual void SAL_CALL pop() throw(com::sun::star::uno::RuntimeException)
109 m_mLock.acquire();
110 m_count--;
111 if (m_count == 0)
112 m_cFinished.set();
113 m_mLock.release();
117 class CSubmission
120 protected:
121 INetURLObject m_aURLObj;
122 CSS::uno::Reference< CSS::xml::xpath::XXPathObject > m_aXPathObject;
123 CSS::uno::Reference< CSS::xml::dom::XDocumentFragment > m_aFragment;
124 CSS::uno::Reference< CSS::io::XInputStream > m_aResultStream;
125 CSS::uno::Reference< CSS::lang::XMultiServiceFactory > m_aFactory;
126 rtl::OUString m_aEncoding;
128 ::std::auto_ptr< CSerialization > createSerialization(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler
129 ,com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment>& _rOutEnv);
131 public:
132 enum SubmissionResult {
133 SUCCESS,
134 INVALID_METHOD,
135 INVALID_URL,
136 INVALID_ENCODING,
137 E_TRANSMISSION,
138 UNKNOWN_ERROR
141 CSubmission(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment)
142 : m_aURLObj(aURL)
143 , m_aFragment(aFragment)
144 , m_aFactory(::utl::getProcessServiceFactory())
147 virtual ~CSubmission() {}
149 // virtual CSS::uno::Sequence< rtl::OUString > getSupportedEncodings() = 0;
150 virtual void setEncoding(const rtl::OUString& aEncoding)
152 m_aEncoding = aEncoding;
154 virtual SubmissionResult submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& ) = 0;
156 virtual SubmissionResult replace(const rtl::OUString&, const CSS::uno::Reference< CSS::xml::dom::XDocument >&, const CSS::uno::Reference< CSS::frame::XFrame>&);
160 #endif