LCOV - code coverage report
Current view: top level - forms/source/xforms/submission - submission_get.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 37 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 98 0.0 %

           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                 :            : 
      30                 :            : #include <memory>
      31                 :            : 
      32                 :            : #include "submission_get.hxx"
      33                 :            : #include "serialization_app_xml.hxx"
      34                 :            : #include "serialization_urlencoded.hxx"
      35                 :            : 
      36                 :            : #include <rtl/strbuf.hxx>
      37                 :            : #include <rtl/string.hxx>
      38                 :            : #include <osl/file.hxx>
      39                 :            : #include <ucbhelper/content.hxx>
      40                 :            : 
      41                 :            : using namespace CSS::uno;
      42                 :            : using namespace CSS::ucb;
      43                 :            : using namespace CSS::task;
      44                 :            : using namespace CSS::io;
      45                 :            : using namespace osl;
      46                 :            : using namespace ucbhelper;
      47                 :            : using namespace std;
      48                 :            : 
      49                 :            : using ::rtl::OUString;
      50                 :            : using ::rtl::OStringToOUString;
      51                 :            : using ::rtl::OStringBuffer;
      52                 :            : 
      53                 :            : 
      54                 :          0 : CSubmissionGet::CSubmissionGet(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment)
      55                 :          0 :     : CSubmission(aURL, aFragment)
      56                 :            : {
      57                 :          0 : }
      58                 :            : 
      59                 :          0 : CSubmission::SubmissionResult CSubmissionGet::submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& aInteractionHandler)
      60                 :            : {
      61                 :            :     // GET always uses apllicatin/x-www-formurlencoded
      62 [ #  # ][ #  # ]:          0 :     auto_ptr< CSerialization > apSerialization(new CSerializationURLEncoded());
      63         [ #  # ]:          0 :     apSerialization->setSource(m_aFragment);
      64         [ #  # ]:          0 :     apSerialization->serialize();
      65                 :            : 
      66         [ #  # ]:          0 :     CSS::uno::Reference< XInputStream > aInStream = apSerialization->getInputStream();
      67                 :            : 
      68                 :            :     // create a commandEnvironment and use the default interaction handler
      69         [ #  # ]:          0 :     CCommandEnvironmentHelper *pHelper = new CCommandEnvironmentHelper;
      70         [ #  # ]:          0 :     if( aInteractionHandler.is() )
      71         [ #  # ]:          0 :         pHelper->m_aInteractionHandler = aInteractionHandler;
      72                 :            :     else
      73         [ #  # ]:          0 :         pHelper->m_aInteractionHandler = CSS::uno::Reference< XInteractionHandler >(m_aFactory->createInstance(
      74 [ #  # ][ #  # ]:          0 :             OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.task.InteractionHandler"))), UNO_QUERY);
         [ #  # ][ #  # ]
      75                 :            :     OSL_ENSURE(pHelper->m_aInteractionHandler.is(), "failed to create IntreractionHandler");
      76         [ #  # ]:          0 :     CProgressHandlerHelper *pProgressHelper = new CProgressHandlerHelper;
      77 [ #  # ][ #  # ]:          0 :     pHelper->m_aProgressHandler = CSS::uno::Reference< XProgressHandler >(pProgressHelper);
                 [ #  # ]
      78                 :            : 
      79                 :            :     // UCB has ownership of environment...
      80 [ #  # ][ #  # ]:          0 :     CSS::uno::Reference< XCommandEnvironment > aEnvironment(pHelper);
      81                 :            : 
      82                 :            :     // append query string to the URL
      83                 :            :     try {
      84                 :            :         OStringBuffer aUTF8QueryURL(OUStringToOString(m_aURLObj.GetMainURL(INetURLObject::NO_DECODE),
      85 [ #  # ][ #  # ]:          0 :             RTL_TEXTENCODING_UTF8));
                 [ #  # ]
      86                 :          0 :         OStringBuffer aQueryString;
      87                 :            : 
      88                 :          0 :         const sal_Int32 size = 1024;
      89                 :          0 :         sal_Int32 n = 0;
      90         [ #  # ]:          0 :         Sequence< sal_Int8 > aByteBuffer(size);
      91 [ #  # ][ #  # ]:          0 :         while ((n = aInStream->readSomeBytes(aByteBuffer, size-1)) != 0)
                 [ #  # ]
      92 [ #  # ][ #  # ]:          0 :             aQueryString.append((sal_Char*)aByteBuffer.getArray(), n);
      93 [ #  # ][ #  # ]:          0 :         if (aQueryString.getLength() > 0 && m_aURLObj.GetProtocol() != INET_PROT_FILE)
                 [ #  # ]
      94                 :            :         {
      95         [ #  # ]:          0 :             aUTF8QueryURL.append('?');
      96         [ #  # ]:          0 :             aUTF8QueryURL.append(aQueryString.makeStringAndClear());
      97                 :            :         }
      98         [ #  # ]:          0 :         OUString aQueryURL = OStringToOUString(aUTF8QueryURL.makeStringAndClear(), RTL_TEXTENCODING_UTF8);
      99         [ #  # ]:          0 :         ucbhelper::Content aContent(aQueryURL, aEnvironment);
     100         [ #  # ]:          0 :         CSS::uno::Reference< XOutputStream > aPipe(m_aFactory->createInstance(
     101 [ #  # ][ #  # ]:          0 :             OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe"))), UNO_QUERY_THROW);
                 [ #  # ]
     102         [ #  # ]:          0 :         aContent.openStream(aPipe);
     103                 :            :         // get reply
     104                 :            :         try {
     105 [ #  # ][ #  # ]:          0 :             m_aResultStream = aContent.openStream();
                 [ #  # ]
     106         [ #  # ]:          0 :         } catch (const Exception&) {
     107                 :            :             OSL_FAIL("Cannot open reply stream from content");
     108 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     109         [ #  # ]:          0 :     } catch (const Exception&)
     110                 :            :     {
     111                 :            :         // XXX
     112                 :            :         OSL_FAIL("Exception during UCB operatration.");
     113                 :          0 :         return UNKNOWN_ERROR;
     114                 :            :     }
     115                 :            : 
     116         [ #  # ]:          0 :     return SUCCESS;
     117                 :            : }
     118                 :            : 
     119                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10