1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef SD_UNOLAYER_HXX 28 #define SD_UNOLAYER_HXX 29 30 #include <com/sun/star/container/XIndexAccess.hpp> 31 #include <com/sun/star/drawing/XLayer.hpp> 32 #include <com/sun/star/drawing/XLayerManager.hpp> 33 34 #include <cppuhelper/implbase5.hxx> 35 #include <comphelper/servicehelper.hxx> 36 37 #include <unomodel.hxx> 38 39 class SdrLayer; 40 class SdLayerManager; 41 class SdXImpressDocument; 42 class SvUnoWeakContainer; 43 44 namespace sd { 45 class View; 46 } 47 enum LayerAttribute { VISIBLE, PRINTABLE, LOCKED }; 48 49 /*********************************************************************** 50 * * 51 ***********************************************************************/ 52 class SdLayer : public ::cppu::WeakImplHelper5< ::com::sun::star::drawing::XLayer, 53 ::com::sun::star::lang::XServiceInfo, 54 ::com::sun::star::container::XChild, 55 ::com::sun::star::lang::XUnoTunnel, 56 ::com::sun::star::lang::XComponent > 57 { 58 public: 59 SdLayer( SdLayerManager* pLayerManager_, SdrLayer* pSdrLayer_ ) throw(); 60 virtual ~SdLayer() throw(); 61 62 // intern 63 SdrLayer* GetSdrLayer() const throw() { return pLayer; } 64 65 static String convertToInternalName( const ::rtl::OUString& rName ); 66 static ::rtl::OUString convertToExternalName( const String& rName ); 67 68 // uno helper 69 UNO3_GETIMPLEMENTATION_DECL( SdLayer ) 70 71 // XServiceInfo 72 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); 73 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); 74 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); 75 76 // ::com::sun::star::beans::XPropertySet 77 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 78 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 79 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 80 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 81 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 82 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 83 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 84 85 // ::com::sun::star::container::XChild 86 87 /** Returns the layer manager that manages this layer. 88 */ 89 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); 90 91 // XComponent 92 virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); 93 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 94 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 95 96 /** Not implemented. Allways throws an exception. 97 @raises NoSupportException. 98 */ 99 virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); 100 101 private: 102 SdLayerManager* pLayerManager; 103 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayerManager > mxLayerManager; 104 105 SdrLayer* pLayer; 106 const SvxItemPropertySet* pPropSet; 107 108 sal_Bool get( LayerAttribute what ) throw(); 109 void set( LayerAttribute what, sal_Bool flag ) throw(); 110 111 }; 112 113 114 115 116 /*********************************************************************** 117 * * 118 ***********************************************************************/ 119 120 //#include <cppuhelper/implbase4.hxx> 121 122 class SdLayerManager : public ::cppu::WeakImplHelper5< ::com::sun::star::drawing::XLayerManager, 123 ::com::sun::star::container::XNameAccess, 124 ::com::sun::star::lang::XServiceInfo, 125 ::com::sun::star::lang::XUnoTunnel, 126 ::com::sun::star::lang::XComponent > 127 { 128 friend class SdLayer; 129 130 public: 131 SdLayerManager( SdXImpressDocument& rMyModel ) throw(); 132 virtual ~SdLayerManager() throw(); 133 134 // uno helper 135 UNO3_GETIMPLEMENTATION_DECL( SdLayerManager ) 136 137 // XServiceInfo 138 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); 139 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); 140 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); 141 142 // XLayerManager 143 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException); 144 virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer >& xLayer ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); 145 virtual void SAL_CALL attachShapeToLayer( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer >& xLayer ) throw(::com::sun::star::uno::RuntimeException); 146 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer > SAL_CALL getLayerForShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException); 147 148 // XIndexAccess 149 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ; 150 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 151 152 // XNameAccess 153 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 154 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException); 155 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); 156 157 // XElementAccess 158 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); 159 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); 160 161 /** Return the <type>XLayer</type> object that is associated with the 162 given <type>SdrLayer</type> object. If the requested object does 163 not yet exist it is created. All calls with the same argument 164 return the same object. 165 @param pLayer 166 The <type>SdrLayer</type> object for which to return the 167 associated <type>XLayer</type> object. 168 @return 169 The returned value is the unique <type>XLayer</type> object 170 associated with the specified argument. If no layer can be 171 created for the argument than an empty reference is returned. 172 */ 173 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer> GetLayer (SdrLayer* pLayer); 174 175 // XComponent 176 virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); 177 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 178 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 179 180 private: 181 SdXImpressDocument* mpModel; 182 SvUnoWeakContainer* mpLayers; 183 184 ::sd::View* GetView() const throw(); 185 ::sd::DrawDocShell* GetDocShell() const throw() { return mpModel->mpDocShell; } 186 void UpdateLayerView( sal_Bool modify = sal_True ) const throw(); 187 }; 188 189 #endif 190