diff options
author | Jim Raykowski <raykowj@gmail.com> | 2017-11-18 22:21:24 -0900 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-01-26 08:10:20 +0100 |
commit | 122da2eea23faf6916c3f3b9e1895f5c404b26c7 (patch) | |
tree | 8e817bf22bb392d13c7b53948fc166da23579ce0 | |
parent | 674b67ab7d92097089000fcd70c7abd84e180220 (diff) |
tdf#107567 et al. Paragraph dialog preview windows fixes
tdf#107567 tdf#98211 tdf#98212 tdf#113275
Change-Id: I6d11cb809283eee4fa79acae9aa32baaab558833
Reviewed-on: https://gerrit.libreoffice.org/45273
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r-- | cui/source/inc/paragrph.hxx | 4 | ||||
-rw-r--r-- | cui/source/tabpages/paragrph.cxx | 184 |
2 files changed, 113 insertions, 75 deletions
diff --git a/cui/source/inc/paragrph.hxx b/cui/source/inc/paragrph.hxx index 2060cd224064..bc79add8c31c 100644 --- a/cui/source/inc/paragrph.hxx +++ b/cui/source/inc/paragrph.hxx @@ -46,6 +46,7 @@ class SvxLineSpacingItem; class SvxStdParagraphTabPage: public SfxTabPage { friend class VclPtr<SvxStdParagraphTabPage>; + using TabPage::ActivatePage; using TabPage::DeactivatePage; static const sal_uInt16 pStdRanges[]; @@ -94,6 +95,7 @@ private: DECL_LINK( AutoHdl_Impl, Button*, void ); protected: + virtual void ActivatePage( const SfxItemSet& rSet ) override; virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; @@ -124,6 +126,7 @@ public: class SvxParaAlignTabPage : public SfxTabPage { friend class VclPtr<SvxParaAlignTabPage>; + using TabPage::ActivatePage; using TabPage::DeactivatePage; static const sal_uInt16 pAlignRanges[]; @@ -159,6 +162,7 @@ class SvxParaAlignTabPage : public SfxTabPage SvxParaAlignTabPage( vcl::Window* pParent, const SfxItemSet& rSet ); protected: + virtual void ActivatePage( const SfxItemSet& rSet ) override; virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; public: diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index 5ea77cf288e1..61cdb6603321 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -617,6 +617,43 @@ void SvxStdParagraphTabPage::EnableRelativeMode() bRelativeMode = true; } +void SvxStdParagraphTabPage::ActivatePage( const SfxItemSet& rSet ) +{ + sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST ); + SfxItemState eItemState = rSet.GetItemState( _nWhich ); + + if ( eItemState >= SfxItemState::DEFAULT ) + { + const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>( rSet.Get( _nWhich ) ); + SvxAdjust eAdjust = rAdj.GetAdjust(); + if ( eAdjust == SvxAdjust::Center || eAdjust == SvxAdjust::Block ) + { + _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION ); + eItemState = rSet.GetItemState( _nWhich ); + + if ( eItemState >= SfxItemState::DEFAULT ) + { + const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet.Get( _nWhich ) ); + SvxFrameDirection eFrameDirection = rFrameDirItem.GetValue(); + + m_pExampleWin->EnableRTL( SvxFrameDirection::Horizontal_RL_TB == eFrameDirection ); + + if ( eAdjust == SvxAdjust::Block ) + m_pExampleWin->SetLastLine( rAdj.GetLastBlock() ); + } + } + else + { + m_pExampleWin->EnableRTL( eAdjust == SvxAdjust::Right ); + eAdjust = SvxAdjust::Left; //required for correct preview display + m_pExampleWin->SetLastLine( eAdjust ); + } + m_pExampleWin->SetAdjust( eAdjust ); + + UpdateExample_Impl(); + } +} + DeactivateRC SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet ) { ELRLoseFocusHdl( *m_pFLineIndent ); @@ -1002,6 +1039,8 @@ SvxParaAlignTabPage::SvxParaAlignTabPage( vcl::Window* pParent, const SfxItemSet get(m_pPropertiesFL,"framePROPERTIES"); get(m_pTextDirectionLB,"comboLB_TEXTDIRECTION"); + SetExchangeSupport(); + SvtLanguageOptions aLangOptions; sal_uInt16 nLastLinePos = LASTLINEPOS_DEFAULT; @@ -1083,69 +1122,35 @@ bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet ) { bool bModified = false; - bool bAdj = false, bChecked = false; SvxAdjust eAdjust = SvxAdjust::Left; if ( m_pLeft->IsChecked() ) - { eAdjust = SvxAdjust::Left; - bAdj = !m_pLeft->GetSavedValue(); - bChecked = true; - } else if ( m_pRight->IsChecked() ) - { eAdjust = SvxAdjust::Right; - bAdj = !m_pRight->GetSavedValue(); - bChecked = true; - } else if ( m_pCenter->IsChecked() ) - { eAdjust = SvxAdjust::Center; - bAdj = !m_pCenter->GetSavedValue(); - bChecked = true; - } else if ( m_pJustify->IsChecked() ) - { eAdjust = SvxAdjust::Block; - bAdj = !m_pJustify->GetSavedValue() || - m_pExpandCB->IsValueChangedFromSaved() || - m_pLastLineLB->IsValueChangedFromSaved(); - bChecked = true; - } - sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST ); - - if ( bAdj ) - { - const SvxAdjustItem* pOld = static_cast<const SvxAdjustItem*>(GetOldItem( *rOutSet, SID_ATTR_PARA_ADJUST )); - SvxAdjust eOneWord = m_pExpandCB->IsChecked() ? SvxAdjust::Block : SvxAdjust::Left; + sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST ); - sal_Int32 nLBPos = m_pLastLineLB->GetSelectedEntryPos(); - SvxAdjust eLastBlock = SvxAdjust::Left; + SvxAdjust eOneWord = m_pExpandCB->IsChecked() ? SvxAdjust::Block : SvxAdjust::Left; - if ( 1 == nLBPos ) - eLastBlock = SvxAdjust::Center; - else if ( 2 == nLBPos ) - eLastBlock = SvxAdjust::Block; + sal_Int32 nLBPos = m_pLastLineLB->GetSelectedEntryPos(); + SvxAdjust eLastBlock = SvxAdjust::Left; + if ( 1 == nLBPos ) + eLastBlock = SvxAdjust::Center; + else if ( 2 == nLBPos ) + eLastBlock = SvxAdjust::Block; - bool bNothingWasChecked = - !m_pLeft->GetSavedValue() && !m_pRight->GetSavedValue() && - !m_pCenter->GetSavedValue() && !m_pJustify->GetSavedValue(); + SvxAdjustItem aAdj( static_cast<const SvxAdjustItem&>(GetItemSet().Get( _nWhich )) ); + aAdj.SetAdjust( eAdjust ); + aAdj.SetOneWord( eOneWord ); + aAdj.SetLastBlock( eLastBlock ); + rOutSet->Put( aAdj ); + bModified = true; - if ( !pOld || pOld->GetAdjust() != eAdjust || - pOld->GetOneWord() != eOneWord || - pOld->GetLastBlock() != eLastBlock || - ( bChecked && bNothingWasChecked ) ) - { - bModified = true; - SvxAdjustItem aAdj( - static_cast<const SvxAdjustItem&>(GetItemSet().Get( _nWhich )) ); - aAdj.SetAdjust( eAdjust ); - aAdj.SetOneWord( eOneWord ); - aAdj.SetLastBlock( eLastBlock ); - rOutSet->Put( aAdj ); - } - } if(m_pSnapToGridCB->IsValueChangedFromSaved()) { rOutSet->Put(SvxParaGridItem(m_pSnapToGridCB->IsChecked(), GetWhich( SID_ATTR_PARA_SNAPTOGRID ))); @@ -1159,9 +1164,9 @@ bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet ) if( m_pTextDirectionLB->IsVisible() ) { - SvxFrameDirection eDir = m_pTextDirectionLB->GetSelectEntryValue(); if( m_pTextDirectionLB->IsValueChangedFromSaved() ) { + SvxFrameDirection eDir = m_pTextDirectionLB->GetSelectEntryValue(); rOutSet->Put( SvxFrameDirectionItem( eDir, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) ); bModified = true; } @@ -1169,6 +1174,12 @@ bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet ) return bModified; } + +void SvxParaAlignTabPage::ActivatePage( const SfxItemSet& rSet ) +{ + Reset( &rSet ); +} + void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet ) { sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST ); @@ -1285,6 +1296,12 @@ IMPL_LINK_NOARG(SvxParaAlignTabPage, AlignHdl_Impl, Button*, void) m_pLastLineLB->Enable(bJustify); bool bLastLineIsBlock = m_pLastLineLB->GetSelectedEntryPos() == 2; m_pExpandCB->Enable(bJustify && bLastLineIsBlock); + //set last line listbox to entry position 0 if not enabled + if(!m_pLastLineLB->IsEnabled()) + m_pLastLineLB->SelectEntryPos(0); + //uncheck 'Expand ... word' when check box is not enabled + if(!m_pExpandCB->IsEnabled()) + m_pExpandCB->Check(false); UpdateExample_Impl(); } @@ -1293,46 +1310,63 @@ IMPL_LINK_NOARG(SvxParaAlignTabPage, LastLineHdl_Impl, ListBox&, void) //fdo#41350 only enable 'Expand last word' if last line is also justified bool bLastLineIsBlock = m_pLastLineLB->GetSelectedEntryPos() == 2; m_pExpandCB->Enable(bLastLineIsBlock); + //uncheck 'Expand ... word' when check box is not enabled + if(!m_pExpandCB->IsEnabled()) + m_pExpandCB->Check(false); UpdateExample_Impl(); } IMPL_LINK_NOARG(SvxParaAlignTabPage, TextDirectionHdl_Impl, ListBox&, void) { - SvxFrameDirection eDir = m_pTextDirectionLB->GetSelectEntryValue(); - switch ( eDir ) - { - // check the default alignment for this text direction - case SvxFrameDirection::Horizontal_LR_TB : m_pLeft->Check(); break; - case SvxFrameDirection::Horizontal_RL_TB : m_pRight->Check(); break; - case SvxFrameDirection::Environment : /* do nothing */ break; - default: - { - SAL_WARN( "cui.tabpages", "SvxParaAlignTabPage::TextDirectionHdl_Impl(): other directions not supported" ); - } - } UpdateExample_Impl(); } void SvxParaAlignTabPage::UpdateExample_Impl() { if ( m_pLeft->IsChecked() ) + { + m_pExampleWin->EnableRTL( false ); m_pExampleWin->SetAdjust( SvxAdjust::Left ); + m_pExampleWin->SetLastLine( SvxAdjust::Left ); + } else if ( m_pRight->IsChecked() ) - m_pExampleWin->SetAdjust( SvxAdjust::Right ); - else if ( m_pCenter->IsChecked() ) - m_pExampleWin->SetAdjust( SvxAdjust::Center ); - else if ( m_pJustify->IsChecked() ) { - m_pExampleWin->SetAdjust( SvxAdjust::Block ); - SvxAdjust eLastBlock = SvxAdjust::Left; - sal_Int32 nLBPos = m_pLastLineLB->GetSelectedEntryPos(); - if(nLBPos == 0 && m_pTextDirectionLB->GetSelectEntryValue() == SvxFrameDirection::Horizontal_RL_TB) - eLastBlock = SvxAdjust::Right; - else if(nLBPos == 1) - eLastBlock = SvxAdjust::Center; - else if(nLBPos == 2) - eLastBlock = SvxAdjust::Block; - m_pExampleWin->SetLastLine( eLastBlock ); + m_pExampleWin->EnableRTL( true ); + m_pExampleWin->SetAdjust( SvxAdjust::Left ); + m_pExampleWin->SetLastLine( SvxAdjust::Left ); + } + else + { + SvxFrameDirection eDir = m_pTextDirectionLB->GetSelectEntryValue(); + switch ( eDir ) + { + case SvxFrameDirection::Environment : + if ( !m_pRight->IsChecked() ) + m_pExampleWin->EnableRTL( IsRTLEnabled() /*false*/ ); + break; + case SvxFrameDirection::Horizontal_RL_TB : + if ( !m_pLeft->IsChecked() ) + m_pExampleWin->EnableRTL( true ); + break; + case SvxFrameDirection::Horizontal_LR_TB : + if ( !m_pRight->IsChecked() ) + m_pExampleWin->EnableRTL( false ); + break; + default: ; //prevent warning + } + if ( m_pCenter->IsChecked() ) + m_pExampleWin->SetAdjust( SvxAdjust::Center ); + else if ( m_pJustify->IsChecked() ) + { + m_pExampleWin->SetAdjust( SvxAdjust::Block ); + sal_Int32 nLBPos = m_pLastLineLB->GetSelectedEntryPos(); + if(nLBPos == 0) + m_pExampleWin->SetLastLine(SvxAdjust::Left); + else if(nLBPos == 1) + m_pExampleWin->SetLastLine(SvxAdjust::Center); + else if(nLBPos == 2) + m_pExampleWin->SetLastLine(SvxAdjust::Block); + } } m_pExampleWin->Invalidate(); |