[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:39:31 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=05f277f

The following commit has been merged in the master branch:
commit 05f277fb1c32e1b382afb36ea4c7f657ef7e3b4e
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Wed Jun 4 08:38:14 2008 +0000

    Improved conversion to/from XMP LangAltValues.
---
 src/convert.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++-------------
 src/xmp.cpp     |  1 +
 2 files changed, 68 insertions(+), 19 deletions(-)

diff --git a/src/convert.cpp b/src/convert.cpp
index 7c639e3..d3cc7a6 100644
--- a/src/convert.cpp
+++ b/src/convert.cpp
@@ -51,6 +51,20 @@ EXIV2_RCSID("@(#) $Id$")
 #endif // EXV_HAVE_XMP_TOOLKIT
 
 // *****************************************************************************
+// local declarations
+namespace {
+    /*!
+      @brief Get the text value of an XmpDatum \em pos.
+
+      If \em pos refers to a LangAltValue, \em value is set to the default language
+      entry without the x-default qualifier. If there is no default but
+      exactly one entry, \em value is set to this entry, without the qualifier.
+      The return code indicates if the operation was successful.
+     */
+    bool getTextValue(std::string& value, const Exiv2::XmpData::iterator& pos);
+}
+
+// *****************************************************************************
 // class member definitions
 namespace Exiv2 {
 
@@ -703,14 +717,7 @@ namespace Exiv2 {
         if (pos == xmpData_->end()) return;
         if (!prepareExifTarget(to)) return;
         std::string value;
-        if (pos->typeId() == langAlt) {
-            // get the default language entry without x-default qualifier
-            value = pos->value().toString(0);
-        }
-        else {
-            value = pos->value().toString();
-        }
-        if (!pos->value().ok()) {
+        if (!getTextValue(value, pos)) {
 #ifndef SUPPRESS_WARNINGS
             std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
 #endif
@@ -726,16 +733,8 @@ namespace Exiv2 {
         if (!prepareExifTarget(to)) return;
         Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
         if (pos == xmpData_->end()) return;
-
         std::string value;
-        if (pos->typeId() == langAlt) {
-            // get the default language entry without x-default qualifier
-            value = pos->value().toString(0);
-        }
-        else {
-            value = pos->value().toString();
-        }
-        if (!pos->value().ok()) {
+        if (!getTextValue(value, pos)) {
 #ifndef SUPPRESS_WARNINGS
             std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
 #endif
@@ -1025,9 +1024,23 @@ namespace Exiv2 {
 
     void Converter::cnvXmpValueToIptc(const char* from, const char* to)
     {
-        Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
+        XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
         if (pos == xmpData_->end()) return;
         if (!prepareIptcTarget(to)) return;
+
+        if (pos->typeId() == langAlt) {
+            std::string value;
+            if (!getTextValue(value, pos)) {
+#ifndef SUPPRESS_WARNINGS
+                std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+#endif
+                return;
+            }
+            (*iptcData_)[to] = value;
+            if (erase_) xmpData_->erase(pos);
+            return;
+        }
+
         int count = pos->value().count();
         for (int i = 0; i < count; ++i) {
             std::string value = pos->value().toString();
@@ -1037,7 +1050,9 @@ namespace Exiv2 {
 #endif
                 continue;
             }
-            (*iptcData_)[to] = value;
+            Iptcdatum id(IptcKey(to), 0);
+            id.setValue(value);
+            iptcData_->add(id);
         }
         if (erase_) xmpData_->erase(pos);
     }
@@ -1207,3 +1222,36 @@ namespace Exiv2 {
     }
 
 }                                       // namespace Exiv2
+
+// *****************************************************************************
+// local definitions
+namespace {
+
+    bool getTextValue(std::string& value, const Exiv2::XmpData::iterator& pos)
+    {
+        if (pos->typeId() == Exiv2::langAlt) {
+            // get the default language entry without x-default qualifier
+            value = pos->value().toString(0);
+            if (!pos->value().ok() && pos->count() == 1) {
+                // If there is no default but exactly one entry, take that
+                // without the qualifier
+                value = pos->value().toString();
+                if (   pos->value().ok()
+                    && value.length() > 5 && value.substr(0, 5) == "lang=") {
+                    std::string::size_type pos = value.find_first_of(' ');
+                    if (pos != std::string::npos) { 
+                        value = value.substr(pos + 1);
+                    }
+                    else {
+                        value.clear();
+                    }
+                }
+            }
+        }
+        else {
+            value = pos->value().toString();
+        }
+        return pos->value().ok();
+    }
+
+}
diff --git a/src/xmp.cpp b/src/xmp.cpp
index 8d55c2c..2f4fb7f 100644
--- a/src/xmp.cpp
+++ b/src/xmp.cpp
@@ -50,6 +50,7 @@ EXIV2_RCSID("@(#) $Id$")
 #endif // EXV_HAVE_XMP_TOOLKIT
 
 // *****************************************************************************
+// local declarations
 namespace {
     //! Unary predicate that matches an Xmpdatum by key
     class FindXmpdatum {

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list