[Libreoffice-commits] .: Branch 'libreoffice-3-4' - 3 commits - oox/inc oox/source writerfilter/source

Fridrich Strba fridrich at kemper.freedesktop.org
Thu Jul 7 06:07:16 PDT 2011


 oox/inc/oox/core/filterdetect.hxx             |    4 +--
 oox/source/core/filterdetect.cxx              |   28 +++++++++++++++++++++-----
 writerfilter/source/ooxml/OOXMLStreamImpl.cxx |   18 ++++++++++++++--
 3 files changed, 41 insertions(+), 9 deletions(-)

New commits:
commit 9515c9073758dcdad311820de45c7424ad287a07
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Tue Jun 7 21:12:25 2011 -0700

    gcc 4.0 doesn't support the C++0x usage of enum::value
    
    Signed-off-by: Fridrich Å trba <fridrich.strba at bluewin.ch>

diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index 44f050a..c9843e6 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -173,7 +173,7 @@ void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs )
              Reference< com::sun::star::uri::XUriReference > xBase = xFac->parse( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("file:///" ) ) );
 
              Reference< com::sun::star::uri::XUriReference > xPart = xFac->parse(  rAttribs.getString( XML_Target, OUString() ) );
-             Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute(  xBase, xPart, sal_True,  com::sun::star::uri::RelativeUriExcessParentSegments_RETAIN );
+             Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute(  xBase, xPart, sal_True, com::sun::star::uri::RelativeUriExcessParentSegments_RETAIN );
 
              if ( xAbs.is() )
                  maTargetPath = xAbs->getPath();
diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
index d1f1d8c..7e1a390 100644
--- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
@@ -201,7 +201,7 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
                     // file://base/word. We need something more than some
                     // simple string concatination here to handle that.
                     uno::Reference< com::sun::star::uri::XUriReference > xPart = xFac->parse(  sMyTarget );
-                    uno::Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute(  xBase, xPart, sal_True,  com::sun::star::uri::RelativeUriExcessParentSegments::RelativeUriExcessParentSegments_RETAIN );
+                    uno::Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute(  xBase, xPart, sal_True,  com::sun::star::uri::RelativeUriExcessParentSegments_RETAIN );
                     rDocumentTarget = xAbs->getPath();
                     // path will start with the fragment separator. need to
                     // remove that
commit 0b87c46a182a9fb15f5dbbdd2f00bde04c99e79b
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Tue Jun 7 20:59:21 2011 -0700

    The enum type name should be included when accessing the enum values.
    
    Signed-off-by: Fridrich Å trba <fridrich.strba at bluewin.ch>

diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index 0857cf4..44f050a 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -173,7 +173,7 @@ void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs )
              Reference< com::sun::star::uri::XUriReference > xBase = xFac->parse( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("file:///" ) ) );
 
              Reference< com::sun::star::uri::XUriReference > xPart = xFac->parse(  rAttribs.getString( XML_Target, OUString() ) );
-             Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute(  xBase, xPart, sal_True,  com::sun::star::uri::RelativeUriExcessParentSegments::RelativeUriExcessParentSegments_RETAIN );
+             Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute(  xBase, xPart, sal_True,  com::sun::star::uri::RelativeUriExcessParentSegments_RETAIN );
 
              if ( xAbs.is() )
                  maTargetPath = xAbs->getPath();
commit 67f661f7d07ee319e3d4b435e07a33aea5baaab7
Author: Noel Power <noel.power at novell.com>
Date:   Tue Jun 7 19:04:40 2011 +0100

    fix for bnc#693386
    
    properly handle relative Uri(s) in Target
    
    Signed-off-by: Fridrich Å trba <fridrich.strba at bluewin.ch>

diff --git a/oox/inc/oox/core/filterdetect.hxx b/oox/inc/oox/core/filterdetect.hxx
index fb444fa..2a336bf 100644
--- a/oox/inc/oox/core/filterdetect.hxx
+++ b/oox/inc/oox/core/filterdetect.hxx
@@ -59,7 +59,7 @@ namespace core {
 class FilterDetectDocHandler : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastDocumentHandler >
 {
 public:
-    explicit            FilterDetectDocHandler( ::rtl::OUString& rFilter );
+    explicit            FilterDetectDocHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, ::rtl::OUString& rFilter );
     virtual             ~FilterDetectDocHandler();
 
     // XFastDocumentHandler
@@ -91,6 +91,7 @@ private:
     ::rtl::OUString&    mrFilterName;
     ContextVector       maContextStack;
     ::rtl::OUString     maTargetPath;
+    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
 };
 
 // ============================================================================
@@ -167,4 +168,4 @@ private:
 
 #endif
 
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index 568634f..0857cf4 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -39,6 +39,7 @@
 #include "oox/helper/binaryoutputstream.hxx"
 #include "oox/helper/zipstorage.hxx"
 #include "oox/ole/olestorage.hxx"
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
 
 namespace oox {
 namespace core {
@@ -57,8 +58,8 @@ using ::rtl::OUString;
 
 // ============================================================================
 
-FilterDetectDocHandler::FilterDetectDocHandler( OUString& rFilterName ) :
-    mrFilterName( rFilterName )
+FilterDetectDocHandler::FilterDetectDocHandler( const  Reference< XComponentContext >& rxContext, OUString& rFilterName ) :
+    mrFilterName( rFilterName ), mxContext( rxContext )
 {
     maContextStack.reserve( 2 );
 }
@@ -163,7 +164,24 @@ void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs )
 {
     OUString aType = rAttribs.getString( XML_Type, OUString() );
     if( aType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ) ) )
-        maTargetPath = OUString( sal_Unicode( '/' ) ) + rAttribs.getString( XML_Target, OUString() );
+    {
+        Reference< com::sun::star::uri::XUriReferenceFactory > xFac =  com::sun::star::uri::UriReferenceFactory::create( mxContext );
+        try
+        {
+             // use '/' to representent the root of the zip package ( and provide a 'file' scheme to
+             // keep the XUriReference implementation happy )
+             Reference< com::sun::star::uri::XUriReference > xBase = xFac->parse( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("file:///" ) ) );
+
+             Reference< com::sun::star::uri::XUriReference > xPart = xFac->parse(  rAttribs.getString( XML_Target, OUString() ) );
+             Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute(  xBase, xPart, sal_True,  com::sun::star::uri::RelativeUriExcessParentSegments::RelativeUriExcessParentSegments_RETAIN );
+
+             if ( xAbs.is() )
+                 maTargetPath = xAbs->getPath();
+        }
+        catch( Exception& e)
+        {
+        }
+    }
 }
 
 OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& rContentType ) const
@@ -663,7 +681,7 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq
             aParser.registerNamespace( NMSP_packageRel );
             aParser.registerNamespace( NMSP_officeRel );
             aParser.registerNamespace( NMSP_packageContentTypes );
-            aParser.setDocumentHandler( new FilterDetectDocHandler( aFilterName ) );
+            aParser.setDocumentHandler( new FilterDetectDocHandler( mxContext, aFilterName ) );
 
             /*  Parse '_rels/.rels' to get the target path and '[Content_Types].xml'
                 to determine the content type of the part at the target path. */
@@ -671,7 +689,7 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq
             aParser.parseStream( aZipStorage, CREATE_OUSTRING( "[Content_Types].xml" ) );
         }
     }
-    catch( Exception& )
+    catch( Exception& e )
     {
     }
 
diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
index ba48c20..d1f1d8c 100644
--- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
@@ -32,6 +32,7 @@
 #include <iostream>
 
 #include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
 
 //#define DEBUG_STREAM
 
@@ -100,6 +101,11 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
                                     ::rtl::OUString & rDocumentTarget)
 {
     bool bFound = false;
+    static uno::Reference< com::sun::star::uri::XUriReferenceFactory > xFac =  ::com::sun::star::uri::UriReferenceFactory::create( mxContext );
+    // use '/' to representent the root of the zip package ( and provide a 'file' scheme to
+    // keep the XUriReference implementation happy )
+    // add mspath to represent the 'source' of this stream
+    uno::Reference< com::sun::star::uri::XUriReference > xBase = xFac->parse( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("file:///" ) ) + msPath );
 
     static rtl::OUString sType(RTL_CONSTASCII_USTRINGPARAM("Type"));
     static rtl::OUString sId(RTL_CONSTASCII_USTRINGPARAM("Id"));
@@ -190,8 +196,16 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
                     rDocumentTarget = sMyTarget;
                 else
                 {
-                    rDocumentTarget = msPath;
-                    rDocumentTarget += sMyTarget;
+                    // 'Target' is a relative Uri, so a 'Target=/path'
+                    // with a base Uri of file://base/foo will resolve to
+                    // file://base/word. We need something more than some
+                    // simple string concatination here to handle that.
+                    uno::Reference< com::sun::star::uri::XUriReference > xPart = xFac->parse(  sMyTarget );
+                    uno::Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute(  xBase, xPart, sal_True,  com::sun::star::uri::RelativeUriExcessParentSegments::RelativeUriExcessParentSegments_RETAIN );
+                    rDocumentTarget = xAbs->getPath();
+                    // path will start with the fragment separator. need to
+                    // remove that
+                    rDocumentTarget = rDocumentTarget.copy( 1 );
                 }
                 
                 break;


More information about the Libreoffice-commits mailing list