24#include <com/sun/star/container/XNameContainer.hpp>
25#include <com/sun/star/inspection/StringRepresentation.hpp>
26#include <com/sun/star/util/XModifiable.hpp>
27#include <com/sun/star/awt/XWindow.hpp>
28#include <com/sun/star/inspection/LineDescriptor.hpp>
29#include <com/sun/star/inspection/PropertyControlType.hpp>
30#include <com/sun/star/inspection/XStringListControl.hpp>
31#include <com/sun/star/inspection/XNumericControl.hpp>
57 LineDescriptor& _out_rDescriptor,
const Reference< XPropertyControlFactory >& _rxControlFactory )
60 _out_rDescriptor.DisplayName = _rProperty.Name;
62 OSL_PRECOND( _rxControlFactory.is(),
"PropertyHandlerHelper::describePropertyLine: no factory -> no control!" );
63 if ( !_rxControlFactory.is() )
69 if ( _rProperty.Type.getTypeClass() == TypeClass_BOOLEAN )
75 sal_Int16 nControlType = PropertyControlType::TextField;
76 switch ( _rProperty.Type.getTypeClass() )
80 case TypeClass_UNSIGNED_SHORT:
82 case TypeClass_UNSIGNED_LONG:
84 case TypeClass_UNSIGNED_HYPER:
86 case TypeClass_DOUBLE:
87 nControlType = PropertyControlType::NumericField;
90 case TypeClass_SEQUENCE:
91 nControlType = PropertyControlType::StringListField;
95 OSL_FAIL(
"PropertyHandlerHelper::describePropertyLine: don't know how to represent this at the UI!" );
98 case TypeClass_STRING:
99 nControlType = PropertyControlType::TextField;
104 _out_rDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, bReadOnlyControl );
110 Reference< XPropertyControl > lcl_implCreateListLikeControl(
111 const Reference< XPropertyControlFactory >& _rxControlFactory,
112 std::vector< OUString >&& _rInitialListEntries,
113 bool _bReadOnlyControl,
115 bool _bTrueIfListBoxFalseIfComboBox
118 Reference< XStringListControl > xListControl(
119 _rxControlFactory->createPropertyControl(
120 _bTrueIfListBoxFalseIfComboBox ? PropertyControlType::ListBox : PropertyControlType::ComboBox, _bReadOnlyControl
126 std::sort( _rInitialListEntries.begin(), _rInitialListEntries.end() );
128 for (
auto const& initialEntry : _rInitialListEntries)
129 xListControl->appendListEntry(initialEntry);
135 std::vector< OUString >&& _rInitialListEntries,
bool _bReadOnlyControl,
bool _bSorted )
137 return lcl_implCreateListLikeControl(_rxControlFactory, std::move(_rInitialListEntries), _bReadOnlyControl, _bSorted,
true);
141 const TranslateId* pTransIds,
size_t nElements,
bool _bReadOnlyControl )
143 std::vector<OUString> aInitialListEntries;
145 aInitialListEntries.push_back(
PcrRes(pTransIds[i]));
146 return lcl_implCreateListLikeControl(_rxControlFactory, std::move(aInitialListEntries), _bReadOnlyControl,
false,
true);
150 std::vector< OUString >&& _rInitialListEntries,
bool _bSorted )
152 return lcl_implCreateListLikeControl( _rxControlFactory, std::move(_rInitialListEntries),
false, _bSorted,
false );
157 sal_Int16 _nDigits,
const Optional< double >& _rMinValue,
const Optional< double >& _rMaxValue )
159 Reference< XNumericControl > xNumericControl(
160 _rxControlFactory->createPropertyControl( PropertyControlType::NumericField,
false ),
164 xNumericControl->setDecimalDigits( _nDigits );
165 xNumericControl->setMinValue( _rMinValue );
166 xNumericControl->setMaxValue( _rMaxValue );
168 return xNumericControl;
173 const Property& _rProperty,
const Any& _rControlValue )
175 Any aPropertyValue( _rControlValue );
176 if ( !aPropertyValue.hasValue() )
178 return aPropertyValue;
180 if ( aPropertyValue.getValueType().equals( _rProperty.Type ) )
182 return aPropertyValue;
184 if ( _rControlValue.getValueType().getTypeClass() == TypeClass_STRING )
186 OUString sControlValue;
187 _rControlValue >>= sControlValue;
189 Reference< XStringRepresentation > xConversionHelper = StringRepresentation::create( _rxContext,_rxTypeConverter );
190 aPropertyValue = xConversionHelper->convertToPropertyValue( sControlValue, _rProperty.Type );
196 if ( _rxTypeConverter.is() )
197 aPropertyValue = _rxTypeConverter->convertTo( _rControlValue, _rProperty.Type );
202 "caught an exception while converting via TypeConverter!");
206 return aPropertyValue;
211 const Any& _rPropertyValue,
const Type& _rControlValueType )
213 Any aControlValue( _rPropertyValue );
214 if ( !aControlValue.hasValue() )
216 return aControlValue;
218 if ( _rControlValueType.getTypeClass() == TypeClass_STRING )
220 Reference< XStringRepresentation > xConversionHelper = StringRepresentation::create( _rxContext,_rxTypeConverter );
221 aControlValue <<= xConversionHelper->convertToControlValue( _rPropertyValue );
227 if ( _rxTypeConverter.is() )
228 aControlValue = _rxTypeConverter->convertTo( _rPropertyValue, _rControlValueType );
233 "caught an exception while converting via TypeConverter!");
237 return aControlValue;
246 xDocumentModifiable->setModified(
true );
271 Any aReturn = rContext->getValueByName(
"ContextDocument" );
281 Reference< XWindow > xInspectorWindow(rContext->getValueByName(
"DialogParentWindow" ), UNO_QUERY_THROW);
288 return pInspectorWindow;
293 Reference<XWindow> xWindow(rContext->getValueByName(
"BuilderParent"), UNO_QUERY_THROW);
300 Reference<css::container::XNameContainer> xName(rContext, UNO_QUERY_THROW);
302 xName->insertByName(
"BuilderParent",
Any(xWindow));
307 Reference<css::container::XNameContainer> xName(rContext, UNO_QUERY_THROW);
308 xName->removeByName(
"BuilderParent");
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static css::uno::Reference< css::uno::XInterface > getContextDocument(const css::uno::Reference< css::uno::XComponentContext > &_rContext)
static css::uno::Reference< css::inspection::XPropertyControl > createComboBoxControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, std::vector< OUString > &&_rInitialListEntries, bool _bSorted)
creates an <member scope="css::inspection">PropertyControlType::ComboBox</member>-type control and fi...
static css::uno::Reference< css::uno::XInterface > getContextDocument_throw(const css::uno::Reference< css::uno::XComponentContext > &_rContext)
static css::uno::Reference< css::inspection::XPropertyControl > createListBoxControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, std::vector< OUString > &&_rInitialListEntries, bool _bReadOnlyControl, bool _bSorted)
creates an <member scope="css::inspection">PropertyControlType::ListBox</member>-type control and fil...
static css::uno::Any convertToPropertyValue(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::script::XTypeConverter > &_rxTypeConverter, const css::beans::Property &_rProperty, const css::uno::Any &_rControlValue)
helper for implementing XPropertyHandler::convertToPropertyValue
static void setBuilderParent(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Widget *pParent)
static weld::Window * getDialogParentFrame(const css::uno::Reference< css::uno::XComponentContext > &_rContext)
gets the window of the ObjectInspector in which a property handler lives
static void clearBuilderParent(const css::uno::Reference< css::uno::XComponentContext > &rContext)
static bool requiresReadOnlyControl(sal_Int16 _nPropertyAttributes)
determines whether given PropertyAttributes require a to-be-created <type scope="css::inspection">XPr...
static std::unique_ptr< weld::Builder > makeBuilder(const OUString &rUIFile, const css::uno::Reference< css::uno::XComponentContext > &rContext)
static void setContextDocumentModified(const css::uno::Reference< css::uno::XComponentContext > &_rContext)
marks the document passed in our UNO context as modified
static css::uno::Any convertToControlValue(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::script::XTypeConverter > &_rxTypeConverter, const css::uno::Any &_rPropertyValue, const css::uno::Type &_rControlValueType)
helper for implementing XPropertyHandler::convertToControlValue
static void describePropertyLine(const css::beans::Property &_rProperty, css::inspection::LineDescriptor &_out_rDescriptor, const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory)
helper for implementing XPropertyHandler::describePropertyLine in a generic way
static css::uno::Reference< css::inspection::XPropertyControl > createNumericControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, sal_Int16 _nDigits, const css::beans::Optional< double > &_rMinValue, const css::beans::Optional< double > &_rMaxValue)
creates an <member scope="css::inspection">PropertyControlType::NumericField</member>-type control an...
weld::Widget * getWidget() const
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
#define SAL_N_ELEMENTS(arr)
a property handler for any virtual string properties
OUString PcrRes(TranslateId aId)