Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __SUBMISSION_HXX
30 : : #define __SUBMISSION_HXX
31 : :
32 : : #include <tools/urlobj.hxx>
33 : : #include <rtl/ustring.h>
34 : : #include <osl/conditn.hxx>
35 : : #include <osl/mutex.hxx>
36 : : #include <comphelper/processfactory.hxx>
37 : : #include <com/sun/star/uno/Reference.hxx>
38 : : #include <com/sun/star/uno/Any.hxx>
39 : : #include <com/sun/star/uno/Exception.hpp>
40 : : #include <com/sun/star/uno/RuntimeException.hpp>
41 : : #include <com/sun/star/xml/xpath/XXPathObject.hpp>
42 : : #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
43 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 : :
45 : : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
46 : : #include <com/sun/star/ucb/XProgressHandler.hpp>
47 : :
48 : : #include <com/sun/star/task/XInteractionHandler.hpp>
49 : :
50 : : #include <com/sun/star/frame/XFrame.hpp>
51 : :
52 : : #include <cppuhelper/implbase1.hxx>
53 : : #include <cppuhelper/implbase2.hxx>
54 : : #include <cppuhelper/implbase3.hxx>
55 : :
56 : : #include "serialization.hxx"
57 : :
58 : : namespace CSS = com::sun::star;
59 : :
60 : : class CSubmissionPut;
61 : : class CSubmissionPost;
62 : : class CSubmissionGet;
63 : :
64 [ # # ]: 0 : class CCommandEnvironmentHelper : public cppu::WeakImplHelper1< CSS::ucb::XCommandEnvironment >
65 : : {
66 : : friend class CSubmissionPut;
67 : : friend class CSubmissionPost;
68 : : friend class CSubmissionGet;
69 : : friend class CSubmission;
70 : :
71 : : protected:
72 : : CSS::uno::Reference< CSS::task::XInteractionHandler > m_aInteractionHandler;
73 : : CSS::uno::Reference< CSS::ucb::XProgressHandler > m_aProgressHandler;
74 : :
75 : : public:
76 : 0 : virtual CSS::uno::Reference< CSS::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (CSS::uno::RuntimeException)
77 : : {
78 : 0 : return m_aInteractionHandler;
79 : : }
80 : 0 : virtual CSS::uno::Reference< CSS::ucb::XProgressHandler > SAL_CALL getProgressHandler() throw (CSS::uno::RuntimeException)
81 : : {
82 : 0 : return m_aProgressHandler;
83 : : }
84 : : };
85 : :
86 [ # # ][ # # ]: 0 : class CProgressHandlerHelper : public cppu::WeakImplHelper1< CSS::ucb::XProgressHandler >
[ # # ]
87 : : {
88 : : friend class CSubmissionPut;
89 : : friend class CSubmissionPost;
90 : : friend class CSubmissionGet;
91 : : protected:
92 : : osl::Condition m_cFinished;
93 : : osl::Mutex m_mLock;
94 : : sal_Int32 m_count;
95 : : public:
96 : 0 : CProgressHandlerHelper()
97 [ # # ][ # # ]: 0 : : m_count(0)
98 : 0 : {}
99 : 0 : virtual void SAL_CALL push( const com::sun::star::uno::Any& /*aStatus*/) throw(com::sun::star::uno::RuntimeException)
100 : : {
101 : 0 : m_mLock.acquire();
102 : 0 : m_count++;
103 : 0 : m_mLock.release();
104 : 0 : }
105 : 0 : virtual void SAL_CALL update(const com::sun::star::uno::Any& /*aStatus*/) throw(com::sun::star::uno::RuntimeException)
106 : : {
107 : 0 : }
108 : 0 : virtual void SAL_CALL pop() throw(com::sun::star::uno::RuntimeException)
109 : : {
110 : 0 : m_mLock.acquire();
111 : 0 : m_count--;
112 [ # # ]: 0 : if (m_count == 0)
113 : 0 : m_cFinished.set();
114 : 0 : m_mLock.release();
115 : 0 : }
116 : : };
117 : :
118 : : class CSubmission
119 : : {
120 : :
121 : : protected:
122 : : INetURLObject m_aURLObj;
123 : : CSS::uno::Reference< CSS::xml::xpath::XXPathObject > m_aXPathObject;
124 : : CSS::uno::Reference< CSS::xml::dom::XDocumentFragment > m_aFragment;
125 : : CSS::uno::Reference< CSS::io::XInputStream > m_aResultStream;
126 : : CSS::uno::Reference< CSS::lang::XMultiServiceFactory > m_aFactory;
127 : : rtl::OUString m_aEncoding;
128 : :
129 : : ::std::auto_ptr< CSerialization > createSerialization(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler
130 : : ,com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment>& _rOutEnv);
131 : :
132 : : public:
133 : : enum SubmissionResult {
134 : : SUCCESS,
135 : : INVALID_METHOD,
136 : : INVALID_URL,
137 : : INVALID_ENCODING,
138 : : E_TRANSMISSION,
139 : : UNKNOWN_ERROR
140 : : };
141 : :
142 : 0 : CSubmission(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment)
143 : : : m_aURLObj(aURL)
144 : : , m_aFragment(aFragment)
145 [ # # ]: 0 : , m_aFactory(::comphelper::getProcessServiceFactory())
146 : 0 : {}
147 : :
148 [ # # ]: 0 : virtual ~CSubmission() {}
149 : :
150 : : // virtual CSS::uno::Sequence< rtl::OUString > getSupportedEncodings() = 0;
151 : 0 : virtual void setEncoding(const rtl::OUString& aEncoding)
152 : : {
153 : 0 : m_aEncoding = aEncoding;
154 : 0 : }
155 : : virtual SubmissionResult submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& ) = 0;
156 : :
157 : : virtual SubmissionResult replace(const rtl::OUString&, const CSS::uno::Reference< CSS::xml::dom::XDocument >&, const CSS::uno::Reference< CSS::frame::XFrame>&);
158 : :
159 : : };
160 : :
161 : : #endif
162 : :
163 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|