1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_filter.hxx"
33 #include <cppuhelper/factory.hxx>
34 #include <cppuhelper/servicefactory.hxx>
35 #include <cppuhelper/implbase1.hxx>
36 #include <cppuhelper/implbase2.hxx>
37 #include <cppuhelper/implbase3.hxx>
38 #include <cppuhelper/implbase4.hxx>
39 #include <cppuhelper/implbase.hxx>
42 #include <osl/conditn.h>
43 #include <tools/urlobj.hxx>
44 #include <osl/module.h>
45 #include <osl/file.hxx>
46 #include <osl/process.h>
48 #include <com/sun/star/lang/XComponent.hpp>
50 #include <com/sun/star/uno/Any.hxx>
51 #include <com/sun/star/uno/Type.hxx>
53 #include <com/sun/star/beans/PropertyValue.hpp>
55 #include <com/sun/star/xml/sax/XParser.hpp>
56 #include <com/sun/star/xml/sax/InputSource.hpp>
57 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
58 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
59 #include <com/sun/star/xml/sax/SAXException.hpp>
60 #include <com/sun/star/xml/XImportFilter.hpp>
61 #include <com/sun/star/xml/XExportFilter.hpp>
62 #include <com/sun/star/beans/XPropertySet.hpp>
63 #include <com/sun/star/util/XMacroExpander.hpp>
65 #include <com/sun/star/io/XInputStream.hpp>
66 #include <com/sun/star/io/XOutputStream.hpp>
67 #include <com/sun/star/io/XActiveDataSource.hpp>
68 #include <com/sun/star/io/XActiveDataSink.hpp>
69 #include <com/sun/star/io/XActiveDataControl.hpp>
70 #include <com/sun/star/io/XStreamListener.hpp>
71 #include <com/sun/star/uno/Any.hxx>
72 #include <com/sun/star/lang/EventObject.hpp>
73 #include <com/sun/star/util/XStringSubstitution.hpp>
74 #include <com/sun/star/beans/NamedValue.hpp>
76 #include <xmloff/attrlist.hxx>
79 using namespace ::rtl
;
80 using namespace ::cppu
;
81 using namespace ::osl
;
82 using namespace ::com::sun::star::beans
;
83 using namespace ::com::sun::star::io
;
84 using namespace ::com::sun::star::uno
;
85 using namespace ::com::sun::star::lang
;
86 using namespace ::com::sun::star::registry
;
87 using namespace ::com::sun::star::xml
;
88 using namespace ::com::sun::star::xml::sax
;
89 using namespace ::com::sun::star::util
;
94 class FLABridge
: public WeakImplHelper1
< XDocumentHandler
>
97 const Reference
<XDocumentHandler
>& m_rDocumentHandler
;
98 const sal_Unicode
*eval(const sal_Unicode
*expr
, sal_Int32 exprLen
);
103 FLABridge(const Reference
<XDocumentHandler
>& m_rDocumentHandler
);
106 virtual void SAL_CALL
startDocument()
107 throw (SAXException
,RuntimeException
);
108 virtual void SAL_CALL
endDocument()
109 throw (SAXException
, RuntimeException
);
110 virtual void SAL_CALL
startElement(const OUString
& str
, const Reference
<XAttributeList
>& attriblist
)
111 throw (SAXException
,RuntimeException
);
112 virtual void SAL_CALL
endElement(const OUString
& str
)
113 throw (SAXException
, RuntimeException
);
114 virtual void SAL_CALL
characters(const OUString
& str
)
115 throw (SAXException
, RuntimeException
);
116 virtual void SAL_CALL
ignorableWhitespace(const OUString
& str
)
117 throw (SAXException
, RuntimeException
);
118 virtual void SAL_CALL
processingInstruction(const OUString
& str
, const OUString
& str2
)
119 throw (com::sun::star::xml::sax::SAXException
,RuntimeException
);
120 virtual void SAL_CALL
setDocumentLocator(const Reference
<XLocator
>& doclocator
)
121 throw (SAXException
,RuntimeException
);
125 FLABridge::FLABridge(const Reference
<XDocumentHandler
>& _rDocumentHandler
) : m_rDocumentHandler(_rDocumentHandler
), active(false)
129 void FLABridge::startDocument() throw (SAXException
,RuntimeException
){
130 OSL_ASSERT(m_rDocumentHandler
.is());
131 m_rDocumentHandler
->startDocument();
134 void FLABridge::endDocument() throw (SAXException
,RuntimeException
){
135 OSL_ASSERT(m_rDocumentHandler
.is());
136 m_rDocumentHandler
->endDocument();
141 void FLABridge::startElement(const OUString
& str
, const Reference
<XAttributeList
>& attriblist
)
142 throw (SAXException
, RuntimeException
)
144 OSL_ASSERT(m_rDocumentHandler
.is());
147 // SvXMLAttributeList* _attriblist=SvXMLAttributeList::getImplementation(attriblist);
148 const int len
=attriblist
->getLength();
149 SvXMLAttributeList
*_newattriblist
= new SvXMLAttributeList();
150 for(int i
=0;i
<len
;i
++)
152 const OUString
& name
=attriblist
->getNameByIndex( sal::static_int_cast
<sal_Int16
>( i
) );
154 static const OUString
_value_(".value", 6, RTL_TEXTENCODING_ASCII_US
);
155 if ((pos
=name
.lastIndexOf(L
'.'))!=-1 && name
.match(_value_
, pos
))
157 const OUString
newName(name
, pos
);
158 const OUString
& value
=attriblist
->getValueByIndex( sal::static_int_cast
<sal_Int16
>( i
) );
159 const OUString
newValue(ev
.eval(value
.getStr(), value
.getLength()));
160 if (newValue
.getLength()>0)
162 _newattriblist
->AddAttribute(newName
, newValue
);
167 _newattriblist
->AddAttribute(name
, attriblist
->getValueByIndex( sal::static_int_cast
<sal_Int16
>( i
)));
170 const Reference
<XAttributeList
> newattriblist(_newattriblist
);
171 m_rDocumentHandler
->startElement(str
, newattriblist
);
175 if (str
.compareToAscii("fla:fla.activate")==0)
179 m_rDocumentHandler
->startElement(str
, attriblist
);
183 void FLABridge::endElement(const OUString
& str
)
184 throw (SAXException
, RuntimeException
)
186 OSL_ASSERT(m_rDocumentHandler
.is());
187 m_rDocumentHandler
->endElement(str
);
190 void FLABridge::characters(const OUString
& str
)
191 throw (SAXException
, RuntimeException
)
193 OSL_ASSERT(m_rDocumentHandler
.is());
194 m_rDocumentHandler
->characters(str
);
197 void FLABridge::ignorableWhitespace(const OUString
& str
)
198 throw (SAXException
, RuntimeException
)
200 OSL_ASSERT(m_rDocumentHandler
.is());
201 m_rDocumentHandler
->ignorableWhitespace(str
);
204 void FLABridge::processingInstruction(const OUString
& str
, const OUString
& str2
)
205 throw (SAXException
, RuntimeException
)
207 OSL_ASSERT(m_rDocumentHandler
.is());
208 m_rDocumentHandler
->processingInstruction(str
, str2
);
211 void FLABridge::setDocumentLocator(const Reference
<XLocator
>& doclocator
)
212 throw (SAXException
, RuntimeException
)
214 OSL_ASSERT(m_rDocumentHandler
.is());
215 m_rDocumentHandler
->setDocumentLocator(doclocator
);
220 class XSLTFilter
: public WeakImplHelper4
< XImportFilter
, XExportFilter
, XDocumentHandler
, XStreamListener
>
223 // the UNO ServiceFactory
224 Reference
< XMultiServiceFactory
> m_rServiceFactory
;
226 // DocumentHandler interface of the css::xml::sax::Writer service
227 Reference
< XExtendedDocumentHandler
> m_rDocumentHandler
;
228 Reference
< XOutputStream
> m_rOutputStream
;
230 // controls pretty-printing
231 sal_Bool m_bPrettyPrint
;
233 Reference
< XActiveDataControl
> m_tcontrol
;
234 oslCondition m_cTransformed
;
235 sal_Bool m_bTerminated
;
238 OUString m_aExportBaseUrl
;
239 OUString m_aOldBaseUrl
;
241 OUString
rel2abs(const OUString
&);
242 OUString
expandUrl(const OUString
&);
247 XSLTFilter( const Reference
< XMultiServiceFactory
> &r
);
250 virtual void SAL_CALL
error(const Any
& a
) throw (RuntimeException
);
251 virtual void SAL_CALL
closed() throw (RuntimeException
);
252 virtual void SAL_CALL
terminated() throw (RuntimeException
);
253 virtual void SAL_CALL
started() throw (RuntimeException
);
254 virtual void SAL_CALL
disposing(const EventObject
& e
) throw (RuntimeException
);
258 virtual sal_Bool SAL_CALL
importer(
259 const Sequence
<PropertyValue
>& aSourceData
,
260 const Reference
<XDocumentHandler
>& xHandler
,
261 const Sequence
<OUString
>& msUserData
)
262 throw(RuntimeException
);
265 virtual sal_Bool SAL_CALL
exporter(
266 const Sequence
<PropertyValue
>& aSourceData
,
267 const Sequence
<OUString
>& msUserData
)
268 throw(RuntimeException
);
271 virtual void SAL_CALL
startDocument()
272 throw (SAXException
,RuntimeException
);
273 virtual void SAL_CALL
endDocument()
274 throw (SAXException
, RuntimeException
);
275 virtual void SAL_CALL
startElement(const OUString
& str
, const Reference
<XAttributeList
>& attriblist
)
276 throw (SAXException
,RuntimeException
);
277 virtual void SAL_CALL
endElement(const OUString
& str
)
278 throw (SAXException
, RuntimeException
);
279 virtual void SAL_CALL
characters(const OUString
& str
)
280 throw (SAXException
, RuntimeException
);
281 virtual void SAL_CALL
ignorableWhitespace(const OUString
& str
)
282 throw (SAXException
, RuntimeException
);
283 virtual void SAL_CALL
processingInstruction(const OUString
& str
, const OUString
& str2
)
284 throw (com::sun::star::xml::sax::SAXException
,RuntimeException
);
285 virtual void SAL_CALL
setDocumentLocator(const Reference
<XLocator
>& doclocator
)
286 throw (SAXException
,RuntimeException
);
289 XSLTFilter::XSLTFilter( const Reference
< XMultiServiceFactory
> &r
)
290 : m_rServiceFactory(r
)
291 , m_bPrettyPrint(sal_True
)
292 , m_bTerminated(sal_False
)
293 , m_bError(sal_False
)
295 m_cTransformed
= osl_createCondition();
298 void XSLTFilter::disposing(const EventObject
& ) throw (RuntimeException
)
302 ::rtl::OUString
XSLTFilter::expandUrl( const ::rtl::OUString
& sUrl
)
304 ::rtl::OUString sExpandedUrl
;
307 Reference
< XComponentContext
> xContext
;
308 Reference
< XPropertySet
> xProps( m_rServiceFactory
, UNO_QUERY_THROW
);
309 xContext
.set( xProps
->getPropertyValue( ::rtl::OUString::createFromAscii( "DefaultContext" ) ), UNO_QUERY_THROW
);
310 Reference
< XMacroExpander
> xMacroExpander( xContext
->getValueByName( ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), UNO_QUERY_THROW
);
311 sExpandedUrl
= xMacroExpander
->expandMacros(sUrl
);
312 sal_Int32 nPos
= sExpandedUrl
.indexOf(::rtl::OUString::createFromAscii("vnd.sun.star.expand:"));
314 sExpandedUrl
= sExpandedUrl
.copy(nPos
+20);
316 catch (Exception
&) {}
320 void XSLTFilter::started() throw (RuntimeException
)
322 osl_resetCondition(m_cTransformed
);
324 void XSLTFilter::error(const Any
& a
) throw (RuntimeException
)
329 OString
aMessage("XSLTFilter::error was called: ");
330 aMessage
+= OUStringToOString(e
.Message
, RTL_TEXTENCODING_ASCII_US
);
331 OSL_ENSURE(sal_False
, aMessage
);
334 osl_setCondition(m_cTransformed
);
336 void XSLTFilter::closed() throw (RuntimeException
)
338 osl_setCondition(m_cTransformed
);
340 void XSLTFilter::terminated() throw (RuntimeException
)
342 m_bTerminated
= sal_True
;
343 osl_setCondition(m_cTransformed
);
346 OUString
XSLTFilter::rel2abs(const OUString
& s
)
349 Reference
< XStringSubstitution
> subs(m_rServiceFactory
->createInstance(
350 OUString::createFromAscii("com.sun.star.util.PathSubstitution")), UNO_QUERY
);
351 OUString aWorkingDir
= subs
->getSubstituteVariableValue(OUString::createFromAscii("$(progurl)"));
352 INetURLObject
aObj( aWorkingDir
);
353 aObj
.setFinalSlash();
355 INetURLObject aURL
= aObj
.smartRel2Abs(
356 s
, bWasAbsolute
, false, INetURLObject::WAS_ENCODED
, RTL_TEXTENCODING_UTF8
, true );
357 return aURL
.GetMainURL(INetURLObject::NO_DECODE
);
362 sal_Bool
XSLTFilter::importer(
363 const Sequence
<PropertyValue
>& aSourceData
,
364 const Reference
<XDocumentHandler
>& xHandler
,
365 const Sequence
<OUString
>& msUserData
)
366 throw (RuntimeException
)
368 if ( msUserData
.getLength() < 5 )
371 OUString udImport
= msUserData
[2];
372 OUString udStyleSheet
= rel2abs(msUserData
[4]);
374 // get information from media descriptor
375 // the imput stream that represents the imported file
376 // is most important here since we need to supply it to
377 // the sax parser that drives the supplied document handler
378 sal_Int32 nLength
= aSourceData
.getLength();
379 OUString aName
, aFileName
, aURL
;
380 Reference
< XInputStream
> xInputStream
;
381 for ( sal_Int32 i
= 0 ; i
< nLength
; i
++)
383 aName
= aSourceData
[i
].Name
;
384 if (aName
.equalsAscii("InputStream"))
385 aSourceData
[i
].Value
>>= xInputStream
;
386 else if ( aName
.equalsAscii("FileName"))
387 aSourceData
[i
].Value
>>= aFileName
;
388 else if ( aName
.equalsAscii("URL"))
389 aSourceData
[i
].Value
>>= aURL
;
391 OSL_ASSERT(xInputStream
.is());
392 if (!xInputStream
.is()) return sal_False
;
394 // create SAX parser that will read the document file
395 // and provide events to xHandler passed to this call
396 Reference
< XParser
> xSaxParser( m_rServiceFactory
->createInstance(
397 OUString::createFromAscii("com.sun.star.xml.sax.Parser")), UNO_QUERY
);
398 OSL_ASSERT(xSaxParser
.is());
399 if(!xSaxParser
.is())return sal_False
;
401 // create transformer
402 Sequence
< Any
> args(3);
405 nv
.Name
= OUString::createFromAscii("StylesheetURL");
406 nv
.Value
<<= expandUrl(udStyleSheet
); args
[0] <<= nv
;
407 nv
.Name
= OUString::createFromAscii("SourceURL");
408 nv
.Value
<<= aURL
; args
[1] <<= nv
;
409 nv
.Name
= OUString::createFromAscii("SourceBaseURL");
410 nv
.Value
<<= OUString(INetURLObject(aURL
).getBase());
413 m_tcontrol
= Reference
< XActiveDataControl
>(m_rServiceFactory
->createInstanceWithArguments(
414 OUString::createFromAscii("com.sun.star.comp.JAXTHelper"), args
), UNO_QUERY
);
416 OSL_ASSERT(xHandler
.is());
417 OSL_ASSERT(xInputStream
.is());
418 OSL_ASSERT(m_tcontrol
.is());
419 if (xHandler
.is() && xInputStream
.is() && m_tcontrol
.is())
423 // we want to be notfied when the processing is done...
424 m_tcontrol
->addListener(Reference
< XStreamListener
>(this));
426 // connect input to transformer
427 Reference
< XActiveDataSink
> tsink(m_tcontrol
, UNO_QUERY
);
428 tsink
->setInputStream(xInputStream
);
431 Reference
< XOutputStream
> pipeout(m_rServiceFactory
->createInstance(
432 OUString::createFromAscii("com.sun.star.io.Pipe")), UNO_QUERY
);
433 Reference
< XInputStream
> pipein(pipeout
, UNO_QUERY
);
435 //connect transformer to pipe
436 Reference
< XActiveDataSource
> tsource(m_tcontrol
, UNO_QUERY
);
437 tsource
->setOutputStream(pipeout
);
439 // connect pipe to sax parser
441 aInput
.sSystemId
= aURL
;
442 aInput
.sPublicId
= aURL
;
443 aInput
.aInputStream
= pipein
;
446 xSaxParser
->setDocumentHandler(new FLABridge(xHandler
));
450 // osl_waitCondition(m_cTransformed, 0);
451 if (!m_bError
&& !m_bTerminated
)
453 // parse the transformed XML buffered in the pipe
454 xSaxParser
->parseStream(aInput
);
455 osl_waitCondition(m_cTransformed
, 0);
461 #if OSL_DEBUG_LEVEL > 0
462 catch( Exception
& exc
)
467 // something went wrong
468 OSL_ENSURE(0, OUStringToOString(exc
.Message
, RTL_TEXTENCODING_ASCII_US
).getStr());
477 sal_Bool
XSLTFilter::exporter(
478 const Sequence
<PropertyValue
>& aSourceData
,
479 const Sequence
<OUString
>& msUserData
)
480 throw (RuntimeException
)
482 if ( msUserData
.getLength() < 6 )
485 // get interesting values from user data
486 OUString udImport
= msUserData
[2];
487 OUString udStyleSheet
= rel2abs(msUserData
[5]);
490 // we are especialy interested in the output stream
491 // since that is where our xml-writer will push the data
492 // from it's data-source interface
493 OUString aName
, sURL
;
494 sal_Bool bIndent
= sal_False
;
495 OUString aDoctypePublic
;
496 OUString aDoctypeSystem
;
497 // Reference<XOutputStream> rOutputStream;
498 sal_Int32 nLength
= aSourceData
.getLength();
499 for ( sal_Int32 i
= 0 ; i
< nLength
; i
++)
501 aName
= aSourceData
[i
].Name
;
502 if ( aName
.equalsAscii("Indent"))
503 aSourceData
[i
].Value
>>= bIndent
;
504 if ( aName
.equalsAscii("DocType_Public"))
505 aSourceData
[i
].Value
>>= aDoctypePublic
;
506 if ( aName
.equalsAscii("DocType_System"))
507 aSourceData
[i
].Value
>>= aDoctypeSystem
;
508 if ( aName
.equalsAscii("OutputStream"))
509 aSourceData
[i
].Value
>>= m_rOutputStream
;
510 else if ( aName
.equalsAscii("URL" ))
511 aSourceData
[i
].Value
>>= sURL
;
514 if (!m_rDocumentHandler
.is()) {
515 // get the document writer
516 m_rDocumentHandler
= Reference
<XExtendedDocumentHandler
>(
517 m_rServiceFactory
->createInstance(
518 OUString::createFromAscii("com.sun.star.xml.sax.Writer")),
522 // create transformer
523 Sequence
< Any
> args(4);
525 nv
.Name
= OUString::createFromAscii("StylesheetURL");
526 nv
.Value
<<= expandUrl(udStyleSheet
); args
[0] <<= nv
;
527 nv
.Name
= OUString::createFromAscii("TargetURL");
528 nv
.Value
<<= sURL
; args
[1] <<= nv
;
529 nv
.Name
= OUString::createFromAscii("DoctypeSystem");
530 nv
.Value
<<= aDoctypeSystem
; args
[2] <<= nv
;
531 nv
.Name
= OUString::createFromAscii("DoctypePublic");
532 nv
.Value
<<= aDoctypePublic
; args
[3] <<= nv
;
533 nv
.Name
= OUString::createFromAscii("TargetBaseURL");
534 INetURLObject
ineturl(sURL
);
535 ineturl
.removeSegment();
536 m_aExportBaseUrl
= ineturl
.GetMainURL(INetURLObject::NO_DECODE
);
537 nv
.Value
<<= m_aExportBaseUrl
;
540 m_tcontrol
= Reference
< XActiveDataControl
>(m_rServiceFactory
->createInstanceWithArguments(
541 OUString::createFromAscii("com.sun.star.comp.JAXTHelper"), args
), UNO_QUERY
);
543 OSL_ASSERT(m_rDocumentHandler
.is());
544 OSL_ASSERT(m_rOutputStream
.is());
545 OSL_ASSERT(m_tcontrol
.is());
546 if (m_tcontrol
.is() && m_rOutputStream
.is() && m_rDocumentHandler
.is())
548 // we want to be notfied when the processing is done...
549 m_tcontrol
->addListener(Reference
< XStreamListener
>(this));
552 Reference
< XOutputStream
> pipeout(m_rServiceFactory
->createInstance(
553 OUString::createFromAscii("com.sun.star.io.Pipe")), UNO_QUERY
);
554 Reference
< XInputStream
> pipein(pipeout
, UNO_QUERY
);
556 // connect sax writer to pipe
557 Reference
< XActiveDataSource
> xmlsource(m_rDocumentHandler
, UNO_QUERY
);
558 xmlsource
->setOutputStream(pipeout
);
560 // connect pipe to transformer
561 Reference
< XActiveDataSink
> tsink(m_tcontrol
, UNO_QUERY
);
562 tsink
->setInputStream(pipein
);
564 // connect transformer to output
565 Reference
< XActiveDataSource
> tsource(m_tcontrol
, UNO_QUERY
);
566 tsource
->setOutputStream(m_rOutputStream
);
568 // we will start receiving events after returning 'true'.
569 // we will start the transformation as soon as we receive the startDocument
579 // for the DocumentHandler implementation, we just proxy the the
580 // events to the XML writer that we created upon the output stream
581 // that was provided by the XMLFilterAdapter
582 void XSLTFilter::startDocument() throw (SAXException
,RuntimeException
){
583 OSL_ASSERT(m_rDocumentHandler
.is());
584 m_rDocumentHandler
->startDocument();
588 void XSLTFilter::endDocument() throw (SAXException
, RuntimeException
){
589 OSL_ASSERT(m_rDocumentHandler
.is());
590 m_rDocumentHandler
->endDocument();
591 // wait for the transformer to finish
592 osl_waitCondition(m_cTransformed
, 0);
593 if (!m_bError
&& !m_bTerminated
)
597 throw RuntimeException();
602 void XSLTFilter::startElement(const OUString
& str
, const Reference
<XAttributeList
>& attriblist
)
603 throw (SAXException
, RuntimeException
)
605 OSL_ASSERT(m_rDocumentHandler
.is());
606 // SvXMLAttributeList* _attriblist=SvXMLAttributeList::getImplementation(attriblist);
607 m_rDocumentHandler
->startElement(str
, attriblist
);
610 void XSLTFilter::endElement(const OUString
& str
)
611 throw (SAXException
, RuntimeException
)
613 OSL_ASSERT(m_rDocumentHandler
.is());
614 m_rDocumentHandler
->endElement(str
);
617 void XSLTFilter::characters(const OUString
& str
)
618 throw (SAXException
, RuntimeException
)
620 OSL_ASSERT(m_rDocumentHandler
.is());
621 m_rDocumentHandler
->characters(str
);
624 void XSLTFilter::ignorableWhitespace(const OUString
& str
)
625 throw (SAXException
, RuntimeException
)
627 OSL_ASSERT(m_rDocumentHandler
.is());
628 if (!m_bPrettyPrint
) return;
629 m_rDocumentHandler
->ignorableWhitespace(str
);
632 void XSLTFilter::processingInstruction(const OUString
& str
, const OUString
& str2
)
633 throw (SAXException
, RuntimeException
)
635 OSL_ASSERT(m_rDocumentHandler
.is());
636 m_rDocumentHandler
->processingInstruction(str
, str2
);
639 void XSLTFilter::setDocumentLocator(const Reference
<XLocator
>& doclocator
)
640 throw (SAXException
, RuntimeException
)
642 OSL_ASSERT(m_rDocumentHandler
.is());
643 m_rDocumentHandler
->setDocumentLocator(doclocator
);
646 // --------------------------------------
647 // Component management
648 // --------------------------------------
649 #define SERVICE_NAME "com.sun.star.documentconversion.XSLTFilter"
650 #define IMPLEMENTATION_NAME "com.sun.star.comp.documentconversion.XSLTFilter"
652 static Reference
< XInterface
> SAL_CALL
CreateInstance( const Reference
< XMultiServiceFactory
> &r
)
654 return Reference
< XInterface
>(( OWeakObject
*)new XSLTFilter(r
));
657 static Sequence
< OUString
> getSupportedServiceNames()
659 static Sequence
< OUString
> *pNames
= 0;
662 MutexGuard
guard( Mutex::getGlobalMutex() );
665 static Sequence
< OUString
> seqNames(1);
666 seqNames
.getArray()[0] = OUString::createFromAscii(SERVICE_NAME
);
675 using namespace XSLT
;
679 void SAL_CALL
component_getImplementationEnvironment(
680 const sal_Char
** ppEnvTypeName
, uno_Environment
** /* ppEnv */ )
682 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
685 void * SAL_CALL
component_getFactory(
686 const sal_Char
* pImplName
, void * pServiceManager
, void * /* pRegistryKey */ )
690 if (pServiceManager
&& rtl_str_compare( pImplName
, IMPLEMENTATION_NAME
) == 0)
692 Reference
< XSingleServiceFactory
> xFactory( createSingleFactory(
693 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
),
694 OUString::createFromAscii( pImplName
),
695 CreateInstance
, getSupportedServiceNames() ) );
700 pRet
= xFactory
.get();