21#include <com/sun/star/beans/XPropertyState.hpp>
26#include <osl/diagnose.h>
41 const sal_Int32 s_nFirstVirtualButtonType = 1 + sal_Int32(FormButtonType_URL);
43 const char* pNavigationURLs[] =
45 ".uno:FormController/moveToFirst",
46 ".uno:FormController/moveToPrev",
47 ".uno:FormController/moveToNext",
48 ".uno:FormController/moveToLast",
49 ".uno:FormController/saveRecord",
50 ".uno:FormController/undoRecord",
51 ".uno:FormController/moveToNew",
52 ".uno:FormController/deleteRecord",
53 ".uno:FormController/refreshForm",
57 sal_Int32 lcl_getNavigationURLIndex( std::u16string_view _rNavURL )
59 const char** pLookup = pNavigationURLs;
63 return pLookup - pNavigationURLs;
69 const char* lcl_getNavigationURL( sal_Int32 _nButtonTypeIndex )
71 const char** pLookup = pNavigationURLs;
72 while ( _nButtonTypeIndex-- && *pLookup++ )
74 OSL_ENSURE( *pLookup,
"lcl_getNavigationURL: invalid index!" );
84 :m_xControlModel( _rxControlModel )
85 ,m_bIsPushButton( false )
87 OSL_ENSURE(
m_xControlModel.is(),
"PushButtonNavigation::PushButtonNavigation: invalid control model!" );
102 sal_Int32 nButtonType = sal_Int32(FormButtonType_PUSH);
104 return static_cast<FormButtonType
>(nButtonType);
107 if ( nButtonType == sal_Int32(FormButtonType_URL) )
114 sal_Int32 nNavigationURLIndex = lcl_getNavigationURLIndex( sTargetURL );
115 if ( nNavigationURLIndex >= 0)
117 nButtonType = s_nFirstVirtualButtonType + nNavigationURLIndex;
119 return static_cast<FormButtonType
>(nButtonType);
125 OSL_ENSURE(
m_bIsPushButton,
"PushButtonNavigation::getCurrentButtonType: not expected to be called for forms!" );
142 OSL_ENSURE(
m_bIsPushButton,
"PushButtonNavigation::setCurrentButtonType: not expected to be called for forms!" );
148 sal_Int32 nButtonType = sal_Int32(FormButtonType_PUSH);
149 OSL_VERIFY( ::cppu::enum2int( nButtonType, _rValue ) );
152 bool bIsVirtualButtonType = nButtonType >= s_nFirstVirtualButtonType;
153 if ( bIsVirtualButtonType )
155 const char* pURL = lcl_getNavigationURL( nButtonType - s_nFirstVirtualButtonType );
156 sTargetURL = OUString::createFromAscii( pURL );
158 nButtonType = sal_Int32(FormButtonType_URL);
173 OSL_ENSURE(
m_bIsPushButton,
"PushButtonNavigation::getCurrentButtonTypeState: not expected to be called for forms!" );
174 PropertyState eState = PropertyState_DIRECT_VALUE;
178 Reference< XPropertyState > xStateAccess(
m_xControlModel, UNO_QUERY );
179 if ( xStateAccess.is() )
183 if ( eState == PropertyState_DIRECT_VALUE )
185 sal_Int32 nRealButtonType = sal_Int32(FormButtonType_PUSH);
188 if ( sal_Int32(FormButtonType_URL) == nRealButtonType )
198 TOOLS_WARN_EXCEPTION(
"extensions.propctrlr",
"PushButtonNavigation::getCurrentButtonTypeState" );
217 bool bIsVirtualButtonType = nCurrentButtonType >= FormButtonType(s_nFirstVirtualButtonType);
218 if ( bIsVirtualButtonType )
223 aReturn <<= OUString();
253 PropertyState eState = PropertyState_DIRECT_VALUE;
257 Reference< XPropertyState > xStateAccess(
m_xControlModel, UNO_QUERY );
258 if ( xStateAccess.is() )
274 FormButtonType nButtonType( FormButtonType_PUSH );
283 return nButtonType == FormButtonType_URL;
291 return !sTargetURL.isEmpty();
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
bool equalsAscii(std::u16string_view s1, std::string_view s2)
a property handler for any virtual string properties