LibreOffice Module extensions (master) 1
formcontroller.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 "formcontroller.hxx"
21#include "pcrcommon.hxx"
22#include "formstrings.hxx"
24
25#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <com/sun/star/util/VetoException.hpp>
28#include <utility>
29
30
31namespace pcr
32{
33
34
35 using ::com::sun::star::uno::Reference;
36 using ::com::sun::star::uno::TypeClass_INTERFACE;
37 using ::com::sun::star::uno::TypeClass_STRING;
38 using ::com::sun::star::uno::XComponentContext;
39 using ::com::sun::star::inspection::XObjectInspectorModel;
40 using ::com::sun::star::uno::UNO_QUERY_THROW;
41 using ::com::sun::star::uno::Sequence;
42 using ::com::sun::star::uno::XInterface;
43 using ::com::sun::star::beans::XPropertySetInfo;
44 using ::com::sun::star::beans::XPropertySet;
45 using ::com::sun::star::beans::Property;
46 using ::com::sun::star::uno::Any;
47 using ::com::sun::star::lang::IllegalArgumentException;
48 using ::com::sun::star::uno::Type;
49 using ::com::sun::star::util::VetoException;
50 using ::com::sun::star::beans::PropertyVetoException;
51 using ::com::sun::star::uno::UNO_QUERY;
52
53 namespace PropertyAttribute = css::beans::PropertyAttribute;
54
55
56 //= FormController
57
58
59 FormController::FormController( const Reference< XComponentContext >& _rxContext,
60 OUString sImplementationName,
61 const css::uno::Sequence<OUString>& aSupportedServiceNames,
62 bool _bUseFormFormComponentHandlers )
63 :OPropertyBrowserController( _rxContext )
64 ,FormController_PropertyBase1( m_aBHelper )
65 ,m_sImplementationName(std::move( sImplementationName ))
66 ,m_aSupportedServiceNames( aSupportedServiceNames )
67 {
68 osl_atomic_increment( &m_refCount );
69 {
70 Reference< XObjectInspectorModel > xModel(
71 *(new DefaultFormComponentInspectorModel( _bUseFormFormComponentHandlers )),
72 UNO_QUERY_THROW
73 );
74 setInspectorModel( xModel );
75 }
76 osl_atomic_decrement( &m_refCount );
77 }
78
79
80 FormController::~FormController()
81 {
82 }
83
84
86
87
88 Sequence< Type > SAL_CALL FormController::getTypes( )
89 {
94 OPropertyBrowserController::getTypes());
95 return aTypes.getTypes();
96 }
97
98
99 IMPLEMENT_GET_IMPLEMENTATION_ID( FormController )
100
101
102 OUString SAL_CALL FormController::getImplementationName( )
103 {
104 return m_sImplementationName;
105 }
106
107
108 Sequence< OUString > SAL_CALL FormController::getSupportedServiceNames( )
109 {
110 Sequence< OUString > aSupported( m_aSupportedServiceNames );
111 aSupported.realloc( aSupported.getLength() + 1 );
112 aSupported.getArray()[ aSupported.getLength() - 1 ] = "com.sun.star.inspection.ObjectInspector";
113 return aSupported;
114 }
115
116
117 Reference< XPropertySetInfo > SAL_CALL FormController::getPropertySetInfo( )
118 {
119 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
120 }
121
122
123 ::cppu::IPropertyArrayHelper& SAL_CALL FormController::getInfoHelper()
124 {
125 return *getArrayHelper();
126 }
127
128
129 ::cppu::IPropertyArrayHelper* FormController::createArrayHelper( ) const
130 {
131 Sequence< Property > aProps{
132 Property(
134 static_cast<sal_Int32>(OwnPropertyId::CURRENTPAGE),
136 PropertyAttribute::TRANSIENT
137 ),
138 Property(
140 static_cast<sal_Int32>(OwnPropertyId::INTROSPECTEDOBJECT),
142 PropertyAttribute::TRANSIENT | PropertyAttribute::CONSTRAINED
143 )
144 };
145 return new ::cppu::OPropertyArrayHelper( aProps );
146 }
147
148
149 sal_Bool SAL_CALL FormController::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue )
150 {
151 switch ( static_cast<OwnPropertyId>(nHandle) )
152 {
153 case OwnPropertyId::INTROSPECTEDOBJECT:
154 if ( rValue.getValueTypeClass() != TypeClass_INTERFACE )
155 throw IllegalArgumentException();
156 break;
157 case OwnPropertyId::CURRENTPAGE:
158 if ( rValue.getValueTypeClass() != TypeClass_STRING )
159 throw IllegalArgumentException();
160 break;
161 default:
162 break;
163 }
164
165 getFastPropertyValue( rOldValue, nHandle );
166 rConvertedValue = rValue;
167 return true;
168 }
169
170
171 void SAL_CALL FormController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue)
172 {
173 switch ( static_cast<OwnPropertyId>(_nHandle) )
174 {
175 case OwnPropertyId::INTROSPECTEDOBJECT:
176 {
177 Reference< XObjectInspectorModel > xModel( getInspectorModel() );
178 if ( xModel.is() )
179 {
180 try
181 {
182 m_xCurrentInspectee.set( _rValue, UNO_QUERY );
183 Sequence< Reference< XInterface > > aObjects;
184 if ( m_xCurrentInspectee.is() )
185 {
186 aObjects = { m_xCurrentInspectee };
187 }
188
189 Reference< XObjectInspector > xInspector( *this, UNO_QUERY_THROW );
190 xInspector->inspect( aObjects );
191 }
192 catch( const VetoException& e )
193 {
194 throw PropertyVetoException( e.Message, e.Context );
195 }
196 }
197 }
198 break;
199 case OwnPropertyId::CURRENTPAGE:
200 restoreViewData( _rValue );
201 break;
202 default:
203 break;
204 }
205 }
206
207
208 void SAL_CALL FormController::getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const
209 {
210 switch ( static_cast<OwnPropertyId>(nHandle) )
211 {
212 case OwnPropertyId::INTROSPECTEDOBJECT:
213 rValue <<= m_xCurrentInspectee;
214 break;
215
216 case OwnPropertyId::CURRENTPAGE:
217 rValue = const_cast< FormController* >( this )->getViewData();
218 break;
219 default:
220 break;
221 }
222 }
223
224
225
226} // namespace pcr
227
228extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
230 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
231{
232 return cppu::acquire(new pcr::FormController( context,
233 "org.openoffice.comp.extensions.FormController",
234 { "com.sun.star.form.PropertyBrowserController" },
235 true ) );
236}
237
238extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
240 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
241{
242 return cppu::acquire(new pcr::FormController( context,
243 "org.openoffice.comp.extensions.DialogController",
244 { "com.sun.star.awt.PropertyBrowserController" },
245 false ) );
246}
247
248/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral sImplementationName
Legacy implementation of com.sun.star.form.PropertyBrowserController.
FormController(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, OUString sImplementName, const css::uno::Sequence< OUString > &aSupportedServiceNames, bool _bUseFormFormComponentHandlers)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * extensions_propctrlr_FormController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * extensions_propctrlr_DialogController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral PROPERTY_INTROSPECTEDOBJECT
Definition: formstrings.hxx:25
constexpr OUStringLiteral PROPERTY_CURRENTPAGE
Definition: formstrings.hxx:26
a property handler for any virtual string properties
Definition: browserline.cxx:39
::cppu::OPropertySetHelper FormController_PropertyBase1
OwnPropertyId
Definition: pcrcommon.hxx:35
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController)
sal_Int32 nHandle
Reference< XModel > xModel
unsigned char sal_Bool
const SvXMLTokenMapEntry aTypes[]