tdf#127802 support tristate for hidden/unhidden text
Change-Id: I9a8ad72ae3ee45ac2521e662b17d3d22d98aa055
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101325
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx
index e84ea0f..fe8255c 100644
--- a/cui/source/inc/chardlg.hxx
+++ b/cui/source/inc/chardlg.hxx
@@ -167,6 +167,11 @@ private:
Color m_aOrigFontColor;
sal_uInt16 m_nHtmlMode;
weld::TriStateEnabled m_aOutlineState;
weld::TriStateEnabled m_aShadowState;
weld::TriStateEnabled m_aHiddenState;
weld::TriStateEnabled m_aIndividualWordsState;
std::unique_ptr<weld::Label> m_xFontColorFT;
std::unique_ptr<ColorListBox> m_xFontColorLB;
std::unique_ptr<weld::Label> m_xFontTransparencyFT;
@@ -202,8 +207,10 @@ private:
void SelectHdl_Impl(const weld::ComboBox*);
DECL_LINK(SelectListBoxHdl_Impl, weld::ComboBox&, void);
DECL_LINK(OutlineBtnClickHdl, weld::ToggleButton&, void);
DECL_LINK(ShadowBtnClickHdl, weld::ToggleButton&, void);
DECL_LINK(HiddenBtnClickHdl, weld::ToggleButton&, void);
DECL_LINK(CbClickHdl_Impl, weld::ToggleButton&, void);
DECL_LINK(TristClickHdl_Impl, weld::ToggleButton&, void);
DECL_LINK(ColorBoxSelectHdl_Impl, ColorListBox&, void);
DECL_LINK(ModifyFontTransparencyHdl_Impl, weld::MetricSpinButton&, void);
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 8c7cef3..0b498f4 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -1408,10 +1408,10 @@ void SvxCharEffectsPage::Initialize()
m_xEffectsLB->set_active( 0 );
m_xHiddenBtn->connect_toggled(LINK(this, SvxCharEffectsPage, HiddenBtnClickHdl));
m_xIndividualWordsBtn->connect_toggled(LINK(this, SvxCharEffectsPage, CbClickHdl_Impl));
Link<weld::ToggleButton&,void> aLink2 = LINK(this, SvxCharEffectsPage, TristClickHdl_Impl);
m_xOutlineBtn->connect_toggled(aLink2);
m_xShadowBtn->connect_toggled(aLink2);
m_xOutlineBtn->connect_toggled(LINK(this, SvxCharEffectsPage, OutlineBtnClickHdl));
m_xShadowBtn->connect_toggled(LINK(this, SvxCharEffectsPage, ShadowBtnClickHdl));
if ( !SvtLanguageOptions().IsAsianTypographyEnabled() )
{
@@ -1487,7 +1487,7 @@ void SvxCharEffectsPage::UpdatePreview_Impl()
rCTLFont.SetCaseMap( eCaps == SvxCaseMap::SmallCaps ? SvxCaseMap::NotMapped : eCaps );
}
bool bWordLine = m_xIndividualWordsBtn->get_active();
bool bWordLine = StateToAttr( m_xIndividualWordsBtn->get_state() );
rFont.SetWordLineMode( bWordLine );
rCJKFont.SetWordLineMode( bWordLine );
rCTLFont.SetWordLineMode( bWordLine );
@@ -1643,13 +1643,10 @@ void SvxCharEffectsPage::SelectHdl_Impl(const weld::ComboBox* pBox)
UpdatePreview_Impl();
}
IMPL_LINK_NOARG(SvxCharEffectsPage, CbClickHdl_Impl, weld::ToggleButton&, void)
IMPL_LINK(SvxCharEffectsPage, CbClickHdl_Impl, weld::ToggleButton&, rToggle, void)
{
m_aIndividualWordsState.ButtonToggled(rToggle);
UpdatePreview_Impl();
}
IMPL_LINK_NOARG(SvxCharEffectsPage, TristClickHdl_Impl, weld::ToggleButton&, void)
{
UpdatePreview_Impl();
}
@@ -1805,15 +1802,18 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet )
switch ( eState )
{
case SfxItemState::UNKNOWN:
m_aIndividualWordsState.bTriStateEnabled = false;
m_xIndividualWordsBtn->hide();
break;
case SfxItemState::DISABLED:
case SfxItemState::READONLY:
m_aIndividualWordsState.bTriStateEnabled = false;
m_xIndividualWordsBtn->set_sensitive(false);
break;
case SfxItemState::DONTCARE:
m_aIndividualWordsState.bTriStateEnabled = true;
m_xIndividualWordsBtn->set_state( TRISTATE_INDET );
break;
@@ -1825,6 +1825,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet )
rCJKFont.SetWordLineMode( rItem.GetValue() );
rCTLFont.SetWordLineMode( rItem.GetValue() );
m_aIndividualWordsState.bTriStateEnabled = false;
m_xIndividualWordsBtn->set_active(rItem.GetValue());
m_xIndividualWordsBtn->set_sensitive(bEnable);
break;
@@ -1939,15 +1940,18 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet )
switch ( eState )
{
case SfxItemState::UNKNOWN:
m_aOutlineState.bTriStateEnabled = false;
m_xOutlineBtn->hide();
break;
case SfxItemState::DISABLED:
case SfxItemState::READONLY:
m_aOutlineState.bTriStateEnabled = false;
m_xOutlineBtn->set_sensitive(false);
break;
case SfxItemState::DONTCARE:
m_aOutlineState.bTriStateEnabled = true;
m_xOutlineBtn->set_state(TRISTATE_INDET);
break;
@@ -1955,6 +1959,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet )
case SfxItemState::SET:
{
const SvxContourItem& rItem = static_cast<const SvxContourItem&>(rSet->Get( nWhich ));
m_aOutlineState.bTriStateEnabled = false;
m_xOutlineBtn->set_state(static_cast<TriState>(rItem.GetValue()));
break;
}
@@ -1967,15 +1972,18 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet )
switch ( eState )
{
case SfxItemState::UNKNOWN:
m_aShadowState.bTriStateEnabled = false;
m_xShadowBtn->hide();
break;
case SfxItemState::DISABLED:
case SfxItemState::READONLY:
m_aShadowState.bTriStateEnabled = false;
m_xShadowBtn->set_sensitive(false);
break;
case SfxItemState::DONTCARE:
m_aShadowState.bTriStateEnabled = true;
m_xShadowBtn->set_state( TRISTATE_INDET );
break;
@@ -1983,6 +1991,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet )
case SfxItemState::SET:
{
const SvxShadowedItem& rItem = static_cast<const SvxShadowedItem&>(rSet->Get( nWhich ));
m_aShadowState.bTriStateEnabled = false;
m_xShadowBtn->set_state( static_cast<TriState>(rItem.GetValue()) );
break;
}
@@ -1995,15 +2004,18 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet )
switch ( eState )
{
case SfxItemState::UNKNOWN:
m_aHiddenState.bTriStateEnabled = false;
m_xHiddenBtn->hide();
break;
case SfxItemState::DISABLED:
case SfxItemState::READONLY:
m_aHiddenState.bTriStateEnabled = false;
m_xHiddenBtn->set_sensitive(false);
break;
case SfxItemState::DONTCARE:
m_aHiddenState.bTriStateEnabled = true;
m_xHiddenBtn->set_state(TRISTATE_INDET);
break;
@@ -2011,6 +2023,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet )
case SfxItemState::SET:
{
const SvxCharHiddenItem& rItem = static_cast<const SvxCharHiddenItem&>(rSet->Get( nWhich ));
m_aHiddenState.bTriStateEnabled = false;
m_xHiddenBtn->set_state(static_cast<TriState>(rItem.GetValue()));
break;
}
@@ -2026,6 +2039,23 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet )
ChangesApplied();
}
IMPL_LINK(SvxCharEffectsPage, HiddenBtnClickHdl, weld::ToggleButton&, rToggle, void)
{
m_aHiddenState.ButtonToggled(rToggle);
}
IMPL_LINK(SvxCharEffectsPage, OutlineBtnClickHdl, weld::ToggleButton&, rToggle, void)
{
m_aOutlineState.ButtonToggled(rToggle);
UpdatePreview_Impl();
}
IMPL_LINK(SvxCharEffectsPage, ShadowBtnClickHdl, weld::ToggleButton&, rToggle, void)
{
m_aShadowState.ButtonToggled(rToggle);
UpdatePreview_Impl();
}
void SvxCharEffectsPage::ChangesApplied()
{
m_xUnderlineLB->save_value();
@@ -2149,23 +2179,26 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet )
bChanged = true;
// Individual words
const SfxItemSet* pExampleSet = GetDialogExampleSet();
nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
pOld = GetOldItem( *rSet, SID_ATTR_CHAR_WORDLINEMODE );
TriState eState = m_xIndividualWordsBtn->get_state();
const SfxPoolItem* pItem;
if ( pOld )
{
const SvxWordLineModeItem& rItem = *static_cast<const SvxWordLineModeItem*>(pOld);
if ( rItem.GetValue() == m_xIndividualWordsBtn->get_active() )
if ( rItem.GetValue() == StateToAttr( eState ) && m_xIndividualWordsBtn->get_saved_state() == eState )
bChanged = false;
}
if ( rOldSet.GetItemState( nWhich ) == SfxItemState::DONTCARE &&
! m_xIndividualWordsBtn->get_state_changed_from_saved() )
bChanged = false;
if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
!StateToAttr( eState ) && static_cast<const SvxWordLineModeItem*>(pItem)->GetValue() )
bChanged = true;
if ( bChanged )
if ( bChanged && eState != TRISTATE_INDET )
{
rSet->Put( SvxWordLineModeItem( m_xIndividualWordsBtn->get_active(), nWhich ) );
rSet->Put( SvxWordLineModeItem( StateToAttr( eState ), nWhich ) );
bModified = true;
}
else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
@@ -2258,11 +2291,9 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet )
}
// Outline
const SfxItemSet* pExampleSet = GetDialogExampleSet();
nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
pOld = GetOldItem( *rSet, SID_ATTR_CHAR_CONTOUR );
TriState eState = m_xOutlineBtn->get_state();
const SfxPoolItem* pItem;
eState = m_xOutlineBtn->get_state();
if ( pOld )
{