summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2009-07-07 19:19:23 -0400
committerKohei Yoshida <kyoshida@novell.com>2009-07-07 19:19:23 -0400
commitbb1812ad6ef4b19ead1fe08fd5e4596a6e6f5800 (patch)
tree8c6bee8bccc4458912d332cfa2a2ab1a760501d8 /source
parent4a27a9b1c8840cb676cee353bcfff2e8ace3ab03 (diff)
added DPDimensions to implement collective dimensions.
Diffstat (limited to 'source')
-rw-r--r--source/dpdimensions.cxx119
-rw-r--r--source/dpsource.cxx9
2 files changed, 126 insertions, 2 deletions
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