Blame SOURCES/0083-fdo-67370-Hyphens-are-not-visible-in-tagged-PDF.patch

f0633d
From 158027cd7fe1ea2faeb5d2220547b36c9cbfb9d3 Mon Sep 17 00:00:00 2001
f0633d
From: Khaled Hosny <khaledhosny@eglug.org>
f0633d
Date: Sun, 22 Dec 2013 01:02:19 +0200
f0633d
Subject: [PATCH 083/109] fdo#67370: Hyphens are not visible in tagged PDF
f0633d
MIME-Version: 1.0
f0633d
Content-Type: text/plain; charset=UTF-8
f0633d
Content-Transfer-Encoding: 8bit
f0633d
f0633d
One requirement of tagged PDF is to represent automatically inserted
f0633d
hyphens using the soft hyphen (U+00AD) character, so we were doing this
f0633d
by simply passing that character to text layout code when exporting a
f0633d
tagged PDF (which is the literal suggestion of old PDF specification).
f0633d
f0633d
This is wrong, though, since the soft hyphen is a control character and
f0633d
should not have a visible output by itself (and fonts might not even
f0633d
have a visible glyph there), but this happened to work because non of
f0633d
the layout engines we are using treated soft hyphen specially and was
f0633d
just showing whatever glyph the font had there. This broke with the
f0633d
switch to HarfBuzz since it will not show any visible glyph for Unicode
f0633d
control characters (by default), which is the right thing to do.
f0633d
f0633d
Latest versions of PDF spec suggest using either ToUnicode mapping or an
f0633d
ActualText text entry to encode the soft hyphen instead, I found it
f0633d
easier to use ActualText since we already have code that handles
f0633d
non-standard hyphenation using it already.
f0633d
f0633d
Conflicts:
f0633d
	sw/source/core/text/EnhancedPDFExportHelper.cxx
f0633d
	sw/source/core/text/txthyph.cxx
f0633d
f0633d
Change-Id: I88deadf3a806f69775b2e0ccff2f9b2f61a0f2e2
f0633d
Reviewed-on: https://gerrit.libreoffice.org/7177
f0633d
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
f0633d
Tested-by: Caolán McNamara <caolanm@redhat.com>
f0633d
---
f0633d
 sw/source/core/text/EnhancedPDFExportHelper.cxx | 11 +++++++++--
f0633d
 sw/source/core/text/txthyph.cxx                 | 12 ++----------
f0633d
 2 files changed, 11 insertions(+), 12 deletions(-)
f0633d
f0633d
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
f0633d
index 3933837..9538de6 100644
f0633d
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
f0633d
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
f0633d
@@ -766,7 +766,8 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType )
f0633d
             case vcl::PDFWriter::Span :
f0633d
             case vcl::PDFWriter::Quote :
f0633d
             case vcl::PDFWriter::Code :
f0633d
-                if( POR_HYPHSTR == pPor->GetWhichPor() || POR_SOFTHYPHSTR == pPor->GetWhichPor() )
f0633d
+                if( POR_HYPHSTR == pPor->GetWhichPor() || POR_SOFTHYPHSTR == pPor->GetWhichPor() ||
f0633d
+                    POR_HYPH == pPor->GetWhichPor() || POR_SOFTHYPH == pPor->GetWhichPor() )
f0633d
                     bActualText = true;
f0633d
                 else
f0633d
                 {
f0633d
@@ -789,7 +790,11 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType )
f0633d
 
f0633d
         if ( bActualText )
f0633d
         {
f0633d
-            const String aActualTxt( rInf.GetTxt(), rInf.GetIdx(), pPor->GetLen() );
f0633d
+            String aActualTxt;
f0633d
+            if (pPor->GetWhichPor() == POR_SOFTHYPH || pPor->GetWhichPor() == POR_HYPH)
f0633d
+                aActualTxt = (sal_Unicode)0xad; // soft hyphen
f0633d
+            else
f0633d
+                aActualTxt = String(rInf.GetTxt(), rInf.GetIdx(), pPor->GetLen());
f0633d
             mpPDFExtOutDevData->SetActualText( aActualTxt );
f0633d
         }
f0633d
 
f0633d
@@ -1373,6 +1378,8 @@ void SwTaggedPDFHelper::BeginInlineStructureElements()
f0633d
 
f0633d
     switch ( pPor->GetWhichPor() )
f0633d
     {
f0633d
+        case POR_HYPH :
f0633d
+        case POR_SOFTHYPH :
f0633d
         // Check for alternative spelling:
f0633d
         case POR_HYPHSTR :
f0633d
         case POR_SOFTHYPHSTR :
f0633d
diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx
f0633d
index 62b3ad4..6b32a9f 100644
f0633d
--- a/sw/source/core/text/txthyph.cxx
f0633d
+++ b/sw/source/core/text/txthyph.cxx
f0633d
@@ -20,7 +20,6 @@
f0633d
 #include <hintids.hxx>
f0633d
 #include <editeng/unolingu.hxx>
f0633d
 #include <com/sun/star/i18n/WordType.hpp>
f0633d
-#include <EnhancedPDFExportHelper.hxx>
f0633d
 #include <viewopt.hxx>  // SwViewOptions
f0633d
 #include <viewsh.hxx>
f0633d
 #include <SwPortionHandler.hxx>
f0633d
@@ -370,16 +369,9 @@ sal_Bool SwTxtPortion::CreateHyphen( SwTxtFormatInfo &rInf, SwTxtGuess &rGuess )
f0633d
  *              virtual SwHyphPortion::GetExpTxt()
f0633d
  *************************************************************************/
f0633d
 
f0633d
-sal_Bool SwHyphPortion::GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt ) const
f0633d
+sal_Bool SwHyphPortion::GetExpTxt( const SwTxtSizeInfo &/*rInf*/, OUString &rTxt ) const
f0633d
 {
f0633d
-    // #i16816# tagged pdf support
f0633d
-    const sal_Unicode cChar = rInf.GetVsh() &&
f0633d
-                              rInf.GetVsh()->GetViewOptions()->IsPDFExport() &&
f0633d
-                              SwTaggedPDFHelper::IsExportTaggedPDF( *rInf.GetOut() ) ?
f0633d
-                              0xad :
f0633d
-                              '-';
f0633d
-
f0633d
-    rTxt = OUString(cChar);
f0633d
+    rTxt = "-";
f0633d
     return sal_True;
f0633d
 }
f0633d
 
f0633d
-- 
f0633d
1.8.4.2
f0633d