diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-04-07 10:49:39 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-04-07 13:47:02 +0100 |
commit | d913a5a9dfa44bb8061ff194e990c08cc40d7a69 (patch) | |
tree | 37c44088f47676e52baec75c5854a050b35f8384 /sfx2/source/dialog/tabdlg.cxx | |
parent | c06267b1056fed5dedac443b706d721620e40da9 (diff) |
untangle the bFmt == 2 hack
Firstly, IsFormat is unused so there's no "escape" of
bFmt back into the outside world.
Then bFmt has two purposes.
Purpose 1 is 'not be a format dialog, be a format dialog, be a format dialog but hide standard button'
so, lets just add an explicit "Hide standard button" method and call
it in the (apparently) one place where it's necessary.
Purpose 2 is to flag that "BaseFmtHdl" was called from clicking
the "Standard" button at which point its set to 2.
SfxTabDialog::Init_Impl had...
"
// bFmt = temporary Flag passed on in the Constructor(),
// if bFmt == 2, then also sal_True,
// additional suppression of the standard button,
// after the Initializing set to sal_True again
if ( bFmtFlag != 2 )
m_pBaseFmtBtn->Show();
else
bFmtFlag = sal_True;
"
but the variable acted on is bFmtFlag a copy of bFmt, and is never read again
after that line, so setting it to sal_True is meaningless. The comment suggests
that the intent is to reset bFmt to true if it was 2 during initialization,
which fits with the later use of bFmt == 2 to indicate that the standard button was
clicked, i.e. reset bFmt back to its standard value.
So make bFmt a simple toggle of dialog as a format dialog or not, add a way
to remove the standard button and add a second variable to indicate the standard
button got pressed.
Change-Id: I98a441f5f314845abe243e05b6d92fd71d7b0b04
Diffstat (limited to 'sfx2/source/dialog/tabdlg.cxx')
-rw-r--r-- | sfx2/source/dialog/tabdlg.cxx | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 6666f830f35c..dec86be638a4 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -397,8 +397,7 @@ SfxTabDialog::SfxTabDialog const OString& rID, const OUString& rUIXMLDescription, //Dialog Name, Dialog .ui path const SfxItemSet* pItemSet, // Itemset with the data; // can be NULL, when Pages are onDemand - sal_Bool bEditFmt // Flag: templates are processed - // when yes -> additional Button for standard + bool bEditFmt // when yes -> additional Button for standard ) : TabDialog(pParent, rID, rUIXMLDescription) , pFrame(pViewFrame) @@ -407,10 +406,10 @@ SfxTabDialog::SfxTabDialog , pRanges(0) , nAppPageId(USHRT_MAX) , bItemsReset(false) - , bFmt(bEditFmt) + , bStandardPushed(false) , pExampleSet(0) { - Init_Impl( bFmt, NULL, NULL ); + Init_Impl(bEditFmt, NULL, NULL); } @@ -427,8 +426,7 @@ SfxTabDialog::SfxTabDialog const OString& rID, const OUString& rUIXMLDescription, //Dialog Name, Dialog .ui path const SfxItemSet* pItemSet, // Itemset with the data; // can be NULL, when Pages are onDemand - sal_Bool bEditFmt // Flag: templates are processed - // when yes -> additional Button for standard + bool bEditFmt // when yes -> additional Button for standard ) : TabDialog(pParent, rID, rUIXMLDescription) , pFrame(0) @@ -437,10 +435,10 @@ SfxTabDialog::SfxTabDialog , pRanges(0) , nAppPageId(USHRT_MAX) , bItemsReset(false) - , bFmt(bEditFmt) + , bStandardPushed(false) , pExampleSet(0) { - Init_Impl(bFmt, NULL, NULL); + Init_Impl(bEditFmt, NULL, NULL); DBG_WARNING( "Please use the Construtor with the ViewFrame" ); } @@ -510,7 +508,7 @@ SfxTabDialog::~SfxTabDialog() -void SfxTabDialog::Init_Impl( sal_Bool bFmtFlag, const OUString* pUserButtonText, const ResId *pResId ) +void SfxTabDialog::Init_Impl(bool bFmtFlag, const OUString* pUserButtonText, const ResId *pResId) /* [Description] @@ -607,22 +605,12 @@ void SfxTabDialog::Init_Impl( sal_Bool bFmtFlag, const OUString* pUserButtonText m_pUserBtn->Show(); } - /* TODO: Check what is up with bFmt/bFmtFlag. Comment below suggests a - different behavior than implemented!! */ if ( bFmtFlag ) { m_pBaseFmtBtn->SetText( SfxResId( STR_STANDARD_SHORTCUT ).toString() ); m_pBaseFmtBtn->SetClickHdl( LINK( this, SfxTabDialog, BaseFmtHdl ) ); m_pBaseFmtBtn->SetHelpId( HID_TABDLG_STANDARD_BTN ); - - // bFmt = temporary Flag passed on in the Constructor(), - // if bFmt == 2, then also sal_True, - // additional suppression of the standard button, - // after the Initializing set to sal_True again - if ( bFmtFlag != 2 ) - m_pBaseFmtBtn->Show(); - else - bFmtFlag = sal_True; + m_pBaseFmtBtn->Show(); } if ( pSet ) @@ -632,15 +620,16 @@ void SfxTabDialog::Init_Impl( sal_Bool bFmtFlag, const OUString* pUserButtonText } } - - void SfxTabDialog::RemoveResetButton() { m_pResetBtn->Hide(); pImpl->bHideResetBtn = true; } - +void SfxTabDialog::RemoveStandardButton() +{ + m_pBaseFmtBtn->Hide(); +} short SfxTabDialog::Execute() { @@ -922,7 +911,6 @@ short SfxTabDialog::Ok() RET_OK: if at least one page has returned from FillItemSet, otherwise RET_CANCEL. */ - { SavePosAndId(); //See fdo#38828 "Apply" resetting window position @@ -966,13 +954,11 @@ short SfxTabDialog::Ok() if ( pImpl->bModified || ( pOutSet && pOutSet->Count() > 0 ) ) bModified |= true; - if ( bFmt == 2 ) + if (bStandardPushed) bModified |= true; return bModified ? RET_OK : RET_CANCEL; } - - IMPL_LINK_NOARG(SfxTabDialog, CancelHdl) { EndDialog( RET_USER_CANCEL ); @@ -1145,10 +1131,11 @@ IMPL_LINK_NOARG(SfxTabDialog, BaseFmtHdl) */ { + bStandardPushed = true; + const sal_uInt16 nId = m_pTabCtrl->GetCurPageId(); Data_Impl* pDataObject = Find( pImpl->aData, nId ); DBG_ASSERT( pDataObject, "Id not known" ); - bFmt = 2; if ( pDataObject->fnGetRanges ) { |