ooo-build r14089 - in trunk: . patches/dev300 patches/vba
- From: kyoshida svn gnome org
- To: svn-commits-list gnome org
- Subject: ooo-build r14089 - in trunk: . patches/dev300 patches/vba
- Date: Thu, 25 Sep 2008 18:37:17 +0000 (UTC)
Author: kyoshida
Date: Thu Sep 25 18:37:17 2008
New Revision: 14089
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14089&view=rev
Log:
2008-09-25 Kohei Yoshida <kyoshida novell com>
* patches/dev300/apply: added one patch and removed one.
* patches/dev300/calc-external-defined-names-svtools.diff: added yet
another patch for the svtools to handle merging of number formats from
external documents.
* patches/dev300/calc-external-defined-names-sc.diff: updated with more
change from mooxlsc cws.
* patches/vba/a1-address-handle-spaces.diff: removed as it is merged
with calc-external-defined-names-sc.diff.
Added:
trunk/patches/dev300/calc-external-defined-names-svtools.diff
Removed:
trunk/patches/vba/a1-address-handle-spaces.diff
Modified:
trunk/ChangeLog
trunk/patches/dev300/apply
trunk/patches/dev300/calc-external-defined-names-sc.diff
Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply (original)
+++ trunk/patches/dev300/apply Thu Sep 25 18:37:17 2008
@@ -1776,9 +1776,8 @@
calc-external-defined-names-sc.diff, i#3740, i#4385, n#355685, kohei
calc-external-defined-names-offapi.diff, i#3740, i#4385, n#355685, kohei
calc-external-defined-names-officecfg.diff, i#3740, i#4385, n#355685, kohei
+calc-external-defined-names-svtools.diff, i#3740, i#4385, n#355685, kohei
-# allow spaces in a1 range strings
-a1-address-handle-spaces.diff
[ CalcSolver ]
SectionOwner => kohei
Modified: trunk/patches/dev300/calc-external-defined-names-sc.diff
==============================================================================
--- trunk/patches/dev300/calc-external-defined-names-sc.diff (original)
+++ trunk/patches/dev300/calc-external-defined-names-sc.diff Thu Sep 25 18:37:17 2008
@@ -289,10 +289,10 @@
diff --git sc/inc/externalrefmgr.hxx sc/inc/externalrefmgr.hxx
new file mode 100644
-index 0000000..1e1ddea
+index 0000000..fa2bd9e
--- /dev/null
+++ sc/inc/externalrefmgr.hxx
-@@ -0,0 +1,507 @@
+@@ -0,0 +1,524 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -332,6 +332,7 @@
+#include "sfx2/lnkbase.hxx"
+#include "tools/time.hxx"
+#include "vcl/timer.hxx"
++#include "svtools/zforlist.hxx"
+#include "scmatrix.hxx"
+
+#include <hash_map>
@@ -423,6 +424,7 @@
+ TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex = NULL) const;
+ void getAllRows(::std::vector<SCROW>& rRows) const;
+ void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols) const;
++ void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
+
+ private:
+ RowsDataType maRows;
@@ -480,6 +482,7 @@
+ void initializeDoc(sal_uInt16 nFileId, const ::std::vector<String>& rTabNames);
+ String getTableName(sal_uInt16 nFileId, size_t nCacheId) const;
+ void getAllTableNames(sal_uInt16 nFileId, ::std::vector<String>& rTabNames) const;
++ void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
+ bool hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const;
+ size_t getCacheTableCount(sal_uInt16 nFileId) const;
+
@@ -589,6 +592,7 @@
+ typedef ::std::hash_set<sal_uInt16> LinkedDocSet;
+
+ typedef ::std::hash_map<sal_uInt16, RefCells> RefCellMap;
++ typedef ::std::hash_map<sal_uInt16, SvNumberFormatterMergeMap> NumFmtMap;
+
+public:
+ /** Source document meta-data container. */
@@ -635,6 +639,15 @@
+ */
+ ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const String& rTabName, bool bCreateNew, size_t* pnIndex = 0);
+ void getAllCachedTableNames(sal_uInt16 nFileId, ::std::vector<String>& rTabNames) const;
++
++ /**
++ * Get all unique number format indices that are used in the cache tables.
++ * The retrieved indices are sorted in ascending order.
++ *
++ * @param rNumFmts (reference) all unique number format indices.
++ */
++ void getAllCachedNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
++
+ bool hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const;
+ size_t getCacheTableCount(sal_uInt16 nFileId) const;
+ sal_uInt16 getExternalFileCount() const;
@@ -770,6 +783,8 @@
+ */
+ void purgeStaleSrcDocument(sal_Int32 nTimeOut);
+
++ sal_uInt32 getMappedNumberFormat(sal_uInt16 nFileId, sal_uInt32 nNumFmt, ScDocument* pSrcDoc);
++
+private:
+ /** cache of referenced ranges and names from source documents. */
+ ScExternalRefCache maRefCache;
@@ -791,6 +806,8 @@
+ */
+ RefCellMap maRefCells;
+
++ NumFmtMap maNumFormatMap;
++
+ /** original source file index. */
+ ::std::vector<SrcFileData> maSrcFiles;
+
@@ -992,6 +1009,28 @@
};
inline void SingleRefData::InitAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
+diff --git sc/inc/scmatrix.hxx sc/inc/scmatrix.hxx
+index dbe8bc7..0f2fcb1 100644
+--- sc/inc/scmatrix.hxx
++++ sc/inc/scmatrix.hxx
+@@ -115,11 +115,14 @@ class ScMatrix
+
+ public:
+
+- /// The maximum number of elements a matrix may have at runtime
++ /// The maximum number of elements a matrix may have at runtime.
+ inline static size_t GetElementsMax()
+ {
+- const size_t nMemMax = (((size_t)(~0))-64) / sizeof(ScMatrixValue);
+- const size_t nArbitraryLimit = 0x80000; // 512k elements ~= 4MB memory
++ // Roughly 125MB in total, divided by 8+1 per element => 14M elements.
++ const size_t nMemMax = 0x08000000 / (sizeof(ScMatrixValue) + sizeof(ScMatValType));
++ // With MAXROWCOUNT==65536 and 128 columns => 8M elements ~72MB.
++ const size_t nArbitraryLimit = (size_t)MAXROWCOUNT * 128;
++ // Stuffed with a million rows would limit this to 14 columns.
+ return nMemMax < nArbitraryLimit ? nMemMax : nArbitraryLimit;
+ }
+
diff --git sc/inc/token.hxx sc/inc/token.hxx
index ded3a94..bc7e993 100644
--- sc/inc/token.hxx
@@ -1408,7 +1447,7 @@
void ScHyperLink();
void ScBahtText();
diff --git sc/source/core/tool/address.cxx sc/source/core/tool/address.cxx
-index 2cb5dce..44c84c0 100644
+index c92f4aa..2d0bfd1 100644
--- sc/source/core/tool/address.cxx
+++ sc/source/core/tool/address.cxx
@@ -35,12 +35,15 @@
@@ -1477,7 +1516,19 @@
static long int
sal_Unicode_strtol ( const sal_Unicode* p,
const sal_Unicode** pEnd )
-@@ -102,31 +148,18 @@ sal_Unicode_strtol ( const sal_Unicode* p,
+@@ -99,34 +145,30 @@ sal_Unicode_strtol ( const sal_Unicode* p,
+ return is_neg ? -accum : accum;
+ }
+
++const sal_Unicode* lcl_eatWhiteSpace( const sal_Unicode* p )
++{
++ if ( p )
++ {
++ while( *p == ' ' )
++ ++p;
++ }
++ return p;
++}
// Returns NULL if the string should be a sheet name, but is invalid
// Returns a pointer to the first character after the sheet name
static const sal_Unicode *
@@ -1512,7 +1563,7 @@
return NULL;
}
else
-@@ -190,26 +223,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode *start,
+@@ -190,26 +232,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode *start,
aTabName.Append( start, sal::static_int_cast<xub_StrLen>( p - start ) );
}
@@ -1540,7 +1591,7 @@
return p;
}
-@@ -220,46 +234,71 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
+@@ -220,46 +243,71 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
String& rExternDocName,
String& rStartTabName,
String& rEndTabName,
@@ -1633,7 +1684,7 @@
if( NULL == p )
return start; // invalid tab
if( p != startTabs )
-@@ -267,9 +306,12 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
+@@ -267,9 +315,12 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
nFlags |= SCA_VALID_TAB | SCA_TAB_3D | SCA_TAB_ABSOLUTE;
if( *p == ':' ) // 3d ref
{
@@ -1647,7 +1698,7 @@
nFlags |= SCA_VALID_TAB2 | SCA_TAB2_3D | SCA_TAB2_ABSOLUTE;
}
else
-@@ -281,7 +323,13 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
+@@ -281,7 +332,15 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
}
if( *p++ != '!' )
@@ -1658,10 +1709,12 @@
+ nFlags = nSaveFlags;
return start; // syntax error
+ }
++ else
++ p = lcl_eatWhiteSpace( p );
}
else
{
-@@ -289,45 +337,39 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
+@@ -289,45 +348,39 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
// Use the current tab, it needs to be passed in. : r.aEnd.SetTab( .. );
}
@@ -1733,7 +1786,7 @@
}
-@@ -427,7 +469,8 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -427,7 +480,8 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
const sal_Unicode* p,
ScDocument* pDoc,
const ScAddress::Details& rDetails,
@@ -1743,7 +1796,7 @@
{
const sal_Unicode* pTmp = NULL;
String aExternDocName, aStartTabName, aEndTabName;
-@@ -441,7 +484,19 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -441,7 +495,19 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
}
#endif
p = lcl_ScRange_Parse_XL_Header( r, p, pDoc,
@@ -1764,7 +1817,7 @@
if( NULL == p )
return 0;
-@@ -480,8 +535,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -480,8 +546,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
r.aStart.SetCol( 0 );
r.aEnd.SetCol( MAXCOL );
@@ -1774,7 +1827,7 @@
}
else if( NULL == (p = lcl_r1c1_get_col( p, rDetails, &r.aStart, &nFlags )))
goto failed;
-@@ -501,8 +555,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -501,8 +566,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
return nFlags;
}
@@ -1784,7 +1837,7 @@
}
p = pTmp;
-@@ -517,8 +570,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -517,8 +581,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
}
nFlags |= (nFlags2 << 4);
@@ -1794,7 +1847,7 @@
}
else if( *p == 'C' || *p == 'c' ) // full col C#
{
-@@ -550,8 +602,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -550,8 +613,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
r.aStart.SetRow( 0 );
r.aEnd.SetRow( MAXROW );
@@ -1804,7 +1857,7 @@
}
failed :
-@@ -604,11 +655,18 @@ static USHORT
+@@ -604,11 +666,18 @@ static USHORT
lcl_ScRange_Parse_XL_A1( ScRange& r,
const sal_Unicode* p,
ScDocument* pDoc,
@@ -1825,7 +1878,7 @@
#if 0
{
-@@ -618,7 +676,19 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -618,7 +687,19 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
}
#endif
p = lcl_ScRange_Parse_XL_Header( r, p, pDoc,
@@ -1846,7 +1899,20 @@
if( NULL == p )
return 0;
-@@ -640,8 +710,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -629,8 +710,12 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+ return 0;
+
+ tmp1 = lcl_a1_get_row( p, &r.aStart, &nFlags );
++
++ tmp1 = lcl_eatWhiteSpace( tmp1 );
+ if( !tmp1 || *tmp1++ != ':' ) // Even a singleton requires ':' (eg 2:2)
+ return 0;
++
++ tmp1 = lcl_eatWhiteSpace( tmp1 );
+ tmp2 = lcl_a1_get_row( tmp1, &r.aEnd, &nFlags2 );
+ if( !tmp2 )
+ return 0;
+@@ -640,8 +725,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
SCA_VALID_COL | SCA_VALID_COL2 |
SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE;
nFlags |= (nFlags2 << 4);
@@ -1856,7 +1922,19 @@
}
tmp2 = lcl_a1_get_row( tmp1, &r.aStart, &nFlags );
-@@ -661,8 +730,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -650,8 +734,11 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+ if( bOnlyAcceptSingle ) // by definition full col refs are ranges
+ return 0;
+
++ tmp1 = lcl_eatWhiteSpace( tmp1 );
+ if( *tmp1++ != ':' ) // Even a singleton requires ':' (eg F:F)
+ return 0;
++
++ tmp1 = lcl_eatWhiteSpace( tmp1 );
+ tmp2 = lcl_a1_get_col( tmp1, &r.aEnd, &nFlags2 );
+ if( !tmp2 )
+ return 0;
+@@ -661,8 +748,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
SCA_VALID_ROW | SCA_VALID_ROW2 |
SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE;
nFlags |= (nFlags2 << 4);
@@ -1866,7 +1944,7 @@
}
// prepare as if it's a singleton, in case we want to fall back */
-@@ -672,8 +740,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -672,8 +758,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
if ( bOnlyAcceptSingle )
{
if ( *tmp2 == 0 )
@@ -1876,9 +1954,21 @@
else
{
// any trailing invalid character must invalidate the address.
-@@ -692,12 +759,11 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -682,6 +767,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+ }
+ }
+
++ tmp2 = lcl_eatWhiteSpace( tmp2 );
+ if( *tmp2 != ':' )
+ {
+ nFlags &= ~(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB |
+@@ -690,14 +776,14 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+ }
+
p = tmp2;
- tmp1 = lcl_a1_get_col( p+1, &r.aEnd, &nFlags2 );
+- tmp1 = lcl_a1_get_col( p+1, &r.aEnd, &nFlags2 );
++ p = lcl_eatWhiteSpace( p+1 );
++ tmp1 = lcl_a1_get_col( p, &r.aEnd, &nFlags2 );
if( !tmp1 ) // strange, but valid singleton
- return lcl_XL_LinkSheetRef( r, pDoc,
- aExternDocName, aStartTabName, aEndTabName, nFlags );
@@ -1892,7 +1982,7 @@
if ( *tmp2 != 0 )
{
-@@ -708,45 +774,31 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -708,45 +794,31 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
}
nFlags |= (nFlags2 << 4);
@@ -1951,7 +2041,7 @@
}
SCCOL nCol = 0;
-@@ -762,25 +814,11 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
+@@ -762,25 +834,11 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
if (*p == '$')
nRes |= SCA_TAB_ABSOLUTE, p++;
@@ -1982,7 +2072,7 @@
while (*p)
{
-@@ -795,35 +833,11 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
+@@ -795,35 +853,11 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
}
if( *p++ != '.' )
nBits = 0;
@@ -2022,7 +2112,7 @@
}
else
nBits = 0;
-@@ -884,16 +898,31 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
+@@ -884,16 +918,31 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
if( !nBits )
p = q;
}
@@ -2060,7 +2150,7 @@
if ( !(nRes & SCA_VALID_ROW) && (nRes & SCA_VALID_COL)
&& !( (nRes & SCA_TAB_3D) && (nRes & SCA_VALID_TAB)) )
{ // keine Row, keine Tab, aber Col => DM (...), B (...) o.ae.
-@@ -912,9 +941,10 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
+@@ -912,9 +961,10 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
}
static USHORT
@@ -2074,7 +2164,7 @@
{
if( !*p )
return 0;
-@@ -924,20 +954,22 @@ lcl_ScAddress_Parse ( BOOL& bExternal, const sal_Unicode* p,
+@@ -924,20 +974,22 @@ lcl_ScAddress_Parse ( BOOL& bExternal, const sal_Unicode* p,
default :
case ScAddress::CONV_OOO:
{
@@ -2100,7 +2190,7 @@
rAddr = r.aStart;
return nFlags;
}
-@@ -949,9 +981,8 @@ bool ConvertSingleRef( ScDocument* pDoc, const String& rRefString,
+@@ -949,9 +1001,8 @@ bool ConvertSingleRef( ScDocument* pDoc, const String& rRefString,
SCTAB nDefTab, ScRefAddress& rRefAddress,
const ScAddress::Details& rDetails )
{
@@ -2111,7 +2201,7 @@
if( nRes & SCA_VALID )
{
rRefAddress.Set( aAddr,
-@@ -988,10 +1019,11 @@ bool ConvertDoubleRef( ScDocument* pDoc, const String& rRefString, SCTAB nDefTab
+@@ -988,10 +1039,11 @@ bool ConvertDoubleRef( ScDocument* pDoc, const String& rRefString, SCTAB nDefTab
USHORT ScAddress::Parse( const String& r, ScDocument* pDoc,
@@ -2126,7 +2216,7 @@
}
-@@ -1060,7 +1092,7 @@ void ScRange::ExtendTo( const ScRange& rRange )
+@@ -1060,7 +1112,7 @@ void ScRange::ExtendTo( const ScRange& rRange )
}
static USHORT
@@ -2135,7 +2225,7 @@
{
USHORT nRes1 = 0, nRes2 = 0;
xub_StrLen nTmp = 0;
-@@ -1073,13 +1105,12 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc )
+@@ -1073,13 +1125,12 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc )
String aTmp( r );
sal_Unicode* p = aTmp.GetBufferAccess();
p[ nPos ] = 0;
@@ -2152,7 +2242,7 @@
nRes2 &= ~SCA_VALID_TAB; // #REF!
else
{
-@@ -1132,7 +1163,9 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc )
+@@ -1132,7 +1183,9 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc )
}
USHORT ScRange::Parse( const String& r, ScDocument* pDoc,
@@ -2163,7 +2253,7 @@
{
if ( r.Len() <= 0 )
return 0;
-@@ -1141,13 +1174,15 @@ USHORT ScRange::Parse( const String& r, ScDocument* pDoc,
+@@ -1141,13 +1194,15 @@ USHORT ScRange::Parse( const String& r, ScDocument* pDoc,
{
default :
case ScAddress::CONV_OOO:
@@ -2182,7 +2272,7 @@
}
}
-@@ -1187,6 +1222,7 @@ USHORT ScRange::ParseCols( const String& rStr, ScDocument* pDoc,
+@@ -1187,6 +1242,7 @@ USHORT ScRange::ParseCols( const String& rStr, ScDocument* pDoc,
default :
case ScAddress::CONV_OOO: // No full col refs in OOO yet, assume XL notation
case ScAddress::CONV_XL_A1:
@@ -2190,7 +2280,7 @@
if (NULL != (p = lcl_a1_get_col( p, &aStart, &ignored ) ) )
{
if( p[0] == ':')
-@@ -1245,6 +1281,7 @@ USHORT ScRange::ParseRows( const String& rStr, ScDocument* pDoc,
+@@ -1245,6 +1301,7 @@ USHORT ScRange::ParseRows( const String& rStr, ScDocument* pDoc,
default :
case ScAddress::CONV_OOO: // No full row refs in OOO yet, assume XL notation
case ScAddress::CONV_XL_A1:
@@ -2198,7 +2288,7 @@
if (NULL != (p = lcl_a1_get_row( p, &aStart, &ignored ) ) )
{
if( p[0] == ':')
-@@ -1429,6 +1466,7 @@ void ScAddress::Format( String& r, USHORT nFlags, ScDocument* pDoc,
+@@ -1429,6 +1486,7 @@ void ScAddress::Format( String& r, USHORT nFlags, ScDocument* pDoc,
case CONV_XL_A1:
case CONV_XL_R1C1:
@@ -2206,7 +2296,7 @@
if (aDocName.Len() > 0)
{
r += '[';
-@@ -1446,6 +1484,7 @@ void ScAddress::Format( String& r, USHORT nFlags, ScDocument* pDoc,
+@@ -1446,6 +1504,7 @@ void ScAddress::Format( String& r, USHORT nFlags, ScDocument* pDoc,
default :
case CONV_OOO:
case CONV_XL_A1:
@@ -2214,7 +2304,7 @@
if( nFlags & SCA_VALID_COL )
lcl_a1_append_c ( r, nCol, nFlags & SCA_COL_ABSOLUTE );
if( nFlags & SCA_VALID_ROW )
-@@ -1565,6 +1604,7 @@ void ScRange::Format( String& r, USHORT nFlags, ScDocument* pDoc,
+@@ -1565,6 +1624,7 @@ void ScRange::Format( String& r, USHORT nFlags, ScDocument* pDoc,
break;
case ScAddress::CONV_XL_A1:
@@ -2222,7 +2312,7 @@
lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails );
if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL )
{
-@@ -1688,6 +1728,7 @@ String ScAddress::GetColRowString( bool bAbsolute,
+@@ -1688,6 +1748,7 @@ String ScAddress::GetColRowString( bool bAbsolute,
default :
case ScAddress::CONV_OOO:
case ScAddress::CONV_XL_A1:
@@ -3772,7 +3862,7 @@
rBuffer.append(sal_Unicode(' '));
if ( bAllowArrAdvance )
diff --git sc/source/core/tool/interpr4.cxx sc/source/core/tool/interpr4.cxx
-index 5f6faa3..a59792f 100644
+index 5f6faa3..c70d42d 100644
--- sc/source/core/tool/interpr4.cxx
+++ sc/source/core/tool/interpr4.cxx
@@ -7,7 +7,7 @@
@@ -3792,7 +3882,7 @@
using namespace com::sun::star;
-@@ -2980,6 +2981,81 @@ void ScInterpreter::ScColRowNameAuto()
+@@ -2980,6 +2981,82 @@ void ScInterpreter::ScColRowNameAuto()
PushError( errNoRef );
}
@@ -3823,13 +3913,7 @@
+ if (!xNew)
+ break;
+
-+ if (xNew->GetType() == svString)
-+ PushString(xNew->GetString());
-+ else if (xNew->GetType() == svDouble)
-+ PushDouble(xNew->GetDouble());
-+ else
-+ // Cell in the source doc is empty. Put 0.
-+ PushInt(0);
++ PushTempToken( *xNew); // push a clone
+
+ if (aFmt.mbIsSet)
+ {
@@ -3861,6 +3945,13 @@
+ if (p->GetType() != svMatrix)
+ break;
+
++ if (xNew->Next())
++ {
++ // Can't handle more than one matrix per parameter.
++ SetError( errIllegalArgument);
++ break;
++ }
++
+ PushMatrix(p->GetMatrix());
+ return;
+ }
@@ -3874,7 +3965,7 @@
// --- internals ------------------------------------------------------------
-@@ -3412,6 +3488,7 @@ StackVar ScInterpreter::Interpret()
+@@ -3412,6 +3489,7 @@ StackVar ScInterpreter::Interpret()
case ocDBArea : ScDBArea(); break;
case ocColRowNameAuto : ScColRowNameAuto(); break;
// separated case ocPush : Push( (ScToken&) *pCur ); break;
@@ -4945,7 +5036,7 @@
void ExcelToSc8::ExcRelToScRel8( UINT16 nRow, UINT16 nC, SingleRefData &rSRD, const BOOL bName )
{
diff --git sc/source/filter/excel/read.cxx sc/source/filter/excel/read.cxx
-index 2cc592c..7f1c44b 100644
+index eea6293..a868e17 100644
--- sc/source/filter/excel/read.cxx
+++ sc/source/filter/excel/read.cxx
@@ -967,7 +967,7 @@ FltError ImportExcel8::Read( void )
@@ -5101,7 +5192,7 @@
diff --git sc/source/filter/excel/xeformula.cxx sc/source/filter/excel/xeformula.cxx
-index 3db8da7..6488f69 100644
+index 3db8da7..dd46fd7 100644
--- sc/source/filter/excel/xeformula.cxx
+++ sc/source/filter/excel/xeformula.cxx
@@ -42,6 +42,11 @@
@@ -5182,7 +5273,7 @@
+ USHORT nFileId = rTokData.mpScToken->GetIndex();
+ switch (eType)
+ {
-+ case svSingleRef:
++ case svExternalSingleRef:
+ {
+ if (!mpScBasePos)
+ {
@@ -5218,7 +5309,7 @@
+ AppendAddress(aXclPos);
+ }
+ break;
-+ case svDoubleRef:
++ case svExternalDoubleRef:
+ {
+ if (!mpScBasePos)
+ {
@@ -7497,7 +7588,7 @@
const sal_Int32 nCol, const sal_Int32 nRow,
com::sun::star::table::CellRangeAddress& aCellAddress) const;
diff --git sc/source/filter/xml/xmldpimp.cxx sc/source/filter/xml/xmldpimp.cxx
-index e29223a..604e04e 100644
+index ea577d2..38bd639 100644
--- sc/source/filter/xml/xmldpimp.cxx
+++ sc/source/filter/xml/xmldpimp.cxx
@@ -65,6 +65,7 @@
@@ -7509,7 +7600,7 @@
//------------------------------------------------------------------
diff --git sc/source/filter/xml/xmlexprt.cxx sc/source/filter/xml/xmlexprt.cxx
-index 441f463..67c2758 100644
+index fcf3e8b..88449bc 100644
--- sc/source/filter/xml/xmlexprt.cxx
+++ sc/source/filter/xml/xmlexprt.cxx
@@ -68,6 +68,7 @@
@@ -7550,7 +7641,82 @@
sAttrName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NAME));
sAttrStyleName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_STYLE_NAME));
sAttrColumnsRepeated = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NUMBER_COLUMNS_REPEATED));
-@@ -1422,180 +1432,181 @@ void ScXMLExport::_ExportContent()
+@@ -525,6 +535,15 @@ ScXMLExport::~ScXMLExport()
+ delete pNumberFormatAttributesExportHelper;
+ }
+
++sal_Int32 ScXMLExport::GetNumberFormatStyleIndex(sal_Int32 nNumFmt) const
++{
++ NumberFormatIndexMap::const_iterator itr = aNumFmtIndexMap.find(nNumFmt);
++ if (itr == aNumFmtIndexMap.end())
++ return -1;
++
++ return itr->second;
++}
++
+ sal_Bool ScXMLExport::HasDrawPages(uno::Reference <sheet::XSpreadsheetDocument>& xDoc)
+ {
+ uno::Reference <beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
+@@ -1019,6 +1038,58 @@ void ScXMLExport::ExportColumns(const sal_Int32 nTable, const table::CellRangeAd
+ pGroupColumns->CloseGroups(nColumn - 1);
+ }
+
++void ScXMLExport::ExportExternalRefCacheStyles()
++{
++ sal_Int32 nEntryIndex = GetCellStylesPropertySetMapper()->FindEntryIndex(
++ "NumberFormat", XML_NAMESPACE_STYLE, OUString::createFromAscii("data-style-name"));
++
++ if (nEntryIndex < 0)
++ // No entry index for the number format is found.
++ return;
++
++ ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
++ if (!pRefMgr->hasExternalData())
++ // No external reference data cached.
++ return;
++
++ // Export each unique number format used in the external ref cache.
++ vector<sal_uInt32> aNumFmts;
++ pRefMgr->getAllCachedNumberFormats(aNumFmts);
++ const OUString aDefaultStyle = OUString::createFromAscii("Default").intern();
++ for (vector<sal_uInt32>::const_iterator itr = aNumFmts.begin(), itrEnd = aNumFmts.end();
++ itr != itrEnd; ++itr)
++ {
++ sal_Int32 nNumFmt = static_cast<sal_Int32>(*itr);
++
++ addDataStyle(nNumFmt);
++
++ uno::Any aVal;
++ aVal <<= nNumFmt;
++ vector<XMLPropertyState> aProps;
++ aProps.push_back(XMLPropertyState(nEntryIndex, aVal));
++ aVal <<= aDefaultStyle;
++ aProps.push_back(XMLPropertyState(nEntryIndex, aVal));
++
++ OUString aName;
++ sal_Int32 nIndex;
++ if (GetAutoStylePool()->Add(aName, XML_STYLE_FAMILY_TABLE_CELL, aDefaultStyle, aProps))
++ {
++ OUString* pTemp(new OUString(aName));
++ if (!pCellStyles->AddStyleName(pTemp, nIndex, true))
++ delete pTemp;
++ }
++ else
++ {
++ sal_Bool bIsAuto;
++ nIndex = pCellStyles->GetIndexOfStyleName(
++ aName, OUString::createFromAscii(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX), bIsAuto);
++ }
++
++ // store the number format to index mapping for later use.
++ aNumFmtIndexMap.insert(NumberFormatIndexMap::value_type(nNumFmt, nIndex));
++ }
++}
++
+ void ScXMLExport::WriteRowContent()
+ {
+ ScMyRowFormatRange aRange;
+@@ -1422,180 +1493,181 @@ void ScXMLExport::_ExportContent()
DBG_ERROR("no shared data setted");
}
ScXMLExportDatabaseRanges aExportDatabaseRanges(*this);
@@ -7898,7 +8064,16 @@
}
void ScXMLExport::_ExportStyles( sal_Bool bUsed )
-@@ -2000,6 +2011,15 @@ void ScXMLExport::_ExportAutoStyles()
+@@ -1671,6 +1743,8 @@ void ScXMLExport::_ExportAutoStyles()
+ {
+ if (getExportFlags() & EXPORT_CONTENT)
+ {
++ ExportExternalRefCacheStyles();
++
+ if (!pSharedData)
+ {
+ sal_Int32 nTableCount(0);
+@@ -2000,6 +2074,15 @@ void ScXMLExport::_ExportAutoStyles()
GetShapeExport()->exportAutoStyles();
GetFormExport()->exportAutoStyles( );
@@ -7914,7 +8089,7 @@
}
if (getExportFlags() & EXPORT_MASTERSTYLES)
{
-@@ -2992,7 +3012,7 @@ sal_Bool ScXMLExport::IsCellEqual (ScMyCell& aCell1, ScMyCell& aCell2)
+@@ -3003,7 +3086,7 @@ sal_Bool ScXMLExport::IsCellEqual (ScMyCell& aCell1, ScMyCell& aCell2)
}
// #i29101# number format may be different from column default styles,
// but can lead to different value types, so it must also be compared
@@ -7923,7 +8098,7 @@
(aCell1.fValue == aCell2.fValue);
}
break;
-@@ -3333,6 +3353,184 @@ void ScXMLExport::WriteNamedExpressions(const com::sun::star::uno::Reference <co
+@@ -3344,6 +3427,192 @@ void ScXMLExport::WriteNamedExpressions(const com::sun::star::uno::Reference <co
}
}
@@ -8066,10 +8241,18 @@
+ }
+
+ // Write out this cell.
-+ ScExternalRefCache::TokenRef pToken = pTable->getCell(nCol, nRow);
++ sal_uInt32 nNumFmt = 0;
++ ScExternalRefCache::TokenRef pToken = pTable->getCell(nCol, nRow, &nNumFmt);
+ OUString aStrVal;
+ if (pToken.get())
+ {
++ sal_Int32 nIndex = GetNumberFormatStyleIndex(nNumFmt);
++ if (nIndex >= 0)
++ {
++ const OUString aStyleName = *pCellStyles->GetStyleNameByIndex(nIndex, true);
++ AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, aStyleName);
++ }
++
+ switch(pToken->GetType())
+ {
+ case svDouble:
@@ -8109,10 +8292,28 @@
void ScXMLExport::WriteConsolidation()
{
diff --git sc/source/filter/xml/xmlexprt.hxx sc/source/filter/xml/xmlexprt.hxx
-index 47171b6..e8477e5 100644
+index e4fcc10..a6385f1 100644
--- sc/source/filter/xml/xmlexprt.hxx
+++ sc/source/filter/xml/xmlexprt.hxx
-@@ -98,6 +98,7 @@ class ScXMLExport : public SvXMLExport
+@@ -38,6 +38,8 @@
+ #include <com/sun/star/drawing/XShapes.hpp>
+ #include <com/sun/star/table/XCellRange.hpp>
+
++#include <hash_map>
++
+ class ScOutlineArray;
+ class SvXMLExportPropertyMapper;
+ class ScMyShapesContainer;
+@@ -80,6 +82,8 @@ class ScXMLExport : public SvXMLExport
+ UniReference < SvXMLExportPropertyMapper > xRowStylesExportPropertySetMapper;
+ UniReference < SvXMLExportPropertyMapper > xTableStylesExportPropertySetMapper;
+ XMLNumberFormatAttributesExportHelper* pNumberFormatAttributesExportHelper;
++ typedef ::std::hash_map<sal_Int32, sal_Int32> NumberFormatIndexMap;
++ NumberFormatIndexMap aNumFmtIndexMap;
+ ScMySharedData* pSharedData;
+ ScColumnStyles* pColumnStyles;
+ ScRowStyles* pRowStyles;
+@@ -99,6 +103,7 @@ class ScXMLExport : public SvXMLExport
ScChangeTrackingExportHelper* pChangeTrackingExportHelper;
const rtl::OUString sLayerID;
const rtl::OUString sCaptionShape;
@@ -8120,7 +8321,24 @@
rtl::OUString sAttrName;
rtl::OUString sAttrStyleName;
rtl::OUString sAttrColumnsRepeated;
-@@ -195,6 +196,7 @@ class ScXMLExport : public SvXMLExport
+@@ -118,7 +123,7 @@ class ScXMLExport : public SvXMLExport
+ sal_Bool bRowHeaderOpen;
+ sal_Bool mbShowProgress;
+
+-
++ sal_Int32 GetNumberFormatStyleIndex(sal_Int32 nNumFmt) const;
+ sal_Bool HasDrawPages(com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheetDocument>& xDoc);
+ void CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCount, const sal_Int32 nCellCount);
+ void CollectShapesAutoStyles(const sal_Int32 nTableCount);
+@@ -146,6 +151,7 @@ class ScXMLExport : public SvXMLExport
+ void OpenHeaderColumn();
+ void CloseHeaderColumn();
+ void ExportColumns(const sal_Int32 nTable, const com::sun::star::table::CellRangeAddress& aColumnHeaderRange, const sal_Bool bHasColumnHeader);
++ void ExportExternalRefCacheStyles();
+ void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow,
+ const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet);
+ void WriteRowContent();
+@@ -196,6 +202,7 @@ class ScXMLExport : public SvXMLExport
void WriteTheLabelRanges(const com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheetDocument >& xSpreadDoc);
void WriteLabelRanges( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xRangesIAccess, sal_Bool bColumn );
void WriteNamedExpressions(const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc);
@@ -8130,10 +8348,10 @@
void CollectUserDefinedNamespaces(const SfxItemPool* pPool, sal_uInt16 nAttrib);
diff --git sc/source/filter/xml/xmlexternaltabi.cxx sc/source/filter/xml/xmlexternaltabi.cxx
new file mode 100644
-index 0000000..aae20c2
+index 0000000..f4e42be
--- /dev/null
+++ sc/source/filter/xml/xmlexternaltabi.cxx
-@@ -0,0 +1,343 @@
+@@ -0,0 +1,355 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -8174,6 +8392,7 @@
+#include "xmlexternaltabi.hxx"
+#include "xmlimprt.hxx"
+#include "xmltabi.hxx"
++#include "xmlstyli.hxx"
+
+#include "token.hxx"
+#include "document.hxx"
@@ -8193,10 +8412,10 @@
+// ============================================================================
+
+ScXMLExternalRefTabSourceContext::ScXMLExternalRefTabSourceContext(
-+ ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName,
++ ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName,
+ const Reference<XAttributeList>& xAttrList, ScXMLExternalTabData& rRefInfo ) :
+ SvXMLImportContext( rImport, nPrefix, rLName ),
-+ mrScImport(rImport),
++ mrScImport(rImport),
+ mrExternalRefInfo(rRefInfo)
+{
+ using namespace ::xmloff::token;
@@ -8250,10 +8469,10 @@
+// ============================================================================
+
+ScXMLExternalRefRowContext::ScXMLExternalRefRowContext(
-+ ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName,
++ ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName,
+ const Reference<XAttributeList>& xAttrList, ScXMLExternalTabData& rRefInfo ) :
+ SvXMLImportContext( rImport, nPrefix, rLName ),
-+ mrScImport(rImport),
++ mrScImport(rImport),
+ mrExternalRefInfo(rRefInfo),
+ mnRepeatRowCount(1)
+{
@@ -8303,11 +8522,11 @@
+ for (sal_Int32 j = 0; j < mrExternalRefInfo.mnCol; ++j)
+ {
+ ScExternalRefCache::TokenRef pToken = pTab->getCell(
-+ static_cast<SCROW>(mrExternalRefInfo.mnRow), static_cast<SCCOL>(j));
++ static_cast<SCCOL>(j), static_cast<SCROW>(mrExternalRefInfo.mnRow));
+
+ if (pToken.get())
+ {
-+ pTab->setCell(static_cast<SCCOL>(j),
++ pTab->setCell(static_cast<SCCOL>(j),
+ static_cast<SCROW>(mrExternalRefInfo.mnRow+i), pToken);
+ }
+ }
@@ -8318,13 +8537,14 @@
+// ============================================================================
+
+ScXMLExternalRefCellContext::ScXMLExternalRefCellContext(
-+ ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName,
++ ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName,
+ const Reference<XAttributeList>& xAttrList, ScXMLExternalTabData& rRefInfo ) :
+ SvXMLImportContext( rImport, nPrefix, rLName ),
-+ mrScImport(rImport),
++ mrScImport(rImport),
+ mrExternalRefInfo(rRefInfo),
+ mfCellValue(0.0),
+ mnRepeatCount(1),
++ mnNumberFormat(-1),
+ mnCellType(::com::sun::star::util::NumberFormat::UNDEFINED),
+ mbIsNumeric(false),
+ mbIsEmpty(true)
@@ -8344,8 +8564,17 @@
+
+ switch (nToken)
+ {
++ case XML_TOK_TABLE_ROW_CELL_ATTR_STYLE_NAME:
++ {
++ XMLTableStylesContext* pStyles = static_cast<XMLTableStylesContext*>(mrScImport.GetAutoStyles());
++ const XMLTableStyleContext* pStyle = static_cast<const XMLTableStyleContext*>(
++ pStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_CELL, sValue, true));
++ if (pStyle)
++ mnNumberFormat = const_cast<XMLTableStyleContext*>(pStyle)->GetNumberFormat();
++ }
++ break;
+ case XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED:
-+ {
++ {
+ mnRepeatCount = ::std::max(sValue.toInt32(), static_cast<sal_Int32>(1));
+ }
+ break;
@@ -8441,20 +8670,21 @@
+ else
+ aToken.reset(new ScStringToken(maCellString));
+
++ sal_uInt32 nNumFmt = mnNumberFormat >= 0 ? static_cast<sal_uInt32>(mnNumberFormat) : 0;
+ mrExternalRefInfo.mpCacheTable->setCell(
-+ static_cast<SCCOL>(mrExternalRefInfo.mnCol),
-+ static_cast<SCROW>(mrExternalRefInfo.mnRow),
-+ aToken);
++ static_cast<SCCOL>(mrExternalRefInfo.mnCol),
++ static_cast<SCROW>(mrExternalRefInfo.mnRow),
++ aToken, nNumFmt);
+ }
+}
+
+// ============================================================================
+
+ScXMLExternalRefCellTextContext::ScXMLExternalRefCellTextContext(
-+ ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName,
++ ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName,
+ const Reference<XAttributeList>& /*xAttrList*/, OUString& rCellString ) :
+ SvXMLImportContext( rImport, nPrefix, rLName ),
-+ mrScImport(rImport),
++ mrScImport(rImport),
+ mrCellString(rCellString)
+{
+}
@@ -8479,10 +8709,10 @@
+}
diff --git sc/source/filter/xml/xmlexternaltabi.hxx sc/source/filter/xml/xmlexternaltabi.hxx
new file mode 100644
-index 0000000..6f26789
+index 0000000..2c3f3fb
--- /dev/null
+++ sc/source/filter/xml/xmlexternaltabi.hxx
-@@ -0,0 +1,149 @@
+@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -8599,6 +8829,7 @@
+ ::rtl::OUString maCellString;
+ double mfCellValue;
+ sal_Int32 mnRepeatCount;
++ sal_Int32 mnNumberFormat;
+ sal_Int16 mnCellType;
+ bool mbIsNumeric;
+ bool mbIsEmpty;
@@ -8633,7 +8864,7 @@
+
+#endif
diff --git sc/source/filter/xml/xmlimprt.cxx sc/source/filter/xml/xmlimprt.cxx
-index 47b26b9..eb74c99 100644
+index 2299598..2ebdc76 100644
--- sc/source/filter/xml/xmlimprt.cxx
+++ sc/source/filter/xml/xmlimprt.cxx
@@ -104,6 +104,7 @@
@@ -8809,6 +9040,87 @@
extern const XMLPropertyMapEntry aXMLScCellStylesProperties[];
extern const XMLPropertyMapEntry aXMLScColumnStylesProperties[];
extern const XMLPropertyMapEntry aXMLScRowStylesProperties[];
+diff --git sc/source/filter/xml/xmlstyli.cxx sc/source/filter/xml/xmlstyli.cxx
+index 6813d0d..9624740 100644
+--- sc/source/filter/xml/xmlstyli.cxx
++++ sc/source/filter/xml/xmlstyli.cxx
+@@ -584,28 +584,10 @@ void XMLTableStyleContext::FillPropertySet(
+ AddProperty(CTF_SC_CELLSTYLE, uno::makeAny(GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TABLE_CELL, GetParentName() )));
+ bParentSet = sal_True;
+ }
+- if ((nNumberFormat == -1) && sDataStyleName.getLength())
+- {
+- SvXMLNumFormatContext* pStyle((SvXMLNumFormatContext *)pStyles->FindStyleChildContext(
+- XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, sal_True));
+- if (!pStyle)
+- {
+- XMLTableStylesContext* pMyStyles((XMLTableStylesContext *)GetScImport().GetStyles());
+- if (pMyStyles)
+- pStyle = (SvXMLNumFormatContext *)pMyStyles->
+- FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, sal_True);
+- else
+- {
+- DBG_ERROR("not possible to get style");
+- }
+- }
+- if (pStyle)
+- {
+- //rPropSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_NUMBERFORMAT)), aNumberFormat);
+- nNumberFormat = pStyle->GetKey();
+- AddProperty(CTF_SC_NUMBERFORMAT, uno::makeAny(nNumberFormat));
+- }
+- }
++ sal_Int32 nNumFmt = GetNumberFormat();
++ if (nNumFmt >= 0)
++ AddProperty(CTF_SC_NUMBERFORMAT, uno::makeAny(nNumFmt));
++
+ if (!bConditionalFormatCreated && (aMaps.size() > 0))
+ {
+ aConditionalFormat = rPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONDXML)));
+@@ -683,6 +665,30 @@ XMLPropertyState* XMLTableStyleContext::FindProperty(const sal_Int16 nContextID)
+ return pRet;
+ }
+
++sal_Int32 XMLTableStyleContext::GetNumberFormat()
++{
++ if (nNumberFormat < 0 && sDataStyleName.getLength())
++ {
++ const SvXMLNumFormatContext* pStyle = static_cast<const SvXMLNumFormatContext*>(
++ pStyles->FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, sal_True));
++
++ if (!pStyle)
++ {
++ XMLTableStylesContext* pMyStyles = static_cast<XMLTableStylesContext*>(GetScImport().GetStyles());
++ if (pMyStyles)
++ pStyle = static_cast<const SvXMLNumFormatContext*>(
++ pMyStyles->FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, sal_True));
++ else
++ {
++ DBG_ERROR("not possible to get style");
++ }
++ }
++ if (pStyle)
++ nNumberFormat = const_cast<SvXMLNumFormatContext*>(pStyle)->GetKey();
++ }
++ return nNumberFormat;
++}
++
+ // ----------------------------------------------------------------------------
+
+ SvXMLStyleContext *XMLTableStylesContext::CreateStyleStyleChildContext(
+diff --git sc/source/filter/xml/xmlstyli.hxx sc/source/filter/xml/xmlstyli.hxx
+index d1d6166..237e8e3 100644
+--- sc/source/filter/xml/xmlstyli.hxx
++++ sc/source/filter/xml/xmlstyli.hxx
+@@ -154,7 +154,7 @@ public:
+ void AddProperty(sal_Int16 nContextID, const com::sun::star::uno::Any& aValue);
+ XMLPropertyState* FindProperty(const sal_Int16 nContextID);
+
+- sal_Int32 GetNumberFormat() { return nNumberFormat; }
++ sal_Int32 GetNumberFormat();
+
+ private:
+ using XMLPropStyleContext::SetStyle;
diff --git sc/source/filter/xml/xmltabi.cxx sc/source/filter/xml/xmltabi.cxx
index 4a0f83e..4dd5a55 100644
--- sc/source/filter/xml/xmltabi.cxx
@@ -9052,10 +9364,10 @@
diff --git sc/source/ui/docshell/externalrefmgr.cxx sc/source/ui/docshell/externalrefmgr.cxx
new file mode 100644
-index 0000000..17037ed
+index 0000000..9dcb2cc
--- /dev/null
+++ sc/source/ui/docshell/externalrefmgr.cxx
-@@ -0,0 +1,1793 @@
+@@ -0,0 +1,1888 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -9269,6 +9581,21 @@
+ rCols.swap(aCols);
+}
+
++void ScExternalRefCache::Table::getAllNumberFormats(vector<sal_uInt32>& rNumFmts) const
++{
++ RowsDataType::const_iterator itrRow = maRows.begin(), itrRowEnd = maRows.end();
++ for (; itrRow != itrRowEnd; ++itrRow)
++ {
++ const RowDataType& rRowData = itrRow->second;
++ RowDataType::const_iterator itrCol = rRowData.begin(), itrColEnd = rRowData.end();
++ for (; itrCol != itrColEnd; ++itrCol)
++ {
++ const Cell& rCell = itrCol->second;
++ rNumFmts.push_back(rCell.mnFmtIndex);
++ }
++ }
++}
++
+// ----------------------------------------------------------------------------
+
+ScExternalRefCache::TableName::TableName(const String& rUpper, const String& rReal) :
@@ -9637,6 +9964,33 @@
+ rTabNames.push_back(itr->maRealName);
+}
+
++void ScExternalRefCache::getAllNumberFormats(vector<sal_uInt32>& rNumFmts) const
++{
++ using ::std::sort;
++ using ::std::unique;
++
++ vector<sal_uInt32> aNumFmts;
++ for (DocDataType::const_iterator itrDoc = maDocs.begin(), itrDocEnd = maDocs.end();
++ itrDoc != itrDocEnd; ++itrDoc)
++ {
++ const vector<TableTypeRef>& rTables = itrDoc->second.maTables;
++ for (vector<TableTypeRef>::const_iterator itrTab = rTables.begin(), itrTabEnd = rTables.end();
++ itrTab != itrTabEnd; ++itrTab)
++ {
++ TableTypeRef pTab = *itrTab;
++ if (!pTab)
++ continue;
++
++ pTab->getAllNumberFormats(aNumFmts);
++ }
++ }
++
++ // remove duplicates.
++ sort(aNumFmts.begin(), aNumFmts.end());
++ aNumFmts.erase(unique(aNumFmts.begin(), aNumFmts.end()), aNumFmts.end());
++ rNumFmts.swap(aNumFmts);
++}
++
+bool ScExternalRefCache::hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const
+{
+ DocItem* pDoc = getDocItem(nFileId);
@@ -9787,41 +10141,50 @@
+
+static ScToken* lcl_convertToToken(ScBaseCell* pCell)
+{
-+ if (!pCell)
-+ return NULL;
++ if (!pCell || pCell->HasEmptyData())
++ {
++ bool bInherited = (pCell && pCell->GetCellType() == CELLTYPE_FORMULA);
++ return new ScEmptyCellToken( bInherited, false);
++ }
+
+ switch (pCell->GetCellType())
+ {
++ case CELLTYPE_EDIT:
++ {
++ String aStr;
++ static_cast<ScEditCell*>(pCell)->GetString(aStr);
++ return new ScStringToken(aStr);
++ }
++ break;
+ case CELLTYPE_STRING:
+ {
+ String aStr;
+ static_cast<ScStringCell*>(pCell)->GetString(aStr);
-+ ScStringToken aToken(aStr);
-+ return aToken.Clone();
++ return new ScStringToken(aStr);
+ }
+ break;
+ case CELLTYPE_VALUE:
+ {
+ double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
-+ ScDoubleToken aToken(fVal);
-+ return aToken.Clone();
++ return new ScDoubleToken(fVal);
+ }
+ break;
+ case CELLTYPE_FORMULA:
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
-+ if (pFCell->IsValue())
++ USHORT nError = pFCell->GetErrCode();
++ if (nError)
++ return new ScErrorToken( nError);
++ else if (pFCell->IsValue())
+ {
+ double fVal = pFCell->GetValue();
-+ ScDoubleToken aToken(fVal);
-+ return aToken.Clone();
++ return new ScDoubleToken(fVal);
+ }
+ else
+ {
+ String aStr;
+ pFCell->GetString(aStr);
-+ ScStringToken aToken(aStr);
-+ return aToken.Clone();
++ return new ScStringToken(aStr);
+ }
+ }
+ break;
@@ -9867,10 +10230,19 @@
+ SCSIZE nC = nCol - nCol1, nR = nRow - nRow1;
+ ScBaseCell* pCell;
+ pSrcDoc->GetCell(nCol, nRow, nTab, pCell);
-+ if (pCell)
++ if (!pCell || pCell->HasEmptyData())
++ xMat->PutEmpty(nC, nR);
++ else
+ {
+ switch (pCell->GetCellType())
+ {
++ case CELLTYPE_EDIT:
++ {
++ String aStr;
++ static_cast<ScEditCell*>(pCell)->GetString(aStr);
++ xMat->PutString(aStr, nC, nR);
++ }
++ break;
+ case CELLTYPE_STRING:
+ {
+ String aStr;
@@ -9887,7 +10259,10 @@
+ case CELLTYPE_FORMULA:
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
-+ if (pFCell->IsValue())
++ USHORT nError = pFCell->GetErrCode();
++ if (nError)
++ xMat->PutDouble( CreateDoubleError( nError), nC, nR);
++ else if (pFCell->IsValue())
+ {
+ double fVal = pFCell->GetValue();
+ xMat->PutDouble(fVal, nC, nR);
@@ -9904,10 +10279,6 @@
+ DBG_ERROR("attempted to convert an unknown cell type.");
+ }
+ }
-+ else
-+ {
-+ xMat->PutEmpty(nC, nR);
-+ }
+ }
+ }
+ if (!bFirstTab)
@@ -10181,6 +10552,11 @@
+ maRefCache.getAllTableNames(nFileId, rTabNames);
+}
+
++void ScExternalRefManager::getAllCachedNumberFormats(vector<sal_uInt32>& rNumFmts) const
++{
++ maRefCache.getAllNumberFormats(rNumFmts);
++}
++
+bool ScExternalRefManager::hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const
+{
+ return maRefCache.hasCacheTable(nFileId, rTabName);
@@ -10225,11 +10601,13 @@
+ {
+ if (pFmt)
+ {
-+ pFmt->mbIsSet = true;
-+ pFmt->mnIndex = nFmtIndex;
-+ SvNumberFormatter* pNumFormat = mpDoc->GetFormatTable();
-+ const SvNumberformat* pEntry = pNumFormat->GetEntry(nFmtIndex);
-+ pFmt->mnType = pEntry ? pEntry->GetType() : NUMBERFORMAT_ALL;
++ short nFmtType = mpDoc->GetFormatTable()->GetType(nFmtIndex);
++ if (nFmtType != NUMBERFORMAT_UNDEFINED)
++ {
++ pFmt->mbIsSet = true;
++ pFmt->mnIndex = nFmtIndex;
++ pFmt->mnType = nFmtType;
++ }
+ }
+ return pToken;
+ }
@@ -10256,20 +10634,22 @@
+ ScExternalRefCache::TokenRef pTok(lcl_convertToToken(pCell));
+
+ pSrcDoc->GetNumberFormat(rCell.Col(), rCell.Row(), nTab, nFmtIndex);
-+
++ nFmtIndex = getMappedNumberFormat(nFileId, nFmtIndex, pSrcDoc);
+ if (pFmt)
+ {
-+ pFmt->mbIsSet = true;
-+ pFmt->mnIndex = nFmtIndex;
-+ SvNumberFormatter* pNumFormat = pSrcDoc->GetFormatTable();
-+ const SvNumberformat* pEntry = pNumFormat->GetEntry(nFmtIndex);
-+ pFmt->mnType = pEntry ? pEntry->GetType() : NUMBERFORMAT_ALL;
++ short nFmtType = mpDoc->GetFormatTable()->GetType(nFmtIndex);
++ if (nFmtType != NUMBERFORMAT_UNDEFINED)
++ {
++ pFmt->mbIsSet = true;
++ pFmt->mnIndex = nFmtIndex;
++ pFmt->mnType = nFmtType;
++ }
+ }
+
+ if (!pTok.get())
+ {
-+ // Cell in the source document is probably empty.
-+ pTok.reset(new ScEmptyCellToken(false, false));
++ // Generate an error for unresolvable cells.
++ pTok.reset( new ScErrorToken( errNoValue));
+ }
+
+ // Now, insert the token into cache table.
@@ -10841,6 +11221,33 @@
+ maSrcDocTimer.Stop();
+}
+
++sal_uInt32 ScExternalRefManager::getMappedNumberFormat(sal_uInt16 nFileId, sal_uInt32 nNumFmt, ScDocument* pSrcDoc)
++{
++ NumFmtMap::iterator itr = maNumFormatMap.find(nFileId);
++ if (itr == maNumFormatMap.end())
++ {
++ // Number formatter map is not initialized for this external document.
++ pair<NumFmtMap::iterator, bool> r = maNumFormatMap.insert(
++ NumFmtMap::value_type(nFileId, SvNumberFormatterMergeMap()));
++
++ if (!r.second)
++ // insertion failed.
++ return nNumFmt;
++
++ itr = r.first;
++ mpDoc->GetFormatTable()->MergeFormatter( *pSrcDoc->GetFormatTable());
++ SvNumberFormatterMergeMap aMap = mpDoc->GetFormatTable()->ConvertMergeTableToMap();
++ itr->second.swap(aMap);
++ }
++ const SvNumberFormatterMergeMap& rMap = itr->second;
++ SvNumberFormatterMergeMap::const_iterator itrNumFmt = rMap.find(nNumFmt);
++ if (itrNumFmt != rMap.end())
++ // mapped value found.
++ return itrNumFmt->second;
++
++ return nNumFmt;
++}
++
+IMPL_LINK(ScExternalRefManager, TimeOutHdl, AutoTimer*, pTimer)
+{
+ if (pTimer == &maSrcDocTimer)
@@ -11692,36 +12099,3 @@
if (!bLink)
if (pDoc->HasDdeLinks() || pDoc->HasAreaLinks())
bLink = TRUE;
-diff --git sc/source/ui/view/viewfunc.cxx sc/source/ui/view/viewfunc.cxx
-index 1fee6ea..651f0c3 100644
---- sc/source/ui/view/viewfunc.cxx
-+++ sc/source/ui/view/viewfunc.cxx
-@@ -619,6 +619,28 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS
- if ( pDoc->GetScriptType( nCol, nRow, i ) != nOldScript )
- bEditDeleted = TRUE;
-
-+ // Set the number format to the cell pattern _only when_ no number
-+ // format is already set.
-+ ScBaseCell* pCell;
-+ pDoc->GetCell(nCol, nRow, nTab, pCell);
-+ if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA &&
-+ pDoc->GetNumberFormat(ScAddress(nCol, nRow, nTab)) == 0)
-+ {
-+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
-+ sal_uInt32 nStdFmtIndex = pFCell->GetStandardFormat(*pDoc->GetFormatTable(), 0);
-+ if (nStdFmtIndex)
-+ {
-+ const ScPatternAttr* pOldPat = pDoc->GetPattern(nCol, nRow, nTab);
-+ ScPatternAttr aNewPat(*pOldPat);
-+ SfxItemSet& rSet = aNewPat.GetItemSet();
-+ SfxUInt32Item aValFmt(ATTR_VALUE_FORMAT, nStdFmtIndex);
-+ rSet.Put(aValFmt);
-+ aNewPat.DeleteUnchanged(pOldPat);
-+ pDoc->SetPattern(nCol, nRow, nTab, aNewPat, true);
-+ bNumFmtChanged = true;
-+ }
-+ }
-+
- HideAllCursors();
-
- if (bEditDeleted || pDoc->HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_NEEDHEIGHT ))
Added: trunk/patches/dev300/calc-external-defined-names-svtools.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/calc-external-defined-names-svtools.diff Thu Sep 25 18:37:17 2008
@@ -0,0 +1,61 @@
+diff --git svtools/inc/svtools/zforlist.hxx svtools/inc/svtools/zforlist.hxx
+index 20d4752..1e4f122 100644
+--- svtools/inc/svtools/zforlist.hxx
++++ svtools/inc/svtools/zforlist.hxx
+@@ -45,6 +45,8 @@
+ #include <tools/link.hxx>
+ #include <svtools/nfkeytab.hxx>
+
++#include <map>
++
+ class Date;
+ class SvStream;
+ class Color;
+@@ -224,6 +226,8 @@ typedef Table SvNumberFormatTable;
+ typedef Table SvNumberFormatterIndexTable;
+ #endif
+
++typedef ::std::map< sal_uInt32, sal_uInt32 > SvNumberFormatterMergeMap;
++
+
+ /** Language/country dependent currency entries
+ */
+@@ -599,6 +603,11 @@ public:
+ /// Return the new format index for an old format index, if a merge table exists
+ inline sal_uInt32 GetMergeFmtIndex( sal_uInt32 nOldFmt ) const;
+
++ /** Convert the ugly old tools' Table type bloated with new'ed sal_uInt32
++ entries merge table to ::std::map with old index key and new index key.
++ @ATTENTION! Also clears the old table using ClearMergeTable() */
++ SvNumberFormatterMergeMap ConvertMergeTableToMap();
++
+ /// Return the last used position ever of a language/country combination
+ USHORT GetLastInsertKey(sal_uInt32 CLOffset);
+
+diff --git svtools/source/numbers/zforlist.cxx svtools/source/numbers/zforlist.cxx
+index b093e0d..adc7e70 100644
+--- svtools/source/numbers/zforlist.cxx
++++ svtools/source/numbers/zforlist.cxx
+@@ -2914,6 +2914,22 @@ SvNumberFormatterIndexTable* SvNumberFormatter::MergeFormatter(SvNumberFormatter
+ }
+
+
++SvNumberFormatterMergeMap SvNumberFormatter::ConvertMergeTableToMap()
++{
++ if (!HasMergeFmtTbl())
++ return SvNumberFormatterMergeMap();
++
++ SvNumberFormatterMergeMap aMap;
++ for (sal_uInt32* pIndex = pMergeTable->First(); pIndex; pIndex = pMergeTable->Next())
++ {
++ sal_uInt32 nOldKey = pMergeTable->GetCurKey();
++ aMap.insert( SvNumberFormatterMergeMap::value_type( nOldKey, *pIndex));
++ }
++ ClearMergeTable();
++ return aMap;
++}
++
++
+ sal_uInt32 SvNumberFormatter::GetFormatForLanguageIfBuiltIn( sal_uInt32 nFormat,
+ LanguageType eLnge )
+ {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]