File xpdf-poppler-cut-and-paste-default-output-encoding.patch of Package xpdf-poppler

Index: XPDFCore.cc
===================================================================
--- XPDFCore.cc.orig
+++ XPDFCore.cc
@@ -419,13 +419,17 @@ Boolean XPDFCore::convertSelectionCbk(Wi
 				      XtPointer *value, unsigned long *length,
 				      int *format) {
   Atom *array;
+  static Atom utf8str = XInternAtom(currentSelectionOwner->display, "UTF8_STRING", False);
 
   // send back a list of supported conversion targets
   if (*target == targetsAtom) {
     if (!(array = (Atom *)XtMalloc(sizeof(Atom)))) {
       return False;
     }
-    array[0] = XA_STRING;
+    if (strcmp("UTF-8",globalParams->getTextEncodingName()->getCString()))
+	    array[0] = XA_STRING;
+    else
+	    array[0] = utf8str;
     *value = (XtPointer)array;
     *type = XA_ATOM;
     *format = 32;
@@ -433,11 +437,11 @@ Boolean XPDFCore::convertSelectionCbk(Wi
     return True;
 
   // send the selected text
-  } else if (*target == XA_STRING) {
+  } else if (*target == XA_STRING || *target == utf8str) {
     //~ for multithreading: need a mutex here
     *value = XtNewString(currentSelection->getCString());
     *length = currentSelection->getLength();
-    *type = XA_STRING;
+    *type = *target;
     *format = 8; // 8-bit elements
     return True;
   }
Index: XPDFViewer.cc
===================================================================
--- XPDFViewer.cc.orig
+++ XPDFViewer.cc
@@ -2735,7 +2735,10 @@ void XPDFViewer::setupOutline() {
     // create the new labels
     items = core->getDoc()->getOutline()->getItems();
     if (items && items->getLength() > 0) {
-      enc = new GooString("Latin1");
+      if (strcmp("UTF-8",globalParams->getTextEncodingName()->getCString()))
+             enc = new GooString("Latin1");
+      else
+             enc = new GooString("UTF-8");
       uMap = globalParamsGUI->getUnicodeMap(enc);
       delete enc;
       setupOutlineItems(items, NULL, uMap);
Index: doc/xpdf-poppler.1
===================================================================
--- doc/xpdf-poppler.1.orig
+++ doc/xpdf-poppler.1
@@ -162,7 +162,8 @@ Sets the encoding to use for text output
 .I encoding\-name
 must be defined with the unicodeMap command (see
 .BR xpdfrc (5)).
-This defaults to "Latin1" (which is a built-in encoding).
+This defaults to "UTF-8" in UTF-8 locales, to "Latin1" in all other
+locales ("UTF-8" and "Latin1" are built-in encodings).
 .RB "[config file: " textEncoding ]
 .TP
 .BI \-eol " unix | dos | mac"
openSUSE Build Service is sponsored by