diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-10-28 13:37:33 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-11-04 17:14:26 +0000 |
commit | 43bc3031483d172eccd72c3804e2d4fc2ef37de4 (patch) | |
tree | 991d98e8e61fae47ada28ba7a0b02e1d6c8e443f /sw/source/ui/config | |
parent | 44523738f094ff3987e85ea0c47b8c636bbe5786 (diff) |
unify color selectors
Note: this removes the use of auto-color from writer's asian text grid, because
its always invisible as far as I can see in practice.
Change-Id: Ie850790d740a4d56c43015e493e093678cef3b4e
Diffstat (limited to 'sw/source/ui/config')
-rw-r--r-- | sw/source/ui/config/optpage.cxx | 240 |
1 files changed, 68 insertions, 172 deletions
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index c599a6ed3e0f..e4c17d0ec431 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -1730,20 +1730,22 @@ SwRedlineOptionsTabPage::SwRedlineOptionsTabPage( vcl::Window* pParent, const SfxItemSet& rSet ) : SfxTabPage(pParent, "OptRedLinePage", "modules/swriter/ui/optredlinepage.ui" , &rSet) - , sNone(SW_RESSTR(SW_STR_NONE)) { Size aPreviewSize(getPreviewOptionsSize(this)); get(pInsertLB,"insert"); get(pInsertColorLB,"insertcolor"); + pInsertColorLB->SetSlotId(SID_AUTHOR_COLOR, true); get(pInsertedPreviewWN,"insertedpreview"); get(pDeletedLB,"deleted"); get(pDeletedColorLB,"deletedcolor"); + pDeletedColorLB->SetSlotId(SID_AUTHOR_COLOR, true); get(pDeletedPreviewWN,"deletedpreview"); get(pChangedLB,"changed"); get(pChangedColorLB,"changedcolor"); + pChangedColorLB->SetSlotId(SID_AUTHOR_COLOR, true); get(pChangedPreviewWN,"changedpreview"); get(pMarkPosLB,"markpos"); @@ -1760,8 +1762,6 @@ SwRedlineOptionsTabPage::SwRedlineOptionsTabPage( vcl::Window* pParent, pChangedPreviewWN->set_width_request(aPreviewSize.Width()); pMarkPreviewWN->set_width_request(aPreviewSize.Width()); - sAuthor = get<vcl::Window>("byauthor")->GetText(); - for (sal_Int32 i = 0; i < pInsertLB->GetEntryCount(); ++i) { const OUString sEntry(pInsertLB->GetEntry(i)); @@ -1781,14 +1781,13 @@ SwRedlineOptionsTabPage::SwRedlineOptionsTabPage( vcl::Window* pParent, pDeletedLB->SetSelectHdl( aLk ); pChangedLB->SetSelectHdl( aLk ); - aLk = LINK(this, SwRedlineOptionsTabPage, ColorHdl); - pInsertColorLB->SetSelectHdl( aLk ); - pDeletedColorLB->SetSelectHdl( aLk ); - pChangedColorLB->SetSelectHdl( aLk ); + Link<SvxColorListBox&,void> aLk2 = LINK(this, SwRedlineOptionsTabPage, ColorHdl); + pInsertColorLB->SetSelectHdl( aLk2 ); + pDeletedColorLB->SetSelectHdl( aLk2 ); + pChangedColorLB->SetSelectHdl( aLk2 ); - aLk = LINK(this, SwRedlineOptionsTabPage, ChangedMaskPrevHdl); - pMarkPosLB->SetSelectHdl( aLk ); - pMarkColorLB->SetSelectHdl( aLk ); + pMarkPosLB->SetSelectHdl(LINK(this, SwRedlineOptionsTabPage, ChangedMaskPrevHdl)); + pMarkColorLB->SetSelectHdl(LINK(this, SwRedlineOptionsTabPage, ChangedMaskColorPrevHdl)); } SwRedlineOptionsTabPage::~SwRedlineOptionsTabPage() @@ -1840,23 +1839,7 @@ bool SwRedlineOptionsTabPage::FillItemSet( SfxItemSet* ) pAttr = static_cast<CharAttr *>(pInsertLB->GetEntryData(nPos)); aInsertedAttr.nItemId = pAttr->nItemId; aInsertedAttr.nAttr = pAttr->nAttr; - - nPos = pInsertColorLB->GetSelectEntryPos(); - - switch (nPos) - { - case 0: - aInsertedAttr.nColor = COL_NONE_COLOR; - break; - case 1: - case LISTBOX_ENTRY_NOTFOUND: - aInsertedAttr.nColor = COL_TRANSPARENT; - break; - default: - aInsertedAttr.nColor = pInsertColorLB->GetEntryColor(nPos).GetColor(); - break; - } - + aInsertedAttr.nColor = pInsertColorLB->GetSelectEntryColor().GetColor(); pOpt->SetInsertAuthorAttr(aInsertedAttr); } @@ -1866,23 +1849,7 @@ bool SwRedlineOptionsTabPage::FillItemSet( SfxItemSet* ) pAttr = static_cast<CharAttr *>(pDeletedLB->GetEntryData(nPos)); aDeletedAttr.nItemId = pAttr->nItemId; aDeletedAttr.nAttr = pAttr->nAttr; - - nPos = pDeletedColorLB->GetSelectEntryPos(); - - switch (nPos) - { - case 0: - aDeletedAttr.nColor = COL_NONE_COLOR; - break; - case 1: - case LISTBOX_ENTRY_NOTFOUND: - aDeletedAttr.nColor = COL_TRANSPARENT; - break; - default: - aDeletedAttr.nColor = pDeletedColorLB->GetEntryColor(nPos).GetColor(); - break; - } - + aDeletedAttr.nColor = pDeletedColorLB->GetSelectEntryColor().GetColor(); pOpt->SetDeletedAuthorAttr(aDeletedAttr); } @@ -1892,23 +1859,7 @@ bool SwRedlineOptionsTabPage::FillItemSet( SfxItemSet* ) pAttr = static_cast<CharAttr *>(pChangedLB->GetEntryData(nPos)); aChangedAttr.nItemId = pAttr->nItemId; aChangedAttr.nAttr = pAttr->nAttr; - - nPos = pChangedColorLB->GetSelectEntryPos(); - - switch (nPos) - { - case 0: - aChangedAttr.nColor = COL_NONE_COLOR; - break; - case 1: - case LISTBOX_ENTRY_NOTFOUND: - aChangedAttr.nColor = COL_TRANSPARENT; - break; - default: - aChangedAttr.nColor = pChangedColorLB->GetEntryColor(nPos).GetColor(); - break; - } - + aChangedAttr.nColor = pChangedColorLB->GetSelectEntryColor().GetColor(); pOpt->SetFormatAuthorAttr(aChangedAttr); } @@ -1957,77 +1908,14 @@ void SwRedlineOptionsTabPage::Reset( const SfxItemSet* ) InitFontStyle(*pDeletedPreviewWN); InitFontStyle(*pChangedPreviewWN); - // initialise colour list box - pInsertColorLB->SetUpdateMode(false); - pDeletedColorLB->SetUpdateMode(false); - pChangedColorLB->SetUpdateMode(false); - pMarkColorLB->SetUpdateMode(false); - pInsertColorLB->InsertEntry(sNone); - pDeletedColorLB->InsertEntry(sNone); - pChangedColorLB->InsertEntry(sNone); - - pInsertColorLB->InsertEntry(sAuthor); - pDeletedColorLB->InsertEntry(sAuthor); - pChangedColorLB->InsertEntry(sAuthor); - - XColorListRef pColorLst = XColorList::GetStdColorList(); - for( long i = 0; i < pColorLst->Count(); ++i ) - { - const XColorEntry* pEntry = pColorLst->GetColor(i); - Color aColor = pEntry->GetColor(); - const OUString sName = pEntry->GetName(); - - pInsertColorLB->InsertEntry( aColor, sName ); - pDeletedColorLB->InsertEntry( aColor, sName ); - pChangedColorLB->InsertEntry( aColor, sName ); - pMarkColorLB->InsertEntry( aColor, sName ); - } - pInsertColorLB->SetUpdateMode( true ); - pDeletedColorLB->SetUpdateMode( true ); - pChangedColorLB->SetUpdateMode( true ); - pMarkColorLB->SetUpdateMode( true ); - ColorData nColor = rInsertAttr.nColor; - - switch (nColor) - { - case COL_TRANSPARENT: - pInsertColorLB->SelectEntryPos(1); - break; - case COL_NONE_COLOR: - pInsertColorLB->SelectEntryPos(0); - break; - default: - pInsertColorLB->SelectEntry(Color(nColor)); - } + pInsertColorLB->SelectEntry(Color(nColor)); nColor = rDeletedAttr.nColor; - - switch (nColor) - { - case COL_TRANSPARENT: - pDeletedColorLB->SelectEntryPos(1); - break; - case COL_NONE_COLOR: - pDeletedColorLB->SelectEntryPos(0); - break; - default: - pDeletedColorLB->SelectEntry(Color(nColor)); - } + pDeletedColorLB->SelectEntry(Color(nColor)); nColor = rChangedAttr.nColor; - - switch (nColor) - { - case COL_TRANSPARENT: - pChangedColorLB->SelectEntryPos(1); - break; - case COL_NONE_COLOR: - pChangedColorLB->SelectEntryPos(0); - break; - default: - pChangedColorLB->SelectEntry(Color(nColor)); - } + pChangedColorLB->SelectEntry(Color(nColor)); pMarkColorLB->SelectEntry(pOpt->GetMarkAlignColor()); @@ -2058,13 +1946,13 @@ void SwRedlineOptionsTabPage::Reset( const SfxItemSet* ) AttribHdl(*pChangedLB); ColorHdl(*pChangedColorLB); - ChangedMaskPrevHdl(*pMarkPosLB); + ChangedMaskPrev(); } IMPL_LINK( SwRedlineOptionsTabPage, AttribHdl, ListBox&, rLB, void ) { SvxFontPrevWindow *pPrev = nullptr; - ColorListBox *pColorLB; + SvxColorListBox *pColorLB; if (&rLB == pInsertLB) { @@ -2096,26 +1984,25 @@ IMPL_LINK( SwRedlineOptionsTabPage, AttribHdl, ListBox&, rLB, void ) rFont.SetCaseMap(SVX_CASEMAP_NOT_MAPPED); rCJKFont.SetCaseMap(SVX_CASEMAP_NOT_MAPPED); - sal_Int32 nPos = pColorLB->GetSelectEntryPos(); + Color aColor = pColorLB->GetSelectEntryColor(); - switch( nPos ) + if (aColor == COL_NONE_COLOR) { - case 0: - rFont.SetColor( Color( COL_BLACK ) ); - rCJKFont.SetColor( Color( COL_BLACK ) ); - break; - case 1: - case LISTBOX_ENTRY_NOTFOUND: - rFont.SetColor( Color( COL_RED ) ); - rCJKFont.SetColor( Color( COL_RED ) ); - break; - default: - rFont.SetColor( pColorLB->GetEntryColor( nPos ) ); - rCJKFont.SetColor( pColorLB->GetEntryColor( nPos ) ); - break; + rFont.SetColor( Color( COL_BLACK ) ); + rCJKFont.SetColor( Color( COL_BLACK ) ); + } + else if (aColor == COL_TRANSPARENT) + { + rFont.SetColor( Color( COL_RED ) ); + rCJKFont.SetColor( Color( COL_RED ) ); + } + else + { + rFont.SetColor(aColor); + rCJKFont.SetColor(aColor); } - nPos = rLB.GetSelectEntryPos(); + sal_Int32 nPos = rLB.GetSelectEntryPos(); if( nPos == LISTBOX_ENTRY_NOTFOUND ) nPos = 0; @@ -2151,12 +2038,11 @@ IMPL_LINK( SwRedlineOptionsTabPage, AttribHdl, ListBox&, rLB, void ) case SID_ATTR_BRUSH: { - nPos = pColorLB->GetSelectEntryPos(); - if( nPos ) - pPrev->SetColor( pColorLB->GetSelectEntryColor() ); + Color aBgColor = pColorLB->GetSelectEntryColor(); + if (aBgColor != COL_NONE_COLOR) + pPrev->SetColor(aBgColor); else - pPrev->SetColor( Color( COL_LIGHTGRAY ) ); - + pPrev->SetColor(Color(COL_LIGHTGRAY)); rFont.SetColor( Color( COL_BLACK ) ); rCJKFont.SetColor( Color( COL_BLACK ) ); } @@ -2166,9 +2052,9 @@ IMPL_LINK( SwRedlineOptionsTabPage, AttribHdl, ListBox&, rLB, void ) pPrev->Invalidate(); } -IMPL_LINK( SwRedlineOptionsTabPage, ColorHdl, ListBox&, rListBox, void ) +IMPL_LINK( SwRedlineOptionsTabPage, ColorHdl, SvxColorListBox&, rListBox, void ) { - ColorListBox* pColorLB = static_cast<ColorListBox*>(&rListBox); + SvxColorListBox* pColorLB = &rListBox; SvxFontPrevWindow *pPrev = nullptr; ListBox* pLB; @@ -2200,38 +2086,38 @@ IMPL_LINK( SwRedlineOptionsTabPage, ColorHdl, ListBox&, rListBox, void ) { rFont.SetColor( Color( COL_BLACK ) ); rCJKFont.SetColor( Color( COL_BLACK ) ); - nPos = pColorLB->GetSelectEntryPos(); - if( nPos && nPos != LISTBOX_ENTRY_NOTFOUND ) - pPrev->SetColor( pColorLB->GetSelectEntryColor() ); + + Color aBgColor = pColorLB->GetSelectEntryColor(); + if (aBgColor != COL_NONE_COLOR) + pPrev->SetColor(aBgColor); else - pPrev->SetColor( Color( COL_LIGHTGRAY ) ); + pPrev->SetColor(Color(COL_LIGHTGRAY)); } else { - nPos = pColorLB->GetSelectEntryPos(); + Color aColor = pColorLB->GetSelectEntryColor(); - switch( nPos ) + if (aColor == COL_NONE_COLOR) { - case 0: - rFont.SetColor( Color( COL_BLACK ) ); - rCJKFont.SetColor( Color( COL_BLACK ) ); - break; - case 1: - case LISTBOX_ENTRY_NOTFOUND: - rFont.SetColor( Color( COL_RED ) ); - rCJKFont.SetColor( Color( COL_RED ) ); - break; - default: - rFont.SetColor( pColorLB->GetEntryColor( nPos ) ); - rCJKFont.SetColor( pColorLB->GetEntryColor( nPos ) ); - break; + rFont.SetColor( Color( COL_BLACK ) ); + rCJKFont.SetColor( Color( COL_BLACK ) ); + } + else if (aColor == COL_TRANSPARENT) + { + rFont.SetColor( Color( COL_RED ) ); + rCJKFont.SetColor( Color( COL_RED ) ); + } + else + { + rFont.SetColor(aColor); + rCJKFont.SetColor(aColor); } } pPrev->Invalidate(); } -IMPL_LINK_NOARG(SwRedlineOptionsTabPage, ChangedMaskPrevHdl, ListBox&, void) +void SwRedlineOptionsTabPage::ChangedMaskPrev() { pMarkPreviewWN->SetMarkPos(pMarkPosLB->GetSelectEntryPos()); pMarkPreviewWN->SetColor(pMarkColorLB->GetSelectEntryColor().GetColor()); @@ -2239,6 +2125,16 @@ IMPL_LINK_NOARG(SwRedlineOptionsTabPage, ChangedMaskPrevHdl, ListBox&, void) pMarkPreviewWN->Invalidate(); } +IMPL_LINK_NOARG(SwRedlineOptionsTabPage, ChangedMaskPrevHdl, ListBox&, void) +{ + ChangedMaskPrev(); +} + +IMPL_LINK_NOARG(SwRedlineOptionsTabPage, ChangedMaskColorPrevHdl, SvxColorListBox&, void) +{ + ChangedMaskPrev(); +} + void SwRedlineOptionsTabPage::InitFontStyle(SvxFontPrevWindow& rExampleWin) { const AllSettings& rAllSettings = Application::GetSettings(); |