summaryrefslogtreecommitdiff
path: root/writerfilter/unocomponent
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/unocomponent')
-rw-r--r--writerfilter/unocomponent/component.cxx81
-rw-r--r--writerfilter/unocomponent/debugservices/doctok/DocTokAnalyzeService.cxx293
-rw-r--r--writerfilter/unocomponent/debugservices/doctok/DocTokAnalyzeService.hxx70
-rw-r--r--writerfilter/unocomponent/debugservices/doctok/DocTokTestService.cxx149
-rw-r--r--writerfilter/unocomponent/debugservices/doctok/DocTokTestService.hxx70
-rw-r--r--writerfilter/unocomponent/debugservices/doctok/makefile.mk44
-rw-r--r--writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.cxx291
-rw-r--r--writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.hxx70
-rw-r--r--writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.cxx182
-rw-r--r--writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.hxx70
-rw-r--r--writerfilter/unocomponent/debugservices/ooxml/makefile.mk58
-rw-r--r--writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.cxx455
-rw-r--r--writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.hxx70
-rw-r--r--writerfilter/unocomponent/debugservices/rtftok/XMLScanner.cxx333
-rw-r--r--writerfilter/unocomponent/debugservices/rtftok/XMLScanner.hxx70
-rw-r--r--writerfilter/unocomponent/debugservices/rtftok/makefile.mk45
-rw-r--r--writerfilter/unocomponent/exports.dxp3
-rw-r--r--writerfilter/unocomponent/makefile.mk90
18 files changed, 2444 insertions, 0 deletions
diff --git a/writerfilter/unocomponent/component.cxx b/writerfilter/unocomponent/component.cxx
new file mode 100644
index 000000000000..327e61e41a21
--- /dev/null
+++ b/writerfilter/unocomponent/component.cxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPTER_FACTORY_
+#include <cppuhelper/factory.hxx>
+#endif
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_
+#include <cppuhelper/implementationentry.hxx>
+#endif
+#include <debugservices/doctok/DocTokTestService.hxx>
+#include <debugservices/doctok/DocTokAnalyzeService.hxx>
+#include <debugservices/ooxml/OOXMLTestService.hxx>
+#include <debugservices/ooxml/OOXMLAnalyzeService.hxx>
+
+#include <stdio.h>
+
+using namespace com::sun::star;
+
+
+extern "C"
+{
+/* shared lib exports implemented with helpers */
+static struct ::cppu::ImplementationEntry s_component_entries [] =
+{//uno -l writerfilter.uno.dll -c debugservices.rtftok.ScannerTestService -- a b c
+ DOCTOK_SCANNERTESTSERVICE_COMPONENT_ENTRY, /* debugservices.doctok.ScannerTestService */
+ DOCTOK_ANALYZESERVICE_COMPONENT_ENTRY, /* debugservices.doctok.AnalyzeService */
+ OOXML_SCANNERTESTSERVICE_COMPONENT_ENTRY, /* debugservices.ooxml.ScannerTestService */
+ OOXML_ANALYZESERVICE_COMPONENT_ENTRY, /* debugservices.ooxml.AnalyzeService */
+ { 0, 0, 0, 0, 0, 0 } // terminate with NULL
+};
+
+
+ void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+sal_Bool SAL_CALL component_writeInfo( ::com::sun::star::lang::XMultiServiceFactory * xMgr, ::com::sun::star::registry::XRegistryKey * xRegistry )
+{
+ return ::cppu::component_writeInfoHelper( xMgr, xRegistry, s_component_entries );
+}
+
+
+void * SAL_CALL component_getFactory(sal_Char const * implName, ::com::sun::star::lang::XMultiServiceFactory * xMgr, ::com::sun::star::registry::XRegistryKey * xRegistry )
+{
+ fprintf(stderr, "Loading service: %s: ", implName);
+
+ void * pResult = ::cppu::component_getFactoryHelper(implName, xMgr, xRegistry, s_component_entries );
+
+ fprintf(stderr, "%p\n", pResult);
+
+ return pResult;
+}
+
+}
diff --git a/writerfilter/unocomponent/debugservices/doctok/DocTokAnalyzeService.cxx b/writerfilter/unocomponent/debugservices/doctok/DocTokAnalyzeService.cxx
new file mode 100644
index 000000000000..9ff3253a161d
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/doctok/DocTokAnalyzeService.cxx
@@ -0,0 +1,293 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "DocTokAnalyzeService.hxx"
+#include <stdio.h>
+#include <wchar.h>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <ucbhelper/contentbroker.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <osl/process.h>
+#include <rtl/string.hxx>
+#include <hash_set>
+#include <assert.h>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <comphelper/storagehelper.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/seqstream.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <resourcemodel/WW8ResourceModel.hxx>
+#include <resourcemodel/exceptions.hxx>
+#include <doctok/WW8Document.hxx>
+
+#include <ctype.h>
+
+using namespace ::com::sun::star;
+
+namespace writerfilter { namespace doctoktest {
+
+const sal_Char AnalyzeService::SERVICE_NAME[40] = "debugservices.doctok.AnalyzeService";
+const sal_Char AnalyzeService::IMPLEMENTATION_NAME[40] = "debugservices.doctok.AnalyzeService";
+
+class URLLister
+{
+ uno::Reference<io::XInputStream> xInputStream;
+ rtl::OUString mString;
+ rtl::OUString mCRLF;
+ rtl::OUString mLF;
+
+ sal_uInt32 getEOLIndex()
+ {
+ sal_Int32 nIndex = mString.indexOf(mCRLF);
+
+ if (nIndex == -1)
+ {
+ nIndex = mString.indexOf(mLF);
+ }
+
+ return nIndex;
+ }
+
+public:
+ URLLister(uno::Reference<com::sun::star::uno::XComponentContext> xContext,
+ uno::Reference<lang::XMultiComponentFactory> xFactory,
+ rtl::OUString absFileUrl)
+ {
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess
+ (xFactory->createInstanceWithContext
+ (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.ucb.SimpleFileAccess")),
+ xContext), uno::UNO_QUERY_THROW);
+ xInputStream = xFileAccess->openFileRead(absFileUrl) ;
+
+ mLF = rtl::OUString::createFromAscii("\n");
+ mCRLF = rtl::OUString::createFromAscii("\r\n");
+ }
+
+ rtl::OUString getURL()
+ {
+ rtl::OUString aResult;
+
+ sal_Int32 nIndex = getEOLIndex();
+
+ while (nIndex == -1)
+ {
+ uno::Sequence<sal_Int8> aSeq;
+ sal_uInt32 nCount = xInputStream->readBytes(aSeq, 1024);
+
+ if (nCount > 0)
+ {
+ rtl_String * pNew = 0;
+ rtl_string_newFromStr_WithLength
+ (&pNew, reinterpret_cast<const sal_Char *>(&aSeq[0]),
+ nCount);
+
+ rtl::OString aTmp(pNew);
+ rtl::OUString aTail(rtl::OStringToOUString
+ (aTmp, RTL_TEXTENCODING_ASCII_US));
+ mString = mString.concat(aTail);
+ }
+
+ nIndex = getEOLIndex();
+
+ if (nCount != 1024)
+ break;
+ }
+
+ if (nIndex > 0)
+ {
+ aResult = mString.copy(0, nIndex);
+
+ if (mString.match(mCRLF, nIndex))
+ mString = mString.copy(nIndex + 2);
+ else
+ mString = mString.copy(nIndex + 1);
+ }
+
+ return aResult;
+ }
+};
+
+AnalyzeService::AnalyzeService(const uno::Reference< uno::XComponentContext > &xContext_) :
+xContext( xContext_ )
+{
+}
+
+sal_Int32 SAL_CALL AnalyzeService::run
+( const uno::Sequence< rtl::OUString >& aArguments )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence<uno::Any> aUcbInitSequence(2);
+ aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
+ aUcbInitSequence[1] <<=
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
+ uno::Reference<lang::XMultiServiceFactory>
+ xServiceFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW);
+ uno::Reference<lang::XMultiComponentFactory>
+ xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+
+ if (::ucbhelper::ContentBroker::initialize(xServiceFactory, aUcbInitSequence))
+ {
+ rtl::OUString arg=aArguments[0];
+
+ rtl_uString *dir=NULL;
+ osl_getProcessWorkingDir(&dir);
+
+ rtl::OUString absFileUrlUrls;
+ osl_getAbsoluteFileURL(dir, arg.pData, &absFileUrlUrls.pData);
+
+ URLLister aLister(xContext, xFactory, absFileUrlUrls);
+
+ fprintf(stdout, "<analyze>\n");
+
+ rtl::OUString aURL = aLister.getURL();
+
+ while (aURL.getLength() > 0)
+ {
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess
+ (xFactory->createInstanceWithContext
+ (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.ucb.SimpleFileAccess")),
+ xContext), uno::UNO_QUERY_THROW );
+
+ rtl::OString aStr;
+ aURL.convertToString(&aStr, RTL_TEXTENCODING_ASCII_US,
+ OUSTRING_TO_OSTRING_CVTFLAGS);
+
+ fprintf(stdout, "<file><name>%s</name>\n", aStr.getStr());
+ fprintf(stderr, "%s\n", aStr.getStr());
+ fflush(stderr);
+
+ bool bStatus = true;
+ try
+ {
+ try
+ {
+ uno::Reference<io::XInputStream> xInputStream =
+ xFileAccess->openFileRead(aURL);
+ {
+ doctok::WW8Stream::Pointer_t pDocStream =
+ doctok::WW8DocumentFactory::createStream
+ (xContext, xInputStream);
+
+ if (pDocStream.get() != NULL)
+ {
+ doctok::WW8Document::Pointer_t pDocument
+ (doctok::WW8DocumentFactory::createDocument
+ (pDocStream));
+
+ Stream::Pointer_t pAnalyzer =
+ writerfilter::createAnalyzer();
+ pDocument->resolve(*pAnalyzer);
+ }
+ else
+ {
+ fprintf(stdout,
+ "<exception>file open failed</exception>\n");
+ bStatus = false;
+ }
+ fprintf(stderr, "done\n");
+ }
+
+ xInputStream->closeInput();
+ }
+ catch (Exception e)
+ {
+ fprintf(stdout, "<exception>%s</exception>\n",
+ e.getText().c_str());
+ bStatus = false;
+ }
+ }
+ catch (...)
+ {
+ fprintf(stdout, "<exception>unknown</exception>\n");
+ bStatus = false;
+ }
+
+ if (bStatus)
+ fprintf(stdout, "<status>ok</status>\n");
+ else
+ fprintf(stdout, "<status>failed</status>\n");
+
+ aURL = aLister.getURL();
+
+ fprintf(stdout, "</file>\n");
+ fflush(stdout);
+ }
+
+ fprintf(stdout, "</analyze>\n");
+
+ rtl_uString_release(dir);
+ ::ucbhelper::ContentBroker::deinitialize();
+
+
+ }
+ else
+ {
+ fprintf(stdout, "can't initialize UCB");
+ }
+ return 0;
+}
+
+::rtl::OUString AnalyzeService_getImplementationName ()
+{
+ return rtl::OUString::createFromAscii ( AnalyzeService::IMPLEMENTATION_NAME );
+}
+
+sal_Bool SAL_CALL AnalyzeService_supportsService( const ::rtl::OUString& ServiceName )
+{
+ return ServiceName.equals( rtl::OUString::createFromAscii( AnalyzeService::SERVICE_NAME ) );
+}
+uno::Sequence< rtl::OUString > SAL_CALL AnalyzeService_getSupportedServiceNames( ) throw (uno::RuntimeException)
+{
+ uno::Sequence < rtl::OUString > aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii ( AnalyzeService::SERVICE_NAME );
+ return aRet;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL AnalyzeService_createInstance( const uno::Reference< uno::XComponentContext > & xContext) throw( uno::Exception )
+{
+ return (cppu::OWeakObject*) new AnalyzeService( xContext );
+}
+
+} } /* end namespace writerfilter::doctok */
diff --git a/writerfilter/unocomponent/debugservices/doctok/DocTokAnalyzeService.hxx b/writerfilter/unocomponent/debugservices/doctok/DocTokAnalyzeService.hxx
new file mode 100644
index 000000000000..5aac9bfba90b
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/doctok/DocTokAnalyzeService.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_DOCTOK_ANALYZESERVICE_HXX
+#define INCLUDED_DOCTOK_ANALYZESERVICE_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/lang/XMain.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace writerfilter { namespace doctoktest {
+
+class AnalyzeService : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XMain >
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext;
+
+public:
+ AnalyzeService(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext);
+
+ virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ const static sal_Char SERVICE_NAME[40];
+ const static sal_Char IMPLEMENTATION_NAME[40];
+
+};
+
+::rtl::OUString AnalyzeService_getImplementationName ();
+sal_Bool SAL_CALL AnalyzeService_supportsService( const ::rtl::OUString& ServiceName );
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL AnalyzeService_getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL AnalyzeService_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext) throw( ::com::sun::star::uno::Exception );
+
+} } /* end namespace writerfilter::rtftok */
+
+#define DOCTOK_ANALYZESERVICE_COMPONENT_ENTRY \
+{\
+ writerfilter::doctoktest::AnalyzeService_createInstance,\
+ writerfilter::doctoktest::AnalyzeService_getImplementationName,\
+ writerfilter::doctoktest::AnalyzeService_getSupportedServiceNames,\
+ ::cppu::createSingleComponentFactory,\
+ 0, 0\
+}
+
+
+#endif /* INCLUDED_RTFTOK_ANALYZESERVICE_HXX */
diff --git a/writerfilter/unocomponent/debugservices/doctok/DocTokTestService.cxx b/writerfilter/unocomponent/debugservices/doctok/DocTokTestService.cxx
new file mode 100644
index 000000000000..02a7eddd7a33
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/doctok/DocTokTestService.cxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "DocTokTestService.hxx"
+#include <stdio.h>
+#include <wchar.h>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <ucbhelper/contentbroker.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <osl/process.h>
+#include <rtl/string.hxx>
+#include <hash_set>
+#include <assert.h>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <comphelper/storagehelper.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/seqstream.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <resourcemodel/WW8ResourceModel.hxx>
+#include <resourcemodel/exceptions.hxx>
+#include <doctok/WW8Document.hxx>
+
+#include <ctype.h>
+
+using namespace ::com::sun::star;
+
+namespace writerfilter { namespace doctoktest {
+
+const sal_Char ScannerTestService::SERVICE_NAME[40] = "debugservices.doctok.ScannerTestService";
+const sal_Char ScannerTestService::IMPLEMENTATION_NAME[40] = "debugservices.doctok.ScannerTestService";
+
+
+
+
+ScannerTestService::ScannerTestService(const uno::Reference< uno::XComponentContext > &xContext_) :
+xContext( xContext_ )
+{
+}
+
+sal_Int32 SAL_CALL ScannerTestService::run( const uno::Sequence< rtl::OUString >& aArguments ) throw (uno::RuntimeException)
+{
+ uno::Sequence<uno::Any> aUcbInitSequence(2);
+ aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
+ aUcbInitSequence[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW);
+ uno::Reference<lang::XMultiComponentFactory> xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ if (::ucbhelper::ContentBroker::initialize(xServiceFactory, aUcbInitSequence))
+ {
+ rtl::OUString arg=aArguments[0];
+
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess(
+ xFactory->createInstanceWithContext(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")),
+ xContext), uno::UNO_QUERY_THROW );
+
+ rtl_uString *dir=NULL;
+ osl_getProcessWorkingDir(&dir);
+ rtl::OUString absFileUrl;
+ osl_getAbsoluteFileURL(dir, arg.pData, &absFileUrl.pData);
+ rtl_uString_release(dir);
+
+ uno::Reference<io::XInputStream> xInputStream = xFileAccess->openFileRead(absFileUrl);
+ doctok::WW8Stream::Pointer_t pDocStream = doctok::WW8DocumentFactory::createStream(xContext, xInputStream);
+
+ doctok::WW8Document::Pointer_t pDocument(doctok::WW8DocumentFactory::createDocument(pDocStream));
+
+#if 0
+ TimeValue t1; osl_getSystemTime(&t1);
+#endif
+
+ Stream::Pointer_t pStream = createStreamHandler();
+ pDocument->resolve(*pStream);
+
+#if 0
+ TimeValue t2; osl_getSystemTime(&t2);
+ printf("time=%is\n", t2.Seconds-t1.Seconds);
+#endif
+
+ ::ucbhelper::ContentBroker::deinitialize();
+ }
+ else
+ {
+ fprintf(stderr, "can't initialize UCB");
+ }
+ return 0;
+}
+
+::rtl::OUString ScannerTestService_getImplementationName ()
+{
+ return rtl::OUString::createFromAscii ( ScannerTestService::IMPLEMENTATION_NAME );
+}
+
+sal_Bool SAL_CALL ScannerTestService_supportsService( const ::rtl::OUString& ServiceName )
+{
+ return ServiceName.equals( rtl::OUString::createFromAscii( ScannerTestService::SERVICE_NAME ) );
+}
+uno::Sequence< rtl::OUString > SAL_CALL ScannerTestService_getSupportedServiceNames( ) throw (uno::RuntimeException)
+{
+ uno::Sequence < rtl::OUString > aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii ( ScannerTestService::SERVICE_NAME );
+ return aRet;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL ScannerTestService_createInstance( const uno::Reference< uno::XComponentContext > & xContext) throw( uno::Exception )
+{
+ return (cppu::OWeakObject*) new ScannerTestService( xContext );
+}
+
+} } /* end namespace writerfilter::doctok */
diff --git a/writerfilter/unocomponent/debugservices/doctok/DocTokTestService.hxx b/writerfilter/unocomponent/debugservices/doctok/DocTokTestService.hxx
new file mode 100644
index 000000000000..4fbcfc5b60b6
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/doctok/DocTokTestService.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_DOCTOK_SCANNERTESTSERVICE_HXX
+#define INCLUDED_DOCTOK_SCANNERTESTSERVICE_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/lang/XMain.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace writerfilter { namespace doctoktest {
+
+class ScannerTestService : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XMain >
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext;
+
+public:
+ ScannerTestService(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext);
+
+ virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ const static sal_Char SERVICE_NAME[40];
+ const static sal_Char IMPLEMENTATION_NAME[40];
+
+};
+
+::rtl::OUString ScannerTestService_getImplementationName ();
+sal_Bool SAL_CALL ScannerTestService_supportsService( const ::rtl::OUString& ServiceName );
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ScannerTestService_getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ScannerTestService_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext) throw( ::com::sun::star::uno::Exception );
+
+} } /* end namespace writerfilter::rtftok */
+
+#define DOCTOK_SCANNERTESTSERVICE_COMPONENT_ENTRY \
+{\
+ writerfilter::doctoktest::ScannerTestService_createInstance,\
+ writerfilter::doctoktest::ScannerTestService_getImplementationName,\
+ writerfilter::doctoktest::ScannerTestService_getSupportedServiceNames,\
+ ::cppu::createSingleComponentFactory,\
+ 0, 0\
+}
+
+
+#endif /* INCLUDED_RTFTOK_SCANNERTESTSERVICE_HXX */
diff --git a/writerfilter/unocomponent/debugservices/doctok/makefile.mk b/writerfilter/unocomponent/debugservices/doctok/makefile.mk
new file mode 100644
index 000000000000..989be1baa3de
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/doctok/makefile.mk
@@ -0,0 +1,44 @@
+#************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+# ***********************************************************************/
+PRJ=..$/..$/..
+PRJNAME=writerfilter
+TARGET=debugservices_doctok
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/DocTokTestService.obj \
+ $(SLO)$/DocTokAnalyzeService.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.cxx b/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.cxx
new file mode 100644
index 000000000000..19f7855acb26
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.cxx
@@ -0,0 +1,291 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <comphelper/processfactory.hxx>
+
+#include "OOXMLAnalyzeService.hxx"
+#include <stdio.h>
+#include <wchar.h>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <ucbhelper/contentbroker.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <osl/process.h>
+#include <rtl/string.hxx>
+#include <hash_set>
+#include <assert.h>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <comphelper/storagehelper.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/seqstream.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <resourcemodel/WW8ResourceModel.hxx>
+#include <ooxml/OOXMLDocument.hxx>
+
+#include <ctype.h>
+
+using namespace ::com::sun::star;
+
+namespace writerfilter { namespace ooxmltest {
+
+const sal_Char AnalyzeService::SERVICE_NAME[40] = "debugservices.ooxml.AnalyzeService";
+const sal_Char AnalyzeService::IMPLEMENTATION_NAME[40] = "debugservices.ooxml.AnalyzeService";
+
+class URLLister
+{
+ uno::Reference<io::XInputStream> xInputStream;
+ rtl::OUString mString;
+ rtl::OUString mCRLF;
+ rtl::OUString mLF;
+
+ sal_uInt32 getEOLIndex()
+ {
+ sal_Int32 nIndex = mString.indexOf(mCRLF);
+
+ if (nIndex == -1)
+ {
+ nIndex = mString.indexOf(mLF);
+ }
+
+ return nIndex;
+ }
+
+public:
+ URLLister(uno::Reference<com::sun::star::uno::XComponentContext> xContext,
+ uno::Reference<lang::XMultiComponentFactory> xFactory,
+ rtl::OUString absFileUrl)
+ {
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess
+ (xFactory->createInstanceWithContext
+ (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.ucb.SimpleFileAccess")),
+ xContext), uno::UNO_QUERY_THROW);
+ xInputStream = xFileAccess->openFileRead(absFileUrl) ;
+
+ mLF = rtl::OUString::createFromAscii("\n");
+ mCRLF = rtl::OUString::createFromAscii("\r\n");
+ }
+
+ rtl::OUString getURL()
+ {
+ rtl::OUString aResult;
+
+ sal_Int32 nIndex = getEOLIndex();
+
+ while (nIndex == -1)
+ {
+ uno::Sequence<sal_Int8> aSeq;
+ sal_uInt32 nCount = xInputStream->readBytes(aSeq, 1024);
+
+ if (nCount > 0)
+ {
+ rtl_String * pNew = 0;
+ rtl_string_newFromStr_WithLength
+ (&pNew, reinterpret_cast<const sal_Char *>(&aSeq[0]),
+ nCount);
+
+ rtl::OString aTmp(pNew);
+ rtl::OUString aTail(rtl::OStringToOUString
+ (aTmp, RTL_TEXTENCODING_ASCII_US));
+ mString = mString.concat(aTail);
+ }
+
+ nIndex = getEOLIndex();
+
+ if (nCount != 1024)
+ break;
+ }
+
+ if (nIndex > 0)
+ {
+ aResult = mString.copy(0, nIndex);
+
+ if (mString.match(mCRLF, nIndex))
+ mString = mString.copy(nIndex + 2);
+ else
+ mString = mString.copy(nIndex + 1);
+ }
+
+ return aResult;
+ }
+};
+
+AnalyzeService::AnalyzeService(const uno::Reference< uno::XComponentContext > &xContext_) :
+xContext( xContext_ )
+{
+}
+
+sal_Int32 SAL_CALL AnalyzeService::run
+( const uno::Sequence< rtl::OUString >& aArguments )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence<uno::Any> aUcbInitSequence(2);
+ aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
+ aUcbInitSequence[1] <<=
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
+ uno::Reference<lang::XMultiServiceFactory>
+ xServiceFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW);
+ uno::Reference<lang::XMultiComponentFactory>
+ xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+
+ if (::ucbhelper::ContentBroker::initialize(xServiceFactory, aUcbInitSequence))
+ {
+ ::comphelper::setProcessServiceFactory(xServiceFactory);
+
+ rtl::OUString arg=aArguments[0];
+
+ rtl_uString *dir=NULL;
+ osl_getProcessWorkingDir(&dir);
+
+ rtl::OUString absFileUrlUrls;
+ osl_getAbsoluteFileURL(dir, arg.pData, &absFileUrlUrls.pData);
+
+ URLLister aLister(xContext, xFactory, absFileUrlUrls);
+
+ fprintf(stdout, "<analyze>\n");
+
+ writerfilter::analyzerIds();
+
+ rtl::OUString aURL = aLister.getURL();
+
+ while (aURL.getLength() > 0)
+ {
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess
+ (xFactory->createInstanceWithContext
+ (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.ucb.SimpleFileAccess")),
+ xContext), uno::UNO_QUERY_THROW );
+
+ rtl::OString aStr;
+ aURL.convertToString(&aStr, RTL_TEXTENCODING_ASCII_US,
+ OUSTRING_TO_OSTRING_CVTFLAGS);
+
+ fprintf(stdout, "<file><name>%s</name>\n", aStr.getStr());
+ fprintf(stderr, "%s\n", aStr.getStr());
+ fflush(stderr);
+
+ bool bStatus = true;
+ try
+ {
+ uno::Reference<io::XInputStream> xInputStream =
+ xFileAccess->openFileRead(aURL);
+
+ if (xInputStream.is())
+ {
+ ooxml::OOXMLStream::Pointer_t pDocStream =
+ ooxml::OOXMLDocumentFactory::createStream
+ (xContext, xInputStream);
+
+ if (pDocStream.get() != NULL)
+ {
+ ooxml::OOXMLDocument::Pointer_t pDocument
+ (ooxml::OOXMLDocumentFactory::createDocument
+ (pDocStream));
+
+ Stream::Pointer_t pAnalyzer =
+ writerfilter::createAnalyzer();
+ pDocument->resolve(*pAnalyzer);
+ }
+ else
+ {
+ fprintf(stdout,
+ "<exception>file open failed</exception>\n");
+ bStatus = false;
+ }
+ fprintf(stderr, "done\n");
+ }
+
+ xInputStream->closeInput();
+ }
+ catch (...)
+ {
+ fprintf(stdout, "<exception>unknown</exception>\n");
+ bStatus = false;
+ }
+
+ if (bStatus)
+ fprintf(stdout, "<status>ok</status>\n");
+ else
+ fprintf(stdout, "<status>failed</status>\n");
+
+ aURL = aLister.getURL();
+
+ fprintf(stdout, "</file>\n");
+ fflush(stdout);
+ }
+
+ fprintf(stdout, "</analyze>\n");
+
+ rtl_uString_release(dir);
+ ::ucbhelper::ContentBroker::deinitialize();
+
+
+ }
+ else
+ {
+ fprintf(stdout, "can't initialize UCB");
+ }
+ return 0;
+}
+
+::rtl::OUString AnalyzeService_getImplementationName ()
+{
+ return rtl::OUString::createFromAscii ( AnalyzeService::IMPLEMENTATION_NAME );
+}
+
+sal_Bool SAL_CALL AnalyzeService_supportsService( const ::rtl::OUString& ServiceName )
+{
+ return ServiceName.equals( rtl::OUString::createFromAscii( AnalyzeService::SERVICE_NAME ) );
+}
+uno::Sequence< rtl::OUString > SAL_CALL AnalyzeService_getSupportedServiceNames( ) throw (uno::RuntimeException)
+{
+ uno::Sequence < rtl::OUString > aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii ( AnalyzeService::SERVICE_NAME );
+ return aRet;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL AnalyzeService_createInstance( const uno::Reference< uno::XComponentContext > & xContext) throw( uno::Exception )
+{
+ return (cppu::OWeakObject*) new AnalyzeService( xContext );
+}
+
+} } /* end namespace writerfilter::doctok */
diff --git a/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.hxx b/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.hxx
new file mode 100644
index 000000000000..6acacbac871a
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_OOXML_ANALYZE_SERVICE_HXX
+#define INCLUDED_OOXML_ANALYZE_SERVICE_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/lang/XMain.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace writerfilter { namespace ooxmltest {
+
+class AnalyzeService : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XMain >
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext;
+
+public:
+ AnalyzeService(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext);
+
+ virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ const static sal_Char SERVICE_NAME[40];
+ const static sal_Char IMPLEMENTATION_NAME[40];
+
+};
+
+::rtl::OUString AnalyzeService_getImplementationName ();
+sal_Bool SAL_CALL AnalyzeService_supportsService( const ::rtl::OUString& ServiceName );
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL AnalyzeService_getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL AnalyzeService_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext) throw( ::com::sun::star::uno::Exception );
+
+} } /* end namespace writerfilter::rtftok */
+
+#define OOXML_ANALYZESERVICE_COMPONENT_ENTRY \
+{\
+ writerfilter::ooxmltest::AnalyzeService_createInstance,\
+ writerfilter::ooxmltest::AnalyzeService_getImplementationName,\
+ writerfilter::ooxmltest::AnalyzeService_getSupportedServiceNames,\
+ ::cppu::createSingleComponentFactory,\
+ 0, 0\
+}
+
+
+#endif /* INCLUDED_OOXML_ANALYZE_SERVICE_HXX */
diff --git a/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.cxx b/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.cxx
new file mode 100644
index 000000000000..7a3f80ea22d9
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.cxx
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/lang/XMain.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <comphelper/processfactory.hxx>
+
+#include "OOXMLTestService.hxx"
+#include <stdio.h>
+#include <wchar.h>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <ucbhelper/contentbroker.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <osl/process.h>
+#include <rtl/string.hxx>
+#include <hash_set>
+#include <assert.h>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <comphelper/storagehelper.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/seqstream.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <ooxml/OOXMLDocument.hxx>
+#include <resourcemodel/TagLogger.hxx>
+
+#include <ctype.h>
+
+using namespace ::com::sun::star;
+
+namespace writerfilter { namespace ooxmltest {
+
+const sal_Char ScannerTestService::SERVICE_NAME[40] = "debugservices.ooxml.ScannerTestService";
+const sal_Char ScannerTestService::IMPLEMENTATION_NAME[40] = "debugservices.ooxml.ScannerTestService";
+
+
+
+
+ScannerTestService::ScannerTestService(const uno::Reference< uno::XComponentContext > &xContext_) :
+xContext( xContext_ )
+{
+}
+
+sal_Int32 SAL_CALL ScannerTestService::run( const uno::Sequence< rtl::OUString >& aArguments ) throw (uno::RuntimeException)
+{
+ uno::Sequence<uno::Any> aUcbInitSequence(2);
+ aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
+ aUcbInitSequence[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW);
+ uno::Reference<lang::XMultiComponentFactory> xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ if (::ucbhelper::ContentBroker::initialize(xServiceFactory, aUcbInitSequence))
+ {
+#ifdef DEBUG_ELEMENT
+ writerfilter::TagLogger::Pointer_t debugLogger
+ (writerfilter::TagLogger::getInstance("DEBUG"));
+ debugLogger->startDocument();
+#endif
+
+ rtl::OUString arg=aArguments[0];
+
+ ::comphelper::setProcessServiceFactory(xServiceFactory);
+
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess
+ (xFactory->createInstanceWithContext
+ (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.ucb.SimpleFileAccess")),
+ xContext), uno::UNO_QUERY_THROW );
+
+ rtl_uString *dir=NULL;
+ osl_getProcessWorkingDir(&dir);
+ rtl::OUString absFileUrl;
+ osl_getAbsoluteFileURL(dir, arg.pData, &absFileUrl.pData);
+ rtl_uString_release(dir);
+
+ uno::Reference<io::XInputStream> xInputStream =
+ xFileAccess->openFileRead(absFileUrl);
+ ooxml::OOXMLStream::Pointer_t pDocStream =
+ ooxml::OOXMLDocumentFactory::createStream(xContext, xInputStream);
+
+ ooxml::OOXMLDocument::Pointer_t pDocument
+ (ooxml::OOXMLDocumentFactory::createDocument(pDocStream));
+
+#if 0
+ uno::Reference<text::XTextDocument> xDocument
+ (xFactory->createInstanceWithContext
+ (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("com.sun.star.text.TextDocument")),
+ xContext), uno::UNO_QUERY_THROW );
+ uno::Reference<frame::XModel> xModel
+ (xDocument, uno::UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier
+ (xDocument, uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XShapes> xShapes
+ (xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW);
+
+ pDocument->setModel(xModel);
+ pDocument->setShapes(xShapes);
+#endif
+
+ Stream::Pointer_t pStream = createStreamHandler();
+ pDocument->resolve(*pStream);
+
+#ifdef DEBUG_ELEMENT
+ writerfilter::TagLogger::dump("DEBUG");
+ debugLogger->endDocument();
+#endif
+
+ ::ucbhelper::ContentBroker::deinitialize();
+ }
+ else
+ {
+ fprintf(stderr, "can't initialize UCB");
+ }
+ return 0;
+}
+
+::rtl::OUString ScannerTestService_getImplementationName ()
+{
+ return rtl::OUString::createFromAscii ( ScannerTestService::IMPLEMENTATION_NAME );
+}
+
+sal_Bool SAL_CALL ScannerTestService_supportsService( const ::rtl::OUString& ServiceName )
+{
+ return ServiceName.equals( rtl::OUString::createFromAscii( ScannerTestService::SERVICE_NAME ) );
+}
+uno::Sequence< rtl::OUString > SAL_CALL ScannerTestService_getSupportedServiceNames( ) throw (uno::RuntimeException)
+{
+ uno::Sequence < rtl::OUString > aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii ( ScannerTestService::SERVICE_NAME );
+ return aRet;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL ScannerTestService_createInstance( const uno::Reference< uno::XComponentContext > & xContext) throw( uno::Exception )
+{
+ return (cppu::OWeakObject*) new ScannerTestService( xContext );
+}
+
+} } /* end namespace writerfilter::ooxml */
diff --git a/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.hxx b/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.hxx
new file mode 100644
index 000000000000..10bbb2a569a4
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_OOXML_SCANNERTESTSERVICE_HXX
+#define INCLUDED_OOXML_SCANNERTESTSERVICE_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/lang/XMain.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace writerfilter { namespace ooxmltest {
+
+class ScannerTestService : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XMain >
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext;
+
+public:
+ ScannerTestService(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext);
+
+ virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ const static sal_Char SERVICE_NAME[40];
+ const static sal_Char IMPLEMENTATION_NAME[40];
+
+};
+
+::rtl::OUString ScannerTestService_getImplementationName ();
+sal_Bool SAL_CALL ScannerTestService_supportsService( const ::rtl::OUString& ServiceName );
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ScannerTestService_getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ScannerTestService_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext) throw( ::com::sun::star::uno::Exception );
+
+} } /* end namespace writerfilter::ooxml */
+
+#define OOXML_SCANNERTESTSERVICE_COMPONENT_ENTRY \
+{\
+ writerfilter::ooxmltest::ScannerTestService_createInstance,\
+ writerfilter::ooxmltest::ScannerTestService_getImplementationName,\
+ writerfilter::ooxmltest::ScannerTestService_getSupportedServiceNames,\
+ ::cppu::createSingleComponentFactory,\
+ 0, 0\
+}
+
+
+#endif /* INCLUDED_OOXML_SCANNERTESTSERVICE_HXX */
diff --git a/writerfilter/unocomponent/debugservices/ooxml/makefile.mk b/writerfilter/unocomponent/debugservices/ooxml/makefile.mk
new file mode 100644
index 000000000000..25835aede106
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/ooxml/makefile.mk
@@ -0,0 +1,58 @@
+#************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+# ***********************************************************************/
+PRJ=..$/..$/..
+PRJNAME=writerfilter
+TARGET=debugservices_ooxml
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(GUI)"=="UNX" || "$(GUI)"=="MAC"
+RESSOUREMODELLIB=-lresourcemodel
+.ELIF "$(GUI)"=="WNT"
+.IF "$(COM)"=="GCC"
+RESOURCEMODELLIB=-lresourcemodel
+.ELSE
+RESOURCEMODELLIB=$(LB)$/iresourcemodel.lib
+.ENDIF
+.ENDIF
+
+SHL1STDLIBS= \
+ $(COMPHELPERLIB) \
+ $(RESOURCEMODELLIB)
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/OOXMLTestService.obj \
+ $(SLO)$/OOXMLAnalyzeService.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.cxx b/writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.cxx
new file mode 100644
index 000000000000..1b02fab37dd6
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.cxx
@@ -0,0 +1,455 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "ScannerTestService.hxx"
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <rtftok/RTFScanner.hxx>
+#include <rtftok/RTFScannerHandler.hxx>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <ucbhelper/contentbroker.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <osl/process.h>
+#include <rtl/string.hxx>
+#include <hash_set>
+#include <assert.h>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <comphelper/storagehelper.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/seqstream.hxx>
+
+#include <ctype.h>
+
+using namespace ::com::sun::star;
+
+namespace writerfilter { namespace rtftok {
+
+const sal_Char ScannerTestService::SERVICE_NAME[40] = "debugservices.rtftok.ScannerTestService";
+const sal_Char ScannerTestService::IMPLEMENTATION_NAME[40] = "debugservices.rtftok.ScannerTestService";
+
+struct ScannerTestServiceHelper
+{
+ size_t operator()(const rtl::OString &str) const
+ {
+ return str.hashCode();
+ }
+ bool operator()(const rtl::OString &str1, const rtl::OString &str2) const
+ {
+ return str1.compareTo(str2)==0;
+ }
+};
+
+typedef ::std::hash_set< ::rtl::OString, ScannerTestServiceHelper, ScannerTestServiceHelper > ScannerTestServiceTokenMap;
+
+class MyRtfScannerHandler : public writerfilter::rtftok::RTFScannerHandler
+{
+ ScannerTestServiceTokenMap destMap;
+ ScannerTestServiceTokenMap ctrlMap;
+ std::vector<unsigned char> binBuffer;
+ int objDataLevel;
+ int numOfOLEs;
+ unsigned char hb;
+ int numOfOLEChars;
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory;
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess;
+ uno::Reference<embed::XStorage> xStorage;
+
+ void dest(char* token, char* /*value*/)
+ {
+ destMap.insert(rtl::OString(token));
+// printf("{\\*\\%s%s ", token, value);
+ if (strcmp(token, "objdata")==0)
+ {
+ binBuffer.clear();
+ objDataLevel=1;
+ numOfOLEChars=0;
+ }
+ }
+ void ctrl(char*token, char* /*value*/)
+ {
+ ctrlMap.insert(rtl::OString(token));
+// printf("\\%s%s ", token, value);
+ }
+ void lbrace(void)
+ {
+// printf("{");
+ }
+ void rbrace(void)
+ {
+#ifndef LINUX
+ unsigned char * binBufferStr = ((unsigned char*)&(*binBuffer.begin()));
+
+ if (objDataLevel)
+ {
+ int o=0;
+ unsigned int type=((unsigned int)binBuffer[o]) | ((unsigned int)binBuffer[o+1])<<8 | ((unsigned int)binBuffer[o+2])<<16 | ((unsigned int)binBuffer[o+3]<<24); o+=4;
+ unsigned int recType=((unsigned int)binBuffer[o]) | ((unsigned int)binBuffer[o+1])<<8 | ((unsigned int)binBuffer[o+2])<<16 | ((unsigned int)binBuffer[o+3]<<24); o+=4;
+ unsigned int strLen=((unsigned int)binBuffer[o]) | ((unsigned int)binBuffer[o+1])<<8 | ((unsigned int)binBuffer[o+2])<<16 | ((unsigned int)binBuffer[o+3]<<24); o+=4;
+ unsigned char *str=binBufferStr+o;
+ o+=strLen;
+ o+=4; // dummy1
+ o+=4; // dummy2
+ unsigned int binLen=((unsigned int)binBuffer[o]) | ((unsigned int)binBuffer[o+1])<<8 | ((unsigned int)binBuffer[o+2])<<16 | ((unsigned int)binBuffer[o+3]<<24); o+=4;
+ printf("OLE%i \"%s\" type=%i recType=%i binBuffer.size()=%u len=%u\n", numOfOLEs, str, type, recType, (unsigned int)(binBuffer.size()), o+binLen);
+ //assert(binBuffer.size()==o+binLen);
+ char buf[100];
+ sprintf(buf, "ole%02i.ole", numOfOLEs);
+/* if 0{
+ FILE *f=fopen(buf, "w+b");
+ unsigned char *data=binBuffer.begin();
+ fwrite(data+o, 1, binLen, f);
+ fclose(f);
+ }*/
+/*
+ rtl_uString *dir=NULL;
+ osl_getProcessWorkingDir(&dir);
+ rtl::OUString absFileUrl;
+ rtl::OUString fileUrl=rtl::OUString::createFromAscii(buf);
+ osl_getAbsoluteFileURL(dir, fileUrl.pData, &absFileUrl.pData);
+ rtl_uString_release(dir);
+*/
+ comphelper::ByteSequence seq(binLen);
+ unsigned char *data0=binBufferStr;
+ memcpy(seq.getArray(), data0+o, binLen);
+ uno::Reference<io::XInputStream> myStream=new comphelper::SequenceInputStream(seq);
+// uno::Reference<io::XStream> myStream=xFileAccess->openFileReadWrite(absFileUrl);
+// uno::Reference<io::XStream> myStream(new MyStreamImpl(binBuffer, o));
+ uno::Sequence< uno::Any > aArgs0( 1 );
+ aArgs0[0] <<= myStream;
+ uno::Reference< container::XNameContainer > xNameContainer(
+ xServiceFactory->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii("com.sun.star.embed.OLESimpleStorage" ),
+ aArgs0 ),
+ uno::UNO_QUERY_THROW );
+ try {
+ printf("TRY\n");
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > names=xNameContainer->getElementNames();
+ printf("OK\n");
+
+ for(int i=0;i<names.getLength();i++)
+ {
+ rtl::OUString &name=names[i];
+ wprintf(L"name=%s\n", name.getStr());
+ }
+ {
+ uno::Reference< io::XStream > xContentStream = xStorage->openStreamElement(
+ rtl::OUString::createFromAscii(buf), embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
+ uno::Reference<beans::XPropertySet> xContentStreamPropSet(xContentStream, uno::UNO_QUERY_THROW);
+ xContentStreamPropSet->setPropertyValue(rtl::OUString::createFromAscii("MediaType"), uno::makeAny(rtl::OUString::createFromAscii("application/vnd.sun.star.oleobject")));
+ uno::Reference<io::XOutputStream> myOutStream=xContentStream->getOutputStream();
+ uno::Sequence< ::sal_Int8 > seq1(binLen);
+ unsigned char *data1=binBufferStr;
+ memcpy(seq1.getArray(), data1+o, binLen);
+ myOutStream->writeBytes(seq1);
+ myOutStream->closeOutput();
+ }
+
+ } catch(com::sun::star::uno::RuntimeException &)
+ {
+ printf("NOT OK\n");
+ comphelper::ByteSequence seq2(4+binLen);
+ // memcpy(seq2.getArray(), &binLen, 4); assert(0); //TODO linux
+ seq2[0]= sal::static_int_cast<sal_Int8>(binLen&0xFF);
+ seq2[1]= sal::static_int_cast<sal_Int8>((binLen>>8)&0xFF);
+ seq2[2]= sal::static_int_cast<sal_Int8>((binLen>>16)&0xFF);
+ seq2[3]= sal::static_int_cast<sal_Int8>((binLen>>24)&0xFF);
+ unsigned char *data2=binBufferStr;
+ memcpy(seq2.getArray()+4, data2+o, binLen);
+ uno::Reference<io::XInputStream> myInStream=new comphelper::SequenceInputStream(seq2);
+ printf("SEQ OK\n");
+
+ uno::Reference< io::XStream > xContentStream = xStorage->openStreamElement(
+ rtl::OUString::createFromAscii(buf), embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
+ uno::Reference<beans::XPropertySet> xContentStreamPropSet(xContentStream, uno::UNO_QUERY_THROW);
+ xContentStreamPropSet->setPropertyValue(rtl::OUString::createFromAscii("MediaType"), uno::makeAny(rtl::OUString::createFromAscii("application/vnd.sun.star.oleobject")));
+ printf("CONTENT STREAM OK\n");
+
+ uno::Sequence< uno::Any > aArgs1( 1 );
+ aArgs1[0] <<= xContentStream;
+ uno::Reference< container::XNameContainer > xNameContainer2(
+ xServiceFactory->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii("com.sun.star.embed.OLESimpleStorage" ),
+ aArgs1 ),
+ uno::UNO_QUERY_THROW );
+ printf("OLE STORAGE OK\n");
+
+ uno::Any anyStream;
+ anyStream <<= myInStream;
+ xNameContainer2->insertByName(rtl::OUString::createFromAscii("\1Ole10Native"), anyStream);
+ printf("INSERT OK\n");
+
+ uno::Reference<embed::XTransactedObject> xTransact(xNameContainer2, uno::UNO_QUERY);
+ xTransact->commit();
+ }
+ objDataLevel--;
+ numOfOLEs++;
+ }
+#endif
+// printf("}");
+ }
+ void addSpaces(int /*count*/)
+ {
+// for(int i=0;i<count;i++)
+// printf(" ");
+
+ }
+ void addBinData(unsigned char /*data*/)
+ {
+// printf("%02Xh", data);
+ }
+ void addChar(char ch)
+ {
+// printf("%c", ch);
+ if (objDataLevel)
+ {
+ if (numOfOLEChars%2==0)
+ {
+ char c=sal::static_int_cast<char>(toupper(ch));
+ assert((c<='F' && c>='A') || (c<='9' && c>='0'));
+ if(c>='A') hb=(unsigned char)(c-'A'+10); else hb=(unsigned char)(c-'0');
+ }
+ else
+ {
+ unsigned char lb;
+ char c=sal::static_int_cast<char>(toupper(ch));
+ assert((c<='F' && c>='A') || (c<='9' && c>='0'));
+ if(c>='A') lb=(unsigned char)(c-'A'+10); else lb=(unsigned char)(c-'0');
+ unsigned char r=(hb<<4)|lb;
+ binBuffer.push_back(r);
+ }
+ numOfOLEChars++;
+ }
+ }
+ void addCharU(sal_Unicode /*ch*/)
+ {
+// printf("\\u%i ", ch);
+ }
+ void addHexChar(char* /*hexch*/)
+ {
+// printf("\'%s ", hexch);
+ }
+
+
+public:
+ MyRtfScannerHandler(uno::Reference<lang::XMultiServiceFactory> &xServiceFactory_, uno::Reference<com::sun::star::ucb::XSimpleFileAccess> &xFileAccess_, uno::Reference<embed::XStorage> &xStorage_) :
+ objDataLevel(0), numOfOLEs(0),
+ xServiceFactory(xServiceFactory_),
+ xFileAccess(xFileAccess_),
+ xStorage(xStorage_)
+ {
+ }
+
+ virtual ~MyRtfScannerHandler() {}
+
+ void dump()
+ {
+ printf("Destinations:\n");
+ for(ScannerTestServiceTokenMap::iterator i=destMap.begin();i!=destMap.end();i++)
+ {
+ printf(" %s\n", i->getStr());
+ }
+ printf("Ctrls:\n");
+ for(ScannerTestServiceTokenMap::iterator i=ctrlMap.begin();i!=ctrlMap.end();i++)
+ {
+ printf(" %s\n", i->getStr());
+ }
+ }
+};
+
+class RtfInputSourceImpl : public rtftok::RTFInputSource
+{
+private:
+ uno::Reference< io::XInputStream > xInputStream;
+ uno::Reference< io::XSeekable > xSeekable;
+ uno::Reference< task::XStatusIndicator > xStatusIndicator;
+ sal_Int64 bytesTotal;
+ sal_Int64 bytesRead;
+public:
+ RtfInputSourceImpl(uno::Reference< io::XInputStream > &xInputStream_, uno::Reference< task::XStatusIndicator > &xStatusIndicator_) :
+ xInputStream(xInputStream_),
+ xStatusIndicator(xStatusIndicator_),
+ bytesRead(0)
+ {
+ xSeekable=uno::Reference< io::XSeekable >(xInputStream, uno::UNO_QUERY);
+ if (xSeekable.is())
+ bytesTotal=xSeekable->getLength();
+ if (xStatusIndicator.is() && xSeekable.is())
+ {
+ xStatusIndicator->start(::rtl::OUString::createFromAscii("Converting"), 100);
+ }
+ }
+
+ virtual ~RtfInputSourceImpl() {}
+
+ int read(void *buf, int maxlen)
+ {
+ uno::Sequence< sal_Int8 > buffer;
+ int len=xInputStream->readSomeBytes(buffer,maxlen);
+ if (len>0)
+ {
+ sal_Int8 *_buffer=buffer.getArray();
+ memcpy(buf, _buffer, len);
+ bytesRead+=len;
+ if (xStatusIndicator.is())
+ {
+ if (xSeekable.is())
+ {
+ xStatusIndicator->setValue((int)(bytesRead*100/bytesTotal));
+ }
+ else
+ {
+ char buf1[100];
+ sprintf(buf1, "Converted %" SAL_PRIdINT64 " KB", bytesRead/1024);
+ xStatusIndicator->start(::rtl::OUString::createFromAscii(buf1), 0);
+ }
+ }
+ return len;
+ }
+ else
+ {
+ if (xStatusIndicator.is())
+ {
+ xStatusIndicator->end();
+ }
+ return 0;
+ }
+ }
+};
+
+ScannerTestService::ScannerTestService(const uno::Reference< uno::XComponentContext > &xContext_) :
+xContext( xContext_ )
+{
+}
+
+sal_Int32 SAL_CALL ScannerTestService::run( const uno::Sequence< rtl::OUString >& aArguments ) throw (uno::RuntimeException)
+{
+
+ printf("TEST\n");
+
+ uno::Sequence<uno::Any> aUcbInitSequence(2);
+ aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
+ aUcbInitSequence[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW);
+ printf("A\n");
+ uno::Reference<lang::XMultiComponentFactory> xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ printf("B\n");
+ if (::ucbhelper::ContentBroker::initialize(xServiceFactory, aUcbInitSequence))
+ {
+ printf("C\n");
+ rtl::OUString arg=aArguments[0];
+
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess(
+ xFactory->createInstanceWithContext(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")),
+ xContext), uno::UNO_QUERY_THROW );
+
+ rtl_uString *dir=NULL;
+ osl_getProcessWorkingDir(&dir);
+ rtl::OUString absFileUrl;
+ osl_getAbsoluteFileURL(dir, arg.pData, &absFileUrl.pData);
+ rtl_uString_release(dir);
+
+ uno::Reference <lang::XSingleServiceFactory> xStorageFactory(
+ xServiceFactory->createInstance (rtl::OUString::createFromAscii("com.sun.star.embed.StorageFactory")), uno::UNO_QUERY_THROW);
+
+ rtl::OUString outFileUrl;
+ {
+ rtl_uString *dir1=NULL;
+ osl_getProcessWorkingDir(&dir1);
+ osl_getAbsoluteFileURL(dir1, aArguments[1].pData, &outFileUrl.pData);
+ rtl_uString_release(dir1);
+ }
+
+ uno::Sequence< uno::Any > aArgs2( 2 );
+ aArgs2[0] <<= outFileUrl;
+ aArgs2[1] <<= embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE;
+ uno::Reference<embed::XStorage> xStorage(xStorageFactory->createInstanceWithArguments(aArgs2), uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xPropSet(xStorage, uno::UNO_QUERY_THROW);
+ xPropSet->setPropertyValue(rtl::OUString::createFromAscii("MediaType"), uno::makeAny(rtl::OUString::createFromAscii("application/vnd.oasis.opendocument.text")));
+ uno::Reference<io::XInputStream> xInputStream = xFileAccess->openFileRead(absFileUrl);
+ uno::Reference< task::XStatusIndicator > xStatusIndicator;
+
+ TimeValue t1; osl_getSystemTime(&t1);
+
+ RtfInputSourceImpl rtfInputSource(xInputStream, xStatusIndicator);
+ MyRtfScannerHandler eventHandler(xServiceFactory, xFileAccess, xStorage);
+ writerfilter::rtftok::RTFScanner *rtfScanner=writerfilter::rtftok::RTFScanner::createRTFScanner(rtfInputSource, eventHandler);
+
+ rtfScanner->yylex();
+ delete rtfScanner;
+
+ TimeValue t2; osl_getSystemTime(&t2);
+ printf("time=%" SAL_PRIuUINT32 "s\n", t2.Seconds-t1.Seconds);
+
+// eventHandler.dump();
+ uno::Reference<embed::XTransactedObject> xTransact(xStorage, uno::UNO_QUERY);
+ xTransact->commit();
+
+
+ ::ucbhelper::ContentBroker::deinitialize();
+ }
+ else
+ {
+ fprintf(stderr, "can't initialize UCB");
+ }
+ return 0;
+}
+
+::rtl::OUString ScannerTestService_getImplementationName ()
+{
+ return rtl::OUString::createFromAscii ( ScannerTestService::IMPLEMENTATION_NAME );
+}
+
+sal_Bool SAL_CALL ScannerTestService_supportsService( const ::rtl::OUString& ServiceName )
+{
+ return ServiceName.equals( rtl::OUString::createFromAscii( ScannerTestService::SERVICE_NAME ) );
+}
+uno::Sequence< rtl::OUString > SAL_CALL ScannerTestService_getSupportedServiceNames( ) throw (uno::RuntimeException)
+{
+ uno::Sequence < rtl::OUString > aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii ( ScannerTestService::SERVICE_NAME );
+ return aRet;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL ScannerTestService_createInstance( const uno::Reference< uno::XComponentContext > & xContext) throw( uno::Exception )
+{
+ return (cppu::OWeakObject*) new ScannerTestService( xContext );
+}
+
+} } /* end namespace writerfilter::rtftok */
diff --git a/writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.hxx b/writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.hxx
new file mode 100644
index 000000000000..9577a4c81553
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_RTFTOK_SCANNERTESTSERVICE_HXX
+#define INCLUDED_RTFTOK_SCANNERTESTSERVICE_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/lang/XMain.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace writerfilter { namespace rtftok {
+
+class ScannerTestService : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XMain >
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext;
+
+public:
+ ScannerTestService(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext);
+
+ virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ const static sal_Char SERVICE_NAME[40];
+ const static sal_Char IMPLEMENTATION_NAME[40];
+
+};
+
+::rtl::OUString ScannerTestService_getImplementationName ();
+sal_Bool SAL_CALL ScannerTestService_supportsService( const ::rtl::OUString& ServiceName );
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ScannerTestService_getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ScannerTestService_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext) throw( ::com::sun::star::uno::Exception );
+
+} } /* end namespace writerfilter::rtftok */
+
+#define RTFTOK_SCANNERTESTSERVICE_COMPONENT_ENTRY \
+{\
+ writerfilter::rtftok::ScannerTestService_createInstance,\
+ writerfilter::rtftok::ScannerTestService_getImplementationName,\
+ writerfilter::rtftok::ScannerTestService_getSupportedServiceNames,\
+ ::cppu::createSingleComponentFactory,\
+ 0, 0\
+}
+
+
+#endif /* INCLUDED_RTFTOK_SCANNERTESTSERVICE_HXX */
diff --git a/writerfilter/unocomponent/debugservices/rtftok/XMLScanner.cxx b/writerfilter/unocomponent/debugservices/rtftok/XMLScanner.cxx
new file mode 100644
index 000000000000..a4a845959afe
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/rtftok/XMLScanner.cxx
@@ -0,0 +1,333 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "XMLScanner.hxx"
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <rtftok/RTFScanner.hxx>
+#include <rtftok/RTFScannerHandler.hxx>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <ucbhelper/contentbroker.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <osl/process.h>
+#include <rtl/string.hxx>
+#include <hash_set>
+#include <assert.h>
+#include <string>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <comphelper/storagehelper.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/seqstream.hxx>
+
+#include <ctype.h>
+#include <iostream>
+
+using namespace ::com::sun::star;
+using namespace ::std;
+
+namespace writerfilter { namespace rtftok {
+
+const sal_Char XMLScanner::SERVICE_NAME[40] = "debugservices.rtftok.XMLScanner";
+const sal_Char XMLScanner::IMPLEMENTATION_NAME[40] = "debugservices.rtftok.XMLScanner";
+
+class XmlRtfScannerHandler : public writerfilter::rtftok::RTFScannerHandler
+{
+ std::vector<unsigned char> binBuffer;
+ int objDataLevel;
+ int numOfOLEs;
+ unsigned char hb;
+ int numOfOLEChars;
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory;
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess;
+ string charBuffer;
+ string ucharBuffer;
+ vector<string> vCloseTags;
+
+ void xmlout(const string & str)
+ {
+ for (size_t n = 0; n < str.length(); ++n)
+ {
+ char c = str[n];
+
+ switch (c)
+ {
+ case '<': cout << "&lt;"; break;
+ case '>': cout << "&gt;"; break;
+ case '&': cout << "&amp;"; break;
+ default:
+ cout << c;
+
+ break;
+ }
+ }
+ }
+
+ void clearBuffers()
+ {
+ if (charBuffer.length() > 0)
+ {
+ cout << "<text>";
+ xmlout(charBuffer);
+ cout << "</text>" << endl;
+ }
+
+ charBuffer = "";
+
+ if (ucharBuffer.length() > 0)
+ {
+ cout << "<utext>";
+ xmlout(ucharBuffer);
+ cout << ucharBuffer << "</utext>" << endl;
+ }
+
+ ucharBuffer = "";
+ }
+
+ void dest(char* token, char* value)
+ {
+ clearBuffers();
+ cout << "<dest name=\"" << token << "\" value=\""<< value << "\">" << endl;
+ vCloseTags.push_back("</dest>");
+ }
+ void ctrl(char*token, char* value)
+ {
+ clearBuffers();
+ cout << "<" << token << ">" << value << "</" << token << ">"
+ << endl;
+ }
+ void lbrace(void)
+ {
+ clearBuffers();
+ cout << "<brace>" << endl;
+ vCloseTags.push_back("</brace>");
+ }
+ void rbrace(void)
+ {
+ clearBuffers();
+ cout << vCloseTags.back() << endl;
+ vCloseTags.pop_back();
+ }
+ void addSpaces(int count)
+ {
+ clearBuffers();
+ cout << "<spaces count=\"" << count << "\"/>" << endl;
+ }
+ void addBinData(unsigned char /*data*/)
+ {
+ clearBuffers();
+ cout << "<bindata/>" << endl;
+ }
+ void addChar(char ch)
+ {
+ charBuffer += ch;
+ }
+ void addCharU(sal_Unicode ch)
+ {
+ ucharBuffer += sal_Char(ch < 128 ? ch : '.');
+ }
+ void addHexChar(char* hexch)
+ {
+ clearBuffers();
+ cout << "<hexchar value=\"" << hexch << "\"/>" << endl;
+ }
+
+public:
+ XmlRtfScannerHandler(uno::Reference<lang::XMultiServiceFactory> &xServiceFactory_, uno::Reference<com::sun::star::ucb::XSimpleFileAccess> &xFileAccess_) :
+ objDataLevel(0), numOfOLEs(0),
+ xServiceFactory(xServiceFactory_),
+ xFileAccess(xFileAccess_)
+ {
+ }
+
+ virtual ~XmlRtfScannerHandler() {}
+
+ void dump()
+ {
+ }
+};
+
+class RtfInputSourceImpl : public rtftok::RTFInputSource
+{
+private:
+ uno::Reference< io::XInputStream > xInputStream;
+ uno::Reference< io::XSeekable > xSeekable;
+ uno::Reference< task::XStatusIndicator > xStatusIndicator;
+ sal_Int64 bytesTotal;
+ sal_Int64 bytesRead;
+public:
+ RtfInputSourceImpl(uno::Reference< io::XInputStream > &xInputStream_, uno::Reference< task::XStatusIndicator > &xStatusIndicator_) :
+ xInputStream(xInputStream_),
+ xStatusIndicator(xStatusIndicator_),
+ bytesRead(0)
+ {
+ xSeekable=uno::Reference< io::XSeekable >(xInputStream, uno::UNO_QUERY);
+ if (xSeekable.is())
+ bytesTotal=xSeekable->getLength();
+ if (xStatusIndicator.is() && xSeekable.is())
+ {
+ xStatusIndicator->start(::rtl::OUString::createFromAscii("Converting"), 100);
+ }
+ }
+
+ virtual ~RtfInputSourceImpl() {}
+
+ int read(void *buf, int maxlen)
+ {
+ uno::Sequence< sal_Int8 > buffer;
+ int len=xInputStream->readSomeBytes(buffer,maxlen);
+ if (len>0)
+ {
+ sal_Int8 *_buffer=buffer.getArray();
+ memcpy(buf, _buffer, len);
+ bytesRead+=len;
+ if (xStatusIndicator.is())
+ {
+ if (xSeekable.is())
+ {
+ xStatusIndicator->setValue((int)(bytesRead*100/bytesTotal));
+ }
+ else
+ {
+ char buf1[100];
+ sprintf(buf1, "Converted %" SAL_PRIdINT64 " KB", bytesRead/1024);
+ xStatusIndicator->start(::rtl::OUString::createFromAscii(buf1), 0);
+ }
+ }
+ return len;
+ }
+ else
+ {
+ if (xStatusIndicator.is())
+ {
+ xStatusIndicator->end();
+ }
+ return 0;
+ }
+ }
+};
+
+XMLScanner::XMLScanner(const uno::Reference< uno::XComponentContext > &xContext_) :
+xContext( xContext_ )
+{
+}
+
+sal_Int32 SAL_CALL XMLScanner::run( const uno::Sequence< rtl::OUString >& aArguments ) throw (uno::RuntimeException)
+{
+ uno::Sequence<uno::Any> aUcbInitSequence(2);
+ aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
+ aUcbInitSequence[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW);
+ uno::Reference<lang::XMultiComponentFactory> xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ if (::ucbhelper::ContentBroker::initialize(xServiceFactory, aUcbInitSequence))
+ {
+ rtl::OUString arg=aArguments[0];
+
+ uno::Reference<com::sun::star::ucb::XSimpleFileAccess> xFileAccess(
+ xFactory->createInstanceWithContext(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")),
+ xContext), uno::UNO_QUERY_THROW );
+
+ rtl_uString *dir=NULL;
+ osl_getProcessWorkingDir(&dir);
+ rtl::OUString absFileUrl;
+ osl_getAbsoluteFileURL(dir, arg.pData, &absFileUrl.pData);
+ rtl_uString_release(dir);
+
+ uno::Reference <lang::XSingleServiceFactory> xStorageFactory(
+ xServiceFactory->createInstance (rtl::OUString::createFromAscii("com.sun.star.embed.StorageFactory")), uno::UNO_QUERY_THROW);
+
+#if 0
+ rtl::OUString outFileUrl;
+ {
+ rtl_uString *dir1=NULL;
+ osl_getProcessWorkingDir(&dir1);
+ osl_getAbsoluteFileURL(dir1, aArguments[1].pData, &outFileUrl.pData);
+ rtl_uString_release(dir1);
+ }
+
+ uno::Sequence< uno::Any > aArgs( 2 );
+ aArgs[0] <<= outFileUrl;
+ aArgs[1] <<= embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE;
+ uno::Reference<embed::XStorage> xStorage(xStorageFactory->createInstanceWithArguments(aArgs), uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xPropSet(xStorage, uno::UNO_QUERY_THROW);
+ xPropSet->setPropertyValue(rtl::OUString::createFromAscii("MediaType"), uno::makeAny(rtl::OUString::createFromAscii("application/vnd.oasis.opendocument.text")));
+#endif
+ uno::Reference<io::XInputStream> xInputStream = xFileAccess->openFileRead(absFileUrl);
+ uno::Reference< task::XStatusIndicator > xStatusIndicator;
+
+ RtfInputSourceImpl rtfInputSource(xInputStream, xStatusIndicator);
+ XmlRtfScannerHandler eventHandler(xServiceFactory, xFileAccess);
+ writerfilter::rtftok::RTFScanner *rtfScanner=writerfilter::rtftok::RTFScanner::createRTFScanner(rtfInputSource, eventHandler);
+
+ cout << "<out>" << endl;
+ rtfScanner->yylex();
+ cout << "</out>" << endl;
+ delete rtfScanner;
+
+ ::ucbhelper::ContentBroker::deinitialize();
+ }
+ else
+ {
+ fprintf(stderr, "can't initialize UCB");
+ }
+ return 0;
+}
+
+::rtl::OUString XMLScanner_getImplementationName ()
+{
+ return rtl::OUString::createFromAscii ( XMLScanner::IMPLEMENTATION_NAME );
+}
+
+sal_Bool SAL_CALL XMLScanner_supportsService( const ::rtl::OUString& ServiceName )
+{
+ return ServiceName.equals( rtl::OUString::createFromAscii( XMLScanner::SERVICE_NAME ) );
+}
+uno::Sequence< rtl::OUString > SAL_CALL XMLScanner_getSupportedServiceNames( ) throw (uno::RuntimeException)
+{
+ uno::Sequence < rtl::OUString > aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii ( XMLScanner::SERVICE_NAME );
+ return aRet;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL XMLScanner_createInstance( const uno::Reference< uno::XComponentContext > & xContext) throw( uno::Exception )
+{
+ return (cppu::OWeakObject*) new XMLScanner( xContext );
+}
+
+} } /* end namespace writerfilter::rtftok */
diff --git a/writerfilter/unocomponent/debugservices/rtftok/XMLScanner.hxx b/writerfilter/unocomponent/debugservices/rtftok/XMLScanner.hxx
new file mode 100644
index 000000000000..d489b7400f2d
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/rtftok/XMLScanner.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_RTFTOK_XMLSCANNER_HXX
+#define INCLUDED_RTFTOK_XMLSCANNER_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/lang/XMain.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace writerfilter { namespace rtftok {
+
+class XMLScanner : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XMain >
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext;
+
+public:
+ XMLScanner(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext);
+
+ virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ const static sal_Char SERVICE_NAME[40];
+ const static sal_Char IMPLEMENTATION_NAME[40];
+
+};
+
+::rtl::OUString XMLScanner_getImplementationName ();
+sal_Bool SAL_CALL XMLScanner_supportsService( const ::rtl::OUString& ServiceName );
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL XMLScanner_getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL XMLScanner_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext) throw( ::com::sun::star::uno::Exception );
+
+} } /* end namespace writerfilter::rtftok */
+
+#define RTFTOK_XMLSCANNER_COMPONENT_ENTRY \
+{\
+ writerfilter::rtftok::XMLScanner_createInstance,\
+ writerfilter::rtftok::XMLScanner_getImplementationName,\
+ writerfilter::rtftok::XMLScanner_getSupportedServiceNames,\
+ ::cppu::createSingleComponentFactory,\
+ 0, 0\
+}
+
+
+#endif /* INCLUDED_RTFTOK_SCANNERTESTSERVICE_HXX */
diff --git a/writerfilter/unocomponent/debugservices/rtftok/makefile.mk b/writerfilter/unocomponent/debugservices/rtftok/makefile.mk
new file mode 100644
index 000000000000..66c54a8707cd
--- /dev/null
+++ b/writerfilter/unocomponent/debugservices/rtftok/makefile.mk
@@ -0,0 +1,45 @@
+#************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+# ***********************************************************************/
+PRJ=..$/..$/..
+PRJNAME=writerfilter
+TARGET=debugservices_rtftok
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/ScannerTestService.obj \
+ $(SLO)$/XMLScanner.obj
+#$(SLO)$/TestService.obj $(SLO)$/ResolverTestService.obj $(SLO)$/XmlParserTestService.obj $(SLO)$/RngService.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/writerfilter/unocomponent/exports.dxp b/writerfilter/unocomponent/exports.dxp
new file mode 100644
index 000000000000..028ac4175990
--- /dev/null
+++ b/writerfilter/unocomponent/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/writerfilter/unocomponent/makefile.mk b/writerfilter/unocomponent/makefile.mk
new file mode 100644
index 000000000000..a01d391e88fb
--- /dev/null
+++ b/writerfilter/unocomponent/makefile.mk
@@ -0,0 +1,90 @@
+#************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+# ***********************************************************************/
+PRJ=..
+PRJNAME=writerfilter
+TARGET=writerfilter.uno
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CDEFS+=-DWRITERFILTER_DLLIMPLEMENTATION
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/component.obj
+
+SHL1TARGET=$(TARGET)
+
+.IF "$(GUI)"=="UNX" || "$(GUI)"=="MAC"
+DOCTOKLIB=-ldoctok
+OOXMLLIB=-looxml
+RESOURCEMODELLIB=-lresourcemodel
+.ELIF "$(GUI)"=="OS2"
+DOCTOKLIB=$(LB)$/idoctok.lib
+OOXMLLIB=$(LB)$/iooxml.lib
+RESOURCEMODELLIB=$(LB)$/iresourcemodel.lib
+.ELIF "$(GUI)"=="WNT"
+.IF "$(COM)"=="GCC"
+DOCTOKLIB=-ldoctok
+OOXMLLIB=-looxml
+RESOURCEMODELLIB=-lresourcemodel
+.ELSE
+DOCTOKLIB=$(LB)$/idoctok.lib
+OOXMLLIB=$(LB)$/iooxml.lib
+RESOURCEMODELLIB=$(LB)$/iresourcemodel.lib
+.ENDIF
+.ENDIF
+
+SHL1STDLIBS=$(SALLIB)\
+ $(CPPULIB)\
+ $(COMPHELPERLIB)\
+ $(CPPUHELPERLIB)\
+ $(UCBHELPERLIB)\
+ $(DOCTOKLIB) \
+ $(OOXMLLIB) \
+ $(RESOURCEMODELLIB)
+
+SHL1LIBS=\
+ $(SLB)$/debugservices_doctok.lib \
+ $(SLB)$/debugservices_ooxml.lib
+
+SHL1IMPLIB=i$(SHL1TARGET)
+
+SHL1OBJS = $(SLO)$/component.obj
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+