xref: /AOO41X/main/toolkit/inc/toolkit/controls/stdtabcontrollermodel.hxx (revision 50e6b0721ed882c1c74690abd9bee6b3a8da8cfd)
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 _TOOLKIT_CONTROLS_STDTABCONTROLLERMODEL_HXX_
25 #define _TOOLKIT_CONTROLS_STDTABCONTROLLERMODEL_HXX_
26 
27 
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/io/XPersistObject.hpp>
30 #include <com/sun/star/awt/XTabControllerModel.hpp>
31 #include <com/sun/star/awt/XWindow.hpp>
32 #include <com/sun/star/lang/XTypeProvider.hpp>
33 #include <com/sun/star/lang/XUnoTunnel.hpp>
34 #include <cppuhelper/weakagg.hxx>
35 #include <toolkit/helper/macros.hxx>
36 #include <toolkit/helper/servicenames.hxx>
37 #include <osl/mutex.hxx>
38 
39 #include <tools/list.hxx>
40 #include <tools/gen.hxx>
41 
42 struct UnoControlModelEntry;
43 
44 DECLARE_LIST( UnoControlModelEntryListBase, UnoControlModelEntry* )
45 
46 class UnoControlModelEntryList : public UnoControlModelEntryListBase
47 {
48 private:
49     ::rtl::OUString maGroupName;
50 
51 public:
52                     UnoControlModelEntryList();
53                     ~UnoControlModelEntryList();
54 
GetName() const55     const ::rtl::OUString&      GetName() const                         { return maGroupName; }
SetName(const::rtl::OUString & rName)56     void                        SetName( const ::rtl::OUString& rName ) { maGroupName = rName; }
57 
58     void    Reset();
59     void    DestroyEntry( sal_uInt32 nEntry );
60 };
61 
62 struct UnoControlModelEntry
63 {
64     sal_Bool        bGroup;
65     union
66     {
67         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >* pxControl;
68         UnoControlModelEntryList*   pGroup;
69     };
70 };
71 
72 // Keine Referenz halten, nur temporaer fuer AutoTabOrder
73 struct ComponentEntry
74 {
75     ::com::sun::star::awt::XWindow*     pComponent;
76     Point                               aPos;
77 };
78 
79 DECLARE_LIST( ComponentEntryList, ComponentEntry* )
80 
81 #define CONTROLPOS_NOTFOUND 0xFFFFFFFF
82 
83 class StdTabControllerModel :   public ::com::sun::star::awt::XTabControllerModel,
84                                 public ::com::sun::star::lang::XServiceInfo,
85                                 public ::com::sun::star::io::XPersistObject,
86                                 public ::com::sun::star::lang::XTypeProvider,
87                                 public ::cppu::OWeakAggObject
88 {
89 private:
90     ::osl::Mutex                maMutex;
91     UnoControlModelEntryList    maControls;
92     sal_Bool                    mbGroupControl;
93 
94 protected:
GetMutex()95     ::osl::Mutex&           GetMutex() { return maMutex; }
96     sal_uInt32              ImplGetControlCount( const UnoControlModelEntryList& rList ) const;
97     void                    ImplGetControlModels( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > ** pRefs, const UnoControlModelEntryList& rList ) const;
98     void                    ImplSetControlModels( UnoControlModelEntryList& rList, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) const;
99     sal_uInt32              ImplGetControlPos( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >  xCtrl, const UnoControlModelEntryList& rList ) const;
100 
101 public:
102                             StdTabControllerModel();
103                             ~StdTabControllerModel();
104 
105     // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)106     ::com::sun::star::uno::Any  SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return OWeakAggObject::queryInterface(rType); }
acquire()107     void                        SAL_CALL acquire() throw()  { OWeakAggObject::acquire(); }
release()108     void                        SAL_CALL release() throw()  { OWeakAggObject::release(); }
109 
110     ::com::sun::star::uno::Any  SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
111 
112     // ::com::sun::star::lang::XTypeProvider
113     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >  SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
114     ::com::sun::star::uno::Sequence< sal_Int8 >                     SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
115 
116     // ::com::sun::star::awt::XTabControllerModel
117     sal_Bool SAL_CALL getGroupControl(  ) throw(::com::sun::star::uno::RuntimeException);
118     void SAL_CALL setGroupControl( sal_Bool GroupControl ) throw(::com::sun::star::uno::RuntimeException);
119     void SAL_CALL setControlModels( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) throw(::com::sun::star::uno::RuntimeException);
120     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL getControlModels(  ) throw(::com::sun::star::uno::RuntimeException);
121     void SAL_CALL setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, const ::rtl::OUString& GroupName ) throw(::com::sun::star::uno::RuntimeException);
122     sal_Int32 SAL_CALL getGroupCount(  ) throw(::com::sun::star::uno::RuntimeException);
123     void SAL_CALL getGroup( sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, ::rtl::OUString& Name ) throw(::com::sun::star::uno::RuntimeException);
124     void SAL_CALL getGroupByName( const ::rtl::OUString& Name, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group ) throw(::com::sun::star::uno::RuntimeException);
125 
126     // ::com::sun::star::io::XPersistObject
127     ::rtl::OUString SAL_CALL getServiceName(  ) throw(::com::sun::star::uno::RuntimeException);
128     void SAL_CALL write( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& OutStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
129     void SAL_CALL read( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& InStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
130 
131     // XServiceInfo
132     DECLIMPL_SERVICEINFO( StdTabControllerModel, szServiceName2_TabControllerModel )
133 };
134 
135 
136 
137 #endif // _TOOLKIT_HELPER_STDTABCONTROLLERMODEL_HXX_
138 
139