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 28 #ifndef _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_ 29 #define _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_ 30 31 #define EDITOR_LIST_APPEND (sal_uInt16)-1 32 #define EDITOR_LIST_REPLACE_EXISTING (sal_uInt16)-1 33 34 /** === begin UNO includes === **/ 35 #include <com/sun/star/uno/Sequence.hxx> 36 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 37 #include <com/sun/star/beans/PropertyChangeEvent.hpp> 38 /** === end UNO includes === **/ 39 40 #include <tools/string.hxx> 41 #include <toolkit/helper/vclunohelper.hxx> 42 #include <comphelper/listenernotification.hxx> 43 44 //............................................................................ 45 namespace pcr 46 { 47 //............................................................................ 48 49 #define OWN_PROPERTY_ID_INTROSPECTEDOBJECT 0x0010 50 #define OWN_PROPERTY_ID_CURRENTPAGE 0x0011 51 #define OWN_PROPERTY_ID_CONTROLCONTEXT 0x0012 52 #define OWN_PROPERTY_ID_TABBINGMODEL 0x0013 53 54 //======================================================================== 55 //= types 56 //======================================================================== 57 typedef ::comphelper::OSimpleListenerContainer < ::com::sun::star::beans::XPropertyChangeListener 58 , ::com::sun::star::beans::PropertyChangeEvent 59 > PropertyChangeListeners; 60 61 //======================================================================== 62 //= helper 63 //======================================================================== 64 // small helper to make the "swap" call on an STL container a single-line call, which 65 // in it's canonic form "aFoo.swap( Container() )" doesn't compile with GCC 66 template< class CONTAINER > 67 void clearContainer( CONTAINER& _rContainer ) 68 { 69 CONTAINER aEmpty; 70 _rContainer.swap( aEmpty ); 71 } 72 73 //======================================================================== 74 //= HelpIdUrl 75 //======================================================================== 76 /// small helper to translate help ids into help urls 77 class HelpIdUrl 78 { 79 public: 80 static rtl::OString getHelpId( const ::rtl::OUString& _rHelpURL ); 81 static ::rtl::OUString getHelpURL( const rtl::OString& ); 82 }; 83 84 //==================================================================== 85 //= StlSyntaxSequence 86 //==================================================================== 87 template< class ELEMENT > 88 class StlSyntaxSequence : public ::com::sun::star::uno::Sequence< ELEMENT > 89 { 90 private: 91 typedef ::com::sun::star::uno::Sequence< ELEMENT > UnoBase; 92 93 public: 94 inline StlSyntaxSequence() : UnoBase() { } 95 inline StlSyntaxSequence( const UnoBase& rSeq ) : UnoBase( rSeq ) { } 96 inline StlSyntaxSequence( const ELEMENT* pElements, sal_Int32 len ) : UnoBase( pElements, len ) { } 97 inline StlSyntaxSequence( sal_Int32 len ) : UnoBase( len ) { } 98 99 operator const UnoBase&() const { return *this; } 100 operator UnoBase&() { return *this; } 101 102 typedef const ELEMENT* const_iterator; 103 typedef ELEMENT* iterator; 104 105 inline const_iterator begin() const { return UnoBase::getConstArray(); } 106 inline const_iterator end() const { return UnoBase::getConstArray() + UnoBase::getLength(); } 107 108 inline iterator begin() { return UnoBase::getArray(); } 109 inline iterator end() { return UnoBase::getArray() + UnoBase::getLength(); } 110 111 inline sal_Int32 size() const { return UnoBase::getLength(); } 112 inline bool empty() const { return UnoBase::getLength() == 0; } 113 114 inline void resize( size_t _newSize ) { UnoBase::realloc( _newSize ); } 115 116 inline iterator erase( iterator _pos ) 117 { 118 iterator loop = end(); 119 while ( --loop != _pos ) 120 *( loop - 1 ) = *loop; 121 resize( size() - 1 ); 122 } 123 }; 124 125 //======================================================================== 126 //= UNO helpers 127 //======================================================================== 128 #define DECLARE_XCOMPONENT() \ 129 virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); \ 130 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); \ 131 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 132 133 #define IMPLEMENT_FORWARD_XCOMPONENT( classname, baseclass ) \ 134 void SAL_CALL classname::dispose( ) throw (::com::sun::star::uno::RuntimeException) \ 135 { \ 136 baseclass::WeakComponentImplHelperBase::dispose(); \ 137 } \ 138 void SAL_CALL classname::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \ 139 { \ 140 baseclass::WeakComponentImplHelperBase::addEventListener( _Listener ); \ 141 } \ 142 void SAL_CALL classname::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \ 143 { \ 144 baseclass::WeakComponentImplHelperBase::removeEventListener( _Listener ); \ 145 } \ 146 147 //............................................................................ 148 } // namespace pcr 149 //............................................................................ 150 151 #endif // _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_ 152 153