LibreOffice Module extensions (master) 1
inspectormodelbase.cxx
Go to the documentation of this file.
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#include <memory>
22
23#include <com/sun/star/beans/PropertyAttribute.hpp>
24
27
28
29namespace pcr
30{
31 namespace
32 {
33 enum class ModelPropertyId
34 {
35 HAS_HELP_SECTION = 2000,
36 MIN_HELP_TEXT_LINES = 2001,
37 MAX_HELP_TEXT_LINES = 2002,
38 IS_READ_ONLY = 2003
39 };
40 };
41 using ::com::sun::star::uno::Reference;
42 using ::com::sun::star::beans::XPropertySetInfo;
43 using ::com::sun::star::uno::Any;
44 using ::com::sun::star::uno::Sequence;
45 using ::com::sun::star::beans::Property;
46
47 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
48
49
50 //= InspectorModelProperties
51
56 {
57 private:
58 ::osl::Mutex& m_rMutex;
63 std::unique_ptr< ::cppu::IPropertyArrayHelper >
65
66 public:
67 explicit InspectorModelProperties( ::osl::Mutex& _rMutex );
68
69 using ::comphelper::OPropertyContainerHelper::convertFastPropertyValue;
70 using ::comphelper::OPropertyContainerHelper::setFastPropertyValue;
71 using ::comphelper::OPropertyContainerHelper::getFastPropertyValue;
72
73 public:
74 bool hasHelpSection() const { return m_bHasHelpSection; }
75 bool isReadOnly() const { return m_bIsReadOnly; }
76 sal_Int32 getMinHelpTextLines() const { return m_nMinHelpTextLines; }
77 sal_Int32 getMaxHelpTextLines() const { return m_nMaxHelpTextLines; }
78
79 css::uno::Reference< css::beans::XPropertySetInfo >
83
84 void constructWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
85 };
86
87
88 //= InspectorModelProperties
89
90
92 :m_rMutex( _rMutex )
93 ,m_bHasHelpSection( false )
94 ,m_nMinHelpTextLines( 3 )
95 ,m_nMaxHelpTextLines( 8 )
96 ,m_bIsReadOnly( false )
97 {
99 "HasHelpSection",
100 static_cast<sal_Int32>(ModelPropertyId::HAS_HELP_SECTION),
101 PropertyAttribute::READONLY,
103 );
105 "MinHelpTextLines",
106 static_cast<sal_Int32>(ModelPropertyId::MIN_HELP_TEXT_LINES),
107 PropertyAttribute::READONLY,
109 );
111 "MaxHelpTextLines",
112 static_cast<sal_Int32>(ModelPropertyId::MAX_HELP_TEXT_LINES),
113 PropertyAttribute::READONLY,
115 );
117 "IsReadOnly",
118 static_cast<sal_Int32>(ModelPropertyId::IS_READ_ONLY),
119 PropertyAttribute::BOUND,
120 &m_bIsReadOnly, cppu::UnoType<decltype(m_bIsReadOnly)>::get()
121 );
122 }
123
124
125 void InspectorModelProperties::constructWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
126 {
127 m_bHasHelpSection = true;
128 m_nMinHelpTextLines = _nMinHelpTextLines;
129 m_nMaxHelpTextLines = _nMaxHelpTextLines;
130 // no need to notify this, those properties are not bound. Also, the method should
131 // only be used during construction phase, where we don't expect to have any listeners.
132 }
133
134
136 {
137 ::osl::MutexGuard aGuard( m_rMutex );
138 if (m_pPropertyInfo == nullptr)
139 {
140 Sequence< Property > aProperties;
142
143 m_pPropertyInfo.reset( new ::cppu::OPropertyArrayHelper( aProperties ) );
144 }
145 return *m_pPropertyInfo;
146 }
147
148
149 Reference< XPropertySetInfo > InspectorModelProperties::getPropertySetInfo()
150 {
151 return ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() );
152 }
153
154
155 //= ImplInspectorModel
156
158 :ImplInspectorModel_PBase( GetBroadcastHelper() )
159 ,m_pProperties( new InspectorModelProperties( m_aMutex ) )
160 {
161 }
162
163
165 {
166 }
167
168
170
171
173
174
175 Reference< XPropertySetInfo > SAL_CALL ImplInspectorModel::getPropertySetInfo( )
176 {
177 return m_pProperties->getPropertySetInfo();
178 }
179
180
182 {
183 return m_pProperties->getInfoHelper();
184 }
185
186
187 sal_Bool SAL_CALL ImplInspectorModel::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue )
188 {
189 return m_pProperties->convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
190 }
191
192
193 void SAL_CALL ImplInspectorModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue )
194 {
195 m_pProperties->setFastPropertyValue( nHandle, rValue );
196 }
197
198
199 void SAL_CALL ImplInspectorModel::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
200 {
201 m_pProperties->getFastPropertyValue( rValue, nHandle );
202 }
203
204
206 {
207 return m_pProperties->hasHelpSection();
208 }
209
210
212 {
213 return m_pProperties->getMinHelpTextLines();
214 }
215
216
218 {
219 return m_pProperties->getMaxHelpTextLines();
220 }
221
222
224 {
225 return m_pProperties->isReadOnly();
226 }
227
228
229 void SAL_CALL ImplInspectorModel::setIsReadOnly( sal_Bool IsReadOnly )
230 {
231 setFastPropertyValue( static_cast<sal_Int32>(ModelPropertyId::IS_READ_ONLY), Any( IsReadOnly ) );
232 }
233
234 sal_Bool SAL_CALL ImplInspectorModel::supportsService( const OUString& ServiceName )
235 {
237 }
238
239
240 void ImplInspectorModel::enableHelpSectionProperties( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
241 {
242 m_pProperties->constructWithHelpSection( _nMinHelpTextLines, _nMaxHelpTextLines );
243 }
244
245
246} // namespace pcr
247
248
249/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const css::uno::Any &rValue) SAL_OVERRIDE
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual ::sal_Int32 SAL_CALL getMinHelpTextLines() override
virtual ~ImplInspectorModel() override
virtual ::sal_Int32 SAL_CALL getMaxHelpTextLines() override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual void SAL_CALL setIsReadOnly(sal_Bool IsReadOnly) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
std::unique_ptr< InspectorModelProperties > m_pProperties
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
void enableHelpSectionProperties(sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines)
virtual sal_Bool SAL_CALL getHasHelpSection() override
virtual sal_Bool SAL_CALL getIsReadOnly() override
helper class for implementing the property set related functionality of an ImplInspectorModel
InspectorModelProperties(::osl::Mutex &_rMutex)
void constructWithHelpSection(sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines)
::cppu::IPropertyArrayHelper & getInfoHelper()
css::uno::Reference< css::beans::XPropertySetInfo > getPropertySetInfo()
std::unique_ptr< ::cppu::IPropertyArrayHelper > m_pPropertyInfo
::osl::Mutex & m_rMutex
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
::osl::Mutex m_aMutex
Definition: logger.cxx:98
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
a property handler for any virtual string properties
Definition: browserline.cxx:39
::cppu::WeakImplHelper< css::inspection::XObjectInspectorModel, css::lang::XInitialization, css::lang::XServiceInfo > ImplInspectorModel_Base
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
sal_Int32 nHandle
unsigned char sal_Bool