[libreoffice/f15/master] Resolves: rhbz#684580 improve X and / strike-through
Caolan McNamara
caolanm at fedoraproject.org
Tue Mar 29 13:22:14 UTC 2011
commit 2d9cb188ebc2f668355ef4ea237542a72c499727
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Mar 29 14:22:08 2011 +0100
Resolves: rhbz#684580 improve X and / strike-through
...bz-684580-X-and-strike-through-escapes-ra.patch | 142 ++++++++++++++++++++
libreoffice.spec | 7 +-
2 files changed, 148 insertions(+), 1 deletions(-)
---
diff --git a/0001-Resolves-rhbz-684580-X-and-strike-through-escapes-ra.patch b/0001-Resolves-rhbz-684580-X-and-strike-through-escapes-ra.patch
new file mode 100644
index 0000000..85c3dec
--- /dev/null
+++ b/0001-Resolves-rhbz-684580-X-and-strike-through-escapes-ra.patch
@@ -0,0 +1,142 @@
+From 53e2bdb610cb46b8a2482c742820e2dbe80bfc47 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Tue, 29 Mar 2011 14:00:33 +0100
+Subject: [PATCH] Resolves: rhbz#684580 'X' and '/' strike-through escapes range
+
+i.e. it bleeds outside the text it is supposed to affect. See #i114076#,
+---
+ vcl/source/gdi/outdev3.cxx | 46 ++++++++++++++++++++++++-------------
+ vcl/source/gdi/pdfwriter_impl.cxx | 23 ++++++++++++++++++
+ 2 files changed, 53 insertions(+), 16 deletions(-)
+
+diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
+index 02febe3..d43c163 100644
+--- a/vcl/source/gdi/outdev3.cxx
++++ b/vcl/source/gdi/outdev3.cxx
+@@ -4005,6 +4005,11 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY,
+ FontStrikeout eStrikeout,
+ Color aColor )
+ {
++ //See qadevOOo/testdocs/StrikeThrough.odt for examples if you need
++ //to tweak this
++ if (!nWidth)
++ return;
++
+ // PDF-export does its own strikeout drawing... why again?
+ if( mpPDFWriter && mpPDFWriter->isBuiltinFont(mpFontEntry->maFontSelData.mpFontData) )
+ return;
+@@ -4017,35 +4022,23 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY,
+ cStrikeoutChar = 'X';
+ static const int nTestStrLen = 4;
+ static const int nMaxStrikeStrLen = 2048;
+- xub_Unicode aChars[ nMaxStrikeStrLen +1]; // +1 for valgrind...
++ xub_Unicode aChars[nMaxStrikeStrLen+1]; // +1 for valgrind...
+ for( int i = 0; i < nTestStrLen; ++i)
+ aChars[i] = cStrikeoutChar;
+ const String aStrikeoutTest( aChars, nTestStrLen );
+
+ // calculate approximation of strikeout atom size
+- long nStrikeoutWidth = nWidth;
++ long nStrikeoutWidth = 0;
+ SalLayout* pLayout = ImplLayout( aStrikeoutTest, 0, nTestStrLen );
+ if( pLayout )
+ {
+- nStrikeoutWidth = (pLayout->GetTextWidth() +nTestStrLen/2) / (nTestStrLen * pLayout->GetUnitsPerPixel());
++ nStrikeoutWidth = pLayout->GetTextWidth() / (nTestStrLen * pLayout->GetUnitsPerPixel());
+ pLayout->Release();
+ }
+ if( nStrikeoutWidth <= 0 ) // sanity check
+ return;
+
+- // calculate acceptable strikeout length
+- // allow the strikeout to be one pixel larger than the text it strikes out
+- long nMaxWidth = nStrikeoutWidth * 3 / 4;
+- if ( nMaxWidth < 2 )
+- nMaxWidth = 2;
+- nMaxWidth += nWidth + 1;
+-
+- int nStrikeStrLen = (nMaxWidth - 1) / nStrikeoutWidth;
+- // if the text width is smaller than the strikeout text, then do not
+- // strike out at all. This case requires user interaction, e.g. adding
+- // a space to the text
+- if( nStrikeStrLen <= 0 )
+- return;
++ int nStrikeStrLen = (nWidth+(nStrikeoutWidth-1)) / nStrikeoutWidth;
+ if( nStrikeStrLen > nMaxStrikeStrLen )
+ nStrikeStrLen = nMaxStrikeStrLen;
+
+@@ -4074,8 +4067,29 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY,
+ ImplInitTextColor();
+
+ pLayout->DrawBase() = Point( nBaseX+mnTextOffX, nBaseY+mnTextOffY );
++
++ Rectangle aPixelRect;
++ aPixelRect.nLeft = nBaseX+mnTextOffX;
++ aPixelRect.nRight = aPixelRect.nLeft+nWidth;
++ aPixelRect.nBottom = nBaseY+mpFontEntry->maMetric.mnDescent;
++ aPixelRect.nTop = nBaseY-mpFontEntry->maMetric.mnAscent;
++
++ if (mpFontEntry->mnOrientation)
++ {
++ Polygon aPoly( aPixelRect );
++ aPoly.Rotate( Point(nBaseX+mnTextOffX, nBaseY+mnTextOffY), mpFontEntry->mnOrientation);
++ aPixelRect = aPoly.GetBoundRect();
++ }
++
++ Push( PUSH_CLIPREGION );
++ IntersectClipRegion( PixelToLogic(aPixelRect) );
++ if( mbInitClipRegion )
++ ImplInitClipRegion();
++
+ pLayout->DrawText( *mpGraphics );
++
+ pLayout->Release();
++ Pop();
+
+ SetTextColor( aOldColor );
+ ImplInitTextColor();
+diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
+index 442a25d..485dad3 100644
+--- a/vcl/source/gdi/pdfwriter_impl.cxx
++++ b/vcl/source/gdi/pdfwriter_impl.cxx
+@@ -8264,6 +8264,9 @@ void PDFWriterImpl::drawStrikeoutLine( OStringBuffer& aLine, long nWidth, FontSt
+
+ void PDFWriterImpl::drawStrikeoutChar( const Point& rPos, long nWidth, FontStrikeout eStrikeout )
+ {
++ //See qadevOOo/testdocs/StrikeThrough.odt for examples if you need
++ //to tweak this
++
+ String aStrikeoutChar = String::CreateFromAscii( eStrikeout == STRIKEOUT_SLASH ? "/" : "X" );
+ String aStrikeout = aStrikeoutChar;
+ while( m_pReferenceDevice->GetTextWidth( aStrikeout ) < nWidth )
+@@ -8285,7 +8288,27 @@ void PDFWriterImpl::drawStrikeoutChar( const Point& rPos, long nWidth, FontStrik
+ // strikeout string is left aligned non-CTL text
+ sal_uLong nOrigTLM = m_pReferenceDevice->GetLayoutMode();
+ m_pReferenceDevice->SetLayoutMode( TEXT_LAYOUT_BIDI_STRONG|TEXT_LAYOUT_COMPLEX_DISABLED );
++
++ push( PUSH_CLIPREGION );
++ FontMetric aRefDevFontMetric = m_pReferenceDevice->GetFontMetric();
++ Rectangle aRect;
++ aRect.nLeft = rPos.X();
++ aRect.nRight = aRect.nLeft+nWidth;
++ aRect.nBottom = rPos.Y()+aRefDevFontMetric.GetDescent();
++ aRect.nTop = rPos.Y()-aRefDevFontMetric.GetAscent();
++
++ ImplFontEntry* pFontEntry = m_pReferenceDevice->mpFontEntry;
++ if (pFontEntry->mnOrientation)
++ {
++ Polygon aPoly( aRect );
++ aPoly.Rotate( rPos, pFontEntry->mnOrientation);
++ aRect = aPoly.GetBoundRect();
++ }
++
++ intersectClipRegion( aRect );
+ drawText( rPos, aStrikeout, 0, aStrikeout.Len(), false );
++ pop();
++
+ m_pReferenceDevice->SetLayoutMode( nOrigTLM );
+
+ if ( bShadow )
+--
+1.7.4.1
+
diff --git a/libreoffice.spec b/libreoffice.spec
index 5f46fc4..0802089 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -29,7 +29,7 @@ Summary: Free Software Productivity Suite
Name: libreoffice
Epoch: 1
Version: 3.3.2.2
-Release: 3%{?dist}
+Release: 4%{?dist}
License: LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and (CDDL or GPLv2) and Public Domain
Group: Applications/Productivity
URL: http://www.documentfoundation.org/develop
@@ -132,6 +132,7 @@ Patch43: 0001-beware-of-invalidated-iterator.patch
Patch44: rhbz680766.fix-mdds-crash.patch
Patch45: mdds.add-missing-link.patch
Patch46: mdds.do-not-insert-new-node.patch
+Patch47: 0001-Resolves-rhbz-684580-X-and-strike-through-escapes-ra.patch
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%define instdir %{_libdir}
@@ -779,6 +780,7 @@ mv -f redhat.soc extras/source/palettes/standard.soc
%patch42 -p1 -b .Cut-Gordian-Knot-of-who-owns-the-font-options.patch
%patch43 -p1 -b .beware-of-invalidated-iterator.patch
%patch44 -p1 -b .rhbz680766.fix-mdds-crash.patch
+%patch47 -p1 -b .rhbz-684580-X-and-strike-through-escapes-ra.patch
touch scripting/source/pyprov/delzip
touch scripting/util/provider/beanshell/delzip
@@ -2128,6 +2130,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
%{basisinstdir}/program/kde-open-url
%changelog
+* Tue Mar 29 2011 Caolán McNamara <caolanm at redhat.com> 3.3.2.2-4
+- Resolves: rhbz#684580 improve X and / strike-through
+
* Thu Mar 24 2011 David Tardon <dtardon at redhat.com> 3.3.2.2-3
- Resolves: rhbz#680766 crash in mdds
More information about the scm-commits
mailing list