Commit a9be51dd3150f75dde3de3b954dcc7e2d58083af

Authored by perry.werneck@gmail.com
1 parent caed0035

Juntando classe base no módulo openoffice

configure.ac
... ... @@ -504,6 +504,12 @@ if test "$CPPUMAKER" == "no" ; then
504 504 app_cv_office="no"
505 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 513 # Check for OO_SDK_HOME
508 514 if test "_$OO_SDK_HOME" == "_" ; then
509 515 app_cv_office="no"
... ...
src/classlib/local.cc
... ... @@ -425,7 +425,7 @@
425 425  
426 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 431 int disconnect(void)
... ...
src/openoffice/Makefile.in
... ... @@ -32,6 +32,8 @@ UNO_CLASSES=XWeak RuntimeException
32 32  
33 33 OO_SDK_HOME=@OO_SDK_HOME@
34 34 OO_SDK_URE_HOME=@OO_SDK_URE_HOME@
  35 +
  36 +UNO=@UNO@
35 37 IDLC=@IDLC@
36 38 REGMERGE=@REGMERGE@
37 39 CPPUMAKER=@CPPUMAKER@
... ... @@ -51,11 +53,6 @@ includedir=@includedir@
51 53 CXX=@CXX@
52 54 MKDIR=@MKDIR_P@
53 55  
54   -#---[ lib3270 common class ]---------------------------------------------------
55   -
56   -CLASSLIBDIR=../classlib
57   -include $(CLASSLIBDIR)/class.mak
58   -
59 56 #---[ Paths ]------------------------------------------------------------------
60 57  
61 58 OBJDIR=.obj
... ... @@ -69,6 +66,12 @@ BINDBG=$(BINDIR)/Debug
69 66 OBJRLS=$(OBJDIR)/Release
70 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 75 #---[ Build options ]----------------------------------------------------------
73 76  
74 77 CPPUENV="gcc3"
... ... @@ -81,37 +84,37 @@ OO_LDFLAGS=-L$(OO_SDK_HOME)/lib -L$(OO_SDK_URE_HOME)/lib \
81 84 #---[ Rules ]------------------------------------------------------------------
82 85  
83 86 $(URDDIR)/%.urd: %.idl
84   - @echo $@ ...
  87 + @echo " IDLC `basename $@`"
85 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 91 $(URDDIR)/%.urd: /usr/share/idl/libreoffice/%.idl
89   - @echo $@ ...
  92 + @echo " IDLC `basename $@`"
90 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 96 $(RDBDIR)/%.rdb: $(URDDIR)/%.urd
94   - @echo $@ ...
  97 + @echo " REGM `basename $@`"
95 98 @$(MKDIR) `dirname $@`
96   - $(REGMERGE) $@ /UCR $<
  99 + @$(REGMERGE) $@ /UCR $<
97 100  
98 101 include/%.hpp: $(RDBDIR)/%.rdb
99   - @echo $@ ...
  102 + @echo " CPPU `basename $@`"
100 103 @$(MKDIR) `dirname $@`
101   - $(CPPUMAKER) -O./include $(TYPES_RDB) $<
  104 + @$(CPPUMAKER) -O./include $(TYPES_RDB) $<
102 105  
103 106 $(OBJDBG)/%.o: %.cc include/pw3270/lib3270.hpp \
104 107 $(foreach CLS, $(basename $(UNO_CLASSES)), include/com/sun/star/uno/$(CLS).hpp) \
105 108 *.hpp Makefile
106   - @echo $< ...
  109 + @echo " CC `basename $@`"
107 110 @mkdir -p `dirname $@`
108   - $(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ -c $<
  111 + @$(CXX) -DDEBUG=1 $(CXXFLAGS) -o $@ -c $<
109 112 # $(DBG_CFLAGS) $(CXXFLAGS) $(LIB3270_CFLAGS) -DLIBNAME=\"$(BINDBG)/$(PROGRAM_NAME).uno@DLLEXT@\" -o $@ -c $<
110 113  
111 114 #---[ UNO targets ]------------------------------------------------------------
112 115  
113 116 include/pw3270/lib3270.hpp: $(RDBDIR)/pw3270.rdb
114   - @echo $@ ...
  117 + @echo " CPPU `basename $@`"
115 118 @$(MKDIR) `dirname $@`
116 119 @$(CPPUMAKER) -O./include -Tpw3270.lib3270 $(TYPES_RDB) $<
117 120  
... ... @@ -120,11 +123,17 @@ include/pw3270/lib3270.hpp: $(RDBDIR)/pw3270.rdb
120 123  
121 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 127 @echo $@ ...
125 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 138 #---[ Misc targets ]-----------------------------------------------------------
130 139  
... ...
src/openoffice/globals.hpp
... ... @@ -44,31 +44,41 @@
44 44 #define UNX 1
45 45 #define GCC 1
46 46 #define LINUX 1
  47 + #define HAVE_GCC_VISIBILITY_FEATURE 1
47 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 52 #include <cppuhelper/factory.hxx>
52 53 #include <com/sun/star/lang/XInitialization.hpp>
53 54 // #include <cppuhelper/implementationentry.hxx>
54 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 61 #include <com/sun/star/uno/RuntimeException.hpp>
56 62  
57 63 #include <pw3270/lib3270.hpp>
58 64  
  65 + #define DLL_PUBLIC __attribute__((visibility("default")))
59 66  
60 67 using namespace ::rtl; // for OUString
61 68 using namespace ::com::sun::star; // for sdk interfaces
62 69 using namespace ::com::sun::star::lang; // for sdk interfaces
63 70 using namespace ::com::sun::star::uno; // for basic types
64 71  
65   -
66   - namespace pw3270_impl
  72 + namespace pw3270_impl
67 73 {
68 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 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 82 // XInitialization will be called upon createInstanceWithArguments[AndContext]()
73 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&lt; Any &gt; const &amp; args ) throw (Exception)
53 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 32 <Compiler>
33 33 <Add option="-Wall" />
34 34 </Compiler>
  35 + <Unit filename="../../configure.ac" />
  36 + <Unit filename="../classlib/class.mak" />
35 37 <Unit filename="../classlib/class.mak.in" />
36 38 <Unit filename="../classlib/exception.cc" />
37 39 <Unit filename="../classlib/local.cc" />
... ...
src/openoffice/pw3270.idl
... ... @@ -34,6 +34,7 @@
34 34  
35 35 #include <com/sun/star/uno/XInterface.idl>
36 36 #include <com/sun/star/lang/XInitialization.idl>
  37 +#include <com/sun/star/lang/XMain.idl>
37 38  
38 39 module pw3270
39 40 {
... ... @@ -49,6 +50,7 @@ module pw3270
49 50 {
50 51 interface lib3270;
51 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 82  
83 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 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 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 97 * ppEnvTypeName = LANGUAGE_BINDING_NAME;
98 98 }
... ...
src/openoffice/testprogram.cc
... ... @@ -28,15 +28,25 @@
28 28 */
29 29  
30 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 36 #include "pw3270/lib3270.hpp"
33 37  
34 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 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 52 Reference< XSimpleRegistry > xReg = DefaultRegistry();
... ...