[PATCH 2/2] Fixed constant definitions for LibXSLTFilter buffers

Peter Jentsch pjotr at guineapics.de
Mon Jan 3 11:38:17 PST 2011


---
 filter/source/xsltfilter/LibXSLTTransformer.cxx |   29 ++++++++++++++++++++++-
 filter/source/xsltfilter/LibXSLTTransformer.hxx |    7 +----
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx
index da51908..2d40381 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.cxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx
@@ -45,6 +45,9 @@
  using ::std::map;
  using ::std::pair;
 
+ #define _INPUT_BUFFER_SIZE 4096
+ #define _OUTPUT_BUFFER_SIZE 4096
+
  namespace XSLT {
      const char* const LibXSLTTransformer::PARAM_SOURCE_URL = "sourceURL";
      const char* const LibXSLTTransformer::PARAM_SOURCE_BASE_URL = "sourceBaseURL";
@@ -52,6 +55,11 @@
      const char* const LibXSLTTransformer::PARAM_TARGET_BASE_URL = "targetBaseURL";
      const char* const LibXSLTTransformer::PARAM_DOCTYPE_SYSTEM = "sytemType";
      const char* const LibXSLTTransformer::PARAM_DOCTYPE_PUBLIC = "publicType";
+
+     const sal_Int32 Reader::OUTPUT_BUFFER_SIZE = _OUTPUT_BUFFER_SIZE;
+
+     const sal_Int32 Reader::INPUT_BUFFER_SIZE = _INPUT_BUFFER_SIZE;
+
      struct ParserInputBufferCallback {
          static int on_read(void * context, char * buffer, int len) {
              Reader * tmp = static_cast<Reader*>(context);
@@ -72,6 +80,7 @@
              return tmp->closeOutput();
          }
      };
+
      Reader::Reader(LibXSLTTransformer* transformer):
          m_transformer(transformer),
          m_terminated(false),
@@ -92,12 +101,13 @@
          }
          return n;
      }
+
      int Reader::write(const char * buffer, int len) {
          if (buffer == NULL || len < 0) return -1;
          if (len > 0) {
              Reference<XOutputStream> xos = m_transformer->getOutputStream();
              sal_Int32 writeLen = len;
-             sal_Int32 bufLen = ::std::min(writeLen, OUTPUT_BUFFER_SIZE);
+             sal_Int32 bufLen = ::std::min(writeLen, this->OUTPUT_BUFFER_SIZE);
              const sal_uInt8* memPtr = reinterpret_cast< const sal_uInt8* >( buffer );
              while( writeLen > 0 ) {
                  sal_Int32 n = ::std::min(writeLen, bufLen);
@@ -110,9 +120,11 @@
          }
          return len;
      }
+
      int Reader::closeInput() {
          return 0;
      }
+
      int Reader::closeOutput() {
          Reference<XOutputStream>  xos = m_transformer->getOutputStream();
          if (xos.is()) {
@@ -122,6 +134,7 @@
          m_transformer->done();
          return 0;
      }
+
      void Reader::run() {
          OSL_ASSERT(m_transformer != NULL);
          OSL_ASSERT(m_transformer->getInputStream().is());
@@ -150,6 +163,7 @@
              xsltQuoteUserParams(tcontext, params);
              result = xsltApplyStylesheetUser(styleSheet, doc, 0, 0, 0, tcontext);
          }
+
          if (result) {
              xmlCharEncodingHandlerPtr encoder = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_UTF8);
              xmlOutputBufferPtr outBuf = xmlAllocOutputBuffer(encoder);
@@ -173,37 +187,47 @@
          xmlFreeDoc(doc);
          xmlFreeDoc(result);
      };
+
      void Reader::onTerminated() {
          m_terminated = true;
      };
+
      Reader::~Reader() {}
+
      LibXSLTTransformer::LibXSLTTransformer( const Reference< XMultiServiceFactory > &r )
          : m_rServiceFactory(r) {
      }
+
      void LibXSLTTransformer::setInputStream(const Reference<XInputStream>& inputStream)
          throw (RuntimeException) {
          m_rInputStream = inputStream;
      }
+
      Reference<XInputStream> LibXSLTTransformer::getInputStream()
          throw (RuntimeException) {
          return m_rInputStream;
      }
+
      void LibXSLTTransformer::setOutputStream(const Reference<XOutputStream>& outputStream)
          throw (RuntimeException) {
          m_rOutputStream = outputStream;
      }
+
      Reference<XOutputStream> LibXSLTTransformer::getOutputStream()
          throw (RuntimeException) {
          return m_rOutputStream;
      }
+
      void LibXSLTTransformer::addListener(const Reference<XStreamListener>& listener)
          throw (RuntimeException) {
          m_listeners.insert(m_listeners.begin(), listener);
      }
+
      void LibXSLTTransformer::removeListener(const Reference<XStreamListener>& listener)
          throw (RuntimeException) {
          m_listeners.remove(listener);
      }
+
      void LibXSLTTransformer::start()
          throw (RuntimeException) {
          ListenerList::iterator it;
@@ -226,6 +250,7 @@
              }
          }
      }
+
      void LibXSLTTransformer::done() {
          ListenerList l = m_listeners;
          for (ListenerList::iterator it=l.begin(); it != l.end(); it++) {
@@ -235,10 +260,12 @@
              }
          }
      }
+
      void LibXSLTTransformer::terminate()
          throw (RuntimeException) {
          m_parameters.clear();
      }
+
      void LibXSLTTransformer::initialize(const Sequence<Any>& params)
          throw (RuntimeException) {
          xmlSubstituteEntitiesDefault(0);
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.hxx b/filter/source/xsltfilter/LibXSLTTransformer.hxx
index 376075e..64073c0 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.hxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.hxx
@@ -32,9 +32,6 @@
  #include <com/sun/star/lang/XInitialization.hpp>
  #include <com/sun/star/beans/NamedValue.hpp>
 
- #define _INPUT_BUFFER_SIZE 1024
- #define _OUTPUT_BUFFER_SIZE 1024
-
  using namespace ::rtl;
  using namespace ::cppu;
  using namespace ::osl;
@@ -127,8 +124,8 @@
          virtual ~Reader();
 
      private:
-         static const sal_Int32 OUTPUT_BUFFER_SIZE = _OUTPUT_BUFFER_SIZE;
-         static const sal_Int32 INPUT_BUFFER_SIZE = _INPUT_BUFFER_SIZE;
+         static const sal_Int32 OUTPUT_BUFFER_SIZE;
+         static const sal_Int32 INPUT_BUFFER_SIZE;
          LibXSLTTransformer* m_transformer;
          sal_Bool m_terminated;
          Sequence<sal_Int8> m_readBuf;
-- 
1.7.1


--=-0WJ2sqsYDik0jKstE9Nt--



More information about the LibreOffice mailing list