49ee92e
From 97de5b728dd336b887ec0d36ab4f01537e26bec6 Mon Sep 17 00:00:00 2001
49ee92e
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
49ee92e
Date: Wed, 11 Nov 2015 13:34:43 +0000
49ee92e
Subject: [PATCH] Incredible slowness and crashes with document with vast num
49ee92e
 of frame dups
49ee92e
49ee92e
it looks like draw:name values are supposed to be unique in ODF, even
49ee92e
if it's not spelled out explicitly, since it exists so the frame can be
49ee92e
referenced, which sort of implies that it has to be unique, so a
49ee92e
document where the values aren't unique can be considered invalid
49ee92e
49ee92e
    19.197.10 <draw:frame>
49ee92e
    The draw:name attribute specifies a name by which a <draw:frame>
49ee92e
element can be referenced.
49ee92e
49ee92e
So reject duplicate frames but limit this to document generated with
49ee92e
4.4.X which we believe is the version that created these bogus docs
49ee92e
49ee92e
(cherry picked from commit de0432a9256188c7b5cd1a83858311e68c890ebf)
49ee92e
49ee92e
Change-Id: I83f6d72fd969f667f0a8c2c85d2ffeeed672387a
49ee92e
49ee92e
xmloff: add meta:generator constants LO_43x and LO_44x
49ee92e
49ee92e
Change-Id: I1d962ad637f19b02855616edebcedbad719689c5
49ee92e
(cherry picked from commit ee655627ad2ba66a8160b4cbdaeb1dd52d047a1d)
49ee92e
---
49ee92e
 include/xmloff/xmlimp.hxx                  |  6 ++++--
49ee92e
 xmloff/source/core/xmlimp.cxx              | 21 ++++++++++++++-------
49ee92e
 xmloff/source/text/XMLTextFrameContext.cxx | 10 +++++++++-
49ee92e
 3 files changed, 27 insertions(+), 10 deletions(-)
49ee92e
49ee92e
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
49ee92e
index 2939f6e..82949d3 100644
49ee92e
--- a/include/xmloff/xmlimp.hxx
49ee92e
+++ b/include/xmloff/xmlimp.hxx
49ee92e
@@ -480,9 +480,11 @@ public:
49ee92e
     static const sal_uInt16 LO_3x = 30 | LO_flag;
49ee92e
     static const sal_uInt16 LO_41x = 41 | LO_flag;
49ee92e
     static const sal_uInt16 LO_42x = 42 | LO_flag;
49ee92e
-    /// @ATTENTION: when adding a new value more specific than "4x", grep for
49ee92e
+    static const sal_uInt16 LO_43x = 43 | LO_flag;
49ee92e
+    static const sal_uInt16 LO_44x = 44 | LO_flag;
49ee92e
+    /// @ATTENTION: when adding a new value more specific than "5x", grep for
49ee92e
     /// all current uses and adapt them!!!
49ee92e
-    static const sal_uInt16 LO_4x = 43 | LO_flag;
49ee92e
+    static const sal_uInt16 LO_5x = 50 | LO_flag;
49ee92e
     static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
49ee92e
 
49ee92e
     /** depending on whether the generator version indicates LO, compare
49ee92e
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
49ee92e
index 339e5dd..46fdae8 100644
49ee92e
--- a/xmloff/source/core/xmlimp.cxx
49ee92e
+++ b/xmloff/source/core/xmlimp.cxx
49ee92e
@@ -190,24 +190,31 @@ getBuildIdsProperty(uno::Reference<beans::XPropertySet> const& xImportInfo)
49ee92e
                             {
49ee92e
                                 mnGeneratorVersion = SvXMLImport::LO_3x;
49ee92e
                             }
49ee92e
-                            else
49ee92e
+                            else if ('4' == loVersion[0])
49ee92e
                             {
49ee92e
-                                SAL_INFO_IF('4' != loVersion[0], "xmloff.core", "unknown LO version: " << loVersion);
49ee92e
-                                if ('4' == loVersion[0] && loVersion.getLength() > 1
49ee92e
+                                if (loVersion.getLength() > 1
49ee92e
                                     && (loVersion[1] == '0' || loVersion[1] == '1'))
49ee92e
                                 {
49ee92e
                                     mnGeneratorVersion = SvXMLImport::LO_41x; // 4.0/4.1
49ee92e
                                 }
49ee92e
-                                else if ('4' == loVersion[0]
49ee92e
-                                    && loVersion.getLength() > 1 && loVersion[1] == '2')
49ee92e
+                                else if (loVersion.getLength() > 1 && '2' == loVersion[1])
49ee92e
                                 {
49ee92e
                                     mnGeneratorVersion = SvXMLImport::LO_42x; // 4.2
49ee92e
                                 }
49ee92e
-                                else
49ee92e
+                                else if (loVersion.getLength() > 1 && '3' == loVersion[1])
49ee92e
+                                {
49ee92e
+                                    mnGeneratorVersion = SvXMLImport::LO_43x; // 4.3
49ee92e
+                                }
49ee92e
+                                else if (loVersion.getLength() > 1 && '4' == loVersion[1])
49ee92e
                                 {
49ee92e
-                                    mnGeneratorVersion = SvXMLImport::LO_4x;
49ee92e
+                                    mnGeneratorVersion = SvXMLImport::LO_44x; // 4.4
49ee92e
                                 }
49ee92e
                             }
49ee92e
+                            else
49ee92e
+                            {
49ee92e
+                                SAL_INFO_IF('5' != loVersion[0], "xmloff.core", "unknown LO version: " << loVersion);
49ee92e
+                                mnGeneratorVersion = SvXMLImport::LO_5x;
49ee92e
+                            }
49ee92e
                             return; // ignore buildIds
49ee92e
                         }
49ee92e
                     }
49ee92e
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
49ee92e
index 6389d8f..76e858c 100644
49ee92e
--- a/xmloff/source/text/XMLTextFrameContext.cxx
49ee92e
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
49ee92e
@@ -593,6 +593,7 @@ void XMLTextFrameContext_Impl::Create( bool /*bHRefOrBase64*/ )
49ee92e
             (!sName.isEmpty() && sOrigName != sName) )
49ee92e
         {
49ee92e
             OUString sOldName( sName );
49ee92e
+
49ee92e
             sal_Int32 i = 0;
49ee92e
             while( xTextImportHelper->HasFrameByName( sName ) )
49ee92e
             {
49ee92e
@@ -601,8 +602,15 @@ void XMLTextFrameContext_Impl::Create( bool /*bHRefOrBase64*/ )
49ee92e
             }
49ee92e
             xNamed->setName( sName );
49ee92e
             if( sName != sOldName )
49ee92e
-                xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME,
49ee92e
+            {
49ee92e
+                bool bSuccess = xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME,
49ee92e
                                              sOldName, sName );
49ee92e
+                if (!bSuccess && GetImport().getGeneratorVersion() == SvXMLImport::LO_44x)
49ee92e
+                {
49ee92e
+                    bCreateFailed = true;
49ee92e
+                    return;
49ee92e
+                }
49ee92e
+            }
49ee92e
         }
49ee92e
     }
49ee92e
 
49ee92e
-- 
49ee92e
2.5.0
49ee92e