Kaydet (Commit) ca0ea73a authored tarafından David Tardon's avatar David Tardon

rework selection of transformer for an XSLT filter

Change-Id: I765762f11813c6b612416a8db2707bf94114c876
üst 25113cd0
...@@ -183,7 +183,7 @@ void TypeDetectionExporter::doExport( Reference< XOutputStream > xOS, const XML ...@@ -183,7 +183,7 @@ void TypeDetectionExporter::doExport( Reference< XOutputStream > xOS, const XML
sValue += sComma; sValue += sComma;
sValue += sXSLTFilterService; sValue += sXSLTFilterService;
sValue += sDelim; sValue += sDelim;
sValue += pFilter->maXSLTTransformerImpl; sValue += OUString::valueOf( pFilter->mbNeedsXSLT2 );
sValue += sDelim; sValue += sDelim;
const application_info_impl* pAppInfo = getApplicationInfo( pFilter->maExportService ); const application_info_impl* pAppInfo = getApplicationInfo( pFilter->maExportService );
......
...@@ -170,7 +170,7 @@ filter_info_impl* TypeDetectionImporter::createFilterForNode( Node * pNode ) ...@@ -170,7 +170,7 @@ filter_info_impl* TypeDetectionImporter::createFilterForNode( Node * pNode )
OUString aAdapterService( getSubdata( 0, aDelim, aFilterUserData ) ); OUString aAdapterService( getSubdata( 0, aDelim, aFilterUserData ) );
//Import/ExportService //Import/ExportService
pFilter->maXSLTTransformerImpl = getSubdata( 1, aDelim, aFilterUserData ); pFilter->mbNeedsXSLT2 = getSubdata( 1, aDelim, aFilterUserData ).toBoolean();
pFilter->maImportService = getSubdata( 2, aDelim, aFilterUserData ); pFilter->maImportService = getSubdata( 2, aDelim, aFilterUserData );
pFilter->maExportService = getSubdata( 3, aDelim, aFilterUserData ); pFilter->maExportService = getSubdata( 3, aDelim, aFilterUserData );
pFilter->maImportXSLT = getSubdata( 4, aDelim, aFilterUserData ); pFilter->maImportXSLT = getSubdata( 4, aDelim, aFilterUserData );
......
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
sal_Bool mbReadonly; sal_Bool mbReadonly;
rtl::OUString maXSLTTransformerImpl; sal_Bool mbNeedsXSLT2;
filter_info_impl(); filter_info_impl();
filter_info_impl( const filter_info_impl& rInfo ); filter_info_impl( const filter_info_impl& rInfo );
......
...@@ -41,8 +41,7 @@ ...@@ -41,8 +41,7 @@
#define HID_XML_FILTER_DOCTYPE "FILTER_HID_XML_FILTER_DOCTYPE" #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 "FILTER_HID_XML_FILTER_DTD"
#define HID_XML_FILTER_DTD_BROWSE "FILTER_HID_XML_FILTER_DTD_BROWSE" #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_NEEDS_XSLT2 "FILTER_HID_XML_FILTER_NEEDS_XSLT2"
#define HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT "FILTER_HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT"
#define HID_XML_FILTER_EXPORT_XSLT "FILTER_HID_XML_FILTER_EXPORT_XSLT" #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_EXPORT_XSLT_BROWSE "FILTER_HID_XML_FILTER_EXPORT_XSLT_BROWSE"
#define HID_XML_FILTER_IMPORT_XSLT "FILTER_HID_XML_FILTER_IMPORT_XSLT" #define HID_XML_FILTER_IMPORT_XSLT "FILTER_HID_XML_FILTER_IMPORT_XSLT"
......
...@@ -1152,7 +1152,7 @@ void XMLFilterSettingsDialog::initFilterList() ...@@ -1152,7 +1152,7 @@ void XMLFilterSettingsDialog::initFilterList()
continue; continue;
// get filter information from userdata // get filter information from userdata
pTempFilter->maXSLTTransformerImpl = aUserData[1]; pTempFilter->mbNeedsXSLT2 = aUserData[1].toBoolean();
pTempFilter->maImportService = aUserData[2]; pTempFilter->maImportService = aUserData[2];
pTempFilter->maExportService = aUserData[3]; pTempFilter->maExportService = aUserData[3];
pTempFilter->maImportXSLT = aUserData[4]; pTempFilter->maImportXSLT = aUserData[4];
...@@ -1572,7 +1572,8 @@ filter_info_impl::filter_info_impl() ...@@ -1572,7 +1572,8 @@ filter_info_impl::filter_info_impl()
: maFlags(0x00080040), : maFlags(0x00080040),
maFileFormatVersion(0), maFileFormatVersion(0),
mnDocumentIconID(0), mnDocumentIconID(0),
mbReadonly(sal_False) mbReadonly(sal_False),
mbNeedsXSLT2(sal_False)
{ {
} }
...@@ -1597,7 +1598,7 @@ filter_info_impl::filter_info_impl( const filter_info_impl& rInfo ) : ...@@ -1597,7 +1598,7 @@ filter_info_impl::filter_info_impl( const filter_info_impl& rInfo ) :
maFileFormatVersion( rInfo.maFileFormatVersion ), maFileFormatVersion( rInfo.maFileFormatVersion ),
mnDocumentIconID( rInfo.mnDocumentIconID ), mnDocumentIconID( rInfo.mnDocumentIconID ),
mbReadonly( rInfo.mbReadonly ), mbReadonly( rInfo.mbReadonly ),
maXSLTTransformerImpl( rInfo.maXSLTTransformerImpl ) mbNeedsXSLT2( rInfo.mbNeedsXSLT2 )
{ {
} }
...@@ -1621,7 +1622,7 @@ int filter_info_impl::operator==( const filter_info_impl& r ) const ...@@ -1621,7 +1622,7 @@ int filter_info_impl::operator==( const filter_info_impl& r ) const
maImportTemplate != r.maImportTemplate || maImportTemplate != r.maImportTemplate ||
maFlags != r.maFlags || maFlags != r.maFlags ||
maFileFormatVersion != r.maFileFormatVersion || maFileFormatVersion != r.maFileFormatVersion ||
maXSLTTransformerImpl != r.maXSLTTransformerImpl mbNeedsXSLT2 != r.mbNeedsXSLT2
) )
return false; return false;
...@@ -1635,7 +1636,7 @@ Sequence< OUString > filter_info_impl::getFilterUserData() const ...@@ -1635,7 +1636,7 @@ Sequence< OUString > filter_info_impl::getFilterUserData() const
Sequence< OUString > aUserData(8); Sequence< OUString > aUserData(8);
aUserData[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.documentconversion.XSLTFilter" ) ); aUserData[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.documentconversion.XSLTFilter" ) );
aUserData[1] = maXSLTTransformerImpl; aUserData[1] = OUString::valueOf( mbNeedsXSLT2 );
aUserData[2] = maImportService; aUserData[2] = maImportService;
aUserData[3] = maExportService; aUserData[3] = maExportService;
aUserData[4] = maImportXSLT; aUserData[4] = maImportXSLT;
......
...@@ -59,9 +59,8 @@ XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, co ...@@ -59,9 +59,8 @@ XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, co
maEDImportTemplate( this, ResId( ED_XML_IMPORT_TEMPLATE, rResMgr ), INET_PROT_FILE ), maEDImportTemplate( this, ResId( ED_XML_IMPORT_TEMPLATE, rResMgr ), INET_PROT_FILE ),
maPBImportTemplate( this, ResId( PB_XML_IMPORT_TEMPLATE_BROWSE, rResMgr ) ), maPBImportTemplate( this, ResId( PB_XML_IMPORT_TEMPLATE_BROWSE, rResMgr ) ),
maFTTransformationService( this, ResId (FT_XML_TRANSFORM_SERVICE, rResMgr ) ), maFTNeedsXSLT2( this, ResId (FT_XML_NEEDS_XSLT2, rResMgr ) ),
maRBTransformationServiceLibXSLT( this, ResId (RB_XML_TRANSFORM_SERVICE_LIBXSLT, rResMgr ) ), maCBNeedsXSLT2( this, ResId (CB_XML_NEEDS_XSLT2, rResMgr ) ),
maRBTransformationServiceSaxonJ( this, ResId (RB_XML_TRANSFORM_SERVICE_SAXON_J, rResMgr ) ),
sHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "http://" ) ), sHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "http://" ) ),
sSHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "shttp://" ) ), sSHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "shttp://" ) ),
...@@ -91,8 +90,7 @@ XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, co ...@@ -91,8 +90,7 @@ XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, co
maEDExportXSLT.SetHelpId( HID_XML_FILTER_EXPORT_XSLT ); maEDExportXSLT.SetHelpId( HID_XML_FILTER_EXPORT_XSLT );
maEDImportXSLT.SetHelpId( HID_XML_FILTER_IMPORT_XSLT ); maEDImportXSLT.SetHelpId( HID_XML_FILTER_IMPORT_XSLT );
maEDImportTemplate.SetHelpId( HID_XML_FILTER_IMPORT_TEMPLATE ); maEDImportTemplate.SetHelpId( HID_XML_FILTER_IMPORT_TEMPLATE );
maRBTransformationServiceLibXSLT.SetHelpId( HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT ); maCBNeedsXSLT2.SetHelpId( HID_XML_FILTER_NEEDS_XSLT2 );
maRBTransformationServiceSaxonJ.SetHelpId( HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J );
} }
XMLFilterTabPageXSLT::~XMLFilterTabPageXSLT() XMLFilterTabPageXSLT::~XMLFilterTabPageXSLT()
...@@ -108,10 +106,7 @@ bool XMLFilterTabPageXSLT::FillInfo( filter_info_impl* pInfo ) ...@@ -108,10 +106,7 @@ bool XMLFilterTabPageXSLT::FillInfo( filter_info_impl* pInfo )
pInfo->maExportXSLT = GetURL( maEDExportXSLT ); pInfo->maExportXSLT = GetURL( maEDExportXSLT );
pInfo->maImportXSLT = GetURL( maEDImportXSLT ); pInfo->maImportXSLT = GetURL( maEDImportXSLT );
pInfo->maImportTemplate = GetURL( maEDImportTemplate ); pInfo->maImportTemplate = GetURL( maEDImportTemplate );
pInfo->maXSLTTransformerImpl pInfo->mbNeedsXSLT2 = maCBNeedsXSLT2.IsChecked();
= maRBTransformationServiceSaxonJ.IsChecked() ? OUString(
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.JAXTHelper" ))
: OUString(RTL_CONSTASCII_USTRINGPARAM( "" ));
} }
return true; return true;
...@@ -127,12 +122,7 @@ void XMLFilterTabPageXSLT::SetInfo(const filter_info_impl* pInfo) ...@@ -127,12 +122,7 @@ void XMLFilterTabPageXSLT::SetInfo(const filter_info_impl* pInfo)
SetURL( maEDExportXSLT, pInfo->maExportXSLT ); SetURL( maEDExportXSLT, pInfo->maExportXSLT );
SetURL( maEDImportXSLT, pInfo->maImportXSLT ); SetURL( maEDImportXSLT, pInfo->maImportXSLT );
SetURL( maEDImportTemplate, pInfo->maImportTemplate ); SetURL( maEDImportTemplate, pInfo->maImportTemplate );
if (pInfo->maXSLTTransformerImpl.equals(OUString( maCBNeedsXSLT2.Check( pInfo->mbNeedsXSLT2 );
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.JAXTHelper" )))) {
maRBTransformationServiceSaxonJ.Check();
} else {
maRBTransformationServiceLibXSLT.Check();
}
} }
} }
......
...@@ -35,8 +35,7 @@ ...@@ -35,8 +35,7 @@
#define FT_XML_IMPORT_TEMPLATE 12 #define FT_XML_IMPORT_TEMPLATE 12
#define ED_XML_IMPORT_TEMPLATE 13 #define ED_XML_IMPORT_TEMPLATE 13
#define PB_XML_IMPORT_TEMPLATE_BROWSE 14 #define PB_XML_IMPORT_TEMPLATE_BROWSE 14
#define FT_XML_TRANSFORM_SERVICE 15 #define FT_XML_NEEDS_XSLT2 15
#define RB_XML_TRANSFORM_SERVICE_LIBXSLT 16 #define CB_XML_NEEDS_XSLT2 16
#define RB_XML_TRANSFORM_SERVICE_SAXON_J 17
#endif #endif
...@@ -60,9 +60,8 @@ public: ...@@ -60,9 +60,8 @@ public:
SvtURLBox maEDImportTemplate; SvtURLBox maEDImportTemplate;
PushButton maPBImportTemplate; PushButton maPBImportTemplate;
FixedText maFTTransformationService; FixedText maFTNeedsXSLT2;
RadioButton maRBTransformationServiceLibXSLT; CheckBox maCBNeedsXSLT2;
RadioButton maRBTransformationServiceSaxonJ;
private: private:
void SetURL( SvtURLBox& rURLBox, const rtl::OUString& rURL ); void SetURL( SvtURLBox& rURLBox, const rtl::OUString& rURL );
......
...@@ -166,27 +166,18 @@ TabPage RID_XML_FILTER_TABPAGE_XSLT ...@@ -166,27 +166,18 @@ TabPage RID_XML_FILTER_TABPAGE_XSLT
// XSLT transformation service -------------------------------------------------------- // 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 ) ; 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 ) ; Size = MAP_APPFONT ( 12, 12 ) ;
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)";
}; };
RadioButton RB_XML_TRANSFORM_SERVICE_SAXON_J FixedText FT_XML_NEEDS_XSLT2
{ {
HelpID = HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J; Pos = MAP_APPFONT ( FIRST_ROW_X + 3 * SPACING , SECOND_ROW_Y + 5 * ROW_HEIGHT + 5 * SPACING + FIXED_TEXT_OFFSET + EDIT_OFFSET ) ;
Pos = MAP_APPFONT ( SECOND_ROW_X , SECOND_ROW_Y + 6 * ROW_HEIGHT + 6 * SPACING + EDIT_OFFSET ) ; Size = MAP_APPFONT ( 2 * FIRST_ROW_WIDTH , 8 ) ; // guess width
Size = MAP_APPFONT ( SECOND_ROW_WIDTH - SPACING - BROWSE_WIDTH, 12 ) ; Text [ en-US ] = "The filter needs XSLT 2.0 processor";
Text[ en-US ] = "~Saxon/J";
}; };
}; };
......
...@@ -494,9 +494,11 @@ namespace XSLT ...@@ -494,9 +494,11 @@ namespace XSLT
} }
void void
LibXSLTTransformer::initialize(const Sequence<Any>& params) LibXSLTTransformer::initialize(const Sequence<Any>& args)
throw (RuntimeException) throw (RuntimeException)
{ {
Sequence<Any> params;
args[0] >>= params;
xmlSubstituteEntitiesDefault(0); xmlSubstituteEntitiesDefault(0);
m_parameters.clear(); m_parameters.clear();
for (int i = 0; i < params.getLength(); i++) for (int i = 0; i < params.getLength(); i++)
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include <cppuhelper/factory.hxx> #include <cppuhelper/factory.hxx>
#include <cppuhelper/servicefactory.hxx> #include <cppuhelper/servicefactory.hxx>
#include <cppuhelper/implbase4.hxx> #include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
...@@ -51,14 +51,12 @@ ...@@ -51,14 +51,12 @@
#include <com/sun/star/uno/Any.hxx> #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/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.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/io/XStreamListener.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/xml/xslt/XXSLTTransformer.hpp>
using namespace ::rtl; using namespace ::rtl;
using namespace ::cppu; using namespace ::cppu;
...@@ -66,7 +64,6 @@ using namespace ::osl; ...@@ -66,7 +64,6 @@ using namespace ::osl;
using namespace ::com::sun::star::beans; using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::io; using namespace ::com::sun::star::io;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using ::std::list; using ::std::list;
using ::std::map; using ::std::map;
...@@ -90,8 +87,7 @@ namespace XSLT ...@@ -90,8 +87,7 @@ namespace XSLT
* *
* See Reader below. * See Reader below.
*/ */
class LibXSLTTransformer : public WeakImplHelper4<XActiveDataSink, class LibXSLTTransformer : public WeakImplHelper1<com::sun::star::xml::xslt::XXSLTTransformer>
XActiveDataSource, XActiveDataControl, XInitialization>
{ {
private: private:
static const char* const PARAM_SOURCE_URL; static const char* const PARAM_SOURCE_URL;
...@@ -102,7 +98,7 @@ namespace XSLT ...@@ -102,7 +98,7 @@ namespace XSLT
static const char* const PARAM_DOCTYPE_PUBLIC; static const char* const PARAM_DOCTYPE_PUBLIC;
// the UNO ServiceFactory // 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; com::sun::star::uno::Reference<XInputStream> m_rInputStream;
...@@ -129,7 +125,7 @@ namespace XSLT ...@@ -129,7 +125,7 @@ namespace XSLT
public: public:
// ctor... // ctor...
LibXSLTTransformer(const com::sun::star::uno::Reference<XMultiServiceFactory> &r); LibXSLTTransformer(const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> &r);
// XActiveDataSink // XActiveDataSink
virtual void SAL_CALL virtual void SAL_CALL
...@@ -169,7 +165,7 @@ namespace XSLT ...@@ -169,7 +165,7 @@ namespace XSLT
::std::map<const char*, OString> SAL_CALL ::std::map<const char*, OString> SAL_CALL
getParameters(); getParameters();
virtual com::sun::star::uno::Reference<XMultiServiceFactory> SAL_CALL virtual com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> SAL_CALL
getServiceFactory() { getServiceFactory() {
return m_rServiceFactory; return m_rServiceFactory;
} }
......
...@@ -66,6 +66,8 @@ ...@@ -66,6 +66,8 @@
#include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/task/XInteractionRequest.hpp> #include <com/sun/star/task/XInteractionRequest.hpp>
#include <com/sun/star/ucb/InteractiveAugmentedIOException.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> #include <xmloff/attrlist.hxx>
...@@ -96,14 +98,10 @@ namespace XSLT ...@@ -96,14 +98,10 @@ namespace XSLT
* them to an XSLT transformation service. XSLT transformation errors are * them to an XSLT transformation service. XSLT transformation errors are
* reported to XSLTFilter. * reported to XSLTFilter.
* *
* Currently, two implementations for the XSLT transformation service exist: * Currently, our transformation service is libxslt based, so it
* a java based service (see XSLTransformer.java) and a libxslt based * only supports XSLT 1.0. There is a possibility to use XSLT 2.0
* service (LibXSLTTransformer.cxx). * supporting service from an extension for a specific filter; the
* * service must support com.sun.star.xml.xslt.XSLT2Transformer.
* 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.
*/ */
class XSLTFilter : public WeakImplHelper4<XImportFilter, XExportFilter, class XSLTFilter : public WeakImplHelper4<XImportFilter, XExportFilter,
XStreamListener, ExtendedDocumentHandlerAdapter> XStreamListener, ExtendedDocumentHandlerAdapter>
...@@ -116,7 +114,7 @@ namespace XSLT ...@@ -116,7 +114,7 @@ namespace XSLT
// DocumentHandler interface of the css::xml::sax::Writer service // DocumentHandler interface of the css::xml::sax::Writer service
css::uno::Reference<XOutputStream> m_rOutputStream; css::uno::Reference<XOutputStream> m_rOutputStream;
css::uno::Reference<XActiveDataControl> m_tcontrol; css::uno::Reference<xslt::XXSLTTransformer> m_tcontrol;
oslCondition m_cTransformed; oslCondition m_cTransformed;
sal_Bool m_bTerminated; sal_Bool m_bTerminated;
...@@ -129,6 +127,8 @@ namespace XSLT ...@@ -129,6 +127,8 @@ namespace XSLT
OUString OUString
expandUrl(const OUString&); expandUrl(const OUString&);
css::uno::Reference<xslt::XXSLTTransformer> impl_createTransformer(const rtl::OUString& rTransformer, const Sequence<Any>& rArgs);
public: public:
// ctor... // ctor...
...@@ -200,6 +200,43 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False) ...@@ -200,6 +200,43 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
return sExpandedUrl; 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.startsWith("com.sun."))
{
try
{
xTransformer = xslt::XSLT2Transformer::create(
comphelper::getComponentContext(m_rServiceFactory), 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::getComponentContext(m_rServiceFactory), rArgs);
}
return xTransformer;
}
void void
XSLTFilter::started() throw (RuntimeException) XSLTFilter::started() throw (RuntimeException)
{ {
...@@ -300,11 +337,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False) ...@@ -300,11 +337,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
nv.Value <<= OUString(INetURLObject(aURL).getBase()); nv.Value <<= OUString(INetURLObject(aURL).getBase());
args[2] <<= nv; args[2] <<= nv;
OUString serviceName("com.sun.star.comp.documentconversion.LibXSLTTransformer"); m_tcontrol = impl_createTransformer(msUserData[1], args);
if (!msUserData[1].isEmpty())
serviceName = msUserData[1];
m_tcontrol = css::uno::Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY);
OSL_ASSERT(xHandler.is()); OSL_ASSERT(xHandler.is());
OSL_ASSERT(xInputStream.is()); OSL_ASSERT(xInputStream.is());
...@@ -459,11 +492,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False) ...@@ -459,11 +492,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
nv.Value <<= m_aExportBaseUrl; nv.Value <<= m_aExportBaseUrl;
args[3] <<= nv; args[3] <<= nv;
OUString serviceName("com.sun.star.comp.documentconversion.LibXSLTTransformer"); m_tcontrol = impl_createTransformer(msUserData[1], args);
if (!msUserData[1].isEmpty())
serviceName = msUserData[1];
m_tcontrol = css::uno::Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY);
OSL_ASSERT(m_rOutputStream.is()); OSL_ASSERT(m_rOutputStream.is());
OSL_ASSERT(m_tcontrol.is()); OSL_ASSERT(m_tcontrol.is());
...@@ -536,7 +565,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False) ...@@ -536,7 +565,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
// -------------------------------------- // --------------------------------------
#define FILTER_SERVICE_NAME "com.sun.star.documentconversion.XSLTFilter" #define FILTER_SERVICE_NAME "com.sun.star.documentconversion.XSLTFilter"
#define FILTER_IMPL_NAME "com.sun.star.comp.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" #define TRANSFORMER_IMPL_NAME "com.sun.star.comp.documentconversion.LibXSLTTransformer"
static css::uno::Reference<XInterface> SAL_CALL static css::uno::Reference<XInterface> SAL_CALL
......
...@@ -68,6 +68,7 @@ import com.sun.star.registry.XRegistryKey; ...@@ -68,6 +68,7 @@ import com.sun.star.registry.XRegistryKey;
import com.sun.star.uno.AnyConverter; import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type; import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.xml.xslt.XXSLTTransformer;
//Uno to java Adaptor //Uno to java Adaptor
import com.sun.star.lib.uno.adapter.XInputStreamToInputStreamAdapter; import com.sun.star.lib.uno.adapter.XInputStreamToInputStreamAdapter;
...@@ -81,8 +82,8 @@ import net.sf.saxon.FeatureKeys; ...@@ -81,8 +82,8 @@ import net.sf.saxon.FeatureKeys;
* component on demand (__getServiceFactory()). * component on demand (__getServiceFactory()).
*/ */
public class XSLTransformer public class XSLTransformer
implements XTypeProvider, XServiceName, XServiceInfo, XActiveDataSink, implements XTypeProvider, XServiceName, XServiceInfo, XXSLTTransformer,
XActiveDataSource, XActiveDataControl, XInitialization, URIResolver, EntityResolver { URIResolver, EntityResolver {
/** /**
* This component provides java based XSL transformations * This component provides java based XSL transformations
...@@ -125,7 +126,7 @@ public class XSLTransformer ...@@ -125,7 +126,7 @@ public class XSLTransformer
svcfactory = msf; 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 // some configurable debugging
String statsfilepath = null; String statsfilepath = null;
if ((statsfilepath = System.getProperty(STATSPROP)) != null) { if ((statsfilepath = System.getProperty(STATSPROP)) != null) {
...@@ -139,6 +140,8 @@ public class XSLTransformer ...@@ -139,6 +140,8 @@ public class XSLTransformer
} }
} }
Object[] values = (Object[]) args[0];
// reading the values // reading the values
NamedValue nv = null; NamedValue nv = null;
debug("The transformation's parameters as 'name = value' pairs:\n"); debug("The transformation's parameters as 'name = value' pairs:\n");
...@@ -437,7 +440,7 @@ public class XSLTransformer ...@@ -437,7 +440,7 @@ public class XSLTransformer
} }
} }
} // --- component management interfaces... --- } // --- 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 // Implement methods from interface XTypeProvider
public byte[] getImplementationId() { public byte[] getImplementationId() {
...@@ -487,7 +490,7 @@ public class XSLTransformer ...@@ -487,7 +490,7 @@ public class XSLTransformer
public static XSingleServiceFactory __getServiceFactory( public static XSingleServiceFactory __getServiceFactory(
String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey) { String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey) {
XSingleServiceFactory xSingleServiceFactory = null; XSingleServiceFactory xSingleServiceFactory = null;
if (implName.indexOf("XSLTransformer") != -1) { if (implName.equals(XSLTransformer.class.getName())) {
xSingleServiceFactory = FactoryHelper.getServiceFactory(XSLTransformer.class, xSingleServiceFactory = FactoryHelper.getServiceFactory(XSLTransformer.class,
_serviceName, multiFactory, regKey); _serviceName, multiFactory, regKey);
} }
......
<?xml version="1.0"?> <?xml version="1.0"?>
<components xmlns="http://openoffice.org/2010/uno-components"> <components xmlns="http://openoffice.org/2010/uno-components">
<component loader="com.sun.star.loader.Java2" uri="./XSLTFilter.jar"> <component loader="com.sun.star.loader.Java2" uri="./XSLTFilter.jar">
<implementation name="XSLTransformer"> <implementation name="com.sun.star.comp.xsltfilter.XSLTransformer">
<service name="com.sun.star.comp.JAXTHelper"/> <service name="com.sun.star.xml.xslt.XSLT2Transformer"/>
</implementation> </implementation>
</component> </component>
</components> </components>
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
<service name="com.sun.star.documentconversion.XSLTFilter"/> <service name="com.sun.star.documentconversion.XSLTFilter"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.documentconversion.LibXSLTTransformer"> <implementation name="com.sun.star.comp.documentconversion.LibXSLTTransformer">
<service name="com.sun.star.documentconversion.LibXSLTTransformer"/> <service name="com.sun.star.xml.xslt.XSLTTransformer"/>
</implementation> </implementation>
</component> </component>
...@@ -326,6 +326,10 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xml/sax,\ ...@@ -326,6 +326,10 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xml/sax,\
Parser \ Parser \
Writer \ Writer \
)) ))
$(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,\ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star,\
...@@ -4272,6 +4276,11 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xml/xpath,\ ...@@ -4272,6 +4276,11 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xml/xpath,\
XXPathExtension \ XXPathExtension \
XXPathObject \ 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,\ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xsd,\
DataTypeClass \ DataTypeClass \
WhiteSpaceTreatment \ WhiteSpaceTreatment \
......
/* -*- 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 // INCLUDED_COM_SUN_STAR_XML_XSLT_XSLT2TRANSFORMER_IDL
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 // INCLUDED_COM_SUN_STAR_XML_XSLT_XSLTTRANSFORMER_IDL
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 // INCLUDED_COM_SUN_STAR_XML_XSLT_XXSLTTRANSFORMER_IDL
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment