summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2011-06-07 19:04:40 +0100
committerNoel Power <noel.power@novell.com>2011-06-07 19:06:45 +0100
commit6808d3376167e1dc4d8c7c2e5cf0f122bbdf7dc4 (patch)
treed6bdc3e4e8572c854d7a8ef5f5f8b493ff66043d /oox
parent57be2940ad5214983e41e30ebdd301116ae83b45 (diff)
fix for bnc#693386
properly handle relative Uri(s) in Target
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/core/filterdetect.hxx3
-rw-r--r--oox/source/core/filterdetect.cxx28
2 files changed, 25 insertions, 6 deletions
diff --git a/oox/inc/oox/core/filterdetect.hxx b/oox/inc/oox/core/filterdetect.hxx
index b83b13910349..39b8abe8efb9 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;
};
// ============================================================================
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index dd218a616c0e..75e54f9eb123 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
@@ -659,7 +677,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. */
@@ -667,7 +685,7 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq
aParser.parseStream( aZipStorage, CREATE_OUSTRING( "[Content_Types].xml" ) );
}
}
- catch( Exception& )
+ catch( Exception& e )
{
}