1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "formcontroller.hxx"
30 #include "pcrcommon.hxx"
31 #include "formstrings.hxx"
32 #include "defaultforminspection.hxx"
33 #include "propctrlr.hrc"
35 /** === begin UNO includes === **/
36 #include <com/sun/star/beans/PropertyAttribute.hpp>
37 #include <com/sun/star/form/XGridColumnFactory.hpp>
38 #include <com/sun/star/form/XForm.hpp>
39 #include <com/sun/star/container/XChild.hpp>
40 /** === end UNO includes === **/
41 #include <cppuhelper/typeprovider.hxx>
42 #include <toolkit/helper/vclunohelper.hxx>
44 //------------------------------------------------------------------------
45 extern "C" void SAL_CALL
createRegistryInfo_FormController()
47 ::pcr::OAutoRegistration
< ::pcr::FormController
> aFormControllerRegistration
;
48 ::pcr::OAutoRegistration
< ::pcr::DialogController
> aDialogControllerRegistration
;
51 //........................................................................
54 //........................................................................
56 /** === begin UNO using === **/
57 using ::com::sun::star::uno::Reference
;
58 using ::com::sun::star::uno::TypeClass_INTERFACE
;
59 using ::com::sun::star::uno::TypeClass_STRING
;
60 using ::com::sun::star::uno::XComponentContext
;
61 using ::com::sun::star::inspection::XObjectInspectorModel
;
62 using ::com::sun::star::uno::RuntimeException
;
63 using ::com::sun::star::uno::UNO_QUERY_THROW
;
64 using ::com::sun::star::uno::Sequence
;
65 using ::com::sun::star::uno::XInterface
;
66 using ::com::sun::star::beans::XPropertySetInfo
;
67 using ::com::sun::star::beans::XPropertySet
;
68 using ::com::sun::star::beans::Property
;
69 using ::com::sun::star::uno::Any
;
70 using ::com::sun::star::lang::IllegalArgumentException
;
71 using ::com::sun::star::uno::Exception
;
72 using ::com::sun::star::uno::Type
;
73 using ::com::sun::star::util::VetoException
;
74 using ::com::sun::star::beans::PropertyVetoException
;
75 using ::com::sun::star::uno::UNO_QUERY
;
76 using ::com::sun::star::form::XGridColumnFactory
;
77 using ::com::sun::star::form::XForm
;
78 using ::com::sun::star::container::XChild
;
79 using ::com::sun::star::frame::XFrame
;
80 using ::com::sun::star::awt::XWindow
;
81 /** === end UNO using === **/
83 namespace PropertyAttribute
= ::com::sun::star::beans::PropertyAttribute
;
85 //====================================================================
87 //====================================================================
88 //--------------------------------------------------------------------
89 FormController::FormController( const Reference
< XComponentContext
>& _rxContext
, ServiceDescriptor _aServiceDescriptor
,
90 bool _bUseFormFormComponentHandlers
)
91 :OPropertyBrowserController( _rxContext
)
92 ,FormController_PropertyBase1( m_aBHelper
)
93 ,m_aServiceDescriptor( _aServiceDescriptor
)
95 osl_incrementInterlockedCount( &m_refCount
);
97 Reference
< XObjectInspectorModel
> xModel(
98 *(new DefaultFormComponentInspectorModel( _rxContext
, _bUseFormFormComponentHandlers
)),
101 setInspectorModel( xModel
);
103 osl_decrementInterlockedCount( &m_refCount
);
106 //------------------------------------------------------------------------
107 FormController::~FormController()
111 //------------------------------------------------------------------------
112 IMPLEMENT_FORWARD_XINTERFACE2( FormController
, OPropertyBrowserController
, FormController_PropertyBase1
)
114 //------------------------------------------------------------------------
115 Sequence
< Type
> SAL_CALL
FormController::getTypes( ) throw(RuntimeException
)
117 ::cppu::OTypeCollection
aTypes(
118 ::getCppuType( static_cast< Reference
< XPropertySet
>* >(NULL
) ),
119 ::getCppuType( static_cast< Reference
< XMultiPropertySet
>* >(NULL
) ),
120 ::getCppuType( static_cast< Reference
< XFastPropertySet
>* >(NULL
) ),
121 OPropertyBrowserController::getTypes());
122 return aTypes
.getTypes();
125 //------------------------------------------------------------------------
126 IMPLEMENT_GET_IMPLEMENTATION_ID( FormController
)
128 //------------------------------------------------------------------------
129 ::rtl::OUString SAL_CALL
FormController::getImplementationName( ) throw(RuntimeException
)
131 return m_aServiceDescriptor
.GetImplementationName();
134 //------------------------------------------------------------------------
135 Sequence
< ::rtl::OUString
> SAL_CALL
FormController::getSupportedServiceNames( ) throw(RuntimeException
)
137 Sequence
< ::rtl::OUString
> aSupported( m_aServiceDescriptor
.GetSupportedServiceNames() );
138 aSupported
.realloc( aSupported
.getLength() + 1 );
139 aSupported
[ aSupported
.getLength() - 1 ] = ::rtl::OUString( "com.sun.star.inspection.ObjectInspector" );
143 //------------------------------------------------------------------------
144 ::rtl::OUString
FormController::getImplementationName_static( ) throw(RuntimeException
)
146 return ::rtl::OUString("org.openoffice.comp.extensions.FormController");
149 //------------------------------------------------------------------------
150 Sequence
< ::rtl::OUString
> FormController::getSupportedServiceNames_static( ) throw(RuntimeException
)
152 Sequence
< ::rtl::OUString
> aSupported(1);
153 aSupported
[0] = ::rtl::OUString("com.sun.star.form.PropertyBrowserController");
157 //------------------------------------------------------------------------
158 Reference
< XInterface
> SAL_CALL
FormController::Create(const Reference
< XComponentContext
>& _rxContext
)
160 ServiceDescriptor aService
;
161 aService
.GetImplementationName
= &FormController::getImplementationName_static
;
162 aService
.GetSupportedServiceNames
= &FormController::getSupportedServiceNames_static
;
163 return *(new FormController( _rxContext
, aService
, true ) );
166 //------------------------------------------------------------------------
167 Reference
< XPropertySetInfo
> SAL_CALL
FormController::getPropertySetInfo( ) throw(RuntimeException
)
169 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
172 //------------------------------------------------------------------------
173 ::cppu::IPropertyArrayHelper
& SAL_CALL
FormController::getInfoHelper()
175 return *getArrayHelper();
178 //------------------------------------------------------------------------
179 ::cppu::IPropertyArrayHelper
* FormController::createArrayHelper( ) const
181 Sequence
< Property
> aProps( 2 );
182 aProps
[0] = Property(
183 PROPERTY_CURRENTPAGE
,
184 OWN_PROPERTY_ID_CURRENTPAGE
,
185 ::getCppuType( static_cast< ::rtl::OUString
* >( NULL
) ),
186 PropertyAttribute::TRANSIENT
188 aProps
[1] = Property(
189 PROPERTY_INTROSPECTEDOBJECT
,
190 OWN_PROPERTY_ID_INTROSPECTEDOBJECT
,
191 XPropertySet::static_type(),
192 PropertyAttribute::TRANSIENT
| PropertyAttribute::CONSTRAINED
194 return new ::cppu::OPropertyArrayHelper( aProps
);
197 //------------------------------------------------------------------------
198 sal_Bool SAL_CALL
FormController::convertFastPropertyValue( Any
& rConvertedValue
, Any
& rOldValue
, sal_Int32 nHandle
, const Any
& rValue
) throw (IllegalArgumentException
)
202 case OWN_PROPERTY_ID_INTROSPECTEDOBJECT
:
203 if ( rValue
.getValueTypeClass() != TypeClass_INTERFACE
)
204 throw IllegalArgumentException();
206 case OWN_PROPERTY_ID_CURRENTPAGE
:
207 if ( rValue
.getValueTypeClass() != TypeClass_STRING
)
208 throw IllegalArgumentException();
212 getFastPropertyValue( rOldValue
, nHandle
);
213 rConvertedValue
= rValue
;
217 //------------------------------------------------------------------------
218 void SAL_CALL
FormController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle
, const Any
& _rValue
) throw (Exception
)
222 case OWN_PROPERTY_ID_INTROSPECTEDOBJECT
:
224 Reference
< XObjectInspectorModel
> xModel( getInspectorModel() );
229 m_xCurrentInspectee
.set( _rValue
, UNO_QUERY
);
230 Sequence
< Reference
< XInterface
> > aObjects
;
231 if ( m_xCurrentInspectee
.is() )
233 aObjects
.realloc( 1 );
234 aObjects
[0] = m_xCurrentInspectee
;
237 Reference
< XObjectInspector
> xInspector( *this, UNO_QUERY_THROW
);
238 xInspector
->inspect( aObjects
);
240 catch( const VetoException
& e
)
242 throw PropertyVetoException( e
.Message
, e
.Context
);
247 case OWN_PROPERTY_ID_CURRENTPAGE
:
248 restoreViewData( _rValue
);
253 //------------------------------------------------------------------------
254 void SAL_CALL
FormController::getFastPropertyValue( ::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const
258 case OWN_PROPERTY_ID_INTROSPECTEDOBJECT
:
259 rValue
<<= m_xCurrentInspectee
;
262 case OWN_PROPERTY_ID_CURRENTPAGE
:
263 rValue
= const_cast< FormController
* >( this )->getViewData();
268 //====================================================================
270 //====================================================================
271 //------------------------------------------------------------------------
272 ::rtl::OUString
DialogController::getImplementationName_static( ) throw(RuntimeException
)
274 return ::rtl::OUString("org.openoffice.comp.extensions.DialogController");
277 //------------------------------------------------------------------------
278 Sequence
< ::rtl::OUString
> DialogController::getSupportedServiceNames_static( ) throw(RuntimeException
)
280 Sequence
< ::rtl::OUString
> aSupported(1);
281 aSupported
[0] = ::rtl::OUString("com.sun.star.awt.PropertyBrowserController");
285 //------------------------------------------------------------------------
286 Reference
< XInterface
> SAL_CALL
DialogController::Create(const Reference
< XComponentContext
>& _rxContext
)
288 ServiceDescriptor aService
;
289 aService
.GetImplementationName
= &DialogController::getImplementationName_static
;
290 aService
.GetSupportedServiceNames
= &DialogController::getSupportedServiceNames_static
;
291 return *(new FormController( _rxContext
, aService
, false ) );
294 //........................................................................
296 //........................................................................
298 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */