xref: /AOO41X/main/forms/source/xforms/submission/submission_put.cxx (revision 24acc54625a85f778a4f966495e8f4cd9d7b247c)
1*24acc546SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*24acc546SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*24acc546SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*24acc546SAndrew Rist  * distributed with this work for additional information
6*24acc546SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*24acc546SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*24acc546SAndrew Rist  * "License"); you may not use this file except in compliance
9*24acc546SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*24acc546SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*24acc546SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*24acc546SAndrew Rist  * software distributed under the License is distributed on an
15*24acc546SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24acc546SAndrew Rist  * KIND, either express or implied.  See the License for the
17*24acc546SAndrew Rist  * specific language governing permissions and limitations
18*24acc546SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*24acc546SAndrew Rist  *************************************************************/
21*24acc546SAndrew Rist 
22*24acc546SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_forms.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <memory>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "submission_put.hxx"
30cdf0e10cSrcweir #include "serialization_app_xml.hxx"
31cdf0e10cSrcweir #include "serialization_urlencoded.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <osl/file.hxx>
34cdf0e10cSrcweir #include <tools/diagnose_ex.h>
35cdf0e10cSrcweir #include <unotools/processfactory.hxx>
36cdf0e10cSrcweir #include <ucbhelper/content.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir using namespace CSS::uno;
39cdf0e10cSrcweir using namespace CSS::ucb;
40cdf0e10cSrcweir using namespace CSS::task;
41cdf0e10cSrcweir using namespace CSS::io;
42cdf0e10cSrcweir using namespace rtl;
43cdf0e10cSrcweir using namespace osl;
44cdf0e10cSrcweir using namespace ucbhelper;
45cdf0e10cSrcweir using namespace std;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 
CSubmissionPut(const rtl::OUString & aURL,const CSS::uno::Reference<CSS::xml::dom::XDocumentFragment> & aFragment)48cdf0e10cSrcweir CSubmissionPut::CSubmissionPut(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment)
49cdf0e10cSrcweir     : CSubmission(aURL, aFragment)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
submit(const CSS::uno::Reference<CSS::task::XInteractionHandler> & aInteractionHandler)53cdf0e10cSrcweir CSubmission::SubmissionResult CSubmissionPut::submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& aInteractionHandler)
54cdf0e10cSrcweir {
55cdf0e10cSrcweir     CSS::uno::Reference< XCommandEnvironment > aEnvironment;
56cdf0e10cSrcweir     auto_ptr< CSerialization > apSerialization(createSerialization(aInteractionHandler,aEnvironment));
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     try
59cdf0e10cSrcweir     {
60cdf0e10cSrcweir         ucbhelper::Content aContent(m_aURLObj.GetMainURL(INetURLObject::NO_DECODE), aEnvironment);
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         // insert serialized data to content -> PUT
63cdf0e10cSrcweir         CSS::uno::Reference< XInputStream > aInStream = apSerialization->getInputStream();
64cdf0e10cSrcweir         aContent.writeStream(aInStream, sal_True);
65cdf0e10cSrcweir         //aContent.closeStream();
66cdf0e10cSrcweir 
67cdf0e10cSrcweir         // no content as a result of put...
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     }
70cdf0e10cSrcweir     catch ( const Exception& )
71cdf0e10cSrcweir     {
72cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
73cdf0e10cSrcweir         return UNKNOWN_ERROR;
74cdf0e10cSrcweir     }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     return SUCCESS;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80