From 32b35febe4c859660a1eafe81be6a18fab831bb0 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 28 Mar 2014 12:57:40 +0000 Subject: [PATCH] Remodelando interface libreoffice --- src/oxt/Makefile.in | 41 +++++++++++++++++++++++++++++++++++++++++ src/oxt/globals.hpp | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/oxt/loffice3270.cbp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/oxt/pw3270.idl | 2 +- src/oxt/testprogram.cc | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 src/oxt/globals.hpp create mode 100644 src/oxt/loffice3270.cbp create mode 100644 src/oxt/testprogram.cc diff --git a/src/oxt/Makefile.in b/src/oxt/Makefile.in index 8e0d1e7..20bc84a 100644 --- a/src/oxt/Makefile.in +++ b/src/oxt/Makefile.in @@ -32,6 +32,15 @@ REGMERGE=@REGMERGE@ CPPUMAKER=@CPPUMAKER@ TYPES_RDB=@OO_SDK_URE_HOME@/share/misc/types.rdb +#---[ Paths ]------------------------------------------------------------------ + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +sbindir=@sbindir@ +libdir=@libdir@ +includedir=@includedir@ + #---[ Tools ]------------------------------------------------------------------ CXX=@CXX@ @@ -42,6 +51,22 @@ MKDIR=@MKDIR_P@ CLASSLIBDIR=../classlib include $(CLASSLIBDIR)/class.mak +#---[ lib3270 common class ]--------------------------------------------------- + +OBJDIR=.obj +BINDIR=.bin + +OBJDBG=$(OBJDIR)/Debug +BINDBG=$(BINDIR)/Debug + +OBJRLS=$(OBJDIR)/Release +BINRLS=$(BINDIR)/Release + +#---[ Build options ]---------------------------------------------------------- + +CPPUENV="gcc3" +CXXFLAGS=@CXXFLAGS@ -Wno-strict-aliasing -I./include -I$(includedir)/libreoffice -Wno-strict-aliasing -DCPPU_ENV=$(CPPUENV) -DLANGUAGE_BINDING_NAME=\"$(CPPUENV)\" + #---[ Rules ]------------------------------------------------------------------ %.urd: %.idl @@ -54,6 +79,13 @@ include $(CLASSLIBDIR)/class.mak @$(MKDIR) `dirname $@` @$(REGMERGE) $@ /UCR $< +$(OBJDBG)/%.o: %.cc include/pw3270/lib3270.hpp Makefile + @echo $< ... + @mkdir -p `dirname $@` + $(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ $< +# $(DBG_CFLAGS) $(CXXFLAGS) $(LIB3270_CFLAGS) -DLIBNAME=\"$(BINDBG)/$(PROGRAM_NAME).uno@DLLEXT@\" -o $@ -c $< + + #---[ UNO targets ]------------------------------------------------------------ include/pw3270/lib3270.hpp: pw3270.rdb @@ -62,6 +94,13 @@ include/pw3270/lib3270.hpp: pw3270.rdb @$(CPPUMAKER) -O./include -Tpw3270.lib3270 $(TYPES_RDB) $< +#---[ Debug targets ]---------------------------------------------------------- + +Debug: $(OBJDBG)/testprogram.o + +cleanDebug: clean + + #---[ Misc targets ]----------------------------------------------------------- all: include/pw3270/lib3270.hpp @@ -70,5 +109,7 @@ clean: @rm -f *.urd @rm -f *.rdb @rm -fr include + @rm -fr $(OBJDIR) + @rm -fr $(BINDIR) diff --git a/src/oxt/globals.hpp b/src/oxt/globals.hpp new file mode 100644 index 0000000..f3cbd13 --- /dev/null +++ b/src/oxt/globals.hpp @@ -0,0 +1,69 @@ +/* + * "Software PW3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA, 02111-1307, USA + * + * Este programa está nomeado como globals.hpp e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) + * + */ + +#ifndef PW3270_OXT_GLOBALS_HPP_INCLUDED + + #define PW3270_OXT_GLOBALS_HPP_INCLUDED 1 + + #define CPPUENV "gcc3" + + #ifdef _WIN32 + #define SAL_W32 + #else + #define UNX 1 + #define GCC 1 + #define LINUX 1 + #endif + + + #include // "3" implementing three interfaces + #include + #include + + #include + #include + #include + + + using namespace ::rtl; // for OUString + using namespace ::com::sun::star; // for sdk interfaces + using namespace ::com::sun::star::uno; // for basic types + + + namespace pw3270_impl + { + + class sessionImpl : public ::cppu::WeakImplHelper2< ::pw3270::lib3270,lang::XServiceInfo > + { + + }; + } + + +#endif // PW3270_OXT_GLOBALS_HPP_INCLUDED diff --git a/src/oxt/loffice3270.cbp b/src/oxt/loffice3270.cbp new file mode 100644 index 0000000..f497258 --- /dev/null +++ b/src/oxt/loffice3270.cbp @@ -0,0 +1,51 @@ + + + + + + diff --git a/src/oxt/pw3270.idl b/src/oxt/pw3270.idl index c159120..6477959 100644 --- a/src/oxt/pw3270.idl +++ b/src/oxt/pw3270.idl @@ -45,7 +45,7 @@ module pw3270 string getVersion(); }; - service host + service session { interface lib3270; }; diff --git a/src/oxt/testprogram.cc b/src/oxt/testprogram.cc new file mode 100644 index 0000000..34abff2 --- /dev/null +++ b/src/oxt/testprogram.cc @@ -0,0 +1,135 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA, 02111-1307, USA + * + * Este programa está nomeado como testprogram.cc e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include "globals.hpp" + #include "pw3270/lib3270.hpp" + +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ + +using namespace com::sun::star::uno; + +int SAL_CALL main(int argc, char **argv) +{ + +/* + Reference< XSimpleRegistry > xReg = createSimpleRegistry(); + + OSL_ENSURE( xReg.is(), "### cannot get service instance of \"SimpleRegistry\"!" ); + + xReg->open(OUString::createFromAscii("pw3270.rdb"), sal_False, sal_False); + + OSL_ENSURE( xReg->isValid(), "### cannot open test registry \"pw3270.rdb\"!" ); + + + TRACE("%s","Calling bootstrap_InitialComponentContext"); + Reference< XComponentContext > xContext = bootstrap_InitialComponentContext(xReg); + OSL_ENSURE( xContext.is(), "### cannot creage intial component context!" ); + + TRACE("%s","Calling getServiceManager\n"); + Reference< XMultiComponentFactory > xMgr = xContext->getServiceManager(); + OSL_ENSURE( xMgr.is(), "### cannot get initial service manager!" ); + + // register my component + TRACE("%s","Calling createInstanceWithContext"); + + Reference< XImplementationRegistration > xImplReg( + xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration"), xContext), UNO_QUERY); + OSL_ENSURE( xImplReg.is(), "### cannot get service instance of \"com.sun.star.registry.ImplementationRegistration\"!" ); + + if (xImplReg.is()) + { + const char *libname = LIBNAME; + + TRACE("Loading %s",libname); + + xImplReg->registerImplementation( + OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), // loader for component + OUString::createFromAscii(libname), // component location + Reference< XSimpleRegistry >() // registry omitted, + // defaulting to service manager registry used + ); + + // get an object instance + printf("Calling createInstanceWithContext(%s)\n",IMPLNAME); + + Reference< XInterface > xx ; + xx = xMgr->createInstanceWithContext(OUString::createFromAscii(IMPLNAME), xContext); + + printf("Instance: %p\n",&xx); + + Reference< pw3270intf > srv( xx, UNO_QUERY ); + + OSL_ENSURE( srv.is(), "### cannot get service instance!"); + + printf("object.is(): %d\n",srv.is()); + + if(srv.is()) + { + // Wait for commands + OString str; + char buffer[80]; + printf("getConnectionState: %d\n", srv->getConnectionState()); + + str = OUStringToOString( srv->getVersion(),RTL_TEXTENCODING_UTF8); + printf("Version:\t%s\n",str.pData->buffer); + + str = OUStringToOString( srv->getRevision(),RTL_TEXTENCODING_UTF8); + printf("Revision:\t%s\n",str.pData->buffer); + + printf("Connect(): %d\n" , srv->Connect(OUString::createFromAscii("L:3270.df.bb:9023"),10)); + + sleep(5); + + //str = OUStringToOString( srv->getScreenContentAt(20,39,5),RTL_TEXTENCODING_UTF8); + //Trace("ContentsAt(20,39): \"%s\"",str.pData->buffer); + printf("waitForStringAt(SISBB) returned %d\n",srv->waitForStringAt(20,39,OUString::createFromAscii("SISBB"),20)); + printf("sendEnterKey() returned %d\n",srv->sendEnterKey()); + printf("waitForStringAt(Senha) returned %d\n",srv->waitForStringAt(14,2,OUString::createFromAscii("Senha"),20)); + printf("setStringAt returned %d\n",srv->setStringAt(13,21,OUString::createFromAscii("c1103788"))); + + str = OUStringToOString( srv->getScreenContent(),RTL_TEXTENCODING_UTF8); + printf("Entire screen:\n%s\n",str.pData->buffer); + + printf("Enter to exit...\n"); + fgets(buffer,80,stdin); + + printf("Disconnect(): %d\n" , srv->Disconnect()); + + sleep(5); + + } + } + + + Reference< XComponent >::query( xContext )->dispose(); + +*/ + + return 0; +} -- libgit2 0.21.2