diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2009-07-07 19:19:23 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2009-07-07 19:19:23 -0400 |
commit | bb1812ad6ef4b19ead1fe08fd5e4596a6e6f5800 (patch) | |
tree | 8c6bee8bccc4458912d332cfa2a2ab1a760501d8 | |
parent | 4a27a9b1c8840cb676cee353bcfff2e8ace3ab03 (diff) |
added DPDimensions to implement collective dimensions.
-rw-r--r-- | cmake/CMakeLists.txt | 4 | ||||
-rw-r--r-- | inc/dpdimensions.hxx | 52 | ||||
-rw-r--r-- | inc/dpsource.hxx | 16 | ||||
-rw-r--r-- | source/dpdimensions.cxx | 119 | ||||
-rw-r--r-- | source/dpsource.cxx | 9 |
5 files changed, 197 insertions, 3 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 03e7c53..5ba0bf6 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -23,7 +23,9 @@ 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,${SHARED_LIB_NAME} -Wl,--no-undefined") -add_library(${TARGET_NAME} SHARED ../source/dpsource.cxx) + +set(SRC_FILES ../source/dpsource.cxx ../source/dpdimensions.cxx) +add_library(${TARGET_NAME} SHARED ${SRC_FILES}) target_link_libraries(${TARGET_NAME} uno_cppuhelpergcc3 uno_sal uno_cppu) diff --git a/inc/dpdimensions.hxx b/inc/dpdimensions.hxx new file mode 100644 index 0000000..ad518b5 --- /dev/null +++ b/inc/dpdimensions.hxx @@ -0,0 +1,52 @@ +#ifndef __DPDIMENSIONS_HXX__ +#define __DPDIMENSIONS_HXX__ + +#include <cppuhelper/implbase2.hxx> + +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +namespace dpsource { + +class DPDimensions : public cppu::WeakImplHelper2< + ::com::sun::star::container::XNameAccess, + ::com::sun::star::lang::XServiceInfo > +{ +public: + DPDimensions(); + ~DPDimensions(); + + // XNameAccess + + virtual ::com::sun::star::uno::Any SAL_CALL getByName(const ::rtl::OUString& aName) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getElementNames() throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& aName) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException); +}; + +} + +#endif diff --git a/inc/dpsource.hxx b/inc/dpsource.hxx index b47c20a..776c0e0 100644 --- a/inc/dpsource.hxx +++ b/inc/dpsource.hxx @@ -11,8 +11,20 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +namespace com { namespace sun { namespace star { + namespace container { + class XNameAccess; + } + namespace sheet { + class XDimensionsSupplier; + class XDataPilotResults; + } +}}} + namespace dpsource { +class DPDimensions; + class SourceProvider : public cppu::WeakImplHelper6< ::com::sun::star::beans::XPropertySet, ::com::sun::star::lang::XServiceInfo, @@ -114,6 +126,10 @@ public: private: SourceProvider(); SourceProvider(const SourceProvider&); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::container::XNameAccess> mxDimensions; }; } diff --git a/source/dpdimensions.cxx b/source/dpdimensions.cxx new file mode 100644 index 0000000..7b9bf35 --- /dev/null +++ b/source/dpdimensions.cxx @@ -0,0 +1,119 @@ + +#include "dpdimensions.hxx" + +#include <com/sun/star/container/XNamed.hpp> + +#define SERVICE_NAME "com.sun.star.sheet.DataPilotSourceDimensions" +#define IMPLEMENTATION_NAME "com.novell.openoffice.DataPilotDimensions" + +using ::com::sun::star::container::NoSuchElementException; +using ::com::sun::star::container::XNameAccess; +using ::com::sun::star::container::XNamed; +using ::com::sun::star::lang::WrappedTargetException; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Type; +using ::rtl::OUString; + + +#include <stdio.h> +#include <string> +#include <sys/time.h> + +namespace { + +class StackPrinter +{ +public: + explicit StackPrinter(const char* msg) : + msMsg(msg) + { + fprintf(stdout, "%s: --begin\n", msMsg.c_str()); + mfStartTime = getTime(); + } + + ~StackPrinter() + { + double fEndTime = getTime(); + fprintf(stdout, "%s: --end (duration: %g sec)\n", msMsg.c_str(), (fEndTime-mfStartTime)); + } + +private: + double getTime() const + { + timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec + tv.tv_usec / 1000000.0; + } + + ::std::string msMsg; + double mfStartTime; +}; + +} + +namespace dpsource { + +DPDimensions::DPDimensions() +{ +} + +DPDimensions::~DPDimensions() +{ +} + +Any DPDimensions::getByName(const OUString& aName) + throw (NoSuchElementException, WrappedTargetException, RuntimeException) +{ + StackPrinter __stack_printer__("dpsource/DPDimensions::getByName"); + fprintf(stdout, "DPDimensions::getByName: name = '%s'\n", rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr()); + return Any(); +} + +Sequence<OUString> DPDimensions::getElementNames() throw (RuntimeException) +{ + StackPrinter __stack_printer__("dpsource/DPDimensions::getElementNames"); + Sequence<OUString> aElemNames(3); + aElemNames[0] = OUString::createFromAscii("A"); + aElemNames[1] = OUString::createFromAscii("B"); + aElemNames[2] = OUString::createFromAscii("C"); + return aElemNames; +} + +sal_Bool DPDimensions::hasByName(const OUString& aName) throw (RuntimeException) +{ + StackPrinter __stack_printer__("dpsource/DPDimensions::hasByName"); + fprintf(stdout, "DPDimensions::hasByName: name = '%s'\n", rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr()); + return false; +} + +Type DPDimensions::getElementType() throw (RuntimeException) +{ + return getCppuType(static_cast< Reference<XNamed>* >(NULL)); +} + +sal_Bool DPDimensions::hasElements() throw (RuntimeException) +{ + return false; +} + +OUString DPDimensions::getImplementationName() throw (RuntimeException) +{ + return OUString::createFromAscii(IMPLEMENTATION_NAME); +} + +sal_Bool DPDimensions::supportsService(const OUString& ServiceName) throw (RuntimeException) +{ + return ServiceName.equalsAscii(SERVICE_NAME); +} + +Sequence<OUString> DPDimensions::getSupportedServiceNames() throw (RuntimeException) +{ + Sequence<OUString> aSrvNames(1); + aSrvNames[0] = OUString::createFromAscii(SERVICE_NAME); + return aSrvNames; +} + +} diff --git a/source/dpsource.cxx b/source/dpsource.cxx index 1623929..7f239c4 100644 --- a/source/dpsource.cxx +++ b/source/dpsource.cxx @@ -1,6 +1,8 @@ #include "dpsource.hxx" +#include "dpdimensions.hxx" + #include <cppuhelper/implementationentry.hxx> #define SERVICE_NAME "com.sun.star.sheet.DataPilotSource" @@ -69,7 +71,8 @@ namespace dpsource { static Sequence<OUString> getSupportedServiceNames(); -SourceProvider::SourceProvider(const Reference<XComponentContext>& xContext) +SourceProvider::SourceProvider(const Reference<XComponentContext>& xContext) : + mxDimensions(static_cast<DPDimensions*>(NULL)) { } @@ -151,7 +154,9 @@ Sequence< Sequence<DataResult> > SourceProvider::getResults() throw (RuntimeExce Reference<XNameAccess> SourceProvider::getDimensions() throw (RuntimeException) { StackPrinter __stack_printer__("dpsource/SourceProvider::getDimensions"); - return Reference<XNameAccess>(); + if (!mxDimensions.is()) + mxDimensions.set(new DPDimensions); + return mxDimensions; } // DrillDownDataSupplier |