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