Kaydet (Commit) ff1a7a59 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Caolán McNamara

RFC: add IsValueChangedFromSaved to VCL button and listbox

Add a method
   bool IsValueChangedFromSaved()
to the various Button and Listbox classes.
Use it to simplify code like
   if ( maBoldAppFont.GetSavedValue() !=
        TriState(maBoldAppFont.IsChecked()) )
to
   if ( maBoldAppFont.IsValueChangedFromSaved() )

Change-Id: I26b291d0980237497063ee301d63a49c7d2bc227
Reviewed-on: https://gerrit.libreoffice.org/9250Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 10314b5d
...@@ -681,7 +681,7 @@ namespace frm ...@@ -681,7 +681,7 @@ namespace frm
void RecordPositionInput::FirePosition( bool _bForce ) void RecordPositionInput::FirePosition( bool _bForce )
{ {
if ( _bForce || (GetText() != GetSavedValue()) ) if ( _bForce || IsValueChangedFromSaved() )
{ {
sal_Int64 nRecord = GetValue(); sal_Int64 nRecord = GetValue();
if ( nRecord < GetMin() || nRecord > GetMax() ) if ( nRecord < GetMin() || nRecord > GetMax() )
......
...@@ -48,9 +48,9 @@ private: ...@@ -48,9 +48,9 @@ private:
SAL_DLLPRIVATE Button (const Button &); SAL_DLLPRIVATE Button (const Button &);
SAL_DLLPRIVATE Button & operator= (const Button &); SAL_DLLPRIVATE Button & operator= (const Button &);
public: public:
SAL_DLLPRIVATE sal_uInt16 ImplGetButtonState() const; SAL_DLLPRIVATE sal_uInt16 ImplGetButtonState() const;
SAL_DLLPRIVATE sal_uInt16& ImplGetButtonState(); SAL_DLLPRIVATE sal_uInt16& ImplGetButtonState();
SAL_DLLPRIVATE sal_uInt16 ImplGetTextStyle( OUString& rText, WinBits nWinStyle, sal_uLong nDrawFlags ); SAL_DLLPRIVATE sal_uInt16 ImplGetTextStyle( OUString& rText, WinBits nWinStyle, sal_uLong nDrawFlags );
SAL_DLLPRIVATE void ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, Size& rSize, SAL_DLLPRIVATE void ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, Size& rSize,
bool bLayout, sal_uLong nImageSep, sal_uLong nDrawFlags, bool bLayout, sal_uLong nImageSep, sal_uLong nDrawFlags,
sal_uInt16 nTextStyle, Rectangle *pSymbolRect=NULL, bool bAddImageSep = false ); sal_uInt16 nTextStyle, Rectangle *pSymbolRect=NULL, bool bAddImageSep = false );
...@@ -106,7 +106,7 @@ protected: ...@@ -106,7 +106,7 @@ protected:
SymbolType meSymbol; SymbolType meSymbol;
TriState meState; TriState meState;
TriState meSaveValue; TriState meSaveValue;
sal_uInt16 mnDDStyle; sal_uInt16 mnDDStyle;
bool mbPressed; bool mbPressed;
bool mbInUserDraw; bool mbInUserDraw;
Link maToggleHdl; Link maToggleHdl;
...@@ -185,6 +185,7 @@ public: ...@@ -185,6 +185,7 @@ public:
void SaveValue() { meSaveValue = GetState(); } void SaveValue() { meSaveValue = GetState(); }
TriState GetSavedValue() const { return meSaveValue; } TriState GetSavedValue() const { return meSaveValue; }
bool IsValueChangedFromSaved() const { return meSaveValue != GetState(); }
Size CalcMinimumSize( long nMaxWidth = 0 ) const; Size CalcMinimumSize( long nMaxWidth = 0 ) const;
virtual Size GetOptimalSize() const SAL_OVERRIDE; virtual Size GetOptimalSize() const SAL_OVERRIDE;
...@@ -367,7 +368,7 @@ public: ...@@ -367,7 +368,7 @@ public:
void EnableRadioCheck( bool bRadioCheck = true ) { mbRadioCheck = bRadioCheck; } void EnableRadioCheck( bool bRadioCheck = true ) { mbRadioCheck = bRadioCheck; }
bool IsRadioCheckEnabled() const { return mbRadioCheck; } bool IsRadioCheckEnabled() const { return mbRadioCheck; }
bool SetModeRadioImage( const Image& rImage ); bool SetModeRadioImage( const Image& rImage );
const Image& GetModeRadioImage( ) const; const Image& GetModeRadioImage( ) const;
void SetState( bool bCheck ); void SetState( bool bCheck );
...@@ -376,6 +377,7 @@ public: ...@@ -376,6 +377,7 @@ public:
void SaveValue() { mbSaveValue = IsChecked(); } void SaveValue() { mbSaveValue = IsChecked(); }
bool GetSavedValue() const { return mbSaveValue; } bool GetSavedValue() const { return mbSaveValue; }
bool IsValueChangedFromSaved() const { return mbSaveValue != IsChecked(); }
static Image GetRadioImage( const AllSettings& rSettings, sal_uInt16 nFlags ); static Image GetRadioImage( const AllSettings& rSettings, sal_uInt16 nFlags );
...@@ -488,6 +490,7 @@ public: ...@@ -488,6 +490,7 @@ public:
void SaveValue() { meSaveValue = GetState(); } void SaveValue() { meSaveValue = GetState(); }
TriState GetSavedValue() const { return meSaveValue; } TriState GetSavedValue() const { return meSaveValue; }
bool IsValueChangedFromSaved() const { return meSaveValue != GetState(); }
static Image GetCheckImage( const AllSettings& rSettings, sal_uInt16 nFlags ); static Image GetCheckImage( const AllSettings& rSettings, sal_uInt16 nFlags );
......
...@@ -218,6 +218,7 @@ public: ...@@ -218,6 +218,7 @@ public:
void SaveValue() { maSaveValue = GetText(); } void SaveValue() { maSaveValue = GetText(); }
const OUString& GetSavedValue() const { return maSaveValue; } const OUString& GetSavedValue() const { return maSaveValue; }
bool IsValueChangedFromSaved() const { return maSaveValue != GetText(); }
virtual void SetModifyHdl( const Link& rLink ) { maModifyHdl = rLink; } virtual void SetModifyHdl( const Link& rLink ) { maModifyHdl = rLink; }
virtual const Link& GetModifyHdl() const { return maModifyHdl; } virtual const Link& GetModifyHdl() const { return maModifyHdl; }
......
...@@ -164,6 +164,7 @@ public: ...@@ -164,6 +164,7 @@ public:
void SaveValue() { mnSaveValue = GetSelectEntryPos(); } void SaveValue() { mnSaveValue = GetSelectEntryPos(); }
sal_Int32 GetSavedValue() const { return mnSaveValue; } sal_Int32 GetSavedValue() const { return mnSaveValue; }
bool IsValueChangedFromSaved() const { return mnSaveValue != GetSelectEntryPos(); }
void SetSeparatorPos( sal_Int32 n = LISTBOX_ENTRY_NOTFOUND ); void SetSeparatorPos( sal_Int32 n = LISTBOX_ENTRY_NOTFOUND );
sal_Int32 GetSeparatorPos() const; sal_Int32 GetSeparatorPos() const;
...@@ -244,10 +245,12 @@ class VCL_DLLPUBLIC MultiListBox : public ListBox ...@@ -244,10 +245,12 @@ class VCL_DLLPUBLIC MultiListBox : public ListBox
public: public:
using ListBox::SaveValue; using ListBox::SaveValue;
using ListBox::GetSavedValue; using ListBox::GetSavedValue;
using ListBox::IsValueChangedFromSaved;
private: private:
// Bei MultiListBox nicht erlaubt... // Bei MultiListBox nicht erlaubt...
void SaveValue(); void SaveValue();
sal_Int32 GetSavedValue(); sal_Int32 GetSavedValue();
bool IsValueChangedFromSaved() const;
public: public:
explicit MultiListBox( Window* pParent, WinBits nStyle = 0 ); explicit MultiListBox( Window* pParent, WinBits nStyle = 0 );
......
...@@ -108,6 +108,7 @@ public: ...@@ -108,6 +108,7 @@ public:
void SaveValue() { aSaveValue = GetText(); } void SaveValue() { aSaveValue = GetText(); }
const OUString& GetSavedValue() const { return aSaveValue; } const OUString& GetSavedValue() const { return aSaveValue; }
bool IsValueChangedFromSaved() const { return aSaveValue != GetText(); }
void SetModifyHdl( const Link& rLink ) SAL_OVERRIDE { aModifyHdlLink = rLink; } void SetModifyHdl( const Link& rLink ) SAL_OVERRIDE { aModifyHdlLink = rLink; }
const Link& GetModifyHdl() const SAL_OVERRIDE { return aModifyHdlLink; } const Link& GetModifyHdl() const SAL_OVERRIDE { return aModifyHdlLink; }
......
...@@ -1071,23 +1071,23 @@ void OGroupsSortingDialog::SaveData( sal_Int32 _nRow) ...@@ -1071,23 +1071,23 @@ void OGroupsSortingDialog::SaveData( sal_Int32 _nRow)
return; return;
uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos); uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos);
if ( m_aHeaderLst.GetSavedValue() != m_aHeaderLst.GetSelectEntryPos() ) if ( m_aHeaderLst.IsValueChangedFromSaved() )
xGroup->setHeaderOn( m_aHeaderLst.GetSelectEntryPos() == 0 ); xGroup->setHeaderOn( m_aHeaderLst.GetSelectEntryPos() == 0 );
if ( m_aFooterLst.GetSavedValue() != m_aFooterLst.GetSelectEntryPos() ) if ( m_aFooterLst.IsValueChangedFromSaved() )
xGroup->setFooterOn( m_aFooterLst.GetSelectEntryPos() == 0 ); xGroup->setFooterOn( m_aFooterLst.GetSelectEntryPos() == 0 );
if ( m_aKeepTogetherLst.GetSavedValue() != m_aKeepTogetherLst.GetSelectEntryPos() ) if ( m_aKeepTogetherLst.IsValueChangedFromSaved() )
xGroup->setKeepTogether( m_aKeepTogetherLst.GetSelectEntryPos() ); xGroup->setKeepTogether( m_aKeepTogetherLst.GetSelectEntryPos() );
if ( m_aGroupOnLst.GetSavedValue() != m_aGroupOnLst.GetSelectEntryPos() ) if ( m_aGroupOnLst.IsValueChangedFromSaved() )
{ {
sal_Int16 nGroupOn = static_cast<sal_Int16>(reinterpret_cast<sal_IntPtr>(m_aGroupOnLst.GetEntryData(m_aGroupOnLst.GetSelectEntryPos()))); sal_Int16 nGroupOn = static_cast<sal_Int16>(reinterpret_cast<sal_IntPtr>(m_aGroupOnLst.GetEntryData(m_aGroupOnLst.GetSelectEntryPos())));
xGroup->setGroupOn( nGroupOn ); xGroup->setGroupOn( nGroupOn );
} }
if ( m_aGroupIntervalEd.GetSavedValue().toInt32() != m_aGroupIntervalEd.GetValue() ) if ( m_aGroupIntervalEd.IsValueChangedFromSaved() )
{ {
xGroup->setGroupInterval( static_cast<sal_Int32>(m_aGroupIntervalEd.GetValue()) ); xGroup->setGroupInterval( static_cast<sal_Int32>(m_aGroupIntervalEd.GetValue()) );
m_aGroupIntervalEd.SaveValue(); m_aGroupIntervalEd.SaveValue();
} }
if ( m_aOrderLst.GetSavedValue() != m_aOrderLst.GetSelectEntryPos() ) if ( m_aOrderLst.IsValueChangedFromSaved() )
xGroup->setSortAscending( m_aOrderLst.GetSelectEntryPos() == 0 ); xGroup->setSortAscending( m_aOrderLst.GetSelectEntryPos() == 0 );
ListBox* pControls[] = { &m_aHeaderLst,&m_aFooterLst,&m_aGroupOnLst,&m_aKeepTogetherLst,&m_aOrderLst}; ListBox* pControls[] = { &m_aHeaderLst,&m_aFooterLst,&m_aGroupOnLst,&m_aKeepTogetherLst,&m_aOrderLst};
...@@ -1196,13 +1196,13 @@ IMPL_LINK( OGroupsSortingDialog, OnFormatAction, ToolBox*, /*NOTINTERESTEDIN*/ ) ...@@ -1196,13 +1196,13 @@ IMPL_LINK( OGroupsSortingDialog, OnFormatAction, ToolBox*, /*NOTINTERESTEDIN*/ )
IMPL_LINK( OGroupsSortingDialog, LBChangeHdl, ListBox*, pListBox ) IMPL_LINK( OGroupsSortingDialog, LBChangeHdl, ListBox*, pListBox )
{ {
if ( pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() ) if ( pListBox->IsValueChangedFromSaved() )
{ {
sal_Int32 nRow = m_pFieldExpression->GetCurRow(); sal_Int32 nRow = m_pFieldExpression->GetCurRow();
sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(nRow); sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(nRow);
if ( pListBox != &m_aHeaderLst && pListBox != &m_aFooterLst) if ( pListBox != &m_aHeaderLst && pListBox != &m_aFooterLst)
{ {
if ( pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() ) if ( pListBox->IsValueChangedFromSaved() )
SaveData(nRow); SaveData(nRow);
if ( pListBox == &m_aGroupOnLst ) if ( pListBox == &m_aGroupOnLst )
m_aGroupIntervalEd.Enable( pListBox->GetSelectEntryPos() != 0 ); m_aGroupIntervalEd.Enable( pListBox->GetSelectEntryPos() != 0 );
......
...@@ -334,7 +334,7 @@ IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton ) ...@@ -334,7 +334,7 @@ IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton )
#define IMMEDIATE_FLAGS (DBG_TEST_RESOURCE | DBG_TEST_DIALOG | DBG_TEST_BOLDAPPFONT) #define IMMEDIATE_FLAGS (DBG_TEST_RESOURCE | DBG_TEST_DIALOG | DBG_TEST_BOLDAPPFONT)
pData->nTestFlags &= ~IMMEDIATE_FLAGS; pData->nTestFlags &= ~IMMEDIATE_FLAGS;
pData->nTestFlags |= aData.nTestFlags & IMMEDIATE_FLAGS; pData->nTestFlags |= aData.nTestFlags & IMMEDIATE_FLAGS;
if ( maBoldAppFont.GetSavedValue() != TriState(maBoldAppFont.IsChecked()) ) if ( maBoldAppFont.IsValueChangedFromSaved() )
{ {
AllSettings aSettings = Application::GetSettings(); AllSettings aSettings = Application::GetSettings();
StyleSettings aStyleSettings = aSettings.GetStyleSettings(); StyleSettings aStyleSettings = aSettings.GetStyleSettings();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment