summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-10-01 13:41:24 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-10-01 14:05:26 +0100
commit2cea241cb55f8c8714744fab4c4e83a07ad66ffa (patch)
tree6cdc40f34cd3a6b0fec26ec685d2c6b2ae4bf6e4
parentd80f53b318bbce420e6eb4c3892022e126dfd289 (diff)
add 602 format to fftester
Change-Id: I52055dc66ab2119dce6e3df3a34c25a822dea166
-rw-r--r--filter/Library_t602filter.mk1
-rw-r--r--filter/source/t602/t602filter.cxx63
-rw-r--r--filter/source/t602/t602filter.hxx3
-rw-r--r--vcl/workben/fftester.cxx14
4 files changed, 68 insertions, 13 deletions
diff --git a/filter/Library_t602filter.mk b/filter/Library_t602filter.mk
index a3735f5e45c3..e744c153bf6f 100644
--- a/filter/Library_t602filter.mk
+++ b/filter/Library_t602filter.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_Library_use_sdk_api,t602filter))
$(eval $(call gb_Library_use_libraries,t602filter,\
xo \
tl \
+ comphelper \
cppuhelper \
cppu \
sal \
diff --git a/filter/source/t602/t602filter.cxx b/filter/source/t602/t602filter.cxx
index 9dae5b84203e..118da3ec0f29 100644
--- a/filter/source/t602/t602filter.cxx
+++ b/filter/source/t602/t602filter.cxx
@@ -36,6 +36,7 @@
#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/awt/XDialog.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <comphelper/oslfile2streamwrap.hxx>
using namespace ::cppu;
using namespace ::osl;
@@ -115,11 +116,17 @@ namespace T602ImportFilter {
"\x00\xb4\x00\xb0\x00\xc0\x02\xc6\x01\x58\x01\x59\x00\x20\x00\x20";
#define _Start(_nam) \
- mxHandler->startElement(_nam, mAttrList);\
- mpAttrList->Clear();
+ if (mxHandler.is()) \
+ { \
+ mxHandler->startElement(_nam, mAttrList); \
+ mpAttrList->Clear(); \
+ }
#define _End(_nam) \
- mxHandler->endElement(_nam);
+ if (mxHandler.is()) \
+ { \
+ mxHandler->endElement(_nam); \
+ }
inistruct ini;
@@ -130,6 +137,14 @@ T602ImportFilter::T602ImportFilter(const css::uno::Reference<css::lang::XMultiSe
{
}
+T602ImportFilter::T602ImportFilter(css::uno::Reference<css::io::XInputStream> xInputStream)
+ : mxInputStream(xInputStream)
+ , mpAttrList(NULL)
+ , node(START)
+{
+}
+
+
T602ImportFilter::~T602ImportFilter()
{
}
@@ -219,7 +234,8 @@ void T602ImportFilter::inschr(unsigned char ch)
} else {
char s[20];
sprintf(s,"%i",pst.wasspace);
- mpAttrList->AddAttribute("text:c",OUString::createFromAscii(s));
+ if (mpAttrList)
+ mpAttrList->AddAttribute("text:c",OUString::createFromAscii(s));
_Start("text:s");
_End("text:s");
}
@@ -440,6 +456,13 @@ bool SAL_CALL T602ImportFilter::importImpl( const Sequence< css::beans::Property
return true;
}
+bool SAL_CALL T602ImportFilter::test()
+{
+ Reset602();
+ Read602();
+ return true;
+}
+
void T602ImportFilter::Reset602()
{
node = START;
@@ -496,7 +519,8 @@ void T602ImportFilter::inschrdef(unsigned char ch)
xch[0] = ch;
pst.waspar = false;
- mxHandler->characters(OUString(xch));
+ if (mxHandler.is())
+ mxHandler->characters(OUString(xch));
}
void T602ImportFilter::wrtfnt()
@@ -517,8 +541,9 @@ void T602ImportFilter::wrtfnt()
}
_End("text:span");
- mpAttrList->AddAttribute(
- "text:style-name", OUString::createFromAscii(style));
+ if (mpAttrList)
+ mpAttrList->AddAttribute(
+ "text:style-name", OUString::createFromAscii(style));
_Start("text:span");
}
@@ -555,7 +580,8 @@ void T602ImportFilter::par602(bool endofpage)
if(pst.waspar||ini.reformatpars) {
_End("text:span");
_End("text:p");
- mpAttrList->AddAttribute("text:style-name", "P1");
+ if (mpAttrList)
+ mpAttrList->AddAttribute("text:style-name", "P1");
_Start("text:p");
_Start("text:span");
wrtfnt();
@@ -581,7 +607,8 @@ void T602ImportFilter::par602(bool endofpage)
if(!ini.reformatpars) {
_End("text:span");
_End("text:p");
- mpAttrList->AddAttribute("text:style-name", "P2");
+ if (mpAttrList)
+ mpAttrList->AddAttribute("text:style-name", "P2");
_Start("text:p");
_Start("text:span");
wrtfnt();
@@ -688,9 +715,11 @@ void T602ImportFilter::Read602()
if (node==QUIT) return;
- mpAttrList->AddAttribute("text:style-name", "P1");
+ if (mpAttrList)
+ mpAttrList->AddAttribute("text:style-name", "P1");
_Start("text:p");
- mpAttrList->AddAttribute("text:style-name", "T1");
+ if (mpAttrList)
+ mpAttrList->AddAttribute("text:style-name", "T1");
_Start("text:span");
if (node==START) { node = EOL; }
@@ -739,7 +768,8 @@ void T602ImportFilter::Read602()
node = SETCMD; //nedodelano
else {
inschr('@');
- mxHandler->characters(OUString::createFromAscii(cmd602));
+ if (mxHandler.is())
+ mxHandler->characters(OUString::createFromAscii(cmd602));
node = READCH;
}
} else {
@@ -1170,4 +1200,13 @@ Reference< XInterface > SAL_CALL T602ImportFilterDialog_createInstance( const Re
}
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImport602(const OUString &rURL)
+{
+ osl::File aInputFile(rURL);
+ aInputFile.open(osl_File_OpenFlag_Read);
+ css::uno::Reference<io::XInputStream> xStream(new comphelper::OSLInputStreamWrapper(aInputFile));
+ T602ImportFilter::T602ImportFilter aImport(xStream);
+ return aImport.test();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/t602/t602filter.hxx b/filter/source/t602/t602filter.hxx
index f12404bb2d2c..4ab091bc4cc3 100644
--- a/filter/source/t602/t602filter.hxx
+++ b/filter/source/t602/t602filter.hxx
@@ -255,6 +255,7 @@ private:
public:
T602ImportFilter(const css::uno::Reference<css::lang::XMultiServiceFactory > &r );
+ T602ImportFilter(css::uno::Reference<css::io::XInputStream> xInputStream);
virtual ~T602ImportFilter();
// XFilter
@@ -283,6 +284,8 @@ private:
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ bool SAL_CALL test();
};
OUString T602ImportFilter_getImplementationName()
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index f0bbb7442668..1143bfcbe521 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -348,7 +348,6 @@ try_again:
}
ret = (int) (*pfnImport)(out);
}
-
else if (strcmp(argv[2], "hwp") == 0)
{
static HFilterCall pfnImport(0);
@@ -362,6 +361,19 @@ try_again:
}
ret = (int) (*pfnImport)(out);
}
+ else if (strcmp(argv[2], "602") == 0)
+ {
+ static HFilterCall pfnImport(0);
+ if (!pfnImport)
+ {
+ osl::Module aLibrary;
+ aLibrary.loadRelative(&thisModule, "libt602filterlo.so", SAL_LOADMODULE_LAZY);
+ pfnImport = reinterpret_cast<HFilterCall>(
+ aLibrary.getFunctionSymbol("TestImport602"));
+ aLibrary.release();
+ }
+ ret = (int) (*pfnImport)(out);
+ }
else if (strcmp(argv[2], "lwp") == 0)
{
static HFilterCall pfnImport(0);