diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-10-26 12:49:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-10-27 09:57:07 +0200 |
commit | bdd7c74a499ea550a10e47d159c2d2d80c940fc0 (patch) | |
tree | f54a6a5e767f2c2aafc88ae7ce566fb81da86e6c /sc/source/ui | |
parent | 75c642dae3ded5bcf6d48f81363ad918d101d2e5 (diff) |
Resolves: tdf#113455 Impossible to clear width/height in pages
Change-Id: I88f80d417108822ceeb73c07cb49892925a2e57f
Reviewed-on: https://gerrit.libreoffice.org/43891
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/inc/tptable.hxx | 8 | ||||
-rw-r--r-- | sc/source/ui/pagedlg/tptable.cxx | 77 |
2 files changed, 67 insertions, 18 deletions
diff --git a/sc/source/ui/inc/tptable.hxx b/sc/source/ui/inc/tptable.hxx index f3d01eef310d..3b01422a68ce 100644 --- a/sc/source/ui/inc/tptable.hxx +++ b/sc/source/ui/inc/tptable.hxx @@ -46,6 +46,9 @@ private: void ShowImage(); private: + sal_uInt16 m_nOrigScalePageWidth; + sal_uInt16 m_nOrigScalePageHeight; + VclPtr<RadioButton> m_pBtnTopDown; VclPtr<RadioButton> m_pBtnLeftRight; VclPtr<FixedImage> m_pBmpPageDir; @@ -66,7 +69,9 @@ private: VclPtr<MetricField> m_pEdScaleAll; VclPtr<VclGrid> m_pGrHeightWidth; VclPtr<NumericField> m_pEdScalePageWidth; + VclPtr<CheckBox> m_pCbScalePageWidth; VclPtr<NumericField> m_pEdScalePageHeight; + VclPtr<CheckBox> m_pCbScalePageHeight; VclPtr<VclHBox> m_pBxScalePageNum; VclPtr<NumericField> m_pEdScalePageNum; @@ -74,8 +79,9 @@ private: // Handler: DECL_LINK(PageDirHdl, Button*, void); - DECL_LINK( PageNoHdl, Button*, void ); + DECL_LINK(PageNoHdl, Button*, void); DECL_LINK(ScaleHdl, ListBox&, void); + DECL_LINK(ToggleHdl, CheckBox&, void); }; #endif // INCLUDED_SC_SOURCE_UI_INC_TPTABLE_HXX diff --git a/sc/source/ui/pagedlg/tptable.cxx b/sc/source/ui/pagedlg/tptable.cxx index be608b015f53..6b9585d79c3f 100644 --- a/sc/source/ui/pagedlg/tptable.cxx +++ b/sc/source/ui/pagedlg/tptable.cxx @@ -55,9 +55,11 @@ static bool lcl_PutScaleItem2( sal_uInt16 nWhich, SfxItemSet& rCoreSet, const SfxItemSet& rOldSet, const ListBox& rListBox, - sal_uInt16 nLBEntry, + sal_uInt16 nLBEntry, const NumericField& rEd1, - const NumericField& rEd2 ); + sal_uInt16 nOrigScalePageWidth, + const NumericField& rEd2, + sal_uInt16 nOrigScalePageHeight ); static bool lcl_PutBoolItem( sal_uInt16 nWhich, SfxItemSet& rCoreSet, @@ -84,9 +86,10 @@ bool WAS_DEFAULT(sal_uInt16 w, SfxItemSet const & s) #define SC_TPTABLE_SCALE_TO 1 #define SC_TPTABLE_SCALE_TO_PAGES 2 -ScTablePage::ScTablePage( vcl::Window* pParent, const SfxItemSet& rCoreAttrs ) : - - SfxTabPage( pParent, "SheetPrintPage","modules/scalc/ui/sheetprintpage.ui", &rCoreAttrs ) +ScTablePage::ScTablePage(vcl::Window* pParent, const SfxItemSet& rCoreAttrs) + : SfxTabPage(pParent, "SheetPrintPage","modules/scalc/ui/sheetprintpage.ui", &rCoreAttrs) + , m_nOrigScalePageWidth(0) + , m_nOrigScalePageHeight(0) { get(m_pBtnTopDown,"radioBTN_TOPDOWN"); get(m_pBtnLeftRight,"radioBTN_LEFTRIGHT"); @@ -108,7 +111,9 @@ ScTablePage::ScTablePage( vcl::Window* pParent, const SfxItemSet& rCoreAttrs ) : get(m_pEdScaleAll,"spinED_SCALEALL"); get(m_pGrHeightWidth,"gridWH"); get(m_pEdScalePageWidth,"spinED_SCALEPAGEWIDTH"); + get(m_pCbScalePageWidth,"unsetwidth"); get(m_pEdScalePageHeight,"spinED_SCALEPAGEHEIGHT"); + get(m_pCbScalePageHeight,"unsetheight"); get(m_pBxScalePageNum,"boxNP"); get(m_pEdScalePageNum,"spinED_SCALEPAGENUM"); @@ -118,7 +123,8 @@ ScTablePage::ScTablePage( vcl::Window* pParent, const SfxItemSet& rCoreAttrs ) : m_pBtnTopDown->SetClickHdl( PAGEDIR_HDL ); m_pBtnLeftRight->SetClickHdl( PAGEDIR_HDL ); m_pLbScaleMode->SetSelectHdl( LINK(this,ScTablePage,ScaleHdl) ); - + m_pCbScalePageWidth->SetToggleHdl(LINK(this, ScTablePage, ToggleHdl)); + m_pCbScalePageHeight->SetToggleHdl(LINK(this, ScTablePage, ToggleHdl)); } void ScTablePage::ShowImage() @@ -152,7 +158,9 @@ void ScTablePage::dispose() m_pBxScaleAll.clear(); m_pEdScaleAll.clear(); m_pGrHeightWidth.clear(); + m_pCbScalePageWidth.clear(); m_pEdScalePageWidth.clear(); + m_pCbScalePageHeight.clear(); m_pEdScalePageHeight.clear(); m_pBxScalePageNum.clear(); m_pEdScalePageNum.clear(); @@ -209,10 +217,12 @@ void ScTablePage::Reset( const SfxItemSet* rCoreSet ) /* width==0 and height==0 is invalid state, used as "not selected". Dialog shows width=height=1 then. */ bool bValid = nWidth || nHeight; - if( bValid ) + if (bValid) m_pLbScaleMode->SelectEntryPos( SC_TPTABLE_SCALE_TO ); m_pEdScalePageWidth->SetValue( bValid ? nWidth : 1 ); m_pEdScalePageHeight->SetValue( bValid ? nHeight : 1 ); + m_pCbScalePageWidth->Check(bValid && !nWidth); + m_pCbScalePageHeight->Check(bValid && !nHeight); } nWhich = GetWhich(SID_SCATTR_PAGE_SCALETOPAGES); @@ -250,8 +260,8 @@ void ScTablePage::Reset( const SfxItemSet* rCoreSet ) m_pBtnPageNo->SaveValue(); m_pEdPageNo->SaveValue(); m_pEdScaleAll->SaveValue(); - m_pEdScalePageWidth->SaveValue(); - m_pEdScalePageHeight->SaveValue(); + m_nOrigScalePageWidth = m_pEdScalePageWidth->IsEnabled() ? m_pEdScalePageWidth->GetValue() : 0; + m_nOrigScalePageHeight = m_pEdScalePageHeight->IsEnabled() ? m_pEdScalePageHeight->GetValue() : 0; m_pEdScalePageNum->SaveValue(); } @@ -323,7 +333,7 @@ bool ScTablePage::FillItemSet( SfxItemSet* rCoreSet ) *rCoreSet, rOldSet, *m_pBtnDrawings ); // scaling: - if( !m_pEdScalePageWidth->GetValue() && !m_pEdScalePageHeight->GetValue() ) + if( !m_pEdScalePageWidth->IsEnabled() && !m_pEdScalePageHeight->IsEnabled() ) { m_pLbScaleMode->SelectEntryPos( SC_TPTABLE_SCALE_PERCENT ); m_pEdScaleAll->SetValue( 100 ); @@ -337,7 +347,8 @@ bool ScTablePage::FillItemSet( SfxItemSet* rCoreSet ) bDataChanged |= lcl_PutScaleItem2( GetWhich(SID_SCATTR_PAGE_SCALETO), *rCoreSet, rOldSet, *m_pLbScaleMode, SC_TPTABLE_SCALE_TO, - *m_pEdScalePageWidth, *m_pEdScalePageHeight ); + *m_pEdScalePageWidth, m_nOrigScalePageWidth, + *m_pEdScalePageHeight, m_nOrigScalePageHeight ); bDataChanged |= lcl_PutScaleItem( GetWhich(SID_SCATTR_PAGE_SCALETOPAGES), *rCoreSet, rOldSet, @@ -393,6 +404,36 @@ IMPL_LINK_NOARG(ScTablePage, ScaleHdl, ListBox&, void) m_pBxScalePageNum->Show(m_pLbScaleMode->GetSelectedEntryPos() == SC_TPTABLE_SCALE_TO_PAGES); } +IMPL_LINK(ScTablePage, ToggleHdl, CheckBox&, rBox, void) +{ + if (&rBox == m_pCbScalePageWidth) + { + if (rBox.IsChecked()) + { + m_pEdScalePageWidth->SetText(OUString()); + m_pEdScalePageWidth->Disable(); + } + else + { + m_pEdScalePageWidth->SetValue(1); + m_pEdScalePageWidth->Enable(); + } + } + else + { + if (rBox.IsChecked()) + { + m_pEdScalePageHeight->SetText(OUString()); + m_pEdScalePageHeight->Disable(); + } + else + { + m_pEdScalePageHeight->SetValue(1); + m_pEdScalePageHeight->Enable(); + } + } +} + // Helper functions for FillItemSet: static bool lcl_PutBoolItem( sal_uInt16 nWhich, @@ -456,16 +497,18 @@ static bool lcl_PutScaleItem2( sal_uInt16 nWhich, SfxItemSet& rCoreSet, const SfxItemSet& rOldSet, const ListBox& rListBox, - sal_uInt16 nLBEntry, + sal_uInt16 nLBEntry, const NumericField& rEd1, - const NumericField& rEd2 ) + sal_uInt16 nOrigScalePageWidth, + const NumericField& rEd2, + sal_uInt16 nOrigScalePageHeight ) { - sal_uInt16 nValue1 = (sal_uInt16)rEd1.GetValue(); - sal_uInt16 nValue2 = (sal_uInt16)rEd2.GetValue(); + sal_uInt16 nValue1 = rEd1.IsEnabled() ? rEd1.GetValue() : 0; + sal_uInt16 nValue2 = rEd2.IsEnabled() ? rEd2.GetValue() : 0; bool bIsSel = (rListBox.GetSelectedEntryPos() == nLBEntry); bool bDataChanged = (rListBox.GetSavedValue() != nLBEntry) || - rEd1.IsValueChangedFromSaved() || - rEd2.IsValueChangedFromSaved() || + nValue1 != nOrigScalePageWidth || + nValue1 != nOrigScalePageHeight || !WAS_DEFAULT( nWhich, rOldSet ); if( bDataChanged ) |