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 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_forms.hxx"
33 #include "submission_post.hxx"
34 #include "serialization_app_xml.hxx"
35 #include "serialization_urlencoded.hxx"
37 #include <osl/file.hxx>
38 #include <unotools/processfactory.hxx>
39 #include <ucbhelper/content.hxx>
40 #include <ucbhelper/activedatasink.hxx>
41 #include <com/sun/star/ucb/PostCommandArgument2.hpp>
43 using namespace CSS::uno
;
44 using namespace CSS::ucb
;
45 using namespace CSS::task
;
46 using namespace CSS::io
;
49 using namespace ucbhelper
;
53 CSubmissionPost::CSubmissionPost(const rtl::OUString
& aURL
, const CSS::uno::Reference
< CSS::xml::dom::XDocumentFragment
>& aFragment
)
54 : CSubmission(aURL
, aFragment
)
58 CSubmission::SubmissionResult
CSubmissionPost::submit(const CSS::uno::Reference
< CSS::task::XInteractionHandler
>& aInteractionHandler
)
60 // PUT always uses application/xml
61 CSS::uno::Reference
< XCommandEnvironment
> aEnvironment
;
62 auto_ptr
< CSerialization
> apSerialization(createSerialization(aInteractionHandler
,aEnvironment
));
65 ucbhelper::Content
aContent(m_aURLObj
.GetMainURL(INetURLObject::NO_DECODE
), aEnvironment
);
69 OUString aCommandName
= OUString::createFromAscii("post");
70 PostCommandArgument2 aPostArgument
;
71 aPostArgument
.Source
= apSerialization
->getInputStream();
72 //CSS::uno::Reference< XInterface > aSink( m_aFactory->createInstance(
73 // OUString::createFromAscii("com.sun.star.io.Pipe")), UNO_QUERY_THROW);
74 CSS::uno::Reference
< XActiveDataSink
> aSink(new ucbhelper::ActiveDataSink
);
75 // OUString::createFromAscii("com.sun.star.io.Pipe")), UNO_QUERY_THROW);
76 aPostArgument
.Sink
= aSink
;
77 aPostArgument
.MediaType
= OUString::createFromAscii("application/xml");
78 aPostArgument
.Referer
= OUString();
80 aCommandArgument
<<= aPostArgument
;
81 aContent
.executeCommand( aCommandName
, aCommandArgument
);
83 // wait for command to finish
84 // pProgressHelper->m_cFinished.wait();
86 // CSS::uno::Reference< XOutputStream > xOut(aSink, UNO_QUERY_THROW);
87 // xOut->closeOutput();
90 // m_aResultStream = CSS::uno::Reference< XInputStream >(aSink, UNO_QUERY_THROW);
91 m_aResultStream
= aSink
->getInputStream();
92 } catch (Exception
&) {
93 OSL_ENSURE(sal_False
, "Cannot open reply stream from content");
98 OSL_ENSURE(sal_False
, "Exception during UCB operatration.");