Commits

Anonymous committed 47a86b1 Merge

sw33bf06: merge fix for #i112473# from sb123

Comments (0)

Files changed (2)

 9f08556668b1565f293d735949e3b16d96e78651 DEV300_m80
 d3a11d2d353c2bf49d279018f2a59774484e9b38 DEV300_m81
 a5fb3c4091cbac8324a98bf080c08ef626b32258 DEV300_m82
+23debe0bf2cd63dd34c412ccb0de5e4dcfe62e58 DEV300_m83

xmloff/source/core/RDFaExportHelper.cxx

 #include <comphelper/stlunosequence.hxx>
 #include <comphelper/stl_types.hxx>
 
+#include <com/sun/star/uri/XUriReference.hpp>
+#include <com/sun/star/uri/XUriReferenceFactory.hpp>
 #include <com/sun/star/rdf/Statement.hpp>
 #include <com/sun/star/rdf/URIs.hpp>
 #include <com/sun/star/rdf/URI.hpp>
     return buf.makeStringAndClear();
 }
 
+// #i112473# SvXMLExport::GetRelativeReference() not right for RDF on SaveAs
+// because the URIs in the repository are not rewritten on SaveAs, the
+// URI of the loaded document has to be used, not the URI of the target doc.
+static ::rtl::OUString
+getRelativeReference(SvXMLExport const& rExport, ::rtl::OUString const& rURI)
+{
+    uno::Reference< rdf::XURI > const xModelURI(
+        rExport.GetModel(), uno::UNO_QUERY_THROW );
+    ::rtl::OUString const baseURI( xModelURI->getStringValue() );
+
+    uno::Reference<uno::XComponentContext> const xContext(
+        rExport.GetComponentContext());
+    uno::Reference<lang::XMultiComponentFactory> const xServiceFactory(
+        xContext->getServiceManager(), uno::UNO_SET_THROW);
+    uno::Reference<uri::XUriReferenceFactory> const xUriFactory(
+        xServiceFactory->createInstanceWithContext(
+            ::rtl::OUString::createFromAscii(
+                "com.sun.star.uri.UriReferenceFactory"), xContext),
+        uno::UNO_QUERY_THROW);
+
+    uno::Reference< uri::XUriReference > const xBaseURI(
+        xUriFactory->parse(baseURI), uno::UNO_SET_THROW );
+    uno::Reference< uri::XUriReference > const xAbsoluteURI(
+        xUriFactory->parse(rURI), uno::UNO_SET_THROW );
+    uno::Reference< uri::XUriReference > const xRelativeURI(
+        xUriFactory->makeRelative(xBaseURI, xAbsoluteURI, true, true, false),
+        uno::UNO_SET_THROW );
+    ::rtl::OUString const relativeURI(xRelativeURI->getUriReference());
+
+    return relativeURI;
+}
+
+
 ////////////////////////////////////////////////////////////////////////////
 
 RDFaExportHelper::RDFaExportHelper(SvXMLExport & i_rExport)
         static const sal_Unicode s_OpenBracket ('[');
         static const sal_Unicode s_CloseBracket(']');
         const ::rtl::OUString about( xSubjectURI.is()
-            ?   m_rExport.GetRelativeReference(xSubjectURI->getStringValue())
+            ?   getRelativeReference(m_rExport, xSubjectURI->getStringValue())
             :   ::rtl::OUStringBuffer().append(s_OpenBracket).append(
                         LookupBlankNode(xSubjectBNode)).append(s_CloseBracket)
                     .makeStringAndClear()