You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2012/11/14 22:45:47 UTC

svn commit: r1409445 - /incubator/ooo/branches/gbuild/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx

Author: arist
Date: Wed Nov 14 21:45:47 2012
New Revision: 1409445

URL: http://svn.apache.org/viewvc?rev=1409445&view=rev
Log:
writerfilter10_17_fb7e1780f025.patch
# HG changeset patch
# User Henning Brinkmann <hb...@openoffice.org>
# Date 1297856597 -3600
# Node ID fb7e1780f0255c2e5fc69feb8b671915125b1856
# Parent  da7cd5c19e609087fe411208a22a16ba13dcb9ef
#i116755# handle absolute paths in _rel


Modified:
    incubator/ooo/branches/gbuild/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx

Modified: incubator/ooo/branches/gbuild/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/gbuild/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx?rev=1409445&r1=1409444&r2=1409445&view=diff
==============================================================================
--- incubator/ooo/branches/gbuild/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx (original)
+++ incubator/ooo/branches/gbuild/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx Wed Nov 14 21:45:47 2012
@@ -90,6 +90,42 @@ const ::rtl::OUString & OOXMLStreamImpl:
     return msTarget;
 }
 
+::rtl::OUString lcl_normalizeTarget(const ::rtl::OUString & s)
+{
+    const int nStringsToCut = 2;
+    const ::rtl::OUString aStringToCut[] = {
+        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("./")),
+        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) 
+    };
+
+    bool bDone = false;
+    sal_Int32 nIndex = 0;
+    while (!bDone)
+    {
+        for (int n = 0; n <= nStringsToCut; n++)
+        {
+            if (n == nStringsToCut)
+            {
+                bDone = true;
+            }
+            else
+            {
+                sal_Int32 nNewIndex = s.indexOf(aStringToCut[n], nIndex);
+
+                if (nIndex == nNewIndex)
+                {
+                    sal_Int32 nLength = aStringToCut[n].getLength();
+                    nIndex += nLength;
+
+                    break;
+                }
+            }
+        }
+    }
+
+    return s.copy(nIndex);
+}
+
 bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess> 
                                     xRelationshipAccess,
                                     StreamType_t nStreamType, 
@@ -184,7 +220,7 @@ bool OOXMLStreamImpl::lcl_getTarget(uno:
                 else
                 {
                     rDocumentTarget = msPath;
-                    rDocumentTarget += sMyTarget;
+                    rDocumentTarget += lcl_normalizeTarget(sMyTarget);
                 }
                 
                 break;