1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef __FRAMEWORK_UIELEMENT_ROOTITEMCONTAINER_HXX_ 25 #define __FRAMEWORK_UIELEMENT_ROOTITEMCONTAINER_HXX_ 26 27 //_________________________________________________________________________________________________________________ 28 // my own includes 29 //_________________________________________________________________________________________________________________ 30 31 #include <threadhelp/threadhelpbase.hxx> 32 #include <macros/generic.hxx> 33 #include <macros/xinterface.hxx> 34 #include <macros/xtypeprovider.hxx> 35 #include <helper/shareablemutex.hxx> 36 37 //_________________________________________________________________________________________________________________ 38 // interface includes 39 //_________________________________________________________________________________________________________________ 40 #include <com/sun/star/container/XIndexContainer.hpp> 41 #include <com/sun/star/container/XIndexAccess.hpp> 42 #include <com/sun/star/lang/XSingleComponentFactory.hpp> 43 #include <com/sun/star/beans/PropertyValue.hpp> 44 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 45 #include <com/sun/star/lang/XUnoTunnel.hpp> 46 47 //_________________________________________________________________________________________________________________ 48 // other includes 49 //_________________________________________________________________________________________________________________ 50 #include <rtl/ustring.hxx> 51 #include <cppuhelper/weak.hxx> 52 #include <cppuhelper/propshlp.hxx> 53 #include <cppuhelper/interfacecontainer.hxx> 54 55 #include <vector> 56 #include <fwidllapi.h> 57 58 namespace framework 59 { 60 class ConstItemContainer; 61 class RootItemContainer : public ::com::sun::star::lang::XTypeProvider , 62 public ::com::sun::star::container::XIndexContainer , 63 public ::com::sun::star::lang::XSingleComponentFactory , 64 public ::com::sun::star::lang::XUnoTunnel , 65 protected ThreadHelpBase , 66 public ::cppu::OBroadcastHelper , 67 public ::cppu::OPropertySetHelper , 68 public ::cppu::OWeakObject 69 { 70 friend class ConstItemContainer; 71 72 public: 73 FWI_DLLPUBLIC RootItemContainer(); 74 FWI_DLLPUBLIC RootItemContainer( const ConstItemContainer& rConstItemContainer ); 75 FWI_DLLPUBLIC RootItemContainer( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rItemAccessContainer ); 76 virtual FWI_DLLPUBLIC ~RootItemContainer(); 77 78 //--------------------------------------------------------------------------------------------------------- 79 // XInterface, XTypeProvider 80 //--------------------------------------------------------------------------------------------------------- 81 FWK_DECLARE_XINTERFACE 82 FWK_DECLARE_XTYPEPROVIDER 83 84 // XUnoTunnel 85 static FWI_DLLPUBLIC const ::com::sun::star::uno::Sequence< sal_Int8 >& GetUnoTunnelId() throw(); 86 static FWI_DLLPUBLIC RootItemContainer* GetImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace ) throw(); 87 sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException); 88 89 // XIndexContainer 90 virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) 91 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 92 93 virtual void SAL_CALL removeByIndex( sal_Int32 Index ) 94 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 95 96 // XIndexReplace 97 virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) 98 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 99 100 // XIndexAccess 101 virtual sal_Int32 SAL_CALL getCount() 102 throw (::com::sun::star::uno::RuntimeException); 103 104 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) 105 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 106 107 // XElementAccess getElementType()108 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 109 throw (::com::sun::star::uno::RuntimeException) 110 { 111 return ::getCppuType((com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >*)0); 112 } 113 114 virtual sal_Bool SAL_CALL hasElements() 115 throw (::com::sun::star::uno::RuntimeException); 116 117 // XSingleComponentFactory 118 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 119 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 120 121 protected: 122 // OPropertySetHelper 123 virtual sal_Bool SAL_CALL convertFastPropertyValue ( com::sun::star::uno::Any& aConvertedValue , 124 com::sun::star::uno::Any& aOldValue , 125 sal_Int32 nHandle , 126 const com::sun::star::uno::Any& aValue ) throw( com::sun::star::lang::IllegalArgumentException ); 127 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , 128 const com::sun::star::uno::Any& aValue ) throw( com::sun::star::uno::Exception ); 129 using cppu::OPropertySetHelper::getFastPropertyValue; 130 virtual void SAL_CALL getFastPropertyValue( com::sun::star::uno::Any& aValue , 131 sal_Int32 nHandle ) const; 132 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 133 virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException); 134 135 static const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > impl_getStaticPropertyDescriptor(); 136 137 private: 138 RootItemContainer& operator=( const RootItemContainer& ); 139 RootItemContainer( const RootItemContainer& ); 140 141 void copyItemContainer( const std::vector< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >& rSourceVector ); 142 com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > deepCopyContainer( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rSubContainer ); 143 144 mutable ShareableMutex m_aShareMutex; 145 std::vector< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > > m_aItemVector; 146 rtl::OUString m_aUIName; 147 }; 148 149 } 150 151 #endif // #ifndef __FRAMEWORK_UIELEMENT_ROOTITEMCONTAINER_HXX_ 152