diff --git a/src/classlib/local.cc b/src/classlib/local.cc index 9ec600e..2ebfa90 100644 --- a/src/classlib/local.cc +++ b/src/classlib/local.cc @@ -454,18 +454,18 @@ return 0; } - string * get_text_at(int row, int col, size_t sz) + string get_text_at(int row, int col, size_t sz) { + string rc; char * ptr = _get_text_at(hSession,row,col,sz); if(ptr) { - string *s = new string(ptr); + rc.assign(ptr); _free(ptr); - return s; } - return new string(""); + return rc; } int set_text_at(int row, int col, const char *str) @@ -478,18 +478,18 @@ return _cmp_text_at(hSession,row,col,text); } - string * get_text(int offset, size_t len) + string get_text(int offset, size_t len) { - char *ptr = _get_text(hSession,offset,len); + string rc; + char * ptr = _get_text(hSession,offset,len); if(ptr) { - string *s = new string(ptr); + rc.assign(ptr); _free(ptr); - return s; } - return new string(""); + return rc; } int set_cursor_position(int row, int col) @@ -561,9 +561,9 @@ return 0; } - string * get_display_charset(void) + string get_display_charset(void) { - return new string(_get_display_charset(hSession)); + return string(_get_display_charset(hSession)); } int set_host_charset(const char *charset) @@ -571,9 +571,9 @@ return _set_host_charset(hSession,charset); } - string * get_host_charset(void) + string get_host_charset(void) { - return new string(_get_host_charset(hSession)); + return string(_get_host_charset(hSession)); } int erase_eof(void) diff --git a/src/classlib/remote.cc b/src/classlib/remote.cc index 6914441..9eaa275 100644 --- a/src/classlib/remote.cc +++ b/src/classlib/remote.cc @@ -214,8 +214,10 @@ return reply; } - string * get_string(DBusMessage * msg) + string get_string(DBusMessage * msg) { + string rc; + if(msg) { DBusMessageIter iter; @@ -224,11 +226,10 @@ { if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING) { - string * rc; const char * str; dbus_message_iter_get_basic(&iter, &str); trace("Response: [%s]",str); - rc = new string(str); + rc.assign(str); dbus_message_unref(msg); return rc; } @@ -242,10 +243,10 @@ } - return NULL; + return rc; } - string * query_string(const char *method) + string query_string(const char *method) { return get_string(call(create_message(method))); } @@ -863,7 +864,7 @@ #endif } - string * get_text_at(int row, int col, size_t sz) + string get_text_at(int row, int col, size_t sz) { #if defined(WIN32) @@ -888,7 +889,7 @@ #else - return NULL; + return string(); #endif @@ -978,7 +979,7 @@ return ETIMEDOUT; } - string * get_text(int baddr, size_t len) + string get_text(int baddr, size_t len) { #if defined(WIN32) struct hllapi_packet_query_offset query = { HLLAPI_PACKET_GET_TEXT_AT_OFFSET, (unsigned short) baddr, (unsigned short) len }; @@ -999,7 +1000,7 @@ return get_string(call(msg)); #else throw exception("%s","IPC support is unavailable"); - return NULL; + return string(); #endif } @@ -1248,7 +1249,7 @@ #endif } - string * get_host_charset(void) + string get_host_charset(void) { #if defined(WIN32) @@ -1268,7 +1269,7 @@ #if defined(HAVE_DBUS) - string * get_clipboard(void) + string get_clipboard(void) { return query_string("getClipboard"); } @@ -1278,7 +1279,7 @@ return query_intval("setClipboard", DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID); } - string * get_display_charset(void) + string get_display_charset(void) { return query_string("getDisplayCharset"); } diff --git a/src/classlib/session.cc b/src/classlib/session.cc index 735907a..b8ca517 100644 --- a/src/classlib/session.cc +++ b/src/classlib/session.cc @@ -124,7 +124,7 @@ void session::set_display_charset(const char *remote, const char *local) { #ifdef HAVE_ICONV - string *display_charset = this->get_display_charset(); + string display_charset = this->get_display_charset(); if(this->conv2Local != (iconv_t) (-1)) iconv_close(this->conv2Local); @@ -133,7 +133,7 @@ iconv_close(this->conv2Host); if(!remote) - remote = display_charset->c_str(); + remote = display_charset.c_str(); if(strcmp(local,remote)) { @@ -146,14 +146,18 @@ conv2Local = conv2Host = (iconv_t)(-1); } - delete display_charset; #endif } - string * session::get_display_charset(void) + string session::get_display_charset(void) { - return new string("ISO-8859-1"); + return string(get_encoding()); + } + + const char * session::get_encoding(void) + { + return "ISO-8859-1"; } // 3270 methods @@ -209,13 +213,13 @@ return EINVAL; } - string * session::get_copy(void) + string session::get_copy(void) { errno = EINVAL; - return NULL; + return string(); } - string * session::get_clipboard(void) + string session::get_clipboard(void) { #if defined(WIN32) @@ -239,7 +243,7 @@ return NULL; } - string *text = new string ( pszText ); + string text = string ( pszText ); GlobalUnlock( hData ); @@ -294,69 +298,75 @@ return -1; } - string * session::file_chooser_dialog(int action, const char *title, const char *extension, const char *filename) + string session::file_chooser_dialog(int action, const char *title, const char *extension, const char *filename) { - return NULL; + return string(""); } - string * session::get_3270_text(string *str) + string session::get_3270_text(const char *str) { + string rc; + #ifdef HAVE_ICONV - if(str && conv2Host != (iconv_t)(-1)) + size_t in = strlen(str); + + if(in && conv2Host != (iconv_t)(-1)) { - size_t in = str->length(); size_t out = (in << 1); char * ptr; char * outBuffer = (char *) malloc(out); - ICONV_CONST char * inBuffer = (ICONV_CONST char *) str->c_str(); + ICONV_CONST char * inBuffer = (ICONV_CONST char *) str; memset(ptr=outBuffer,0,out); iconv(conv2Host,NULL,NULL,NULL,NULL); // Reset state if(iconv(conv2Host,&inBuffer,&in,&ptr,&out) != ((size_t) -1)) - str->assign(outBuffer); + rc.assign(outBuffer); free(outBuffer); } +#else + rc = str; #endif // HAVE_ICONV - return str; + return rc; } - string * session::get_local_text(string *str) + string session::get_local_text(const char *str) { + string rc; + #ifdef HAVE_ICONV - if(str && conv2Local != (iconv_t)(-1)) + size_t in = strlen(str); + + if(in && conv2Local != (iconv_t)(-1)) { - size_t in = str->length(); size_t out = (in << 1); char * ptr; char * outBuffer = (char *) malloc(out); - ICONV_CONST char * inBuffer = (ICONV_CONST char *) str->c_str(); + ICONV_CONST char * inBuffer = (ICONV_CONST char *) str; memset(ptr=outBuffer,0,out); iconv(conv2Local,NULL,NULL,NULL,NULL); // Reset state if(iconv(conv2Local,&inBuffer,&in,&ptr,&out) != ((size_t) -1)) - str->assign(outBuffer); + rc.assign(outBuffer); free(outBuffer); } +#else + rc = str; #endif // HAVE_ICONV - return str; + return rc; } - string * session::get_string_at(int row, int col, size_t sz) + string session::get_string_at(int row, int col, size_t sz) { - string *str = this->get_text_at(row,col,sz); - - if(str) - return this->get_local_text(str); - - return 0; + string str = this->get_text_at(row,col,sz); + return this->get_local_text(str.c_str()); } int session::set_string_at(int row, int col, const char *str) @@ -427,23 +437,17 @@ int session::cmp_string_at(int row, int col, const char *text) { - string * str = get_3270_text(new string(text)); - int rc = cmp_text_at(row,col,str->c_str()); - delete str; - return rc; + return cmp_text_at(row,col,get_3270_text(text).c_str()); } int session::wait_for_string_at(int row, int col, const char *key, int timeout) { - string * str = get_3270_text(new string(key)); - int rc = wait_for_text_at(row,col,str->c_str(),timeout); - delete str; - return rc; + return wait_for_text_at(row,col,get_3270_text(key).c_str(),timeout); } - string * session::get_string(int baddr, size_t len) + string session::get_string(int baddr, size_t len) { - return get_local_text(get_text(baddr,len)); + return get_local_text(get_text(baddr,len).c_str()); } string session::asc2ebc(string &str) diff --git a/src/classlib/testprogram.cc b/src/classlib/testprogram.cc index bfabcf3..a4e4867 100644 --- a/src/classlib/testprogram.cc +++ b/src/classlib/testprogram.cc @@ -40,7 +40,7 @@ { { - string *s; + string s; session *session = session::start("pw3270:a"); // session *session = session::start("new"); @@ -55,12 +55,10 @@ cout << "\tSession state: " << session->get_cstate() << endl; s = session->get_display_charset(); - cout << "\tDisplay charset: " << s->c_str() << endl; - delete s; + cout << "\tDisplay charset: " << s.c_str() << endl; s = session->get_host_charset(); - cout << "\tHost charset: " << s->c_str() << endl; - delete s; + cout << "\tHost charset: " << s.c_str() << endl; session->connect(false); delete session; diff --git a/src/include/pw3270/class.h b/src/include/pw3270/class.h index b68c9c1..d413961 100644 --- a/src/include/pw3270/class.h +++ b/src/include/pw3270/class.h @@ -130,8 +130,8 @@ #endif // WIN32 virtual int set_host_charset(const char *charset) = 0; - virtual string * get_host_charset(void) = 0; - virtual string * get_display_charset(void); + virtual string get_host_charset(void) = 0; + virtual string get_display_charset(void); // Connection & Network int connect(const char *host, bool wait = true); @@ -144,8 +144,8 @@ virtual int iterate(bool wait = true) = 0; // Get/Set/Test without charset translation - virtual string * get_text(int baddr, size_t len) = 0; - virtual string * get_text_at(int row, int col, size_t sz) = 0; + virtual string get_text(int baddr, size_t len) = 0; + virtual string get_text_at(int row, int col, size_t sz) = 0; virtual int set_text_at(int row, int col, const char *str) = 0; virtual int cmp_text_at(int row, int col, const char *text) = 0; virtual int wait_for_text_at(int row, int col, const char *key, int timeout); @@ -158,8 +158,8 @@ string ebc2asc(string &str); // Get/Set/Test with charset translation - string * get_string(int baddr, size_t len); - string * get_string_at(int row, int col, size_t sz); + string get_string(int baddr, size_t len); + string get_string_at(int row, int col, size_t sz); int set_string_at(int row, int col, const char *str); int cmp_string_at(int row, int col, const char *text); int wait_for_string_at(int row, int col, const char *key, int timeout); @@ -190,21 +190,23 @@ // Clipboard management virtual int set_copy(const char *text); - virtual string * get_copy(void); + virtual string get_copy(void); - virtual string * get_clipboard(void); + virtual string get_clipboard(void); virtual int set_clipboard(const char *text); // Dialogs virtual int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); - virtual string * file_chooser_dialog(int action, const char *title, const char *extension, const char *filename); + virtual string file_chooser_dialog(int action, const char *title, const char *extension, const char *filename); // File transfer virtual int file_transfer(LIB3270_FT_OPTION options, const char *local, const char *remote, int lrecl = 0, int blksize = 0, int primspace = 0, int secspace = 0, int dft = 4096); // Charset translation - string * get_3270_text(string *str); - string * get_local_text(string *str); + const char * get_encoding(void); + + string get_3270_text(const char *str); + string get_local_text(const char *str); protected: session(); diff --git a/src/loffice/Makefile.in b/src/loffice/Makefile.in new file mode 100644 index 0000000..4d95ccf --- /dev/null +++ b/src/loffice/Makefile.in @@ -0,0 +1,192 @@ +# +# "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 +# +# Contatos: +# +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) +# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) +# + +PACKAGE_NAME=@PACKAGE_NAME@ +SOURCES=info.cc get.cc set.cc service.cc init.cc connect.cc + +UNO_CLASSES= /com/sun/star/uno/XWeak \ + /com/sun/star/uno/RuntimeException \ + /com/sun/star/lang/WrappedTargetException + + +#---[ LibreOffice SDK ]-------------------------------------------------------- + +OO_SDK_HOME=@OO_SDK_HOME@ +OO_SDK_URE_HOME=@OO_SDK_URE_HOME@ + +UNO=@UNO@ +UNOPKG=@UNOPKG@ +IDLC=@IDLC@ +REGMERGE=@REGMERGE@ +CPPUMAKER=@CPPUMAKER@ +CONVERT=@CONVERT@ +ZIP=@ZIP@ + +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@ +MKDIR=@MKDIR_P@ + +#---[ Paths ]------------------------------------------------------------------ + +OBJDIR=.obj +BINDIR=.bin +RDBDIR=.rdb +URDDIR=.urd + +OBJDBG=$(OBJDIR)/Debug +BINDBG=$(BINDIR)/Debug + +OBJRLS=$(OBJDIR)/Release +BINRLS=$(BINDIR)/Release + +#---[ lib3270 common class ]--------------------------------------------------- + +DEBUG_CFLAGS=-DDEBUG=1 -g -Wall +PW3270_CFLAGS=-I../include +CLASSLIBDIR=../classlib +include $(CLASSLIBDIR)/class.mak + +#---[ Build options ]---------------------------------------------------------- + +CPPUENV="gcc3" +CXXFLAGS=@CXXFLAGS@ -fvisibility=hidden @DLL_CFLAGS@ -Wno-strict-aliasing -I../include -I./include -I$(includedir)/libreoffice -Wno-strict-aliasing -DCPPU_ENV=$(CPPUENV) -DLANGUAGE_BINDING_NAME=\"$(CPPUENV)\" + +OO_LDFLAGS=-L$(OO_SDK_HOME)/lib -L$(OO_SDK_URE_HOME)/lib \ + -Wl,-rpath-link=$(OO_SDK_URE_HOME)/lib,-rpath=$(OO_SDK_URE_HOME)/lib \ + -luno_cppu -luno_cppuhelpergcc3 -luno_salhelpergcc3 + +#---[ Rules ]------------------------------------------------------------------ + +$(URDDIR)/%.urd: %.idl + @echo " IDLC `basename $@`" + @$(MKDIR) `dirname $@` + @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< + +$(URDDIR)/%.urd: /usr/share/idl/libreoffice/%.idl + @echo " IDLC `basename $@`" + @$(MKDIR) `dirname $@` + @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< + +$(RDBDIR)/%.rdb: $(URDDIR)/%.urd + @echo " REGM `basename $@`" + @$(MKDIR) `dirname $@` + @$(REGMERGE) $@ /UCR $< + +include/%.hpp: $(RDBDIR)/%.rdb + @echo " CPPU `basename $@`" + @$(MKDIR) `dirname $@` + @$(CPPUMAKER) -O./include $(TYPES_RDB) $< + +$(OBJDBG)/%.o: %.cc include/$(PACKAGE_NAME)/lib3270.hpp \ + $(foreach CLS, $(UNO_CLASSES), include/$(CLS).hpp) \ + *.hpp Makefile + @echo " CC `basename $@`" + @mkdir -p `dirname $@` + @$(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ -c $< +# $(DBG_CFLAGS) $(CXXFLAGS) $(LIB3270_CFLAGS) -DLIBNAME=\"$(BINDBG)/$(PROGRAM_NAME).uno@DLLEXT@\" -o $@ -c $< + +#---[ UNO targets ]------------------------------------------------------------ + +include/$(PACKAGE_NAME)/lib3270.hpp: $(RDBDIR)/$(PACKAGE_NAME).rdb + @echo " CPPU `basename $@`" + @$(MKDIR) `dirname $@` + @$(CPPUMAKER) -O./include -T$(PACKAGE_NAME).lib3270 $(TYPES_RDB) $< + + +#---[ Debug targets ]---------------------------------------------------------- + +Debug: $(BINDBG)/$(PACKAGE_NAME).oxt + +run: $(BINDBG)/$(PACKAGE_NAME).oxt + @SHARED=false $(UNOPKG) add --verbose --force $(BINDBG)/$(PACKAGE_NAME).oxt + @libreoffice testmacros.odt + @SHARED=false $(UNOPKG) remove $(PACKAGE_NAME) + +add: $(BINDBG)/$(PACKAGE_NAME).oxt + @SHARED=false $(UNOPKG) add --verbose --force $(BINDBG)/$(PACKAGE_NAME).oxt + +$(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@: \ + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) \ + $(CLASS_DEBUG_OBJECTS) + @echo " LD `basename $@`" + @$(MKDIR) `dirname $@` + $(CXX) -shared $(LDFLAGS) $(OO_LDFLAGS) $(CLASS_LIBS) -o $@ $^ + + +$(BINDBG)/$(PACKAGE_NAME).oxt: \ + $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ \ + $(RDBDIR)/$(PACKAGE_NAME).rdb \ + description.xml \ + manifest.xml \ + description.txt + @rm -f $@ + @$(MKDIR) `dirname $@` + + @$(MKDIR) $(BINDBG)/$(PACKAGE).oxt.tmp + + @cp $(RDBDIR)/$(PACKAGE_NAME).rdb $(BINDBG)/$(PACKAGE).oxt.tmp + @cp $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ $(BINDBG)/$(PACKAGE).oxt.tmp + + @$(MKDIR) $(BINDBG)/$(PACKAGE).oxt.tmp/META-INF + @cp manifest.xml $(BINDBG)/$(PACKAGE).oxt.tmp/META-INF + + @cp description.xml $(BINDBG)/$(PACKAGE).oxt.tmp + @cp description.txt $(BINDBG)/$(PACKAGE).oxt.tmp + + @$(CONVERT) ../$(PACKAGE_NAME)/pixmaps/$(PACKAGE_NAME).svg --format=png > $(BINDBG)/$(PACKAGE).oxt.tmp/$(PACKAGE_NAME).png + + @cp $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ $(BINDBG)/$(PACKAGE_NAME).oxt.tmp + @cd $(BINDBG)/$(PACKAGE).oxt.tmp ; $(ZIP) -r -m ../$(PACKAGE_NAME).oxt . + @rm -fr $(BINDBG)/$(PACKAGE).oxt.tmp + @echo $@ Ok. + + +#---[ Misc targets ]----------------------------------------------------------- + +cleanDebug: clean + +clean: + @rm -f *.urd + @rm -fr $(RDBDIR) + @rm -fr $(URDDIR) + @rm -fr include + @rm -f *.rdb + @rm -fr $(OBJDIR) + @rm -fr $(BINDIR) + + diff --git a/src/loffice/connect.cc b/src/loffice/connect.cc new file mode 100644 index 0000000..e7393dc --- /dev/null +++ b/src/loffice/connect.cc @@ -0,0 +1,145 @@ +/* + * "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 connect.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" + #include + #include + +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ + + using namespace pw3270_impl; + + ::sal_Int16 SAL_CALL session_impl::Connect() throw (::com::sun::star::uno::RuntimeException) + { + trace("%s: hSession=%p",__FUNCTION__,hSession); + + try + { + if(!hSession) + hSession = h3270::session::get_default(); + + return hSession->connect(false); + + } catch(std::exception &e) + { + trace("%s failed: %s",__FUNCTION__,e.what()); + + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + + } + + return -1; + + + } + + ::sal_Int16 SAL_CALL session_impl::Disconnect() throw (::com::sun::star::uno::RuntimeException) + { + try + { + CHECK_SESSION_HANDLE + + return hSession->disconnect(); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + + } + + return -1; + + } + + ::sal_Bool SAL_CALL session_impl::isConnected() throw (::com::sun::star::uno::RuntimeException) + { + try + { + CHECK_SESSION_HANDLE + + return hSession->is_connected(); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + + } + + return -1; + } + + ::sal_Bool SAL_CALL session_impl::isReady() throw (::com::sun::star::uno::RuntimeException) + { + try + { + CHECK_SESSION_HANDLE + + return hSession->is_ready(); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + + } + + return -1; + + } + + ::sal_Int16 SAL_CALL session_impl::waitForReady( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException) + { + try + { + CHECK_SESSION_HANDLE + + return hSession->wait_for_ready(seconds); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + + } + + return -1; + + } + + diff --git a/src/loffice/description.txt b/src/loffice/description.txt new file mode 100644 index 0000000..a163cab --- /dev/null +++ b/src/loffice/description.txt @@ -0,0 +1,2 @@ +Uno/OpenOffice library allowing 3270 access from StarBasic + diff --git a/src/loffice/description.xml.in b/src/loffice/description.xml.in new file mode 100644 index 0000000..327d444 --- /dev/null +++ b/src/loffice/description.xml.in @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 3270 access extension + + + + + + + + + + + + + diff --git a/src/loffice/get.cc b/src/loffice/get.cc new file mode 100644 index 0000000..8d0ef40 --- /dev/null +++ b/src/loffice/get.cc @@ -0,0 +1,88 @@ +/* + * "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 get.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) + * + * Referência: + * + * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes + * + */ + + #include "globals.hpp" + #include + #include "pw3270/lib3270.hpp" + +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ + + using namespace pw3270_impl; + + ::rtl::OUString session_impl::getVersion() throw (RuntimeException) + { + trace("%s: hSession=%p",__FUNCTION__,hSession); + return OUString( RTL_CONSTASCII_USTRINGPARAM(PACKAGE_VERSION) ); + } + + ::rtl::OUString session_impl::getRevision() throw (RuntimeException) + { + trace("%s: hSession=%p",__FUNCTION__,hSession); + return OUString( RTL_CONSTASCII_USTRINGPARAM(PACKAGE_REVISION) ); + } + + ::rtl::OUString SAL_CALL session_impl::getTextAt( ::sal_Int16 row, ::sal_Int16 col, ::sal_Int16 size ) throw (::com::sun::star::uno::RuntimeException) + { + string s; + + try + { + CHECK_SESSION_HANDLE + s = hSession->get_text_at(row,col,size); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + } + + return OUString(s.c_str(), s.length(), encoding, RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + } + + ::sal_Int16 SAL_CALL session_impl::waitForTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& str, ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException) + { + try + { + CHECK_SESSION_HANDLE + OString vlr = rtl::OUStringToOString(str,encoding); + return hSession->wait_for_text_at(row,col,vlr.getStr(),seconds); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + } + + return -1; + + } diff --git a/src/loffice/globals.hpp b/src/loffice/globals.hpp new file mode 100644 index 0000000..dcc7bfb --- /dev/null +++ b/src/loffice/globals.hpp @@ -0,0 +1,143 @@ +/* + * "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) + * + * Referências: + * + * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/C%2B%2B_Component + * + * + */ + +#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 + #define HAVE_GCC_VISIBILITY_FEATURE 1 + #endif + + + #include // "3" implementing three interfaces + #include + #include +// #include + #include + +#ifdef DEBUG + #include +#endif // DEBUG + + #include + + #ifdef DEBUG + #include + #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); + #else + #define trace(x, ...) // __VA_ARGS__ + #endif + + #include + #include + + #define DLL_PUBLIC __attribute__((visibility("default"))) + + #define CHECK_SESSION_HANDLE if(!hSession) hSession = h3270::session::get_default(); + + + using namespace ::rtl; // for OUString + using namespace ::com::sun::star; // for sdk interfaces + using namespace ::com::sun::star::lang; // for sdk interfaces + using namespace ::com::sun::star::uno; // for basic types + using namespace PW3270_NAMESPACE; + + namespace pw3270_impl + { + // https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes + class DLL_PUBLIC session_impl : public ::cppu::WeakImplHelper4< ::pw3270::lib3270, XServiceInfo, XMain, XInitialization > + { + public: + + session_impl(); + virtual ~session_impl(); + + // XMain + virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (Exception); + + // XInitialization will be called upon createInstanceWithArguments[AndContext]() + virtual void SAL_CALL initialize( Sequence< Any > const & args ) throw (Exception); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() throw (RuntimeException); + virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName ) throw (RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException); + + // lib3270 + virtual ::rtl::OUString SAL_CALL getVersion() throw (RuntimeException); + virtual ::rtl::OUString SAL_CALL getRevision() throw (RuntimeException); + virtual ::sal_Int16 SAL_CALL iterate( ::sal_Bool wait ) throw (::com::sun::star::uno::RuntimeException); + + virtual ::sal_Int16 SAL_CALL setSessionName( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException); + + virtual ::sal_Int16 SAL_CALL setHost( const ::rtl::OUString& url ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL Connect() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL Disconnect() throw (::com::sun::star::uno::RuntimeException); + + // State + virtual ::sal_Bool SAL_CALL isConnected() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isReady() throw (::com::sun::star::uno::RuntimeException); + + // Screen contents + virtual ::rtl::OUString SAL_CALL getTextAt( ::sal_Int16 row, ::sal_Int16 col, ::sal_Int16 size ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL setTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& str ) throw (::com::sun::star::uno::RuntimeException); + + // Wait + virtual ::sal_Int16 SAL_CALL waitForReady( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL waitForTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& str, ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException); + + + + private: + h3270::session * hSession; + rtl_TextEncoding encoding; + + }; + + extern Sequence< OUString > SAL_CALL getSupportedServiceNames_session_impl(); + extern OUString SAL_CALL getImplementationName_session_impl(); + extern Reference< XInterface > SAL_CALL create_session_impl(Reference< XComponentContext > const & xContext ) SAL_THROW( () ); + + }; + + +#endif // PW3270_OXT_GLOBALS_HPP_INCLUDED diff --git a/src/loffice/info.cc b/src/loffice/info.cc new file mode 100644 index 0000000..b47503c --- /dev/null +++ b/src/loffice/info.cc @@ -0,0 +1,58 @@ +/* + * "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 info.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) + * + * Referência: + * + * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes + * + */ + + #include "globals.hpp" + #include "pw3270/lib3270.hpp" + +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ + +using namespace pw3270_impl; + +// XServiceInfo implementation +OUString session_impl::getImplementationName() throw (RuntimeException) +{ + // unique implementation name + return OUString( RTL_CONSTASCII_USTRINGPARAM("pw3270.pw3270_impl.session") ); +} + +sal_Bool session_impl::supportsService( OUString const & serviceName ) throw (RuntimeException) +{ + // this object only supports one service, so the test is simple + return serviceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("pw3270.session") ); +} + +Sequence< OUString > session_impl::getSupportedServiceNames() throw (RuntimeException) +{ + return getSupportedServiceNames_session_impl(); +} + diff --git a/src/loffice/init.cc b/src/loffice/init.cc new file mode 100644 index 0000000..2d19f8d --- /dev/null +++ b/src/loffice/init.cc @@ -0,0 +1,95 @@ +/* + * "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 init.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) + * + * Referência: + * + * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Create_Instance_with_Arguments + * + */ + + #include "globals.hpp" + #include + #include "pw3270/lib3270.hpp" + +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ + +using namespace pw3270_impl; + + +session_impl::session_impl() +{ + this->hSession = NULL; + this->encoding = RTL_TEXTENCODING_ISO_8859_1; +} + +session_impl::~session_impl() +{ + if(this->hSession) + delete this->hSession; +} + + +// XInitialization implementation +void session_impl::initialize( Sequence< Any > const & args ) throw (Exception) +{ + if (1 != args.getLength()) + { + throw lang::IllegalArgumentException( + OUString( RTL_CONSTASCII_USTRINGPARAM("give a string instanciating this component!") ), + (::cppu::OWeakObject *)this, + 0 ); + } + + // Initialize + + // TODO: Get arguments. + + +} + +// XMain +::sal_Int32 SAL_CALL session_impl::run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (Exception) +{ + + + return 0; +} + +::sal_Int16 SAL_CALL session_impl::iterate( ::sal_Bool wait ) throw (::com::sun::star::uno::RuntimeException) +{ + try + { + CHECK_SESSION_HANDLE + return hSession->iterate(wait); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + } + return -1; +} diff --git a/src/loffice/loffice3270.cbp b/src/loffice/loffice3270.cbp new file mode 100644 index 0000000..3d11352 --- /dev/null +++ b/src/loffice/loffice3270.cbp @@ -0,0 +1,64 @@ + + + + + + diff --git a/src/loffice/manifest.xml.in b/src/loffice/manifest.xml.in new file mode 100644 index 0000000..8908827 --- /dev/null +++ b/src/loffice/manifest.xml.in @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/loffice/pw3270.idl b/src/loffice/pw3270.idl new file mode 100644 index 0000000..ad21cf6 --- /dev/null +++ b/src/loffice/pw3270.idl @@ -0,0 +1,79 @@ +/* + * "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., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como pw3270.idl e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + * Referências: + * + * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C++/C++_Component + * + */ + +#include +#include +#include + +module pw3270 +{ + /* + * Interface to lib3270 + */ + interface lib3270 : com::sun::star::uno::XInterface + { + // Constants + string getVersion(); + string getRevision(); + + // Host definition + short setHost([in] string url); + short Connect(); + short Disconnect(); + short iterate([in] boolean wait); + + // Screen contents + string getTextAt([in] short row, [in] short col, [in] short size); + short setTextAt([in] short row, [in] short col, [in] string str); + short waitForTextAt([in] short row, [in] short col, [in] string str, [in] short seconds); + + // Misc Settings + short setSessionName([in] string name); + + // State + boolean isConnected(); + boolean isReady(); + + // Waiting + short waitForReady([in] short seconds); + + }; + + service session + { + interface lib3270; + interface com::sun::star::lang::XInitialization; + interface com::sun::star::lang::XMain; + }; +}; + diff --git a/src/loffice/research.sh b/src/loffice/research.sh new file mode 100755 index 0000000..4bb9ad0 --- /dev/null +++ b/src/loffice/research.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +OO_SDK_HOME=/usr/lib64/libreoffice/sdk +IDLC=/usr/lib64/libreoffice/sdk/bin/idlc +CPPUMAKER=/usr/lib64/libreoffice/sdk/bin/cppumaker +TYPES_RDB=/usr/lib64/libreoffice/ure/share/misc/types.rdb +REGMERGE=/usr/lib64/libreoffice/ure/bin/regmerge + +$IDLC -C -I$OO_SDK_HOME/idl -O. pw3270.idl +if [ "$?" != "0" ]; then + exit -1 +fi + + +$REGMERGE pw3270.rdb /UCR pw3270.urd +if [ "$?" != "0" ]; then + exit -1 +fi + + +$CPPUMAKER -O./include -Tpw3270.lib3270 $TYPES_RDB pw3270.rdb +if [ "$?" != "0" ]; then + exit -1 +fi + +# XWeak +$IDLC -C -I$OO_SDK_HOME/idl -O. /usr/share/idl/libreoffice/com/sun/star/uno/XWeak.idl +if [ "$?" != "0" ]; then + exit -1 +fi + +$REGMERGE XWeak.rdb /UCR XWeak.urd +if [ "$?" != "0" ]; then + exit -1 +fi + +$CPPUMAKER -O./include $TYPES_RDB XWeak.rdb +if [ "$?" != "0" ]; then + exit -1 +fi + + +echo ok + diff --git a/src/loffice/service.cc b/src/loffice/service.cc new file mode 100644 index 0000000..275fbd5 --- /dev/null +++ b/src/loffice/service.cc @@ -0,0 +1,98 @@ +/* + * "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 info.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) + * + * Referência: + * + * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Providing_a_Single_Factory_Using_a_Helper_Method + * + */ + + #include "globals.hpp" + #include + #include "pw3270/lib3270.hpp" + +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ + +namespace pw3270_impl +{ + Sequence< OUString > SAL_CALL getSupportedServiceNames_session_impl() + { + Sequence names(1); + names[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("pw3270.session")); + return names; + } + + OUString SAL_CALL getImplementationName_session_impl() + { + return OUString( RTL_CONSTASCII_USTRINGPARAM("pw3270.lib3270.session") ); + } + + Reference< XInterface > SAL_CALL create_session_impl(Reference< XComponentContext > const & xContext ) SAL_THROW( () ) + { + return static_cast< lang::XTypeProvider * >( new session_impl() ); + } + + static struct ::cppu::ImplementationEntry s_component_entries [] = + { + { + create_session_impl, + getImplementationName_session_impl, + getSupportedServiceNames_session_impl, + ::cppu::createSingleComponentFactory, + 0, + 0 + }, + { + 0, + 0, + 0, + 0, + 0, + 0 + } + }; + +} + +extern "C" +{ + DLL_PUBLIC void * SAL_CALL component_getFactory(sal_Char const * implName, lang::XMultiServiceFactory * xMgr,registry::XRegistryKey * xRegistry ) + { + return ::cppu::component_getFactoryHelper(implName, xMgr, xRegistry, ::pw3270_impl::s_component_entries ); + } + + DLL_PUBLIC sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry ) + { + return ::cppu::component_writeInfoHelper(xMgr, xRegistry, ::pw3270_impl::s_component_entries ); + } + + DLL_PUBLIC void SAL_CALL component_getImplementationEnvironment(sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv ) + { + * ppEnvTypeName = LANGUAGE_BINDING_NAME; + } + +} diff --git a/src/loffice/set.cc b/src/loffice/set.cc new file mode 100644 index 0000000..b737d1c --- /dev/null +++ b/src/loffice/set.cc @@ -0,0 +1,143 @@ +/* + * "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 get.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) + * + * Referência: + * + * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes + * + */ + + #include "globals.hpp" + #include + #include + #include + #include "pw3270/lib3270.hpp" + +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ + + using namespace pw3270_impl; + using namespace com::sun::star::uno; + + ::sal_Int16 SAL_CALL session_impl::setSessionName( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException) + { + if(hSession) + { + // Remove old session + delete hSession; + hSession = NULL; + } + + OString vlr = rtl::OUStringToOString( name , RTL_TEXTENCODING_UNICODE ); + + trace("%s(\"%s\")",__FUNCTION__,vlr.getStr()); + + try + { + string charset; + + hSession = h3270::session::create(((const char *) vlr.getStr())); + + trace("%s: hSession(\"%s\"=%p",__FUNCTION__,vlr.getStr(),hSession); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + + return -1; + + } + + string charset = hSession->get_display_charset(); + + trace("Charset=\"%s\"",charset.c_str()); + + if(!charset.compare("ISO-8859-1")) + { + encoding = RTL_TEXTENCODING_ISO_8859_1; + } + else if(!charset.compare("UTF-8")) + { + encoding = RTL_TEXTENCODING_UTF8; + } + else + { + string s = "Unable to convert the host's display charset " + charset + "."; + + throw lang::IllegalArgumentException( + OUString( RTL_CONSTASCII_USTRINGPARAM(s.c_str()) ), + (::cppu::OWeakObject *)this, + 0 ); + + } + + return 0; + + } + + ::sal_Int16 SAL_CALL session_impl::setHost( const ::rtl::OUString& url ) throw (::com::sun::star::uno::RuntimeException) + { + if(!hSession) + hSession = h3270::session::get_default(); + + OString vlr = rtl::OUStringToOString( url , RTL_TEXTENCODING_UNICODE ); + + try + { + + return hSession->set_url(vlr.getStr()); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + + } + + return -1; + } + + ::sal_Int16 SAL_CALL session_impl::setTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& str ) throw (::com::sun::star::uno::RuntimeException) + { + try + { + CHECK_SESSION_HANDLE + OString vlr = rtl::OUStringToOString(str,encoding); + return hSession->set_text_at(row,col,vlr.getStr()); + + } catch(std::exception &e) + { + OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); + throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); + } + + return -1; + + } + diff --git a/src/loffice/testmacros.odt b/src/loffice/testmacros.odt new file mode 100644 index 0000000..754ee72 Binary files /dev/null and b/src/loffice/testmacros.odt differ diff --git a/src/loffice/testprogram.cc b/src/loffice/testprogram.cc new file mode 100644 index 0000000..6885e1d --- /dev/null +++ b/src/loffice/testprogram.cc @@ -0,0 +1,148 @@ +/* + * "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 + #include + #include + + #include "pw3270/lib3270.hpp" + +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ + +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::bridge; +using namespace rtl; +using namespace cppu; + +int SAL_CALL main(int argc, char **argv) +{ + Reference< XComponentContext > rComponentContext = defaultBootstrap_InitialComponentContext(); + OSL_ENSURE( xContext.is(), "### cannot creage intial component context!" ); + +/* + Reference< XSimpleRegistry > xReg = DefaultRegistry(); + + 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; +} diff --git a/src/openoffice/Makefile.in b/src/openoffice/Makefile.in deleted file mode 100644 index 4d95ccf..0000000 --- a/src/openoffice/Makefile.in +++ /dev/null @@ -1,192 +0,0 @@ -# -# "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 -# -# Contatos: -# -# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) -# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) -# - -PACKAGE_NAME=@PACKAGE_NAME@ -SOURCES=info.cc get.cc set.cc service.cc init.cc connect.cc - -UNO_CLASSES= /com/sun/star/uno/XWeak \ - /com/sun/star/uno/RuntimeException \ - /com/sun/star/lang/WrappedTargetException - - -#---[ LibreOffice SDK ]-------------------------------------------------------- - -OO_SDK_HOME=@OO_SDK_HOME@ -OO_SDK_URE_HOME=@OO_SDK_URE_HOME@ - -UNO=@UNO@ -UNOPKG=@UNOPKG@ -IDLC=@IDLC@ -REGMERGE=@REGMERGE@ -CPPUMAKER=@CPPUMAKER@ -CONVERT=@CONVERT@ -ZIP=@ZIP@ - -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@ -MKDIR=@MKDIR_P@ - -#---[ Paths ]------------------------------------------------------------------ - -OBJDIR=.obj -BINDIR=.bin -RDBDIR=.rdb -URDDIR=.urd - -OBJDBG=$(OBJDIR)/Debug -BINDBG=$(BINDIR)/Debug - -OBJRLS=$(OBJDIR)/Release -BINRLS=$(BINDIR)/Release - -#---[ lib3270 common class ]--------------------------------------------------- - -DEBUG_CFLAGS=-DDEBUG=1 -g -Wall -PW3270_CFLAGS=-I../include -CLASSLIBDIR=../classlib -include $(CLASSLIBDIR)/class.mak - -#---[ Build options ]---------------------------------------------------------- - -CPPUENV="gcc3" -CXXFLAGS=@CXXFLAGS@ -fvisibility=hidden @DLL_CFLAGS@ -Wno-strict-aliasing -I../include -I./include -I$(includedir)/libreoffice -Wno-strict-aliasing -DCPPU_ENV=$(CPPUENV) -DLANGUAGE_BINDING_NAME=\"$(CPPUENV)\" - -OO_LDFLAGS=-L$(OO_SDK_HOME)/lib -L$(OO_SDK_URE_HOME)/lib \ - -Wl,-rpath-link=$(OO_SDK_URE_HOME)/lib,-rpath=$(OO_SDK_URE_HOME)/lib \ - -luno_cppu -luno_cppuhelpergcc3 -luno_salhelpergcc3 - -#---[ Rules ]------------------------------------------------------------------ - -$(URDDIR)/%.urd: %.idl - @echo " IDLC `basename $@`" - @$(MKDIR) `dirname $@` - @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< - -$(URDDIR)/%.urd: /usr/share/idl/libreoffice/%.idl - @echo " IDLC `basename $@`" - @$(MKDIR) `dirname $@` - @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< - -$(RDBDIR)/%.rdb: $(URDDIR)/%.urd - @echo " REGM `basename $@`" - @$(MKDIR) `dirname $@` - @$(REGMERGE) $@ /UCR $< - -include/%.hpp: $(RDBDIR)/%.rdb - @echo " CPPU `basename $@`" - @$(MKDIR) `dirname $@` - @$(CPPUMAKER) -O./include $(TYPES_RDB) $< - -$(OBJDBG)/%.o: %.cc include/$(PACKAGE_NAME)/lib3270.hpp \ - $(foreach CLS, $(UNO_CLASSES), include/$(CLS).hpp) \ - *.hpp Makefile - @echo " CC `basename $@`" - @mkdir -p `dirname $@` - @$(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ -c $< -# $(DBG_CFLAGS) $(CXXFLAGS) $(LIB3270_CFLAGS) -DLIBNAME=\"$(BINDBG)/$(PROGRAM_NAME).uno@DLLEXT@\" -o $@ -c $< - -#---[ UNO targets ]------------------------------------------------------------ - -include/$(PACKAGE_NAME)/lib3270.hpp: $(RDBDIR)/$(PACKAGE_NAME).rdb - @echo " CPPU `basename $@`" - @$(MKDIR) `dirname $@` - @$(CPPUMAKER) -O./include -T$(PACKAGE_NAME).lib3270 $(TYPES_RDB) $< - - -#---[ Debug targets ]---------------------------------------------------------- - -Debug: $(BINDBG)/$(PACKAGE_NAME).oxt - -run: $(BINDBG)/$(PACKAGE_NAME).oxt - @SHARED=false $(UNOPKG) add --verbose --force $(BINDBG)/$(PACKAGE_NAME).oxt - @libreoffice testmacros.odt - @SHARED=false $(UNOPKG) remove $(PACKAGE_NAME) - -add: $(BINDBG)/$(PACKAGE_NAME).oxt - @SHARED=false $(UNOPKG) add --verbose --force $(BINDBG)/$(PACKAGE_NAME).oxt - -$(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@: \ - $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) \ - $(CLASS_DEBUG_OBJECTS) - @echo " LD `basename $@`" - @$(MKDIR) `dirname $@` - $(CXX) -shared $(LDFLAGS) $(OO_LDFLAGS) $(CLASS_LIBS) -o $@ $^ - - -$(BINDBG)/$(PACKAGE_NAME).oxt: \ - $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ \ - $(RDBDIR)/$(PACKAGE_NAME).rdb \ - description.xml \ - manifest.xml \ - description.txt - @rm -f $@ - @$(MKDIR) `dirname $@` - - @$(MKDIR) $(BINDBG)/$(PACKAGE).oxt.tmp - - @cp $(RDBDIR)/$(PACKAGE_NAME).rdb $(BINDBG)/$(PACKAGE).oxt.tmp - @cp $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ $(BINDBG)/$(PACKAGE).oxt.tmp - - @$(MKDIR) $(BINDBG)/$(PACKAGE).oxt.tmp/META-INF - @cp manifest.xml $(BINDBG)/$(PACKAGE).oxt.tmp/META-INF - - @cp description.xml $(BINDBG)/$(PACKAGE).oxt.tmp - @cp description.txt $(BINDBG)/$(PACKAGE).oxt.tmp - - @$(CONVERT) ../$(PACKAGE_NAME)/pixmaps/$(PACKAGE_NAME).svg --format=png > $(BINDBG)/$(PACKAGE).oxt.tmp/$(PACKAGE_NAME).png - - @cp $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ $(BINDBG)/$(PACKAGE_NAME).oxt.tmp - @cd $(BINDBG)/$(PACKAGE).oxt.tmp ; $(ZIP) -r -m ../$(PACKAGE_NAME).oxt . - @rm -fr $(BINDBG)/$(PACKAGE).oxt.tmp - @echo $@ Ok. - - -#---[ Misc targets ]----------------------------------------------------------- - -cleanDebug: clean - -clean: - @rm -f *.urd - @rm -fr $(RDBDIR) - @rm -fr $(URDDIR) - @rm -fr include - @rm -f *.rdb - @rm -fr $(OBJDIR) - @rm -fr $(BINDIR) - - diff --git a/src/openoffice/connect.cc b/src/openoffice/connect.cc deleted file mode 100644 index c21ca21..0000000 --- a/src/openoffice/connect.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* - * "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 connect.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" - #include - #include - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - - using namespace pw3270_impl; - - ::sal_Int16 SAL_CALL session_impl::Connect() throw (::com::sun::star::uno::RuntimeException) - { - trace("%s: hSession=%p",__FUNCTION__,hSession); - - try - { - if(!hSession) - hSession = h3270::session::get_default(); - - return hSession->connect(false); - - } catch(std::exception &e) - { - trace("%s failed: %s",__FUNCTION__,e.what()); - - OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); - - throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); - - } - - return -1; - - - } - - ::sal_Int16 SAL_CALL session_impl::Disconnect() throw (::com::sun::star::uno::RuntimeException) - { - try - { - if(!hSession) - hSession = h3270::session::get_default(); - - return hSession->disconnect(); - - } catch(std::exception &e) - { - OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); - - throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); - - } - - return -1; - - } - - diff --git a/src/openoffice/description.txt b/src/openoffice/description.txt deleted file mode 100644 index a163cab..0000000 --- a/src/openoffice/description.txt +++ /dev/null @@ -1,2 +0,0 @@ -Uno/OpenOffice library allowing 3270 access from StarBasic - diff --git a/src/openoffice/description.xml.in b/src/openoffice/description.xml.in deleted file mode 100644 index 327d444..0000000 --- a/src/openoffice/description.xml.in +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - 3270 access extension - - - - - - - - - - - - - diff --git a/src/openoffice/get.cc b/src/openoffice/get.cc deleted file mode 100644 index a1e9d68..0000000 --- a/src/openoffice/get.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* - * "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 get.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) - * - * Referência: - * - * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes - * - */ - - #include "globals.hpp" - #include - #include "pw3270/lib3270.hpp" - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - - using namespace pw3270_impl; - - ::rtl::OUString session_impl::getVersion() throw (RuntimeException) - { - trace("%s: hSession=%p",__FUNCTION__,hSession); - return OUString( RTL_CONSTASCII_USTRINGPARAM(PACKAGE_VERSION) ); - } - - ::rtl::OUString session_impl::getRevision() throw (RuntimeException) - { - trace("%s: hSession=%p",__FUNCTION__,hSession); - return OUString( RTL_CONSTASCII_USTRINGPARAM(PACKAGE_REVISION) ); - } diff --git a/src/openoffice/globals.hpp b/src/openoffice/globals.hpp deleted file mode 100644 index 239b642..0000000 --- a/src/openoffice/globals.hpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * "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) - * - * Referências: - * - * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/C%2B%2B_Component - * - * - */ - -#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 - #define HAVE_GCC_VISIBILITY_FEATURE 1 - #endif - - - #include // "3" implementing three interfaces - #include - #include -// #include - #include - -#ifdef DEBUG - #include -#endif // DEBUG - - #include - - #ifdef DEBUG - #include - #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); - #else - #define trace(x, ...) // __VA_ARGS__ - #endif - - #include - #include - - #define DLL_PUBLIC __attribute__((visibility("default"))) - - using namespace ::rtl; // for OUString - using namespace ::com::sun::star; // for sdk interfaces - using namespace ::com::sun::star::lang; // for sdk interfaces - using namespace ::com::sun::star::uno; // for basic types - using namespace PW3270_NAMESPACE; - - namespace pw3270_impl - { - // https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes - class DLL_PUBLIC session_impl : public ::cppu::WeakImplHelper4< ::pw3270::lib3270, XServiceInfo, XMain, XInitialization > - { - public: - - session_impl(); - virtual ~session_impl(); - - // XMain - virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (Exception); - - // XInitialization will be called upon createInstanceWithArguments[AndContext]() - virtual void SAL_CALL initialize( Sequence< Any > const & args ) throw (Exception); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw (RuntimeException); - virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName ) throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException); - - // lib3270 - virtual ::rtl::OUString SAL_CALL getVersion() throw (RuntimeException); - virtual ::rtl::OUString SAL_CALL getRevision() throw (RuntimeException); - - virtual ::sal_Int16 SAL_CALL setSessionName( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException); - - virtual ::sal_Int16 SAL_CALL setHost( const ::rtl::OUString& url ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL Connect() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL Disconnect() throw (::com::sun::star::uno::RuntimeException); - - private: - h3270::session *hSession; - - }; - - extern Sequence< OUString > SAL_CALL getSupportedServiceNames_session_impl(); - extern OUString SAL_CALL getImplementationName_session_impl(); - extern Reference< XInterface > SAL_CALL create_session_impl(Reference< XComponentContext > const & xContext ) SAL_THROW( () ); - - }; - - -#endif // PW3270_OXT_GLOBALS_HPP_INCLUDED diff --git a/src/openoffice/info.cc b/src/openoffice/info.cc deleted file mode 100644 index b47503c..0000000 --- a/src/openoffice/info.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * "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 info.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) - * - * Referência: - * - * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes - * - */ - - #include "globals.hpp" - #include "pw3270/lib3270.hpp" - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -using namespace pw3270_impl; - -// XServiceInfo implementation -OUString session_impl::getImplementationName() throw (RuntimeException) -{ - // unique implementation name - return OUString( RTL_CONSTASCII_USTRINGPARAM("pw3270.pw3270_impl.session") ); -} - -sal_Bool session_impl::supportsService( OUString const & serviceName ) throw (RuntimeException) -{ - // this object only supports one service, so the test is simple - return serviceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("pw3270.session") ); -} - -Sequence< OUString > session_impl::getSupportedServiceNames() throw (RuntimeException) -{ - return getSupportedServiceNames_session_impl(); -} - diff --git a/src/openoffice/init.cc b/src/openoffice/init.cc deleted file mode 100644 index 2f075a8..0000000 --- a/src/openoffice/init.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - * "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 init.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) - * - * Referência: - * - * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Create_Instance_with_Arguments - * - */ - - #include "globals.hpp" - #include - #include "pw3270/lib3270.hpp" - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -using namespace pw3270_impl; - - -session_impl::session_impl() -{ - this->hSession = NULL; -} - -session_impl::~session_impl() -{ - if(this->hSession) - delete this->hSession; -} - - -// XInitialization implementation -void session_impl::initialize( Sequence< Any > const & args ) throw (Exception) -{ - if (1 != args.getLength()) - { - throw lang::IllegalArgumentException( - OUString( RTL_CONSTASCII_USTRINGPARAM("give a string instanciating this component!") ), - (::cppu::OWeakObject *)this, - 0 ); - } - - // Initialize - - // TODO: Get arguments. - - -} - -// XMain -::sal_Int32 SAL_CALL session_impl::run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (Exception) -{ - - - return 0; -} diff --git a/src/openoffice/loffice3270.cbp b/src/openoffice/loffice3270.cbp deleted file mode 100644 index 3d11352..0000000 --- a/src/openoffice/loffice3270.cbp +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - diff --git a/src/openoffice/manifest.xml.in b/src/openoffice/manifest.xml.in deleted file mode 100644 index 8908827..0000000 --- a/src/openoffice/manifest.xml.in +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/openoffice/pw3270.idl b/src/openoffice/pw3270.idl deleted file mode 100644 index 5952450..0000000 --- a/src/openoffice/pw3270.idl +++ /dev/null @@ -1,66 +0,0 @@ -/* - * "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., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como pw3270.idl e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - * - * Referências: - * - * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C++/C++_Component - * - */ - -#include -#include -#include - -module pw3270 -{ - /* - * Interface to lib3270 - */ - interface lib3270 : com::sun::star::uno::XInterface - { - // Constants - string getVersion(); - string getRevision(); - - // Host definition - short setHost([in] string url); - short Connect(); - short Disconnect(); - - // Misc Settings - short setSessionName([in] string name); - }; - - service session - { - interface lib3270; - interface com::sun::star::lang::XInitialization; - interface com::sun::star::lang::XMain; - }; -}; - diff --git a/src/openoffice/research.sh b/src/openoffice/research.sh deleted file mode 100755 index 4bb9ad0..0000000 --- a/src/openoffice/research.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -OO_SDK_HOME=/usr/lib64/libreoffice/sdk -IDLC=/usr/lib64/libreoffice/sdk/bin/idlc -CPPUMAKER=/usr/lib64/libreoffice/sdk/bin/cppumaker -TYPES_RDB=/usr/lib64/libreoffice/ure/share/misc/types.rdb -REGMERGE=/usr/lib64/libreoffice/ure/bin/regmerge - -$IDLC -C -I$OO_SDK_HOME/idl -O. pw3270.idl -if [ "$?" != "0" ]; then - exit -1 -fi - - -$REGMERGE pw3270.rdb /UCR pw3270.urd -if [ "$?" != "0" ]; then - exit -1 -fi - - -$CPPUMAKER -O./include -Tpw3270.lib3270 $TYPES_RDB pw3270.rdb -if [ "$?" != "0" ]; then - exit -1 -fi - -# XWeak -$IDLC -C -I$OO_SDK_HOME/idl -O. /usr/share/idl/libreoffice/com/sun/star/uno/XWeak.idl -if [ "$?" != "0" ]; then - exit -1 -fi - -$REGMERGE XWeak.rdb /UCR XWeak.urd -if [ "$?" != "0" ]; then - exit -1 -fi - -$CPPUMAKER -O./include $TYPES_RDB XWeak.rdb -if [ "$?" != "0" ]; then - exit -1 -fi - - -echo ok - diff --git a/src/openoffice/service.cc b/src/openoffice/service.cc deleted file mode 100644 index 275fbd5..0000000 --- a/src/openoffice/service.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* - * "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 info.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) - * - * Referência: - * - * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Providing_a_Single_Factory_Using_a_Helper_Method - * - */ - - #include "globals.hpp" - #include - #include "pw3270/lib3270.hpp" - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -namespace pw3270_impl -{ - Sequence< OUString > SAL_CALL getSupportedServiceNames_session_impl() - { - Sequence names(1); - names[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("pw3270.session")); - return names; - } - - OUString SAL_CALL getImplementationName_session_impl() - { - return OUString( RTL_CONSTASCII_USTRINGPARAM("pw3270.lib3270.session") ); - } - - Reference< XInterface > SAL_CALL create_session_impl(Reference< XComponentContext > const & xContext ) SAL_THROW( () ) - { - return static_cast< lang::XTypeProvider * >( new session_impl() ); - } - - static struct ::cppu::ImplementationEntry s_component_entries [] = - { - { - create_session_impl, - getImplementationName_session_impl, - getSupportedServiceNames_session_impl, - ::cppu::createSingleComponentFactory, - 0, - 0 - }, - { - 0, - 0, - 0, - 0, - 0, - 0 - } - }; - -} - -extern "C" -{ - DLL_PUBLIC void * SAL_CALL component_getFactory(sal_Char const * implName, lang::XMultiServiceFactory * xMgr,registry::XRegistryKey * xRegistry ) - { - return ::cppu::component_getFactoryHelper(implName, xMgr, xRegistry, ::pw3270_impl::s_component_entries ); - } - - DLL_PUBLIC sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry ) - { - return ::cppu::component_writeInfoHelper(xMgr, xRegistry, ::pw3270_impl::s_component_entries ); - } - - DLL_PUBLIC void SAL_CALL component_getImplementationEnvironment(sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv ) - { - * ppEnvTypeName = LANGUAGE_BINDING_NAME; - } - -} diff --git a/src/openoffice/set.cc b/src/openoffice/set.cc deleted file mode 100644 index e025a9a..0000000 --- a/src/openoffice/set.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* - * "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 get.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) - * - * Referência: - * - * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes - * - */ - - #include "globals.hpp" - #include - #include - #include "pw3270/lib3270.hpp" - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - - using namespace pw3270_impl; - using namespace com::sun::star::uno; - - ::sal_Int16 SAL_CALL session_impl::setSessionName( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException) - { - if(hSession) - { - // Remove old session - delete hSession; - hSession = NULL; - } - - OString vlr = rtl::OUStringToOString( name , RTL_TEXTENCODING_UNICODE ); - - trace("%s(\"%s\")",__FUNCTION__,vlr.getStr()); - - try - { - - hSession = h3270::session::create(((const char *) vlr.getStr())); - trace("%s: hSession(\"%s\"=%p",__FUNCTION__,vlr.getStr(),hSession); - - } catch(std::exception &e) - { - OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); - - throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); - - return -1; - - } - - return 0; - - } - - ::sal_Int16 SAL_CALL session_impl::setHost( const ::rtl::OUString& url ) throw (::com::sun::star::uno::RuntimeException) - { - if(!hSession) - hSession = h3270::session::get_default(); - - OString vlr = rtl::OUStringToOString( url , RTL_TEXTENCODING_UNICODE ); - - try - { - - return hSession->set_url(vlr.getStr()); - - } catch(std::exception &e) - { - OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); - - throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this)); - - } - - return -1; - } - diff --git a/src/openoffice/testmacros.odt b/src/openoffice/testmacros.odt deleted file mode 100644 index 35a28a7..0000000 Binary files a/src/openoffice/testmacros.odt and /dev/null differ diff --git a/src/openoffice/testprogram.cc b/src/openoffice/testprogram.cc deleted file mode 100644 index 6885e1d..0000000 --- a/src/openoffice/testprogram.cc +++ /dev/null @@ -1,148 +0,0 @@ -/* - * "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 - #include - #include - - #include "pw3270/lib3270.hpp" - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::bridge; -using namespace rtl; -using namespace cppu; - -int SAL_CALL main(int argc, char **argv) -{ - Reference< XComponentContext > rComponentContext = defaultBootstrap_InitialComponentContext(); - OSL_ENSURE( xContext.is(), "### cannot creage intial component context!" ); - -/* - Reference< XSimpleRegistry > xReg = DefaultRegistry(); - - 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; -} diff --git a/src/plugins/dbus3270/gobject.c b/src/plugins/dbus3270/gobject.c index fb81c89..1d1a638 100644 --- a/src/plugins/dbus3270/gobject.c +++ b/src/plugins/dbus3270/gobject.c @@ -481,7 +481,8 @@ void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *con void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context) { - dbus_g_method_return(context,lib3270_get_display_charset(pw3270_dbus_get_session_handle(object))); + // Allways return UTF-8 to avoid double conversion + dbus_g_method_return(context,"UTF-8"); } void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context) diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc index 520dcca..0787623 100644 --- a/src/plugins/rx3270/pluginmain.cc +++ b/src/plugins/rx3270/pluginmain.cc @@ -100,8 +100,8 @@ int wait(int seconds); int wait_for_ready(int seconds); - string * get_text(int baddr, size_t len); - string * get_text_at(int row, int col, size_t sz); + string get_text(int baddr, size_t len); + string get_text_at(int row, int col, size_t sz); int cmp_text_at(int row, int col, const char *text); int set_text_at(int row, int col, const char *str); @@ -124,17 +124,17 @@ int get_next_unprotected(int baddr = -1); int set_copy(const char *text); - string * get_copy(void); + string get_copy(void); - string * get_clipboard(void); + string get_clipboard(void); int set_clipboard(const char *text); int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); - string * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename); + string file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename); int set_host_charset(const char *charset); - string * get_host_charset(void); - string * get_display_charset(void); + string get_host_charset(void); + string get_display_charset(void); const char * asc2ebc(unsigned char *str, int sz = -1); const char * ebc2asc(unsigned char *str, int sz = -1); @@ -588,18 +588,18 @@ extern "C" return lib3270_wait_for_ready(hSession,seconds); } - string * plugin::get_text_at(int row, int col, size_t sz) + string plugin::get_text_at(int row, int col, size_t sz) { - char * ptr = lib3270_get_text_at(hSession,row,col,(int) sz); + string rc; + char * ptr = lib3270_get_text_at(hSession,row,col,(int) sz); if(ptr) { - string *s = new string(ptr); + rc.assign(ptr); lib3270_free(ptr); - return s; } - return new string(""); + return rc; } int plugin::cmp_text_at(int row, int col, const char *text) @@ -632,17 +632,18 @@ extern "C" lib3270_write_va_log(hSession,"REXX",fmt,args); } - string * plugin::get_text(int baddr, size_t len) + string plugin::get_text(int baddr, size_t len) { - char *ptr = lib3270_get_text(hSession,baddr,len); + string rc; + char * ptr = lib3270_get_text(hSession,baddr,len); + if(ptr) { - string *s = new string(ptr); + rc.assign(ptr); lib3270_free(ptr); - return s; } - return new string(""); + return rc; } int plugin::get_field_start(int baddr) @@ -661,32 +662,32 @@ extern "C" return 0; } - string * plugin::get_copy(void) + string plugin::get_copy(void) { - gchar *ptr = v3270_get_copy(GTK_WIDGET(lib3270_get_widget(hSession))); + string rc; + gchar * ptr = v3270_get_copy(GTK_WIDGET(lib3270_get_widget(hSession))); if(ptr) { - string *ret = new string((char *) ptr); + rc.assign(ptr); g_free(ptr); - return ret; } - return NULL; + return rc; } - string * plugin::get_clipboard(void) + string plugin::get_clipboard(void) { - gchar *ptr = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); + string rc; + gchar * ptr = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); if(ptr) { - string *ret = new string((char *) ptr); + rc.assign(ptr); g_free(ptr); - return ret; } - return NULL; + return rc; } int plugin::set_clipboard(const char *text) @@ -729,18 +730,18 @@ int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *mess return 0; } -string * plugin::file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename) +string plugin::file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename) { - gchar *ptr = pw3270_file_chooser(action, script_name ? script_name : "rexx", title, filename, extension); + string rc; + gchar * ptr = pw3270_file_chooser(action, script_name ? script_name : "rexx", title, filename, extension); if(ptr) { - string *s = new string((char *) ptr); + rc.assign((char *) ptr); g_free(ptr); - return s; } - return NULL; + return rc; } int plugin::quit(void) @@ -754,14 +755,14 @@ int plugin::set_host_charset(const char *charset) return lib3270_set_host_charset(hSession,charset); } -string * plugin::get_host_charset(void) +string plugin::get_host_charset(void) { - return new string(lib3270_get_host_charset(hSession)); + return string(lib3270_get_host_charset(hSession)); } -string * plugin::get_display_charset(void) +string plugin::get_display_charset(void) { - return new string(lib3270_get_display_charset(hSession)); + return string(lib3270_get_display_charset(hSession)); } int plugin::erase_eof(void) diff --git a/src/plugins/rx3270/rexx_methods.cc b/src/plugins/rx3270/rexx_methods.cc index 30aacfc..85f535c 100644 --- a/src/plugins/rx3270/rexx_methods.cc +++ b/src/plugins/rx3270/rexx_methods.cc @@ -207,14 +207,8 @@ RexxMethod4(RexxStringObject, rx3270_method_get_text_at, CSELF, sessionPtr, int, try { session * hSession = (session *) sessionPtr; - string * str = hSession->get_string_at(row,col,sz); - - if(str) - { - RexxStringObject ret = context->String((CSTRING) str->c_str()); - delete str; - return ret; - } + string str = hSession->get_string_at(row,col,sz); + return context->String((CSTRING) str.c_str()); } catch(std::exception &e) @@ -363,12 +357,8 @@ RexxMethod4(logical_t, rx3270_method_test, CSELF, sessionPtr, CSTRING, key, int, if(hSession->is_ready()) { - bool rc = false; - string * str = hSession->get_string_at(row,col,strlen(key)); - if(str) - rc = (strcasecmp(str->c_str(),key) == 0); - delete str; - return rc; + string str = hSession->get_string_at(row,col,strlen(key)); + return (strcasecmp(str.c_str(),key) == 0); } } @@ -401,14 +391,8 @@ RexxMethod3(RexxStringObject, rx3270_method_get_text, CSELF, sessionPtr, OPTIONA try { session * hSession = (session *) sessionPtr; - string * str = hSession->get_string(baddr,sz > 0 ? sz : -1); - - if(str) - { - RexxStringObject ret = context->String((CSTRING) str->c_str()); - delete str; - return ret; - } + string str = hSession->get_string(baddr,sz > 0 ? sz : -1); + return context->String((CSTRING) str.c_str()); } catch(std::exception &e) { @@ -452,14 +436,8 @@ RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr) { try { - string *str = ((session *) sessionPtr)->get_copy(); - - if(str) - { - RexxStringObject ret = context->String((CSTRING) str->c_str()); - delete str; - return ret; - } + string str = ((session *) sessionPtr)->get_copy(); + return context->String((CSTRING) str.c_str()); } catch(std::exception &e) @@ -490,14 +468,8 @@ RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr) if(hSession) { - string *str = hSession->get_clipboard(); - - if(str) - { - RexxStringObject ret = context->String((CSTRING) str->c_str()); - delete str; - return ret; - } + string str = hSession->get_clipboard(); + return context->String((CSTRING) str.c_str()); } trace("%s","rx3270_method_get_clipboard: Clipboard is empty"); @@ -560,7 +532,7 @@ RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CST }; GtkFileChooserAction id = GTK_FILE_CHOOSER_ACTION_OPEN; - string * ret; + string ret; for(int f=0;f<5;f++) { @@ -572,14 +544,8 @@ RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CST } ret = ((session *) sessionPtr)->file_chooser_dialog(id, title, extension,filename); - if(ret) - { - RexxStringObject obj = context->String(ret->c_str()); - delete ret; - return obj; - } - return context->String(""); + return context->String(ret.c_str()); } RexxMethod2(int, rx3270_method_set_host_charset, CSELF, sessionPtr, CSTRING, text) @@ -589,17 +555,13 @@ RexxMethod2(int, rx3270_method_set_host_charset, CSELF, sessionPtr, CSTRING, tex RexxMethod1(RexxStringObject, rx3270_method_get_host_charset, CSELF, sessionPtr) { - string * ret = ((session *) sessionPtr)->get_host_charset(); - RexxStringObject obj = context->String(ret->c_str()); - delete ret; - return obj; + string ret = ((session *) sessionPtr)->get_host_charset(); + return context->String(ret.c_str()); } RexxMethod1(RexxStringObject, rx3270_method_get_display_charset, CSELF, sessionPtr) { - string * ret = ((session *) sessionPtr)->get_display_charset(); - RexxStringObject obj = context->String(ret->c_str()); - delete ret; - return obj; + string ret = ((session *) sessionPtr)->get_display_charset(); + return context->String(ret.c_str()); } diff --git a/src/plugins/rx3270/typed_routines.cc b/src/plugins/rx3270/typed_routines.cc index 156b616..673c765 100644 --- a/src/plugins/rx3270/typed_routines.cc +++ b/src/plugins/rx3270/typed_routines.cc @@ -150,14 +150,8 @@ RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz) { try { - string *str = session::get_default()->get_string_at(row,col,(int) sz); - - if(str) - { - RexxStringObject ret = context->String((CSTRING) str->c_str()); - delete str; - return ret; - } + string str = session::get_default()->get_string_at(row,col,(int) sz); + return context->String((CSTRING) str.c_str()); } catch(std::exception &e) { -- libgit2 0.21.2