1*38d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*38d50f7bSAndrew Rist * distributed with this work for additional information 6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10*38d50f7bSAndrew Rist * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*38d50f7bSAndrew Rist * 13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an 15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 17*38d50f7bSAndrew Rist * specific language governing permissions and limitations 18*38d50f7bSAndrew Rist * under the License. 19*38d50f7bSAndrew Rist * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_AFMTUNO_HXX 25cdf0e10cSrcweir #define SC_AFMTUNO_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svl/lstner.hxx> 28cdf0e10cSrcweir #include <svl/itemprop.hxx> 29cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 30cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp> 31cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp> 32cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp> 33cdf0e10cSrcweir #include <com/sun/star/container/XContainerListener.hpp> 34cdf0e10cSrcweir #include <com/sun/star/container/XSet.hpp> 35cdf0e10cSrcweir #include <com/sun/star/container/ContainerEvent.hpp> 36cdf0e10cSrcweir #include <com/sun/star/container/XIndexReplace.hpp> 37cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 38cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp> 39cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 40cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp> 41cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 42cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 43cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx> 44cdf0e10cSrcweir #include <cppuhelper/implbase6.hxx> 45cdf0e10cSrcweir 46cdf0e10cSrcweir class ScAutoFormatFieldObj; 47cdf0e10cSrcweir class ScAutoFormatObj; 48cdf0e10cSrcweir 49cdf0e10cSrcweir 50cdf0e10cSrcweir #define SC_AFMTOBJ_INVALID USHRT_MAX 51cdf0e10cSrcweir 52cdf0e10cSrcweir 53cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 54cdf0e10cSrcweir ScAutoFormatsObj_CreateInstance( 55cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 56cdf0e10cSrcweir ::com::sun::star::lang::XMultiServiceFactory >& ); 57cdf0e10cSrcweir 58cdf0e10cSrcweir 59cdf0e10cSrcweir class ScAutoFormatsObj : public ::cppu::WeakImplHelper4< 60cdf0e10cSrcweir ::com::sun::star::container::XNameContainer, 61cdf0e10cSrcweir ::com::sun::star::container::XEnumerationAccess, 62cdf0e10cSrcweir ::com::sun::star::container::XIndexAccess, 63cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo > 64cdf0e10cSrcweir { 65cdf0e10cSrcweir private: 66cdf0e10cSrcweir ScAutoFormatObj* GetObjectByIndex_Impl(sal_uInt16 nIndex); 67cdf0e10cSrcweir ScAutoFormatObj* GetObjectByName_Impl(const ::rtl::OUString& aName); 68cdf0e10cSrcweir 69cdf0e10cSrcweir public: 70cdf0e10cSrcweir ScAutoFormatsObj(); 71cdf0e10cSrcweir virtual ~ScAutoFormatsObj(); 72cdf0e10cSrcweir 73cdf0e10cSrcweir static ::rtl::OUString getImplementationName_Static(); 74cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< ::rtl::OUString> getSupportedServiceNames_Static(); 75cdf0e10cSrcweir 76cdf0e10cSrcweir // XNameContainer 77cdf0e10cSrcweir virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, 78cdf0e10cSrcweir const ::com::sun::star::uno::Any& aElement ) 79cdf0e10cSrcweir throw(::com::sun::star::lang::IllegalArgumentException, 80cdf0e10cSrcweir ::com::sun::star::container::ElementExistException, 81cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 82cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 83cdf0e10cSrcweir virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) 84cdf0e10cSrcweir throw(::com::sun::star::container::NoSuchElementException, 85cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 86cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 87cdf0e10cSrcweir 88cdf0e10cSrcweir // XNameReplace 89cdf0e10cSrcweir virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, 90cdf0e10cSrcweir const ::com::sun::star::uno::Any& aElement ) 91cdf0e10cSrcweir throw(::com::sun::star::lang::IllegalArgumentException, 92cdf0e10cSrcweir ::com::sun::star::container::NoSuchElementException, 93cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 94cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir 96cdf0e10cSrcweir // XNameAccess 97cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) 98cdf0e10cSrcweir throw(::com::sun::star::container::NoSuchElementException, 99cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 100cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 101cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() 102cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 103cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) 104cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 105cdf0e10cSrcweir 106cdf0e10cSrcweir // XElementAccess 107cdf0e10cSrcweir virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 108cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 109cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); 110cdf0e10cSrcweir 111cdf0e10cSrcweir // XEnumerationAccess 112cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL 113cdf0e10cSrcweir createEnumeration() throw(::com::sun::star::uno::RuntimeException); 114cdf0e10cSrcweir 115cdf0e10cSrcweir // XIndexAccess 116cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); 117cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) 118cdf0e10cSrcweir throw(::com::sun::star::lang::IndexOutOfBoundsException, 119cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 120cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 121cdf0e10cSrcweir 122cdf0e10cSrcweir // XServiceInfo 123cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() 124cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 125cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 126cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 127cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 128cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 129cdf0e10cSrcweir }; 130cdf0e10cSrcweir 131cdf0e10cSrcweir 132cdf0e10cSrcweir class ScAutoFormatObj : public ::cppu::WeakImplHelper6< 133cdf0e10cSrcweir ::com::sun::star::container::XIndexAccess, 134cdf0e10cSrcweir ::com::sun::star::container::XEnumerationAccess, 135cdf0e10cSrcweir ::com::sun::star::container::XNamed, 136cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet, 137cdf0e10cSrcweir ::com::sun::star::lang::XUnoTunnel, 138cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo >, 139cdf0e10cSrcweir public SfxListener 140cdf0e10cSrcweir { 141cdf0e10cSrcweir private: 142cdf0e10cSrcweir SfxItemPropertySet aPropSet; 143cdf0e10cSrcweir sal_uInt16 nFormatIndex; 144cdf0e10cSrcweir 145cdf0e10cSrcweir ScAutoFormatFieldObj* GetObjectByIndex_Impl(sal_uInt16 nIndex); 146cdf0e10cSrcweir 147cdf0e10cSrcweir public: 148cdf0e10cSrcweir ScAutoFormatObj(sal_uInt16 nIndex); 149cdf0e10cSrcweir virtual ~ScAutoFormatObj(); 150cdf0e10cSrcweir 151cdf0e10cSrcweir virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 152cdf0e10cSrcweir 153cdf0e10cSrcweir // per getImplementation gerufen: IsInserted() const154cdf0e10cSrcweir sal_Bool IsInserted() const { return nFormatIndex != SC_AFMTOBJ_INVALID; } 155cdf0e10cSrcweir void InitFormat( sal_uInt16 nNewIndex ); 156cdf0e10cSrcweir 157cdf0e10cSrcweir // XIndexAccess 158cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); 159cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) 160cdf0e10cSrcweir throw(::com::sun::star::lang::IndexOutOfBoundsException, 161cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 162cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 163cdf0e10cSrcweir 164cdf0e10cSrcweir // XElementAccess 165cdf0e10cSrcweir virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 166cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 167cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); 168cdf0e10cSrcweir 169cdf0e10cSrcweir // XEnumerationAccess 170cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL 171cdf0e10cSrcweir createEnumeration() throw(::com::sun::star::uno::RuntimeException); 172cdf0e10cSrcweir 173cdf0e10cSrcweir // XNamed 174cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); 175cdf0e10cSrcweir virtual void SAL_CALL setName( const ::rtl::OUString& aName ) 176cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 177cdf0e10cSrcweir 178cdf0e10cSrcweir // XPropertySet 179cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 180cdf0e10cSrcweir SAL_CALL getPropertySetInfo() 181cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 182cdf0e10cSrcweir virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, 183cdf0e10cSrcweir const ::com::sun::star::uno::Any& aValue ) 184cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 185cdf0e10cSrcweir ::com::sun::star::beans::PropertyVetoException, 186cdf0e10cSrcweir ::com::sun::star::lang::IllegalArgumentException, 187cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 188cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 189cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( 190cdf0e10cSrcweir const ::rtl::OUString& PropertyName ) 191cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 192cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 193cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 194cdf0e10cSrcweir virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, 195cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 196cdf0e10cSrcweir ::com::sun::star::beans::XPropertyChangeListener >& xListener ) 197cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 198cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 199cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 200cdf0e10cSrcweir virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, 201cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 202cdf0e10cSrcweir ::com::sun::star::beans::XPropertyChangeListener >& aListener ) 203cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 204cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 205cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 206cdf0e10cSrcweir virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, 207cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 208cdf0e10cSrcweir ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 209cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 210cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 211cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 212cdf0e10cSrcweir virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, 213cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 214cdf0e10cSrcweir ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 215cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 216cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 217cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 218cdf0e10cSrcweir 219cdf0e10cSrcweir // XServiceInfo 220cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() 221cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 222cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 223cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 224cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 225cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 226cdf0e10cSrcweir 227cdf0e10cSrcweir // XUnoTunnel 228cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< 229cdf0e10cSrcweir sal_Int8 >& aIdentifier ) 230cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 231cdf0e10cSrcweir 232cdf0e10cSrcweir static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId(); 233cdf0e10cSrcweir static ScAutoFormatObj* getImplementation( const ::com::sun::star::uno::Reference< 234cdf0e10cSrcweir ::com::sun::star::uno::XInterface> xObj ); 235cdf0e10cSrcweir }; 236cdf0e10cSrcweir 237cdf0e10cSrcweir 238cdf0e10cSrcweir class ScAutoFormatFieldObj : public ::cppu::WeakImplHelper2< 239cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet, 240cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo >, 241cdf0e10cSrcweir public SfxListener 242cdf0e10cSrcweir { 243cdf0e10cSrcweir private: 244cdf0e10cSrcweir SfxItemPropertySet aPropSet; 245cdf0e10cSrcweir sal_uInt16 nFormatIndex; 246cdf0e10cSrcweir sal_uInt16 nFieldIndex; 247cdf0e10cSrcweir 248cdf0e10cSrcweir public: 249cdf0e10cSrcweir ScAutoFormatFieldObj(sal_uInt16 nFormat, sal_uInt16 nField); 250cdf0e10cSrcweir virtual ~ScAutoFormatFieldObj(); 251cdf0e10cSrcweir 252cdf0e10cSrcweir virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 253cdf0e10cSrcweir 254cdf0e10cSrcweir // XPropertySet 255cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 256cdf0e10cSrcweir SAL_CALL getPropertySetInfo() 257cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 258cdf0e10cSrcweir virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, 259cdf0e10cSrcweir const ::com::sun::star::uno::Any& aValue ) 260cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 261cdf0e10cSrcweir ::com::sun::star::beans::PropertyVetoException, 262cdf0e10cSrcweir ::com::sun::star::lang::IllegalArgumentException, 263cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 264cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 265cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( 266cdf0e10cSrcweir const ::rtl::OUString& PropertyName ) 267cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 268cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 269cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 270cdf0e10cSrcweir virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, 271cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 272cdf0e10cSrcweir ::com::sun::star::beans::XPropertyChangeListener >& xListener ) 273cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 274cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 275cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 276cdf0e10cSrcweir virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, 277cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 278cdf0e10cSrcweir ::com::sun::star::beans::XPropertyChangeListener >& aListener ) 279cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 280cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 281cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 282cdf0e10cSrcweir virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, 283cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 284cdf0e10cSrcweir ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 285cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 286cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 287cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 288cdf0e10cSrcweir virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, 289cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 290cdf0e10cSrcweir ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 291cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, 292cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 293cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 294cdf0e10cSrcweir 295cdf0e10cSrcweir // XServiceInfo 296cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() 297cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 298cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 299cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 300cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 301cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 302cdf0e10cSrcweir }; 303cdf0e10cSrcweir 304cdf0e10cSrcweir 305cdf0e10cSrcweir #endif 306cdf0e10cSrcweir 307