From a9be51dd3150f75dde3de3b954dcc7e2d58083af Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 31 Mar 2014 12:03:08 +0000 Subject: [PATCH] Juntando classe base no módulo openoffice --- configure.ac | 6 ++++++ src/classlib/local.cc | 2 +- src/openoffice/Makefile.in | 45 +++++++++++++++++++++++++++------------------ src/openoffice/globals.hpp | 18 ++++++++++++++---- src/openoffice/init.cc | 8 ++++++++ src/openoffice/loffice3270.cbp | 2 ++ src/openoffice/pw3270.idl | 2 ++ src/openoffice/service.cc | 6 +++--- src/openoffice/testprogram.cc | 14 ++++++++++++-- 9 files changed, 75 insertions(+), 28 deletions(-) diff --git a/configure.ac b/configure.ac index dfac9a7..264a7af 100644 --- a/configure.ac +++ b/configure.ac @@ -504,6 +504,12 @@ if test "$CPPUMAKER" == "no" ; then app_cv_office="no" fi +AC_PATH_TOOL([UNO], uno, "no", path=$PATH:$OO_SDK_URE_BIN_DIR) +if test "$UNO" == "no" ; then + app_cv_office="no" +fi + + # Check for OO_SDK_HOME if test "_$OO_SDK_HOME" == "_" ; then app_cv_office="no" diff --git a/src/classlib/local.cc b/src/classlib/local.cc index 729c397..9ec600e 100644 --- a/src/classlib/local.cc +++ b/src/classlib/local.cc @@ -425,7 +425,7 @@ int set_url(const char *uri) { - return (_set_url(hSession,uri) == NULL) ? 0 : 1; + return (_set_url(hSession,uri) != 0) ? 1 : 0; } int disconnect(void) diff --git a/src/openoffice/Makefile.in b/src/openoffice/Makefile.in index dc2a4c8..3bd59f2 100644 --- a/src/openoffice/Makefile.in +++ b/src/openoffice/Makefile.in @@ -32,6 +32,8 @@ UNO_CLASSES=XWeak RuntimeException OO_SDK_HOME=@OO_SDK_HOME@ OO_SDK_URE_HOME=@OO_SDK_URE_HOME@ + +UNO=@UNO@ IDLC=@IDLC@ REGMERGE=@REGMERGE@ CPPUMAKER=@CPPUMAKER@ @@ -51,11 +53,6 @@ includedir=@includedir@ CXX=@CXX@ MKDIR=@MKDIR_P@ -#---[ lib3270 common class ]--------------------------------------------------- - -CLASSLIBDIR=../classlib -include $(CLASSLIBDIR)/class.mak - #---[ Paths ]------------------------------------------------------------------ OBJDIR=.obj @@ -69,6 +66,12 @@ BINDBG=$(BINDIR)/Debug OBJRLS=$(OBJDIR)/Release BINRLS=$(BINDIR)/Release +#---[ lib3270 common class ]--------------------------------------------------- + +PW3270_CFLAGS=-I../include +CLASSLIBDIR=../classlib +include $(CLASSLIBDIR)/class.mak + #---[ Build options ]---------------------------------------------------------- CPPUENV="gcc3" @@ -81,37 +84,37 @@ OO_LDFLAGS=-L$(OO_SDK_HOME)/lib -L$(OO_SDK_URE_HOME)/lib \ #---[ Rules ]------------------------------------------------------------------ $(URDDIR)/%.urd: %.idl - @echo $@ ... + @echo " IDLC `basename $@`" @$(MKDIR) `dirname $@` - $(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< + @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< $(URDDIR)/%.urd: /usr/share/idl/libreoffice/%.idl - @echo $@ ... + @echo " IDLC `basename $@`" @$(MKDIR) `dirname $@` - $(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< + @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< $(RDBDIR)/%.rdb: $(URDDIR)/%.urd - @echo $@ ... + @echo " REGM `basename $@`" @$(MKDIR) `dirname $@` - $(REGMERGE) $@ /UCR $< + @$(REGMERGE) $@ /UCR $< include/%.hpp: $(RDBDIR)/%.rdb - @echo $@ ... + @echo " CPPU `basename $@`" @$(MKDIR) `dirname $@` - $(CPPUMAKER) -O./include $(TYPES_RDB) $< + @$(CPPUMAKER) -O./include $(TYPES_RDB) $< $(OBJDBG)/%.o: %.cc include/pw3270/lib3270.hpp \ $(foreach CLS, $(basename $(UNO_CLASSES)), include/com/sun/star/uno/$(CLS).hpp) \ *.hpp Makefile - @echo $< ... + @echo " CC `basename $@`" @mkdir -p `dirname $@` - $(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ -c $< + @$(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ -c $< # $(DBG_CFLAGS) $(CXXFLAGS) $(LIB3270_CFLAGS) -DLIBNAME=\"$(BINDBG)/$(PROGRAM_NAME).uno@DLLEXT@\" -o $@ -c $< #---[ UNO targets ]------------------------------------------------------------ include/pw3270/lib3270.hpp: $(RDBDIR)/pw3270.rdb - @echo $@ ... + @echo " CPPU `basename $@`" @$(MKDIR) `dirname $@` @$(CPPUMAKER) -O./include -Tpw3270.lib3270 $(TYPES_RDB) $< @@ -120,11 +123,17 @@ include/pw3270/lib3270.hpp: $(RDBDIR)/pw3270.rdb Debug: $(BINDBG)/pw3270.uno@DLLEXT@ -$(BINDBG)/pw3270.uno@DLLEXT@: $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) +$(BINDBG)/testprogram: $(OBJDBG)/testprogram@OBJEXT@ $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) @echo $@ ... @$(MKDIR) `dirname $@` - $(CXX) -shared $(LDFLAGS) $(OO_LDFLAGS) -o $@ $^ + $(CXX) -shared $(LDFLAGS) $(OO_LDFLAGS) -o $(BINDBG)/pw3270.uno@DLLEXT@ $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) +$(BINDBG)/pw3270.uno@DLLEXT@: \ + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) \ + $(CLASS_DEBUG_OBJECTS) + @echo " LD `basename $@`" + @$(MKDIR) `dirname $@` + $(CXX) -shared $(LDFLAGS) $(OO_LDFLAGS) -o $@ $^ #---[ Misc targets ]----------------------------------------------------------- diff --git a/src/openoffice/globals.hpp b/src/openoffice/globals.hpp index a33dddb..f449575 100644 --- a/src/openoffice/globals.hpp +++ b/src/openoffice/globals.hpp @@ -44,31 +44,41 @@ #define UNX 1 #define GCC 1 #define LINUX 1 + #define HAVE_GCC_VISIBILITY_FEATURE 1 #endif - #include // "3" implementing three interfaces + #include // "3" implementing three interfaces #include #include // #include #include + +#ifdef DEBUG + #include +#endif // DEBUG + #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 - - namespace pw3270_impl + namespace pw3270_impl { // https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes - class session_impl : public ::cppu::WeakImplHelper3< ::pw3270::lib3270, XServiceInfo, XInitialization > + class DLL_PUBLIC session_impl : public ::cppu::WeakImplHelper4< ::pw3270::lib3270, XServiceInfo, XMain, XInitialization > { public: + + // 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); diff --git a/src/openoffice/init.cc b/src/openoffice/init.cc index f4061a9..0b725d5 100644 --- a/src/openoffice/init.cc +++ b/src/openoffice/init.cc @@ -53,3 +53,11 @@ void session_impl::initialize( Sequence< Any > const & args ) throw (Exception) // Initialize } + +// 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 index 5b9f569..2916fd6 100644 --- a/src/openoffice/loffice3270.cbp +++ b/src/openoffice/loffice3270.cbp @@ -32,6 +32,8 @@ + + diff --git a/src/openoffice/pw3270.idl b/src/openoffice/pw3270.idl index a8a084a..6286c7d 100644 --- a/src/openoffice/pw3270.idl +++ b/src/openoffice/pw3270.idl @@ -34,6 +34,7 @@ #include #include +#include module pw3270 { @@ -49,6 +50,7 @@ module pw3270 { interface lib3270; interface com::sun::star::lang::XInitialization; + interface com::sun::star::lang::XMain; }; }; diff --git a/src/openoffice/service.cc b/src/openoffice/service.cc index 31337f8..dd053e8 100644 --- a/src/openoffice/service.cc +++ b/src/openoffice/service.cc @@ -82,17 +82,17 @@ namespace pw3270_impl extern "C" { - __attribute__((visibility("default"))) void * SAL_CALL component_getFactory(sal_Char const * implName, lang::XMultiServiceFactory * xMgr,registry::XRegistryKey * xRegistry ) + 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 ); } - __attribute__((visibility("default"))) sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry ) + 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 ); } - __attribute__((visibility("default"))) void SAL_CALL component_getImplementationEnvironment(sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv ) + DLL_PUBLIC void SAL_CALL component_getImplementationEnvironment(sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv ) { * ppEnvTypeName = LANGUAGE_BINDING_NAME; } diff --git a/src/openoffice/testprogram.cc b/src/openoffice/testprogram.cc index 00026c3..6885e1d 100644 --- a/src/openoffice/testprogram.cc +++ b/src/openoffice/testprogram.cc @@ -28,15 +28,25 @@ */ #include "globals.hpp" - #include + + #include + #include + #include + #include "pw3270/lib3270.hpp" /*---[ Implement ]-----------------------------------------------------------------------------------------*/ -using namespace ::com::sun::star::registry; +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(); -- libgit2 0.21.2