1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pcrcommon.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
32 #define _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
34 #define EDITOR_LIST_APPEND (sal_uInt16)-1
35 #define EDITOR_LIST_REPLACE_EXISTING (sal_uInt16)-1
37 /** === begin UNO includes === **/
38 #include <com/sun/star/uno/Sequence.hxx>
39 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
40 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
41 /** === end UNO includes === **/
43 #include <vcl/smartid.hxx>
44 #include <tools/string.hxx>
45 #include <toolkit/helper/vclunohelper.hxx>
46 #include <comphelper/listenernotification.hxx>
48 //............................................................................
51 //............................................................................
53 #define OWN_PROPERTY_ID_INTROSPECTEDOBJECT 0x0010
54 #define OWN_PROPERTY_ID_CURRENTPAGE 0x0011
55 #define OWN_PROPERTY_ID_CONTROLCONTEXT 0x0012
56 #define OWN_PROPERTY_ID_TABBINGMODEL 0x0013
58 //========================================================================
60 //========================================================================
61 typedef ::comphelper::OSimpleListenerContainer
< ::com::sun::star::beans::XPropertyChangeListener
62 , ::com::sun::star::beans::PropertyChangeEvent
63 > PropertyChangeListeners
;
65 //========================================================================
67 //========================================================================
68 // small helper to make the "swap" call on an STL container a single-line call, which
69 // in it's canonic form "aFoo.swap( Container() )" doesn't compile with GCC
70 template< class CONTAINER
>
71 void clearContainer( CONTAINER
& _rContainer
)
74 _rContainer
.swap( aEmpty
);
77 //========================================================================
79 //========================================================================
80 /// small helper to translate help ids into help urls
84 static SmartId
getHelpId( const ::rtl::OUString
& _rHelpURL
);
85 static ::rtl::OUString
getHelpURL( sal_uInt32 _nHelpId
);
88 //====================================================================
90 //====================================================================
91 template< class ELEMENT
>
92 class StlSyntaxSequence
: public ::com::sun::star::uno::Sequence
< ELEMENT
>
95 typedef ::com::sun::star::uno::Sequence
< ELEMENT
> UnoBase
;
98 inline StlSyntaxSequence() : UnoBase() { }
99 inline StlSyntaxSequence( const UnoBase
& rSeq
) : UnoBase( rSeq
) { }
100 inline StlSyntaxSequence( const ELEMENT
* pElements
, sal_Int32 len
) : UnoBase( pElements
, len
) { }
101 inline StlSyntaxSequence( sal_Int32 len
) : UnoBase( len
) { }
103 operator const UnoBase
&() const { return *this; }
104 operator UnoBase
&() { return *this; }
106 typedef const ELEMENT
* const_iterator
;
107 typedef ELEMENT
* iterator
;
109 inline const_iterator
begin() const { return UnoBase::getConstArray(); }
110 inline const_iterator
end() const { return UnoBase::getConstArray() + UnoBase::getLength(); }
112 inline iterator
begin() { return UnoBase::getArray(); }
113 inline iterator
end() { return UnoBase::getArray() + UnoBase::getLength(); }
115 inline sal_Int32
size() const { return UnoBase::getLength(); }
116 inline bool empty() const { return UnoBase::getLength() == 0; }
118 inline void resize( size_t _newSize
) { UnoBase::realloc( _newSize
); }
120 inline iterator
erase( iterator _pos
)
122 iterator loop
= end();
123 while ( --loop
!= _pos
)
124 *( loop
- 1 ) = *loop
;
125 resize( size() - 1 );
129 //========================================================================
131 //========================================================================
132 #define DECLARE_XCOMPONENT() \
133 virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); \
134 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); \
135 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
137 #define IMPLEMENT_FORWARD_XCOMPONENT( classname, baseclass ) \
138 void SAL_CALL classname::dispose( ) throw (::com::sun::star::uno::RuntimeException) \
140 baseclass::WeakComponentImplHelperBase::dispose(); \
142 void SAL_CALL classname::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
144 baseclass::WeakComponentImplHelperBase::addEventListener( _Listener ); \
146 void SAL_CALL classname::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
148 baseclass::WeakComponentImplHelperBase::removeEventListener( _Listener ); \
151 //............................................................................
153 //............................................................................
155 #endif // _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_