Bug Summary

File:ucbhelper/source/client/content.cxx
Location:line 1119, column 10
Description:Called C++ object pointer is null

Annotated 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
21/**************************************************************************
22 TODO
23 **************************************************************************
24
25 *************************************************************************/
26#include <osl/diagnose.h>
27#include <osl/mutex.hxx>
28#include <salhelper/simplereferenceobject.hxx>
29#include <cppuhelper/weak.hxx>
30
31#include <cppuhelper/implbase1.hxx>
32#include <com/sun/star/ucb/ContentCreationError.hpp>
33#include <com/sun/star/ucb/XCommandEnvironment.hpp>
34#include <com/sun/star/ucb/XCommandInfo.hpp>
35#include <com/sun/star/ucb/XCommandProcessor.hpp>
36#include <com/sun/star/ucb/Command.hpp>
37#include <com/sun/star/ucb/CommandInfo.hpp>
38#include <com/sun/star/ucb/ContentAction.hpp>
39#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
40#include <com/sun/star/ucb/InsertCommandArgument.hpp>
41#include <com/sun/star/ucb/GlobalTransferCommandArgument.hpp>
42#include <com/sun/star/ucb/NameClash.hpp>
43#include <com/sun/star/ucb/OpenMode.hpp>
44#include <com/sun/star/ucb/XContentCreator.hpp>
45#include <com/sun/star/ucb/XContentEventListener.hpp>
46#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
47#include <com/sun/star/ucb/XContentProvider.hpp>
48#include <com/sun/star/ucb/XContentProviderManager.hpp>
49#include <com/sun/star/ucb/XDynamicResultSet.hpp>
50#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
51#include <com/sun/star/beans/XPropertySetInfo.hpp>
52#include <com/sun/star/beans/Property.hpp>
53#include <com/sun/star/beans/PropertyValue.hpp>
54#include <com/sun/star/sdbc/XResultSet.hpp>
55#include <com/sun/star/sdbc/XRow.hpp>
56#include <com/sun/star/lang/IllegalArgumentException.hpp>
57#include <com/sun/star/beans/UnknownPropertyException.hpp>
58#include <ucbhelper/macros.hxx>
59#include <ucbhelper/content.hxx>
60#include <ucbhelper/contentbroker.hxx>
61#include <ucbhelper/activedatasink.hxx>
62#include <ucbhelper/activedatastreamer.hxx>
63#include <ucbhelper/interactionrequest.hxx>
64#include <ucbhelper/cancelcommandexecution.hxx>
65
66using namespace com::sun::star::container;
67using namespace com::sun::star::beans;
68using namespace com::sun::star::io;
69using namespace com::sun::star::lang;
70using namespace com::sun::star::sdbc;
71using namespace com::sun::star::task;
72using namespace com::sun::star::ucb;
73using namespace com::sun::star::uno;
74
75namespace ucbhelper
76{
77
78class EmptyInputStream : public ::cppu::WeakImplHelper1< XInputStream >
79{
80public:
81 virtual sal_Int32 SAL_CALL readBytes(
82 Sequence< sal_Int8 > & data, sal_Int32 nBytesToRead )
83 throw (IOException, RuntimeException);
84 virtual sal_Int32 SAL_CALL readSomeBytes(
85 Sequence< sal_Int8 > & data, sal_Int32 nMaxBytesToRead )
86 throw (IOException, RuntimeException);
87 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
88 throw (IOException, RuntimeException);
89 virtual sal_Int32 SAL_CALL available()
90 throw (IOException, RuntimeException);
91 virtual void SAL_CALL closeInput()
92 throw (IOException, RuntimeException);
93};
94
95sal_Int32 EmptyInputStream::readBytes(
96 Sequence< sal_Int8 > & data, sal_Int32 )
97 throw (IOException, RuntimeException)
98{
99 data.realloc( 0 );
100 return 0;
101}
102
103sal_Int32 EmptyInputStream::readSomeBytes(
104 Sequence< sal_Int8 > & data, sal_Int32 )
105 throw (IOException, RuntimeException)
106{
107 data.realloc( 0 );
108 return 0;
109}
110
111void EmptyInputStream::skipBytes( sal_Int32 )
112 throw (IOException, RuntimeException)
113{
114}
115
116sal_Int32 EmptyInputStream::available()
117 throw (IOException, RuntimeException)
118{
119 return 0;
120}
121
122void EmptyInputStream::closeInput()
123 throw (IOException, RuntimeException)
124{
125}
126
127
128//=========================================================================
129//=========================================================================
130//
131// class ContentEventListener_Impl.
132//
133//=========================================================================
134//=========================================================================
135
136class ContentEventListener_Impl : public cppu::OWeakObject,
137 public XContentEventListener
138{
139 Content_Impl& m_rContent;
140
141public:
142 ContentEventListener_Impl( Content_Impl& rContent )
143 : m_rContent( rContent ) {}
144
145 // XInterface
146 XINTERFACE_DECL()virtual com::sun::star::uno::Any queryInterface( const com::sun
::star::uno::Type & rType ) throw( com::sun::star::uno::RuntimeException
); virtual void acquire() throw(); virtual void release() throw
();
147
148 // XContentEventListener
149 virtual void SAL_CALL contentEvent( const ContentEvent& evt )
150 throw( RuntimeException );
151
152 // XEventListener ( base of XContentEventListener )
153 virtual void SAL_CALL disposing( const EventObject& Source )
154 throw( RuntimeException );
155};
156
157//=========================================================================
158//=========================================================================
159//
160// class Content_Impl.
161//
162//=========================================================================
163//=========================================================================
164
165class Content_Impl : public salhelper::SimpleReferenceObject
166{
167friend class ContentEventListener_Impl;
168
169 mutable rtl::OUString m_aURL;
170 Reference< XMultiServiceFactory > m_xSMgr;
171 Reference< XContent > m_xContent;
172 Reference< XCommandProcessor > m_xCommandProcessor;
173 Reference< XCommandEnvironment > m_xEnv;
174 Reference< XContentEventListener > m_xContentEventListener;
175 mutable osl::Mutex m_aMutex;
176 sal_Int32 m_nCommandId;
177
178private:
179 void reinit( const Reference< XContent >& xContent );
180 void disposing(const EventObject& Source);
181
182public:
183 Content_Impl() : m_nCommandId( 0 ) {};
184 Content_Impl( const Reference< XMultiServiceFactory >& rSMgr,
185 const Reference< XContent >& rContent,
186 const Reference< XCommandEnvironment >& rEnv );
187
188 virtual ~Content_Impl();
189
190 const rtl::OUString& getURL() const;
191 Reference< XContent > getContent();
192 Reference< XCommandProcessor > getCommandProcessor();
193 sal_Int32 getCommandId();
194 Reference< XMultiServiceFactory > getServiceManager() { return m_xSMgr; }
195
196 Any executeCommand( const Command& rCommand );
197
198 inline const Reference< XCommandEnvironment >& getEnvironment() const;
199 inline void setEnvironment(
200 const Reference< XCommandEnvironment >& xNewEnv );
201
202 void inserted();
203};
204
205//=========================================================================
206// Helpers.
207//=========================================================================
208
209static void ensureContentProviderForURL( const ContentBroker & rBroker,
210 const rtl::OUString & rURL )
211 throw ( ContentCreationException, RuntimeException )
212{
213 Reference< XContentProviderManager > xMgr
214 = rBroker.getContentProviderManagerInterface();
215 if ( !xMgr.is() )
216 {
217 throw RuntimeException(
218 rtl::OUString(
219 "UCB does not implement mandatory interface "
220 "XContentProviderManager!" ),
221 Reference< XInterface >() );
222 }
223 else
224 {
225 Reference< XContentProvider > xProv
226 = xMgr->queryContentProvider( rURL );
227 if ( !xProv.is() )
228 {
229 throw ContentCreationException(
230 rtl::OUString(
231 "No Content Provider available for URL: ") + rURL,
232 Reference< XInterface >(),
233 ContentCreationError_NO_CONTENT_PROVIDER );
234 }
235 }
236}
237
238//=========================================================================
239static ContentBroker* getContentBroker( bool bThrow )
240 throw ( ContentCreationException, RuntimeException )
241{
242 ContentBroker* pBroker = ContentBroker::get();
243
244 if ( !pBroker )
245 {
246 if ( bThrow )
247 throw RuntimeException(
248 rtl::OUString("No Content Broker!"),
249 Reference< XInterface >() );
250 }
251 else
252 {
253#if OSL_DEBUG_LEVEL1 > 1
254 Reference< XContentProviderManager > xMgr
255 = pBroker->getContentProviderManagerInterface();
256 if ( !xMgr.is() )
257 {
258 if ( bThrow )
259 throw RuntimeException(
260 rtl::OUString(
261 "UCB does not implement mandatory interface "
262 "XContentProviderManager!" ),
263 Reference< XInterface >() );
264 }
265 else
266 {
267 OSL_ENSURE( xMgr->queryContentProviders().getLength(),do { if (true && (!(xMgr->queryContentProviders().
getLength()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "268" ": "), "%s", "Content Broker not configured (no providers)!"
); } } while (false)
268 "Content Broker not configured (no providers)!" )do { if (true && (!(xMgr->queryContentProviders().
getLength()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "268" ": "), "%s", "Content Broker not configured (no providers)!"
); } } while (false)
;
269 }
270#endif
271 }
272
273 return pBroker;
274}
275
276//=========================================================================
277static Reference< XContentIdentifier > getContentIdentifier(
278 const ContentBroker & rBroker,
279 const rtl::OUString & rURL,
280 bool bThrow )
281 throw ( ContentCreationException, RuntimeException )
282{
283 Reference< XContentIdentifierFactory > xIdFac
284 = rBroker.getContentIdentifierFactoryInterface();
285 if ( xIdFac.is() )
286 {
287 Reference< XContentIdentifier > xId
288 = xIdFac->createContentIdentifier( rURL );
289
290 if ( xId.is() )
291 return xId;
292
293 if ( bThrow )
294 {
295 ensureContentProviderForURL( rBroker, rURL );
296
297 throw ContentCreationException(
298 rtl::OUString(
299 "Unable to create Content Identifier!" ),
300 Reference< XInterface >(),
301 ContentCreationError_IDENTIFIER_CREATION_FAILED );
302 }
303 }
304 else
305 {
306 if ( bThrow )
307 throw RuntimeException(
308 rtl::OUString(
309 "UCB does not implement mandatory interface "
310 "XContentIdentifierFactory!" ),
311 Reference< XInterface >() );
312 }
313
314 return Reference< XContentIdentifier >();
315}
316
317//=========================================================================
318static Reference< XContent > getContent(
319 const ContentBroker & rBroker,
320 const Reference< XContentIdentifier > & xId,
321 bool bThrow )
322 throw ( ContentCreationException, RuntimeException )
323{
324 Reference< XContentProvider > xProvider
325 = rBroker.getContentProviderInterface();
326 if ( xProvider.is() )
327 {
328 Reference< XContent > xContent;
329 rtl::OUString msg;
330 try
331 {
332 xContent = xProvider->queryContent( xId );
333 }
334 catch ( IllegalIdentifierException const & e )
335 {
336 msg = e.Message;
337 // handled below.
338 }
339
340 if ( xContent.is() )
341 return xContent;
342
343 if ( bThrow )
344 {
345 ensureContentProviderForURL( rBroker, xId->getContentIdentifier() );
346
347 throw ContentCreationException(
348 rtl::OUString(
349 "Unable to create Content! " ) + msg,
350 Reference< XInterface >(),
351 ContentCreationError_CONTENT_CREATION_FAILED );
352 }
353 }
354 else
355 {
356 if ( bThrow )
357 throw RuntimeException(
358 rtl::OUString(
359 "UCB does not implement mandatory interface "
360 "XContentProvider!" ),
361 Reference< XInterface >() );
362 }
363
364 return Reference< XContent >();
365}
366
367//=========================================================================
368//=========================================================================
369//
370// Content Implementation.
371//
372//=========================================================================
373//=========================================================================
374
375Content::Content()
376: m_xImpl( new Content_Impl )
377{
378}
379
380//=========================================================================
381Content::Content( const rtl::OUString& rURL,
382 const Reference< XCommandEnvironment >& rEnv )
383 throw ( ContentCreationException, RuntimeException )
384{
385 ContentBroker* pBroker = getContentBroker( true );
386
387 Reference< XContentIdentifier > xId
388 = getContentIdentifier( *pBroker, rURL, true );
389
390 Reference< XContent > xContent = getContent( *pBroker, xId, true );
391
392 m_xImpl = new Content_Impl( pBroker->getServiceManager(), xContent, rEnv );
393}
394
395//=========================================================================
396Content::Content( const Reference< XContent >& rContent,
397 const Reference< XCommandEnvironment >& rEnv )
398 throw ( ContentCreationException, RuntimeException )
399{
400 ContentBroker* pBroker = getContentBroker( true );
401
402 m_xImpl = new Content_Impl( pBroker->getServiceManager(), rContent, rEnv );
403}
404
405//=========================================================================
406Content::Content( const Content& rOther )
407{
408 m_xImpl = rOther.m_xImpl;
409}
410
411//=========================================================================
412// static
413sal_Bool Content::create( const rtl::OUString& rURL,
414 const Reference< XCommandEnvironment >& rEnv,
415 Content& rContent )
416{
417 ContentBroker* pBroker = getContentBroker( false );
418 if ( !pBroker )
419 return sal_False((sal_Bool)0);
420
421 Reference< XContentIdentifier > xId
422 = getContentIdentifier( *pBroker, rURL, false );
423 if ( !xId.is() )
424 return sal_False((sal_Bool)0);
425
426 Reference< XContent > xContent = getContent( *pBroker, xId, false );
427 if ( !xContent.is() )
428 return sal_False((sal_Bool)0);
429
430 rContent.m_xImpl
431 = new Content_Impl( pBroker->getServiceManager(), xContent, rEnv );
432
433 return sal_True((sal_Bool)1);
434}
435
436//=========================================================================
437Content::~Content()
438{
439}
440
441//=========================================================================
442Content& Content::operator=( const Content& rOther )
443{
444 m_xImpl = rOther.m_xImpl;
445 return *this;
446}
447
448//=========================================================================
449Reference< XContent > Content::get() const
450{
451 return m_xImpl->getContent();
452}
453
454//=========================================================================
455const rtl::OUString& Content::getURL() const
456{
457 return m_xImpl->getURL();
458}
459
460//=========================================================================
461const Reference< XCommandEnvironment >& Content::getCommandEnvironment() const
462{
463 return m_xImpl->getEnvironment();
464}
465
466//=========================================================================
467void Content::setCommandEnvironment(
468 const Reference< XCommandEnvironment >& xNewEnv )
469{
470 m_xImpl->setEnvironment( xNewEnv );
471}
472
473//=========================================================================
474Reference< XCommandInfo > Content::getCommands()
475 throw( CommandAbortedException, RuntimeException, Exception )
476{
477 Command aCommand;
478 aCommand.Name = rtl::OUString("getCommandInfo");
479 aCommand.Handle = -1; // n/a
480 aCommand.Argument = Any();
481
482 Any aResult = m_xImpl->executeCommand( aCommand );
483
484 Reference< XCommandInfo > xInfo;
485 aResult >>= xInfo;
486 return xInfo;
487}
488
489//=========================================================================
490Reference< XPropertySetInfo > Content::getProperties()
491 throw( CommandAbortedException, RuntimeException, Exception )
492{
493 Command aCommand;
494 aCommand.Name = rtl::OUString("getPropertySetInfo");
495 aCommand.Handle = -1; // n/a
496 aCommand.Argument = Any();
497
498 Any aResult = m_xImpl->executeCommand( aCommand );
499
500 Reference< XPropertySetInfo > xInfo;
501 aResult >>= xInfo;
502 return xInfo;
503}
504
505//=========================================================================
506Any Content::getPropertyValue( const rtl::OUString& rPropertyName )
507 throw( CommandAbortedException, RuntimeException, Exception )
508{
509 Sequence< rtl::OUString > aNames( 1 );
510 aNames.getArray()[ 0 ] = rPropertyName;
511
512 Sequence< Any > aRet = getPropertyValues( aNames );
513 return aRet.getConstArray()[ 0 ];
514}
515
516//=========================================================================
517Any Content::setPropertyValue( const rtl::OUString& rName,
518 const Any& rValue )
519 throw( CommandAbortedException, RuntimeException, Exception )
520{
521 Sequence< rtl::OUString > aNames( 1 );
522 aNames.getArray()[ 0 ] = rName;
523
524 Sequence< Any > aValues( 1 );
525 aValues.getArray()[ 0 ] = rValue;
526
527 Sequence< Any > aErrors = setPropertyValues( aNames, aValues );
528 return aErrors.getConstArray()[ 0 ];
529}
530
531//=========================================================================
532Sequence< Any > Content::getPropertyValues(
533 const Sequence< rtl::OUString >& rPropertyNames )
534 throw( CommandAbortedException, RuntimeException, Exception )
535{
536 Reference< XRow > xRow = getPropertyValuesInterface( rPropertyNames );
537
538 sal_Int32 nCount = rPropertyNames.getLength();
539 Sequence< Any > aValues( nCount );
540
541 if ( xRow.is() )
542 {
543 Any* pValues = aValues.getArray();
544
545 for ( sal_Int32 n = 0; n < nCount; ++n )
546 pValues[ n ] = xRow->getObject( n + 1, Reference< XNameAccess >() );
547 }
548
549 return aValues;
550}
551
552//=========================================================================
553Reference< XRow > Content::getPropertyValuesInterface(
554 const Sequence< rtl::OUString >& rPropertyNames )
555 throw( CommandAbortedException, RuntimeException, Exception )
556{
557 sal_Int32 nCount = rPropertyNames.getLength();
558 Sequence< Property > aProps( nCount );
559 Property* pProps = aProps.getArray();
560
561 const rtl::OUString* pNames = rPropertyNames.getConstArray();
562
563 for ( sal_Int32 n = 0; n< nCount; ++n )
564 {
565 Property& rProp = pProps[ n ];
566
567 rProp.Name = pNames[ n ];
568 rProp.Handle = -1; // n/a
569// rProp.Type =
570// rProp.Attributes = ;
571 }
572
573 Command aCommand;
574 aCommand.Name = rtl::OUString("getPropertyValues");
575 aCommand.Handle = -1; // n/a
576 aCommand.Argument <<= aProps;
577
578 Any aResult = m_xImpl->executeCommand( aCommand );
579
580 Reference< XRow > xRow;
581 aResult >>= xRow;
582 return xRow;
583}
584
585//=========================================================================
586Sequence< Any > Content::setPropertyValues(
587 const Sequence< rtl::OUString >& rPropertyNames,
588 const Sequence< Any >& rValues )
589 throw( CommandAbortedException, RuntimeException, Exception )
590{
591 if ( rPropertyNames.getLength() != rValues.getLength() )
592 {
593 ucbhelper::cancelCommandExecution(
594 makeAny( IllegalArgumentException(
595 rtl::OUString(
596 "Length of property names sequence and value "
597 "sequence are unequal!" ),
598 get(),
599 -1 ) ),
600 m_xImpl->getEnvironment() );
601 // Unreachable
602 }
603
604 sal_Int32 nCount = rValues.getLength();
605 Sequence< PropertyValue > aProps( nCount );
606 PropertyValue* pProps = aProps.getArray();
607
608 const rtl::OUString* pNames = rPropertyNames.getConstArray();
609 const Any* pValues = rValues.getConstArray();
610
611 for ( sal_Int32 n = 0; n< nCount; ++n )
612 {
613 PropertyValue& rProp = pProps[ n ];
614
615 rProp.Name = pNames[ n ];
616 rProp.Handle = -1; // n/a
617 rProp.Value = pValues[ n ];
618// rProp.State = ;
619 }
620
621 Command aCommand;
622 aCommand.Name = rtl::OUString("setPropertyValues");
623 aCommand.Handle = -1; // n/a
624 aCommand.Argument <<= aProps;
625
626 Any aResult = m_xImpl->executeCommand( aCommand );
627
628 Sequence< Any > aErrors;
629 aResult >>= aErrors;
630 return aErrors;
631}
632
633//=========================================================================
634Any Content::executeCommand( const rtl::OUString& rCommandName,
635 const Any& rCommandArgument )
636 throw( CommandAbortedException, RuntimeException, Exception )
637{
638 Command aCommand;
639 aCommand.Name = rCommandName;
640 aCommand.Handle = -1; // n/a
641 aCommand.Argument = rCommandArgument;
642
643 return m_xImpl->executeCommand( aCommand );
644}
645
646//=========================================================================
647Any Content::createCursorAny( const Sequence< rtl::OUString >& rPropertyNames,
648 ResultSetInclude eMode )
649 throw( CommandAbortedException, RuntimeException, Exception )
650{
651 sal_Int32 nCount = rPropertyNames.getLength();
652 Sequence< Property > aProps( nCount );
653 Property* pProps = aProps.getArray();
654 const rtl::OUString* pNames = rPropertyNames.getConstArray();
655 for ( sal_Int32 n = 0; n < nCount; ++n )
656 {
657 Property& rProp = pProps[ n ];
658 rProp.Name = pNames[ n ];
659 rProp.Handle = -1; // n/a
660 }
661
662 OpenCommandArgument2 aArg;
663 aArg.Mode = ( eMode == INCLUDE_FOLDERS_ONLY )
664 ? OpenMode::FOLDERS
665 : ( eMode == INCLUDE_DOCUMENTS_ONLY )
666 ? OpenMode::DOCUMENTS : OpenMode::ALL;
667 aArg.Priority = 0; // unused
668 aArg.Sink = Reference< XInterface >(); // unused
669 aArg.Properties = aProps;
670
671 Command aCommand;
672 aCommand.Name = rtl::OUString("open");
673 aCommand.Handle = -1; // n/a
674 aCommand.Argument <<= aArg;
675
676 return m_xImpl->executeCommand( aCommand );
677}
678
679//=========================================================================
680Reference< XResultSet > Content::createCursor(
681 const Sequence< rtl::OUString >& rPropertyNames,
682 ResultSetInclude eMode )
683 throw( CommandAbortedException, RuntimeException, Exception )
684{
685 Any aCursorAny = createCursorAny( rPropertyNames, eMode );
686
687 Reference< XDynamicResultSet > xDynSet;
688 Reference< XResultSet > aResult;
689
690 aCursorAny >>= xDynSet;
691 if ( xDynSet.is() )
692 aResult = xDynSet->getStaticResultSet();
693
694 OSL_ENSURE( aResult.is(), "Content::createCursor - no cursor!" )do { if (true && (!(aResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "694" ": "), "%s", "Content::createCursor - no cursor!")
; } } while (false)
;
695
696 if ( !aResult.is() )
697 {
698 // Former, the open command directly returned a XResultSet.
699 aCursorAny >>= aResult;
700
701 OSL_ENSURE( !aResult.is(),do { if (true && (!(!aResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "703" ": "), "%s", "Content::createCursor - open-Command must "
"return a Reference< XDynnamicResultSet >!"); } } while
(false)
702 "Content::createCursor - open-Command must "do { if (true && (!(!aResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "703" ": "), "%s", "Content::createCursor - open-Command must "
"return a Reference< XDynnamicResultSet >!"); } } while
(false)
703 "return a Reference< XDynnamicResultSet >!" )do { if (true && (!(!aResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "703" ": "), "%s", "Content::createCursor - open-Command must "
"return a Reference< XDynnamicResultSet >!"); } } while
(false)
;
704 }
705
706 return aResult;
707}
708
709//=========================================================================
710Reference< XDynamicResultSet > Content::createDynamicCursor(
711 const Sequence< rtl::OUString >& rPropertyNames,
712 ResultSetInclude eMode )
713 throw( CommandAbortedException, RuntimeException, Exception )
714{
715 Reference< XDynamicResultSet > aResult;
716 createCursorAny( rPropertyNames, eMode ) >>= aResult;
717
718 OSL_ENSURE( aResult.is(), "Content::createDynamicCursor - no cursor!" )do { if (true && (!(aResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "718" ": "), "%s", "Content::createDynamicCursor - no cursor!"
); } } while (false)
;
719
720 return aResult;
721}
722
723//=========================================================================
724Reference< XResultSet > Content::createSortedCursor(
725 const Sequence< rtl::OUString >& rPropertyNames,
726 const Sequence< NumberedSortingInfo >& rSortInfo,
727 Reference< XAnyCompareFactory > rAnyCompareFactory,
728 ResultSetInclude eMode )
729 throw( CommandAbortedException, RuntimeException, Exception )
730{
731 Reference< XResultSet > aResult;
732 Reference< XDynamicResultSet > aDynSet;
733
734 Any aCursorAny = createCursorAny( rPropertyNames, eMode );
735
736 aCursorAny >>= aDynSet;
737
738 if( aDynSet.is() )
739 {
740 Reference< XDynamicResultSet > aDynResult;
741 Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager();
742
743 if( aServiceManager.is() )
744 {
745 Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance(
746 rtl::OUString("com.sun.star.ucb.SortedDynamicResultSetFactory")),
747 UNO_QUERY );
748
749 aDynResult = aSortFactory->createSortedDynamicResultSet( aDynSet,
750 rSortInfo,
751 rAnyCompareFactory );
752 }
753
754 OSL_ENSURE( aDynResult.is(), "Content::createSortedCursor - no sorted cursor!\n" )do { if (true && (!(aDynResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "754" ": "), "%s", "Content::createSortedCursor - no sorted cursor!\n"
); } } while (false)
;
755
756 if( aDynResult.is() )
757 aResult = aDynResult->getStaticResultSet();
758 else
759 aResult = aDynSet->getStaticResultSet();
760 }
761
762 OSL_ENSURE( aResult.is(), "Content::createSortedCursor - no cursor!" )do { if (true && (!(aResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "762" ": "), "%s", "Content::createSortedCursor - no cursor!"
); } } while (false)
;
763
764 if ( !aResult.is() )
765 {
766 // Former, the open command directly returned a XResultSet.
767 aCursorAny >>= aResult;
768
769 OSL_ENSURE( !aResult.is(),do { if (true && (!(!aResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "771" ": "), "%s", "Content::createCursor - open-Command must "
"return a Reference< XDynnamicResultSet >!"); } } while
(false)
770 "Content::createCursor - open-Command must "do { if (true && (!(!aResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "771" ": "), "%s", "Content::createCursor - open-Command must "
"return a Reference< XDynnamicResultSet >!"); } } while
(false)
771 "return a Reference< XDynnamicResultSet >!" )do { if (true && (!(!aResult.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "771" ": "), "%s", "Content::createCursor - open-Command must "
"return a Reference< XDynnamicResultSet >!"); } } while
(false)
;
772 }
773
774 return aResult;
775}
776
777//=========================================================================
778Reference< XInputStream > Content::openStream()
779 throw( CommandAbortedException, RuntimeException, Exception )
780{
781 if ( !isDocument() )
782 return Reference< XInputStream >();
783
784 Reference< XActiveDataSink > xSink = new ActiveDataSink;
785
786 OpenCommandArgument2 aArg;
787 aArg.Mode = OpenMode::DOCUMENT;
788 aArg.Priority = 0; // unused
789 aArg.Sink = xSink;
790 aArg.Properties = Sequence< Property >( 0 ); // unused
791
792 Command aCommand;
793 aCommand.Name = rtl::OUString("open");
794 aCommand.Handle = -1; // n/a
795 aCommand.Argument <<= aArg;
796
797 m_xImpl->executeCommand( aCommand );
798
799 return xSink->getInputStream();
800}
801
802//=========================================================================
803Reference< XInputStream > Content::openStreamNoLock()
804 throw( CommandAbortedException, RuntimeException, Exception )
805{
806 if ( !isDocument() )
807 return Reference< XInputStream >();
808
809 Reference< XActiveDataSink > xSink = new ActiveDataSink;
810
811 OpenCommandArgument2 aArg;
812 aArg.Mode = OpenMode::DOCUMENT_SHARE_DENY_NONE;
813 aArg.Priority = 0; // unused
814 aArg.Sink = xSink;
815 aArg.Properties = Sequence< Property >( 0 ); // unused
816
817 Command aCommand;
818 aCommand.Name = rtl::OUString("open");
819 aCommand.Handle = -1; // n/a
820 aCommand.Argument <<= aArg;
821
822 m_xImpl->executeCommand( aCommand );
823
824 return xSink->getInputStream();
825}
826
827//=========================================================================
828Reference< XStream > Content::openWriteableStream()
829 throw( CommandAbortedException, RuntimeException, Exception )
830{
831 if ( !isDocument() )
832 return Reference< XStream >();
833
834 Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer;
835
836 OpenCommandArgument2 aArg;
837 aArg.Mode = OpenMode::DOCUMENT;
838 aArg.Priority = 0; // unused
839 aArg.Sink = xStreamer;
840 aArg.Properties = Sequence< Property >( 0 ); // unused
841
842 Command aCommand;
843 aCommand.Name = rtl::OUString("open");
844 aCommand.Handle = -1; // n/a
845 aCommand.Argument <<= aArg;
846
847 m_xImpl->executeCommand( aCommand );
848
849 return xStreamer->getStream();
850}
851
852//=========================================================================
853Reference< XStream > Content::openWriteableStreamNoLock()
854 throw( CommandAbortedException, RuntimeException, Exception )
855{
856 if ( !isDocument() )
857 return Reference< XStream >();
858
859 Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer;
860
861 OpenCommandArgument2 aArg;
862 aArg.Mode = OpenMode::DOCUMENT_SHARE_DENY_NONE;
863 aArg.Priority = 0; // unused
864 aArg.Sink = xStreamer;
865 aArg.Properties = Sequence< Property >( 0 ); // unused
866
867 Command aCommand;
868 aCommand.Name = rtl::OUString("open");
869 aCommand.Handle = -1; // n/a
870 aCommand.Argument <<= aArg;
871
872 m_xImpl->executeCommand( aCommand );
873
874 return xStreamer->getStream();
875}
876
877//=========================================================================
878sal_Bool Content::openStream( const Reference< XActiveDataSink >& rSink )
879 throw( CommandAbortedException, RuntimeException, Exception )
880{
881 if ( !isDocument() )
882 return sal_False((sal_Bool)0);
883
884 OpenCommandArgument2 aArg;
885 aArg.Mode = OpenMode::DOCUMENT;
886 aArg.Priority = 0; // unused
887 aArg.Sink = rSink;
888 aArg.Properties = Sequence< Property >( 0 ); // unused
889
890 Command aCommand;
891 aCommand.Name = rtl::OUString("open");
892 aCommand.Handle = -1; // n/a
893 aCommand.Argument <<= aArg;
894
895 m_xImpl->executeCommand( aCommand );
896
897 return sal_True((sal_Bool)1);
898}
899
900//=========================================================================
901sal_Bool Content::openStream( const Reference< XOutputStream >& rStream )
902 throw( CommandAbortedException, RuntimeException, Exception )
903{
904 if ( !isDocument() )
905 return sal_False((sal_Bool)0);
906
907 OpenCommandArgument2 aArg;
908 aArg.Mode = OpenMode::DOCUMENT;
909 aArg.Priority = 0; // unused
910 aArg.Sink = rStream;
911 aArg.Properties = Sequence< Property >( 0 ); // unused
912
913 Command aCommand;
914 aCommand.Name = rtl::OUString("open");
915 aCommand.Handle = -1; // n/a
916 aCommand.Argument <<= aArg;
917
918 m_xImpl->executeCommand( aCommand );
919
920 return sal_True((sal_Bool)1);
921}
922
923//=========================================================================
924void Content::writeStream( const Reference< XInputStream >& rStream,
925 sal_Bool bReplaceExisting )
926 throw( CommandAbortedException, RuntimeException, Exception )
927{
928 InsertCommandArgument aArg;
929 aArg.Data = rStream.is() ? rStream : new EmptyInputStream;
930 aArg.ReplaceExisting = bReplaceExisting;
931
932 Command aCommand;
933 aCommand.Name = rtl::OUString("insert");
934 aCommand.Handle = -1; // n/a
935 aCommand.Argument <<= aArg;
936
937 m_xImpl->executeCommand( aCommand );
938
939 m_xImpl->inserted();
940}
941
942//=========================================================================
943Sequence< ContentInfo > Content::queryCreatableContentsInfo()
944 throw( CommandAbortedException, RuntimeException, Exception )
945{
946 // First, try it using "CreatableContentsInfo" property -> the "new" way.
947 Sequence< ContentInfo > aInfo;
948 if ( getPropertyValue(
949 rtl::OUString("CreatableContentsInfo") )
950 >>= aInfo )
951 return aInfo;
952
953 // Second, try it using XContentCreator interface -> the "old" way (not
954 // providing the chance to supply an XCommandEnvironment.
955 Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY );
956 if ( xCreator.is() )
957 aInfo = xCreator->queryCreatableContentsInfo();
958
959 return aInfo;
960}
961
962//=========================================================================
963sal_Bool Content::insertNewContent( const rtl::OUString& rContentType,
964 const Sequence< rtl::OUString >&
965 rPropertyNames,
966 const Sequence< Any >& rPropertyValues,
967 Content& rNewContent )
968 throw( CommandAbortedException, RuntimeException, Exception )
969{
970 return insertNewContent( rContentType,
971 rPropertyNames,
972 rPropertyValues,
973 new EmptyInputStream,
974 rNewContent );
975}
976
977//=========================================================================
978sal_Bool Content::insertNewContent( const rtl::OUString& rContentType,
979 const Sequence< rtl::OUString >&
980 rPropertyNames,
981 const Sequence< Any >& rPropertyValues,
982 const Reference< XInputStream >& rData,
983 Content& rNewContent )
984 throw( CommandAbortedException, RuntimeException, Exception )
985{
986 if ( rContentType.isEmpty() )
987 return sal_False((sal_Bool)0);
988
989 // First, try it using "createNewContent" command -> the "new" way.
990 ContentInfo aInfo;
991 aInfo.Type = rContentType;
992 aInfo.Attributes = 0;
993
994 Command aCommand;
995 aCommand.Name = rtl::OUString("createNewContent");
996 aCommand.Handle = -1; // n/a
997 aCommand.Argument <<= aInfo;
998
999 Reference< XContent > xNew;
1000 try
1001 {
1002 m_xImpl->executeCommand( aCommand ) >>= xNew;
1003 }
1004 catch ( RuntimeException const & )
1005 {
1006 throw;
1007 }
1008 catch ( Exception const & )
1009 {
1010 }
1011
1012 if ( !xNew.is() )
1013 {
1014 // Second, try it using XContentCreator interface -> the "old"
1015 // way (not providing the chance to supply an XCommandEnvironment.
1016 Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY );
1017
1018 if ( !xCreator.is() )
1019 return sal_False((sal_Bool)0);
1020
1021 xNew = xCreator->createNewContent( aInfo );
1022
1023 if ( !xNew.is() )
1024 return sal_False((sal_Bool)0);
1025 }
1026
1027 Content aNewContent( xNew, m_xImpl->getEnvironment() );
1028 aNewContent.setPropertyValues( rPropertyNames, rPropertyValues );
1029 aNewContent.executeCommand( rtl::OUString("insert"),
1030 makeAny(
1031 InsertCommandArgument(
1032 rData.is() ? rData : new EmptyInputStream,
1033 sal_False((sal_Bool)0) /* ReplaceExisting */ ) ) );
1034 aNewContent.m_xImpl->inserted();
1035
1036 rNewContent = aNewContent;
1037 return sal_True((sal_Bool)1);
1038}
1039
1040//=========================================================================
1041sal_Bool Content::transferContent( const Content& rSourceContent,
1042 InsertOperation eOperation,
1043 const rtl::OUString & rTitle,
1044 const sal_Int32 nNameClashAction )
1045 throw( CommandAbortedException, RuntimeException, Exception )
1046{
1047 ContentBroker* pBroker = ContentBroker::get();
1048 if ( !pBroker )
1049 {
1050 OSL_FAIL( "Content::transferContent - No Content Broker!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "1050" ": "), "%s", "Content::transferContent - No Content Broker!"
); } } while (false)
;
1051 return sal_False((sal_Bool)0);
1052 }
1053
1054 Reference< XCommandProcessor > xCmdProc(
1055 pBroker->getCommandProcessorInterface() );
1056 if ( !xCmdProc.is() )
1057 {
1058 OSL_FAIL( "Content::transferContent - No XCommandProcessor!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "1058" ": "), "%s", "Content::transferContent - No XCommandProcessor!"
); } } while (false)
;
1059 return sal_False((sal_Bool)0);
1060 }
1061
1062 // Execute command "globalTransfer" at UCB.
1063
1064 TransferCommandOperation eTransOp = TransferCommandOperation();
1065 switch ( eOperation )
1066 {
1067 case InsertOperation_COPY:
1068 eTransOp = TransferCommandOperation_COPY;
1069 break;
1070
1071 case InsertOperation_MOVE:
1072 eTransOp = TransferCommandOperation_MOVE;
1073 break;
1074
1075 case InsertOperation_LINK:
1076 eTransOp = TransferCommandOperation_LINK;
1077 break;
1078
1079 default:
1080 ucbhelper::cancelCommandExecution(
1081 makeAny( IllegalArgumentException(
1082 rtl::OUString(
1083 "Unknown transfer operation!" ),
1084 get(),
1085 -1 ) ),
1086 m_xImpl->getEnvironment() );
1087 // Unreachable
1088 }
1089
1090 GlobalTransferCommandArgument aTransferArg(
1091 eTransOp,
1092 rSourceContent.getURL(), // SourceURL
1093 getURL(), // TargetFolderURL,
1094 rTitle,
1095 nNameClashAction );
1096 Command aCommand;
1097 aCommand.Name = rtl::OUString("globalTransfer");
1098 aCommand.Handle = -1; // n/a
1099 aCommand.Argument <<= aTransferArg;
1100
1101 xCmdProc->execute( aCommand, 0, m_xImpl->getEnvironment() );
1102 return sal_True((sal_Bool)1);
1103}
1104
1105//=========================================================================
1106sal_Bool Content::isFolder()
1107 throw( CommandAbortedException, RuntimeException, Exception )
1108{
1109 sal_Bool bFolder = sal_False((sal_Bool)0);
1110 if ( getPropertyValue( rtl::OUString("IsFolder") )
1
Taking false branch
1111 >>= bFolder )
1112 return bFolder;
1113
1114 ucbhelper::cancelCommandExecution(
1115 makeAny( UnknownPropertyException(
1116 rtl::OUString(
1117 "Unable to retreive value of property 'IsFolder'!" ),
1118 get() ) ),
1119 m_xImpl->getEnvironment() );
2
Called C++ object pointer is null
1120
1121 // Unreachable - cancelCommandExecution always throws an exception.
1122 // But some compilers complain...
1123 return sal_False((sal_Bool)0);
1124}
1125
1126//=========================================================================
1127sal_Bool Content::isDocument()
1128 throw( CommandAbortedException, RuntimeException, Exception )
1129{
1130 sal_Bool bDoc = sal_False((sal_Bool)0);
1131 if ( getPropertyValue( rtl::OUString("IsDocument") )
1132 >>= bDoc )
1133 return bDoc;
1134
1135 ucbhelper::cancelCommandExecution(
1136 makeAny( UnknownPropertyException(
1137 rtl::OUString(
1138 "Unable to retreive value of property 'IsDocument'!" ),
1139 get() ) ),
1140 m_xImpl->getEnvironment() );
1141
1142 // Unreachable - cancelCommandExecution always throws an exception,
1143 // But some compilers complain...
1144 return sal_False((sal_Bool)0);
1145}
1146
1147//=========================================================================
1148//=========================================================================
1149//
1150// Content_Impl Implementation.
1151//
1152//=========================================================================
1153//=========================================================================
1154
1155Content_Impl::Content_Impl( const Reference< XMultiServiceFactory >& rSMgr,
1156 const Reference< XContent >& rContent,
1157 const Reference< XCommandEnvironment >& rEnv )
1158: m_xSMgr( rSMgr ),
1159 m_xContent( rContent ),
1160 m_xEnv( rEnv ),
1161 m_nCommandId( 0 )
1162{
1163 if ( m_xContent.is() )
1164 {
1165 m_xContentEventListener = new ContentEventListener_Impl( *this );
1166 m_xContent->addContentEventListener( m_xContentEventListener );
1167
1168#if OSL_DEBUG_LEVEL1 > 1
1169 // Only done on demand in product version for performance reasons,
1170 // but a nice debug helper.
1171 getURL();
1172#endif
1173 }
1174}
1175
1176//=========================================================================
1177void Content_Impl::reinit( const Reference< XContent >& xContent )
1178{
1179 osl::MutexGuard aGuard( m_aMutex );
1180
1181 m_xCommandProcessor = 0;
1182 m_nCommandId = 0;
1183
1184 // #92581# - Don't reset m_aURL!!!
1185
1186 if ( m_xContent.is() )
1187 {
1188 try
1189 {
1190 m_xContent->removeContentEventListener( m_xContentEventListener );
1191 }
1192 catch ( RuntimeException const & )
1193 {
1194 }
1195 }
1196
1197 if ( xContent.is() )
1198 {
1199 m_xContent = xContent;
1200 m_xContent->addContentEventListener( m_xContentEventListener );
1201
1202#if OSL_DEBUG_LEVEL1 > 1
1203 // Only done on demand in product version for performance reasons,
1204 // but a nice debug helper.
1205 getURL();
1206#endif
1207 }
1208 else
1209 {
1210 // We need m_xContent's URL in order to be able to create the
1211 // content object again if demanded ( --> Content_Impl::getContent() )
1212 getURL();
1213
1214 m_xContent = 0;
1215 }
1216}
1217
1218//=========================================================================
1219// virtual
1220Content_Impl::~Content_Impl()
1221{
1222 if ( m_xContent.is() )
1223 {
1224 try
1225 {
1226 m_xContent->removeContentEventListener( m_xContentEventListener );
1227 }
1228 catch ( RuntimeException const & )
1229 {
1230 }
1231 }
1232}
1233
1234//=========================================================================
1235void Content_Impl::disposing( const EventObject& Source )
1236{
1237 Reference<XContent> xContent;
1238
1239 {
1240 osl::MutexGuard aGuard( m_aMutex );
1241 if(Source.Source != m_xContent)
1242 return;
1243
1244 xContent = m_xContent;
1245
1246 m_nCommandId = 0;
1247 m_aURL = rtl::OUString();
1248 m_xCommandProcessor = 0;
1249 m_xContent = 0;
1250 }
1251
1252 if ( xContent.is() )
1253 {
1254 try
1255 {
1256 xContent->removeContentEventListener( m_xContentEventListener );
1257 }
1258 catch ( RuntimeException const & )
1259 {
1260 }
1261 }
1262}
1263
1264//=========================================================================
1265const rtl::OUString& Content_Impl::getURL() const
1266{
1267 if ( m_aURL.isEmpty() && m_xContent.is() )
1268 {
1269 osl::MutexGuard aGuard( m_aMutex );
1270
1271 if ( m_aURL.isEmpty() && m_xContent.is() )
1272 {
1273 Reference< XContentIdentifier > xId = m_xContent->getIdentifier();
1274 if ( xId.is() )
1275 m_aURL = xId->getContentIdentifier();
1276 }
1277 }
1278
1279 return m_aURL;
1280}
1281
1282//=========================================================================
1283Reference< XContent > Content_Impl::getContent()
1284{
1285 if ( !m_xContent.is() && !m_aURL.isEmpty() )
1286 {
1287 osl::MutexGuard aGuard( m_aMutex );
1288
1289 if ( !m_xContent.is() && !m_aURL.isEmpty() )
1290 {
1291 ContentBroker* pBroker = ContentBroker::get();
1292
1293 OSL_ENSURE( pBroker, "No Content Broker!" )do { if (true && (!(pBroker))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "1293" ": "), "%s", "No Content Broker!"); } } while (false
)
;
1294
1295 if ( pBroker )
1296 {
1297 OSL_ENSURE( pBroker->getContentProviderManagerInterface()do { if (true && (!(pBroker->getContentProviderManagerInterface
() ->queryContentProviders().getLength()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "1299" ": "), "%s", "Content Broker not configured (no providers)!"
); } } while (false)
1298 ->queryContentProviders().getLength(),do { if (true && (!(pBroker->getContentProviderManagerInterface
() ->queryContentProviders().getLength()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "1299" ": "), "%s", "Content Broker not configured (no providers)!"
); } } while (false)
1299 "Content Broker not configured (no providers)!" )do { if (true && (!(pBroker->getContentProviderManagerInterface
() ->queryContentProviders().getLength()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "1299" ": "), "%s", "Content Broker not configured (no providers)!"
); } } while (false)
;
1300
1301 Reference< XContentIdentifierFactory > xIdFac
1302 = pBroker->getContentIdentifierFactoryInterface();
1303
1304 OSL_ENSURE( xIdFac.is(), "No Content Identifier factory!" )do { if (true && (!(xIdFac.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "1304" ": "), "%s", "No Content Identifier factory!"); }
} while (false)
;
1305
1306 if ( xIdFac.is() )
1307 {
1308 Reference< XContentIdentifier > xId
1309 = xIdFac->createContentIdentifier( m_aURL );
1310
1311 OSL_ENSURE( xId.is(), "No Content Identifier!" )do { if (true && (!(xId.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "1311" ": "), "%s", "No Content Identifier!"); } } while
(false)
;
1312
1313 if ( xId.is() )
1314 {
1315 Reference< XContentProvider > xProvider
1316 = pBroker->getContentProviderInterface();
1317
1318 OSL_ENSURE( xProvider.is(), "No Content Provider!" )do { if (true && (!(xProvider.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/client/content.cxx"
":" "1318" ": "), "%s", "No Content Provider!"); } } while (
false)
;
1319
1320 if ( xProvider.is() )
1321 {
1322 try
1323 {
1324 m_xContent = xProvider->queryContent( xId );
1325 }
1326 catch ( IllegalIdentifierException const & )
1327 {
1328 }
1329
1330 if ( m_xContent.is() )
1331 m_xContent->addContentEventListener(
1332 m_xContentEventListener );
1333 }
1334 }
1335 }
1336 }
1337 }
1338 }
1339
1340 return m_xContent;
1341}
1342
1343//=========================================================================
1344Reference< XCommandProcessor > Content_Impl::getCommandProcessor()
1345{
1346 if ( !m_xCommandProcessor.is() )
1347 {
1348 osl::MutexGuard aGuard( m_aMutex );
1349
1350 if ( !m_xCommandProcessor.is() )
1351 m_xCommandProcessor
1352 = Reference< XCommandProcessor >( getContent(), UNO_QUERY );
1353 }
1354
1355 return m_xCommandProcessor;
1356}
1357
1358//=========================================================================
1359sal_Int32 Content_Impl::getCommandId()
1360{
1361 if ( m_nCommandId == 0 )
1362 {
1363 osl::MutexGuard aGuard( m_aMutex );
1364
1365 if ( m_nCommandId == 0 )
1366 {
1367 Reference< XCommandProcessor > xProc = getCommandProcessor();
1368 if ( xProc.is() )
1369 m_nCommandId = xProc->createCommandIdentifier();
1370 }
1371 }
1372
1373 return m_nCommandId;
1374}
1375
1376//=========================================================================
1377Any Content_Impl::executeCommand( const Command& rCommand )
1378{
1379 Reference< XCommandProcessor > xProc = getCommandProcessor();
1380 if ( !xProc.is() )
1381 return Any();
1382
1383 // Execute command
1384 return xProc->execute( rCommand, getCommandId(), m_xEnv );
1385}
1386
1387//=========================================================================
1388inline const Reference< XCommandEnvironment >&
1389 Content_Impl::getEnvironment() const
1390{
1391 return m_xEnv;
1392}
1393
1394//=========================================================================
1395inline void Content_Impl::setEnvironment(
1396 const Reference< XCommandEnvironment >& xNewEnv )
1397{
1398 osl::MutexGuard aGuard( m_aMutex );
1399 m_xEnv = xNewEnv;
1400}
1401
1402//=========================================================================
1403void Content_Impl::inserted()
1404{
1405 // URL might have changed during 'insert' => recalculate in next getURL()
1406 osl::MutexGuard aGuard( m_aMutex );
1407 m_aURL = ::rtl::OUString();
1408}
1409
1410//=========================================================================
1411//=========================================================================
1412//
1413// ContentEventListener_Impl Implementation.
1414//
1415//=========================================================================
1416//=========================================================================
1417
1418//=========================================================================
1419//
1420// XInterface methods.
1421//
1422//=========================================================================
1423
1424XINTERFACE_IMPL_2( ContentEventListener_Impl,void ContentEventListener_Impl::acquire() throw() { OWeakObject
::acquire(); } void ContentEventListener_Impl::release() throw
() { OWeakObject::release(); } com::sun::star::uno::Any ContentEventListener_Impl
::queryInterface( const com::sun::star::uno::Type & rType
) throw( com::sun::star::uno::RuntimeException ) { com::sun::
star::uno::Any aRet = cppu::queryInterface( rType, (static_cast
< XContentEventListener* >(this)), (static_cast< XEventListener
* >(this)) ); return aRet.hasValue() ? aRet : OWeakObject::
queryInterface( rType ); }
1425 XContentEventListener,void ContentEventListener_Impl::acquire() throw() { OWeakObject
::acquire(); } void ContentEventListener_Impl::release() throw
() { OWeakObject::release(); } com::sun::star::uno::Any ContentEventListener_Impl
::queryInterface( const com::sun::star::uno::Type & rType
) throw( com::sun::star::uno::RuntimeException ) { com::sun::
star::uno::Any aRet = cppu::queryInterface( rType, (static_cast
< XContentEventListener* >(this)), (static_cast< XEventListener
* >(this)) ); return aRet.hasValue() ? aRet : OWeakObject::
queryInterface( rType ); }
1426 XEventListener )void ContentEventListener_Impl::acquire() throw() { OWeakObject
::acquire(); } void ContentEventListener_Impl::release() throw
() { OWeakObject::release(); } com::sun::star::uno::Any ContentEventListener_Impl
::queryInterface( const com::sun::star::uno::Type & rType
) throw( com::sun::star::uno::RuntimeException ) { com::sun::
star::uno::Any aRet = cppu::queryInterface( rType, (static_cast
< XContentEventListener* >(this)), (static_cast< XEventListener
* >(this)) ); return aRet.hasValue() ? aRet : OWeakObject::
queryInterface( rType ); }
; /* base of XContentEventListener */
1427
1428//=========================================================================
1429//
1430// XContentEventListener methods.
1431//
1432//=========================================================================
1433
1434// virtual
1435void SAL_CALL ContentEventListener_Impl::contentEvent( const ContentEvent& evt )
1436 throw( RuntimeException )
1437{
1438 if ( evt.Source == m_rContent.m_xContent )
1439 {
1440 switch ( evt.Action )
1441 {
1442 case ContentAction::DELETED:
1443 m_rContent.reinit( Reference< XContent >() );
1444 break;
1445
1446 case ContentAction::EXCHANGED:
1447 m_rContent.reinit( evt.Content );
1448 break;
1449
1450 default:
1451 break;
1452 }
1453 }
1454}
1455
1456//=========================================================================
1457//
1458// XEventListenr methods.
1459//
1460//=========================================================================
1461
1462// virtual
1463void SAL_CALL ContentEventListener_Impl::disposing( const EventObject& Source )
1464 throw( RuntimeException )
1465{
1466 m_rContent.disposing(Source);
1467}
1468
1469} /* namespace ucbhelper */
1470
1471/* vim:set shiftwidth=4 softtabstop=4 expandtab: */