Blob Blame History Raw
From f05438dda954965651f332b2f7ee97dbdd951b98 Mon Sep 17 00:00:00 2001
From: David Tardon <dtardon@redhat.com>
Date: Thu, 20 Sep 2012 10:28:56 +0200
Subject: [PATCH 2/4] rework selection of transformer for an XSLT filter

(cherry picked from commit ca0ea73a4ab104031a16b5bac7a9bb6e57c77ba0)

Conflicts:
	filter/source/xsltdialog/xmlfiltersettingsdialog.cxx

Change-Id: I765762f11813c6b612416a8db2707bf94114c876
---
 filter/source/xsltdialog/typedetectionexport.cxx   |  2 +-
 filter/source/xsltdialog/typedetectionimport.cxx   |  2 +-
 filter/source/xsltdialog/xmlfiltercommon.hxx       |  2 +-
 filter/source/xsltdialog/xmlfilterhelpids.hrc      |  3 +-
 .../source/xsltdialog/xmlfiltersettingsdialog.cxx  | 19 ++----
 filter/source/xsltdialog/xmlfiltertabpagexslt.cxx  | 20 ++-----
 filter/source/xsltdialog/xmlfiltertabpagexslt.hrc  |  5 +-
 filter/source/xsltdialog/xmlfiltertabpagexslt.hxx  |  5 +-
 filter/source/xsltdialog/xmlfiltertabpagexslt.src  | 23 +++----
 filter/source/xsltfilter/LibXSLTTransformer.cxx    |  4 +-
 filter/source/xsltfilter/LibXSLTTransformer.hxx    | 18 +++---
 filter/source/xsltfilter/XSLTFilter.cxx            | 70 +++++++++++++++-------
 .../sun/star/comp/xsltfilter/XSLTransformer.java   | 13 ++--
 filter/source/xsltfilter/components.rdb            |  4 +-
 filter/source/xsltfilter/xsltfilter.component      |  2 +-
 offapi/UnoApi_offapi.mk                            |  9 +++
 offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl  | 30 ++++++++++
 offapi/com/sun/star/xml/xslt/XSLTTransformer.idl   | 32 ++++++++++
 offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl  | 36 +++++++++++
 19 files changed, 204 insertions(+), 95 deletions(-)
 create mode 100644 offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl
 create mode 100644 offapi/com/sun/star/xml/xslt/XSLTTransformer.idl
 create mode 100644 offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl

diff --git a/filter/source/xsltdialog/typedetectionexport.cxx b/filter/source/xsltdialog/typedetectionexport.cxx
index a01b462..83bf7fa 100644
--- a/filter/source/xsltdialog/typedetectionexport.cxx
+++ b/filter/source/xsltdialog/typedetectionexport.cxx
@@ -192,7 +192,7 @@ void TypeDetectionExporter::doExport( Reference< XOutputStream > xOS,  const XML
                 sValue += sComma;
                 sValue += sXSLTFilterService;
                 sValue += sDelim;
-                sValue += pFilter->maXSLTTransformerImpl;
+                sValue += OUString::valueOf( pFilter->mbNeedsXSLT2 );
                 sValue += sDelim;
 
                 const application_info_impl* pAppInfo = getApplicationInfo( pFilter->maExportService );
diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx
index 3d3b937..50428e7 100644
--- a/filter/source/xsltdialog/typedetectionimport.cxx
+++ b/filter/source/xsltdialog/typedetectionimport.cxx
@@ -180,7 +180,7 @@ filter_info_impl* TypeDetectionImporter::createFilterForNode( Node * pNode )
 
     OUString aAdapterService( getSubdata( 0, aDelim, aFilterUserData ) );
     //Import/ExportService
-    pFilter->maXSLTTransformerImpl = getSubdata( 1, aDelim, aFilterUserData );
+    pFilter->mbNeedsXSLT2 = getSubdata( 1, aDelim, aFilterUserData ).toBoolean();
     pFilter->maImportService = getSubdata( 2, aDelim, aFilterUserData );
     pFilter->maExportService = getSubdata( 3, aDelim, aFilterUserData );
     pFilter->maImportXSLT = getSubdata( 4, aDelim, aFilterUserData );
diff --git a/filter/source/xsltdialog/xmlfiltercommon.hxx b/filter/source/xsltdialog/xmlfiltercommon.hxx
index cdb767e..41be2c7 100644
--- a/filter/source/xsltdialog/xmlfiltercommon.hxx
+++ b/filter/source/xsltdialog/xmlfiltercommon.hxx
@@ -77,7 +77,7 @@ public:
 
     sal_Bool        mbReadonly;
 
-    rtl::OUString   maXSLTTransformerImpl;
+    sal_Bool        mbNeedsXSLT2;
 
     filter_info_impl();
     filter_info_impl( const filter_info_impl& rInfo );
diff --git a/filter/source/xsltdialog/xmlfilterhelpids.hrc b/filter/source/xsltdialog/xmlfilterhelpids.hrc
index 558a274..a22fa52 100644
--- a/filter/source/xsltdialog/xmlfilterhelpids.hrc
+++ b/filter/source/xsltdialog/xmlfilterhelpids.hrc
@@ -50,8 +50,7 @@
 #define HID_XML_FILTER_DOCTYPE                              "FILTER_HID_XML_FILTER_DOCTYPE"
 #define HID_XML_FILTER_DTD                                  "FILTER_HID_XML_FILTER_DTD"
 #define HID_XML_FILTER_DTD_BROWSE                           "FILTER_HID_XML_FILTER_DTD_BROWSE"
-#define HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J			"FILTER_HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J"
-#define HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT			"FILTER_HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT"
+#define HID_XML_FILTER_NEEDS_XSLT2			    "FILTER_HID_XML_FILTER_NEEDS_XSLT2"
 #define HID_XML_FILTER_EXPORT_XSLT                          "FILTER_HID_XML_FILTER_EXPORT_XSLT"
 #define HID_XML_FILTER_EXPORT_XSLT_BROWSE                   "FILTER_HID_XML_FILTER_EXPORT_XSLT_BROWSE"
 #define HID_XML_FILTER_IMPORT_XSLT                          "FILTER_HID_XML_FILTER_IMPORT_XSLT"
diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
index 558ac0d..a54b520 100644
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
@@ -1164,7 +1164,7 @@ void XMLFilterSettingsDialog::initFilterList()
                     continue;
 
                 // get filter information from userdata
-                pTempFilter->maXSLTTransformerImpl = aUserData[1];
+                pTempFilter->mbNeedsXSLT2 = aUserData[1].toBoolean();
                 pTempFilter->maImportService = aUserData[2];
                 pTempFilter->maExportService = aUserData[3];
                 pTempFilter->maImportXSLT = aUserData[4];
@@ -1590,7 +1590,8 @@ filter_info_impl::filter_info_impl()
 :   maFlags(0x00080040),
     maFileFormatVersion(0),
     mnDocumentIconID(0),
-    mbReadonly(sal_False)
+    mbReadonly(sal_False),
+    mbNeedsXSLT2(sal_False)
 {
 }
 
@@ -1615,7 +1616,7 @@ filter_info_impl::filter_info_impl( const filter_info_impl& rInfo ) :
     maFileFormatVersion( rInfo.maFileFormatVersion ),
     mnDocumentIconID( rInfo.mnDocumentIconID ),
     mbReadonly( rInfo.mbReadonly ),
-    maXSLTTransformerImpl( rInfo.maXSLTTransformerImpl )
+    mbNeedsXSLT2( rInfo.mbNeedsXSLT2 )
 {
 }
 
@@ -1639,7 +1640,7 @@ int filter_info_impl::operator==( const filter_info_impl& r ) const
         maImportTemplate != r.maImportTemplate ||
         maFlags != r.maFlags ||
         maFileFormatVersion != r.maFileFormatVersion ||
-        maXSLTTransformerImpl != r.maXSLTTransformerImpl
+        mbNeedsXSLT2 != r.mbNeedsXSLT2
         )
         return false;
 
@@ -1653,15 +1654,7 @@ Sequence< OUString > filter_info_impl::getFilterUserData() const
     Sequence< OUString > aUserData(8);
 
     aUserData[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.documentconversion.XSLTFilter" ) );
-    /*
-    const application_info_impl* pInfo = getApplicationInfo( maDocumentService );
-    if( pInfo )
-    {
-        aUserData[2] = pInfo->maXMLImporter;
-        aUserData[3] = pInfo->maXMLExporter;
-    }
-    */
-    aUserData[1] = maXSLTTransformerImpl;
+    aUserData[1] = OUString::valueOf( mbNeedsXSLT2 );
     aUserData[2] = maImportService;
     aUserData[3] = maExportService;
     aUserData[4] = maImportXSLT;
diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx b/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx
index dc1a4c8..b4cae16 100644
--- a/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx
+++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx
@@ -68,9 +68,8 @@ XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, co
     maEDImportTemplate( this, ResId( ED_XML_IMPORT_TEMPLATE, rResMgr ), INET_PROT_FILE ),
     maPBImportTemplate( this, ResId( PB_XML_IMPORT_TEMPLATE_BROWSE, rResMgr ) ),
 
-    maFTTransformationService( this, ResId (FT_XML_TRANSFORM_SERVICE, rResMgr ) ),
-    maRBTransformationServiceLibXSLT( this, ResId (RB_XML_TRANSFORM_SERVICE_LIBXSLT, rResMgr ) ),
-    maRBTransformationServiceSaxonJ( this, ResId (RB_XML_TRANSFORM_SERVICE_SAXON_J, rResMgr ) ),
+    maFTNeedsXSLT2( this, ResId (FT_XML_NEEDS_XSLT2, rResMgr ) ),
+    maCBNeedsXSLT2( this, ResId (CB_XML_NEEDS_XSLT2, rResMgr ) ),
 
     sHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "http://" ) ),
     sSHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "shttp://" ) ),
@@ -100,8 +99,7 @@ XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, co
     maEDExportXSLT.SetHelpId( HID_XML_FILTER_EXPORT_XSLT );
     maEDImportXSLT.SetHelpId( HID_XML_FILTER_IMPORT_XSLT );
     maEDImportTemplate.SetHelpId( HID_XML_FILTER_IMPORT_TEMPLATE );
-    maRBTransformationServiceLibXSLT.SetHelpId( HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT );
-    maRBTransformationServiceSaxonJ.SetHelpId( HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J );
+    maCBNeedsXSLT2.SetHelpId( HID_XML_FILTER_NEEDS_XSLT2 );
 }
 
 XMLFilterTabPageXSLT::~XMLFilterTabPageXSLT()
@@ -117,10 +115,7 @@ bool XMLFilterTabPageXSLT::FillInfo( filter_info_impl* pInfo )
         pInfo->maExportXSLT = GetURL( maEDExportXSLT );
         pInfo->maImportXSLT = GetURL( maEDImportXSLT );
         pInfo->maImportTemplate = GetURL( maEDImportTemplate );
-        pInfo->maXSLTTransformerImpl
-                = maRBTransformationServiceSaxonJ.IsChecked() ? OUString(
-                        RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.JAXTHelper" ))
-                        : OUString(RTL_CONSTASCII_USTRINGPARAM( "" ));
+        pInfo->mbNeedsXSLT2 = maCBNeedsXSLT2.IsChecked();
     }
 
     return true;
@@ -136,12 +131,7 @@ void XMLFilterTabPageXSLT::SetInfo(const filter_info_impl* pInfo)
         SetURL( maEDExportXSLT, pInfo->maExportXSLT );
         SetURL( maEDImportXSLT, pInfo->maImportXSLT );
         SetURL( maEDImportTemplate, pInfo->maImportTemplate );
-        if (pInfo->maXSLTTransformerImpl.equals(OUString(
-                RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.JAXTHelper" )))) {
-            maRBTransformationServiceSaxonJ.Check();
-        } else {
-            maRBTransformationServiceLibXSLT.Check();
-        }
+        maCBNeedsXSLT2.Check( pInfo->mbNeedsXSLT2 );
     }
 }
 
diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.hrc b/filter/source/xsltdialog/xmlfiltertabpagexslt.hrc
index 12a9d46..bdd39e7 100644
--- a/filter/source/xsltdialog/xmlfiltertabpagexslt.hrc
+++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.hrc
@@ -44,8 +44,7 @@
 #define FT_XML_IMPORT_TEMPLATE          12
 #define ED_XML_IMPORT_TEMPLATE          13
 #define PB_XML_IMPORT_TEMPLATE_BROWSE   14
-#define FT_XML_TRANSFORM_SERVICE		15
-#define RB_XML_TRANSFORM_SERVICE_LIBXSLT 16
-#define RB_XML_TRANSFORM_SERVICE_SAXON_J 17
+#define FT_XML_NEEDS_XSLT2		15
+#define CB_XML_NEEDS_XSLT2		16
 
 #endif
diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.hxx b/filter/source/xsltdialog/xmlfiltertabpagexslt.hxx
index a9d8062..a0375b7 100644
--- a/filter/source/xsltdialog/xmlfiltertabpagexslt.hxx
+++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.hxx
@@ -69,9 +69,8 @@ public:
     SvtURLBox       maEDImportTemplate;
     PushButton      maPBImportTemplate;
 
-    FixedText       maFTTransformationService;
-    RadioButton		maRBTransformationServiceLibXSLT;
-    RadioButton		maRBTransformationServiceSaxonJ;
+    FixedText       maFTNeedsXSLT2;
+    CheckBox	    maCBNeedsXSLT2;
 
 private:
     void SetURL( SvtURLBox& rURLBox, const rtl::OUString& rURL );
diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.src b/filter/source/xsltdialog/xmlfiltertabpagexslt.src
index 2d0391c..96b83f7 100644
--- a/filter/source/xsltdialog/xmlfiltertabpagexslt.src
+++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.src
@@ -175,27 +175,18 @@ TabPage RID_XML_FILTER_TABPAGE_XSLT
 
     // XSLT transformation service --------------------------------------------------------
 
-    FixedText FT_XML_TRANSFORM_SERVICE
+    CheckBox CB_XML_NEEDS_XSLT2
     {
+        HelpID = HID_XML_FILTER_NEEDS_XSLT2;
         Pos                 = MAP_APPFONT ( FIRST_ROW_X , FIRST_ROW_Y + 5 * ROW_HEIGHT + 5 * SPACING + FIXED_TEXT_OFFSET + EDIT_OFFSET ) ;
-        Size                = MAP_APPFONT ( FIRST_ROW_WIDTH , 8 ) ;
-        Text [ en-US ]  = "XSLT Transformation Service";
-    };
-
-    RadioButton RB_XML_TRANSFORM_SERVICE_LIBXSLT
-    {
-        HelpID = HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT;
-        Pos                 = MAP_APPFONT ( SECOND_ROW_X , SECOND_ROW_Y + 5 * ROW_HEIGHT + 5 * SPACING + EDIT_OFFSET ) ;
-        Size                = MAP_APPFONT ( SECOND_ROW_WIDTH - SPACING - BROWSE_WIDTH, 12 ) ;
-        Text[ en-US ] = "~Builtin (LibXSLT)";
+        Size                = MAP_APPFONT ( 12, 12 ) ;
     };
 
-    RadioButton RB_XML_TRANSFORM_SERVICE_SAXON_J
+    FixedText FT_XML_NEEDS_XSLT2
     {
-        HelpID = HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J;
-        Pos                 = MAP_APPFONT ( SECOND_ROW_X , SECOND_ROW_Y + 6 * ROW_HEIGHT + 6 * SPACING + EDIT_OFFSET ) ;
-        Size                = MAP_APPFONT ( SECOND_ROW_WIDTH - SPACING - BROWSE_WIDTH, 12 ) ;
-        Text[ en-US ] = "~Saxon/J";
+        Pos                 = MAP_APPFONT ( FIRST_ROW_X + 3 * SPACING , SECOND_ROW_Y + 5 * ROW_HEIGHT + 5 * SPACING + FIXED_TEXT_OFFSET + EDIT_OFFSET ) ;
+        Size                = MAP_APPFONT ( 2 * FIRST_ROW_WIDTH , 8 ) ; // guess width
+        Text [ en-US ]  = "The filter needs XSLT 2.0 processor";
     };
 
 };
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx
index ff57fc1..ab03316 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.cxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx
@@ -488,9 +488,11 @@ namespace XSLT
     }
 
     void
-    LibXSLTTransformer::initialize(const Sequence<Any>& params)
+    LibXSLTTransformer::initialize(const Sequence<Any>& args)
             throw (RuntimeException)
     {
+        Sequence<Any> params;
+        args[0] >>= params;
         xmlSubstituteEntitiesDefault(0);
         m_parameters.clear();
         for (int i = 0; i < params.getLength(); i++)
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.hxx b/filter/source/xsltfilter/LibXSLTTransformer.hxx
index 444cb2f..a7c71a6 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.hxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.hxx
@@ -42,7 +42,7 @@
 
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/servicefactory.hxx>
-#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/implbase1.hxx>
 #include <cppuhelper/implbase.hxx>
 
 #include <rtl/ref.hxx>
@@ -51,14 +51,12 @@
 
 #include <com/sun/star/uno/Any.hxx>
 
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
-#include <com/sun/star/io/XActiveDataSink.hpp>
-#include <com/sun/star/io/XActiveDataControl.hpp>
 #include <com/sun/star/io/XStreamListener.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/xml/xslt/XXSLTTransformer.hpp>
 
 using namespace ::rtl;
 using namespace ::cppu;
@@ -66,7 +64,6 @@ using namespace ::osl;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::io;
 using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
 
 using ::std::list;
 using ::std::map;
@@ -90,8 +87,7 @@ namespace XSLT
      *
      * See Reader below.
      */
-    class LibXSLTTransformer : public WeakImplHelper4<XActiveDataSink,
-            XActiveDataSource, XActiveDataControl, XInitialization>
+    class LibXSLTTransformer : public WeakImplHelper1<com::sun::star::xml::xslt::XXSLTTransformer>
     {
     private:
         static const char* const PARAM_SOURCE_URL;
@@ -102,7 +98,7 @@ namespace XSLT
         static const char* const PARAM_DOCTYPE_PUBLIC;
 
         // the UNO ServiceFactory
-        com::sun::star::uno::Reference<XMultiServiceFactory> m_rServiceFactory;
+        com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> m_rServiceFactory;
 
         com::sun::star::uno::Reference<XInputStream> m_rInputStream;
 
@@ -129,7 +125,7 @@ namespace XSLT
     public:
 
         // ctor...
-        LibXSLTTransformer(const com::sun::star::uno::Reference<XMultiServiceFactory> &r);
+        LibXSLTTransformer(const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> &r);
 
         // XActiveDataSink
         virtual void SAL_CALL
@@ -169,7 +165,7 @@ namespace XSLT
         ::std::map<const char*, OString> SAL_CALL
         getParameters();
 
-        virtual com::sun::star::uno::Reference<XMultiServiceFactory> SAL_CALL
+        virtual com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> SAL_CALL
         getServiceFactory() {
             return m_rServiceFactory;
         }
diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx
index f3ebd2f..36968e7 100644
--- a/filter/source/xsltfilter/XSLTFilter.cxx
+++ b/filter/source/xsltfilter/XSLTFilter.cxx
@@ -41,6 +41,7 @@
 #include <rtl/strbuf.hxx>
 #include <tools/urlobj.hxx>
 
+#include <comphelper/componentcontext.hxx>
 #include <comphelper/interaction.hxx>
 
 #include <com/sun/star/lang/XComponent.hpp>
@@ -72,6 +73,8 @@
 #include <com/sun/star/task/XInteractionHandler.hpp>
 #include <com/sun/star/task/XInteractionRequest.hpp>
 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
+#include <com/sun/star/xml/xslt/XSLT2Transformer.hpp>
+#include <com/sun/star/xml/xslt/XSLTTransformer.hpp>
 
 #include <xmloff/attrlist.hxx>
 
@@ -102,14 +105,10 @@ namespace XSLT
      * them to an XSLT transformation service. XSLT transformation errors are
      * reported to XSLTFilter.
      *
-     * Currently, two implementations for the XSLT transformation service exist:
-     * a java based service (see XSLTransformer.java) and  a libxslt based
-     * service (LibXSLTTransformer.cxx).
-     *
-     * The libxslt implementation will be used by default.
-     *
-     * If the value of the 2nd "UserData" parameter of the filter configuration is
-     * not empty, the service name given there will be used.
+     * Currently, our transformation service is libxslt based, so it
+     * only supports XSLT 1.0. There is a possibility to use XSLT 2.0
+     * supporting service from an extension for a specific filter; the
+     * service must support com.sun.star.xml.xslt.XSLT2Transformer.
      */
     class XSLTFilter : public WeakImplHelper4<XImportFilter, XExportFilter,
             XStreamListener, ExtendedDocumentHandlerAdapter>
@@ -122,7 +121,7 @@ namespace XSLT
         // DocumentHandler interface of the css::xml::sax::Writer service
         css::uno::Reference<XOutputStream> m_rOutputStream;
 
-        css::uno::Reference<XActiveDataControl> m_tcontrol;
+        css::uno::Reference<xslt::XXSLTTransformer> m_tcontrol;
 
         oslCondition m_cTransformed;
         sal_Bool m_bTerminated;
@@ -135,6 +134,8 @@ namespace XSLT
         OUString
         expandUrl(const OUString&);
 
+        css::uno::Reference<xslt::XXSLTTransformer> impl_createTransformer(const rtl::OUString& rTransformer, const Sequence<Any>& rArgs);
+
     public:
 
         // ctor...
@@ -211,6 +212,43 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
         return sExpandedUrl;
     }
 
+    css::uno::Reference<xslt::XXSLTTransformer>
+    XSLTFilter::impl_createTransformer(const rtl::OUString& rTransformer, const Sequence<Any>& rArgs)
+    {
+        css::uno::Reference<xslt::XXSLTTransformer> xTransformer;
+
+        // check if the filter needs XSLT-2.0-capable transformer
+        // COMPATIBILITY: libreoffice 3.5/3.6 used to save the impl.
+        // name of the XSLT 2.0 transformation service there, so check
+        // for that too (it is sufficient to check that there is _a_
+        // service name there)
+        if (rTransformer.toBoolean() || rTransformer.match("com.sun."))
+        {
+            try
+            {
+                xTransformer = xslt::XSLT2Transformer::create(
+                        comphelper::ComponentContext(m_rServiceFactory).getUNOContext(), rArgs);
+            }
+            catch (const Exception&)
+            {
+                // TODO: put a dialog telling about the need to install
+                // xslt2-transformer extension here
+                SAL_WARN("filter.xslt", "could not create XSLT 2.0 transformer");
+                throw;
+            }
+        }
+
+        // instantiation of XSLT 2.0 transformer service failed, or the
+        // filter does not need it
+        if (!xTransformer.is())
+        {
+            xTransformer = xslt::XSLTTransformer::create(
+                    comphelper::ComponentContext(m_rServiceFactory).getUNOContext(), rArgs);
+        }
+
+        return xTransformer;
+    }
+
     void
     XSLTFilter::started() throw (RuntimeException)
     {
@@ -322,11 +360,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
         nv.Value <<= OUString(INetURLObject(aURL).getBase());
         args[2] <<= nv;
 
-        OUString serviceName("com.sun.star.comp.documentconversion.LibXSLTTransformer");
-        if (!msUserData[1].isEmpty())
-            serviceName = msUserData[1];
-
-        m_tcontrol = css::uno::Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY);
+        m_tcontrol = impl_createTransformer(msUserData[1], args);
 
         OSL_ASSERT(xHandler.is());
         OSL_ASSERT(xInputStream.is());
@@ -486,11 +520,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
         nv.Value <<= m_aExportBaseUrl;
         args[3] <<= nv;
 
-        OUString serviceName("com.sun.star.comp.documentconversion.LibXSLTTransformer");
-        if (!msUserData[1].isEmpty())
-            serviceName = msUserData[1];
-
-        m_tcontrol = css::uno::Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY);
+        m_tcontrol = impl_createTransformer(msUserData[1], args);
 
         OSL_ASSERT(m_rOutputStream.is());
         OSL_ASSERT(m_tcontrol.is());
@@ -566,7 +596,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
     // --------------------------------------
 #define FILTER_SERVICE_NAME "com.sun.star.documentconversion.XSLTFilter"
 #define FILTER_IMPL_NAME "com.sun.star.comp.documentconversion.XSLTFilter"
-#define TRANSFORMER_SERVICE_NAME "com.sun.star.documentconversion.LibXSLTTransformer"
+#define TRANSFORMER_SERVICE_NAME "com.sun.star.xml.xslt.XSLTTransformer"
 #define TRANSFORMER_IMPL_NAME "com.sun.star.comp.documentconversion.LibXSLTTransformer"
 
     static css::uno::Reference<XInterface> SAL_CALL
diff --git a/filter/source/xsltfilter/com/sun/star/comp/xsltfilter/XSLTransformer.java b/filter/source/xsltfilter/com/sun/star/comp/xsltfilter/XSLTransformer.java
index 1a6d8cf..7036646 100644
--- a/filter/source/xsltfilter/com/sun/star/comp/xsltfilter/XSLTransformer.java
+++ b/filter/source/xsltfilter/com/sun/star/comp/xsltfilter/XSLTransformer.java
@@ -75,6 +75,7 @@ import com.sun.star.registry.XRegistryKey;
 import com.sun.star.uno.AnyConverter;
 import com.sun.star.uno.Type;
 import com.sun.star.uno.UnoRuntime;
+import com.sun.star.xml.xslt.XXSLTTransformer;
 
 //Uno to java Adaptor
 import com.sun.star.lib.uno.adapter.XInputStreamToInputStreamAdapter;
@@ -88,8 +89,8 @@ import net.sf.saxon.FeatureKeys;
  * component on demand (__getServiceFactory()).
  */
 public class XSLTransformer
-        implements XTypeProvider, XServiceName, XServiceInfo, XActiveDataSink,
-        XActiveDataSource, XActiveDataControl, XInitialization, URIResolver, EntityResolver {
+        implements XTypeProvider, XServiceName, XServiceInfo, XXSLTTransformer,
+        URIResolver, EntityResolver {
 
     /**
      * This component provides java based XSL transformations
@@ -132,7 +133,7 @@ public class XSLTransformer
         svcfactory = msf;
     }
 
-    public void initialize(Object[] values) throws com.sun.star.uno.Exception {
+    public void initialize(Object[] args) throws com.sun.star.uno.Exception {
         // some configurable debugging
         String statsfilepath = null;
         if ((statsfilepath = System.getProperty(STATSPROP)) != null) {
@@ -146,6 +147,8 @@ public class XSLTransformer
             }
         }
 
+        Object[] values = (Object[]) args[0];
+
         // reading the values
         NamedValue nv = null;
         debug("The transformation's parameters as 'name = value' pairs:\n");
@@ -444,7 +447,7 @@ public class XSLTransformer
             }
         }
     }    // --- component management interfaces... ---
-    private final static String _serviceName = "com.sun.star.comp.JAXTHelper";
+    private final static String _serviceName = "com.sun.star.xml.xslt.XSLT2Transformer";
 
     // Implement methods from interface XTypeProvider
     public byte[] getImplementationId() {
@@ -494,7 +497,7 @@ public class XSLTransformer
     public static XSingleServiceFactory __getServiceFactory(
             String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey) {
         XSingleServiceFactory xSingleServiceFactory = null;
-        if (implName.indexOf("XSLTransformer") != -1) {
+        if (implName.equals(XSLTransformer.class.getName())) {
             xSingleServiceFactory = FactoryHelper.getServiceFactory(XSLTransformer.class,
                     _serviceName, multiFactory, regKey);
         }
diff --git a/filter/source/xsltfilter/components.rdb b/filter/source/xsltfilter/components.rdb
index 080cb7a..6014b82 100644
--- a/filter/source/xsltfilter/components.rdb
+++ b/filter/source/xsltfilter/components.rdb
@@ -1,8 +1,8 @@
 <?xml version="1.0"?>
 <components xmlns="http://openoffice.org/2010/uno-components">
     <component loader="com.sun.star.loader.Java2" uri="./XSLTFilter.jar">
-        <implementation name="XSLTransformer">
-            <service name="com.sun.star.comp.JAXTHelper"/>
+        <implementation name="com.sun.star.comp.xsltfilter.XSLTransformer">
+            <service name="com.sun.star.xml.xslt.XSLT2Transformer"/>
         </implementation>
     </component>
 </components>
diff --git a/filter/source/xsltfilter/xsltfilter.component b/filter/source/xsltfilter/xsltfilter.component
index 5fb985c..296f2bc 100644
--- a/filter/source/xsltfilter/xsltfilter.component
+++ b/filter/source/xsltfilter/xsltfilter.component
@@ -32,6 +32,6 @@
     <service name="com.sun.star.documentconversion.XSLTFilter"/>
   </implementation>
   <implementation name="com.sun.star.comp.documentconversion.LibXSLTTransformer">
-    <service name="com.sun.star.documentconversion.LibXSLTTransformer"/>
+    <service name="com.sun.star.xml.xslt.XSLTTransformer"/>
   </implementation>
 </component>
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 98cca5f..007cc52 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -285,6 +285,10 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xml/sax,\
 	FastShapeContextHandler \
 	FastTokenHandler \
 ))
+$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xml/xslt,\
+	XSLTTransformer \
+	XSLT2Transformer \
+))
 
 
 $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star,\
@@ -4255,6 +4259,11 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xml/xpath,\
 	XXPathExtension \
 	XXPathObject \
 ))
+
+$(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xml/xslt,\
+	XXSLTTransformer \
+))
+
 $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xsd,\
 	DataTypeClass \
 	WhiteSpaceTreatment \
diff --git a/offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl b/offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl
new file mode 100644
index 0000000..af5abed
--- /dev/null
+++ b/offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_COM_SUN_STAR_XML_XSLT_XSLT2TRANSFORMER_IDL
+#define INCLUDED_COM_SUN_STAR_XML_XSLT_XSLT2TRANSFORMER_IDL
+
+#include <com/sun/star/xml/xslt/XXSLTTransformer.idl>
+
+module com { module sun { module star { module xml { module xslt {
+
+/** Get XSLT filter transformer supporting XSLT 2.0.
+
+    @since LibreOffice 3.7
+ */
+service XSLT2Transformer : XXSLTTransformer
+{
+    create([in] sequence<any> args);
+};
+
+}; }; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/xml/xslt/XSLTTransformer.idl b/offapi/com/sun/star/xml/xslt/XSLTTransformer.idl
new file mode 100644
index 0000000..f9d75e3
--- /dev/null
+++ b/offapi/com/sun/star/xml/xslt/XSLTTransformer.idl
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_COM_SUN_STAR_XML_XSLT_XSLTTRANSFORMER_IDL
+#define INCLUDED_COM_SUN_STAR_XML_XSLT_XSLTTRANSFORMER_IDL
+
+#include <com/sun/star/xml/xslt/XXSLTTransformer.idl>
+
+module com { module sun { module star { module xml { module xslt {
+
+/** Get unspecified XSLT filter transformer.
+
+    <p>It is not safe to expect support for any features except XSLT 1.0 .
+
+    @since LibreOffice 3.7
+  */
+service XSLTTransformer : XXSLTTransformer
+{
+    create([in] sequence<any> args);
+};
+
+}; }; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl b/offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl
new file mode 100644
index 0000000..9316c25
--- /dev/null
+++ b/offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_COM_SUN_STAR_XML_XSLT_XXSLTTRANSFORMER_IDL
+#define INCLUDED_COM_SUN_STAR_XML_XSLT_XXSLTTRANSFORMER_IDL
+
+#include <com/sun/star/io/XActiveDataControl.idl>
+#include <com/sun/star/io/XActiveDataSink.idl>
+#include <com/sun/star/io/XActiveDataSource.idl>
+#include <com/sun/star/lang/XInitialization.idl>
+
+module com { module sun { module star { module xml { module xslt {
+
+/** An interface for XSLT transformers.
+
+    @since LibreOffice 3.7
+ */
+interface XXSLTTransformer
+{
+    interface com::sun::star::io::XActiveDataControl;
+    interface com::sun::star::io::XActiveDataSink;
+    interface com::sun::star::io::XActiveDataSource;
+    interface com::sun::star::lang::XInitialization;
+};
+
+}; }; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-- 
1.7.11.7