From 9a745d54a5c7470180f41494283983a3b8b84a51 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 22 Apr 2016 15:22:03 +0200 Subject: tdf#89953 Character spacing: Allow to enter negative values without selecting from a condensed/expanded listbox first. Change-Id: I1111e6f1d7cdc6c0bc79d542f49c58f1022ad739 Reviewed-on: https://gerrit.libreoffice.org/24301 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- cui/source/inc/chardlg.hxx | 4 -- cui/source/tabpages/chardlg.cxx | 103 ++-------------------------------------- cui/uiconfig/ui/positionpage.ui | 66 ++++--------------------- 3 files changed, 12 insertions(+), 161 deletions(-) diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx index ed2fc5933021..bfa100cf5753 100644 --- a/cui/source/inc/chardlg.hxx +++ b/cui/source/inc/chardlg.hxx @@ -276,8 +276,6 @@ private: VclPtr m_pScaleWidthMF; - VclPtr m_pKerningLB; - VclPtr m_pKerningFT; VclPtr m_pKerningMF; VclPtr m_pPairKerningBtn; @@ -310,11 +308,9 @@ public: virtual ~SvxCharPositionPage(); virtual void dispose() override; - using SfxTabPage::ActivatePage; using SfxTabPage::DeactivatePage; virtual sfxpg DeactivatePage( SfxItemSet* pSet = nullptr ) override; - virtual void ActivatePage( const SfxItemSet& rSet ) override; public: static VclPtr Create( vcl::Window* pParent, const SfxItemSet* rSet ); diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index d0d76c1be32a..4f1cd066434c 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -80,10 +80,6 @@ using namespace ::com::sun::star; #define CLEARTITEM rSet.InvalidateItem(nWhich) -#define LW_NORMAL 0 -#define LW_EXPANDED 1 -#define LW_CONDENSED 2 - // static ---------------------------------------------------------------- const sal_uInt16 SvxCharNamePage::pNameRanges[] = @@ -2636,8 +2632,6 @@ SvxCharPositionPage::SvxCharPositionPage( vcl::Window* pParent, const SfxItemSet get(m_p270degRB, "270deg"); get(m_pFitToLineCB, "fittoline"); get(m_pScaleWidthMF, "scalewidthsb"); - get(m_pKerningLB, "kerninglb"); - get(m_pKerningFT, "kerningft"); get(m_pKerningMF, "kerningsb"); get(m_pPairKerningBtn, "pairkerning"); @@ -2669,8 +2663,6 @@ void SvxCharPositionPage::dispose() m_p270degRB.clear(); m_pFitToLineCB.clear(); m_pScaleWidthMF.clear(); - m_pKerningLB.clear(); - m_pKerningFT.clear(); m_pKerningMF.clear(); m_pPairKerningBtn.clear(); SvxCharBasePage::dispose(); @@ -2688,8 +2680,6 @@ void SvxCharPositionPage::Initialize() m_pNormalPosBtn->Check(); PositionHdl_Impl( m_pNormalPosBtn ); - m_pKerningLB->SelectEntryPos( 0 ); - KerningSelectHdl_Impl( *m_pKerningLB ); Link aLink2 = LINK( this, SvxCharPositionPage, PositionHdl_Impl ); m_pHighPosBtn->SetClickHdl( aLink2 ); @@ -2711,7 +2701,6 @@ void SvxCharPositionPage::Initialize() m_pHighLowRB->SetClickHdl( LINK( this, SvxCharPositionPage, AutoPositionHdl_Impl ) ); m_pFitToLineCB->SetClickHdl( LINK( this, SvxCharPositionPage, FitToLineHdl_Impl ) ); - m_pKerningLB->SetSelectHdl( LINK( this, SvxCharPositionPage, KerningSelectHdl_Impl ) ); m_pKerningMF->SetModifyHdl( LINK( this, SvxCharPositionPage, KerningModifyHdl_Impl ) ); m_pScaleWidthMF->SetModifyHdl( LINK( this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl ) ); } @@ -2830,48 +2819,12 @@ IMPL_LINK_TYPED( SvxCharPositionPage, FitToLineHdl_Impl, Button*, pBox, void ) } -IMPL_LINK_NOARG_TYPED(SvxCharPositionPage, KerningSelectHdl_Impl, ListBox&, void) -{ - if ( m_pKerningLB->GetSelectEntryPos() > LW_NORMAL ) - { - m_pKerningFT->Enable(); - m_pKerningMF->Enable(); - - if ( m_pKerningLB->GetSelectEntryPos() == LW_CONDENSED ) - { - // Condensed -> max value == 1/6 of the current font height - SvxFont& rFont = GetPreviewFont(); - long nMax = rFont.GetFontSize().Height() / 6; - m_pKerningMF->SetMax( m_pKerningMF->Normalize( nMax ), FUNIT_TWIP ); - m_pKerningMF->SetLast( m_pKerningMF->GetMax( m_pKerningMF->GetUnit() ) ); - } - else - { - m_pKerningMF->SetMax( 9999 ); - m_pKerningMF->SetLast( 9999 ); - } - } - else - { - m_pKerningMF->SetValue( 0 ); - m_pKerningFT->Disable(); - m_pKerningMF->Disable(); - } - - KerningModifyHdl_Impl( *m_pKerningMF ); -} - - IMPL_LINK_NOARG_TYPED(SvxCharPositionPage, KerningModifyHdl_Impl, Edit&, void) { long nVal = static_cast(m_pKerningMF->GetValue()); nVal = LogicToLogic( nVal, MAP_POINT, MAP_TWIP ); long nKern = (short)m_pKerningMF->Denormalize( nVal ); - // Condensed? -> then negative - if ( m_pKerningLB->GetSelectEntryPos() == LW_CONDENSED ) - nKern *= -1; - SvxFont& rFont = GetPreviewFont(); SvxFont& rCJKFont = GetPreviewCJKFont(); SvxFont& rCTLFont = GetPreviewCTLFont(); @@ -2912,25 +2865,6 @@ IMPL_LINK_NOARG_TYPED(SvxCharPositionPage, ScaleWidthModifyHdl_Impl, Edit&, void m_pPreviewWin->SetFontWidthScale( sal_uInt16( m_pScaleWidthMF->GetValue() ) ); } -void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet ) -{ - //update the preview - SvxCharBasePage::ActivatePage( rSet ); - - //the only thing that has to be checked is the max. allowed value for the - //condense edit field - if ( m_pKerningLB->GetSelectEntryPos() == LW_CONDENSED ) - { - // Condensed -> max value == 1/6 of the current font height - SvxFont& rFont = GetPreviewFont(); - long nMax = rFont.GetFontSize().Height() / 6; - long nKern = (short)m_pKerningMF->Denormalize( LogicToLogic( static_cast(m_pKerningMF->GetValue()), MAP_POINT, MAP_TWIP ) ); - m_pKerningMF->SetMax( m_pKerningMF->Normalize( nKern > nMax ? nKern : nMax ), FUNIT_TWIP ); - m_pKerningMF->SetLast( m_pKerningMF->GetMax( m_pKerningMF->GetUnit() ) ); - } -} - - SfxTabPage::sfxpg SvxCharPositionPage::DeactivatePage( SfxItemSet* _pSet ) { if ( _pSet ) @@ -3077,22 +3011,6 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) rCJKFont.SetFixKerning( (short)nKern ); rCTLFont.SetFixKerning( (short)nKern ); - if ( nKerning > 0 ) - { - m_pKerningLB->SelectEntryPos( LW_EXPANDED ); - } - else if ( nKerning < 0 ) - { - m_pKerningLB->SelectEntryPos( LW_CONDENSED ); - nKerning = -nKerning; - } - else - { - nKerning = 0; - m_pKerningLB->SelectEntryPos( LW_NORMAL ); - } - //enable/disable and set min/max of the Edit - KerningSelectHdl_Impl(*m_pKerningLB); //the attribute value must be displayed also if it's above the maximum allowed value long nVal = static_cast(m_pKerningMF->GetMax()); if(nVal < nKerning) @@ -3195,7 +3113,6 @@ void SvxCharPositionPage::ChangesApplied() m_p270degRB->SaveValue(); m_pFitToLineCB->SaveValue(); m_pScaleWidthMF->SaveValue(); - m_pKerningLB->SaveValue(); m_pKerningMF->SaveValue(); m_pPairKerningBtn->SaveValue(); } @@ -3254,19 +3171,12 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) // Kerning nWhich = GetWhich( SID_ATTR_CHAR_KERNING ); pOld = GetOldItem( *rSet, SID_ATTR_CHAR_KERNING ); - sal_Int32 nPos = m_pKerningLB->GetSelectEntryPos(); short nKerning = 0; SfxMapUnit eUnit = rSet->GetPool()->GetMetric( nWhich ); - if ( nPos == LW_EXPANDED || nPos == LW_CONDENSED ) - { - long nTmp = static_cast(m_pKerningMF->GetValue()); - long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit ); - nKerning = (short)m_pKerningMF->Denormalize( nVal ); - - if ( nPos == LW_CONDENSED ) - nKerning *= - 1; - } + long nTmp = static_cast(m_pKerningMF->GetValue()); + long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit ); + nKerning = (short)m_pKerningMF->Denormalize( nVal ); if ( pOld ) { @@ -3275,12 +3185,7 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) bChanged = false; } - if ( !bChanged && - ( m_pKerningLB->GetSavedValue() == LISTBOX_ENTRY_NOTFOUND || - ( m_pKerningMF->GetSavedValue().isEmpty() && m_pKerningMF->IsEnabled() ) ) ) - bChanged = true; - - if ( bChanged && nPos != LISTBOX_ENTRY_NOTFOUND ) + if ( bChanged ) { rSet->Put( SvxKerningItem( nKerning, nWhich ) ); bModified = true; diff --git a/cui/uiconfig/ui/positionpage.ui b/cui/uiconfig/ui/positionpage.ui index 22776edb2c96..86ab691dc896 100644 --- a/cui/uiconfig/ui/positionpage.ui +++ b/cui/uiconfig/ui/positionpage.ui @@ -1,8 +1,8 @@ - + - + 1 100 @@ -18,27 +18,11 @@ 10 - 999.89999999999998 + -2 + 1000 1 10 - - - - - - - - Default - - - Expanded - - - Condensed - - - True False @@ -134,16 +118,14 @@ True False - 0 Raise/lower by True raiselowersb:0% + 0 0 0 - 1 - 1 @@ -156,8 +138,6 @@ 1 0 - 1 - 1 @@ -170,8 +150,6 @@ 1 1 - 1 - 1 @@ -186,24 +164,20 @@ 2 0 - 1 - 1 True False - 0 Relative font size True fontsizesb:0% + 0 0 1 - 1 - 1 @@ -435,30 +409,6 @@ True False 12 - - - True - False - liststore1 - - - False - True - 0 - - - - - True - False - by - - - False - True - 1 - - True @@ -470,7 +420,7 @@ False True - 2 + 0 @@ -485,7 +435,7 @@ False True - 3 + 1 -- cgit v1.2.3