bump product version to 4.1.6.2
[LibreOffice.git] / extensions / source / propctrlr / pcrcommon.hxx
blobe3216ad295ec14235c19a172e18cfa9925a6850d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
21 #define _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
23 #define EDITOR_LIST_APPEND (sal_uInt16)-1
24 #define EDITOR_LIST_REPLACE_EXISTING (sal_uInt16)-1
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
28 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
30 #include <toolkit/helper/vclunohelper.hxx>
31 #include <comphelper/listenernotification.hxx>
33 //............................................................................
34 namespace pcr
36 //............................................................................
38 #define OWN_PROPERTY_ID_INTROSPECTEDOBJECT 0x0010
39 #define OWN_PROPERTY_ID_CURRENTPAGE 0x0011
40 #define OWN_PROPERTY_ID_CONTROLCONTEXT 0x0012
41 #define OWN_PROPERTY_ID_TABBINGMODEL 0x0013
43 //========================================================================
44 //= types
45 //========================================================================
46 typedef ::comphelper::OSimpleListenerContainer < ::com::sun::star::beans::XPropertyChangeListener
47 , ::com::sun::star::beans::PropertyChangeEvent
48 > PropertyChangeListeners;
50 //========================================================================
51 //= helper
52 //========================================================================
53 // small helper to make the "swap" call on an STL container a single-line call, which
54 // in it's canonic form "aFoo.swap( Container() )" doesn't compile with GCC
55 template< class CONTAINER >
56 void clearContainer( CONTAINER& _rContainer )
58 CONTAINER aEmpty;
59 _rContainer.swap( aEmpty );
62 //========================================================================
63 //= HelpIdUrl
64 //========================================================================
65 /// small helper to translate help ids into help urls
66 class HelpIdUrl
68 public:
69 static OString getHelpId( const OUString& _rHelpURL );
70 static OUString getHelpURL( const OString& );
73 //====================================================================
74 //= StlSyntaxSequence
75 //====================================================================
76 template< class ELEMENT >
77 class StlSyntaxSequence : public ::com::sun::star::uno::Sequence< ELEMENT >
79 private:
80 typedef ::com::sun::star::uno::Sequence< ELEMENT > UnoBase;
82 public:
83 inline StlSyntaxSequence() : UnoBase() { }
84 inline StlSyntaxSequence( const UnoBase& rSeq ) : UnoBase( rSeq ) { }
85 inline StlSyntaxSequence( const ELEMENT* pElements, sal_Int32 len ) : UnoBase( pElements, len ) { }
86 inline StlSyntaxSequence( sal_Int32 len ) : UnoBase( len ) { }
88 operator const UnoBase&() const { return *this; }
89 operator UnoBase&() { return *this; }
91 typedef const ELEMENT* const_iterator;
92 typedef ELEMENT* iterator;
94 inline const_iterator begin() const { return UnoBase::getConstArray(); }
95 inline const_iterator end() const { return UnoBase::getConstArray() + UnoBase::getLength(); }
97 inline iterator begin() { return UnoBase::getArray(); }
98 inline iterator end() { return UnoBase::getArray() + UnoBase::getLength(); }
100 inline sal_Int32 size() const { return UnoBase::getLength(); }
101 inline bool empty() const { return UnoBase::getLength() == 0; }
103 inline void resize( size_t _newSize ) { UnoBase::realloc( _newSize ); }
105 inline iterator erase( iterator _pos )
107 iterator loop = end();
108 while ( --loop != _pos )
109 *( loop - 1 ) = *loop;
110 resize( size() - 1 );
114 //========================================================================
115 //= UNO helpers
116 //========================================================================
117 #define DECLARE_XCOMPONENT() \
118 virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); \
119 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); \
120 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
122 #define IMPLEMENT_FORWARD_XCOMPONENT( classname, baseclass ) \
123 void SAL_CALL classname::dispose( ) throw (::com::sun::star::uno::RuntimeException) \
125 baseclass::WeakComponentImplHelperBase::dispose(); \
127 void SAL_CALL classname::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
129 baseclass::WeakComponentImplHelperBase::addEventListener( _Listener ); \
131 void SAL_CALL classname::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
133 baseclass::WeakComponentImplHelperBase::removeEventListener( _Listener ); \
136 //............................................................................
137 } // namespace pcr
138 //............................................................................
140 #endif // _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */