LCOV - code coverage report
Current view: top level - forms/source/xforms - submission.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 252 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 46 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "submission.hxx"
      21             : 
      22             : #include "model.hxx"
      23             : #include "binding.hxx"
      24             : #include "mip.hxx"
      25             : #include "evaluationcontext.hxx"
      26             : #include "unohelper.hxx"
      27             : #include "submission/submission_put.hxx"
      28             : #include "submission/submission_post.hxx"
      29             : #include "submission/submission_get.hxx"
      30             : 
      31             : #include <rtl/ustring.hxx>
      32             : #include <rtl/ustrbuf.hxx>
      33             : 
      34             : #include <com/sun/star/uno/Sequence.hxx>
      35             : #include <com/sun/star/uno/Reference.hxx>
      36             : #include <com/sun/star/xforms/XModel.hpp>
      37             : #include <com/sun/star/uno/RuntimeException.hpp>
      38             : #include <com/sun/star/xml/xpath/XXPathObject.hpp>
      39             : #include <com/sun/star/container/XNameAccess.hpp>
      40             : #include <com/sun/star/xml/xpath/XPathObjectType.hpp>
      41             : #include <com/sun/star/xml/dom/XNodeList.hpp>
      42             : #include <com/sun/star/xml/dom/XDocument.hpp>
      43             : #include <com/sun/star/xml/dom/DocumentBuilder.hpp>
      44             : #include <com/sun/star/xml/dom/XDocumentFragment.hpp>
      45             : #include <com/sun/star/xml/dom/NodeType.hpp>
      46             : #include <com/sun/star/task/XInteractionHandler.hpp>
      47             : #include <com/sun/star/task/XInteractionRequest.hpp>
      48             : #include <com/sun/star/task/XInteractionContinuation.hpp>
      49             : #include <com/sun/star/xforms/InvalidDataOnSubmitException.hpp>
      50             : #include <com/sun/star/frame/XFrame.hpp>
      51             : #include <cppuhelper/typeprovider.hxx>
      52             : #include <comphelper/propertysetinfo.hxx>
      53             : #include <comphelper/interaction.hxx>
      54             : #include <comphelper/processfactory.hxx>
      55             : #include <boost/scoped_ptr.hpp>
      56             : 
      57             : 
      58             : 
      59             : 
      60             : using com::sun::star::beans::UnknownPropertyException;
      61             : using com::sun::star::beans::PropertyVetoException;
      62             : using com::sun::star::lang::IllegalArgumentException;
      63             : using com::sun::star::util::VetoException;
      64             : using com::sun::star::form::submission::XSubmissionVetoListener;
      65             : using com::sun::star::lang::WrappedTargetException;
      66             : using com::sun::star::lang::NoSupportException;
      67             : using com::sun::star::task::XInteractionHandler;
      68             : using com::sun::star::task::XInteractionRequest;
      69             : using com::sun::star::task::XInteractionContinuation;
      70             : using com::sun::star::xforms::XModel;
      71             : using com::sun::star::xforms::InvalidDataOnSubmitException;
      72             : using com::sun::star::container::XNameAccess;
      73             : using com::sun::star::xml::xpath::XXPathObject;
      74             : using com::sun::star::xml::xpath::XPathObjectType;
      75             : using com::sun::star::frame::XFrame;
      76             : using xforms::Submission;
      77             : using xforms::Model;
      78             : using xforms::MIP;
      79             : 
      80             : using namespace com::sun::star::uno;
      81             : using namespace com::sun::star::lang;
      82             : using namespace com::sun::star::xml::dom;
      83             : 
      84           0 : Submission::Submission() :
      85             :     msID(),
      86             :     msBind(),
      87             :     maRef(),
      88             :     msAction(),
      89             :     msMethod(),
      90             :     msVersion(),
      91             :     mbIndent(),
      92             :     msMediaType(),
      93             :     msEncoding(),
      94             :     mbOmitXmlDeclaration(),
      95             :     mbStandalone(),
      96             :     msCDataSectionElement(),
      97             :     msReplace( "none" ),
      98             :     msSeparator(),
      99           0 :     msIncludeNamespacePrefixes()
     100             : {
     101           0 :     initializePropertySet();
     102           0 : }
     103             : 
     104           0 : Submission::~Submission() throw()
     105             : {
     106           0 : }
     107             : 
     108             : 
     109           0 : void Submission::setModel( const Reference<XModel>& xModel )
     110             : {
     111           0 :     mxModel = xModel;
     112           0 : }
     113             : 
     114             : 
     115           0 : void Submission::setID( const OUString& sID )
     116             : {
     117           0 :     msID = sID;
     118           0 : }
     119             : 
     120             : 
     121           0 : void Submission::setBind( const OUString& sBind )
     122             : {
     123           0 :     msBind = sBind;
     124           0 : }
     125             : 
     126           0 : OUString Submission::getRef() const
     127             : {
     128           0 :     return maRef.getExpression();
     129             : }
     130             : 
     131           0 : void Submission::setRef( const OUString& sRef )
     132             : {
     133           0 :     maRef.setExpression( sRef );
     134           0 : }
     135             : 
     136             : 
     137           0 : void Submission::setAction( const OUString& sAction )
     138             : {
     139           0 :     msAction = sAction;
     140           0 : }
     141             : 
     142             : 
     143           0 : void Submission::setMethod( const OUString& sMethod )
     144             : {
     145           0 :     msMethod = sMethod;
     146           0 : }
     147             : 
     148             : 
     149           0 : void Submission::setVersion( const OUString& sVersion )
     150             : {
     151           0 :     msVersion = sVersion;
     152           0 : }
     153             : 
     154             : 
     155           0 : void Submission::setIndent( bool bIndent )
     156             : {
     157           0 :     mbIndent = bIndent;
     158           0 : }
     159             : 
     160             : 
     161           0 : void Submission::setMediaType( const OUString& sMediaType )
     162             : {
     163           0 :     msMediaType = sMediaType;
     164           0 : }
     165             : 
     166             : 
     167           0 : void Submission::setEncoding( const OUString& sEncoding )
     168             : {
     169           0 :     msEncoding = sEncoding;
     170           0 : }
     171             : 
     172             : 
     173           0 : void Submission::setOmitXmlDeclaration( bool bOmitXmlDeclaration )
     174             : {
     175           0 :     mbOmitXmlDeclaration = bOmitXmlDeclaration;
     176           0 : }
     177             : 
     178             : 
     179           0 : void Submission::setStandalone( bool bStandalone )
     180             : {
     181           0 :     mbStandalone = bStandalone;
     182           0 : }
     183             : 
     184             : 
     185           0 : void Submission::setCDataSectionElement( const OUString& sCDataSectionElement )
     186             : {
     187           0 :     msCDataSectionElement = sCDataSectionElement;
     188           0 : }
     189             : 
     190             : 
     191           0 : void Submission::setReplace( const OUString& sReplace )
     192             : {
     193           0 :     msReplace = sReplace;
     194           0 : }
     195             : 
     196             : 
     197           0 : void Submission::setSeparator( const OUString& sSeparator )
     198             : {
     199           0 :     msSeparator = sSeparator;
     200           0 : }
     201             : 
     202             : 
     203           0 : void Submission::setIncludeNamespacePrefixes( const Sequence< OUString >& rIncludeNamespacePrefixes )
     204             : {
     205           0 :     msIncludeNamespacePrefixes = rIncludeNamespacePrefixes;
     206           0 : }
     207             : 
     208           0 : bool Submission::doSubmit( const Reference< XInteractionHandler >& xHandler )
     209             : {
     210           0 :     liveCheck();
     211             : 
     212             :     // construct XXPathObject for submission doc; use bind in preference of ref
     213           0 :     EvaluationContext aEvalContext;
     214           0 :     ComputedExpression aExpression;
     215           0 :     if( !msBind.isEmpty() )
     216             :     {
     217           0 :         Binding* pBinding = Binding::getBinding( mxModel->getBinding(msBind) );
     218           0 :         if( pBinding != NULL )
     219             :         {
     220           0 :             aExpression.setExpression( pBinding->getBindingExpression() );
     221           0 :             aEvalContext = pBinding->getEvaluationContext();
     222             :         }
     223             :         // TODO: else: illegal binding name -> raise error
     224             :     }
     225           0 :     else if( !maRef.getExpression().isEmpty() )
     226             :     {
     227           0 :         aExpression.setExpression( maRef.getExpression() );
     228           0 :         aEvalContext = Model::getModel( mxModel )->getEvaluationContext();
     229             :     }
     230             :     else
     231             :     {
     232           0 :         aExpression.setExpression( "/" );
     233           0 :         aEvalContext = Model::getModel( mxModel )->getEvaluationContext();
     234             :     }
     235           0 :     aExpression.evaluate( aEvalContext );
     236           0 :     Reference<XXPathObject> xResult = aExpression.getXPath();
     237             :     OSL_ENSURE( xResult.is(), "no result?" );
     238             : 
     239             :     // early out if we have not obtained any result
     240           0 :     if( ! xResult.is() )
     241           0 :         return false;
     242             : 
     243             : 
     244             :     // Reference< XNodeList > aList = xResult->getNodeList();
     245           0 :     OUString aMethod = getMethod();
     246             : 
     247             :     // strip whitespace-only text node for get submission
     248             :     Reference< XDocumentFragment > aFragment = createSubmissionDocument(
     249           0 :         xResult, aMethod.equalsIgnoreAsciiCase("get"));
     250             : 
     251             :     // submit result; set encoding, etc.
     252           0 :     boost::scoped_ptr<CSubmission> xSubmission;
     253           0 :     if (aMethod.equalsIgnoreAsciiCase("PUT"))
     254           0 :         xSubmission.reset(new CSubmissionPut( getAction(), aFragment));
     255           0 :     else if (aMethod.equalsIgnoreAsciiCase("post"))
     256           0 :         xSubmission.reset(new CSubmissionPost( getAction(), aFragment));
     257           0 :     else if (aMethod.equalsIgnoreAsciiCase("get"))
     258           0 :         xSubmission.reset(new CSubmissionGet( getAction(), aFragment));
     259             :     else
     260             :     {
     261             :         OSL_FAIL("Unsupported xforms submission method");
     262           0 :         return false;
     263             :     }
     264             : 
     265           0 :     xSubmission->setEncoding(getEncoding());
     266           0 :     CSubmission::SubmissionResult aResult = xSubmission->submit( xHandler );
     267             : 
     268           0 :     if (aResult == CSubmission::SUCCESS)
     269             :     {
     270           0 :         Reference< XDocument > aInstanceDoc = getInstanceDocument(xResult);
     271           0 :         aResult = xSubmission->replace(getReplace(), aInstanceDoc, Reference< XFrame >());
     272             :     }
     273             : 
     274           0 :     return ( aResult == CSubmission::SUCCESS );
     275             : }
     276             : 
     277           0 : Sequence<sal_Int8> Submission::getUnoTunnelID()
     278             : {
     279           0 :     static cppu::OImplementationId aImplementationId;
     280           0 :     return aImplementationId.getImplementationId();
     281             : }
     282             : 
     283           0 : Submission* Submission::getSubmission(
     284             :     const Reference<XPropertySet>& xPropertySet )
     285             : {
     286           0 :     Reference<XUnoTunnel> xTunnel( xPropertySet, UNO_QUERY );
     287           0 :     return xTunnel.is()
     288             :         ? reinterpret_cast<Submission*>(
     289           0 :             xTunnel->getSomething( getUnoTunnelID() ) )
     290           0 :         : NULL;
     291             : }
     292             : 
     293             : 
     294             : 
     295             : 
     296             : 
     297             : 
     298           0 : void Submission::liveCheck()
     299             :     throw( RuntimeException )
     300             : {
     301           0 :     bool bValid = mxModel.is();
     302             : 
     303           0 :     if( ! bValid )
     304           0 :         throw RuntimeException();
     305           0 : }
     306             : 
     307           0 : Model* Submission::getModelImpl() const
     308             : {
     309           0 :     Model* pModel = NULL;
     310           0 :     if( mxModel.is() )
     311           0 :         pModel = Model::getModel( mxModel );
     312           0 :     return pModel;
     313             : }
     314             : 
     315             : 
     316             : 
     317             : // Property-Set implementation
     318             : 
     319             : 
     320             : #define HANDLE_ID 0
     321             : #define HANDLE_Bind 1
     322             : #define HANDLE_Ref 2
     323             : #define HANDLE_Action 3
     324             : #define HANDLE_Method 4
     325             : #define HANDLE_Version 5
     326             : #define HANDLE_Indent 6
     327             : #define HANDLE_MediaType 7
     328             : #define HANDLE_Encoding 8
     329             : #define HANDLE_OmitXmlDeclaration 9
     330             : #define HANDLE_Standalone 10
     331             : #define HANDLE_CDataSectionElement 11
     332             : #define HANDLE_Replace 12
     333             : #define HANDLE_Separator 13
     334             : #define HANDLE_IncludeNamespacePrefixes 14
     335             : #define HANDLE_Model 15
     336             : 
     337             : #define REGISTER_PROPERTY( property, type )   \
     338             :     registerProperty( PROPERTY( property, type ), \
     339             :     new DirectPropertyAccessor< Submission, type >( this, &Submission::set##property, &Submission::get##property ) );
     340             : 
     341             : #define REGISTER_PROPERTY_BOOL( property )   \
     342             :     registerProperty( PROPERTY( property, bool ), \
     343             :     new BooleanPropertyAccessor< Submission, bool >( this, &Submission::set##property, &Submission::get##property ) );
     344             : 
     345           0 : void Submission::initializePropertySet()
     346             : {
     347           0 :     REGISTER_PROPERTY     ( ID,                         OUString );
     348           0 :     REGISTER_PROPERTY     ( Bind,                       OUString );
     349           0 :     REGISTER_PROPERTY     ( Ref,                        OUString );
     350           0 :     REGISTER_PROPERTY     ( Action,                     OUString );
     351           0 :     REGISTER_PROPERTY     ( Method,                     OUString );
     352           0 :     REGISTER_PROPERTY     ( Version,                    OUString );
     353           0 :     REGISTER_PROPERTY_BOOL( Indent );
     354           0 :     REGISTER_PROPERTY     ( MediaType,                  OUString );
     355           0 :     REGISTER_PROPERTY     ( Encoding,                   OUString );
     356           0 :     REGISTER_PROPERTY_BOOL( OmitXmlDeclaration );
     357           0 :     REGISTER_PROPERTY_BOOL( Standalone );
     358           0 :     REGISTER_PROPERTY     ( CDataSectionElement,        OUString );
     359           0 :     REGISTER_PROPERTY     ( Replace,                    OUString );
     360           0 :     REGISTER_PROPERTY     ( Separator,                  OUString );
     361           0 :     REGISTER_PROPERTY     ( IncludeNamespacePrefixes,   Sequence< OUString > );
     362           0 :     REGISTER_PROPERTY     ( Model,                      Reference<XModel> );
     363             : 
     364           0 :     initializePropertyValueCache( HANDLE_Indent );
     365           0 :     initializePropertyValueCache( HANDLE_OmitXmlDeclaration );
     366           0 :     initializePropertyValueCache( HANDLE_Standalone );
     367           0 : }
     368             : 
     369           0 : sal_Bool SAL_CALL Submission::convertFastPropertyValue(
     370             :     Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue )
     371             :     throw ( IllegalArgumentException )
     372             : {
     373           0 :     if ( nHandle == HANDLE_IncludeNamespacePrefixes )
     374             :     {
     375             :         // for convinience reasons (????), we accept a string which contains
     376             :         // a comma-separated list of namespace prefixes
     377           0 :         OUString sTokenList;
     378           0 :         if ( rValue >>= sTokenList )
     379             :         {
     380           0 :             std::vector< OUString > aPrefixes;
     381           0 :             sal_Int32 p = 0;
     382           0 :             while ( p >= 0 )
     383           0 :                 aPrefixes.push_back( sTokenList.getToken( 0, ',', p ) );
     384             : 
     385           0 :             Sequence< OUString > aConvertedPrefixes( &aPrefixes[0], aPrefixes.size() );
     386           0 :             return PropertySetBase::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, makeAny( aConvertedPrefixes ) );
     387           0 :         }
     388             :     }
     389             : 
     390           0 :     return PropertySetBase::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
     391             : }
     392             : 
     393           0 : OUString SAL_CALL Submission::getName()
     394             :     throw( RuntimeException, std::exception )
     395             : {
     396           0 :     return getID();
     397             : }
     398             : 
     399           0 : void SAL_CALL Submission::setName( const OUString& sID )
     400             :     throw( RuntimeException, std::exception )
     401             : {
     402           0 :     setID( sID );
     403           0 : }
     404             : 
     405             : 
     406             : 
     407           0 : sal_Int64 SAL_CALL Submission::getSomething(
     408             :     const Sequence<sal_Int8>& aId )
     409             :     throw( RuntimeException, std::exception )
     410             : {
     411           0 :     return ( aId == getUnoTunnelID() ) ? reinterpret_cast<sal_Int64>(this) : 0;
     412             : }
     413             : 
     414             : 
     415           0 : static OUString lcl_message( const OUString& rID, const OUString& rText )
     416             : {
     417           0 :     OUString aMessage = "XForms submission '" + rID + "' failed" + rText + ".";
     418           0 :     return aMessage;
     419             : }
     420             : 
     421           0 : void SAL_CALL Submission::submitWithInteraction(
     422             :     const Reference<XInteractionHandler>& _rxHandler )
     423             :     throw ( VetoException,
     424             :             WrappedTargetException,
     425             :             RuntimeException, std::exception )
     426             : {
     427             :     // as long as this class is not really threadsafe, we need to copy
     428             :     // the members we're interested in
     429           0 :     Reference< XModel > xModel( mxModel );
     430           0 :     OUString sID( msID );
     431             : 
     432           0 :     if ( !xModel.is() || msID.isEmpty() )
     433             :         throw RuntimeException(
     434             :                 "This is not a valid submission object.",
     435             :                 *this
     436           0 :               );
     437             : 
     438           0 :     Model* pModel = Model::getModel( xModel );
     439             :     OSL_ENSURE( pModel != NULL, "illegal model?" );
     440             : 
     441             :     // #i36765# #i47248# warning on submission of illegal data
     442             :     // check for validity (and query user if invalid)
     443           0 :     bool bValid = pModel->isValid();
     444           0 :     if( ! bValid )
     445             :     {
     446             :         InvalidDataOnSubmitException aInvalidDataException(
     447           0 :             lcl_message(sID, " due to invalid data" ), *this );
     448             : 
     449           0 :         if( _rxHandler.is() )
     450             :         {
     451             :             // labouriously create interaction request
     452             :             comphelper::OInteractionRequest* pRequest
     453             :                 = new comphelper::OInteractionRequest(
     454           0 :                     makeAny( aInvalidDataException ) );
     455           0 :             Reference<XInteractionRequest> xRequest = pRequest;
     456             : 
     457             :             comphelper::OInteractionApprove* pContinue
     458           0 :                 = new comphelper::OInteractionApprove();
     459           0 :             Reference<XInteractionContinuation> xContinue = pContinue;
     460           0 :             pRequest->addContinuation( xContinue );
     461             : 
     462             :             comphelper::OInteractionDisapprove* pCancel
     463           0 :                 = new comphelper::OInteractionDisapprove();
     464           0 :             Reference<XInteractionContinuation> xCancel = pCancel;
     465           0 :             pRequest->addContinuation( xCancel );
     466             : 
     467             :             // ask the handler...
     468           0 :             _rxHandler->handle( xRequest );
     469             :             OSL_ENSURE( pContinue->wasSelected() || pCancel->wasSelected(),
     470             :                         "handler didn't select" );
     471             : 
     472             :             // and continue, if user chose 'continue'
     473           0 :             if( pContinue->wasSelected() )
     474           0 :                 bValid = true;
     475             :         }
     476             : 
     477             :         // abort if invalid (and user didn't tell us to continue)
     478           0 :         if( ! bValid )
     479           0 :             throw aInvalidDataException;
     480             :     }
     481             : 
     482             :     // attempt submission
     483           0 :     bool bResult = false;
     484             :     try
     485             :     {
     486           0 :         bResult = doSubmit( _rxHandler );
     487             :     }
     488           0 :     catch( const VetoException& )
     489             :     {
     490             :         OSL_FAIL( "Model::submit: Hmm. How can a single submission have a veto right?" );
     491             :         // allowed to leave
     492           0 :         throw;
     493             :     }
     494           0 :     catch( const Exception& e )
     495             :     {
     496             :         // exception caught: re-throw as wrapped target exception
     497             :         throw WrappedTargetException(
     498             :             lcl_message( sID, " due to exception being thrown" ),
     499           0 :             *this, makeAny( e ) );
     500             :     }
     501             : 
     502           0 :     if( bResult )
     503             :     {
     504           0 :         mxModel->rebuild();
     505             :     }
     506             :     else
     507             :     {
     508             :         // other failure: throw wrapped target exception, too.
     509             :         throw WrappedTargetException(
     510           0 :             lcl_message( sID, OUString() ), *this, Any() );
     511           0 :     }
     512           0 : }
     513             : 
     514           0 : void SAL_CALL Submission::submit( ) throw ( VetoException, WrappedTargetException, RuntimeException, std::exception )
     515             : {
     516           0 :     submitWithInteraction( NULL );
     517           0 : }
     518             : 
     519           0 : void SAL_CALL Submission::addSubmissionVetoListener( const Reference< XSubmissionVetoListener >& /*listener*/ ) throw (NoSupportException, RuntimeException, std::exception)
     520             : {
     521             :     // TODO
     522           0 :     throw NoSupportException();
     523             : }
     524             : 
     525           0 : void SAL_CALL Submission::removeSubmissionVetoListener( const Reference< XSubmissionVetoListener >& /*listener*/ ) throw (NoSupportException, RuntimeException, std::exception)
     526             : {
     527             :     // TODO
     528           0 :     throw NoSupportException();
     529             : }
     530             : 
     531           0 : static bool _isIgnorable(const Reference< XNode >& aNode)
     532             : {
     533             :     // ignore whitespace-only textnodes
     534           0 :     if (aNode->getNodeType() == NodeType_TEXT_NODE)
     535             :     {
     536           0 :         OUString aTrimmedValue = aNode->getNodeValue().trim();
     537           0 :         if (aTrimmedValue.isEmpty()) return true;
     538             :     }
     539             : 
     540           0 :     return false;
     541             : }
     542             : 
     543             : // recursively copy relevant nodes from A to B
     544           0 : static void _cloneNodes(Model& aModel, const Reference< XNode >& dstParent, const Reference< XNode >& source, bool bRemoveWSNodes)
     545             : {
     546           0 :     if (!source.is()) return;
     547             : 
     548           0 :     Reference< XNode > cur = source;
     549           0 :     Reference< XDocument > dstDoc = dstParent->getOwnerDocument();
     550           0 :     Reference< XNode > imported;
     551             : 
     552           0 :     if (cur.is())
     553             :     {
     554             :         //  is this node relevant?
     555           0 :         MIP mip = aModel.queryMIP(cur);
     556           0 :         if(mip.isRelevant() && !(bRemoveWSNodes && _isIgnorable(cur)))
     557             :         {
     558           0 :             imported = dstDoc->importNode(cur, sal_False);
     559           0 :             imported = dstParent->appendChild(imported);
     560             :             // append source children to new imported parent
     561           0 :             for( cur = cur->getFirstChild(); cur.is(); cur = cur->getNextSibling() )
     562           0 :                 _cloneNodes(aModel, imported, cur, bRemoveWSNodes);
     563           0 :         }
     564           0 :     }
     565             : }
     566           0 : Reference< XDocument > Submission::getInstanceDocument(const Reference< XXPathObject >& aObj)
     567             : {
     568             :     using namespace com::sun::star::xml::xpath;
     569             :     // result
     570           0 :     Reference< XDocument > aDocument;
     571             : 
     572           0 :     if (aObj->getObjectType() == XPathObjectType_XPATH_NODESET)
     573             :     {
     574           0 :         Reference< XNodeList > aList = aObj->getNodeList();
     575           0 :         if (aList->getLength() > 0)
     576           0 :             aDocument = aList->item(0)->getOwnerDocument();
     577             :     }
     578           0 :     return aDocument;
     579             : }
     580             : 
     581           0 : Reference< XDocumentFragment > Submission::createSubmissionDocument(const Reference< XXPathObject >& aObj, bool bRemoveWSNodes)
     582             : {
     583             :     using namespace com::sun::star::xml::xpath;
     584           0 :     Reference< XDocumentBuilder > aDocBuilder = DocumentBuilder::create(comphelper::getProcessComponentContext());
     585           0 :     Reference< XDocument > aDocument = aDocBuilder->newDocument();
     586           0 :     Reference< XDocumentFragment > aFragment = aDocument->createDocumentFragment();
     587             : 
     588             : 
     589           0 :     if (aObj->getObjectType() == XPathObjectType_XPATH_NODESET)
     590             :     {
     591           0 :         Reference< XNodeList > aList = aObj->getNodeList();
     592           0 :         Reference< XNode > aListItem;
     593           0 :         for (sal_Int32 i=0; i < aList->getLength(); i++)
     594             :         {
     595           0 :             aListItem = aList->item(i);
     596           0 :             if (aListItem->getNodeType()==NodeType_DOCUMENT_NODE)
     597           0 :                 aListItem = Reference< XNode >(
     598           0 :                     (Reference< XDocument >(aListItem, UNO_QUERY))->getDocumentElement(), UNO_QUERY);
     599             :             // copy relevant nodes from instance into fragment
     600           0 :             _cloneNodes(*getModelImpl(), aFragment, aListItem, bRemoveWSNodes);
     601           0 :         }
     602             :     }
     603           0 :     return aFragment;
     604             : }
     605             : 
     606             : // some forwarding: XPropertySet is implemented in our base class,
     607             : // but also available as base of XSubmission
     608           0 : Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL Submission::getPropertySetInfo(  ) throw(RuntimeException, std::exception)
     609             : {
     610           0 :     return PropertySetBase::getPropertySetInfo();
     611             : }
     612           0 : void SAL_CALL Submission::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
     613             : {
     614           0 :     PropertySetBase::setPropertyValue( aPropertyName, aValue );
     615           0 : }
     616           0 : Any SAL_CALL Submission::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     617             : {
     618           0 :     return PropertySetBase::getPropertyValue( PropertyName );
     619             : }
     620           0 : void SAL_CALL Submission::addPropertyChangeListener( const OUString& aPropertyName, const Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     621             : {
     622           0 :     PropertySetBase::addPropertyChangeListener( aPropertyName, xListener );
     623           0 : }
     624           0 : void SAL_CALL Submission::removePropertyChangeListener( const OUString& aPropertyName, const Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     625             : {
     626           0 :     PropertySetBase::removePropertyChangeListener( aPropertyName, aListener );
     627           0 : }
     628           0 : void SAL_CALL Submission::addVetoableChangeListener( const OUString& PropertyName, const Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     629             : {
     630           0 :     PropertySetBase::addVetoableChangeListener( PropertyName, aListener );
     631           0 : }
     632           0 : void SAL_CALL Submission::removeVetoableChangeListener( const OUString& PropertyName, const Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     633             : {
     634           0 :     PropertySetBase::removeVetoableChangeListener( PropertyName, aListener );
     635           0 : }
     636             : 
     637             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11