diff options
author | Jürgen Schmidt <jsc@apache.org> | 2013-03-20 14:18:15 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-05-23 11:55:27 +0100 |
commit | 79b231f7a032c7e04b74fa019e18a5d7e3b5f4f3 (patch) | |
tree | 64ac7648566d3180e7fafaeddbadb7620c982e4c /sw/source/core/txtnode | |
parent | c5b604b9527d0dc32066e17dc3ce7f7370a78fe1 (diff) |
Resolves: #i121733# enhancement for colored smarttags
Patch By: Kai Labusch
Review by: arielch, jsc
(cherry picked from commit 5da75c78a80e43cb2bb4ed777ae5efcc1449cdda)
Conflicts:
sw/source/core/inc/wrong.hxx
sw/source/core/txtnode/fntcache.cxx
Change-Id: Ibc609ce4ef3492b537bb1ddec5ff7c460eb2c573
Diffstat (limited to 'sw/source/core/txtnode')
-rw-r--r-- | sw/source/core/txtnode/fntcache.cxx | 195 |
1 files changed, 108 insertions, 87 deletions
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 83981599c0df..77ae8499ce4e 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -665,115 +665,136 @@ static void lcl_DrawLineForWrongListData( const CalcLinePosData &rCalcLinePosData, const Size &rPrtFontSize ) { - if (!pWList) - return; + if (!pWList) return; xub_StrLen nStart = rInf.GetIdx(); xub_StrLen nWrLen = rInf.GetLen(); // check if respective data is available in the current text range - if (pWList->Check( nStart, nWrLen )) + if (!pWList->Check( nStart, nWrLen )) + { + return; + } + + long nHght = rInf.GetOut().LogicToPixel( rPrtFontSize ).Height(); + + // Draw wavy lines for spell and grammar errors only if font is large enough. + // Lines for smart tags will always be drawn. + if (pWList != rInf.GetSmartTags() && WRONG_SHOW_MIN >= nHght) + { + return; + } + + SwForbidden::iterator pIter = rForbidden.begin(); + if (rInf.GetOut().GetConnectMetaFile()) + rInf.GetOut().Push(); + + const Color aCol( rInf.GetOut().GetLineColor() ); + + // iterate over all ranges stored in the respective SwWrongList + do { - // get line color to use... - Color aLineColor; - if (pWList == rInf.GetWrong()) // ... for spell checking - aLineColor = SwViewOption::GetSpellColor(); - else if (pWList == rInf.GetGrammarCheck()) // ... for grammar checking - // currently there is no specific color for grammar check errors available in the configuration - aLineColor = Color( COL_LIGHTBLUE ); - else if (pWList == rInf.GetSmartTags()) // ... for smart tags - aLineColor = SwViewOption::GetSmarttagColor(); - - long nHght = rInf.GetOut().LogicToPixel( rPrtFontSize ).Height(); - - // Draw wavy lines for spell and grammar errors only if font is large enough. - // Lines for smart tags will always be drawn. - if (pWList == rInf.GetSmartTags() || WRONG_SHOW_MIN < nHght) + nStart = nStart - rInf.GetIdx(); + + const xub_StrLen nEnd = nStart + nWrLen; + xub_StrLen nNext = nStart; + while( nNext < nEnd ) { - SwForbidden::iterator pIter = rForbidden.begin(); - if (rInf.GetOut().GetConnectMetaFile()) - rInf.GetOut().Push(); + while( pIter != rForbidden.end() && pIter->second <= nNext ) + ++pIter; - const Color aCol( rInf.GetOut().GetLineColor() ); - const bool bColSave = aCol != aLineColor; - if (bColSave) - rInf.GetOut().SetLineColor( aLineColor ); + xub_StrLen nNextStart = nNext; + xub_StrLen nNextEnd = nEnd; - // iterate over all ranges stored in the respective SwWrongList - do + if( pIter == rForbidden.end() || nNextEnd <= pIter->first ) { - nStart = nStart - rInf.GetIdx(); + // No overlapping mark up found + std::pair< xub_StrLen, xub_StrLen > aNew; + aNew.first = nNextStart; + aNew.second = nNextEnd; + rForbidden.insert( pIter, aNew ); + pIter = rForbidden.begin(); + nNext = nEnd; + } + else + { + nNext = pIter->second; + if( nNextStart < pIter->first ) + { + nNextEnd = pIter->first; + pIter->first = nNextStart; + } + else + continue; + } + // determine line pos + Point aStart( rInf.GetPos() ); + Point aEnd; + lcl_calcLinePos( rCalcLinePosData, aStart, aEnd, nNextStart, nNextEnd - nNextStart ); + - const xub_StrLen nEnd = nStart + nWrLen; - xub_StrLen nNext = nStart; - while( nNext < nEnd ) + sal_uInt16 wrongPos = pWList->GetWrongPos(nNextStart + rInf.GetIdx()); + + const SwWrongArea* wrongArea = pWList->GetElement(wrongPos); + + if (wrongArea != 0) + { + if (WRONGAREA_DASHED == wrongArea->mLineType) { - while( pIter != rForbidden.end() && pIter->second <= nNext ) - ++pIter; - xub_StrLen nNextStart = nNext; - xub_StrLen nNextEnd = nEnd; - if( pIter == rForbidden.end() || nNextEnd <= pIter->first ) - { - // No overlapping mark up found - std::pair< xub_StrLen, xub_StrLen > aNew; - aNew.first = nNextStart; - aNew.second = nNextEnd; - rForbidden.insert( pIter, aNew ); - pIter = rForbidden.begin(); - nNext = nEnd; - } - else - { - nNext = pIter->second; - if( nNextStart < pIter->first ) - { - nNextEnd = pIter->first; - pIter->first = nNextStart; - } - else - continue; - } - // determine line pos - Point aStart( rInf.GetPos() ); - Point aEnd; - lcl_calcLinePos( rCalcLinePosData, aStart, aEnd, nNextStart, nNextEnd - nNextStart ); + rInf.GetOut().SetLineColor( wrongArea->mColor ); - // draw line for smart tags? - if (pWList == rInf.GetSmartTags()) - { - aStart.Y() +=30; - aEnd.Y() +=30; + aStart.Y() +=30; + aEnd.Y() +=30; - LineInfo aLineInfo( LINE_DASH ); - aLineInfo.SetDistance( 40 ); - aLineInfo.SetDashLen( 1 ); - aLineInfo.SetDashCount(1); + LineInfo aLineInfo( LINE_DASH ); + aLineInfo.SetDistance( 40 ); + aLineInfo.SetDashLen( 1 ); + aLineInfo.SetDashCount(1); - rInf.GetOut().DrawLine( aStart, aEnd, aLineInfo ); - } - else // draw wavy lines for spell or grammar errors - { - // get wavy line type to use - sal_uInt16 nWave = - WRONG_SHOW_MEDIUM < nHght ? WAVE_NORMAL : - ( WRONG_SHOW_SMALL < nHght ? WAVE_SMALL : WAVE_FLAT ); + rInf.GetOut().DrawLine( aStart, aEnd, aLineInfo ); + } + else if (WRONGAREA_WAVE == wrongArea->mLineType) + { + rInf.GetOut().SetLineColor( wrongArea->mColor ); - rInf.GetOut().DrawWaveLine( aStart, aEnd, nWave ); - } + // get wavy line type to use + sal_uInt16 nWave = + WRONG_SHOW_MEDIUM < nHght ? WAVE_NORMAL : + ( WRONG_SHOW_SMALL < nHght ? WAVE_SMALL : WAVE_FLAT ); + + rInf.GetOut().DrawWaveLine( aStart, aEnd, nWave ); } + else if (WRONGAREA_WAVE_NORMAL == wrongArea->mLineType) + { + rInf.GetOut().SetLineColor( wrongArea->mColor ); - nStart = nEnd + rInf.GetIdx(); - nWrLen = rInf.GetIdx() + rInf.GetLen() - nStart; - } - while (nWrLen && pWList->Check( nStart, nWrLen )); + rInf.GetOut().DrawWaveLine( aStart, aEnd, WAVE_NORMAL); + } - if (bColSave) - rInf.GetOut().SetLineColor( aCol ); + else if (WRONGAREA_WAVE_SMALL == wrongArea->mLineType) + { + rInf.GetOut().SetLineColor( wrongArea->mColor ); - if (rInf.GetOut().GetConnectMetaFile()) - rInf.GetOut().Pop(); + rInf.GetOut().DrawWaveLine( aStart, aEnd, WAVE_SMALL); + } + else if (WRONGAREA_WAVE_FLAT == wrongArea->mLineType) + { + rInf.GetOut().SetLineColor( wrongArea->mColor ); + + rInf.GetOut().DrawWaveLine( aStart, aEnd, WAVE_FLAT); + } + } } + + nStart = nEnd + rInf.GetIdx(); + nWrLen = rInf.GetIdx() + rInf.GetLen() - nStart; } + while (nWrLen && pWList->Check( nStart, nWrLen )); + + rInf.GetOut().SetLineColor( aCol ); + + if (rInf.GetOut().GetConnectMetaFile()) + rInf.GetOut().Pop(); } |