diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2009-07-10 18:25:43 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2009-07-10 18:25:43 -0400 |
commit | 2d99acb627eaba41f82247d74415fcd8a1524f36 (patch) | |
tree | c1b7641b3fec4c72db5e0cf5e3d4ff635cdd132d | |
parent | d4525f04ae2536cb875aeaac21e74b24f47fd8c8 (diff) |
First cut on displaying table outputs.
It now displays field names and field member names.
-rw-r--r-- | inc/dpdimension.hxx | 2 | ||||
-rw-r--r-- | inc/dphierarchies.hxx | 4 | ||||
-rw-r--r-- | inc/dphierarchy.hxx | 4 | ||||
-rw-r--r-- | inc/dplevel.hxx | 17 | ||||
-rw-r--r-- | inc/dplevels.hxx | 3 | ||||
-rw-r--r-- | inc/global.hxx | 11 | ||||
-rw-r--r-- | inc/proptokenizer.hxx | 1 | ||||
-rw-r--r-- | inc/sharedstring.hxx | 2 | ||||
-rw-r--r-- | source/dpdimension.cxx | 7 | ||||
-rw-r--r-- | source/dpdimensions.cxx | 22 | ||||
-rw-r--r-- | source/dphierarchies.cxx | 5 | ||||
-rw-r--r-- | source/dphierarchy.cxx | 5 | ||||
-rw-r--r-- | source/dplevel.cxx | 49 | ||||
-rw-r--r-- | source/dplevels.cxx | 6 | ||||
-rw-r--r-- | source/dpsource.cxx | 20 | ||||
-rw-r--r-- | source/global.cxx | 27 | ||||
-rw-r--r-- | source/proptokenizer.cxx | 36 | ||||
-rw-r--r-- | source/sharedstring.cxx | 2 |
18 files changed, 186 insertions, 37 deletions
diff --git a/inc/dpdimension.hxx b/inc/dpdimension.hxx index ef72742..9b43093 100644 --- a/inc/dpdimension.hxx +++ b/inc/dpdimension.hxx @@ -82,6 +82,8 @@ public: ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + SourceProvider* getSourceProvider() const; + private: ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxHierarchies; diff --git a/inc/dphierarchies.hxx b/inc/dphierarchies.hxx index d304ce6..410ea81 100644 --- a/inc/dphierarchies.hxx +++ b/inc/dphierarchies.hxx @@ -10,7 +10,6 @@ namespace dpsource { -class SourceProvider; class DPDimension; class DPHierarchies : public ::cppu::WeakImplHelper2< @@ -18,7 +17,7 @@ class DPHierarchies : public ::cppu::WeakImplHelper2< ::com::sun::star::container::XIndexAccess > { public: - explicit DPHierarchies(SourceProvider* pSrc, DPDimension* pDim); + explicit DPHierarchies(DPDimension* pDim); ~DPHierarchies(); // XNameAccess @@ -55,7 +54,6 @@ private: private: NamedObjMapType maHierarchies; - SourceProvider* mpSource; DPDimension* mpDim; }; diff --git a/inc/dphierarchy.hxx b/inc/dphierarchy.hxx index ec87f9e..901bca2 100644 --- a/inc/dphierarchy.hxx +++ b/inc/dphierarchy.hxx @@ -14,7 +14,6 @@ namespace com { namespace sun { namespace star { namespace dpsource { -class SourceProvider; class DPDimension; class DPHierarchy : public ::cppu::WeakImplHelper2< @@ -22,7 +21,7 @@ class DPHierarchy : public ::cppu::WeakImplHelper2< ::com::sun::star::sheet::XLevelsSupplier > { public: - explicit DPHierarchy(SourceProvider* pSrc, DPDimension* pDim); + explicit DPHierarchy(DPDimension* pDim); ~DPHierarchy(); // XNamed @@ -41,7 +40,6 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxLevels; ::rtl::OUString maName; - SourceProvider* mpSource; DPDimension* mpDim; }; diff --git a/inc/dplevel.hxx b/inc/dplevel.hxx index 69a40c1..36b2333 100644 --- a/inc/dplevel.hxx +++ b/inc/dplevel.hxx @@ -1,10 +1,11 @@ #ifndef __DPLEVEL_HXX__ #define __DPLEVEL_HXX__ -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase4.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/sheet/XDataPilotMemberResults.hpp> #include <com/sun/star/sheet/XMembersSupplier.hpp> namespace com { namespace sun { namespace star { @@ -15,15 +16,16 @@ namespace com { namespace sun { namespace star { namespace dpsource { -class SourceProvider; +class DPDimension; -class DPLevel : public ::cppu::WeakImplHelper3< +class DPLevel : public ::cppu::WeakImplHelper4< ::com::sun::star::beans::XPropertySet, ::com::sun::star::container::XNamed, + ::com::sun::star::sheet::XDataPilotMemberResults, ::com::sun::star::sheet::XMembersSupplier > { public: - DPLevel(SourceProvider* pSrc); + DPLevel(DPDimension* pDim); ~DPLevel(); // XNamed @@ -33,6 +35,11 @@ public: void SAL_CALL setName(const ::rtl::OUString& aName) throw (::com::sun::star::uno::RuntimeException); + // XDataPilotMemberResults + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::MemberResult > + SAL_CALL getResults() throw (::com::sun::star::uno::RuntimeException); + // XMembersSupplier virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > @@ -89,7 +96,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxMembers; ::rtl::OUString maName; - SourceProvider* mpSource; + DPDimension* mpDim; }; } diff --git a/inc/dplevels.hxx b/inc/dplevels.hxx index 7edaab4..1e4d330 100644 --- a/inc/dplevels.hxx +++ b/inc/dplevels.hxx @@ -15,7 +15,7 @@ class DPDimension; class DPLevels : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XNameAccess > { public: - DPLevels(SourceProvider* pSrc, DPDimension* pDim); + DPLevels(DPDimension* pDim); ~DPLevels(); // XNameAccess @@ -42,7 +42,6 @@ private: private: NamedObjMapType maLevels; - SourceProvider* mpSource; DPDimension* mpDim; }; diff --git a/inc/global.hxx b/inc/global.hxx index a2b6fff..69ae298 100644 --- a/inc/global.hxx +++ b/inc/global.hxx @@ -3,6 +3,7 @@ #include <cppuhelper/implementationentry.hxx> #include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <hash_map> @@ -12,6 +13,16 @@ typedef ::__gnu_cxx::hash_map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed >, ::rtl::OUStringHash > NamedObjMapType; +// ============================================================================ + +class PropertySetHelper +{ +public: + static bool getBoolProperty( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rObj, + const ::rtl::OUString& rPropName, bool bValueOnFail); +}; + } #endif diff --git a/inc/proptokenizer.hxx b/inc/proptokenizer.hxx index 34f3b3c..4b16979 100644 --- a/inc/proptokenizer.hxx +++ b/inc/proptokenizer.hxx @@ -30,6 +30,7 @@ public: ~PropertyTokenizer(); NameToken getNameToken(const ::rtl::OUString& rName); + ::rtl::OUString getStringFromToken(NameToken eToken) const; private: SimpleSharedString maSharedStrings; diff --git a/inc/sharedstring.hxx b/inc/sharedstring.hxx index e427613..e91680a 100644 --- a/inc/sharedstring.hxx +++ b/inc/sharedstring.hxx @@ -18,7 +18,7 @@ public: SimpleSharedString(const SimpleSharedString& r); ~SimpleSharedString(); - const ::rtl::OUString* getString(StrID nId); + const ::rtl::OUString* getString(StrID nId) const; StrID getStringId(const ::rtl::OUString& aStr); StrID insertString(const ::rtl::OUString& aStr); diff --git a/source/dpdimension.cxx b/source/dpdimension.cxx index 3789793..698d46e 100644 --- a/source/dpdimension.cxx +++ b/source/dpdimension.cxx @@ -87,7 +87,7 @@ void DPDimension::setName(const OUString& aName) throw (RuntimeException) Reference<XNameAccess> DPDimension::getHierarchies() throw (RuntimeException) { if (!mxHierarchies.is()) - mxHierarchies.set(new DPHierarchies(mpSource, this)); + mxHierarchies.set(new DPHierarchies(this)); return mxHierarchies; } @@ -185,4 +185,9 @@ void DPDimension::removeVetoableChangeListener( { } +SourceProvider* DPDimension::getSourceProvider() const +{ + return mpSource; +} + } diff --git a/source/dpdimensions.cxx b/source/dpdimensions.cxx index c98c975..fcaaaed 100644 --- a/source/dpdimensions.cxx +++ b/source/dpdimensions.cxx @@ -8,6 +8,7 @@ #define SERVICE_NAME "com.sun.star.sheet.DataPilotSourceDimensions" #define IMPLEMENTATION_NAME "com.novell.openoffice.DataPilotDimensions" +using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::container::NoSuchElementException; using ::com::sun::star::container::XNameAccess; using ::com::sun::star::container::XNamed; @@ -17,6 +18,7 @@ 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 ::com::sun::star::uno::UNO_QUERY; using ::rtl::OUString; @@ -83,13 +85,26 @@ void DPDimensions::init() xRef->setName(aDimName); maDimensions.insert(NamedObjMapType::value_type(aDimName, xRef)); } + + // Insert data layout dimension. + OUString aDimName = OUString::createFromAscii("Data"); + Reference<XNamed> xRef(new DPDimension(mpSource)); + xRef->setName(aDimName); + Reference<XPropertySet> xPropSet(xRef, UNO_QUERY); + if (xPropSet.is()) + { + Any any; + any <<= static_cast<sal_Bool>(true); + OUString aPropName = mpSource->getPropertyTokenizer().getStringFromToken(PropertyTokenizer::IsDataLayoutDimension); + fprintf(stdout, "DPDimensions::init: prop name = '%s'\n", rtl::OUStringToOString(aPropName, RTL_TEXTENCODING_UTF8).getStr()); + xPropSet->setPropertyValue(aPropName, any); + } + maDimensions.insert(NamedObjMapType::value_type(aDimName, xRef)); } 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()); NamedObjMapType::const_iterator itr = maDimensions.find(aName); if (itr == maDimensions.end()) throw NoSuchElementException(); @@ -101,7 +116,6 @@ Any DPDimensions::getByName(const OUString& aName) Sequence<OUString> DPDimensions::getElementNames() throw (RuntimeException) { - StackPrinter __stack_printer__("dpsource/DPDimensions::getElementNames"); Sequence<OUString> aElemNames(maDimensions.size()); NamedObjMapType::const_iterator itr = maDimensions.begin(), itrEnd = maDimensions.end(); for (sal_Int32 i = 0; itr != itrEnd; ++itr, ++i) @@ -112,8 +126,6 @@ Sequence<OUString> DPDimensions::getElementNames() throw (RuntimeException) 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()); NamedObjMapType::const_iterator itr = maDimensions.find(aName); return (itr != maDimensions.end()); } diff --git a/source/dphierarchies.cxx b/source/dphierarchies.cxx index 7dcf0a7..2d0f67c 100644 --- a/source/dphierarchies.cxx +++ b/source/dphierarchies.cxx @@ -56,8 +56,7 @@ private: namespace dpsource { -DPHierarchies::DPHierarchies(SourceProvider* pSrc, DPDimension* pDim) : - mpSource(pSrc), +DPHierarchies::DPHierarchies(DPDimension* pDim) : mpDim(pDim) { init(); @@ -73,7 +72,7 @@ void DPHierarchies::init() // For now, only create a 'flat' hierarchy. OUString aName = OUString::createFromAscii("flat"); - Reference<XNamed> xFlatHier(new DPHierarchy(mpSource, mpDim)); + Reference<XNamed> xFlatHier(new DPHierarchy(mpDim)); xFlatHier->setName(aName); maHierarchies.insert( NamedObjMapType::value_type(aName, xFlatHier)); diff --git a/source/dphierarchy.cxx b/source/dphierarchy.cxx index ba6e30b..d68e265 100644 --- a/source/dphierarchy.cxx +++ b/source/dphierarchy.cxx @@ -12,8 +12,7 @@ using ::rtl::OUString; namespace dpsource { -DPHierarchy::DPHierarchy(SourceProvider* pSrc, DPDimension* pDim) : - mpSource(pSrc), +DPHierarchy::DPHierarchy(DPDimension* pDim) : mpDim(pDim) { } @@ -37,7 +36,7 @@ void DPHierarchy::setName(const OUString& aName) throw (RuntimeException) Reference<XNameAccess> DPHierarchy::getLevels() throw (RuntimeException) { if (!mxLevels.is()) - mxLevels.set(new DPLevels(mpSource, mpDim)); + mxLevels.set(new DPLevels(mpDim)); return mxLevels; } diff --git a/source/dplevel.cxx b/source/dplevel.cxx index 57b3dce..476ae86 100644 --- a/source/dplevel.cxx +++ b/source/dplevel.cxx @@ -1,21 +1,28 @@ #include "dplevel.hxx" #include "dpmembers.hxx" +#include "dpdimension.hxx" #include "dpsource.hxx" +#include "proptokenizer.hxx" +#include "global.hxx" #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/sheet/MemberResult.hpp> +#include <com/sun/star/sheet/MemberResultFlags.hpp> -using ::com::sun::star::beans::XPropertySetInfo; using ::com::sun::star::beans::PropertyVetoException; using ::com::sun::star::beans::UnknownPropertyException; 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::uno::Reference; +using ::com::sun::star::sheet::MemberResult; 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 ::rtl::OUString; @@ -57,8 +64,8 @@ private: namespace dpsource { -DPLevel::DPLevel(SourceProvider* pSrc) : - mpSource(pSrc) +DPLevel::DPLevel(DPDimension* pDim) : + mpDim(pDim) { } @@ -78,6 +85,40 @@ void DPLevel::setName(const OUString& aName) throw (RuntimeException) maName = aName; } +// XDataPilotMemberResults + +Sequence<MemberResult> DPLevel::getResults() throw (RuntimeException) +{ + using namespace ::com::sun::star::sheet; + do + { + PropertyTokenizer& rPropTokens = mpDim->getSourceProvider()->getPropertyTokenizer(); + bool bDataLayout = PropertySetHelper::getBoolProperty( + *mpDim, rPropTokens.getStringFromToken(PropertyTokenizer::IsDataLayoutDimension), false); + if (bDataLayout) + break; + + Reference<XNameAccess> xMembers = getMembers(); + if (!xMembers.is()) + break; + + DPMembers* pMembers = static_cast<DPMembers*>(xMembers.get()); + Sequence<OUString> aNames = pMembers->getElementNames(); + sal_Int32 n = aNames.getLength(); + Sequence<MemberResult> aResult(n); + for (sal_Int32 i = 0; i < n; ++i) + { + aResult[i].Name = aNames[i]; + aResult[i].Caption = aNames[i]; + aResult[i].Flags = MemberResultFlags::HASMEMBER; + } + return aResult; + } + while (false); + + return Sequence<MemberResult>(); +} + // XMembersSupplier Reference<XNameAccess> DPLevel::getMembers() throw (RuntimeException) diff --git a/source/dplevels.cxx b/source/dplevels.cxx index db6e90d..932285c 100644 --- a/source/dplevels.cxx +++ b/source/dplevels.cxx @@ -56,8 +56,7 @@ private: namespace dpsource { -DPLevels::DPLevels(SourceProvider* pSrc, DPDimension* pDim) : - mpSource(pSrc), +DPLevels::DPLevels(DPDimension* pDim) : mpDim(pDim) { init(); @@ -74,7 +73,7 @@ void DPLevels::init() // A flat hierarchy only has one level, and its name equals the name of // the dimension. OUString aName = mpDim->getName(); - Reference<XNamed> xRef(new DPLevel(mpSource)); + Reference<XNamed> xRef(new DPLevel(mpDim)); xRef->setName(aName); maLevels.insert(NamedObjMapType::value_type(aName, xRef)); } @@ -99,7 +98,6 @@ Any DPLevels::getByName(const OUString& aName) 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) diff --git a/source/dpsource.cxx b/source/dpsource.cxx index fdd58be..64df860 100644 --- a/source/dpsource.cxx +++ b/source/dpsource.cxx @@ -88,7 +88,6 @@ Reference<XPropertySetInfo> SourceProvider::getPropertySetInfo() throw (RuntimeE void SourceProvider::setPropertyValue(const OUString& aPropertyName, const Any& aValue) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) { - StackPrinter __stack_printer__("dpsource/SourceProvider::setPropertyValue"); fprintf(stdout, "SourceProvider::setPropertyValue: prop name = '%s'\n", rtl::OUStringToOString(aPropertyName, RTL_TEXTENCODING_UTF8).getStr()); } @@ -146,7 +145,24 @@ Sequence<OUString> SourceProvider::getSupportedServiceNames() Sequence< Sequence<DataResult> > SourceProvider::getResults() throw (RuntimeException) { - return Sequence< Sequence<DataResult> >(); + StackPrinter __stack_printer__("dpsource/SourceProvider::getResults"); + Sequence< Sequence<DataResult> > aResults(3); + Sequence<DataResult> aRow(1); + aRow[0].Value = 1.0; + aResults[0] = aRow; + aResults[1] = aRow; + aResults[2] = aRow; + + for (sal_Int32 i = 0; i < aResults.getLength(); ++i) + { + for (sal_Int32 j = 0; j < aResults[i].getLength(); ++j) + { + printf("| %g (%ld)", aResults[i][j].Value, aResults[i][j].Flags); + } + printf(" |\n"); + } + + return aResults; } // XDimensionsSupplier diff --git a/source/global.cxx b/source/global.cxx index b384eea..4189724 100644 --- a/source/global.cxx +++ b/source/global.cxx @@ -1,8 +1,35 @@ #include "global.hxx" +#include <com/sun/star/beans/XPropertySet.hpp> + +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::XInterface; +using ::rtl::OUString; + namespace dpsource { +bool PropertySetHelper::getBoolProperty(const Reference<XInterface>& rObj, const OUString& rPropName, bool bValueOnFail) +{ + do + { + Reference<XPropertySet> xPropSet(rObj, UNO_QUERY); + if (!xPropSet.is()) + break; + + Any any = xPropSet->getPropertyValue(rPropName); + sal_Bool bVal; + if (!(any >>= bVal)) + break; + return static_cast<bool>(bVal); + } + while (false); + + return bValueOnFail; +} } diff --git a/source/proptokenizer.cxx b/source/proptokenizer.cxx index ce749d8..4441f7e 100644 --- a/source/proptokenizer.cxx +++ b/source/proptokenizer.cxx @@ -45,4 +45,40 @@ PropertyTokenizer::NameToken PropertyTokenizer::getNameToken(const OUString& rNa return Unknown; } +OUString PropertyTokenizer::getStringFromToken(NameToken eToken) const +{ + StrID nStrID = 0; // 0 = empty string + switch (eToken) + { + case Filter: + nStrID = mnFilter; + break; + case Function: + nStrID = mnFunction; + break; + case HasHiddenMember: + nStrID = mnHasHiddenMember; + break; + case IsDataLayoutDimension: + nStrID = mnIsDataLayoutDimension; + break; + case Orientation: + nStrID = mnOrientation; + break; + case Original: + nStrID = mnOriginal; + break; + case Position: + nStrID = mnPosition; + break; + case UsedHierarchy: + nStrID = mnUsedHierarchy; + break; + default: + ; + } + const OUString* pStr = maSharedStrings.getString(nStrID); + return pStr ? *pStr : OUString(); +} + } diff --git a/source/sharedstring.cxx b/source/sharedstring.cxx index c04fb17..03ce133 100644 --- a/source/sharedstring.cxx +++ b/source/sharedstring.cxx @@ -81,7 +81,7 @@ StrID SimpleSharedString::insertString(const OUString& aStr) return maStringTable.insertString(aStr); } -const OUString* SimpleSharedString::getString(StrID nId) +const OUString* SimpleSharedString::getString(StrID nId) const { return maStringTable.getString(nId); } |