From bdd7c74a499ea550a10e47d159c2d2d80c940fc0 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 26 Oct 2017 12:49:44 +0100 Subject: Resolves: tdf#113455 Impossible to clear width/height in pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I88f80d417108822ceeb73c07cb49892925a2e57f Reviewed-on: https://gerrit.libreoffice.org/43891 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sc/source/ui/inc/tptable.hxx | 8 ++- sc/source/ui/pagedlg/tptable.cxx | 77 +++++++++++++++++++++------ sc/uiconfig/scalc/ui/sheetprintpage.ui | 95 +++++++++++++--------------------- 3 files changed, 103 insertions(+), 77 deletions(-) (limited to 'sc') 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 m_pBtnTopDown; VclPtr m_pBtnLeftRight; VclPtr m_pBmpPageDir; @@ -66,7 +69,9 @@ private: VclPtr m_pEdScaleAll; VclPtr m_pGrHeightWidth; VclPtr m_pEdScalePageWidth; + VclPtr m_pCbScalePageWidth; VclPtr m_pEdScalePageHeight; + VclPtr m_pCbScalePageHeight; VclPtr m_pBxScalePageNum; VclPtr 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 ) diff --git a/sc/uiconfig/scalc/ui/sheetprintpage.ui b/sc/uiconfig/scalc/ui/sheetprintpage.ui index 83330ca7f31c..4daeadf15309 100644 --- a/sc/uiconfig/scalc/ui/sheetprintpage.ui +++ b/sc/uiconfig/scalc/ui/sheetprintpage.ui @@ -1,6 +1,7 @@ + - + 1.05 9999.0400000000009 @@ -72,8 +73,6 @@ 0 0 - 1 - 1 @@ -93,8 +92,6 @@ 0 1 - 1 - 1 @@ -110,8 +107,6 @@ 0 2 - 1 - 1 @@ -125,8 +120,6 @@ 1 2 - 1 - 1 @@ -176,8 +169,6 @@ 0 0 - 1 - 1 @@ -213,8 +204,6 @@ 0 0 - 1 - 1 @@ -231,8 +220,6 @@ 0 1 - 1 - 1 @@ -248,8 +235,6 @@ 0 2 - 1 - 1 @@ -265,8 +250,6 @@ 0 3 - 1 - 1 @@ -282,8 +265,6 @@ 2 0 - 1 - 1 @@ -299,8 +280,6 @@ 2 1 - 1 - 1 @@ -316,8 +295,6 @@ 2 2 - 1 - 1 @@ -333,8 +310,6 @@ 2 3 - 1 - 1 @@ -367,8 +342,6 @@ 0 1 - 1 - 1 @@ -392,16 +365,14 @@ True False - 0 Scaling _mode: True comboLB_SCALEMODE + 0 0 0 - 1 - 1 @@ -419,10 +390,10 @@ True False - 0 _Scaling factor: True spinED_SCALEALL:0% + 0 False @@ -435,7 +406,6 @@ True True - True adjustmentScalingFactor @@ -462,32 +432,28 @@ True False - 0 _Width in pages: True spinED_SCALEPAGEWIDTH + 0 0 0 - 1 - 1 True False - 0 _Height in pages: True spinED_SCALEPAGEHEIGHT + 0 0 1 - 1 - 1 @@ -496,14 +462,11 @@ True none - True adjustmentPage 1 0 - 1 - 1 @@ -511,14 +474,37 @@ True True - True adjustmentPage 1 1 - 1 - 1 + + + + + Unspecified + True + True + False + True + + + 2 + 0 + + + + + Unspecified + True + True + False + True + + + 2 + 1 @@ -537,10 +523,10 @@ True False - 0 N_umber of pages: True spinED_SCALEPAGENUM + 0 False @@ -553,7 +539,6 @@ True True - True adjustmentPage if-valid @@ -574,19 +559,12 @@ 1 1 - 1 - 1 - - - True False - 0 - 1 Reduce/enlarge printout Fit print range(s) to width/height @@ -596,10 +574,11 @@ 1 0 - 1 - 1 + + + @@ -618,8 +597,6 @@ 0 2 - 1 - 1 -- cgit