1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include "formcontroller.hxx"
21 #include "pcrcommon.hxx"
22 #include "formstrings.hxx"
23 #include "defaultforminspection.hxx"
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <com/sun/star/util/VetoException.hpp>
27 #include <cppuhelper/typeprovider.hxx>
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
;
53 namespace PropertyAttribute
= css::beans::PropertyAttribute
;
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
)
68 osl_atomic_increment( &m_refCount
);
70 Reference
< XObjectInspectorModel
> xModel(
71 *(new DefaultFormComponentInspectorModel( _bUseFormFormComponentHandlers
)),
74 setInspectorModel( xModel
);
76 osl_atomic_decrement( &m_refCount
);
80 FormController::~FormController()
85 IMPLEMENT_FORWARD_XINTERFACE2( FormController
, OPropertyBrowserController
, FormController_PropertyBase1
)
88 Sequence
< Type
> SAL_CALL
FormController::getTypes( )
90 ::cppu::OTypeCollection
aTypes(
91 cppu::UnoType
<XPropertySet
>::get(),
92 cppu::UnoType
<XMultiPropertySet
>::get(),
93 cppu::UnoType
<XFastPropertySet
>::get(),
94 OPropertyBrowserController::getTypes());
95 return aTypes
.getTypes();
99 IMPLEMENT_GET_IMPLEMENTATION_ID( FormController
)
102 OUString SAL_CALL
FormController::getImplementationName( )
104 return m_sImplementationName
;
108 Sequence
< OUString
> SAL_CALL
FormController::getSupportedServiceNames( )
110 Sequence
< OUString
> aSupported( m_aSupportedServiceNames
);
111 aSupported
.realloc( aSupported
.getLength() + 1 );
112 aSupported
.getArray()[ aSupported
.getLength() - 1 ] = "com.sun.star.inspection.ObjectInspector";
117 Reference
< XPropertySetInfo
> SAL_CALL
FormController::getPropertySetInfo( )
119 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
123 ::cppu::IPropertyArrayHelper
& SAL_CALL
FormController::getInfoHelper()
125 return *getArrayHelper();
129 ::cppu::IPropertyArrayHelper
* FormController::createArrayHelper( ) const
131 Sequence
< Property
> aProps
{
133 PROPERTY_CURRENTPAGE
,
134 OWN_PROPERTY_ID_CURRENTPAGE
,
135 ::cppu::UnoType
<OUString
>::get(),
136 PropertyAttribute::TRANSIENT
139 PROPERTY_INTROSPECTEDOBJECT
,
140 OWN_PROPERTY_ID_INTROSPECTEDOBJECT
,
141 cppu::UnoType
<XPropertySet
>::get(),
142 PropertyAttribute::TRANSIENT
| PropertyAttribute::CONSTRAINED
145 return new ::cppu::OPropertyArrayHelper( aProps
);
149 sal_Bool SAL_CALL
FormController::convertFastPropertyValue( Any
& rConvertedValue
, Any
& rOldValue
, sal_Int32 nHandle
, const Any
& rValue
)
153 case OWN_PROPERTY_ID_INTROSPECTEDOBJECT
:
154 if ( rValue
.getValueTypeClass() != TypeClass_INTERFACE
)
155 throw IllegalArgumentException();
157 case OWN_PROPERTY_ID_CURRENTPAGE
:
158 if ( rValue
.getValueTypeClass() != TypeClass_STRING
)
159 throw IllegalArgumentException();
163 getFastPropertyValue( rOldValue
, nHandle
);
164 rConvertedValue
= rValue
;
169 void SAL_CALL
FormController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle
, const Any
& _rValue
)
173 case OWN_PROPERTY_ID_INTROSPECTEDOBJECT
:
175 Reference
< XObjectInspectorModel
> xModel( getInspectorModel() );
180 m_xCurrentInspectee
.set( _rValue
, UNO_QUERY
);
181 Sequence
< Reference
< XInterface
> > aObjects
;
182 if ( m_xCurrentInspectee
.is() )
184 aObjects
= { m_xCurrentInspectee
};
187 Reference
< XObjectInspector
> xInspector( *this, UNO_QUERY_THROW
);
188 xInspector
->inspect( aObjects
);
190 catch( const VetoException
& e
)
192 throw PropertyVetoException( e
.Message
, e
.Context
);
197 case OWN_PROPERTY_ID_CURRENTPAGE
:
198 restoreViewData( _rValue
);
204 void SAL_CALL
FormController::getFastPropertyValue( css::uno::Any
& rValue
, sal_Int32 nHandle
) const
208 case OWN_PROPERTY_ID_INTROSPECTEDOBJECT
:
209 rValue
<<= m_xCurrentInspectee
;
212 case OWN_PROPERTY_ID_CURRENTPAGE
:
213 rValue
= const_cast< FormController
* >( this )->getViewData();
222 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
223 extensions_propctrlr_FormController_get_implementation(
224 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
226 return cppu::acquire(new pcr::FormController( context
,
227 "org.openoffice.comp.extensions.FormController",
228 { "com.sun.star.form.PropertyBrowserController" },
232 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
233 extensions_propctrlr_DialogController_get_implementation(
234 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
236 return cppu::acquire(new pcr::FormController( context
,
237 "org.openoffice.comp.extensions.DialogController",
238 { "com.sun.star.awt.PropertyBrowserController" },
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */