1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX 29*cdf0e10cSrcweir #define EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir /** === begin UNO includes === **/ 32*cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/script/XTypeConverter.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/inspection/XPropertyControlFactory.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/beans/Optional.hpp> 39*cdf0e10cSrcweir /** === end UNO includes === **/ 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <vector> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir class Window; 44*cdf0e10cSrcweir namespace com { namespace sun { namespace star { 45*cdf0e10cSrcweir namespace inspection { 46*cdf0e10cSrcweir struct LineDescriptor; 47*cdf0e10cSrcweir } 48*cdf0e10cSrcweir } } } 49*cdf0e10cSrcweir //........................................................................ 50*cdf0e10cSrcweir namespace pcr 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir //........................................................................ 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir class ComponentContext; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir //==================================================================== 57*cdf0e10cSrcweir //= PropertyHandlerHelper 58*cdf0e10cSrcweir //==================================================================== 59*cdf0e10cSrcweir class PropertyHandlerHelper 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir public: 62*cdf0e10cSrcweir /** helper for implementing XPropertyHandler::describePropertyLine in a generic way 63*cdf0e10cSrcweir */ 64*cdf0e10cSrcweir static void describePropertyLine( 65*cdf0e10cSrcweir const ::com::sun::star::beans::Property& _rProperty, 66*cdf0e10cSrcweir ::com::sun::star::inspection::LineDescriptor& /* [out] */ _out_rDescriptor, 67*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory 68*cdf0e10cSrcweir ); 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir /** helper for implementing XPropertyHandler::convertToPropertyValue 71*cdf0e10cSrcweir */ 72*cdf0e10cSrcweir static ::com::sun::star::uno::Any convertToPropertyValue( 73*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, 74*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter, 75*cdf0e10cSrcweir const ::com::sun::star::beans::Property& _rProperty, 76*cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rControlValue 77*cdf0e10cSrcweir ); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir /// helper for implementing XPropertyHandler::convertToControlValue 80*cdf0e10cSrcweir static ::com::sun::star::uno::Any convertToControlValue( 81*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, 82*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter, 83*cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rPropertyValue, 84*cdf0e10cSrcweir const ::com::sun::star::uno::Type& _rControlValueType 85*cdf0e10cSrcweir ); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ListBox</member>-type control 88*cdf0e10cSrcweir and fills it with initial values 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir @param _rxControlFactory 91*cdf0e10cSrcweir A control factory. Must not be <NULL/>. 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir @param _rInitialListEntries 94*cdf0e10cSrcweir the initial values of the control 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir @param _bReadOnlyControl 97*cdf0e10cSrcweir determines whether the control should be read-only 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir @param _bSorted 100*cdf0e10cSrcweir determines whether the list entries should be sorted 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir @return 103*cdf0e10cSrcweir the newly created control 104*cdf0e10cSrcweir */ 105*cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > 106*cdf0e10cSrcweir createListBoxControl( 107*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory, 108*cdf0e10cSrcweir const ::std::vector< ::rtl::OUString >& _rInitialListEntries, 109*cdf0e10cSrcweir sal_Bool _bReadOnlyControl, 110*cdf0e10cSrcweir sal_Bool _bSorted 111*cdf0e10cSrcweir ); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ComboBox</member>-type control 114*cdf0e10cSrcweir and fills it with initial values 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir @param _rxControlFactory 117*cdf0e10cSrcweir A control factory. Must not be <NULL/>. 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir @param _rInitialListEntries 120*cdf0e10cSrcweir the initial values of the control 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir @param _bReadOnlyControl 123*cdf0e10cSrcweir determines whether the control should be read-only 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir @param _bSorted 126*cdf0e10cSrcweir determines whether the list entries should be sorted 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir @return 129*cdf0e10cSrcweir the newly created control 130*cdf0e10cSrcweir */ 131*cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > 132*cdf0e10cSrcweir createComboBoxControl( 133*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory, 134*cdf0e10cSrcweir const ::std::vector< ::rtl::OUString >& _rInitialListEntries, 135*cdf0e10cSrcweir sal_Bool _bReadOnlyControl, 136*cdf0e10cSrcweir sal_Bool _bSorted 137*cdf0e10cSrcweir ); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir /** creates an <member scope="com::sun::star::inspection">PropertyControlType::NumericField</member>-type control 140*cdf0e10cSrcweir and initializes it 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir @param _rxControlFactory 143*cdf0e10cSrcweir A control factory. Must not be <NULL/>. 144*cdf0e10cSrcweir @param _nDigits 145*cdf0e10cSrcweir number of decimal digits for the control 146*cdf0e10cSrcweir (<member scope="com::sun::star::inspection">XNumericControl::DecimalDigits</member>) 147*cdf0e10cSrcweir @param _rMinValue 148*cdf0e10cSrcweir minimum value which can be entered in the control 149*cdf0e10cSrcweir (<member scope="com::sun::star::inspection">XNumericControl::MinValue</member>) 150*cdf0e10cSrcweir @param _rMaxValue 151*cdf0e10cSrcweir maximum value which can be entered in the control 152*cdf0e10cSrcweir (<member scope="com::sun::star::inspection">XNumericControl::MaxValue</member>) 153*cdf0e10cSrcweir @param _bReadOnlyControl 154*cdf0e10cSrcweir determines whether the control should be read-only 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir @return 157*cdf0e10cSrcweir the newly created control 158*cdf0e10cSrcweir */ 159*cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > 160*cdf0e10cSrcweir createNumericControl( 161*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory, 162*cdf0e10cSrcweir sal_Int16 _nDigits, 163*cdf0e10cSrcweir const ::com::sun::star::beans::Optional< double >& _rMinValue, 164*cdf0e10cSrcweir const ::com::sun::star::beans::Optional< double >& _rMaxValue, 165*cdf0e10cSrcweir sal_Bool _bReadOnlyControl 166*cdf0e10cSrcweir ); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir /** marks the document passed in our UNO context as modified 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir The method looks up a value called "ContextDocument" in the given UNO component context, 171*cdf0e10cSrcweir queries it for the ->com::sun::star::util::XModifiable interface, and calls its 172*cdf0e10cSrcweir setModified method. If either of those steps fails, this is asserted in a non-product 173*cdf0e10cSrcweir version, and silently ignore otherwise. 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir @param _rContext 176*cdf0e10cSrcweir the component context which was used to create the component calling this method 177*cdf0e10cSrcweir */ 178*cdf0e10cSrcweir static void setContextDocumentModified( 179*cdf0e10cSrcweir const ComponentContext& _rContext 180*cdf0e10cSrcweir ); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir /** gets the window of the ObjectInspector in which an property handler lives 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir The method looks up a value called "DialogParentWindow" in the given UNO copmonent context, 185*cdf0e10cSrcweir queries it for XWindow, and returns the respective Window*. If either of those steps fails, 186*cdf0e10cSrcweir this is asserted in a non-product version, and silently ignore otherwise. 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir @param _rContext 189*cdf0e10cSrcweir the component context which was used to create the component calling this method 190*cdf0e10cSrcweir */ 191*cdf0e10cSrcweir static Window* getDialogParentWindow( const ComponentContext& _rContext ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir /** determines whether given PropertyAttributes require a to-be-created 195*cdf0e10cSrcweir <type scope="com::sun::star::inspection">XPropertyControl</type> to be read-only 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir @param _nPropertyAttributes 198*cdf0e10cSrcweir the attributes of the property which should be reflected by a to-be-created 199*cdf0e10cSrcweir <type scope="com::sun::star::inspection">XPropertyControl</type> 200*cdf0e10cSrcweir */ 201*cdf0e10cSrcweir inline static sal_Bool requiresReadOnlyControl( sal_Int16 _nPropertyAttributes ) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir return ( _nPropertyAttributes & ::com::sun::star::beans::PropertyAttribute::READONLY ) != 0; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir private: 207*cdf0e10cSrcweir PropertyHandlerHelper(); // never implemented 208*cdf0e10cSrcweir PropertyHandlerHelper( const PropertyHandlerHelper& ); // never implemented 209*cdf0e10cSrcweir PropertyHandlerHelper& operator=( const PropertyHandlerHelper& ); // never implemented 210*cdf0e10cSrcweir }; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir //........................................................................ 213*cdf0e10cSrcweir } // namespace pcr 214*cdf0e10cSrcweir //........................................................................ 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir #endif // EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX 217*cdf0e10cSrcweir 218