masterfix DEV300: #i10000# build fix
[LibreOffice.git] / extensions / source / propctrlr / pcrcommon.hxx
blob69e508ca8d8715182cdbdfb5cfc504b72264b333
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
29 #define _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
31 #define EDITOR_LIST_APPEND (sal_uInt16)-1
32 #define EDITOR_LIST_REPLACE_EXISTING (sal_uInt16)-1
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 === **/
40 #include <tools/string.hxx>
41 #include <toolkit/helper/vclunohelper.hxx>
42 #include <comphelper/listenernotification.hxx>
44 //............................................................................
45 namespace pcr
47 //............................................................................
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
54 //========================================================================
55 //= types
56 //========================================================================
57 typedef ::comphelper::OSimpleListenerContainer < ::com::sun::star::beans::XPropertyChangeListener
58 , ::com::sun::star::beans::PropertyChangeEvent
59 > PropertyChangeListeners;
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 )
69 CONTAINER aEmpty;
70 _rContainer.swap( aEmpty );
73 //========================================================================
74 //= HelpIdUrl
75 //========================================================================
76 /// small helper to translate help ids into help urls
77 class HelpIdUrl
79 public:
80 static rtl::OString getHelpId( const ::rtl::OUString& _rHelpURL );
81 static ::rtl::OUString getHelpURL( const rtl::OString& );
84 //====================================================================
85 //= StlSyntaxSequence
86 //====================================================================
87 template< class ELEMENT >
88 class StlSyntaxSequence : public ::com::sun::star::uno::Sequence< ELEMENT >
90 private:
91 typedef ::com::sun::star::uno::Sequence< ELEMENT > UnoBase;
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 ) { }
99 operator const UnoBase&() const { return *this; }
100 operator UnoBase&() { return *this; }
102 typedef const ELEMENT* const_iterator;
103 typedef ELEMENT* iterator;
105 inline const_iterator begin() const { return UnoBase::getConstArray(); }
106 inline const_iterator end() const { return UnoBase::getConstArray() + UnoBase::getLength(); }
108 inline iterator begin() { return UnoBase::getArray(); }
109 inline iterator end() { return UnoBase::getArray() + UnoBase::getLength(); }
111 inline sal_Int32 size() const { return UnoBase::getLength(); }
112 inline bool empty() const { return UnoBase::getLength() == 0; }
114 inline void resize( size_t _newSize ) { UnoBase::realloc( _newSize ); }
116 inline iterator erase( iterator _pos )
118 iterator loop = end();
119 while ( --loop != _pos )
120 *( loop - 1 ) = *loop;
121 resize( size() - 1 );
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);
133 #define IMPLEMENT_FORWARD_XCOMPONENT( classname, baseclass ) \
134 void SAL_CALL classname::dispose( ) throw (::com::sun::star::uno::RuntimeException) \
136 baseclass::WeakComponentImplHelperBase::dispose(); \
138 void SAL_CALL classname::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
140 baseclass::WeakComponentImplHelperBase::addEventListener( _Listener ); \
142 void SAL_CALL classname::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
144 baseclass::WeakComponentImplHelperBase::removeEventListener( _Listener ); \
147 //............................................................................
148 } // namespace pcr
149 //............................................................................
151 #endif // _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_