summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2009-07-09 13:35:19 -0400
committerKohei Yoshida <kyoshida@novell.com>2009-07-09 13:35:19 -0400
commitc4e0c45675e3cffc51c018d61ec389986af9e210 (patch)
tree4ceb8d1d797edfe93ab9609e880e67be64d294af
parent43e75a849e57225aa03a2396d0e39ee8b81b0615 (diff)
Added levels and level objects. Now the dp layout dialog finally shows
the dummy dimension created within the extension.
-rw-r--r--cmake/CMakeLists.txt4
-rw-r--r--inc/dphierarchies.hxx6
-rw-r--r--inc/dphierarchy.hxx12
-rw-r--r--inc/dplevel.hxx43
-rw-r--r--inc/dplevels.hxx47
-rw-r--r--source/dphierarchies.cxx22
-rw-r--r--source/dphierarchy.cxx8
-rw-r--r--source/dplevel.cxx40
-rw-r--r--source/dplevels.cxx120
9 files changed, 289 insertions, 13 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index d2dfa18..a0fab7b 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -21,7 +21,7 @@ add_definitions(-DUNX -DGCC -DLINUX -DCPPU_ENV=gcc3 -DHAVE_GCC_VISIBILITY_FEATUR
set(CMAKE_BUILD_TYPE debug)
set(CMAKE_C_FLAGS_DEBUG "-g -Wall")
-set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall")
+set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wno-deprecated")
set(CMAKE_SHARED_LINKER_FLAGS "-shared -Wl,-soname,${SHARED_LIB_NAME} -Wl,--no-undefined")
# Source files to build.
@@ -31,6 +31,8 @@ set(SRC_FILES
../source/dpdimension.cxx
../source/dphierarchies.cxx
../source/dphierarchy.cxx
+ ../source/dplevels.cxx
+ ../source/dplevel.cxx
)
add_library(${TARGET_NAME} SHARED ${SRC_FILES})
diff --git a/inc/dphierarchies.hxx b/inc/dphierarchies.hxx
index 08c2a66..2988257 100644
--- a/inc/dphierarchies.hxx
+++ b/inc/dphierarchies.hxx
@@ -8,12 +8,6 @@
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
-namespace com { namespace sun { namespace star {
- namespace container {
- class XNamed;
- }
-}}}
-
namespace dpsource {
class DPHierarchies : public ::cppu::WeakImplHelper2<
diff --git a/inc/dphierarchy.hxx b/inc/dphierarchy.hxx
index f324013..85649ea 100644
--- a/inc/dphierarchy.hxx
+++ b/inc/dphierarchy.hxx
@@ -1,11 +1,17 @@
-#ifndef __DPHIEARCHIES_HXX__
-#define __DPHIEARCHIES_HXX__
+#ifndef __DPHIEARCHY_HXX__
+#define __DPHIEARCHY_HXX__
#include <cppuhelper/implbase2.hxx>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/sheet/XLevelsSupplier.hpp>
+namespace com { namespace sun { namespace star {
+ namespace container {
+ class XNameAccess;
+ }
+}}}
+
namespace dpsource {
class DPHierarchy : public ::cppu::WeakImplHelper2<
@@ -29,6 +35,8 @@ public:
SAL_CALL getLevels() throw (::com::sun::star::uno::RuntimeException);
private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ mxLevels;
::rtl::OUString maName;
};
diff --git a/inc/dplevel.hxx b/inc/dplevel.hxx
new file mode 100644
index 0000000..a661a53
--- /dev/null
+++ b/inc/dplevel.hxx
@@ -0,0 +1,43 @@
+#ifndef __DPLEVEL_HXX__
+#define __DPLEVEL_HXX__
+
+#include <cppuhelper/implbase2.hxx>
+
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/sheet/XMembersSupplier.hpp>
+
+namespace com { namespace sun { namespace star {
+ namespace container {
+ class XNameAccess;
+ }
+}}}
+
+namespace dpsource {
+
+class DPLevel : public ::cppu::WeakImplHelper2<
+ ::com::sun::star::container::XNamed,
+ ::com::sun::star::sheet::XMembersSupplier >
+{
+public:
+ DPLevel();
+ ~DPLevel();
+
+ // XNamed
+
+ ::rtl::OUString SAL_CALL getName() throw (::com::sun::star::uno::RuntimeException);
+
+ void SAL_CALL setName(const ::rtl::OUString& aName)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XMembersSupplier
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ SAL_CALL getMembers() throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ::rtl::OUString maName;
+};
+
+}
+
+#endif
diff --git a/inc/dplevels.hxx b/inc/dplevels.hxx
new file mode 100644
index 0000000..5418b7a
--- /dev/null
+++ b/inc/dplevels.hxx
@@ -0,0 +1,47 @@
+#ifndef __DPLEVELS_HXX__
+#define __DPLEVELS_HXX__
+
+#include "global.hxx"
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/container/XNameAccess.hpp>
+
+namespace dpsource {
+
+class DPLevels : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XNameAccess >
+{
+public:
+ DPLevels();
+ ~DPLevels();
+
+ // 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);
+
+private:
+ void init();
+
+private:
+ NamedObjMapType maLevels;
+};
+
+}
+
+
+#endif
diff --git a/source/dphierarchies.cxx b/source/dphierarchies.cxx
index 6e49c43..9b4a6b6 100644
--- a/source/dphierarchies.cxx
+++ b/source/dphierarchies.cxx
@@ -1,5 +1,6 @@
#include "dphierarchies.hxx"
+#include "dphierarchy.hxx"
#include <com/sun/star/container/XNamed.hpp>
@@ -65,6 +66,14 @@ DPHierarchies::~DPHierarchies()
void DPHierarchies::init()
{
+ maHierarchies.clear();
+
+ // For now, only create a 'flat' hierarchy.
+ OUString aName = OUString::createFromAscii("flat");
+ Reference<XNamed> xFlatHier(new DPHierarchy);
+ xFlatHier->setName(aName);
+ maHierarchies.insert(
+ NamedObjMapType::value_type(aName, xFlatHier));
}
Any DPHierarchies::getByName(const OUString& aName)
@@ -72,6 +81,13 @@ Any DPHierarchies::getByName(const OUString& aName)
{
StackPrinter __stack_printer__("dpsource/DPHierarchies::getByName");
fprintf(stdout, "DPHierarchies::getByName: name = '%s'\n", rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr());
+ NamedObjMapType::const_iterator itr = maHierarchies.find(aName);
+ if (itr != maHierarchies.end())
+ {
+ Any any;
+ any <<= itr->second;
+ return any;
+ }
throw NoSuchElementException();
return Any();
}
@@ -85,7 +101,7 @@ Sequence<OUString> DPHierarchies::getElementNames() throw (RuntimeException)
sal_Bool DPHierarchies::hasByName(const OUString& aName) throw (RuntimeException)
{
- return false;
+ return maHierarchies.count(aName) > 0;
}
Type DPHierarchies::getElementType() throw (RuntimeException)
@@ -95,12 +111,12 @@ Type DPHierarchies::getElementType() throw (RuntimeException)
sal_Bool DPHierarchies::hasElements() throw (RuntimeException)
{
- return false;
+ return !maHierarchies.empty();
}
sal_Int32 DPHierarchies::getCount() throw (RuntimeException)
{
- return 0;
+ return maHierarchies.size();
}
Any DPHierarchies::getByIndex(sal_Int32 nIndex)
diff --git a/source/dphierarchy.cxx b/source/dphierarchy.cxx
index fd30a5b..cc7c8f5 100644
--- a/source/dphierarchy.cxx
+++ b/source/dphierarchy.cxx
@@ -1,5 +1,8 @@
#include "dphierarchy.hxx"
+#include "dplevels.hxx"
+
+#include <com/sun/star/container/XNameAccess.hpp>
using ::com::sun::star::container::XNameAccess;
using ::com::sun::star::uno::RuntimeException;
@@ -30,7 +33,10 @@ void DPHierarchy::setName(const OUString& aName) throw (RuntimeException)
Reference<XNameAccess> DPHierarchy::getLevels() throw (RuntimeException)
{
- return Reference<XNameAccess>();
+ if (!mxLevels.is())
+ mxLevels.set(new DPLevels);
+
+ return mxLevels;
}
}
diff --git a/source/dplevel.cxx b/source/dplevel.cxx
new file mode 100644
index 0000000..0439234
--- /dev/null
+++ b/source/dplevel.cxx
@@ -0,0 +1,40 @@
+
+#include "dplevel.hxx"
+
+#include <com/sun/star/container/XNameAccess.hpp>
+
+using ::com::sun::star::container::XNameAccess;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+using ::rtl::OUString;
+
+namespace dpsource {
+
+DPLevel::DPLevel()
+{
+}
+
+DPLevel::~DPLevel()
+{
+}
+
+// XNamed
+
+OUString DPLevel::getName() throw (RuntimeException)
+{
+ return maName;
+}
+
+void DPLevel::setName(const OUString& aName) throw (RuntimeException)
+{
+ maName = aName;
+}
+
+// XMembersSupplier
+
+Reference<XNameAccess> DPLevel::getMembers() throw (RuntimeException)
+{
+ return Reference<XNameAccess>();
+}
+
+}
diff --git a/source/dplevels.cxx b/source/dplevels.cxx
new file mode 100644
index 0000000..4a43bc1
--- /dev/null
+++ b/source/dplevels.cxx
@@ -0,0 +1,120 @@
+
+#include "dplevels.hxx"
+#include "dplevel.hxx"
+
+#include <com/sun/star/container/XNamed.hpp>
+
+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 {
+
+DPLevels::DPLevels()
+{
+ init();
+}
+
+DPLevels::~DPLevels()
+{
+}
+
+void DPLevels::init()
+{
+ maLevels.clear();
+
+ // TODO: A flat hierarchy only has one level, and its name equals the name
+ // of the dimension.
+ OUString aName = OUString::createFromAscii("Andy");
+ Reference<XNamed> xRef(new DPLevel);
+ xRef->setName(aName);
+ maLevels.insert(NamedObjMapType::value_type(aName, xRef));
+}
+
+Any DPLevels::getByName(const OUString& aName)
+ throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ StackPrinter __stack_printer__("dpsource/DPLevels::getByName");
+ fprintf(stdout, "DPLevels::getByName: name = '%s'\n", rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr());
+ NamedObjMapType::const_iterator itr = maLevels.find(aName);
+ if (itr != maLevels.end())
+ {
+ Any any;
+ any <<= itr->second;
+ return any;
+ }
+ throw NoSuchElementException();
+ return Any();
+}
+
+Sequence<OUString> DPLevels::getElementNames() throw (RuntimeException)
+{
+ StackPrinter __stack_printer__("dpsource/DPLevels::getElementNames");
+ Sequence<OUString> aNames(maLevels.size());
+ NamedObjMapType::const_iterator itr = maLevels.begin(), itrEnd = maLevels.end();
+ for (sal_Int32 i = 0; itr != itrEnd; ++itr, ++i)
+ aNames[i] = itr->first;
+
+ return aNames;
+}
+
+sal_Bool DPLevels::hasByName(const OUString& aName) throw (RuntimeException)
+{
+ return maLevels.count(aName) > 0;
+}
+
+Type DPLevels::getElementType() throw (RuntimeException)
+{
+ return getCppuType(static_cast< Reference<XNamed>* >(NULL));
+}
+
+sal_Bool DPLevels::hasElements() throw (RuntimeException)
+{
+ return !maLevels.empty();
+}
+
+}