26#include <com/sun/star/beans/PropertyValue.hpp>
56 virtual void dispose()
override;
75 std::unique_ptr<weld::FormattedSpinButton>
m_xWidget;
81 ,
m_xWidget(m_xBuilder->weld_formatted_spin_button(
"spinbutton"))
82 , m_pSpinfieldToolbarController(pSpinfieldToolbarController)
105 return ChildKeyInput(rKEvt);
128 if (m_pSpinfieldToolbarController)
129 m_pSpinfieldToolbarController->execute(0);
134 if (m_pSpinfieldToolbarController)
135 m_pSpinfieldToolbarController->Modify();
140 if (m_pSpinfieldToolbarController)
141 m_pSpinfieldToolbarController->GetFocus();
146 if (m_pSpinfieldToolbarController)
147 m_pSpinfieldToolbarController->LoseFocus();
152 bool bConsumed =
false;
153 if (m_pSpinfieldToolbarController)
155 m_pSpinfieldToolbarController->Activate();
163 OUString aText = m_pSpinfieldToolbarController->FormatOutputString(
m_xWidget->GetFormatter().GetValue());
169 const Reference< XComponentContext >& rxContext,
170 const Reference< XFrame >& rFrame,
181 , m_pSpinfieldControl( nullptr )
215 :
Any(aSpinfieldText.toInt32()));
216 return { aArgs0, aArgs1 };
247 bool bFloatValue(
false );
249 if ( rControlCommand.Command ==
"SetStep" )
251 for (
auto const & arg : rControlCommand.Arguments )
253 if ( arg.Name ==
"Step" )
257 bool bFloat(
false );
259 aStep = bFloat ? OUString::number( fValue ) :
260 OUString( OUString::number(
nValue ));
265 else if ( rControlCommand.Command ==
"SetValue" )
267 for (
auto const & arg : rControlCommand.Arguments )
269 if ( arg.Name ==
"Value" )
273 bool bFloat(
false );
277 aValue = bFloat ? OUString::number( fValue ) :
278 OUString( OUString::number(
nValue ));
279 bFloatValue = bFloat;
285 else if ( rControlCommand.Command ==
"SetValues" )
287 for (
auto const & arg : rControlCommand.Arguments )
291 bool bFloat(
false );
293 OUString
aName = arg.Name;
296 if (
aName ==
"Value" )
298 aValue = bFloat ? OUString::number( fValue ) :
299 OUString( OUString::number(
nValue ));
300 bFloatValue = bFloat;
302 else if (
aName ==
"Step" )
303 aStep = bFloat ? OUString::number( fValue ) :
304 OUString( OUString::number(
nValue ));
305 else if (
aName ==
"LowerLimit" )
306 aMin = bFloat ? OUString::number( fValue ) :
307 OUString( OUString::number(
nValue ));
308 else if (
aName ==
"UpperLimit" )
309 aMax = bFloat ? OUString::number( fValue ) :
310 OUString( OUString::number(
nValue ));
312 else if (
aName ==
"OutputFormat" )
316 else if ( rControlCommand.Command ==
"SetLowerLimit" )
318 for (
auto const & arg : rControlCommand.Arguments )
320 if ( arg.Name ==
"LowerLimit" )
324 bool bFloat(
false );
326 aMin = bFloat ? OUString::number( fValue ) :
327 OUString( OUString::number(
nValue ));
332 else if ( rControlCommand.Command ==
"SetUpperLimit" )
334 for (
auto const & arg : rControlCommand.Arguments )
336 if ( arg.Name ==
"UpperLimit" )
340 bool bFloat(
false );
342 aMax = bFloat ? OUString::number( fValue ) :
343 OUString( OUString::number(
nValue ));
348 else if ( rControlCommand.Command ==
"SetOutputFormat" )
350 for (
auto const & arg : rControlCommand.Arguments )
352 if ( arg.Name ==
"OutputFormat" )
365 if ( !aValue.isEmpty() )
371 if ( !aMax.isEmpty() )
376 if ( !aMin.isEmpty() )
381 if ( !aStep.isEmpty() )
389 const Any& rAny, sal_Int32& nValue,
double& fValue,
bool& bFloat )
391 using ::com::sun::star::uno::TypeClass;
393 bool bValueValid(
false );
396 TypeClass aTypeClass = rAny.getValueTypeClass();
397 if (( aTypeClass == TypeClass( typelib_TypeClass_LONG )) ||
398 ( aTypeClass == TypeClass( typelib_TypeClass_SHORT )) ||
399 ( aTypeClass == TypeClass( typelib_TypeClass_BYTE )))
400 bValueValid = rAny >>=
nValue;
401 else if (( aTypeClass == TypeClass( typelib_TypeClass_FLOAT )) ||
402 ( aTypeClass == TypeClass( typelib_TypeClass_DOUBLE )))
404 bValueValid = rAny >>= fValue;
416 return OUString::number( fValue );
418 return OUString::number( sal_Int32( fValue ));
439 snprintf(
aBuffer, 128, aFormat.getStr(), fValue );
443 sal_Int32 nSize = strlen(
aBuffer );
444 std::string_view aTmp(
aBuffer, nSize );
445 return OStringToOUString( aTmp, osl_getThreadTextEncoding() );
virtual void dispose() override
void InitControlBase(weld::Widget *pWidget)
static VclPtr< reference_type > Create(Arg &&... arg)
DECL_LINK(ModifyHdl, weld::Entry &, void)
DECL_LINK(ParseInputHdl, sal_Int64 *, TriState)
virtual void dispose() override
DECL_LINK(FocusInHdl, weld::Widget &, void)
Formatter & GetFormatter()
DECL_LINK(ActivateHdl, weld::Entry &, bool)
SpinfieldToolbarController * m_pSpinfieldToolbarController
DECL_LINK(FormatOutputHdl, LinkParamNone *, bool)
OUString get_entry_text() const
DECL_LINK(ValueChangedHdl, weld::FormattedSpinButton &, void)
SpinfieldControl(vcl::Window *pParent, SpinfieldToolbarController *pSpinfieldToolbarController)
DECL_LINK(FocusOutHdl, weld::Widget &, void)
DECL_LINK(KeyInputHdl, const ::KeyEvent &, bool)
std::unique_ptr< weld::FormattedSpinButton > m_xWidget
virtual ~SpinfieldControl() override
virtual void SetSizePixel(const Size &rNewSize)
Size get_preferred_size() const
#define LINK(Instance, Class, Member)
#define SAL_N_ELEMENTS(arr)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
IMPL_LINK(WindowCommandDispatch, impl_notifyCommand, VclWindowEvent &, rEvent, void)
IMPL_LINK_NOARG(CloseDispatcher, impl_asyncCallback, LinkParamNone *, void)
asynchronous callback @descr We start all actions inside this object asynchronous (see comments there...
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::unique_ptr< char[]> aBuffer