Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hello,

this patch should ensure that we write the password algorithm only to odf
1.2 and later files.

I'm not quite sure how important it is to be 100% standard compliant so I
don't know if we should include it into 3-4.

Regards,
Markus
From 0bdea28c21531d6d09858e926915e325dd70212c Mon Sep 17 00:00:00 2001
From: Markus Mohrhard <markus.mohrhard@googlemail.com>
Date: Fri, 5 Aug 2011 21:51:31 +0200
Subject: [PATCH] fix for fdo#39678: don't write password algorithm in odf 1.0 and 1.1

---
 sc/source/filter/xml/xmlexprt.cxx |   51 +++++++++++++++++++++++++-----------
 sc/source/filter/xml/xmlexprt.hxx |    2 +
 2 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 4a5eecb..99c2ebd 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1525,16 +1525,19 @@ void ScXMLExport::SetBodyAttributes()
         if (aBuffer.getLength())
         {
             AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear());
-            if (eHashUsed == PASSHASH_XL)
+            if ( IsOdfVersionGreaterEqual_1_2() )
             {
-                AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
-                             ScPassHashHelper::getHashURI(PASSHASH_XL));
-                AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM_2,
-                             ScPassHashHelper::getHashURI(PASSHASH_SHA1));
+                if (eHashUsed == PASSHASH_XL)
+                {
+                    AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
+                                 ScPassHashHelper::getHashURI(PASSHASH_XL));
+                    AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM_2,
+                                 ScPassHashHelper::getHashURI(PASSHASH_SHA1));
+                }
+                else if (eHashUsed == PASSHASH_SHA1)
+                    AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
+                                 ScPassHashHelper::getHashURI(PASSHASH_SHA1));
             }
-            else if (eHashUsed == PASSHASH_SHA1)
-                AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
-                             ScPassHashHelper::getHashURI(PASSHASH_SHA1));
         }
     }
 }
@@ -1648,6 +1651,19 @@ void ScXMLExport::CopySourceStream( sal_Int32 nStartOffset, sal_Int32 
nEndOffset
     }
 }
 
+bool ScXMLExport::IsOdfVersionGreaterEqual_1_2()
+{
+    switch(getDefaultVersion())
+    {
+        case SvtSaveOptions::ODFVER_010:
+        case SvtSaveOptions::ODFVER_011:
+            return false;
+        default:
+            break;
+    }
+    return true;
+}
+
 void ScXMLExport::_ExportContent()
 {
     nCurrentTable = 0;
@@ -2695,16 +2711,19 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const 
Reference<sheet::XSpreadshe
                 if (aBuffer.getLength())
                 {
                     AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, 
aBuffer.makeStringAndClear());
-                    if (eHashUsed == PASSHASH_XL)
+                    if ( IsOdfVersionGreaterEqual_1_2() )
                     {
-                        AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
-                                     ScPassHashHelper::getHashURI(PASSHASH_XL));
-                        AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM_2,
-                                     ScPassHashHelper::getHashURI(PASSHASH_SHA1));
+                        if (eHashUsed == PASSHASH_XL)
+                        {
+                            AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
+                                         ScPassHashHelper::getHashURI(PASSHASH_XL));
+                            AddAttribute(XML_NAMESPACE_TABLE, 
XML_PROTECTION_KEY_DIGEST_ALGORITHM_2,
+                                         ScPassHashHelper::getHashURI(PASSHASH_SHA1));
+                        }
+                        else if (eHashUsed == PASSHASH_SHA1)
+                            AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
+                                         ScPassHashHelper::getHashURI(PASSHASH_SHA1));
                     }
-                    else if (eHashUsed == PASSHASH_SHA1)
-                        AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
-                                     ScPassHashHelper::getHashURI(PASSHASH_SHA1));
                 }
             }
         }
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index 2fb3ac4..54d6d60 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -223,6 +223,8 @@ class ScXMLExport : public SvXMLExport
 
     void CopySourceStream( sal_Int32 nStartOffset, sal_Int32 nEndOffset, sal_Int32& rNewStart, 
sal_Int32& rNewEnd );
 
+    bool IsOdfVersionGreaterEqual_1_2();
+
 protected:
     virtual SvXMLAutoStylePoolP* CreateAutoStylePool();
     virtual XMLPageExport* CreatePageExport();
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.