Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PCRCOMMON_HXX
21 : #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PCRCOMMON_HXX
22 :
23 : #define EDITOR_LIST_APPEND (SAL_MAX_UINT16)
24 : #define EDITOR_LIST_REPLACE_EXISTING (SAL_MAX_UINT16)
25 : #define EDITOR_LIST_ENTRY_NOTFOUND (SAL_MAX_UINT16)
26 :
27 : #include <com/sun/star/uno/Sequence.hxx>
28 : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
29 : #include <com/sun/star/beans/PropertyChangeEvent.hpp>
30 :
31 : #include <toolkit/helper/vclunohelper.hxx>
32 : #include <comphelper/listenernotification.hxx>
33 :
34 :
35 : namespace pcr
36 : {
37 :
38 :
39 : #define OWN_PROPERTY_ID_INTROSPECTEDOBJECT 0x0010
40 : #define OWN_PROPERTY_ID_CURRENTPAGE 0x0011
41 : #define OWN_PROPERTY_ID_CONTROLCONTEXT 0x0012
42 : #define OWN_PROPERTY_ID_TABBINGMODEL 0x0013
43 :
44 :
45 : //= types
46 :
47 : typedef ::comphelper::OSimpleListenerContainer < ::com::sun::star::beans::XPropertyChangeListener
48 : , ::com::sun::star::beans::PropertyChangeEvent
49 : > PropertyChangeListeners;
50 :
51 :
52 : //= helper
53 :
54 : // small helper to make the "swap" call on an STL container a single-line call, which
55 : // in it's canonic form "aFoo.swap( Container() )" doesn't compile with GCC
56 : template< class CONTAINER >
57 50 : void clearContainer( CONTAINER& _rContainer )
58 : {
59 50 : CONTAINER aEmpty;
60 50 : _rContainer.swap( aEmpty );
61 50 : }
62 :
63 :
64 : //= HelpIdUrl
65 :
66 : /// small helper to translate help ids into help urls
67 : class HelpIdUrl
68 : {
69 : public:
70 : static OString getHelpId( const OUString& _rHelpURL );
71 : static OUString getHelpURL( const OString& );
72 : };
73 :
74 :
75 : //= StlSyntaxSequence
76 :
77 : template< class ELEMENT >
78 25 : class StlSyntaxSequence : public ::com::sun::star::uno::Sequence< ELEMENT >
79 : {
80 : private:
81 : typedef ::com::sun::star::uno::Sequence< ELEMENT > UnoBase;
82 :
83 : public:
84 12 : inline StlSyntaxSequence() : UnoBase() { }
85 11 : inline StlSyntaxSequence( const UnoBase& rSeq ) : UnoBase( rSeq ) { }
86 : inline StlSyntaxSequence( const ELEMENT* pElements, sal_Int32 len ) : UnoBase( pElements, len ) { }
87 0 : inline StlSyntaxSequence( sal_Int32 len ) : UnoBase( len ) { }
88 :
89 : operator const UnoBase&() const { return *this; }
90 : operator UnoBase&() { return *this; }
91 :
92 : typedef const ELEMENT* const_iterator;
93 : typedef ELEMENT* iterator;
94 :
95 0 : inline const_iterator begin() const { return UnoBase::getConstArray(); }
96 0 : inline const_iterator end() const { return UnoBase::getConstArray() + UnoBase::getLength(); }
97 :
98 2 : inline iterator begin() { return UnoBase::getArray(); }
99 2 : inline iterator end() { return UnoBase::getArray() + UnoBase::getLength(); }
100 :
101 0 : inline sal_Int32 size() const { return UnoBase::getLength(); }
102 9 : inline bool empty() const { return UnoBase::getLength() == 0; }
103 :
104 : inline void resize( size_t _newSize ) { UnoBase::realloc( _newSize ); }
105 :
106 : inline iterator erase( iterator _pos )
107 : {
108 : iterator loop = end();
109 : while ( --loop != _pos )
110 : *( loop - 1 ) = *loop;
111 : resize( size() - 1 );
112 : }
113 : };
114 :
115 :
116 : //= UNO helpers
117 :
118 : #define DECLARE_XCOMPONENT() \
119 : virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; \
120 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; \
121 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 :
123 : #define IMPLEMENT_FORWARD_XCOMPONENT( classname, baseclass ) \
124 : void SAL_CALL classname::dispose( ) throw (::com::sun::star::uno::RuntimeException, std::exception) \
125 : { \
126 : baseclass::WeakComponentImplHelperBase::dispose(); \
127 : } \
128 : void SAL_CALL classname::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) \
129 : { \
130 : baseclass::WeakComponentImplHelperBase::addEventListener( _Listener ); \
131 : } \
132 : void SAL_CALL classname::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) \
133 : { \
134 : baseclass::WeakComponentImplHelperBase::removeEventListener( _Listener ); \
135 : } \
136 :
137 :
138 : } // namespace pcr
139 :
140 :
141 : #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PCRCOMMON_HXX
142 :
143 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|