Commit a9be51dd3150f75dde3de3b954dcc7e2d58083af
1 parent
caed0035
Exists in
master
and in
5 other branches
Juntando classe base no módulo openoffice
Showing
9 changed files
with
75 additions
and
28 deletions
Show diff stats
configure.ac
| @@ -504,6 +504,12 @@ if test "$CPPUMAKER" == "no" ; then | @@ -504,6 +504,12 @@ if test "$CPPUMAKER" == "no" ; then | ||
| 504 | app_cv_office="no" | 504 | app_cv_office="no" |
| 505 | fi | 505 | fi |
| 506 | 506 | ||
| 507 | +AC_PATH_TOOL([UNO], uno, "no", path=$PATH:$OO_SDK_URE_BIN_DIR) | ||
| 508 | +if test "$UNO" == "no" ; then | ||
| 509 | + app_cv_office="no" | ||
| 510 | +fi | ||
| 511 | + | ||
| 512 | + | ||
| 507 | # Check for OO_SDK_HOME | 513 | # Check for OO_SDK_HOME |
| 508 | if test "_$OO_SDK_HOME" == "_" ; then | 514 | if test "_$OO_SDK_HOME" == "_" ; then |
| 509 | app_cv_office="no" | 515 | app_cv_office="no" |
src/classlib/local.cc
| @@ -425,7 +425,7 @@ | @@ -425,7 +425,7 @@ | ||
| 425 | 425 | ||
| 426 | int set_url(const char *uri) | 426 | int set_url(const char *uri) |
| 427 | { | 427 | { |
| 428 | - return (_set_url(hSession,uri) == NULL) ? 0 : 1; | 428 | + return (_set_url(hSession,uri) != 0) ? 1 : 0; |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | int disconnect(void) | 431 | int disconnect(void) |
src/openoffice/Makefile.in
| @@ -32,6 +32,8 @@ UNO_CLASSES=XWeak RuntimeException | @@ -32,6 +32,8 @@ UNO_CLASSES=XWeak RuntimeException | ||
| 32 | 32 | ||
| 33 | OO_SDK_HOME=@OO_SDK_HOME@ | 33 | OO_SDK_HOME=@OO_SDK_HOME@ |
| 34 | OO_SDK_URE_HOME=@OO_SDK_URE_HOME@ | 34 | OO_SDK_URE_HOME=@OO_SDK_URE_HOME@ |
| 35 | + | ||
| 36 | +UNO=@UNO@ | ||
| 35 | IDLC=@IDLC@ | 37 | IDLC=@IDLC@ |
| 36 | REGMERGE=@REGMERGE@ | 38 | REGMERGE=@REGMERGE@ |
| 37 | CPPUMAKER=@CPPUMAKER@ | 39 | CPPUMAKER=@CPPUMAKER@ |
| @@ -51,11 +53,6 @@ includedir=@includedir@ | @@ -51,11 +53,6 @@ includedir=@includedir@ | ||
| 51 | CXX=@CXX@ | 53 | CXX=@CXX@ |
| 52 | MKDIR=@MKDIR_P@ | 54 | MKDIR=@MKDIR_P@ |
| 53 | 55 | ||
| 54 | -#---[ lib3270 common class ]--------------------------------------------------- | ||
| 55 | - | ||
| 56 | -CLASSLIBDIR=../classlib | ||
| 57 | -include $(CLASSLIBDIR)/class.mak | ||
| 58 | - | ||
| 59 | #---[ Paths ]------------------------------------------------------------------ | 56 | #---[ Paths ]------------------------------------------------------------------ |
| 60 | 57 | ||
| 61 | OBJDIR=.obj | 58 | OBJDIR=.obj |
| @@ -69,6 +66,12 @@ BINDBG=$(BINDIR)/Debug | @@ -69,6 +66,12 @@ BINDBG=$(BINDIR)/Debug | ||
| 69 | OBJRLS=$(OBJDIR)/Release | 66 | OBJRLS=$(OBJDIR)/Release |
| 70 | BINRLS=$(BINDIR)/Release | 67 | BINRLS=$(BINDIR)/Release |
| 71 | 68 | ||
| 69 | +#---[ lib3270 common class ]--------------------------------------------------- | ||
| 70 | + | ||
| 71 | +PW3270_CFLAGS=-I../include | ||
| 72 | +CLASSLIBDIR=../classlib | ||
| 73 | +include $(CLASSLIBDIR)/class.mak | ||
| 74 | + | ||
| 72 | #---[ Build options ]---------------------------------------------------------- | 75 | #---[ Build options ]---------------------------------------------------------- |
| 73 | 76 | ||
| 74 | CPPUENV="gcc3" | 77 | CPPUENV="gcc3" |
| @@ -81,37 +84,37 @@ OO_LDFLAGS=-L$(OO_SDK_HOME)/lib -L$(OO_SDK_URE_HOME)/lib \ | @@ -81,37 +84,37 @@ OO_LDFLAGS=-L$(OO_SDK_HOME)/lib -L$(OO_SDK_URE_HOME)/lib \ | ||
| 81 | #---[ Rules ]------------------------------------------------------------------ | 84 | #---[ Rules ]------------------------------------------------------------------ |
| 82 | 85 | ||
| 83 | $(URDDIR)/%.urd: %.idl | 86 | $(URDDIR)/%.urd: %.idl |
| 84 | - @echo $@ ... | 87 | + @echo " IDLC `basename $@`" |
| 85 | @$(MKDIR) `dirname $@` | 88 | @$(MKDIR) `dirname $@` |
| 86 | - $(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< | 89 | + @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< |
| 87 | 90 | ||
| 88 | $(URDDIR)/%.urd: /usr/share/idl/libreoffice/%.idl | 91 | $(URDDIR)/%.urd: /usr/share/idl/libreoffice/%.idl |
| 89 | - @echo $@ ... | 92 | + @echo " IDLC `basename $@`" |
| 90 | @$(MKDIR) `dirname $@` | 93 | @$(MKDIR) `dirname $@` |
| 91 | - $(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< | 94 | + @$(IDLC) -C -I$(OO_SDK_HOME)/idl -O`dirname $@` $< |
| 92 | 95 | ||
| 93 | $(RDBDIR)/%.rdb: $(URDDIR)/%.urd | 96 | $(RDBDIR)/%.rdb: $(URDDIR)/%.urd |
| 94 | - @echo $@ ... | 97 | + @echo " REGM `basename $@`" |
| 95 | @$(MKDIR) `dirname $@` | 98 | @$(MKDIR) `dirname $@` |
| 96 | - $(REGMERGE) $@ /UCR $< | 99 | + @$(REGMERGE) $@ /UCR $< |
| 97 | 100 | ||
| 98 | include/%.hpp: $(RDBDIR)/%.rdb | 101 | include/%.hpp: $(RDBDIR)/%.rdb |
| 99 | - @echo $@ ... | 102 | + @echo " CPPU `basename $@`" |
| 100 | @$(MKDIR) `dirname $@` | 103 | @$(MKDIR) `dirname $@` |
| 101 | - $(CPPUMAKER) -O./include $(TYPES_RDB) $< | 104 | + @$(CPPUMAKER) -O./include $(TYPES_RDB) $< |
| 102 | 105 | ||
| 103 | $(OBJDBG)/%.o: %.cc include/pw3270/lib3270.hpp \ | 106 | $(OBJDBG)/%.o: %.cc include/pw3270/lib3270.hpp \ |
| 104 | $(foreach CLS, $(basename $(UNO_CLASSES)), include/com/sun/star/uno/$(CLS).hpp) \ | 107 | $(foreach CLS, $(basename $(UNO_CLASSES)), include/com/sun/star/uno/$(CLS).hpp) \ |
| 105 | *.hpp Makefile | 108 | *.hpp Makefile |
| 106 | - @echo $< ... | 109 | + @echo " CC `basename $@`" |
| 107 | @mkdir -p `dirname $@` | 110 | @mkdir -p `dirname $@` |
| 108 | - $(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ -c $< | 111 | + @$(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ -c $< |
| 109 | # $(DBG_CFLAGS) $(CXXFLAGS) $(LIB3270_CFLAGS) -DLIBNAME=\"$(BINDBG)/$(PROGRAM_NAME).uno@DLLEXT@\" -o $@ -c $< | 112 | # $(DBG_CFLAGS) $(CXXFLAGS) $(LIB3270_CFLAGS) -DLIBNAME=\"$(BINDBG)/$(PROGRAM_NAME).uno@DLLEXT@\" -o $@ -c $< |
| 110 | 113 | ||
| 111 | #---[ UNO targets ]------------------------------------------------------------ | 114 | #---[ UNO targets ]------------------------------------------------------------ |
| 112 | 115 | ||
| 113 | include/pw3270/lib3270.hpp: $(RDBDIR)/pw3270.rdb | 116 | include/pw3270/lib3270.hpp: $(RDBDIR)/pw3270.rdb |
| 114 | - @echo $@ ... | 117 | + @echo " CPPU `basename $@`" |
| 115 | @$(MKDIR) `dirname $@` | 118 | @$(MKDIR) `dirname $@` |
| 116 | @$(CPPUMAKER) -O./include -Tpw3270.lib3270 $(TYPES_RDB) $< | 119 | @$(CPPUMAKER) -O./include -Tpw3270.lib3270 $(TYPES_RDB) $< |
| 117 | 120 | ||
| @@ -120,11 +123,17 @@ include/pw3270/lib3270.hpp: $(RDBDIR)/pw3270.rdb | @@ -120,11 +123,17 @@ include/pw3270/lib3270.hpp: $(RDBDIR)/pw3270.rdb | ||
| 120 | 123 | ||
| 121 | Debug: $(BINDBG)/pw3270.uno@DLLEXT@ | 124 | Debug: $(BINDBG)/pw3270.uno@DLLEXT@ |
| 122 | 125 | ||
| 123 | -$(BINDBG)/pw3270.uno@DLLEXT@: $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) | 126 | +$(BINDBG)/testprogram: $(OBJDBG)/testprogram@OBJEXT@ $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) |
| 124 | @echo $@ ... | 127 | @echo $@ ... |
| 125 | @$(MKDIR) `dirname $@` | 128 | @$(MKDIR) `dirname $@` |
| 126 | - $(CXX) -shared $(LDFLAGS) $(OO_LDFLAGS) -o $@ $^ | 129 | + $(CXX) -shared $(LDFLAGS) $(OO_LDFLAGS) -o $(BINDBG)/pw3270.uno@DLLEXT@ $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) |
| 127 | 130 | ||
| 131 | +$(BINDBG)/pw3270.uno@DLLEXT@: \ | ||
| 132 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) \ | ||
| 133 | + $(CLASS_DEBUG_OBJECTS) | ||
| 134 | + @echo " LD `basename $@`" | ||
| 135 | + @$(MKDIR) `dirname $@` | ||
| 136 | + $(CXX) -shared $(LDFLAGS) $(OO_LDFLAGS) -o $@ $^ | ||
| 128 | 137 | ||
| 129 | #---[ Misc targets ]----------------------------------------------------------- | 138 | #---[ Misc targets ]----------------------------------------------------------- |
| 130 | 139 |
src/openoffice/globals.hpp
| @@ -44,31 +44,41 @@ | @@ -44,31 +44,41 @@ | ||
| 44 | #define UNX 1 | 44 | #define UNX 1 |
| 45 | #define GCC 1 | 45 | #define GCC 1 |
| 46 | #define LINUX 1 | 46 | #define LINUX 1 |
| 47 | + #define HAVE_GCC_VISIBILITY_FEATURE 1 | ||
| 47 | #endif | 48 | #endif |
| 48 | 49 | ||
| 49 | 50 | ||
| 50 | - #include <cppuhelper/implbase3.hxx> // "3" implementing three interfaces | 51 | + #include <cppuhelper/implbase4.hxx> // "3" implementing three interfaces |
| 51 | #include <cppuhelper/factory.hxx> | 52 | #include <cppuhelper/factory.hxx> |
| 52 | #include <com/sun/star/lang/XInitialization.hpp> | 53 | #include <com/sun/star/lang/XInitialization.hpp> |
| 53 | // #include <cppuhelper/implementationentry.hxx> | 54 | // #include <cppuhelper/implementationentry.hxx> |
| 54 | #include <com/sun/star/lang/XServiceInfo.hpp> | 55 | #include <com/sun/star/lang/XServiceInfo.hpp> |
| 56 | + | ||
| 57 | +#ifdef DEBUG | ||
| 58 | + #include <com/sun/star/lang/XMain.hpp> | ||
| 59 | +#endif // DEBUG | ||
| 60 | + | ||
| 55 | #include <com/sun/star/uno/RuntimeException.hpp> | 61 | #include <com/sun/star/uno/RuntimeException.hpp> |
| 56 | 62 | ||
| 57 | #include <pw3270/lib3270.hpp> | 63 | #include <pw3270/lib3270.hpp> |
| 58 | 64 | ||
| 65 | + #define DLL_PUBLIC __attribute__((visibility("default"))) | ||
| 59 | 66 | ||
| 60 | using namespace ::rtl; // for OUString | 67 | using namespace ::rtl; // for OUString |
| 61 | using namespace ::com::sun::star; // for sdk interfaces | 68 | using namespace ::com::sun::star; // for sdk interfaces |
| 62 | using namespace ::com::sun::star::lang; // for sdk interfaces | 69 | using namespace ::com::sun::star::lang; // for sdk interfaces |
| 63 | using namespace ::com::sun::star::uno; // for basic types | 70 | using namespace ::com::sun::star::uno; // for basic types |
| 64 | 71 | ||
| 65 | - | ||
| 66 | - namespace pw3270_impl | 72 | + namespace pw3270_impl |
| 67 | { | 73 | { |
| 68 | // https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes | 74 | // https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes |
| 69 | - class session_impl : public ::cppu::WeakImplHelper3< ::pw3270::lib3270, XServiceInfo, XInitialization > | 75 | + class DLL_PUBLIC session_impl : public ::cppu::WeakImplHelper4< ::pw3270::lib3270, XServiceInfo, XMain, XInitialization > |
| 70 | { | 76 | { |
| 71 | public: | 77 | public: |
| 78 | + | ||
| 79 | + // XMain | ||
| 80 | + virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (Exception); | ||
| 81 | + | ||
| 72 | // XInitialization will be called upon createInstanceWithArguments[AndContext]() | 82 | // XInitialization will be called upon createInstanceWithArguments[AndContext]() |
| 73 | virtual void SAL_CALL initialize( Sequence< Any > const & args ) throw (Exception); | 83 | virtual void SAL_CALL initialize( Sequence< Any > const & args ) throw (Exception); |
| 74 | 84 |
src/openoffice/init.cc
| @@ -53,3 +53,11 @@ void session_impl::initialize( Sequence< Any > const & args ) throw (Exception) | @@ -53,3 +53,11 @@ void session_impl::initialize( Sequence< Any > const & args ) throw (Exception) | ||
| 53 | // Initialize | 53 | // Initialize |
| 54 | 54 | ||
| 55 | } | 55 | } |
| 56 | + | ||
| 57 | +// XMain | ||
| 58 | +::sal_Int32 SAL_CALL session_impl::run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (Exception) | ||
| 59 | +{ | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + return 0; | ||
| 63 | +} |
src/openoffice/loffice3270.cbp
| @@ -32,6 +32,8 @@ | @@ -32,6 +32,8 @@ | ||
| 32 | <Compiler> | 32 | <Compiler> |
| 33 | <Add option="-Wall" /> | 33 | <Add option="-Wall" /> |
| 34 | </Compiler> | 34 | </Compiler> |
| 35 | + <Unit filename="../../configure.ac" /> | ||
| 36 | + <Unit filename="../classlib/class.mak" /> | ||
| 35 | <Unit filename="../classlib/class.mak.in" /> | 37 | <Unit filename="../classlib/class.mak.in" /> |
| 36 | <Unit filename="../classlib/exception.cc" /> | 38 | <Unit filename="../classlib/exception.cc" /> |
| 37 | <Unit filename="../classlib/local.cc" /> | 39 | <Unit filename="../classlib/local.cc" /> |
src/openoffice/pw3270.idl
| @@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
| 34 | 34 | ||
| 35 | #include <com/sun/star/uno/XInterface.idl> | 35 | #include <com/sun/star/uno/XInterface.idl> |
| 36 | #include <com/sun/star/lang/XInitialization.idl> | 36 | #include <com/sun/star/lang/XInitialization.idl> |
| 37 | +#include <com/sun/star/lang/XMain.idl> | ||
| 37 | 38 | ||
| 38 | module pw3270 | 39 | module pw3270 |
| 39 | { | 40 | { |
| @@ -49,6 +50,7 @@ module pw3270 | @@ -49,6 +50,7 @@ module pw3270 | ||
| 49 | { | 50 | { |
| 50 | interface lib3270; | 51 | interface lib3270; |
| 51 | interface com::sun::star::lang::XInitialization; | 52 | interface com::sun::star::lang::XInitialization; |
| 53 | + interface com::sun::star::lang::XMain; | ||
| 52 | }; | 54 | }; |
| 53 | }; | 55 | }; |
| 54 | 56 |
src/openoffice/service.cc
| @@ -82,17 +82,17 @@ namespace pw3270_impl | @@ -82,17 +82,17 @@ namespace pw3270_impl | ||
| 82 | 82 | ||
| 83 | extern "C" | 83 | extern "C" |
| 84 | { | 84 | { |
| 85 | - __attribute__((visibility("default"))) void * SAL_CALL component_getFactory(sal_Char const * implName, lang::XMultiServiceFactory * xMgr,registry::XRegistryKey * xRegistry ) | 85 | + DLL_PUBLIC void * SAL_CALL component_getFactory(sal_Char const * implName, lang::XMultiServiceFactory * xMgr,registry::XRegistryKey * xRegistry ) |
| 86 | { | 86 | { |
| 87 | return ::cppu::component_getFactoryHelper(implName, xMgr, xRegistry, ::pw3270_impl::s_component_entries ); | 87 | return ::cppu::component_getFactoryHelper(implName, xMgr, xRegistry, ::pw3270_impl::s_component_entries ); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | - __attribute__((visibility("default"))) sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry ) | 90 | + DLL_PUBLIC sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry ) |
| 91 | { | 91 | { |
| 92 | return ::cppu::component_writeInfoHelper(xMgr, xRegistry, ::pw3270_impl::s_component_entries ); | 92 | return ::cppu::component_writeInfoHelper(xMgr, xRegistry, ::pw3270_impl::s_component_entries ); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | - __attribute__((visibility("default"))) void SAL_CALL component_getImplementationEnvironment(sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv ) | 95 | + DLL_PUBLIC void SAL_CALL component_getImplementationEnvironment(sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv ) |
| 96 | { | 96 | { |
| 97 | * ppEnvTypeName = LANGUAGE_BINDING_NAME; | 97 | * ppEnvTypeName = LANGUAGE_BINDING_NAME; |
| 98 | } | 98 | } |
src/openoffice/testprogram.cc
| @@ -28,15 +28,25 @@ | @@ -28,15 +28,25 @@ | ||
| 28 | */ | 28 | */ |
| 29 | 29 | ||
| 30 | #include "globals.hpp" | 30 | #include "globals.hpp" |
| 31 | - #include <com/sun/star/registry/XSimpleRegistry.hpp> | 31 | + |
| 32 | + #include <cppuhelper/bootstrap.hxx> | ||
| 33 | + #include <com/sun/star/bridge/XUnoUrlResolver.hpp> | ||
| 34 | + #include <com/sun/star/lang/XMultiServiceFactory.hpp> | ||
| 35 | + | ||
| 32 | #include "pw3270/lib3270.hpp" | 36 | #include "pw3270/lib3270.hpp" |
| 33 | 37 | ||
| 34 | /*---[ Implement ]-----------------------------------------------------------------------------------------*/ | 38 | /*---[ Implement ]-----------------------------------------------------------------------------------------*/ |
| 35 | 39 | ||
| 36 | -using namespace ::com::sun::star::registry; | 40 | +using namespace com::sun::star::uno; |
| 41 | +using namespace com::sun::star::lang; | ||
| 42 | +using namespace com::sun::star::bridge; | ||
| 43 | +using namespace rtl; | ||
| 44 | +using namespace cppu; | ||
| 37 | 45 | ||
| 38 | int SAL_CALL main(int argc, char **argv) | 46 | int SAL_CALL main(int argc, char **argv) |
| 39 | { | 47 | { |
| 48 | + Reference< XComponentContext > rComponentContext = defaultBootstrap_InitialComponentContext(); | ||
| 49 | + OSL_ENSURE( xContext.is(), "### cannot creage intial component context!" ); | ||
| 40 | 50 | ||
| 41 | /* | 51 | /* |
| 42 | Reference< XSimpleRegistry > xReg = DefaultRegistry(); | 52 | Reference< XSimpleRegistry > xReg = DefaultRegistry(); |