Branch libreoffice-5-0-4
[LibreOffice.git] / include / toolkit / controls / stdtabcontrollermodel.hxx
blob3552c15a65691a2dddad4ba670ac14ff3336887a
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 INCLUDED_TOOLKIT_CONTROLS_STDTABCONTROLLERMODEL_HXX
21 #define INCLUDED_TOOLKIT_CONTROLS_STDTABCONTROLLERMODEL_HXX
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>
35 #include <tools/gen.hxx>
36 #include <vector>
38 struct UnoControlModelEntry;
39 typedef ::std::vector< UnoControlModelEntry* > UnoControlModelEntryListBase;
41 class UnoControlModelEntryList
43 private:
44 UnoControlModelEntryListBase maList;
45 OUString maGroupName;
47 public:
48 UnoControlModelEntryList();
49 ~UnoControlModelEntryList();
51 const OUString& GetName() const { return maGroupName; }
52 void SetName( const OUString& rName ) { maGroupName = rName; }
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 );
62 struct UnoControlModelEntry
64 bool bGroup;
65 union
67 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >* pxControl;
68 UnoControlModelEntryList* pGroup;
72 struct ComponentEntry
74 ::com::sun::star::awt::XWindow* pComponent;
75 Point aPos;
78 typedef ::std::vector< ComponentEntry* > ComponentEntryList;
80 #define CONTROLPOS_NOTFOUND 0xFFFFFFFF
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
88 private:
89 ::osl::Mutex maMutex;
90 UnoControlModelEntryList maControls;
91 bool mbGroupControl;
93 protected:
94 ::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 static void ImplSetControlModels( UnoControlModelEntryList& rList, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls );
98 static sal_uInt32 ImplGetControlPos( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rCtrl, const UnoControlModelEntryList& rList );
100 public:
101 StdTabControllerModel();
102 virtual ~StdTabControllerModel();
104 // ::com::sun::star::uno::XInterface
105 ::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 void SAL_CALL acquire() throw() SAL_OVERRIDE { OWeakAggObject::acquire(); }
107 void SAL_CALL release() throw() SAL_OVERRIDE { OWeakAggObject::release(); }
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;
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;
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;
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;
130 // XServiceInfo
131 OUString SAL_CALL getImplementationName()
132 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
135 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
137 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
138 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 #endif // _TOOLKIT_HELPER_STDTABCONTROLLERMODEL_HXX_
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */