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