Bug Summary

File:ucbhelper/source/provider/contenthelper.cxx
Location:line 1027, column 11
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 TODO
22 **************************************************************************
23
24 *************************************************************************/
25
26#include <boost/unordered_map.hpp>
27#include <com/sun/star/ucb/ContentAction.hpp>
28#include <com/sun/star/ucb/CommandInfoChange.hpp>
29#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
30#include <com/sun/star/beans/PropertyAttribute.hpp>
31#include <com/sun/star/beans/PropertySetInfoChange.hpp>
32#include <cppuhelper/interfacecontainer.hxx>
33
34#include "osl/diagnose.h"
35#include "osl/mutex.hxx"
36#include "rtl/ref.hxx"
37#include <ucbhelper/contentidentifier.hxx>
38#include <ucbhelper/contenthelper.hxx>
39#include <ucbhelper/providerhelper.hxx>
40#include <ucbhelper/contentinfo.hxx>
41
42using namespace com::sun::star;
43
44namespace ucbhelper_impl
45{
46
47//=========================================================================
48//
49// class PropertyEventSequence.
50//
51//=========================================================================
52
53class PropertyEventSequence
54{
55 uno::Sequence< beans::PropertyChangeEvent > m_aSeq;
56 sal_uInt32 m_nPos;
57
58public:
59 PropertyEventSequence( sal_uInt32 nSize )
60 : m_aSeq( nSize ), m_nPos( 0 ) {};
61
62 void append( const beans::PropertyChangeEvent& rEvt )
63 { m_aSeq.getArray()[ m_nPos ] = rEvt; ++m_nPos; }
64
65 const uno::Sequence< beans::PropertyChangeEvent >& getEvents()
66 { m_aSeq.realloc( m_nPos ); return m_aSeq; }
67};
68
69//=========================================================================
70//
71// PropertiesEventListenerMap.
72//
73//=========================================================================
74
75typedef void* XPropertiesChangeListenerPtr; // -> Compiler problems!
76
77struct equalPtr
78{
79 bool operator()( const XPropertiesChangeListenerPtr& rp1,
80 const XPropertiesChangeListenerPtr& rp2 ) const
81 {
82 return ( rp1 == rp2 );
83 }
84};
85
86struct hashPtr
87{
88 size_t operator()( const XPropertiesChangeListenerPtr& rp ) const
89 {
90 return (size_t)rp;
91 }
92};
93
94typedef boost::unordered_map
95<
96 XPropertiesChangeListenerPtr,
97 PropertyEventSequence*,
98 hashPtr,
99 equalPtr
100>
101PropertiesEventListenerMap;
102
103//=========================================================================
104//
105// PropertyChangeListenerContainer.
106//
107//=========================================================================
108
109struct equalStr
110{
111 bool operator()( const rtl::OUString& s1, const rtl::OUString& s2 ) const
112 {
113 return !!( s1 == s2 );
114 }
115};
116
117struct hashStr
118{
119 size_t operator()( const rtl::OUString& rName ) const
120 {
121 return rName.hashCode();
122 }
123};
124
125typedef cppu::OMultiTypeInterfaceContainerHelperVar
126<
127 rtl::OUString,
128 hashStr,
129 equalStr
130> PropertyChangeListeners;
131
132//=========================================================================
133//
134// struct ContentImplHelper_Impl
135//
136//=========================================================================
137
138struct ContentImplHelper_Impl
139{
140 rtl::Reference< ::ucbhelper::PropertySetInfo > m_xPropSetInfo;
141 rtl::Reference< ::ucbhelper::CommandProcessorInfo > m_xCommandsInfo;
142 cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
143 cppu::OInterfaceContainerHelper* m_pContentEventListeners;
144 cppu::OInterfaceContainerHelper* m_pPropSetChangeListeners;
145 cppu::OInterfaceContainerHelper* m_pCommandChangeListeners;
146 PropertyChangeListeners* m_pPropertyChangeListeners;
147
148 ContentImplHelper_Impl()
149 : m_pDisposeEventListeners( 0 ),
150 m_pContentEventListeners( 0 ),
151 m_pPropSetChangeListeners( 0 ),
152 m_pCommandChangeListeners( 0 ),
153 m_pPropertyChangeListeners( 0 ) {}
154
155 ~ContentImplHelper_Impl()
156 {
157 delete m_pDisposeEventListeners;
158 delete m_pContentEventListeners;
159 delete m_pPropSetChangeListeners;
160 delete m_pCommandChangeListeners;
161 delete m_pPropertyChangeListeners;
162 }
163};
164
165} // namespace ucbhelper_impl
166
167using namespace ucbhelper_impl;
168
169//=========================================================================
170//=========================================================================
171//
172// ContentImplHelper Implementation.
173//
174//=========================================================================
175//=========================================================================
176
177namespace ucbhelper {
178
179ContentImplHelper::ContentImplHelper(
180 const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
181 const rtl::Reference< ContentProviderImplHelper >& rxProvider,
182 const uno::Reference<
183 com::sun::star::ucb::XContentIdentifier >& Identifier )
184: m_pImpl( new ContentImplHelper_Impl ),
185 m_xSMgr( rxSMgr ),
186 m_xIdentifier( Identifier ),
187 m_xProvider( rxProvider ),
188 m_nCommandId( 0 )
189{
190}
191
192//=========================================================================
193// virtual
194ContentImplHelper::~ContentImplHelper()
195{
196 delete m_pImpl;
197}
198
199//=========================================================================
200//
201// XInterface methods.
202//
203//=========================================================================
204
205void SAL_CALL ContentImplHelper::acquire()
206 throw()
207{
208 cppu::OWeakObject::acquire();
209}
210
211void SAL_CALL ContentImplHelper::release()
212 throw()
213{
214 // #144882# - Call to OWeakObject::release may destroy m_xProvider.
215 // Prevent this.
216 rtl::Reference< ContentProviderImplHelper > xKeepProviderAlive(
217 m_xProvider );
218
219 {
220 osl::MutexGuard aGuard( m_xProvider->m_aMutex );
221 OWeakObject::release();
222 }
223}
224
225uno::Any SAL_CALL ContentImplHelper::queryInterface( const uno::Type & rType )
226 throw( uno::RuntimeException )
227{
228 com::sun::star::uno::Any aRet = cppu::queryInterface( rType,
229 static_cast< lang::XTypeProvider * >(this),
230 static_cast< lang::XServiceInfo * >(this),
231 static_cast< lang::XComponent * >(this),
232 static_cast< com::sun::star::ucb::XContent * >(this),
233 static_cast< com::sun::star::ucb::XCommandProcessor * >(this),
234 static_cast< beans::XPropertiesChangeNotifier * >(this),
235 static_cast< com::sun::star::ucb::XCommandInfoChangeNotifier * >(this),
236 static_cast< beans::XPropertyContainer * >(this),
237 static_cast< beans::XPropertySetInfoChangeNotifier * >(this),
238 static_cast< container::XChild * >(this));
239 return aRet.hasValue() ? aRet : cppu::OWeakObject::queryInterface( rType );
240}
241
242//=========================================================================
243//
244// XTypeProvider methods.
245//
246//=========================================================================
247
248XTYPEPROVIDER_IMPL_10( ContentImplHelper,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
249 lang::XTypeProvider,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
250 lang::XServiceInfo,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
251 lang::XComponent,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
252 com::sun::star::ucb::XContent,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
253 com::sun::star::ucb::XCommandProcessor,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
254 beans::XPropertiesChangeNotifier,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
255 com::sun::star::ucb::XCommandInfoChangeNotifier,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
256 beans::XPropertyContainer,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
257 beans::XPropertySetInfoChangeNotifier,com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
258 container::XChild )com::sun::star::uno::Sequence< sal_Int8 > ContentImplHelper
::getImplementationId() throw( com::sun::star::uno::RuntimeException
) { static cppu::OImplementationId* pId = __null; if ( !pId )
{ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex
() ); if ( !pId ) { static cppu::OImplementationId id( ((sal_Bool
)0) ); pId = &id; } } return (*pId).getImplementationId()
; } com::sun::star::uno::Sequence< com::sun::star::uno::Type
> ContentImplHelper::getTypes() throw( com::sun::star::uno
::RuntimeException ) { static cppu::OTypeCollection* pCollection
= __null; if ( !pCollection ) { osl::Guard< osl::Mutex >
aGuard( osl::Mutex::getGlobalMutex() ); if ( !pCollection ) {
static cppu::OTypeCollection collection( getCppuType( static_cast
< com::sun::star::uno::Reference< lang::XTypeProvider >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< lang::XServiceInfo > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< lang::XComponent
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< com::sun::star::ucb::XContent > * >
( 0 ) ), getCppuType( static_cast< com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandProcessor > * >( 0 ) )
, getCppuType( static_cast< com::sun::star::uno::Reference
< beans::XPropertiesChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< com::sun
::star::ucb::XCommandInfoChangeNotifier > * >( 0 ) ), getCppuType
( static_cast< com::sun::star::uno::Reference< beans::XPropertyContainer
> * >( 0 ) ), getCppuType( static_cast< com::sun::star
::uno::Reference< beans::XPropertySetInfoChangeNotifier >
* >( 0 ) ), getCppuType( static_cast< com::sun::star::
uno::Reference< container::XChild > * >( 0 ) ) ); pCollection
= &collection; } } return (*pCollection).getTypes(); }
;
259
260//=========================================================================
261//
262// XServiceInfo methods.
263//
264//=========================================================================
265
266// virtual
267sal_Bool SAL_CALL ContentImplHelper::supportsService(
268 const rtl::OUString& ServiceName )
269 throw( uno::RuntimeException )
270{
271 uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
272 const rtl::OUString* pArray = aSNL.getConstArray();
273 for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
274 {
275 if ( pArray[ i ] == ServiceName )
276 return sal_True((sal_Bool)1);
277 }
278
279 return sal_False((sal_Bool)0);
280}
281
282//=========================================================================
283//
284// XComponent methods.
285//
286//=========================================================================
287
288// virtual
289void SAL_CALL ContentImplHelper::dispose()
290 throw( uno::RuntimeException )
291{
292 osl::MutexGuard aGuard( m_aMutex );
293
294 if ( m_pImpl->m_pDisposeEventListeners &&
295 m_pImpl->m_pDisposeEventListeners->getLength() )
296 {
297 lang::EventObject aEvt;
298 aEvt.Source = static_cast< lang::XComponent * >( this );
299 m_pImpl->m_pDisposeEventListeners->disposeAndClear( aEvt );
300 }
301
302 if ( m_pImpl->m_pContentEventListeners &&
303 m_pImpl->m_pContentEventListeners->getLength() )
304 {
305 lang::EventObject aEvt;
306 aEvt.Source = static_cast< com::sun::star::ucb::XContent * >( this );
307 m_pImpl->m_pContentEventListeners->disposeAndClear( aEvt );
308 }
309
310 if ( m_pImpl->m_pPropSetChangeListeners &&
311 m_pImpl->m_pPropSetChangeListeners->getLength() )
312 {
313 lang::EventObject aEvt;
314 aEvt.Source
315 = static_cast< beans::XPropertySetInfoChangeNotifier * >( this );
316 m_pImpl->m_pPropSetChangeListeners->disposeAndClear( aEvt );
317 }
318
319 if ( m_pImpl->m_pCommandChangeListeners &&
320 m_pImpl->m_pCommandChangeListeners->getLength() )
321 {
322 lang::EventObject aEvt;
323 aEvt.Source = static_cast< com::sun::star::ucb::XCommandInfoChangeNotifier * >( this );
324 m_pImpl->m_pCommandChangeListeners->disposeAndClear( aEvt );
325 }
326
327 if ( m_pImpl->m_pPropertyChangeListeners )
328 {
329 lang::EventObject aEvt;
330 aEvt.Source
331 = static_cast< beans::XPropertiesChangeNotifier * >( this );
332 m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aEvt );
333 }
334}
335
336//=========================================================================
337// virtual
338void SAL_CALL ContentImplHelper::addEventListener(
339 const uno::Reference< lang::XEventListener >& Listener )
340 throw( uno::RuntimeException )
341{
342 osl::MutexGuard aGuard( m_aMutex );
343
344 if ( !m_pImpl->m_pDisposeEventListeners )
345 m_pImpl->m_pDisposeEventListeners
346 = new cppu::OInterfaceContainerHelper( m_aMutex );
347
348 m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
349}
350
351//=========================================================================
352// virtual
353void SAL_CALL ContentImplHelper::removeEventListener(
354 const uno::Reference< lang::XEventListener >& Listener )
355 throw( uno::RuntimeException )
356{
357 osl::MutexGuard aGuard( m_aMutex );
358
359 if ( m_pImpl->m_pDisposeEventListeners )
360 m_pImpl->m_pDisposeEventListeners->removeInterface( Listener );
361}
362
363//=========================================================================
364//
365// XContent methods.
366//
367//=========================================================================
368
369// virtual
370uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL
371ContentImplHelper::getIdentifier()
372 throw( uno::RuntimeException )
373{
374 return m_xIdentifier;
375}
376
377//=========================================================================
378// virtual
379void SAL_CALL ContentImplHelper::addContentEventListener(
380 const uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener )
381 throw( uno::RuntimeException )
382{
383 osl::MutexGuard aGuard( m_aMutex );
384
385 if ( !m_pImpl->m_pContentEventListeners )
386 m_pImpl->m_pContentEventListeners
387 = new cppu::OInterfaceContainerHelper( m_aMutex );
388
389 m_pImpl->m_pContentEventListeners->addInterface( Listener );
390}
391
392//=========================================================================
393// virtual
394void SAL_CALL ContentImplHelper::removeContentEventListener(
395 const uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener )
396 throw( uno::RuntimeException )
397{
398 osl::MutexGuard aGuard( m_aMutex );
399
400 if ( m_pImpl->m_pContentEventListeners )
401 m_pImpl->m_pContentEventListeners->removeInterface( Listener );
402}
403
404//=========================================================================
405//
406// XCommandProcessor methods.
407//
408//=========================================================================
409
410// virtual
411sal_Int32 SAL_CALL ContentImplHelper::createCommandIdentifier()
412 throw( uno::RuntimeException )
413{
414 osl::MutexGuard aGuard( m_aMutex );
415
416 // Just increase counter on every call to generate an identifier.
417 return ++m_nCommandId;
418}
419
420//=========================================================================
421//
422// XPropertiesChangeNotifier methods.
423//
424//=========================================================================
425
426// virtual
427void SAL_CALL ContentImplHelper::addPropertiesChangeListener(
428 const uno::Sequence< rtl::OUString >& PropertyNames,
429 const uno::Reference< beans::XPropertiesChangeListener >& Listener )
430 throw( uno::RuntimeException )
431{
432 osl::MutexGuard aGuard( m_aMutex );
433
434 if ( !m_pImpl->m_pPropertyChangeListeners )
435 m_pImpl->m_pPropertyChangeListeners
436 = new PropertyChangeListeners( m_aMutex );
437
438 sal_Int32 nCount = PropertyNames.getLength();
439 if ( !nCount )
440 {
441 // Note: An empty sequence means a listener for "all" properties.
442 m_pImpl->m_pPropertyChangeListeners->addInterface(
443 rtl::OUString(), Listener );
444 }
445 else
446 {
447 const rtl::OUString* pSeq = PropertyNames.getConstArray();
448
449 for ( sal_Int32 n = 0; n < nCount; ++n )
450 {
451 const rtl::OUString& rName = pSeq[ n ];
452 if ( !rName.isEmpty() )
453 m_pImpl->m_pPropertyChangeListeners->addInterface(
454 rName, Listener );
455 }
456 }
457}
458
459//=========================================================================
460// virtual
461void SAL_CALL ContentImplHelper::removePropertiesChangeListener(
462 const uno::Sequence< rtl::OUString >& PropertyNames,
463 const uno::Reference< beans::XPropertiesChangeListener >& Listener )
464 throw( uno::RuntimeException )
465{
466 osl::MutexGuard aGuard( m_aMutex );
467
468 if ( !m_pImpl->m_pPropertyChangeListeners )
469 return;
470
471 sal_Int32 nCount = PropertyNames.getLength();
472 if ( !nCount )
473 {
474 // Note: An empty sequence means a listener for "all" properties.
475 m_pImpl->m_pPropertyChangeListeners->removeInterface(
476 rtl::OUString(), Listener );
477 }
478 else
479 {
480 const rtl::OUString* pSeq = PropertyNames.getConstArray();
481
482 for ( sal_Int32 n = 0; n < nCount; ++n )
483 {
484 const rtl::OUString& rName = pSeq[ n ];
485 if ( !rName.isEmpty() )
486 m_pImpl->m_pPropertyChangeListeners->removeInterface(
487 rName, Listener );
488 }
489 }
490}
491
492//=========================================================================
493//
494// XCommandInfoChangeNotifier methods.
495//
496//=========================================================================
497
498// virtual
499void SAL_CALL ContentImplHelper::addCommandInfoChangeListener(
500 const uno::Reference< com::sun::star::ucb::XCommandInfoChangeListener >& Listener )
501 throw( uno::RuntimeException )
502{
503 osl::MutexGuard aGuard( m_aMutex );
504
505 if ( !m_pImpl->m_pCommandChangeListeners )
506 m_pImpl->m_pCommandChangeListeners
507 = new cppu::OInterfaceContainerHelper( m_aMutex );
508
509 m_pImpl->m_pCommandChangeListeners->addInterface( Listener );
510}
511
512//=========================================================================
513// virtual
514void SAL_CALL ContentImplHelper::removeCommandInfoChangeListener(
515 const uno::Reference< com::sun::star::ucb::XCommandInfoChangeListener >& Listener )
516 throw( uno::RuntimeException )
517{
518 osl::MutexGuard aGuard( m_aMutex );
519
520 if ( m_pImpl->m_pCommandChangeListeners )
521 m_pImpl->m_pCommandChangeListeners->removeInterface( Listener );
522}
523
524//=========================================================================
525//
526// XPropertyContainer methods.
527//
528//=========================================================================
529
530// virtual
531void SAL_CALL ContentImplHelper::addProperty(
532 const rtl::OUString& Name,
533 sal_Int16 Attributes,
534 const uno::Any& DefaultValue )
535 throw( beans::PropertyExistException,
536 beans::IllegalTypeException,
537 lang::IllegalArgumentException,
538 uno::RuntimeException )
539{
540 osl::MutexGuard aGuard( m_aMutex );
541
542 //////////////////////////////////////////////////////////////////////
543 // Make sure a property with the requested name does not already
544 // exist in dynamic and static(!) properties.
545 //////////////////////////////////////////////////////////////////////
546
547 // @@@ Need real command environment here, but where to get it from?
548 // XPropertyContainer interface should be replaced by
549 // XCommandProcessor commands!
550 uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv;
551
552 if ( getPropertySetInfo( xEnv )->hasPropertyByName( Name ) )
553 {
554 // Property does already exist.
555 throw beans::PropertyExistException();
556 }
557
558 //////////////////////////////////////////////////////////////////////
559 // Add a new dynamic property.
560 //////////////////////////////////////////////////////////////////////
561
562 // Open/create persistent property set.
563 uno::Reference< com::sun::star::ucb::XPersistentPropertySet > xSet(
564 getAdditionalPropertySet( sal_True((sal_Bool)1) ) );
565
566 OSL_ENSURE( xSet.is(),do { if (true && (!(xSet.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "567" ": "), "%s", "ContentImplHelper::addProperty - No property set!"
); } } while (false)
567 "ContentImplHelper::addProperty - No property set!" )do { if (true && (!(xSet.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "567" ": "), "%s", "ContentImplHelper::addProperty - No property set!"
); } } while (false)
;
568
569 if ( xSet.is() )
570 {
571 uno::Reference< beans::XPropertyContainer > xContainer(
572 xSet, uno::UNO_QUERY );
573
574 OSL_ENSURE(do { if (true && (!(xContainer.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "576" ": "), "%s", "ContentImplHelper::addProperty - No property container!"
); } } while (false)
575 xContainer.is(),do { if (true && (!(xContainer.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "576" ": "), "%s", "ContentImplHelper::addProperty - No property container!"
); } } while (false)
576 "ContentImplHelper::addProperty - No property container!" )do { if (true && (!(xContainer.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "576" ": "), "%s", "ContentImplHelper::addProperty - No property container!"
); } } while (false)
;
577
578 if ( xContainer.is() )
579 {
580 // Property is always removeable.
581 Attributes |= beans::PropertyAttribute::REMOVEABLE;
582
583 try
584 {
585 xContainer->addProperty( Name, Attributes, DefaultValue );
586 }
587 catch ( beans::PropertyExistException const & )
588 {
589 OSL_FAIL( "ContentImplHelper::addProperty - Exists!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "589" ": "), "%s", "ContentImplHelper::addProperty - Exists!"
); } } while (false)
;
590 throw;
591 }
592 catch ( beans::IllegalTypeException const & )
593 {
594 OSL_FAIL( "ContentImplHelper::addProperty - Wrong Type!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "594" ": "), "%s", "ContentImplHelper::addProperty - Wrong Type!"
); } } while (false)
;
595 throw;
596 }
597 catch ( lang::IllegalArgumentException const & )
598 {
599 OSL_FAIL( "ContentImplHelper::addProperty - Illegal Arg!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "599" ": "), "%s", "ContentImplHelper::addProperty - Illegal Arg!"
); } } while (false)
;
600 throw;
601 }
602
603 // Success!
604
605 if ( m_pImpl->m_xPropSetInfo.is() )
606 {
607 // Info cached in propertyset info is invalid now!
608 m_pImpl->m_xPropSetInfo->reset();
609 }
610
611 // Notify propertyset info change listeners.
612 if ( m_pImpl->m_pPropSetChangeListeners &&
613 m_pImpl->m_pPropSetChangeListeners->getLength() )
614 {
615 beans::PropertySetInfoChangeEvent evt(
616 static_cast< cppu::OWeakObject * >( this ),
617 Name,
618 -1, // No handle available
619 beans::PropertySetInfoChange::PROPERTY_INSERTED );
620 notifyPropertySetInfoChange( evt );
621 }
622 }
623 }
624}
625
626//=========================================================================
627// virtual
628void SAL_CALL ContentImplHelper::removeProperty( const rtl::OUString& Name )
629 throw( beans::UnknownPropertyException,
630 beans::NotRemoveableException,
631 uno::RuntimeException )
632{
633 osl::MutexGuard aGuard( m_aMutex );
634
635 try
636 {
637 // @@@ Need real command environment here, but where to get it from?
638 // XPropertyContainer interface should be replaced by
639 // XCommandProcessor commands!
640 uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv;
641
642 beans::Property aProp
643 = getPropertySetInfo( xEnv )->getPropertyByName( Name );
644
645 if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVEABLE ) )
646 {
647 // Not removeable!
648 throw beans::NotRemoveableException();
649 }
650 }
651 catch ( beans::UnknownPropertyException const & )
652 {
653 OSL_FAIL( "ContentImplHelper::removeProperty - Unknown!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "653" ": "), "%s", "ContentImplHelper::removeProperty - Unknown!"
); } } while (false)
;
654 throw;
655 }
656
657 //////////////////////////////////////////////////////////////////////
658 // Try to remove property from dynamic property set.
659 //////////////////////////////////////////////////////////////////////
660
661 // Open persistent property set, if exists.
662 uno::Reference< com::sun::star::ucb::XPersistentPropertySet > xSet(
663 getAdditionalPropertySet( sal_False((sal_Bool)0) ) );
664 if ( xSet.is() )
665 {
666 uno::Reference< beans::XPropertyContainer > xContainer(
667 xSet, uno::UNO_QUERY );
668
669 OSL_ENSURE(do { if (true && (!(xContainer.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "671" ": "), "%s", "ContentImplHelper::removeProperty - No property container!"
); } } while (false)
670 xContainer.is(),do { if (true && (!(xContainer.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "671" ": "), "%s", "ContentImplHelper::removeProperty - No property container!"
); } } while (false)
671 "ContentImplHelper::removeProperty - No property container!" )do { if (true && (!(xContainer.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "671" ": "), "%s", "ContentImplHelper::removeProperty - No property container!"
); } } while (false)
;
672
673 if ( xContainer.is() )
674 {
675 try
676 {
677 xContainer->removeProperty( Name );
678 }
679 catch ( beans::UnknownPropertyException const & )
680 {
681 OSL_FAIL( "ContentImplHelper::removeProperty - Unknown!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "681" ": "), "%s", "ContentImplHelper::removeProperty - Unknown!"
); } } while (false)
;
682 throw;
683 }
684 catch ( beans::NotRemoveableException const & )
685 {
686 OSL_FAIL(do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "687" ": "), "%s", "ContentImplHelper::removeProperty - Unremoveable!"
); } } while (false)
687 "ContentImplHelper::removeProperty - Unremoveable!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/ucbhelper/source/provider/contenthelper.cxx"
":" "687" ": "), "%s", "ContentImplHelper::removeProperty - Unremoveable!"
); } } while (false)
;
688 throw;
689 }
690
691 xContainer = 0;
692
693 // Success!
694
695 if ( xSet->getPropertySetInfo()->getProperties().getLength() == 0 )
696 {
697 // Remove empty propertyset from registry.
698 uno::Reference< com::sun::star::ucb::XPropertySetRegistry >
699 xReg = xSet->getRegistry();
700 if ( xReg.is() )
701 {
702 rtl::OUString aKey( xSet->getKey() );
703 xSet = 0;
704 xReg->removePropertySet( aKey );
705 }
706 }
707
708 if ( m_pImpl->m_xPropSetInfo.is() )
709 {
710 // Info cached in propertyset info is invalid now!
711 m_pImpl->m_xPropSetInfo->reset();
712 }
713
714 // Notify propertyset info change listeners.
715 if ( m_pImpl->m_pPropSetChangeListeners &&
716 m_pImpl->m_pPropSetChangeListeners->getLength() )
717 {
718 beans::PropertySetInfoChangeEvent evt(
719 static_cast< cppu::OWeakObject * >( this ),
720 Name,
721 -1, // No handle available
722 beans::PropertySetInfoChange::PROPERTY_REMOVED );
723 notifyPropertySetInfoChange( evt );
724 }
725 }
726 }
727}
728
729//=========================================================================
730//
731// XPropertySetInfoChangeNotifier methods.
732//
733//=========================================================================
734
735// virtual
736void SAL_CALL ContentImplHelper::addPropertySetInfoChangeListener(
737 const uno::Reference< beans::XPropertySetInfoChangeListener >& Listener )
738 throw( uno::RuntimeException )
739{
740 osl::MutexGuard aGuard( m_aMutex );
741
742 if ( !m_pImpl->m_pPropSetChangeListeners )
743 m_pImpl->m_pPropSetChangeListeners
744 = new cppu::OInterfaceContainerHelper( m_aMutex );
745
746 m_pImpl->m_pPropSetChangeListeners->addInterface( Listener );
747}
748
749//=========================================================================
750// virtual
751void SAL_CALL ContentImplHelper::removePropertySetInfoChangeListener(
752 const uno::Reference< beans::XPropertySetInfoChangeListener >& Listener )
753 throw( uno::RuntimeException )
754{
755 osl::MutexGuard aGuard( m_aMutex );
756
757 if ( m_pImpl->m_pPropSetChangeListeners )
758 m_pImpl->m_pPropSetChangeListeners->removeInterface( Listener );
759}
760
761//=========================================================================
762//
763// XChild methods.
764//
765//=========================================================================
766
767// virtual
768uno::Reference< uno::XInterface > SAL_CALL ContentImplHelper::getParent()
769 throw( uno::RuntimeException )
770{
771 uno::Reference< uno::XInterface > xParent;
772 rtl::OUString aURL = getParentURL();
773
774 if ( !aURL.isEmpty() )
775 {
776 uno::Reference< com::sun::star::ucb::XContentIdentifier > xId(
777 new ContentIdentifier( m_xSMgr, aURL ) );
778 try
779 {
780 xParent.set( m_xProvider->queryContent( xId ) );
781 }
782 catch ( com::sun::star::ucb::IllegalIdentifierException const & )
783 {
784 }
785 }
786
787 return xParent;
788}
789
790//=========================================================================
791// virtual
792void SAL_CALL ContentImplHelper::setParent(
793 const uno::Reference< uno::XInterface >& )
794 throw( lang::NoSupportException, uno::RuntimeException )
795{
796 throw lang::NoSupportException();
797}
798
799//=========================================================================
800//
801// Non-interface methods
802//
803//=========================================================================
804
805uno::Reference< com::sun::star::ucb::XPersistentPropertySet >
806ContentImplHelper::getAdditionalPropertySet( sal_Bool bCreate )
807{
808 // Get propertyset from provider.
809 return m_xProvider->getAdditionalPropertySet(
810 m_xIdentifier->getContentIdentifier(), bCreate );
811}
812
813//=========================================================================
814sal_Bool ContentImplHelper::renameAdditionalPropertySet(
815 const rtl::OUString& rOldKey,
816 const rtl::OUString& rNewKey,
817 sal_Bool bRecursive )
818{
819 return m_xProvider->renameAdditionalPropertySet(
820 rOldKey, rNewKey, bRecursive );
821}
822
823//=========================================================================
824sal_Bool ContentImplHelper::copyAdditionalPropertySet(
825 const rtl::OUString& rSourceKey,
826 const rtl::OUString& rTargetKey,
827 sal_Bool bRecursive )
828{
829 return m_xProvider->copyAdditionalPropertySet(
830 rSourceKey, rTargetKey, bRecursive );
831}
832
833//=========================================================================
834sal_Bool ContentImplHelper::removeAdditionalPropertySet( sal_Bool bRecursive )
835{
836 return m_xProvider->removeAdditionalPropertySet(
837 m_xIdentifier->getContentIdentifier(), bRecursive );
838}
839
840//=========================================================================
841void ContentImplHelper::notifyPropertiesChange(
842 const uno::Sequence< beans::PropertyChangeEvent >& evt ) const
843{
844 if ( !m_pImpl->m_pPropertyChangeListeners )
845 return;
846
847 sal_Int32 nCount = evt.getLength();
848 if ( nCount )
849 {
850 // First, notify listeners interested in changes of every property.
851 cppu::OInterfaceContainerHelper* pAllPropsContainer
852 = m_pImpl->m_pPropertyChangeListeners->getContainer(
853 rtl::OUString() );
854 if ( pAllPropsContainer )
855 {
856 cppu::OInterfaceIteratorHelper aIter( *pAllPropsContainer );
857 while ( aIter.hasMoreElements() )
858 {
859 // Propagate event.
860 uno::Reference< beans::XPropertiesChangeListener > xListener(
861 aIter.next(), uno::UNO_QUERY );
862 if ( xListener.is() )
863 xListener->propertiesChange( evt );
864 }
865 }
866
867 PropertiesEventListenerMap aListeners;
868
869 const beans::PropertyChangeEvent* pEvents = evt.getConstArray();
870
871 for ( sal_Int32 n = 0; n < nCount; ++n )
872 {
873 const beans::PropertyChangeEvent& rEvent = pEvents[ n ];
874 const rtl::OUString& rName = rEvent.PropertyName;
875
876 cppu::OInterfaceContainerHelper* pPropsContainer
877 = m_pImpl->m_pPropertyChangeListeners->getContainer( rName );
878 if ( pPropsContainer )
879 {
880 cppu::OInterfaceIteratorHelper aIter( *pPropsContainer );
881 while ( aIter.hasMoreElements() )
882 {
883 PropertyEventSequence* p = NULL__null;
884
885 beans::XPropertiesChangeListener* pListener =
886 static_cast< beans::XPropertiesChangeListener * >(
887 aIter.next() );
888 PropertiesEventListenerMap::iterator it =
889 aListeners.find( pListener );
890 if ( it == aListeners.end() )
891 {
892 // Not in map - create and insert new entry.
893 p = new PropertyEventSequence( nCount );
894 aListeners[ pListener ] = p;
895 }
896 else
897 p = (*it).second;
898
899 if ( p )
900 p->append( rEvent );
901 }
902 }
903 }
904
905 // Notify listeners.
906 PropertiesEventListenerMap::iterator it = aListeners.begin();
907 while ( !aListeners.empty() )
908 {
909 beans::XPropertiesChangeListener* pListener =
910 static_cast< beans::XPropertiesChangeListener * >( (*it).first );
911 PropertyEventSequence* pSeq = (*it).second;
912
913 // Remove current element.
914 aListeners.erase( it );
915
916 // Propagate event.
917 pListener->propertiesChange( pSeq->getEvents() );
918
919 delete pSeq;
920
921 it = aListeners.begin();
922 }
923 }
924}
925
926//=========================================================================
927void ContentImplHelper::notifyPropertySetInfoChange(
928 const beans::PropertySetInfoChangeEvent& evt ) const
929{
930 if ( !m_pImpl->m_pPropSetChangeListeners )
931 return;
932
933 // Notify event listeners.
934 cppu::OInterfaceIteratorHelper aIter( *m_pImpl->m_pPropSetChangeListeners );
935 while ( aIter.hasMoreElements() )
936 {
937 // Propagate event.
938 uno::Reference< beans::XPropertySetInfoChangeListener >
939 xListener( aIter.next(), uno::UNO_QUERY );
940 if ( xListener.is() )
941 xListener->propertySetInfoChange( evt );
942 }
943}
944
945//=========================================================================
946void ContentImplHelper::notifyContentEvent(
947 const com::sun::star::ucb::ContentEvent& evt ) const
948{
949 if ( !m_pImpl->m_pContentEventListeners )
950 return;
951
952 // Notify event listeners.
953 cppu::OInterfaceIteratorHelper aIter( *m_pImpl->m_pContentEventListeners );
954 while ( aIter.hasMoreElements() )
955 {
956 // Propagate event.
957 uno::Reference<
958 com::sun::star::ucb::XContentEventListener > xListener(
959 aIter.next(), uno::UNO_QUERY );
960 if ( xListener.is() )
961 xListener->contentEvent( evt );
962 }
963}
964
965//=========================================================================
966void ContentImplHelper::inserted()
967{
968 // Content is not yet registered at provider.
969 m_xProvider->registerNewContent( this );
970
971 // If the parent content is currently not instanciated, there can be
972 // no listeners interested in changes ;-)
973
974 rtl::Reference< ContentImplHelper > xParent
975 = m_xProvider->queryExistingContent( getParentURL() );
976
977 if ( xParent.is() )
978 {
979 com::sun::star::ucb::ContentEvent aEvt(
980 static_cast< cppu::OWeakObject * >( xParent.get() ), // Source
981 com::sun::star::ucb::ContentAction::INSERTED, // Action
982 this, // Content
983 xParent->getIdentifier() ); // Id
984 xParent->notifyContentEvent( aEvt );
985 }
986}
987
988//=========================================================================
989void ContentImplHelper::deleted()
990{
991 uno::Reference< com::sun::star::ucb::XContent > xThis = this;
992
993 rtl::Reference< ContentImplHelper > xParent
994 = m_xProvider->queryExistingContent( getParentURL() );
995
996 if ( xParent.is() )
997 {
998 // Let parent notify "REMOVED" event.
999 com::sun::star::ucb::ContentEvent aEvt(
1000 static_cast< cppu::OWeakObject * >( xParent.get() ),
1001 com::sun::star::ucb::ContentAction::REMOVED,
1002 this,
1003 xParent->getIdentifier() );
1004 xParent->notifyContentEvent( aEvt );
1005 }
1006
1007 // Notify "DELETED" event.
1008 com::sun::star::ucb::ContentEvent aEvt1(
1009 static_cast< cppu::OWeakObject * >( this ),
1010 com::sun::star::ucb::ContentAction::DELETED,
1011 this,
1012 getIdentifier() );
1013 notifyContentEvent( aEvt1 );
1014
1015 m_xProvider->removeContent( this );
1016}
1017
1018//=========================================================================
1019sal_Bool ContentImplHelper::exchange(
1020 const uno::Reference< com::sun::star::ucb::XContentIdentifier >& rNewId )
1021{
1022 uno::Reference< com::sun::star::ucb::XContent > xThis = this;
1023
1024 osl::ClearableMutexGuard aGuard( m_aMutex );
1025
1026 rtl::Reference< ContentImplHelper > xContent
1027 = m_xProvider->queryExistingContent( rNewId );
Called C++ object pointer is null
1028 if ( xContent.is() )
1029 {
1030 // @@@
1031 // Big trouble. Another object with the new identity exists.
1032 // How shall I mutate to / merge with the other object?
1033 return sal_False((sal_Bool)0);
1034 }
1035
1036 uno::Reference< com::sun::star::ucb::XContentIdentifier > xOldId
1037 = getIdentifier();
1038
1039 // Re-insert at provider.
1040 m_xProvider->removeContent( this );
1041 m_xIdentifier = rNewId;
1042 m_xProvider->registerNewContent( this );
1043
1044 aGuard.clear();
1045
1046 // Notify "EXCHANGED" event.
1047 com::sun::star::ucb::ContentEvent aEvt(
1048 static_cast< cppu::OWeakObject * >( this ),
1049 com::sun::star::ucb::ContentAction::EXCHANGED,
1050 this,
1051 xOldId );
1052 notifyContentEvent( aEvt );
1053 return sal_True((sal_Bool)1);
1054}
1055
1056//=========================================================================
1057uno::Reference< com::sun::star::ucb::XCommandInfo >
1058ContentImplHelper::getCommandInfo(
1059 const uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv,
1060 sal_Bool bCache )
1061{
1062 osl::MutexGuard aGuard( m_aMutex );
1063
1064 if ( !m_pImpl->m_xCommandsInfo.is() )
1065 m_pImpl->m_xCommandsInfo
1066 = new CommandProcessorInfo( m_xSMgr, xEnv, this );
1067 else if ( !bCache )
1068 m_pImpl->m_xCommandsInfo->reset();
1069
1070 return uno::Reference< com::sun::star::ucb::XCommandInfo >(
1071 m_pImpl->m_xCommandsInfo.get() );
1072}
1073
1074//=========================================================================
1075uno::Reference< beans::XPropertySetInfo >
1076ContentImplHelper::getPropertySetInfo(
1077 const uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv,
1078 sal_Bool bCache )
1079{
1080 osl::MutexGuard aGuard( m_aMutex );
1081
1082 if ( !m_pImpl->m_xPropSetInfo.is() )
1083 m_pImpl->m_xPropSetInfo
1084 = new PropertySetInfo( m_xSMgr, xEnv, this );
1085 else if ( !bCache )
1086 m_pImpl->m_xPropSetInfo->reset();
1087
1088 return uno::Reference< beans::XPropertySetInfo >(
1089 m_pImpl->m_xPropSetInfo.get() );
1090}
1091
1092} // namespace ucbhelper
1093
1094/* vim:set shiftwidth=4 softtabstop=4 expandtab: */