diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2009-07-02 22:35:38 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2009-07-02 22:35:38 -0400 |
commit | 487b02b53b79d8d358b7d8c965ef0dd5d4bdf92d (patch) | |
tree | 6ca4676769a5726082ca9c400610a0c4f08ca656 | |
parent | a0d67e4778cb4d05905f73786dd0e235c2a04461 (diff) |
Finally managed to get the first shared library to register!
-rw-r--r-- | cmake/CMakeLists.txt | 9 | ||||
-rw-r--r-- | inc/dpsource.hxx | 7 | ||||
-rw-r--r-- | source/dpsource.cxx | 110 |
3 files changed, 112 insertions, 14 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 22a47e7..5ce35fc 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,10 +1,17 @@ cmake_minimum_required(VERSION 2.6) project(DP_SOURCE_EXTENSION) +set(URE_BINDIR /usr/lib/ooo3/ure/bin) + include_directories(../inc /usr/lib/ooo3/solver/inc /usr/lib/ooo3/solver/inc/offuh) -add_definitions(-DUNX -DGCC -DLINUX -DCPPU_ENV=gcc4 -DHAVE_GCC_VISIBILITY_FEATURE) +link_directories(/usr/lib/ooo3/solver/lib) + +add_definitions(-DUNX -DGCC -DLINUX -DCPPU_ENV=gcc3 -DHAVE_GCC_VISIBILITY_FEATURE) + set(CMAKE_BUILD_TYPE debug) set(CMAKE_C_FLAGS_DEBUG "-g -Wall") set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall") +set(CMAKE_SHARED_LINKER_FLAGS "-shared -Wl,-soname,libtest.so -Wl,--no-undefined") add_library(test SHARED ../source/dpsource.cxx) +target_link_libraries(test uno_cppuhelpergcc3 uno_sal uno_cppu) diff --git a/inc/dpsource.hxx b/inc/dpsource.hxx index b85c38e..18cecb0 100644 --- a/inc/dpsource.hxx +++ b/inc/dpsource.hxx @@ -9,6 +9,7 @@ #include <com/sun/star/util/XRefreshable.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> namespace dpsource { @@ -21,7 +22,7 @@ class SourceProvider : public cppu::WeakImplHelper6< ::com::sun::star::util::XRefreshable > { public: - SourceProvider(); + SourceProvider(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext); virtual ~SourceProvider(); // XPropertySet @@ -109,6 +110,10 @@ public: virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l ) throw (::com::sun::star::uno::RuntimeException); + +private: + SourceProvider(); + SourceProvider(const SourceProvider&); }; } diff --git a/source/dpsource.cxx b/source/dpsource.cxx index 21434f2..4ceaf3e 100644 --- a/source/dpsource.cxx +++ b/source/dpsource.cxx @@ -1,27 +1,40 @@ #include "dpsource.hxx" +#include <cppuhelper/implementationentry.hxx> + +#include <stdio.h> + +#define SERVICE_NAME "com.sun.star.sheet.DataPilotSource" +#define IMPLEMENTATION_NAME "com.novell.openoffice.DataPilotSourceProvider" -using ::com::sun::star::lang::IllegalArgumentException; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::beans::PropertyVetoException; using ::com::sun::star::beans::UnknownPropertyException; -using ::com::sun::star::beans::XPropertySetInfo; using ::com::sun::star::beans::XPropertyChangeListener; +using ::com::sun::star::beans::XPropertySetInfo; using ::com::sun::star::beans::XVetoableChangeListener; +using ::com::sun::star::container::XNameAccess; +using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::lang::WrappedTargetException; -using ::com::sun::star::sheet::DataResult; +using ::com::sun::star::lang::XTypeProvider; using ::com::sun::star::sheet::DataPilotFieldFilter; -using ::com::sun::star::container::XNameAccess; +using ::com::sun::star::sheet::DataResult; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::XComponentContext; +using ::com::sun::star::uno::XInterface; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Sequence; using ::com::sun::star::util::XRefreshListener; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::registry::XRegistryKey; using ::rtl::OUString; namespace dpsource { -SourceProvider::SourceProvider() +static Sequence<OUString> getSupportedServiceNames(); + +SourceProvider::SourceProvider(const Reference<XComponentContext>& xContext) { } @@ -73,19 +86,19 @@ void SourceProvider::removeVetoableChangeListener( OUString SourceProvider::getImplementationName() throw (RuntimeException) { - return OUString(); + return OUString::createFromAscii(IMPLEMENTATION_NAME); } sal_Bool SourceProvider::supportsService(const OUString& ServiceName) throw (RuntimeException) { - return false; + return ServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(SERVICE_NAME)); } Sequence<OUString> SourceProvider::getSupportedServiceNames() throw (RuntimeException) { - return Sequence<OUString>(); + return ::dpsource::getSupportedServiceNames(); } // XDataPilotResults @@ -124,6 +137,79 @@ void SourceProvider::removeRefreshListener(const Reference< XRefreshListener >& { } +// ============================================================================ + +static Sequence<OUString> getSupportedServiceNames() +{ + static Sequence <OUString> *pNames = 0; + if (!pNames) + { + static Sequence<OUString> seqNames(1); + seqNames.getArray()[0] = OUString::createFromAscii(SERVICE_NAME); + pNames = &seqNames; + } + return *pNames; +} + +static rtl::OUString getImplementationName() +{ + static OUString *pImplName = 0; + if (!pImplName) + { + static OUString implName( + RTL_CONSTASCII_USTRINGPARAM(IMPLEMENTATION_NAME)); + pImplName = &implName; + } + return *pImplName; +} + +static Reference<XInterface> SAL_CALL createCompInstance( + Reference<XComponentContext> const & xContext ) + SAL_THROW( () ) +{ + return static_cast<XTypeProvider*>(new SourceProvider(xContext)); +} + + +static struct ::cppu::ImplementationEntry s_component_entries [] = +{ + { + createCompInstance, getImplementationName, + getSupportedServiceNames, ::cppu::createSingleComponentFactory, + 0, 0 + }, + { 0, 0, 0, 0, 0, 0 } +}; + +} + +// ============================================================================ + +extern "C" +{ + +void SAL_DLLPUBLIC_EXPORT component_getImplementationEnvironment( + sal_Char const ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) +{ + fprintf(stdout, "component_getImplementationEnvironment: \n"); + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } +sal_Bool SAL_DLLPUBLIC_EXPORT component_writeInfo( + XMultiServiceFactory * xMgr, XRegistryKey * xRegistry) +{ + fprintf(stdout, "component_writeInfo: \n"); + return ::cppu::component_writeInfoHelper( + xMgr, xRegistry, ::dpsource::s_component_entries); +} +void SAL_DLLPUBLIC_EXPORT *component_getFactory( + sal_Char const* implName, XMultiServiceFactory * xMgr, + XRegistryKey * xRegistry) +{ + fprintf(stdout, "component_getFactory: \n"); + return ::cppu::component_getFactoryHelper( + implName, xMgr, xRegistry, ::dpsource::s_component_entries); +} + +} |