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 0 : Reference<XModel> Submission::getModel() const
109 : {
110 0 : return mxModel;
111 : }
112 :
113 0 : void Submission::setModel( const Reference<XModel>& xModel )
114 : {
115 0 : mxModel = xModel;
116 0 : }
117 :
118 0 : OUString Submission::getID() const
119 : {
120 0 : return msID;
121 : }
122 :
123 0 : void Submission::setID( const OUString& sID )
124 : {
125 0 : msID = sID;
126 0 : }
127 :
128 0 : OUString Submission::getBind() const
129 : {
130 0 : return msBind;
131 : }
132 :
133 0 : void Submission::setBind( const OUString& sBind )
134 : {
135 0 : msBind = sBind;
136 0 : }
137 :
138 0 : OUString Submission::getRef() const
139 : {
140 0 : return maRef.getExpression();
141 : }
142 :
143 0 : void Submission::setRef( const OUString& sRef )
144 : {
145 0 : maRef.setExpression( sRef );
146 0 : }
147 :
148 0 : OUString Submission::getAction() const
149 : {
150 0 : return msAction;
151 : }
152 :
153 0 : void Submission::setAction( const OUString& sAction )
154 : {
155 0 : msAction = sAction;
156 0 : }
157 :
158 0 : OUString Submission::getMethod() const
159 : {
160 0 : return msMethod;
161 : }
162 :
163 0 : void Submission::setMethod( const OUString& sMethod )
164 : {
165 0 : msMethod = sMethod;
166 0 : }
167 :
168 0 : OUString Submission::getVersion() const
169 : {
170 0 : return msVersion;
171 : }
172 :
173 0 : void Submission::setVersion( const OUString& sVersion )
174 : {
175 0 : msVersion = sVersion;
176 0 : }
177 :
178 0 : bool Submission::getIndent() const
179 : {
180 0 : return mbIndent;
181 : }
182 :
183 0 : void Submission::setIndent( bool bIndent )
184 : {
185 0 : mbIndent = bIndent;
186 0 : }
187 :
188 0 : OUString Submission::getMediaType() const
189 : {
190 0 : return msMediaType;
191 : }
192 :
193 0 : void Submission::setMediaType( const OUString& sMediaType )
194 : {
195 0 : msMediaType = sMediaType;
196 0 : }
197 :
198 0 : OUString Submission::getEncoding() const
199 : {
200 0 : return msEncoding;
201 : }
202 :
203 0 : void Submission::setEncoding( const OUString& sEncoding )
204 : {
205 0 : msEncoding = sEncoding;
206 0 : }
207 :
208 0 : bool Submission::getOmitXmlDeclaration() const
209 : {
210 0 : return mbOmitXmlDeclaration;
211 : }
212 :
213 0 : void Submission::setOmitXmlDeclaration( bool bOmitXmlDeclaration )
214 : {
215 0 : mbOmitXmlDeclaration = bOmitXmlDeclaration;
216 0 : }
217 :
218 0 : bool Submission::getStandalone() const
219 : {
220 0 : return mbStandalone;
221 : }
222 :
223 0 : void Submission::setStandalone( bool bStandalone )
224 : {
225 0 : mbStandalone = bStandalone;
226 0 : }
227 :
228 0 : OUString Submission::getCDataSectionElement() const
229 : {
230 0 : return msCDataSectionElement;
231 : }
232 :
233 0 : void Submission::setCDataSectionElement( const OUString& sCDataSectionElement )
234 : {
235 0 : msCDataSectionElement = sCDataSectionElement;
236 0 : }
237 :
238 0 : OUString Submission::getReplace() const
239 : {
240 0 : return msReplace;
241 : }
242 :
243 0 : void Submission::setReplace( const OUString& sReplace )
244 : {
245 0 : msReplace = sReplace;
246 0 : }
247 :
248 0 : OUString Submission::getSeparator() const
249 : {
250 0 : return msSeparator;
251 : }
252 :
253 0 : void Submission::setSeparator( const OUString& sSeparator )
254 : {
255 0 : msSeparator = sSeparator;
256 0 : }
257 :
258 0 : Sequence< OUString > Submission::getIncludeNamespacePrefixes() const
259 : {
260 0 : return msIncludeNamespacePrefixes;
261 : }
262 :
263 0 : void Submission::setIncludeNamespacePrefixes( const Sequence< OUString >& rIncludeNamespacePrefixes )
264 : {
265 0 : msIncludeNamespacePrefixes = rIncludeNamespacePrefixes;
266 0 : }
267 :
268 0 : bool Submission::doSubmit( const Reference< XInteractionHandler >& xHandler )
269 : {
270 0 : liveCheck();
271 :
272 : // construct XXPathObject for submission doc; use bind in preference of ref
273 0 : EvaluationContext aEvalContext;
274 0 : ComputedExpression aExpression;
275 0 : if( !msBind.isEmpty() )
276 : {
277 0 : Binding* pBinding = Binding::getBinding( mxModel->getBinding(msBind) );
278 0 : if( pBinding != NULL )
279 : {
280 0 : aExpression.setExpression( pBinding->getBindingExpression() );
281 0 : aEvalContext = pBinding->getEvaluationContext();
282 : }
283 : // TODO: else: illegal binding name -> raise error
284 : }
285 0 : else if( !maRef.getExpression().isEmpty() )
286 : {
287 0 : aExpression.setExpression( maRef.getExpression() );
288 0 : aEvalContext = Model::getModel( mxModel )->getEvaluationContext();
289 : }
290 : else
291 : {
292 0 : aExpression.setExpression( "/" );
293 0 : aEvalContext = Model::getModel( mxModel )->getEvaluationContext();
294 : }
295 0 : aExpression.evaluate( aEvalContext );
296 0 : Reference<XXPathObject> xResult = aExpression.getXPath();
297 : OSL_ENSURE( xResult.is(), "no result?" );
298 :
299 : // early out if we have not obtained any result
300 0 : if( ! xResult.is() )
301 0 : return false;
302 :
303 :
304 : // Reference< XNodeList > aList = xResult->getNodeList();
305 0 : OUString aMethod = getMethod();
306 :
307 : // strip whitespace-only text node for get submission
308 : Reference< XDocumentFragment > aFragment = createSubmissionDocument(
309 0 : xResult, aMethod.equalsIgnoreAsciiCase("get"));
310 :
311 : // submit result; set encoding, etc.
312 0 : boost::scoped_ptr<CSubmission> xSubmission;
313 0 : if (aMethod.equalsIgnoreAsciiCase("PUT"))
314 0 : xSubmission.reset(new CSubmissionPut( getAction(), aFragment));
315 0 : else if (aMethod.equalsIgnoreAsciiCase("post"))
316 0 : xSubmission.reset(new CSubmissionPost( getAction(), aFragment));
317 0 : else if (aMethod.equalsIgnoreAsciiCase("get"))
318 0 : xSubmission.reset(new CSubmissionGet( getAction(), aFragment));
319 : else
320 : {
321 : OSL_FAIL("Unsupported xforms submission method");
322 0 : return false;
323 : }
324 :
325 0 : xSubmission->setEncoding(getEncoding());
326 0 : CSubmission::SubmissionResult aResult = xSubmission->submit( xHandler );
327 :
328 0 : if (aResult == CSubmission::SUCCESS)
329 : {
330 0 : Reference< XDocument > aInstanceDoc = getInstanceDocument(xResult);
331 0 : aResult = xSubmission->replace(getReplace(), aInstanceDoc, Reference< XFrame >());
332 : }
333 :
334 0 : return ( aResult == CSubmission::SUCCESS );
335 : }
336 :
337 0 : Sequence<sal_Int8> Submission::getUnoTunnelID()
338 : {
339 0 : static cppu::OImplementationId aImplementationId;
340 0 : return aImplementationId.getImplementationId();
341 : }
342 :
343 0 : Submission* Submission::getSubmission(
344 : const Reference<XPropertySet>& xPropertySet )
345 : {
346 0 : Reference<XUnoTunnel> xTunnel( xPropertySet, UNO_QUERY );
347 0 : return xTunnel.is()
348 : ? reinterpret_cast<Submission*>(
349 0 : xTunnel->getSomething( getUnoTunnelID() ) )
350 0 : : NULL;
351 : }
352 :
353 :
354 :
355 :
356 :
357 :
358 0 : void Submission::liveCheck()
359 : throw( RuntimeException )
360 : {
361 0 : bool bValid = mxModel.is();
362 :
363 0 : if( ! bValid )
364 0 : throw RuntimeException();
365 0 : }
366 :
367 0 : Model* Submission::getModelImpl() const
368 : {
369 0 : Model* pModel = NULL;
370 0 : if( mxModel.is() )
371 0 : pModel = Model::getModel( mxModel );
372 0 : return pModel;
373 : }
374 :
375 :
376 :
377 : // Property-Set implementation
378 :
379 :
380 : #define HANDLE_ID 0
381 : #define HANDLE_Bind 1
382 : #define HANDLE_Ref 2
383 : #define HANDLE_Action 3
384 : #define HANDLE_Method 4
385 : #define HANDLE_Version 5
386 : #define HANDLE_Indent 6
387 : #define HANDLE_MediaType 7
388 : #define HANDLE_Encoding 8
389 : #define HANDLE_OmitXmlDeclaration 9
390 : #define HANDLE_Standalone 10
391 : #define HANDLE_CDataSectionElement 11
392 : #define HANDLE_Replace 12
393 : #define HANDLE_Separator 13
394 : #define HANDLE_IncludeNamespacePrefixes 14
395 : #define HANDLE_Model 15
396 :
397 : #define REGISTER_PROPERTY( property, type ) \
398 : registerProperty( PROPERTY( property, type ), \
399 : new DirectPropertyAccessor< Submission, type >( this, &Submission::set##property, &Submission::get##property ) );
400 :
401 : #define REGISTER_PROPERTY_BOOL( property ) \
402 : registerProperty( PROPERTY( property, bool ), \
403 : new BooleanPropertyAccessor< Submission, bool >( this, &Submission::set##property, &Submission::get##property ) );
404 :
405 0 : void Submission::initializePropertySet()
406 : {
407 0 : REGISTER_PROPERTY ( ID, OUString );
408 0 : REGISTER_PROPERTY ( Bind, OUString );
409 0 : REGISTER_PROPERTY ( Ref, OUString );
410 0 : REGISTER_PROPERTY ( Action, OUString );
411 0 : REGISTER_PROPERTY ( Method, OUString );
412 0 : REGISTER_PROPERTY ( Version, OUString );
413 0 : REGISTER_PROPERTY_BOOL( Indent );
414 0 : REGISTER_PROPERTY ( MediaType, OUString );
415 0 : REGISTER_PROPERTY ( Encoding, OUString );
416 0 : REGISTER_PROPERTY_BOOL( OmitXmlDeclaration );
417 0 : REGISTER_PROPERTY_BOOL( Standalone );
418 0 : REGISTER_PROPERTY ( CDataSectionElement, OUString );
419 0 : REGISTER_PROPERTY ( Replace, OUString );
420 0 : REGISTER_PROPERTY ( Separator, OUString );
421 0 : REGISTER_PROPERTY ( IncludeNamespacePrefixes, Sequence< OUString > );
422 0 : REGISTER_PROPERTY ( Model, Reference<XModel> );
423 :
424 0 : initializePropertyValueCache( HANDLE_Indent );
425 0 : initializePropertyValueCache( HANDLE_OmitXmlDeclaration );
426 0 : initializePropertyValueCache( HANDLE_Standalone );
427 0 : }
428 :
429 0 : sal_Bool SAL_CALL Submission::convertFastPropertyValue(
430 : Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue )
431 : throw ( IllegalArgumentException )
432 : {
433 0 : if ( nHandle == HANDLE_IncludeNamespacePrefixes )
434 : {
435 : // for convinience reasons (????), we accept a string which contains
436 : // a comma-separated list of namespace prefixes
437 0 : OUString sTokenList;
438 0 : if ( rValue >>= sTokenList )
439 : {
440 0 : std::vector< OUString > aPrefixes;
441 0 : sal_Int32 p = 0;
442 0 : while ( p >= 0 )
443 0 : aPrefixes.push_back( sTokenList.getToken( 0, ',', p ) );
444 :
445 0 : Sequence< OUString > aConvertedPrefixes( &aPrefixes[0], aPrefixes.size() );
446 0 : return PropertySetBase::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, makeAny( aConvertedPrefixes ) );
447 0 : }
448 : }
449 :
450 0 : return PropertySetBase::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
451 : }
452 :
453 0 : OUString SAL_CALL Submission::getName()
454 : throw( RuntimeException, std::exception )
455 : {
456 0 : return getID();
457 : }
458 :
459 0 : void SAL_CALL Submission::setName( const OUString& sID )
460 : throw( RuntimeException, std::exception )
461 : {
462 0 : setID( sID );
463 0 : }
464 :
465 :
466 :
467 0 : sal_Int64 SAL_CALL Submission::getSomething(
468 : const Sequence<sal_Int8>& aId )
469 : throw( RuntimeException, std::exception )
470 : {
471 0 : return ( aId == getUnoTunnelID() ) ? reinterpret_cast<sal_Int64>(this) : 0;
472 : }
473 :
474 :
475 0 : static OUString lcl_message( const OUString& rID, const OUString& rText )
476 : {
477 0 : OUString aMessage = "XForms submission '" + rID + "' failed" + rText + ".";
478 0 : return aMessage;
479 : }
480 :
481 0 : void SAL_CALL Submission::submitWithInteraction(
482 : const Reference<XInteractionHandler>& _rxHandler )
483 : throw ( VetoException,
484 : WrappedTargetException,
485 : RuntimeException, std::exception )
486 : {
487 : // as long as this class is not really threadsafe, we need to copy
488 : // the members we're interested in
489 0 : Reference< XModel > xModel( mxModel );
490 0 : OUString sID( msID );
491 :
492 0 : if ( !xModel.is() || msID.isEmpty() )
493 : throw RuntimeException(
494 : OUString( "This is not a valid submission object." ),
495 : *this
496 0 : );
497 :
498 0 : Model* pModel = Model::getModel( xModel );
499 : OSL_ENSURE( pModel != NULL, "illegal model?" );
500 :
501 : // #i36765# #i47248# warning on submission of illegal data
502 : // check for validity (and query user if invalid)
503 0 : bool bValid = pModel->isValid();
504 0 : if( ! bValid )
505 : {
506 : InvalidDataOnSubmitException aInvalidDataException(
507 0 : lcl_message(sID, " due to invalid data" ), *this );
508 :
509 0 : if( _rxHandler.is() )
510 : {
511 : // labouriously create interaction request
512 : comphelper::OInteractionRequest* pRequest
513 : = new comphelper::OInteractionRequest(
514 0 : makeAny( aInvalidDataException ) );
515 0 : Reference<XInteractionRequest> xRequest = pRequest;
516 :
517 : comphelper::OInteractionApprove* pContinue
518 0 : = new comphelper::OInteractionApprove();
519 0 : Reference<XInteractionContinuation> xContinue = pContinue;
520 0 : pRequest->addContinuation( xContinue );
521 :
522 : comphelper::OInteractionDisapprove* pCancel
523 0 : = new comphelper::OInteractionDisapprove();
524 0 : Reference<XInteractionContinuation> xCancel = pCancel;
525 0 : pRequest->addContinuation( xCancel );
526 :
527 : // ask the handler...
528 0 : _rxHandler->handle( xRequest );
529 : OSL_ENSURE( pContinue->wasSelected() || pCancel->wasSelected(),
530 : "handler didn't select" );
531 :
532 : // and continue, if user chose 'continue'
533 0 : if( pContinue->wasSelected() )
534 0 : bValid = true;
535 : }
536 :
537 : // abort if invalid (and user didn't tell us to continue)
538 0 : if( ! bValid )
539 0 : throw aInvalidDataException;
540 : }
541 :
542 : // attempt submission
543 0 : bool bResult = false;
544 : try
545 : {
546 0 : bResult = doSubmit( _rxHandler );
547 : }
548 0 : catch( const VetoException& )
549 : {
550 : OSL_FAIL( "Model::submit: Hmm. How can a single submission have a veto right?" );
551 : // allowed to leave
552 0 : throw;
553 : }
554 0 : catch( const Exception& e )
555 : {
556 : // exception caught: re-throw as wrapped target exception
557 : throw WrappedTargetException(
558 : lcl_message( sID, " due to exception being thrown" ),
559 0 : *this, makeAny( e ) );
560 : }
561 :
562 0 : if( bResult )
563 : {
564 0 : mxModel->rebuild();
565 : }
566 : else
567 : {
568 : // other failure: throw wrapped target exception, too.
569 : throw WrappedTargetException(
570 0 : lcl_message( sID, OUString() ), *this, Any() );
571 0 : }
572 0 : }
573 :
574 0 : void SAL_CALL Submission::submit( ) throw ( VetoException, WrappedTargetException, RuntimeException, std::exception )
575 : {
576 0 : submitWithInteraction( NULL );
577 0 : }
578 :
579 0 : void SAL_CALL Submission::addSubmissionVetoListener( const Reference< XSubmissionVetoListener >& /*listener*/ ) throw (NoSupportException, RuntimeException, std::exception)
580 : {
581 : // TODO
582 0 : throw NoSupportException();
583 : }
584 :
585 0 : void SAL_CALL Submission::removeSubmissionVetoListener( const Reference< XSubmissionVetoListener >& /*listener*/ ) throw (NoSupportException, RuntimeException, std::exception)
586 : {
587 : // TODO
588 0 : throw NoSupportException();
589 : }
590 :
591 0 : static sal_Bool _isIgnorable(const Reference< XNode >& aNode)
592 : {
593 : // ignore whitespace-only textnodes
594 0 : if (aNode->getNodeType() == NodeType_TEXT_NODE)
595 : {
596 0 : OUString aTrimmedValue = aNode->getNodeValue().trim();
597 0 : if (aTrimmedValue.isEmpty()) return sal_True;
598 : }
599 :
600 0 : return sal_False;
601 : }
602 :
603 : // recursively copy relevant nodes from A to B
604 0 : static void _cloneNodes(Model& aModel, const Reference< XNode >& dstParent, const Reference< XNode >& source, sal_Bool bRemoveWSNodes)
605 : {
606 0 : if (!source.is()) return;
607 :
608 0 : Reference< XNode > cur = source;
609 0 : Reference< XDocument > dstDoc = dstParent->getOwnerDocument();
610 0 : Reference< XNode > imported;
611 :
612 0 : if (cur.is())
613 : {
614 : // is this node relevant?
615 0 : MIP mip = aModel.queryMIP(cur);
616 0 : if(mip.isRelevant() && !(bRemoveWSNodes && _isIgnorable(cur)))
617 : {
618 0 : imported = dstDoc->importNode(cur, sal_False);
619 0 : imported = dstParent->appendChild(imported);
620 : // append source children to new imported parent
621 0 : for( cur = cur->getFirstChild(); cur.is(); cur = cur->getNextSibling() )
622 0 : _cloneNodes(aModel, imported, cur, bRemoveWSNodes);
623 0 : }
624 0 : }
625 : }
626 0 : Reference< XDocument > Submission::getInstanceDocument(const Reference< XXPathObject >& aObj)
627 : {
628 : using namespace com::sun::star::xml::xpath;
629 : // result
630 0 : Reference< XDocument > aDocument;
631 :
632 0 : if (aObj->getObjectType() == XPathObjectType_XPATH_NODESET)
633 : {
634 0 : Reference< XNodeList > aList = aObj->getNodeList();
635 0 : if (aList->getLength() > 0)
636 0 : aDocument = aList->item(0)->getOwnerDocument();
637 : }
638 0 : return aDocument;
639 : }
640 :
641 0 : Reference< XDocumentFragment > Submission::createSubmissionDocument(const Reference< XXPathObject >& aObj, sal_Bool bRemoveWSNodes)
642 : {
643 : using namespace com::sun::star::xml::xpath;
644 0 : Reference< XDocumentBuilder > aDocBuilder = DocumentBuilder::create(comphelper::getProcessComponentContext());
645 0 : Reference< XDocument > aDocument = aDocBuilder->newDocument();
646 0 : Reference< XDocumentFragment > aFragment = aDocument->createDocumentFragment();
647 :
648 :
649 0 : if (aObj->getObjectType() == XPathObjectType_XPATH_NODESET)
650 : {
651 0 : Reference< XNodeList > aList = aObj->getNodeList();
652 0 : Reference< XNode > aListItem;
653 0 : for (sal_Int32 i=0; i < aList->getLength(); i++)
654 : {
655 0 : aListItem = aList->item(i);
656 0 : if (aListItem->getNodeType()==NodeType_DOCUMENT_NODE)
657 0 : aListItem = Reference< XNode >(
658 0 : (Reference< XDocument >(aListItem, UNO_QUERY))->getDocumentElement(), UNO_QUERY);
659 : // copy relevant nodes from instance into fragment
660 0 : _cloneNodes(*getModelImpl(), aFragment, aListItem, bRemoveWSNodes);
661 0 : }
662 : }
663 0 : return aFragment;
664 : }
665 :
666 : // some forwarding: XPropertySet is implemented in our base class,
667 : // but also available as base of XSubmission
668 0 : Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL Submission::getPropertySetInfo( ) throw(RuntimeException, std::exception)
669 : {
670 0 : return PropertySetBase::getPropertySetInfo();
671 : }
672 0 : void SAL_CALL Submission::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
673 : {
674 0 : PropertySetBase::setPropertyValue( aPropertyName, aValue );
675 0 : }
676 0 : Any SAL_CALL Submission::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
677 : {
678 0 : return PropertySetBase::getPropertyValue( PropertyName );
679 : }
680 0 : void SAL_CALL Submission::addPropertyChangeListener( const OUString& aPropertyName, const Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
681 : {
682 0 : PropertySetBase::addPropertyChangeListener( aPropertyName, xListener );
683 0 : }
684 0 : void SAL_CALL Submission::removePropertyChangeListener( const OUString& aPropertyName, const Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
685 : {
686 0 : PropertySetBase::removePropertyChangeListener( aPropertyName, aListener );
687 0 : }
688 0 : void SAL_CALL Submission::addVetoableChangeListener( const OUString& PropertyName, const Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
689 : {
690 0 : PropertySetBase::addVetoableChangeListener( PropertyName, aListener );
691 0 : }
692 0 : void SAL_CALL Submission::removeVetoableChangeListener( const OUString& PropertyName, const Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
693 : {
694 0 : PropertySetBase::removeVetoableChangeListener( PropertyName, aListener );
695 0 : }
696 :
697 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|