1 |
From f05438dda954965651f332b2f7ee97dbdd951b98 Mon Sep 17 00:00:00 2001 |
2 |
From: David Tardon <dtardon@redhat.com> |
3 |
Date: Thu, 20 Sep 2012 10:28:56 +0200 |
4 |
Subject: [PATCH 2/4] rework selection of transformer for an XSLT filter |
5 |
|
6 |
(cherry picked from commit ca0ea73a4ab104031a16b5bac7a9bb6e57c77ba0) |
7 |
|
8 |
Conflicts: |
9 |
filter/source/xsltdialog/xmlfiltersettingsdialog.cxx |
10 |
|
11 |
Change-Id: I765762f11813c6b612416a8db2707bf94114c876 |
12 |
--- |
13 |
filter/source/xsltdialog/typedetectionexport.cxx | 2 +- |
14 |
filter/source/xsltdialog/typedetectionimport.cxx | 2 +- |
15 |
filter/source/xsltdialog/xmlfiltercommon.hxx | 2 +- |
16 |
filter/source/xsltdialog/xmlfilterhelpids.hrc | 3 +- |
17 |
.../source/xsltdialog/xmlfiltersettingsdialog.cxx | 19 ++---- |
18 |
filter/source/xsltdialog/xmlfiltertabpagexslt.cxx | 20 ++----- |
19 |
filter/source/xsltdialog/xmlfiltertabpagexslt.hrc | 5 +- |
20 |
filter/source/xsltdialog/xmlfiltertabpagexslt.hxx | 5 +- |
21 |
filter/source/xsltdialog/xmlfiltertabpagexslt.src | 23 +++---- |
22 |
filter/source/xsltfilter/LibXSLTTransformer.cxx | 4 +- |
23 |
filter/source/xsltfilter/LibXSLTTransformer.hxx | 18 +++--- |
24 |
filter/source/xsltfilter/XSLTFilter.cxx | 70 +++++++++++++++------- |
25 |
.../sun/star/comp/xsltfilter/XSLTransformer.java | 13 ++-- |
26 |
filter/source/xsltfilter/components.rdb | 4 +- |
27 |
filter/source/xsltfilter/xsltfilter.component | 2 +- |
28 |
offapi/UnoApi_offapi.mk | 9 +++ |
29 |
offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl | 30 ++++++++++ |
30 |
offapi/com/sun/star/xml/xslt/XSLTTransformer.idl | 32 ++++++++++ |
31 |
offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl | 36 +++++++++++ |
32 |
19 files changed, 204 insertions(+), 95 deletions(-) |
33 |
create mode 100644 offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl |
34 |
create mode 100644 offapi/com/sun/star/xml/xslt/XSLTTransformer.idl |
35 |
create mode 100644 offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl |
36 |
|
37 |
diff --git a/filter/source/xsltdialog/typedetectionexport.cxx b/filter/source/xsltdialog/typedetectionexport.cxx |
38 |
index a01b462..83bf7fa 100644 |
39 |
--- a/filter/source/xsltdialog/typedetectionexport.cxx |
40 |
+++ b/filter/source/xsltdialog/typedetectionexport.cxx |
41 |
@@ -192,7 +192,7 @@ void TypeDetectionExporter::doExport( Reference< XOutputStream > xOS, const XML |
42 |
sValue += sComma; |
43 |
sValue += sXSLTFilterService; |
44 |
sValue += sDelim; |
45 |
- sValue += pFilter->maXSLTTransformerImpl; |
46 |
+ sValue += OUString::valueOf( pFilter->mbNeedsXSLT2 ); |
47 |
sValue += sDelim; |
48 |
|
49 |
const application_info_impl* pAppInfo = getApplicationInfo( pFilter->maExportService ); |
50 |
diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx |
51 |
index 3d3b937..50428e7 100644 |
52 |
--- a/filter/source/xsltdialog/typedetectionimport.cxx |
53 |
+++ b/filter/source/xsltdialog/typedetectionimport.cxx |
54 |
@@ -180,7 +180,7 @@ filter_info_impl* TypeDetectionImporter::createFilterForNode( Node * pNode ) |
55 |
|
56 |
OUString aAdapterService( getSubdata( 0, aDelim, aFilterUserData ) ); |
57 |
//Import/ExportService |
58 |
- pFilter->maXSLTTransformerImpl = getSubdata( 1, aDelim, aFilterUserData ); |
59 |
+ pFilter->mbNeedsXSLT2 = getSubdata( 1, aDelim, aFilterUserData ).toBoolean(); |
60 |
pFilter->maImportService = getSubdata( 2, aDelim, aFilterUserData ); |
61 |
pFilter->maExportService = getSubdata( 3, aDelim, aFilterUserData ); |
62 |
pFilter->maImportXSLT = getSubdata( 4, aDelim, aFilterUserData ); |
63 |
diff --git a/filter/source/xsltdialog/xmlfiltercommon.hxx b/filter/source/xsltdialog/xmlfiltercommon.hxx |
64 |
index cdb767e..41be2c7 100644 |
65 |
--- a/filter/source/xsltdialog/xmlfiltercommon.hxx |
66 |
+++ b/filter/source/xsltdialog/xmlfiltercommon.hxx |
67 |
@@ -77,7 +77,7 @@ public: |
68 |
|
69 |
sal_Bool mbReadonly; |
70 |
|
71 |
- rtl::OUString maXSLTTransformerImpl; |
72 |
+ sal_Bool mbNeedsXSLT2; |
73 |
|
74 |
filter_info_impl(); |
75 |
filter_info_impl( const filter_info_impl& rInfo ); |
76 |
diff --git a/filter/source/xsltdialog/xmlfilterhelpids.hrc b/filter/source/xsltdialog/xmlfilterhelpids.hrc |
77 |
index 558a274..a22fa52 100644 |
78 |
--- a/filter/source/xsltdialog/xmlfilterhelpids.hrc |
79 |
+++ b/filter/source/xsltdialog/xmlfilterhelpids.hrc |
80 |
@@ -50,8 +50,7 @@ |
81 |
#define HID_XML_FILTER_DOCTYPE "FILTER_HID_XML_FILTER_DOCTYPE" |
82 |
#define HID_XML_FILTER_DTD "FILTER_HID_XML_FILTER_DTD" |
83 |
#define HID_XML_FILTER_DTD_BROWSE "FILTER_HID_XML_FILTER_DTD_BROWSE" |
84 |
-#define HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J "FILTER_HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J" |
85 |
-#define HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT "FILTER_HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT" |
86 |
+#define HID_XML_FILTER_NEEDS_XSLT2 "FILTER_HID_XML_FILTER_NEEDS_XSLT2" |
87 |
#define HID_XML_FILTER_EXPORT_XSLT "FILTER_HID_XML_FILTER_EXPORT_XSLT" |
88 |
#define HID_XML_FILTER_EXPORT_XSLT_BROWSE "FILTER_HID_XML_FILTER_EXPORT_XSLT_BROWSE" |
89 |
#define HID_XML_FILTER_IMPORT_XSLT "FILTER_HID_XML_FILTER_IMPORT_XSLT" |
90 |
diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx |
91 |
index 558ac0d..a54b520 100644 |
92 |
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx |
93 |
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx |
94 |
@@ -1164,7 +1164,7 @@ void XMLFilterSettingsDialog::initFilterList() |
95 |
continue; |
96 |
|
97 |
// get filter information from userdata |
98 |
- pTempFilter->maXSLTTransformerImpl = aUserData[1]; |
99 |
+ pTempFilter->mbNeedsXSLT2 = aUserData[1].toBoolean(); |
100 |
pTempFilter->maImportService = aUserData[2]; |
101 |
pTempFilter->maExportService = aUserData[3]; |
102 |
pTempFilter->maImportXSLT = aUserData[4]; |
103 |
@@ -1590,7 +1590,8 @@ filter_info_impl::filter_info_impl() |
104 |
: maFlags(0x00080040), |
105 |
maFileFormatVersion(0), |
106 |
mnDocumentIconID(0), |
107 |
- mbReadonly(sal_False) |
108 |
+ mbReadonly(sal_False), |
109 |
+ mbNeedsXSLT2(sal_False) |
110 |
{ |
111 |
} |
112 |
|
113 |
@@ -1615,7 +1616,7 @@ filter_info_impl::filter_info_impl( const filter_info_impl& rInfo ) : |
114 |
maFileFormatVersion( rInfo.maFileFormatVersion ), |
115 |
mnDocumentIconID( rInfo.mnDocumentIconID ), |
116 |
mbReadonly( rInfo.mbReadonly ), |
117 |
- maXSLTTransformerImpl( rInfo.maXSLTTransformerImpl ) |
118 |
+ mbNeedsXSLT2( rInfo.mbNeedsXSLT2 ) |
119 |
{ |
120 |
} |
121 |
|
122 |
@@ -1639,7 +1640,7 @@ int filter_info_impl::operator==( const filter_info_impl& r ) const |
123 |
maImportTemplate != r.maImportTemplate || |
124 |
maFlags != r.maFlags || |
125 |
maFileFormatVersion != r.maFileFormatVersion || |
126 |
- maXSLTTransformerImpl != r.maXSLTTransformerImpl |
127 |
+ mbNeedsXSLT2 != r.mbNeedsXSLT2 |
128 |
) |
129 |
return false; |
130 |
|
131 |
@@ -1653,15 +1654,7 @@ Sequence< OUString > filter_info_impl::getFilterUserData() const |
132 |
Sequence< OUString > aUserData(8); |
133 |
|
134 |
aUserData[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.documentconversion.XSLTFilter" ) ); |
135 |
- /* |
136 |
- const application_info_impl* pInfo = getApplicationInfo( maDocumentService ); |
137 |
- if( pInfo ) |
138 |
- { |
139 |
- aUserData[2] = pInfo->maXMLImporter; |
140 |
- aUserData[3] = pInfo->maXMLExporter; |
141 |
- } |
142 |
- */ |
143 |
- aUserData[1] = maXSLTTransformerImpl; |
144 |
+ aUserData[1] = OUString::valueOf( mbNeedsXSLT2 ); |
145 |
aUserData[2] = maImportService; |
146 |
aUserData[3] = maExportService; |
147 |
aUserData[4] = maImportXSLT; |
148 |
diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx b/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx |
149 |
index dc1a4c8..b4cae16 100644 |
150 |
--- a/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx |
151 |
+++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.cxx |
152 |
@@ -68,9 +68,8 @@ XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, co |
153 |
maEDImportTemplate( this, ResId( ED_XML_IMPORT_TEMPLATE, rResMgr ), INET_PROT_FILE ), |
154 |
maPBImportTemplate( this, ResId( PB_XML_IMPORT_TEMPLATE_BROWSE, rResMgr ) ), |
155 |
|
156 |
- maFTTransformationService( this, ResId (FT_XML_TRANSFORM_SERVICE, rResMgr ) ), |
157 |
- maRBTransformationServiceLibXSLT( this, ResId (RB_XML_TRANSFORM_SERVICE_LIBXSLT, rResMgr ) ), |
158 |
- maRBTransformationServiceSaxonJ( this, ResId (RB_XML_TRANSFORM_SERVICE_SAXON_J, rResMgr ) ), |
159 |
+ maFTNeedsXSLT2( this, ResId (FT_XML_NEEDS_XSLT2, rResMgr ) ), |
160 |
+ maCBNeedsXSLT2( this, ResId (CB_XML_NEEDS_XSLT2, rResMgr ) ), |
161 |
|
162 |
sHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "http://" ) ), |
163 |
sSHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "shttp://" ) ), |
164 |
@@ -100,8 +99,7 @@ XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, co |
165 |
maEDExportXSLT.SetHelpId( HID_XML_FILTER_EXPORT_XSLT ); |
166 |
maEDImportXSLT.SetHelpId( HID_XML_FILTER_IMPORT_XSLT ); |
167 |
maEDImportTemplate.SetHelpId( HID_XML_FILTER_IMPORT_TEMPLATE ); |
168 |
- maRBTransformationServiceLibXSLT.SetHelpId( HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT ); |
169 |
- maRBTransformationServiceSaxonJ.SetHelpId( HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J ); |
170 |
+ maCBNeedsXSLT2.SetHelpId( HID_XML_FILTER_NEEDS_XSLT2 ); |
171 |
} |
172 |
|
173 |
XMLFilterTabPageXSLT::~XMLFilterTabPageXSLT() |
174 |
@@ -117,10 +115,7 @@ bool XMLFilterTabPageXSLT::FillInfo( filter_info_impl* pInfo ) |
175 |
pInfo->maExportXSLT = GetURL( maEDExportXSLT ); |
176 |
pInfo->maImportXSLT = GetURL( maEDImportXSLT ); |
177 |
pInfo->maImportTemplate = GetURL( maEDImportTemplate ); |
178 |
- pInfo->maXSLTTransformerImpl |
179 |
- = maRBTransformationServiceSaxonJ.IsChecked() ? OUString( |
180 |
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.JAXTHelper" )) |
181 |
- : OUString(RTL_CONSTASCII_USTRINGPARAM( "" )); |
182 |
+ pInfo->mbNeedsXSLT2 = maCBNeedsXSLT2.IsChecked(); |
183 |
} |
184 |
|
185 |
return true; |
186 |
@@ -136,12 +131,7 @@ void XMLFilterTabPageXSLT::SetInfo(const filter_info_impl* pInfo) |
187 |
SetURL( maEDExportXSLT, pInfo->maExportXSLT ); |
188 |
SetURL( maEDImportXSLT, pInfo->maImportXSLT ); |
189 |
SetURL( maEDImportTemplate, pInfo->maImportTemplate ); |
190 |
- if (pInfo->maXSLTTransformerImpl.equals(OUString( |
191 |
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.JAXTHelper" )))) { |
192 |
- maRBTransformationServiceSaxonJ.Check(); |
193 |
- } else { |
194 |
- maRBTransformationServiceLibXSLT.Check(); |
195 |
- } |
196 |
+ maCBNeedsXSLT2.Check( pInfo->mbNeedsXSLT2 ); |
197 |
} |
198 |
} |
199 |
|
200 |
diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.hrc b/filter/source/xsltdialog/xmlfiltertabpagexslt.hrc |
201 |
index 12a9d46..bdd39e7 100644 |
202 |
--- a/filter/source/xsltdialog/xmlfiltertabpagexslt.hrc |
203 |
+++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.hrc |
204 |
@@ -44,8 +44,7 @@ |
205 |
#define FT_XML_IMPORT_TEMPLATE 12 |
206 |
#define ED_XML_IMPORT_TEMPLATE 13 |
207 |
#define PB_XML_IMPORT_TEMPLATE_BROWSE 14 |
208 |
-#define FT_XML_TRANSFORM_SERVICE 15 |
209 |
-#define RB_XML_TRANSFORM_SERVICE_LIBXSLT 16 |
210 |
-#define RB_XML_TRANSFORM_SERVICE_SAXON_J 17 |
211 |
+#define FT_XML_NEEDS_XSLT2 15 |
212 |
+#define CB_XML_NEEDS_XSLT2 16 |
213 |
|
214 |
#endif |
215 |
diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.hxx b/filter/source/xsltdialog/xmlfiltertabpagexslt.hxx |
216 |
index a9d8062..a0375b7 100644 |
217 |
--- a/filter/source/xsltdialog/xmlfiltertabpagexslt.hxx |
218 |
+++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.hxx |
219 |
@@ -69,9 +69,8 @@ public: |
220 |
SvtURLBox maEDImportTemplate; |
221 |
PushButton maPBImportTemplate; |
222 |
|
223 |
- FixedText maFTTransformationService; |
224 |
- RadioButton maRBTransformationServiceLibXSLT; |
225 |
- RadioButton maRBTransformationServiceSaxonJ; |
226 |
+ FixedText maFTNeedsXSLT2; |
227 |
+ CheckBox maCBNeedsXSLT2; |
228 |
|
229 |
private: |
230 |
void SetURL( SvtURLBox& rURLBox, const rtl::OUString& rURL ); |
231 |
diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.src b/filter/source/xsltdialog/xmlfiltertabpagexslt.src |
232 |
index 2d0391c..96b83f7 100644 |
233 |
--- a/filter/source/xsltdialog/xmlfiltertabpagexslt.src |
234 |
+++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.src |
235 |
@@ -175,27 +175,18 @@ TabPage RID_XML_FILTER_TABPAGE_XSLT |
236 |
|
237 |
// XSLT transformation service -------------------------------------------------------- |
238 |
|
239 |
- FixedText FT_XML_TRANSFORM_SERVICE |
240 |
+ CheckBox CB_XML_NEEDS_XSLT2 |
241 |
{ |
242 |
+ HelpID = HID_XML_FILTER_NEEDS_XSLT2; |
243 |
Pos = MAP_APPFONT ( FIRST_ROW_X , FIRST_ROW_Y + 5 * ROW_HEIGHT + 5 * SPACING + FIXED_TEXT_OFFSET + EDIT_OFFSET ) ; |
244 |
- Size = MAP_APPFONT ( FIRST_ROW_WIDTH , 8 ) ; |
245 |
- Text [ en-US ] = "XSLT Transformation Service"; |
246 |
- }; |
247 |
- |
248 |
- RadioButton RB_XML_TRANSFORM_SERVICE_LIBXSLT |
249 |
- { |
250 |
- HelpID = HID_XML_FILTER_TRANSFORM_SERVICE_LIBXSLT; |
251 |
- Pos = MAP_APPFONT ( SECOND_ROW_X , SECOND_ROW_Y + 5 * ROW_HEIGHT + 5 * SPACING + EDIT_OFFSET ) ; |
252 |
- Size = MAP_APPFONT ( SECOND_ROW_WIDTH - SPACING - BROWSE_WIDTH, 12 ) ; |
253 |
- Text[ en-US ] = "~Builtin (LibXSLT)"; |
254 |
+ Size = MAP_APPFONT ( 12, 12 ) ; |
255 |
}; |
256 |
|
257 |
- RadioButton RB_XML_TRANSFORM_SERVICE_SAXON_J |
258 |
+ FixedText FT_XML_NEEDS_XSLT2 |
259 |
{ |
260 |
- HelpID = HID_XML_FILTER_TRANSFORM_SERVICE_SAXON_J; |
261 |
- Pos = MAP_APPFONT ( SECOND_ROW_X , SECOND_ROW_Y + 6 * ROW_HEIGHT + 6 * SPACING + EDIT_OFFSET ) ; |
262 |
- Size = MAP_APPFONT ( SECOND_ROW_WIDTH - SPACING - BROWSE_WIDTH, 12 ) ; |
263 |
- Text[ en-US ] = "~Saxon/J"; |
264 |
+ Pos = MAP_APPFONT ( FIRST_ROW_X + 3 * SPACING , SECOND_ROW_Y + 5 * ROW_HEIGHT + 5 * SPACING + FIXED_TEXT_OFFSET + EDIT_OFFSET ) ; |
265 |
+ Size = MAP_APPFONT ( 2 * FIRST_ROW_WIDTH , 8 ) ; // guess width |
266 |
+ Text [ en-US ] = "The filter needs XSLT 2.0 processor"; |
267 |
}; |
268 |
|
269 |
}; |
270 |
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx |
271 |
index ff57fc1..ab03316 100644 |
272 |
--- a/filter/source/xsltfilter/LibXSLTTransformer.cxx |
273 |
+++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx |
274 |
@@ -488,9 +488,11 @@ namespace XSLT |
275 |
} |
276 |
|
277 |
void |
278 |
- LibXSLTTransformer::initialize(const Sequence<Any>& params) |
279 |
+ LibXSLTTransformer::initialize(const Sequence<Any>& args) |
280 |
throw (RuntimeException) |
281 |
{ |
282 |
+ Sequence<Any> params; |
283 |
+ args[0] >>= params; |
284 |
xmlSubstituteEntitiesDefault(0); |
285 |
m_parameters.clear(); |
286 |
for (int i = 0; i < params.getLength(); i++) |
287 |
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.hxx b/filter/source/xsltfilter/LibXSLTTransformer.hxx |
288 |
index 444cb2f..a7c71a6 100644 |
289 |
--- a/filter/source/xsltfilter/LibXSLTTransformer.hxx |
290 |
+++ b/filter/source/xsltfilter/LibXSLTTransformer.hxx |
291 |
@@ -42,7 +42,7 @@ |
292 |
|
293 |
#include <cppuhelper/factory.hxx> |
294 |
#include <cppuhelper/servicefactory.hxx> |
295 |
-#include <cppuhelper/implbase4.hxx> |
296 |
+#include <cppuhelper/implbase1.hxx> |
297 |
#include <cppuhelper/implbase.hxx> |
298 |
|
299 |
#include <rtl/ref.hxx> |
300 |
@@ -51,14 +51,12 @@ |
301 |
|
302 |
#include <com/sun/star/uno/Any.hxx> |
303 |
|
304 |
+#include <com/sun/star/lang/XMultiServiceFactory.hpp> |
305 |
#include <com/sun/star/io/XInputStream.hpp> |
306 |
#include <com/sun/star/io/XOutputStream.hpp> |
307 |
-#include <com/sun/star/io/XActiveDataSource.hpp> |
308 |
-#include <com/sun/star/io/XActiveDataSink.hpp> |
309 |
-#include <com/sun/star/io/XActiveDataControl.hpp> |
310 |
#include <com/sun/star/io/XStreamListener.hpp> |
311 |
-#include <com/sun/star/lang/XInitialization.hpp> |
312 |
#include <com/sun/star/beans/NamedValue.hpp> |
313 |
+#include <com/sun/star/xml/xslt/XXSLTTransformer.hpp> |
314 |
|
315 |
using namespace ::rtl; |
316 |
using namespace ::cppu; |
317 |
@@ -66,7 +64,6 @@ using namespace ::osl; |
318 |
using namespace ::com::sun::star::beans; |
319 |
using namespace ::com::sun::star::io; |
320 |
using namespace ::com::sun::star::uno; |
321 |
-using namespace ::com::sun::star::lang; |
322 |
|
323 |
using ::std::list; |
324 |
using ::std::map; |
325 |
@@ -90,8 +87,7 @@ namespace XSLT |
326 |
* |
327 |
* See Reader below. |
328 |
*/ |
329 |
- class LibXSLTTransformer : public WeakImplHelper4<XActiveDataSink, |
330 |
- XActiveDataSource, XActiveDataControl, XInitialization> |
331 |
+ class LibXSLTTransformer : public WeakImplHelper1<com::sun::star::xml::xslt::XXSLTTransformer> |
332 |
{ |
333 |
private: |
334 |
static const char* const PARAM_SOURCE_URL; |
335 |
@@ -102,7 +98,7 @@ namespace XSLT |
336 |
static const char* const PARAM_DOCTYPE_PUBLIC; |
337 |
|
338 |
// the UNO ServiceFactory |
339 |
- com::sun::star::uno::Reference<XMultiServiceFactory> m_rServiceFactory; |
340 |
+ com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> m_rServiceFactory; |
341 |
|
342 |
com::sun::star::uno::Reference<XInputStream> m_rInputStream; |
343 |
|
344 |
@@ -129,7 +125,7 @@ namespace XSLT |
345 |
public: |
346 |
|
347 |
// ctor... |
348 |
- LibXSLTTransformer(const com::sun::star::uno::Reference<XMultiServiceFactory> &r); |
349 |
+ LibXSLTTransformer(const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> &r); |
350 |
|
351 |
// XActiveDataSink |
352 |
virtual void SAL_CALL |
353 |
@@ -169,7 +165,7 @@ namespace XSLT |
354 |
::std::map<const char*, OString> SAL_CALL |
355 |
getParameters(); |
356 |
|
357 |
- virtual com::sun::star::uno::Reference<XMultiServiceFactory> SAL_CALL |
358 |
+ virtual com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> SAL_CALL |
359 |
getServiceFactory() { |
360 |
return m_rServiceFactory; |
361 |
} |
362 |
diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx |
363 |
index f3ebd2f..36968e7 100644 |
364 |
--- a/filter/source/xsltfilter/XSLTFilter.cxx |
365 |
+++ b/filter/source/xsltfilter/XSLTFilter.cxx |
366 |
@@ -41,6 +41,7 @@ |
367 |
#include <rtl/strbuf.hxx> |
368 |
#include <tools/urlobj.hxx> |
369 |
|
370 |
+#include <comphelper/componentcontext.hxx> |
371 |
#include <comphelper/interaction.hxx> |
372 |
|
373 |
#include <com/sun/star/lang/XComponent.hpp> |
374 |
@@ -72,6 +73,8 @@ |
375 |
#include <com/sun/star/task/XInteractionHandler.hpp> |
376 |
#include <com/sun/star/task/XInteractionRequest.hpp> |
377 |
#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> |
378 |
+#include <com/sun/star/xml/xslt/XSLT2Transformer.hpp> |
379 |
+#include <com/sun/star/xml/xslt/XSLTTransformer.hpp> |
380 |
|
381 |
#include <xmloff/attrlist.hxx> |
382 |
|
383 |
@@ -102,14 +105,10 @@ namespace XSLT |
384 |
* them to an XSLT transformation service. XSLT transformation errors are |
385 |
* reported to XSLTFilter. |
386 |
* |
387 |
- * Currently, two implementations for the XSLT transformation service exist: |
388 |
- * a java based service (see XSLTransformer.java) and a libxslt based |
389 |
- * service (LibXSLTTransformer.cxx). |
390 |
- * |
391 |
- * The libxslt implementation will be used by default. |
392 |
- * |
393 |
- * If the value of the 2nd "UserData" parameter of the filter configuration is |
394 |
- * not empty, the service name given there will be used. |
395 |
+ * Currently, our transformation service is libxslt based, so it |
396 |
+ * only supports XSLT 1.0. There is a possibility to use XSLT 2.0 |
397 |
+ * supporting service from an extension for a specific filter; the |
398 |
+ * service must support com.sun.star.xml.xslt.XSLT2Transformer. |
399 |
*/ |
400 |
class XSLTFilter : public WeakImplHelper4<XImportFilter, XExportFilter, |
401 |
XStreamListener, ExtendedDocumentHandlerAdapter> |
402 |
@@ -122,7 +121,7 @@ namespace XSLT |
403 |
// DocumentHandler interface of the css::xml::sax::Writer service |
404 |
css::uno::Reference<XOutputStream> m_rOutputStream; |
405 |
|
406 |
- css::uno::Reference<XActiveDataControl> m_tcontrol; |
407 |
+ css::uno::Reference<xslt::XXSLTTransformer> m_tcontrol; |
408 |
|
409 |
oslCondition m_cTransformed; |
410 |
sal_Bool m_bTerminated; |
411 |
@@ -135,6 +134,8 @@ namespace XSLT |
412 |
OUString |
413 |
expandUrl(const OUString&); |
414 |
|
415 |
+ css::uno::Reference<xslt::XXSLTTransformer> impl_createTransformer(const rtl::OUString& rTransformer, const Sequence<Any>& rArgs); |
416 |
+ |
417 |
public: |
418 |
|
419 |
// ctor... |
420 |
@@ -211,6 +212,43 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False) |
421 |
return sExpandedUrl; |
422 |
} |
423 |
|
424 |
+ css::uno::Reference<xslt::XXSLTTransformer> |
425 |
+ XSLTFilter::impl_createTransformer(const rtl::OUString& rTransformer, const Sequence<Any>& rArgs) |
426 |
+ { |
427 |
+ css::uno::Reference<xslt::XXSLTTransformer> xTransformer; |
428 |
+ |
429 |
+ // check if the filter needs XSLT-2.0-capable transformer |
430 |
+ // COMPATIBILITY: libreoffice 3.5/3.6 used to save the impl. |
431 |
+ // name of the XSLT 2.0 transformation service there, so check |
432 |
+ // for that too (it is sufficient to check that there is _a_ |
433 |
+ // service name there) |
434 |
+ if (rTransformer.toBoolean() || rTransformer.match("com.sun.")) |
435 |
+ { |
436 |
+ try |
437 |
+ { |
438 |
+ xTransformer = xslt::XSLT2Transformer::create( |
439 |
+ comphelper::ComponentContext(m_rServiceFactory).getUNOContext(), rArgs); |
440 |
+ } |
441 |
+ catch (const Exception&) |
442 |
+ { |
443 |
+ // TODO: put a dialog telling about the need to install |
444 |
+ // xslt2-transformer extension here |
445 |
+ SAL_WARN("filter.xslt", "could not create XSLT 2.0 transformer"); |
446 |
+ throw; |
447 |
+ } |
448 |
+ } |
449 |
+ |
450 |
+ // instantiation of XSLT 2.0 transformer service failed, or the |
451 |
+ // filter does not need it |
452 |
+ if (!xTransformer.is()) |
453 |
+ { |
454 |
+ xTransformer = xslt::XSLTTransformer::create( |
455 |
+ comphelper::ComponentContext(m_rServiceFactory).getUNOContext(), rArgs); |
456 |
+ } |
457 |
+ |
458 |
+ return xTransformer; |
459 |
+ } |
460 |
+ |
461 |
void |
462 |
XSLTFilter::started() throw (RuntimeException) |
463 |
{ |
464 |
@@ -322,11 +360,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False) |
465 |
nv.Value <<= OUString(INetURLObject(aURL).getBase()); |
466 |
args[2] <<= nv; |
467 |
|
468 |
- OUString serviceName("com.sun.star.comp.documentconversion.LibXSLTTransformer"); |
469 |
- if (!msUserData[1].isEmpty()) |
470 |
- serviceName = msUserData[1]; |
471 |
- |
472 |
- m_tcontrol = css::uno::Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY); |
473 |
+ m_tcontrol = impl_createTransformer(msUserData[1], args); |
474 |
|
475 |
OSL_ASSERT(xHandler.is()); |
476 |
OSL_ASSERT(xInputStream.is()); |
477 |
@@ -486,11 +520,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False) |
478 |
nv.Value <<= m_aExportBaseUrl; |
479 |
args[3] <<= nv; |
480 |
|
481 |
- OUString serviceName("com.sun.star.comp.documentconversion.LibXSLTTransformer"); |
482 |
- if (!msUserData[1].isEmpty()) |
483 |
- serviceName = msUserData[1]; |
484 |
- |
485 |
- m_tcontrol = css::uno::Reference<XActiveDataControl> (m_rServiceFactory->createInstanceWithArguments(serviceName, args), UNO_QUERY); |
486 |
+ m_tcontrol = impl_createTransformer(msUserData[1], args); |
487 |
|
488 |
OSL_ASSERT(m_rOutputStream.is()); |
489 |
OSL_ASSERT(m_tcontrol.is()); |
490 |
@@ -566,7 +596,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False) |
491 |
// -------------------------------------- |
492 |
#define FILTER_SERVICE_NAME "com.sun.star.documentconversion.XSLTFilter" |
493 |
#define FILTER_IMPL_NAME "com.sun.star.comp.documentconversion.XSLTFilter" |
494 |
-#define TRANSFORMER_SERVICE_NAME "com.sun.star.documentconversion.LibXSLTTransformer" |
495 |
+#define TRANSFORMER_SERVICE_NAME "com.sun.star.xml.xslt.XSLTTransformer" |
496 |
#define TRANSFORMER_IMPL_NAME "com.sun.star.comp.documentconversion.LibXSLTTransformer" |
497 |
|
498 |
static css::uno::Reference<XInterface> SAL_CALL |
499 |
diff --git a/filter/source/xsltfilter/com/sun/star/comp/xsltfilter/XSLTransformer.java b/filter/source/xsltfilter/com/sun/star/comp/xsltfilter/XSLTransformer.java |
500 |
index 1a6d8cf..7036646 100644 |
501 |
--- a/filter/source/xsltfilter/com/sun/star/comp/xsltfilter/XSLTransformer.java |
502 |
+++ b/filter/source/xsltfilter/com/sun/star/comp/xsltfilter/XSLTransformer.java |
503 |
@@ -75,6 +75,7 @@ import com.sun.star.registry.XRegistryKey; |
504 |
import com.sun.star.uno.AnyConverter; |
505 |
import com.sun.star.uno.Type; |
506 |
import com.sun.star.uno.UnoRuntime; |
507 |
+import com.sun.star.xml.xslt.XXSLTTransformer; |
508 |
|
509 |
//Uno to java Adaptor |
510 |
import com.sun.star.lib.uno.adapter.XInputStreamToInputStreamAdapter; |
511 |
@@ -88,8 +89,8 @@ import net.sf.saxon.FeatureKeys; |
512 |
* component on demand (__getServiceFactory()). |
513 |
*/ |
514 |
public class XSLTransformer |
515 |
- implements XTypeProvider, XServiceName, XServiceInfo, XActiveDataSink, |
516 |
- XActiveDataSource, XActiveDataControl, XInitialization, URIResolver, EntityResolver { |
517 |
+ implements XTypeProvider, XServiceName, XServiceInfo, XXSLTTransformer, |
518 |
+ URIResolver, EntityResolver { |
519 |
|
520 |
/** |
521 |
* This component provides java based XSL transformations |
522 |
@@ -132,7 +133,7 @@ public class XSLTransformer |
523 |
svcfactory = msf; |
524 |
} |
525 |
|
526 |
- public void initialize(Object[] values) throws com.sun.star.uno.Exception { |
527 |
+ public void initialize(Object[] args) throws com.sun.star.uno.Exception { |
528 |
// some configurable debugging |
529 |
String statsfilepath = null; |
530 |
if ((statsfilepath = System.getProperty(STATSPROP)) != null) { |
531 |
@@ -146,6 +147,8 @@ public class XSLTransformer |
532 |
} |
533 |
} |
534 |
|
535 |
+ Object[] values = (Object[]) args[0]; |
536 |
+ |
537 |
// reading the values |
538 |
NamedValue nv = null; |
539 |
debug("The transformation's parameters as 'name = value' pairs:\n"); |
540 |
@@ -444,7 +447,7 @@ public class XSLTransformer |
541 |
} |
542 |
} |
543 |
} // --- component management interfaces... --- |
544 |
- private final static String _serviceName = "com.sun.star.comp.JAXTHelper"; |
545 |
+ private final static String _serviceName = "com.sun.star.xml.xslt.XSLT2Transformer"; |
546 |
|
547 |
// Implement methods from interface XTypeProvider |
548 |
public byte[] getImplementationId() { |
549 |
@@ -494,7 +497,7 @@ public class XSLTransformer |
550 |
public static XSingleServiceFactory __getServiceFactory( |
551 |
String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey) { |
552 |
XSingleServiceFactory xSingleServiceFactory = null; |
553 |
- if (implName.indexOf("XSLTransformer") != -1) { |
554 |
+ if (implName.equals(XSLTransformer.class.getName())) { |
555 |
xSingleServiceFactory = FactoryHelper.getServiceFactory(XSLTransformer.class, |
556 |
_serviceName, multiFactory, regKey); |
557 |
} |
558 |
diff --git a/filter/source/xsltfilter/components.rdb b/filter/source/xsltfilter/components.rdb |
559 |
index 080cb7a..6014b82 100644 |
560 |
--- a/filter/source/xsltfilter/components.rdb |
561 |
+++ b/filter/source/xsltfilter/components.rdb |
562 |
@@ -1,8 +1,8 @@ |
563 |
<?xml version="1.0"?> |
564 |
<components xmlns="http://openoffice.org/2010/uno-components"> |
565 |
<component loader="com.sun.star.loader.Java2" uri="./XSLTFilter.jar"> |
566 |
- <implementation name="XSLTransformer"> |
567 |
- <service name="com.sun.star.comp.JAXTHelper"/> |
568 |
+ <implementation name="com.sun.star.comp.xsltfilter.XSLTransformer"> |
569 |
+ <service name="com.sun.star.xml.xslt.XSLT2Transformer"/> |
570 |
</implementation> |
571 |
</component> |
572 |
</components> |
573 |
diff --git a/filter/source/xsltfilter/xsltfilter.component b/filter/source/xsltfilter/xsltfilter.component |
574 |
index 5fb985c..296f2bc 100644 |
575 |
--- a/filter/source/xsltfilter/xsltfilter.component |
576 |
+++ b/filter/source/xsltfilter/xsltfilter.component |
577 |
@@ -32,6 +32,6 @@ |
578 |
<service name="com.sun.star.documentconversion.XSLTFilter"/> |
579 |
</implementation> |
580 |
<implementation name="com.sun.star.comp.documentconversion.LibXSLTTransformer"> |
581 |
- <service name="com.sun.star.documentconversion.LibXSLTTransformer"/> |
582 |
+ <service name="com.sun.star.xml.xslt.XSLTTransformer"/> |
583 |
</implementation> |
584 |
</component> |
585 |
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk |
586 |
index 98cca5f..007cc52 100644 |
587 |
--- a/offapi/UnoApi_offapi.mk |
588 |
+++ b/offapi/UnoApi_offapi.mk |
589 |
@@ -285,6 +285,10 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xml/sax,\ |
590 |
FastShapeContextHandler \ |
591 |
FastTokenHandler \ |
592 |
)) |
593 |
+$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xml/xslt,\ |
594 |
+ XSLTTransformer \ |
595 |
+ XSLT2Transformer \ |
596 |
+)) |
597 |
|
598 |
|
599 |
$(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star,\ |
600 |
@@ -4255,6 +4259,11 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xml/xpath,\ |
601 |
XXPathExtension \ |
602 |
XXPathObject \ |
603 |
)) |
604 |
+ |
605 |
+$(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xml/xslt,\ |
606 |
+ XXSLTTransformer \ |
607 |
+)) |
608 |
+ |
609 |
$(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/xsd,\ |
610 |
DataTypeClass \ |
611 |
WhiteSpaceTreatment \ |
612 |
diff --git a/offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl b/offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl |
613 |
new file mode 100644 |
614 |
index 0000000..af5abed |
615 |
--- /dev/null |
616 |
+++ b/offapi/com/sun/star/xml/xslt/XSLT2Transformer.idl |
617 |
@@ -0,0 +1,30 @@ |
618 |
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
619 |
+/* |
620 |
+ * This file is part of the LibreOffice project. |
621 |
+ * |
622 |
+ * This Source Code Form is subject to the terms of the Mozilla Public |
623 |
+ * License, v. 2.0. If a copy of the MPL was not distributed with this |
624 |
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
625 |
+ */ |
626 |
+ |
627 |
+#ifndef INCLUDED_COM_SUN_STAR_XML_XSLT_XSLT2TRANSFORMER_IDL |
628 |
+#define INCLUDED_COM_SUN_STAR_XML_XSLT_XSLT2TRANSFORMER_IDL |
629 |
+ |
630 |
+#include <com/sun/star/xml/xslt/XXSLTTransformer.idl> |
631 |
+ |
632 |
+module com { module sun { module star { module xml { module xslt { |
633 |
+ |
634 |
+/** Get XSLT filter transformer supporting XSLT 2.0. |
635 |
+ |
636 |
+ @since LibreOffice 3.7 |
637 |
+ */ |
638 |
+service XSLT2Transformer : XXSLTTransformer |
639 |
+{ |
640 |
+ create([in] sequence<any> args); |
641 |
+}; |
642 |
+ |
643 |
+}; }; }; }; }; |
644 |
+ |
645 |
+#endif |
646 |
+ |
647 |
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
648 |
diff --git a/offapi/com/sun/star/xml/xslt/XSLTTransformer.idl b/offapi/com/sun/star/xml/xslt/XSLTTransformer.idl |
649 |
new file mode 100644 |
650 |
index 0000000..f9d75e3 |
651 |
--- /dev/null |
652 |
+++ b/offapi/com/sun/star/xml/xslt/XSLTTransformer.idl |
653 |
@@ -0,0 +1,32 @@ |
654 |
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
655 |
+/* |
656 |
+ * This file is part of the LibreOffice project. |
657 |
+ * |
658 |
+ * This Source Code Form is subject to the terms of the Mozilla Public |
659 |
+ * License, v. 2.0. If a copy of the MPL was not distributed with this |
660 |
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
661 |
+ */ |
662 |
+ |
663 |
+#ifndef INCLUDED_COM_SUN_STAR_XML_XSLT_XSLTTRANSFORMER_IDL |
664 |
+#define INCLUDED_COM_SUN_STAR_XML_XSLT_XSLTTRANSFORMER_IDL |
665 |
+ |
666 |
+#include <com/sun/star/xml/xslt/XXSLTTransformer.idl> |
667 |
+ |
668 |
+module com { module sun { module star { module xml { module xslt { |
669 |
+ |
670 |
+/** Get unspecified XSLT filter transformer. |
671 |
+ |
672 |
+ <p>It is not safe to expect support for any features except XSLT 1.0 . |
673 |
+ |
674 |
+ @since LibreOffice 3.7 |
675 |
+ */ |
676 |
+service XSLTTransformer : XXSLTTransformer |
677 |
+{ |
678 |
+ create([in] sequence<any> args); |
679 |
+}; |
680 |
+ |
681 |
+}; }; }; }; }; |
682 |
+ |
683 |
+#endif |
684 |
+ |
685 |
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
686 |
diff --git a/offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl b/offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl |
687 |
new file mode 100644 |
688 |
index 0000000..9316c25 |
689 |
--- /dev/null |
690 |
+++ b/offapi/com/sun/star/xml/xslt/XXSLTTransformer.idl |
691 |
@@ -0,0 +1,36 @@ |
692 |
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
693 |
+/* |
694 |
+ * This file is part of the LibreOffice project. |
695 |
+ * |
696 |
+ * This Source Code Form is subject to the terms of the Mozilla Public |
697 |
+ * License, v. 2.0. If a copy of the MPL was not distributed with this |
698 |
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
699 |
+ */ |
700 |
+ |
701 |
+#ifndef INCLUDED_COM_SUN_STAR_XML_XSLT_XXSLTTRANSFORMER_IDL |
702 |
+#define INCLUDED_COM_SUN_STAR_XML_XSLT_XXSLTTRANSFORMER_IDL |
703 |
+ |
704 |
+#include <com/sun/star/io/XActiveDataControl.idl> |
705 |
+#include <com/sun/star/io/XActiveDataSink.idl> |
706 |
+#include <com/sun/star/io/XActiveDataSource.idl> |
707 |
+#include <com/sun/star/lang/XInitialization.idl> |
708 |
+ |
709 |
+module com { module sun { module star { module xml { module xslt { |
710 |
+ |
711 |
+/** An interface for XSLT transformers. |
712 |
+ |
713 |
+ @since LibreOffice 3.7 |
714 |
+ */ |
715 |
+interface XXSLTTransformer |
716 |
+{ |
717 |
+ interface com::sun::star::io::XActiveDataControl; |
718 |
+ interface com::sun::star::io::XActiveDataSink; |
719 |
+ interface com::sun::star::io::XActiveDataSource; |
720 |
+ interface com::sun::star::lang::XInitialization; |
721 |
+}; |
722 |
+ |
723 |
+}; }; }; }; }; |
724 |
+ |
725 |
+#endif |
726 |
+ |
727 |
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
728 |
-- |
729 |
1.7.11.7 |
730 |
|