[Libreoffice-commits] .: Branch 'libreoffice-3-4' - 4 commits - sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Apr 26 14:23:36 PDT 2011
sc/source/core/data/dpoutput.cxx | 65 ++++++++++++++++-------------------
sc/source/core/data/dptablecache.cxx | 22 ++++++++++-
2 files changed, 50 insertions(+), 37 deletions(-)
New commits:
commit 61db82397810dcfd560561cd5c1cbc871d383131
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Apr 26 17:14:11 2011 -0400
n#677917: Try a bit harder to determine the number format of a dimension.
The old code always took the number format of the first member of the
dimension. We should at least try the first 10 members to determine
what number format to use.
BTW this is just a stop-gap measure; to fix it properly we need to
use a better cache table structure that properly marks empty cells.
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 1ba04d0..de7480c 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -932,7 +932,22 @@ sal_uLong ScDPCache::GetNumberFormat( long nDim ) const
if (maTableDataValues[nDim].empty())
return 0;
- return maTableDataValues[nDim][0].nNumFormat;
+ // TODO: This is very ugly, but the best we can do right now. Check the
+ // first 10 dimension members, and take the first non-zero number format,
+ // else return the default number format (of 0). For the long-term, we
+ // need to redo this cache structure to properly indicate empty cells, and
+ // skip them when trying to determine the representative number format for
+ // a dimension.
+ size_t nCount = maTableDataValues[nDim].size();
+ if (nCount > 10)
+ nCount = 10;
+ for (size_t i = 0; i < nCount; ++i)
+ {
+ sal_uLong n = maTableDataValues[nDim][i].nNumFormat;
+ if (n)
+ return n;
+ }
+ return 0;
}
bool ScDPCache::IsDateDimension( long nDim ) const
commit 51857e89c12604fb3c456594fbbc82db8490bc52
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Apr 26 16:43:54 2011 -0400
Prefer empty() over size() where it makes sense.
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 3c66b72..1ba04d0 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -928,10 +928,11 @@ sal_uLong ScDPCache::GetNumberFormat( long nDim ) const
{
if ( nDim >= mnColumnCount )
return 0;
- if ( maTableDataValues[nDim].size()==0 )
+
+ if (maTableDataValues[nDim].empty())
return 0;
- else
- return maTableDataValues[nDim][0].nNumFormat;
+
+ return maTableDataValues[nDim][0].nNumFormat;
}
bool ScDPCache::IsDateDimension( long nDim ) const
commit 00339ebfa6483b7d631a973e733c2fa27f475ac1
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Apr 26 16:40:34 2011 -0400
Let's use the constant in unonames.hxx to be consistent.
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 1335555..a48f0b6 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -82,7 +82,6 @@ using ::rtl::OUString;
#define DP_PROP_POSITION "Position"
#define DP_PROP_USEDHIERARCHY "UsedHierarchy"
#define DP_PROP_ISDATALAYOUT "IsDataLayoutDimension"
-#define DP_PROP_NUMBERFORMAT "NumberFormat"
#define DP_PROP_FILTER "Filter"
#define DP_PROP_COLUMNGRAND "ColumnGrand"
#define DP_PROP_ROWGRAND "RowGrand"
@@ -395,7 +394,7 @@ void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
aDataNames[nDataCount] = String( xDimName->getName() );
long nFormat = ScUnoHelpFunctions::GetLongProperty(
xDimProp,
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(DP_PROP_NUMBERFORMAT)) );
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)) );
nDataFormats[nDataCount] = nFormat;
if ( nFormat != 0 )
bAnySet = sal_True;
@@ -461,7 +460,7 @@ sal_uInt32 lcl_GetFirstNumberFormat( const uno::Reference<container::XIndexAcces
{
long nFormat = ScUnoHelpFunctions::GetLongProperty(
xDimProp,
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(DP_PROP_NUMBERFORMAT)) );
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)) );
return nFormat; // use format from first found data dimension
}
commit 21948a9a6f7521ccb1183d162176abcf1c82865d
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Apr 26 14:33:32 2011 -0400
Put more source local functions into anonymous namespace.
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 21b40d4..1335555 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -95,6 +95,33 @@ using ::rtl::OUString;
#define SC_DPOUT_MAXLEVELS 256
+struct ScDPOutLevelData
+{
+ long nDim;
+ long nHier;
+ long nLevel;
+ long nDimPos;
+ uno::Sequence<sheet::MemberResult> aResult;
+ String maName; /// Name is the internal field name.
+ String aCaption; /// Caption is the name visible in the output table.
+ bool mbHasHiddenMember;
+
+ ScDPOutLevelData()
+ {
+ nDim = nHier = nLevel = nDimPos = -1;
+ mbHasHiddenMember = false;
+ }
+
+ sal_Bool operator<(const ScDPOutLevelData& r) const
+ { return nDimPos<r.nDimPos || ( nDimPos==r.nDimPos && nHier<r.nHier ) ||
+ ( nDimPos==r.nDimPos && nHier==r.nHier && nLevel<r.nLevel ); }
+
+ void Swap(ScDPOutLevelData& r)
+ { ScDPOutLevelData aTemp; aTemp = r; r = *this; *this = aTemp; }
+
+ //! bug (73840) in uno::Sequence - copy and then assign doesn't work!
+};
+
namespace {
bool lcl_compareColfuc ( SCCOL i, SCCOL j) { return (i<j); }
@@ -277,37 +304,6 @@ void ScDPOutputImpl::OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL
}
-}
-
-struct ScDPOutLevelData
-{
- long nDim;
- long nHier;
- long nLevel;
- long nDimPos;
- uno::Sequence<sheet::MemberResult> aResult;
- String maName; /// Name is the internal field name.
- String aCaption; /// Caption is the name visible in the output table.
- bool mbHasHiddenMember;
-
- ScDPOutLevelData()
- {
- nDim = nHier = nLevel = nDimPos = -1;
- mbHasHiddenMember = false;
- }
-
- sal_Bool operator<(const ScDPOutLevelData& r) const
- { return nDimPos<r.nDimPos || ( nDimPos==r.nDimPos && nHier<r.nHier ) ||
- ( nDimPos==r.nDimPos && nHier==r.nHier && nLevel<r.nLevel ); }
-
- void Swap(ScDPOutLevelData& r)
- { ScDPOutLevelData aTemp; aTemp = r; r = *this; *this = aTemp; }
-
- //! bug (73840) in uno::Sequence - copy and then assign doesn't work!
-};
-
-// -----------------------------------------------------------------------
-
void lcl_SetStyleById( ScDocument* pDoc, SCTAB nTab,
SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
sal_uInt16 nStrId )
@@ -534,6 +530,8 @@ uno::Sequence<sheet::MemberResult> lcl_GetSelectedPageAsResult( const uno::Refer
return aRet;
}
+}
+
ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsSupplier>& xSrc,
const ScAddress& rPos, bool bFilter ) :
pDoc( pD ),
More information about the Libreoffice-commits
mailing list