ooo-build r13516 - in trunk: . patches/test
- From: kyoshida svn gnome org
- To: svn-commits-list gnome org
- Subject: ooo-build r13516 - in trunk: . patches/test
- Date: Mon, 11 Aug 2008 19:53:44 +0000 (UTC)
Author: kyoshida
Date: Mon Aug 11 19:53:44 2008
New Revision: 13516
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13516&view=rev
Log:
2008-08-11 Kohei Yoshida <kyoshida novell com>
* patches/test/calc-external-defined-names.diff: massive code cleanup.
Modified:
trunk/ChangeLog
trunk/patches/test/calc-external-defined-names.diff
Modified: trunk/patches/test/calc-external-defined-names.diff
==============================================================================
--- trunk/patches/test/calc-external-defined-names.diff (original)
+++ trunk/patches/test/calc-external-defined-names.diff Mon Aug 11 19:53:44 2008
@@ -679,41 +679,10 @@
/** Xcl import may play dirty tricks with OpCode!=ocExternal.
Others don't use! */
diff --git sc/source/core/data/cell.cxx sc/source/core/data/cell.cxx
-index a68efc0..4ac2ce7 100644
+index a68efc0..ed6a75e 100644
--- sc/source/core/data/cell.cxx
+++ sc/source/core/data/cell.cxx
-@@ -87,6 +87,30 @@ static const sal_Char __FAR_DATA msgDbgInfinity[] =
- "NICHTS anruehren und ER bescheid sagen!";
- #endif
-
-+
-+namespace {
-+
-+#include <string>
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
- // -----------------------------------------------------------------------
-
- ScBaseCell::ScBaseCell( CellType eNewType ) :
-@@ -689,7 +713,12 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rNewPos,
+@@ -689,7 +689,12 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rNewPos,
for( ScToken* t = pCode->GetNextReferenceOrName(); t && !bCompile;
t = pCode->GetNextReferenceOrName() )
{
@@ -844,7 +813,7 @@
{
if (pLinkManager)
diff --git sc/source/core/tool/address.cxx sc/source/core/tool/address.cxx
-index 2cb5dce..bb5bc8e 100644
+index 2cb5dce..80dfb34 100644
--- sc/source/core/tool/address.cxx
+++ sc/source/core/tool/address.cxx
@@ -35,6 +35,7 @@
@@ -855,40 +824,7 @@
#include "globstr.hrc"
#include <sal/alloca.h>
-@@ -45,6 +46,32 @@
- #include <tools/urlobj.hxx>
- using namespace ::com::sun::star;
-
-+
-+#include <stdio.h>
-+#include <string>
-+
-+namespace {
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
-+
- ////////////////////////////////////////////////////////////////////////////
- const ScAddress::Details ScAddress::detailsOOOa1( CONV_OOO, 0, 0 );
-
-@@ -102,12 +129,9 @@ sal_Unicode_strtol ( const sal_Unicode* p,
+@@ -102,10 +103,7 @@ sal_Unicode_strtol ( const sal_Unicode* 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 *
@@ -898,12 +834,9 @@
- const String& rDocName,
+lcl_XL_ParseSheetRef( const sal_Unicode* start,
String& rExternTabName,
-- bool allow_3d )
-+ bool allow_3d)
+ bool allow_3d )
{
- String aTabName;
- SCTAB nTab = 0;
-@@ -190,26 +214,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode *start,
+@@ -190,26 +188,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode *start,
aTabName.Append( start, sal::static_int_cast<xub_StrLen>( p - start ) );
}
@@ -931,7 +864,7 @@
return p;
}
-@@ -227,39 +232,66 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
+@@ -227,39 +206,66 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
// Is this an external reference ?
rStartTabName.Erase();
rEndTabName.Erase();
@@ -1015,7 +948,7 @@
if( NULL == p )
return start; // invalid tab
if( p != startTabs )
-@@ -267,7 +299,7 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
+@@ -267,7 +273,7 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
nFlags |= SCA_VALID_TAB | SCA_TAB_3D | SCA_TAB_ABSOLUTE;
if( *p == ':' ) // 3d ref
{
@@ -1024,7 +957,7 @@
if( p == NULL )
return start; // invalid tab
nFlags |= SCA_VALID_TAB2 | SCA_TAB2_3D | SCA_TAB2_ABSOLUTE;
-@@ -289,45 +321,36 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
+@@ -289,45 +295,36 @@ lcl_ScRange_Parse_XL_Header( ScRange& r,
// Use the current tab, it needs to be passed in. : r.aEnd.SetTab( .. );
}
@@ -1063,12 +996,12 @@
+ nFlags &= ~SCA_VALID_TAB;
+ nTab = -1;
+ }
++
++ r.aStart.SetTab(nTab);
++ r.aEnd.SetTab(nTab);
- if( rEndTabName.Len() > 0 &&
- rStartTabName != rEndTabName )
-+ r.aStart.SetTab(nTab);
-+ r.aEnd.SetTab(nTab);
-+
+ if (rEndTabName.Len())
{
- aDocTab = ScGlobal::GetDocTabName( aDocName, rEndTabName );
@@ -1093,7 +1026,7 @@
}
-@@ -427,7 +450,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -427,7 +424,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
const sal_Unicode* p,
ScDocument* pDoc,
const ScAddress::Details& rDetails,
@@ -1102,7 +1035,7 @@
{
const sal_Unicode* pTmp = NULL;
String aExternDocName, aStartTabName, aEndTabName;
-@@ -442,6 +465,15 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -442,6 +439,15 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
#endif
p = lcl_ScRange_Parse_XL_Header( r, p, pDoc,
aExternDocName, aStartTabName, aEndTabName, nFlags );
@@ -1118,7 +1051,7 @@
if( NULL == p )
return 0;
-@@ -480,8 +512,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -480,8 +486,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
r.aStart.SetCol( 0 );
r.aEnd.SetCol( MAXCOL );
@@ -1128,7 +1061,7 @@
}
else if( NULL == (p = lcl_r1c1_get_col( p, rDetails, &r.aStart, &nFlags )))
goto failed;
-@@ -501,8 +532,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -501,8 +506,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
return nFlags;
}
@@ -1138,7 +1071,7 @@
}
p = pTmp;
-@@ -517,8 +547,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -517,8 +521,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
}
nFlags |= (nFlags2 << 4);
@@ -1148,7 +1081,7 @@
}
else if( *p == 'C' || *p == 'c' ) // full col C#
{
-@@ -550,8 +579,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+@@ -550,8 +553,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
r.aStart.SetRow( 0 );
r.aEnd.SetRow( MAXROW );
@@ -1158,7 +1091,7 @@
}
failed :
-@@ -604,8 +632,12 @@ static USHORT
+@@ -604,7 +606,8 @@ static USHORT
lcl_ScRange_Parse_XL_A1( ScRange& r,
const sal_Unicode* p,
ScDocument* pDoc,
@@ -1166,22 +1099,13 @@
+ BOOL bOnlyAcceptSingle,
+ ScAddress::ExternalInfo* pExtInfo )
{
-+ StackPrinter __stack_print__("::lcl_ScRange_Parse_XL_A1");
-+ fprintf(stdout, "lcl_ScRange_Parse_XL_A1: text = '%s'\n",
-+ rtl::OUStringToOString(String(p), RTL_TEXTENCODING_UTF8).getStr());
const sal_Unicode* tmp1, *tmp2;
String aExternDocName, aStartTabName, aEndTabName; // for external link table
- USHORT nFlags = SCA_VALID | SCA_VALID_TAB, nFlags2 = SCA_VALID_TAB2;
-@@ -619,6 +651,20 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -619,6 +622,15 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
#endif
p = lcl_ScRange_Parse_XL_Header( r, p, pDoc,
aExternDocName, aStartTabName, aEndTabName, nFlags );
+
-+ fprintf(stdout, "lcl_ScRange_Parse_XL_A1: extern doc name = '%s'; start tab = '%s'; end tab = '%s'\n",
-+ rtl::OUStringToOString(aExternDocName, RTL_TEXTENCODING_UTF8).getStr(),
-+ rtl::OUStringToOString(aStartTabName, RTL_TEXTENCODING_UTF8).getStr(),
-+ rtl::OUStringToOString(aEndTabName, RTL_TEXTENCODING_UTF8).getStr());
-+
+ if (aExternDocName.Len() > 0)
+ {
+ ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
@@ -1193,7 +1117,7 @@
if( NULL == p )
return 0;
-@@ -640,8 +686,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -640,8 +652,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
SCA_VALID_COL | SCA_VALID_COL2 |
SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE;
nFlags |= (nFlags2 << 4);
@@ -1203,7 +1127,7 @@
}
tmp2 = lcl_a1_get_row( tmp1, &r.aStart, &nFlags );
-@@ -661,8 +706,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -661,8 +672,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
SCA_VALID_ROW | SCA_VALID_ROW2 |
SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE;
nFlags |= (nFlags2 << 4);
@@ -1213,7 +1137,7 @@
}
// prepare as if it's a singleton, in case we want to fall back */
-@@ -672,8 +716,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -672,8 +682,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
if ( bOnlyAcceptSingle )
{
if ( *tmp2 == 0 )
@@ -1223,7 +1147,7 @@
else
{
// any trailing invalid character must invalidate the address.
-@@ -692,12 +735,11 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -692,12 +701,11 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
p = tmp2;
tmp1 = lcl_a1_get_col( p+1, &r.aEnd, &nFlags2 );
if( !tmp1 ) // strange, but valid singleton
@@ -1239,7 +1163,7 @@
if ( *tmp2 != 0 )
{
-@@ -708,20 +750,19 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -708,20 +716,19 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
}
nFlags |= (nFlags2 << 4);
@@ -1264,7 +1188,7 @@
// Lets see if this is a reference to something in an external file.
// A Documentname is always quoted and has a trailing #
-@@ -795,35 +836,11 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
+@@ -795,35 +802,11 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
}
if( *p++ != '.' )
nBits = 0;
@@ -1304,7 +1228,7 @@
}
else
nBits = 0;
-@@ -884,16 +901,33 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
+@@ -884,16 +867,30 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
if( !nBits )
p = q;
}
@@ -1316,11 +1240,8 @@
- && pDoc->LinkExternalTab( nTab, aDocTab, aDocName, aTab ) )
+ ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
+ pRefMgr->convertToAbsName(aDocName);
-+ fprintf(stdout, "lcl_ScAddress_Parse_OOo: doc name = '%s'; tab = '%s' col = %d row = %ld\n",
-+ rtl::OUStringToOString(aDocName, RTL_TEXTENCODING_UTF8).getStr(),
-+ rtl::OUStringToOString(aTab, RTL_TEXTENCODING_UTF8).getStr(), nCol, nRow);
+
-+ // TODO: Make sure the document exists!
++ // TODO: Do we need to check if the document exists before going further?
+
+ sal_uInt16 nFileId = pRefMgr->getExternalFileId(aDocName);
+ if (pExtInfo && !pExtInfo->mbExternal)
@@ -1342,7 +1263,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 +946,8 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
+@@ -912,9 +909,8 @@ lcl_ScAddress_Parse_OOo( BOOL& bExternal, const sal_Unicode* p,
}
static USHORT
@@ -1354,7 +1275,7 @@
{
if( !*p )
return 0;
-@@ -924,20 +957,20 @@ lcl_ScAddress_Parse ( BOOL& bExternal, const sal_Unicode* p,
+@@ -924,20 +920,20 @@ lcl_ScAddress_Parse ( BOOL& bExternal, const sal_Unicode* p,
default :
case ScAddress::CONV_OOO:
{
@@ -1378,7 +1299,7 @@
rAddr = r.aStart;
return nFlags;
}
-@@ -949,9 +982,8 @@ bool ConvertSingleRef( ScDocument* pDoc, const String& rRefString,
+@@ -949,9 +945,8 @@ bool ConvertSingleRef( ScDocument* pDoc, const String& rRefString,
SCTAB nDefTab, ScRefAddress& rRefAddress,
const ScAddress::Details& rDetails )
{
@@ -1389,7 +1310,7 @@
if( nRes & SCA_VALID )
{
rRefAddress.Set( aAddr,
-@@ -988,10 +1020,9 @@ bool ConvertDoubleRef( ScDocument* pDoc, const String& rRefString, SCTAB nDefTab
+@@ -988,10 +983,9 @@ bool ConvertDoubleRef( ScDocument* pDoc, const String& rRefString, SCTAB nDefTab
USHORT ScAddress::Parse( const String& r, ScDocument* pDoc,
@@ -1402,7 +1323,7 @@
}
-@@ -1060,7 +1091,7 @@ void ScRange::ExtendTo( const ScRange& rRange )
+@@ -1060,7 +1054,7 @@ void ScRange::ExtendTo( const ScRange& rRange )
}
static USHORT
@@ -1411,7 +1332,7 @@
{
USHORT nRes1 = 0, nRes2 = 0;
xub_StrLen nTmp = 0;
-@@ -1073,13 +1104,12 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc )
+@@ -1073,13 +1067,12 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc )
String aTmp( r );
sal_Unicode* p = aTmp.GetBufferAccess();
p[ nPos ] = 0;
@@ -1428,7 +1349,7 @@
nRes2 &= ~SCA_VALID_TAB; // #REF!
else
{
-@@ -1132,7 +1162,7 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc )
+@@ -1132,7 +1125,7 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc )
}
USHORT ScRange::Parse( const String& r, ScDocument* pDoc,
@@ -1437,7 +1358,7 @@
{
if ( r.Len() <= 0 )
return 0;
-@@ -1141,13 +1171,13 @@ USHORT ScRange::Parse( const String& r, ScDocument* pDoc,
+@@ -1141,13 +1134,13 @@ USHORT ScRange::Parse( const String& r, ScDocument* pDoc,
{
default :
case ScAddress::CONV_OOO:
@@ -1455,41 +1376,14 @@
}
diff --git sc/source/core/tool/compiler.cxx sc/source/core/tool/compiler.cxx
-index 084f533..37ec1f8 100644
+index 084f533..c320d37 100644
--- sc/source/core/tool/compiler.cxx
+++ sc/source/core/tool/compiler.cxx
-@@ -74,9 +74,38 @@
+@@ -74,9 +74,11 @@
#include "errorcodes.hxx"
#include "parclass.hxx"
#include "autonamecache.hxx"
+#include "externalrefmgr.hxx"
-+
-+#include <stdio.h>
-+
-+
-+namespace {
-+
-+#include <string>
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
using namespace ::com::sun::star;
using rtl::OUString;
@@ -1497,7 +1391,7 @@
#if OSL_DEBUG_LEVEL > 1
// For some unknown reason the identical dbg_dump utilities in
-@@ -1164,7 +1193,7 @@ static bool lcl_isValidQuotedText( const String& rFormula, xub_StrLen nSrcPos, P
+@@ -1164,7 +1166,7 @@ static bool lcl_isValidQuotedText( const String& rFormula, xub_StrLen nSrcPos, P
{
rRes.TokenType = KParseType::SINGLE_QUOTE_NAME;
rRes.EndPos = nPos+1;
@@ -1506,7 +1400,7 @@
}
++nPos;
}
-@@ -1172,9 +1201,217 @@ static bool lcl_isValidQuotedText( const String& rFormula, xub_StrLen nSrcPos, P
+@@ -1172,9 +1174,197 @@ static bool lcl_isValidQuotedText( const String& rFormula, xub_StrLen nSrcPos, P
}
}
@@ -1515,9 +1409,6 @@
+
+static bool lcl_parseExternalName( const String& rSymbol, String& rFile, String& rName, const sal_Unicode cSep )
+{
-+ StackPrinter __stack_print__("::lcl_parseExternalName");
-+ fprintf(stdout, "lcl_parseExternalName: symbol = '%s'\n", rtl::OUStringToOString(rSymbol, RTL_TEXTENCODING_UTF8).getStr());
-+
+ const sal_Unicode* p = rSymbol.GetBuffer();
+ xub_StrLen nLen = rSymbol.Len();
+ sal_Unicode cPrev = 0;
@@ -1529,11 +1420,7 @@
+ if (i == 0)
+ {
+ if (c == '.' || c == cSep)
-+ {
-+ fprintf(stdout, "lcl_parseExternalName: not allowed as first character '%s'\n",
-+ rtl::OUStringToOString(String(c), RTL_TEXTENCODING_UTF8).getStr());
+ return false;
-+ }
+
+ if (c == '\'')
+ {
@@ -1549,7 +1436,6 @@
+ if (j == i)
+ {
+ // empty quote e.g. (=''!Name)
-+ fprintf(stdout, "lcl_parseExternalName: empty quote\n");
+ return false;
+ }
+
@@ -1583,16 +1469,12 @@
+ if (!bInName)
+ {
+ // premature ending of the quoted segment.
-+ fprintf(stdout, "lcl_parseExternalName: premature ending of the quoted segment\n");
+ return false;
+ }
+
+ if (c != cSep)
+ {
+ // only the separator is allowed after the closing quote.
-+ fprintf(stdout, "lcl_parseExternalName: only the '%s' is allowed after the closing quote '%s'\n",
-+ rtl::OUStringToOString(String(cSep), RTL_TEXTENCODING_UTF8).getStr(),
-+ rtl::OUStringToOString(String(c), RTL_TEXTENCODING_UTF8).getStr());
+ return false;
+ }
+
@@ -1606,8 +1488,6 @@
+ if (c == cSep)
+ {
+ // A second separator ? Not a valid external name.
-+ fprintf(stdout, "lcl_parseExternalName: second %s encountered\n",
-+ rtl::OUStringToOString(String(cSep), RTL_TEXTENCODING_UTF8).getStr());
+ return false;
+ }
+ aTmpName.Append(c);
@@ -1643,8 +1523,6 @@
+ if (bValid)
+ break;
+
-+ fprintf(stdout, "lcl_parseExternalName: invalid character '%s'\n",
-+ rtl::OUStringToOString(String(c), RTL_TEXTENCODING_UTF8).getStr());
+ return false;
+ }
+ while (false);
@@ -1657,18 +1535,14 @@
+ if (!bInName)
+ {
+ // No name found - most likely the symbol has no '!'s.
-+ fprintf(stdout, "lcl_parseExternalName: not name found\n");
+ return false;
+ }
+
-+ fprintf(stdout, "lcl_parseExternalName: file = '%s'; name = '%s'\n",
-+ rtl::OUStringToOString(aTmpFile, RTL_TEXTENCODING_UTF8).getStr(),
-+ rtl::OUStringToOString(aTmpName, RTL_TEXTENCODING_UTF8).getStr());
+ rFile = aTmpFile;
+ rName = aTmpName;
- return true;
- }
-
++ return true;
++}
++
+static String lcl_makeExternalNameStr( const String& rFile, const String& rName, const sal_Unicode cSep )
+{
+ String aStr, aFile = rFile;
@@ -1708,9 +1582,9 @@
+ else
+ rTabName2 = rTabName1;
+
-+ return true;
-+}
-+
+ return true;
+ }
+
+static void lcl_appendTabName(::rtl::OUStringBuffer& rBuffer, const String& rTabName)
+{
+ bool bQuote = (rTabName.Search(sal_Unicode(' '), 0) != STRING_NOTFOUND);
@@ -1724,7 +1598,7 @@
struct Convention_A1 : public ScCompiler::Convention
{
Convention_A1( ScAddress::Convention eConv ) : ScCompiler::Convention( eConv ) { }
-@@ -1188,14 +1425,14 @@ struct Convention_A1 : public ScCompiler::Convention
+@@ -1188,14 +1378,14 @@ struct Convention_A1 : public ScCompiler::Convention
const CharClass* pCharClass) const
{
ParseResult aRet;
@@ -1741,7 +1615,7 @@
return pCharClass->parseAnyToken( rFormula,
nSrcPos, nStartFlags, aAddAllowed, nContFlags, aAddAllowed );
}
-@@ -1378,6 +1615,86 @@ struct ConventionOOO_A1 : public Convention_A1
+@@ -1378,6 +1568,86 @@ struct ConventionOOO_A1 : public Convention_A1
return sal_Unicode(0);
}
@@ -1828,7 +1702,7 @@
};
-@@ -1499,11 +1816,150 @@ struct ConventionXL
+@@ -1499,11 +1769,128 @@ struct ConventionXL
}
return sal_Unicode(0);
}
@@ -1845,9 +1719,10 @@
+
+ static void makeExternalDocStr( ::rtl::OUStringBuffer& rBuffer, const String& rFullName )
+ {
-+#if 1
+ // Format that is easier to deal with inside OOo, because we use file
-+ // URL, and all characetrs all allowed.
++ // URL, and all characetrs are allowed. Check if it makes sense to do
++ // it the way Gnumeric does it. Gnumeric doesn't use the URL form
++ // and allows relative file path.
+ //
+ // ['file:///path/to/source/filename.xls']
+
@@ -1864,29 +1739,6 @@
+ }
+ rBuffer.append(sal_Unicode('\''));
+ rBuffer.append(sal_Unicode(']'));
-+#else
-+ // Format that is closer to the original Excel way. It's a little out
-+ // of wack especially when the file name contains '[' or ']'. Excel
-+ // will translate them to '(' and ')', but fails to find the source
-+ // document. We don't want to use this format.
-+ //
-+ // file:///path/to/source/[filename.xls]
-+
-+ String aDirName, aFileName;
-+ xub_StrLen nPos = rFullName.SearchBackward(sal_Unicode('/'));
-+ if (nPos == STRING_NOTFOUND)
-+ aFileName = rFullName;
-+ else
-+ {
-+ aDirName = rFullName.Copy(0, nPos+1);
-+ aFileName = rFullName.Copy(nPos+1);
-+ }
-+
-+ rBuffer.append(aDirName);
-+ rBuffer.append(sal_Unicode('['));
-+ rBuffer.append(aFileName);
-+ rBuffer.append(sal_Unicode(']'));
-+#endif
+ }
+
+ static void makeExternalTabNameRange( ::rtl::OUStringBuffer& rBuf, const String& rTabName,
@@ -1979,7 +1831,7 @@
void MakeRefStr( rtl::OUStringBuffer& rBuf,
const ScCompiler& rComp,
const ComplRefData& rRef,
-@@ -1557,22 +2013,11 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
+@@ -1557,22 +1944,11 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
}
}
@@ -2004,7 +1856,7 @@
}
}
-@@ -1580,8 +2025,10 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
+@@ -1580,8 +1956,10 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
xub_StrLen nSrcPos,
const CharClass* pCharClass) const
{
@@ -2016,7 +1868,7 @@
return aRet;
static const sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER |
-@@ -1597,6 +2044,67 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
+@@ -1597,6 +1975,67 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
{
return ConventionXL::getSpecialSymbol(eSymType);
}
@@ -2084,7 +1936,7 @@
};
static const ConventionXL_A1 ConvXL_A1;
-@@ -1706,8 +2214,10 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
+@@ -1706,8 +2145,10 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
xub_StrLen nSrcPos,
const CharClass* pCharClass) const
{
@@ -2096,7 +1948,7 @@
return aRet;
static const sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER |
-@@ -1724,6 +2234,95 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
+@@ -1724,6 +2165,95 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
{
return ConventionXL::getSpecialSymbol(eSymType);
}
@@ -2192,28 +2044,7 @@
};
static const ConventionXL_R1C1 ConvXL_R1C1;
-@@ -1898,6 +2497,8 @@ sal_Unicode* lcl_UnicodeStrNCpy( sal_Unicode* pDst, const sal_Unicode* pSrc, xub
-
- xub_StrLen ScCompiler::NextSymbol(bool bInArray)
- {
-+ StackPrinter __stack_print__("ScCompiler::NextSymbol");
-+
- cSymbol[MAXSTRLEN-1] = 0; // Stopper
- sal_Unicode* pSym = cSymbol;
- const sal_Unicode* const pStart = aFormula.GetBuffer();
-@@ -1922,6 +2523,11 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
- bool bAutoIntersection = false;
- int nRefInSheetName = 0;
- mnPredetectedReference = 0;
-+#if 0
-+ // disable non-i18n parsing
-+ if (c != 0)
-+ bi18n = true;
-+#else
- // try to parse simple tokens before calling i18n parser
- while ((c != 0) && (eState != ssStop) )
- {
-@@ -2179,7 +2785,7 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
+@@ -2179,7 +2709,7 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
static const int kQuote = kInc * 2;
static const int kPast = kInc * 3;
bool bAddToSymbol = true;
@@ -2222,7 +2053,7 @@
{
// eat it, no sheet name
bAddToSymbol = false;
-@@ -2194,7 +2800,7 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
+@@ -2194,7 +2724,7 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
}
else if (nRefInSheetName < kPast)
{
@@ -2231,28 +2062,7 @@
nRefInSheetName += kDollar;
else if ('\'' == c)
{
-@@ -2245,8 +2851,10 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
- cLast = c;
- c = *pSrc;
- }
-+#endif
- if ( bi18n )
- {
-+ fprintf(stdout, "ScCompiler::NextSymbol: i18n parsing\n");
- nSrcPos = sal::static_int_cast<xub_StrLen>( nSrcPos + nSpaces );
- String aSymbol;
- USHORT nErr = 0;
-@@ -2297,6 +2905,9 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
- aCorrectedSymbol = cSymbol;
- if (bAutoIntersection && nSpaces > 1)
- --nSpaces; // replace '!!' with only one space
-+
-+ fprintf(stdout, "ScCompiler::NextSymbol: symbol = '%s'\n",
-+ rtl::OUStringToOString(aCorrectedSymbol, RTL_TEXTENCODING_UTF8).getStr());
- return nSpaces;
- }
-
-@@ -2516,7 +3127,8 @@ BOOL ScCompiler::IsDoubleReference( const String& rName )
+@@ -2516,7 +3046,8 @@ BOOL ScCompiler::IsDoubleReference( const String& rName )
{
ScRange aRange( aPos, aPos );
const ScAddress::Details aDetails( pConv->meConv, aPos );
@@ -2262,7 +2072,7 @@
if( nFlags & SCA_VALID )
{
ScRawToken aToken;
-@@ -2535,23 +3147,41 @@ BOOL ScCompiler::IsDoubleReference( const String& rName )
+@@ -2535,7 +3066,14 @@ BOOL ScCompiler::IsDoubleReference( const String& rName )
aRef.Ref2.SetTabDeleted( TRUE ); // #REF!
aRef.Ref2.SetFlag3D( ( nFlags & SCA_TAB2_3D ) != 0 );
aRef.CalcRelFromAbs( aPos );
@@ -2278,17 +2088,8 @@
pRawToken = aToken.Clone();
}
-+ bool bRes = (nFlags & SCA_VALID) != 0;
-+ fprintf(stdout, "ScCompiler::IsDoubleReference: is double ref? (%s)\n", bRes?"yes":"no");
- return ( nFlags & SCA_VALID ) != 0;
- }
-
-
- BOOL ScCompiler::IsSingleReference( const String& rName )
+@@ -2547,7 +3085,8 @@ BOOL ScCompiler::IsSingleReference( const String& rName )
{
-+ StackPrinter __stack_print__("ScCompiler::IsSingleReference");
-+ fprintf(stdout, "ScCompiler::IsSingleReference: symbol ='%s'\n", rtl::OUStringToOString(rName, RTL_TEXTENCODING_UTF8).getStr());
-+
ScAddress aAddr( aPos );
const ScAddress::Details aDetails( pConv->meConv, aPos );
- USHORT nFlags = aAddr.Parse( rName, pDoc, aDetails );
@@ -2297,25 +2098,11 @@
// Something must be valid in order to recognize Sheet1.blah or blah.a1
// as a (wrong) reference.
if( nFlags & ( SCA_VALID_COL|SCA_VALID_ROW|SCA_VALID_TAB ) )
- {
-+ if (aExtInfo.mbExternal)
-+ fprintf(stdout, "ScCompiler::IsSingleReference: this is an external single ref\n");
-+ else
-+ fprintf(stdout, "ScCompiler::IsSingleReference: this is an internal single ref\n");
-+
- ScRawToken aToken;
- SingleRefData aRef;
- aRef.InitAddress( aAddr );
-@@ -2571,16 +3201,28 @@ BOOL ScCompiler::IsSingleReference( const String& rName )
+@@ -2571,7 +3110,11 @@ BOOL ScCompiler::IsSingleReference( const String& rName )
nFlags |= SCA_VALID;
}
aRef.CalcRelFromAbs( aPos );
- aToken.SetSingleReference( aRef );
-+ fprintf(stdout, "ScCompiler::IsSingleReference: abs col = %d; row = %d; tab = %d\n", aRef.nCol, aRef.nRow, aRef.nTab);
-+ fprintf(stdout, "ScCompiler::IsSingleReference: rel col = %d; row = %d; tab = %d\n",
-+ aRef.nRelCol, aRef.nRelRow, aRef.nRelTab);
-+ fprintf(stdout, "ScCompiler::IsSingleReference: col rel (%d); row rel (%d); tab rel (%d)\n",
-+ aRef.IsColRel(), aRef.IsRowRel(), aRef.IsTabRel());
+
+ if (aExtInfo.mbExternal)
+ aToken.SetExternalSingleRef(aExtInfo.mnFileId, aExtInfo.maTabName, aRef);
@@ -2324,19 +2111,7 @@
pRawToken = aToken.Clone();
}
-+ fprintf(stdout, "ScCompiler::IsSingleReference: is single ref? (%s)\n", (nFlags&SCA_VALID)?"yes":"no");
- return ( nFlags & SCA_VALID ) != 0;
- }
-
-
- BOOL ScCompiler::IsReference( const String& rName )
- {
-+ StackPrinter aStack("ScCompiler::IsReference");
-+
- // Has to be called before IsValue
- sal_Unicode ch1 = rName.GetChar(0);
- sal_Unicode cDecSep = ( mxSymbols->isEnglish() ? '.' :
-@@ -2679,6 +3321,30 @@ BOOL ScCompiler::IsNamedRange( const String& rUpperName )
+@@ -2679,6 +3222,27 @@ BOOL ScCompiler::IsNamedRange( const String& rUpperName )
return FALSE;
}
@@ -2356,9 +2131,6 @@
+ ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
+ pRefMgr->convertToAbsName(aFile);
+ sal_uInt16 nFileId = pRefMgr->getExternalFileId(aFile);
-+ fprintf(stdout, "ScCompiler::IsExternalNamedRange: file name = '%s'; file id = %d\n",
-+ rtl::OUStringToOString(aFile, RTL_TEXTENCODING_UTF8).getStr(), nFileId);
-+
+ aToken.SetExternalName(nFileId, aName);
+ pRawToken = aToken.Clone();
+ return true;
@@ -2367,7 +2139,7 @@
BOOL ScCompiler::IsDBRange( const String& rName )
{
USHORT n;
-@@ -3277,6 +3943,7 @@ BOOL ScCompiler::NextNewToken( bool bInArray )
+@@ -3277,6 +3841,7 @@ BOOL ScCompiler::NextNewToken( bool bInArray )
&& !(bAllowBooleans && IsBoolean( aUpper ))
&& !IsValue( aUpper )
&& !IsNamedRange( aUpper )
@@ -2375,7 +2147,7 @@
&& !IsDBRange( aUpper )
&& !IsColRowName( aUpper )
&& !(bMayBeFuncName && IsMacro( aUpper ))
-@@ -3603,6 +4270,70 @@ BOOL ScCompiler::GetToken()
+@@ -3603,6 +4168,67 @@ BOOL ScCompiler::GetToken()
}
if( pToken->GetOpCode() == ocSubTotal )
glSubTotal = TRUE;
@@ -2392,7 +2164,6 @@
+ {
+ case svExternalName:
+ {
-+ fprintf(stdout, "ScCompiler::GetToken: external name token\n");
+ const String& rName = pToken->GetString();
+ ScTokenArray* pNew = pRefMgr->getRangeNameTokens(pToken->GetIndex(), rName, &aPos);
+ if (pNew)
@@ -2404,7 +2175,6 @@
+ break;
+ case svSingleRef:
+ {
-+ fprintf(stdout, "ScCompiler::GetToken: external single ref (file id = %d)\n", pToken->GetIndex());
+ SingleRefData aData(pToken->GetSingleRef());
+ if (aData.IsTabRel())
+ // external single reference must have an absolute table reference!
@@ -2422,7 +2192,6 @@
+ break;
+ case svDoubleRef:
+ {
-+ fprintf(stdout, "ScCompiler::GetToken: external double ref (file id = %d)\n", pToken->GetIndex());
+ ComplRefData aData(pToken->GetDoubleRef());
+ if (aData.Ref1.IsTabRel() || aData.Ref2.IsTabRel())
+ // external double reference must have an absolute table reference!
@@ -2446,15 +2215,7 @@
else if( pToken->GetOpCode() == ocName )
{
ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( pToken->GetIndex() );
-@@ -5553,6 +6284,7 @@ ScToken* ScCompiler::CreateStringFromToken( rtl::OUStringBuffer& rBuffer, ScToke
- BOOL bSpaces = FALSE;
- ScToken* t = pTokenP;
- OpCode eOp = t->GetOpCode();
-+
- if( eOp >= ocAnd && eOp <= ocOr )
- {
- // AND, OR infix?
-@@ -5600,111 +6332,140 @@ ScToken* ScCompiler::CreateStringFromToken( rtl::OUStringBuffer& rBuffer, ScToke
+@@ -5600,111 +6226,140 @@ ScToken* ScCompiler::CreateStringFromToken( rtl::OUStringBuffer& rBuffer, ScToke
DBG_ERRORFILE("unknown OpCode");
rBuffer.append(ScGlobal::GetRscString(STR_NO_NAME_REF));
}
@@ -2697,44 +2458,19 @@
static void lcl_putInOrder( SingleRefData & rRef1, SingleRefData & rRef2 )
{
diff --git sc/source/core/tool/token.cxx sc/source/core/tool/token.cxx
-index a20cbd5..34b892c 100644
+index a20cbd5..51611ef 100644
--- sc/source/core/tool/token.cxx
+++ sc/source/core/tool/token.cxx
-@@ -54,6 +54,33 @@
+@@ -54,6 +54,8 @@
#include "parclass.hxx"
#include "jumpmatrix.hxx"
+using ::std::vector;
+
-+
-+namespace {
-+
-+#include <string>
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
-+
// ImpTokenIterator wird je Interpreter angelegt, mehrfache auch durch
// SubCode via ScTokenIterator Push/Pop moeglich
IMPL_FIXEDMEMPOOL_NEWDEL( ImpTokenIterator, 32, 16 )
-@@ -209,6 +236,51 @@ void ScRawToken::SetName( USHORT n )
+@@ -209,6 +211,48 @@ void ScRawToken::SetName( USHORT n )
nRefCnt = 0;
}
@@ -2749,9 +2485,6 @@
+ extref.aRef.Ref2 = rRef;
+
+ xub_StrLen n = rTabName.Len();
-+ fprintf(stdout, "ScRawToken::SetExternalSingleRef: tab name = '%s'; len = %d\n",
-+ rtl::OUStringToOString(rTabName, RTL_TEXTENCODING_UTF8).getStr(), n);
-+
+ memcpy(extref.cTabName, rTabName.GetBuffer(), n*sizeof(sal_Unicode));
+ extref.cTabName[n] = 0;
+}
@@ -2786,7 +2519,7 @@
ComplRefData& ScRawToken::GetReference()
{
DBG_ASSERT( lcl_IsReference( eOp, GetType() ), "GetReference: no Ref" );
-@@ -260,22 +332,34 @@ ScRawToken* ScRawToken::Clone() const
+@@ -260,22 +304,34 @@ ScRawToken* ScRawToken::Clone() const
static USHORT nOffset = lcl_ScRawTokenOffset(); // offset of sbyte
USHORT n = nOffset;
@@ -2836,7 +2569,7 @@
}
p = (ScRawToken*) new BYTE[ n ];
memcpy( p, this, n * sizeof(BYTE) );
-@@ -311,12 +395,22 @@ ScToken* ScRawToken::CreateToken() const
+@@ -311,12 +367,22 @@ ScToken* ScRawToken::CreateToken() const
case svSingleRef :
if (eOp == ocPush)
return new ScSingleRefToken( aRef.Ref1 );
@@ -2859,7 +2592,7 @@
else
return new ScDoubleRefOpToken( eOp, aRef );
//break;
-@@ -327,6 +421,11 @@ ScToken* ScRawToken::CreateToken() const
+@@ -327,6 +393,11 @@ ScToken* ScRawToken::CreateToken() const
case svIndex :
return new ScIndexToken( eOp, nIndex );
//break;
@@ -2871,7 +2604,7 @@
case svJump :
return new ScJumpToken( eOp, (short*) nJump );
//break;
-@@ -478,6 +577,7 @@ BOOL ScToken::IsMatrixFunction() const
+@@ -478,6 +549,7 @@ BOOL ScToken::IsMatrixFunction() const
ScToken* ScToken::Clone() const
{
@@ -2879,7 +2612,7 @@
switch ( GetType() )
{
case svByte :
-@@ -487,20 +587,24 @@ ScToken* ScToken::Clone() const
+@@ -487,20 +559,24 @@ ScToken* ScToken::Clone() const
return new ScDoubleToken( *static_cast<const ScDoubleToken*>(this) );
//break;
case svString :
@@ -2907,7 +2640,7 @@
else
return new ScDoubleRefOpToken( *static_cast<const ScDoubleRefOpToken*>(this) );
//break;
-@@ -522,6 +626,9 @@ ScToken* ScToken::Clone() const
+@@ -522,6 +598,9 @@ ScToken* ScToken::Clone() const
case svExternal :
return new ScExternalToken( *static_cast<const ScExternalToken*>(this) );
//break;
@@ -2917,7 +2650,7 @@
case svFAP :
return new ScFAPToken( *static_cast<const ScFAPToken*>(this) );
//break;
-@@ -660,6 +767,7 @@ ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2,
+@@ -660,6 +739,7 @@ ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2,
return NULL;
ScTokenRef xRes;
@@ -2925,7 +2658,7 @@
if (sv1 == svSingleRef && sv2 == svSingleRef)
{
// Range references like Sheet1.A1:A2 are generalized and built by
-@@ -671,7 +779,10 @@ ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2,
+@@ -671,7 +751,10 @@ ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2,
aRef.Ref1 = aRef.Ref2 = p1->GetSingleRef();
aRef.Ref2.SetFlag3D( false);
aRef.Extend( p2->GetSingleRef(), rPos);
@@ -2937,7 +2670,7 @@
}
else
{
-@@ -694,7 +805,10 @@ ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2,
+@@ -694,7 +777,10 @@ ScTokenRef ScToken::ExtendRangeReference( ScToken & rTok1, ScToken & rTok2,
{
if (!pRefList->size())
return NULL;
@@ -2949,7 +2682,7 @@
}
if (!xRes)
return NULL; // shouldn't happen..
-@@ -1035,6 +1149,190 @@ BOOL ScIndexToken::operator==( const ScToken& r ) const
+@@ -1035,6 +1121,190 @@ BOOL ScIndexToken::operator==( const ScToken& r ) const
return ScToken::operator==( r ) && nIndex == r.GetIndex();
}
@@ -3140,7 +2873,7 @@
short* ScJumpToken::GetJump() const { return pJump; }
BOOL ScJumpToken::operator==( const ScToken& r ) const
-@@ -1237,6 +1535,9 @@ ScToken* ScTokenArray::GetNextReferenceOrName()
+@@ -1237,6 +1507,9 @@ ScToken* ScTokenArray::GetNextReferenceOrName()
{
for( ScToken* t = Next(); t; t = Next() )
{
@@ -3150,7 +2883,7 @@
switch( t->GetType() )
{
case svSingleRef:
-@@ -1893,6 +2194,21 @@ ScToken* ScTokenArray::AddMatrix( ScMatrix* p )
+@@ -1893,6 +2166,21 @@ ScToken* ScTokenArray::AddMatrix( ScMatrix* p )
return Add( new ScMatrixToken( p ) );
}
@@ -3199,10 +2932,10 @@
{
DBG_ASSERT_BIFF( GetBiff() == EXC_BIFF5 );
diff --git sc/source/filter/excel/excform8.cxx sc/source/filter/excel/excform8.cxx
-index ebf8543..5b55c59 100644
+index ebf8543..46a5163 100644
--- sc/source/filter/excel/excform8.cxx
+++ sc/source/filter/excel/excform8.cxx
-@@ -41,6 +41,35 @@
+@@ -41,6 +41,11 @@
#include "xilink.hxx"
#include "xiname.hxx"
@@ -3211,34 +2944,10 @@
+#include <vector>
+
+using ::std::vector;
-+
-+namespace {
-+
-+#include <string>
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
ExcelToSc8::ExcelToSc8( const XclImpRoot& rRoot ) :
ExcelToSc( rRoot ),
-@@ -53,15 +82,33 @@ ExcelToSc8::~ExcelToSc8()
+@@ -53,15 +58,33 @@ ExcelToSc8::~ExcelToSc8()
{
}
@@ -3251,11 +2960,11 @@
+ String aFileUrl = ScGlobal::GetAbsDocName(*pFileUrl, GetDocShell());
+ ScExternalRefManager* pRefMgr = GetDoc().GetExternalRefManager();
+ rFileId = pRefMgr->getExternalFileId(aFileUrl);
-+
-+ return true;
-+}
-BOOL ExcelToSc8::Read3DTabReference( XclImpStream& rStrm, SCTAB& rFirstTab, SCTAB& rLastTab )
++ return true;
++}
++
+bool ExcelToSc8::Read3DTabReference( UINT16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo )
{
rFirstTab = rLastTab = 0;
@@ -3276,7 +2985,7 @@
}
-@@ -608,8 +655,15 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
+@@ -608,8 +631,15 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
{
case xlExtName:
{
@@ -3294,12 +3003,11 @@
}
break;
-@@ -657,47 +711,71 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
+@@ -657,47 +687,67 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
case 0x7C:
case 0x3C: // Deleted 3-D Cell Reference [ 277]
{
- UINT16 nRw, nGrbitCol;
-+ fprintf(stdout, "ExcelToSc8::Convert: cell reference\n");
+ UINT16 nIxti, nRw, nGrbitCol;
SCTAB nTabFirst, nTabLast;
@@ -3321,8 +3029,9 @@
+ }
- ExcRelToScRel8( nRw, nGrbitCol, aSRD, bRangeName );
-+ fprintf(stdout, "ExcelToSc8::Convert: first tab = %d; last tab = %d; external (%d)\n",
-+ nTabFirst, nTabLast, aExtInfo.mbExternal);
++ aSRD.nTab = nTabFirst;
++ aSRD.SetFlag3D( TRUE );
++ aSRD.SetTabRel( FALSE );
- switch ( nOp )
- {
@@ -3335,16 +3044,12 @@
- }
- if ( !ValidTab(nTabFirst) )
- aSRD.SetTabDeleted( TRUE );
-+ aSRD.nTab = nTabFirst;
-+ aSRD.SetFlag3D( TRUE );
-+ aSRD.SetTabRel( FALSE );
++ ExcRelToScRel8( nRw, nGrbitCol, aSRD, bRangeName );
- if( nTabLast != nTabFirst )
- {
- aCRD.Ref1 = aCRD.Ref2 = aSRD;
- aCRD.Ref2.nTab = nTabLast;
-+ ExcRelToScRel8( nRw, nGrbitCol, aSRD, bRangeName );
-+
+ switch ( nOp )
+ {
+ case 0x5C:
@@ -3400,12 +3105,11 @@
}
break;
case 0x5B:
-@@ -707,55 +785,65 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
+@@ -707,55 +757,61 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
case 0x7D:
case 0x3D: // Deleted 3-D Area Reference [ 277]
{
- UINT16 nRw1, nGrbitCol1, nRw2, nGrbitCol2;
-+ fprintf(stdout, "ExcelToSc8::Convert: area reference\n");
+ UINT16 nIxti, nRw1, nGrbitCol1, nRw2, nGrbitCol2;
SCTAB nTabFirst, nTabLast;
+ aIn >> nIxti >> nRw1 >> nRw2 >> nGrbitCol1 >> nGrbitCol2;
@@ -3414,44 +3118,25 @@
- aIn >> nRw1 >> nRw2 >> nGrbitCol1 >> nGrbitCol2;
-
- if( bOK )
-+ ExternalTabInfo aExtInfo;
-+ if (!Read3DTabReference(nIxti, nTabFirst, nTabLast, aExtInfo))
- {
+- {
- SingleRefData &rR1 = aCRD.Ref1;
- SingleRefData &rR2 = aCRD.Ref2;
-+ aPool << ocBad;
-+ aPool >> aStack;
-+ break;
-+ }
-
+-
- rR1.nTab = nTabFirst;
- rR2.nTab = nTabLast;
- rR1.SetFlag3D( TRUE );
- rR1.SetTabRel( FALSE );
- rR2.SetFlag3D( nTabFirst != nTabLast );
- rR2.SetTabRel( FALSE );
-+ fprintf(stdout, "ExcelToSc8::Convert: first tab = %d; last tab = %d; external (%d)\n",
-+ nTabFirst, nTabLast, aExtInfo.mbExternal);
-+
-+ SingleRefData &rR1 = aCRD.Ref1;
-+ SingleRefData &rR2 = aCRD.Ref2;
-
+-
- ExcRelToScRel8( nRw1, nGrbitCol1, aCRD.Ref1, bRangeName );
- ExcRelToScRel8( nRw2, nGrbitCol2, aCRD.Ref2, bRangeName );
-+ rR1.nTab = nTabFirst;
-+ rR2.nTab = nTabLast;
-+ rR1.SetFlag3D( TRUE );
-+ rR1.SetTabRel( FALSE );
-+ rR2.SetFlag3D( nTabFirst != nTabLast );
-+ rR2.SetTabRel( FALSE );
-
+-
- if( IsComplColRange( nGrbitCol1, nGrbitCol2 ) )
- SetComplCol( aCRD );
- else if( IsComplRowRange( nRw1, nRw2 ) )
- SetComplRow( aCRD );
-+ ExcRelToScRel8( nRw1, nGrbitCol1, aCRD.Ref1, bRangeName );
-+ ExcRelToScRel8( nRw2, nGrbitCol2, aCRD.Ref2, bRangeName );
-
+-
- switch ( nOp )
- {
- case 0x5D:
@@ -3467,18 +3152,36 @@
- rR1.SetTabDeleted( TRUE );
- if ( !ValidTab(nTabLast) )
- rR2.SetTabDeleted( TRUE );
+-
+- aStack << aPool.Store( aCRD );
+- }
+- else
++ ExternalTabInfo aExtInfo;
++ if (!Read3DTabReference(nIxti, nTabFirst, nTabLast, aExtInfo))
+ {
+ aPool << ocBad;
+ aPool >> aStack;
++ break;
+ }
++
++ SingleRefData &rR1 = aCRD.Ref1;
++ SingleRefData &rR2 = aCRD.Ref2;
++
++ rR1.nTab = nTabFirst;
++ rR2.nTab = nTabLast;
++ rR1.SetFlag3D( TRUE );
++ rR1.SetTabRel( FALSE );
++ rR2.SetFlag3D( nTabFirst != nTabLast );
++ rR2.SetTabRel( FALSE );
++
++ ExcRelToScRel8( nRw1, nGrbitCol1, aCRD.Ref1, bRangeName );
++ ExcRelToScRel8( nRw2, nGrbitCol2, aCRD.Ref2, bRangeName );
++
+ if( IsComplColRange( nGrbitCol1, nGrbitCol2 ) )
+ SetComplCol( aCRD );
+ else if( IsComplRowRange( nRw1, nRw2 ) )
+ SetComplRow( aCRD );
-
-- aStack << aPool.Store( aCRD );
-- }
-- else
-- {
-- aPool << ocBad;
-- aPool >> aStack;
-- }
++
+ switch ( nOp )
+ {
+ case 0x5D:
@@ -3507,14 +3210,13 @@
}
break;
default: bError = TRUE;
-@@ -1143,7 +1231,135 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
+@@ -1143,7 +1199,130 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
return eRet;
}
+ConvErr ExcelToSc8::ConvertExternName( const ScTokenArray*& rpArray, XclImpStream& rStrm, sal_Size nFormulaLen,
+ const String& rUrl, const vector<String>& rTabNames )
+{
-+ StackPrinter __stack_print__("ExcelToSc8::ConvertExternName");
+ String aFileUrl = ScGlobal::GetAbsDocName(rUrl, GetDocShell());
+
+ sal_uInt8 nOp, nByte;
@@ -3546,7 +3248,7 @@
+ while( (rStrm.GetRecPos() < nEndPos) && !bError )
+ {
+ rStrm >> nOp;
-
++
+ // #98524# always reset flags
+ aSRD.InitFlags();
+ aCRD.InitFlags();
@@ -3577,10 +3279,8 @@
+ case 0x3A:
+ {
+ // cell reference in external range name
-+ fprintf(stdout, "ExcelToSc8::ConvertExternName: cell reference (0x3A)\n");
+ sal_uInt16 nExtTab1, nExtTab2, nRow, nGrbitCol;
+ rStrm >> nExtTab1 >> nExtTab2 >> nRow >> nGrbitCol;
-+ fprintf(stdout, "ExcelToSc8::ConvertExternName: tab1 = %d; tab2 = %d\n", nExtTab1, nExtTab2);
+ if (nExtTab1 >= nTabCount || nExtTab2 >= nTabCount)
+ {
+ bError = true;
@@ -3593,7 +3293,7 @@
+ ExcRelToScRel8(nRow, nGrbitCol, aSRD, true);
+ aCRD.Ref1 = aCRD.Ref2 = aSRD;
+ String aTabName = rTabNames[nExtTab1];
-+
+
+ if (nExtTab1 == nExtTab2)
+ {
+ // single cell reference
@@ -3605,11 +3305,9 @@
+ aCRD.Ref2.nTab = nExtTab2;
+ aStack << aPool.StoreExtRef(nFileId, aTabName, aCRD);
+ }
-+ fprintf(stdout, "ExcelToSc8::ConvertExternName: external ref inserted\n");
+ }
+ break;
+ default:
-+ fprintf(stdout, "ExcelToSc8::ConvertExternName: un-handled opcode (%2.2X)\n", nOp);
+ bError = true;
+ }
+ bError |= !rStrm.IsValid();
@@ -3643,41 +3341,6 @@
void ExcelToSc8::ExcRelToScRel8( UINT16 nRow, UINT16 nC, SingleRefData &rSRD, const BOOL bName )
{
-diff --git sc/source/filter/excel/impop.cxx sc/source/filter/excel/impop.cxx
-index 258a7c7..4687365 100644
---- sc/source/filter/excel/impop.cxx
-+++ sc/source/filter/excel/impop.cxx
-@@ -98,6 +98,30 @@
- using namespace ::com::sun::star;
-
-
-+namespace {
-+
-+#include <string>
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
-+
- const double ImportExcel::fExcToTwips =
- ( double ) TWIPS_PER_CHAR / 256.0;
-
diff --git sc/source/filter/excel/read.cxx sc/source/filter/excel/read.cxx
index 2cc592c..7f1c44b 100644
--- sc/source/filter/excel/read.cxx
@@ -3835,10 +3498,10 @@
diff --git sc/source/filter/excel/xeformula.cxx sc/source/filter/excel/xeformula.cxx
-index 3db8da7..e13d161 100644
+index 3db8da7..f9f87c2 100644
--- sc/source/filter/excel/xeformula.cxx
+++ sc/source/filter/excel/xeformula.cxx
-@@ -42,6 +42,12 @@
+@@ -42,6 +42,11 @@
#include "xelink.hxx"
#include "xename.hxx"
@@ -3846,12 +3509,11 @@
+#include "externalrefmgr.hxx"
+
+#include <memory>
-+#include <stdio.h>
+
// External reference log =====================================================
XclExpRefLogEntry::XclExpRefLogEntry() :
-@@ -225,6 +231,32 @@ void XclExpFuncData::IncExpParamClassIdx()
+@@ -225,6 +230,32 @@ void XclExpFuncData::IncExpParamClassIdx()
++mnClassIdx;
}
@@ -3884,7 +3546,7 @@
// ----------------------------------------------------------------------------
/** Implementation class of the export formula compiler. */
-@@ -299,6 +331,7 @@ private:
+@@ -299,6 +330,7 @@ private:
void ProcessBoolean( const XclExpTokenData& rTokData );
void ProcessDdeLink( const XclExpTokenData& rTokData, sal_uInt8 nExpClass );
void ProcessExternal( const XclExpTokenData& rTokData, sal_uInt8 nExpClass );
@@ -3892,7 +3554,7 @@
void ProcessFunction( const XclExpTokenData& rTokData, sal_uInt8 nExpClass );
void PrepareFunction( XclExpFuncData& rFuncData );
-@@ -1114,6 +1147,12 @@ XclExpTokenData XclExpFmlaCompImpl::Factor( XclExpTokenData aTokData, sal_uInt8
+@@ -1114,6 +1146,12 @@ XclExpTokenData XclExpFmlaCompImpl::Factor( XclExpTokenData aTokData, sal_uInt8
StackVar eTokType = aTokData.GetType();
OpCode eOpCode = aTokData.GetOpCode();
@@ -3905,7 +3567,7 @@
switch( eTokType )
{
case svUnknown: mbOk = false; break;
-@@ -1248,6 +1287,135 @@ void XclExpFmlaCompImpl::ProcessExternal( const XclExpTokenData& rTokData, sal_u
+@@ -1248,6 +1286,133 @@ void XclExpFmlaCompImpl::ProcessExternal( const XclExpTokenData& rTokData, sal_u
ProcessFunction( rTokData, nExpClass );
}
@@ -3996,8 +3658,6 @@
+ break;
+ case svExternalName:
+ {
-+ fprintf(stdout, "XclExpFmlaCompImpl::ProcessExternalName: svExternalName\n");
-+
+ const String& aName = rTokData.mpScToken->GetString();
+ ScTokenArray* pArray = pRefMgr->getRangeNameTokens(nFileId, aName);
+ if (!pArray || !mpScBasePos)
@@ -4041,7 +3701,7 @@
void XclExpFmlaCompImpl::ProcessFunction( const XclExpTokenData& rTokData, sal_uInt8 nExpClass )
{
OpCode eOpCode = rTokData.GetOpCode();
-@@ -1623,32 +1791,6 @@ void XclExpFmlaCompImpl::AppendTrailingParam( XclExpFuncData& rFuncData )
+@@ -1623,32 +1788,6 @@ void XclExpFmlaCompImpl::AppendTrailingParam( XclExpFuncData& rFuncData )
}
}
@@ -4075,10 +3735,10 @@
SCTAB XclExpFmlaCompImpl::GetScTab( const SingleRefData& rRefData ) const
diff --git sc/source/filter/excel/xelink.cxx sc/source/filter/excel/xelink.cxx
-index b1bacad..b643eda 100644
+index b1bacad..08517ca 100644
--- sc/source/filter/excel/xelink.cxx
+++ sc/source/filter/excel/xelink.cxx
-@@ -38,6 +38,40 @@
+@@ -38,6 +38,14 @@
#include "document.hxx"
#include "cell.hxx"
#include "scextopt.hxx"
@@ -4086,48 +3746,22 @@
+
+#include <vector>
+#include <memory>
-+#include <stdio.h>
+
+using ::std::auto_ptr;
+using ::std::find_if;
+using ::std::vector;
+
+ // ============================================================================
+ // *** Helper classes ***
+@@ -102,6 +110,25 @@ private:
+ XclExpCachedMatRef mxMatrix; /// Cached results of the DDE link.
+ };
+
++// ----------------------------------------------------------------------------
+
++class XclExpSupbook;
+
-+namespace {
-+
-+#include <string>
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
-
- // ============================================================================
- // *** Helper classes ***
-@@ -102,6 +136,25 @@ private:
- XclExpCachedMatRef mxMatrix; /// Cached results of the DDE link.
- };
-
-+// ----------------------------------------------------------------------------
-+
-+class XclExpSupbook;
-+
-+class XclExpExtName : public XclExpExtNameBase
++class XclExpExtName : public XclExpExtNameBase
+{
+public:
+ explicit XclExpExtName( const XclExpRoot& rRoot, const XclExpSupbook& rSupbook, const String& rName,
@@ -4145,7 +3779,7 @@
// List of external names =====================================================
/** List of all external names of a sheet. */
-@@ -117,6 +170,8 @@ public:
+@@ -117,6 +144,8 @@ public:
@return The 1-based (Excel-like) list index of the DDE link. */
sal_uInt16 InsertDde( const String& rApplic, const String& rTopic, const String& rItem );
@@ -4154,7 +3788,7 @@
/** Writes the EXTERNNAME record list. */
virtual void Save( XclExpStream& rStrm );
-@@ -220,6 +275,9 @@ public:
+@@ -220,6 +249,9 @@ public:
/** Stores all cells in the given range in the CRN list. */
void StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange );
@@ -4164,7 +3798,7 @@
/** Writes the XCT and all CRN records. */
virtual void Save( XclExpStream& rStrm );
-@@ -319,6 +377,12 @@ public:
+@@ -319,6 +351,12 @@ public:
/** Stores all cells in the given range in the CRN list of the specified SUPBOOK sheet. */
void StoreCellRange( const ScRange& rRange, sal_uInt16 nSBTab );
@@ -4177,7 +3811,7 @@
/** Inserts a new sheet name into the SUPBOOK and returns the SUPBOOK internal sheet index. */
sal_uInt16 InsertTabName( const String& rTabName );
/** Finds or inserts an EXTERNNAME record for add-ins.
-@@ -328,6 +392,8 @@ public:
+@@ -328,6 +366,8 @@ public:
@return The 1-based EXTERNNAME record index; or 0, if the record list is full. */
sal_uInt16 InsertDde( const String& rItem );
@@ -4186,7 +3820,7 @@
/** Writes the SUPBOOK and all EXTERNNAME, XCT and CRN records. */
virtual void Save( XclExpStream& rStrm );
-@@ -394,6 +460,9 @@ public:
+@@ -394,6 +434,9 @@ public:
/** Stores all cells in the given range in a CRN record list. */
void StoreCellRange( const ScRange& rRange );
@@ -4196,7 +3830,7 @@
/** Finds or inserts an EXTERNNAME record for an add-in function name.
@param rnSupbook Returns the index of the SUPBOOK record which contains the add-in function name.
@param rnExtName Returns the 1-based EXTERNNAME record index. */
-@@ -407,9 +476,25 @@ public:
+@@ -407,9 +450,25 @@ public:
sal_uInt16& rnSupbook, sal_uInt16& rnExtName,
const String& rApplic, const String& rTopic, const String& rItem );
@@ -4222,7 +3856,7 @@
private:
typedef XclExpRecordList< XclExpSupbook > XclExpSupbookList;
typedef XclExpSupbookList::RecordRefType XclExpSupbookRef;
-@@ -431,19 +516,8 @@ private:
+@@ -431,19 +490,8 @@ private:
/** Appends a new SUPBOOK to the list.
@return The list index of the SUPBOOK record. */
sal_uInt16 Append( XclExpSupbookRef xSupbook );
@@ -4242,7 +3876,7 @@
XclExpSupbookList maSupbookList; /// List of all SUPBOOK records.
XclExpSBIndexVec maSBIndexVec; /// SUPBOOK and sheet name index for each Excel sheet.
sal_uInt16 mnOwnDocSB; /// Index to SUPBOOK for own document.
-@@ -464,9 +538,16 @@ public:
+@@ -464,9 +512,16 @@ public:
/** Derived classes search for a special EXTERNSHEET index for the own document. */
virtual sal_uInt16 FindExtSheet( sal_Unicode cCode ) = 0;
@@ -4259,7 +3893,7 @@
/** Derived classes find or insert an EXTERNNAME record for an add-in function name. */
virtual bool InsertAddIn(
sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
-@@ -476,6 +557,10 @@ public:
+@@ -476,6 +531,10 @@ public:
sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
const String& rApplic, const String& rTopic, const String& rItem ) = 0;
@@ -4270,7 +3904,7 @@
/** Derived classes write the entire link table to the passed stream. */
virtual void Save( XclExpStream& rStrm ) = 0;
-@@ -497,15 +582,27 @@ public:
+@@ -497,15 +556,27 @@ public:
XclExpRefLogEntry* pRefLogEntry );
virtual sal_uInt16 FindExtSheet( sal_Unicode cCode );
@@ -4298,7 +3932,7 @@
virtual void Save( XclExpStream& rStrm );
private:
-@@ -550,15 +647,27 @@ public:
+@@ -550,15 +621,27 @@ public:
XclExpRefLogEntry* pRefLogEntry );
virtual sal_uInt16 FindExtSheet( sal_Unicode cCode );
@@ -4326,7 +3960,7 @@
virtual void Save( XclExpStream& rStrm );
private:
-@@ -885,6 +994,100 @@ void XclExpExtNameDde::WriteAddData( XclExpStream& rStrm )
+@@ -885,6 +968,100 @@ void XclExpExtNameDde::WriteAddData( XclExpStream& rStrm )
mxMatrix->Save( rStrm );
}
@@ -4427,7 +4061,7 @@
// List of external names =====================================================
XclExpExtNameBuffer::XclExpExtNameBuffer( const XclExpRoot& rRoot ) :
-@@ -920,6 +1123,12 @@ sal_uInt16 XclExpExtNameBuffer::InsertDde(
+@@ -920,6 +1097,12 @@ sal_uInt16 XclExpExtNameBuffer::InsertDde(
return nIndex;
}
@@ -4440,7 +4074,7 @@
void XclExpExtNameBuffer::Save( XclExpStream& rStrm )
{
maNameList.Save( rStrm );
-@@ -1066,6 +1275,83 @@ void XclExpXct::StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange )
+@@ -1066,6 +1249,78 @@ void XclExpXct::StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange )
maUsedCells.SetMultiMarkArea( rRange );
}
@@ -4474,7 +4108,6 @@
+
+void XclExpXct::StoreCellRange( const XclExpRoot& /*rRoot*/, const ScRange& rRange, const ScToken& rToken )
+{
-+ StackPrinter __stack_print__("XclExpXct::StoreCellRange");
+ if (rToken.GetType() != svMatrix)
+ return;
+
@@ -4506,16 +4139,12 @@
+ XclExpCrnRef xCrn(new XclExpCrnString(
+ s.Col() + nCol, s.Row() + nRow, pMtx->GetString(nCol, nRow)));
+ maCrnList.AppendRecord(xCrn);
-+ fprintf(stdout, "XclExpXct::StoreCellRange: storing at (col=%d; row=%d) (%s)\n",
-+ s.Col()+nCol, s.Row()+nRow, rtl::OUStringToOString(pMtx->GetString(nCol, nRow), RTL_TEXTENCODING_UTF8).getStr());
+ }
+ else if (pMtx->IsValueOrEmpty(nCol, nRow))
+ {
+ XclExpCrnRef xCrn(new XclExpCrnDouble(
+ s.Col() + nCol, s.Row() + nRow, pMtx->GetDouble(nCol, nRow)));
+ maCrnList.AppendRecord(xCrn);
-+ fprintf(stdout, "XclExpXct::StoreCellRange: storing at (col=%d; row=%d) (%g)\n",
-+ s.Col()+nCol, s.Row()+nRow, pMtx->GetDouble(nCol, nRow));
+ }
+ }
+ }
@@ -4524,7 +4153,7 @@
void XclExpXct::Save( XclExpStream& rStrm )
{
XclExpRecord::Save( rStrm );
-@@ -1168,6 +1454,21 @@ XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, const String& rUrl ) :
+@@ -1168,6 +1423,17 @@ XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, const String& rUrl ) :
mnXclTabCount( 0 )
{
SetRecSize( 2 + maUrlEncoded.GetSize() );
@@ -4538,15 +4167,11 @@
+
+ vector<String>::const_iterator itr = pTabNames->begin(), itrEnd = pTabNames->end();
+ for (; itr != itrEnd; ++itr)
-+ {
-+ fprintf(stdout, "XclExpSupbook::InsertTabName: name = '%s'\n",
-+ rtl::OUStringToOString(*itr, RTL_TEXTENCODING_UTF8).getStr());
+ InsertTabName(*itr);
-+ }
}
XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, const String& rApplic, const String& rTopic ) :
-@@ -1206,6 +1507,46 @@ void XclExpSupbook::StoreCellRange( const ScRange& rRange, sal_uInt16 nSBTab )
+@@ -1206,6 +1472,46 @@ void XclExpSupbook::StoreCellRange( const ScRange& rRange, sal_uInt16 nSBTab )
xXct->StoreCellRange( GetRoot(), rRange );
}
@@ -4593,7 +4218,7 @@
sal_uInt16 XclExpSupbook::InsertTabName( const String& rTabName )
{
DBG_ASSERT( meType == EXC_SBTYPE_EXTERN, "XclExpSupbook::InsertTabName - don't insert sheet names here" );
-@@ -1226,6 +1567,11 @@ sal_uInt16 XclExpSupbook::InsertDde( const String& rItem )
+@@ -1226,6 +1532,11 @@ sal_uInt16 XclExpSupbook::InsertDde( const String& rItem )
return GetExtNameBuffer().InsertDde( maUrl, maDdeTopic, rItem );
}
@@ -4605,7 +4230,7 @@
void XclExpSupbook::Save( XclExpStream& rStrm )
{
// SUPBOOK record
-@@ -1289,11 +1635,6 @@ XclExpSupbookBuffer::XclExpSupbookBuffer( const XclExpRoot& rRoot ) :
+@@ -1289,11 +1600,6 @@ XclExpSupbookBuffer::XclExpSupbookBuffer( const XclExpRoot& rRoot ) :
mnOwnDocSB = Append( xSupbook );
for( sal_uInt16 nXclTab = 0; nXclTab < nXclCnt; ++nXclTab )
maSBIndexVec[ nXclTab ].Set( mnOwnDocSB, nXclTab );
@@ -4617,7 +4242,7 @@
}
}
-@@ -1352,6 +1693,134 @@ void XclExpSupbookBuffer::StoreCellRange( const ScRange& rRange )
+@@ -1352,6 +1658,130 @@ void XclExpSupbookBuffer::StoreCellRange( const ScRange& rRange )
}
}
@@ -4666,7 +4291,6 @@
+ return;
+
+ FindSBIndexEntry f(nSupbookId, nSheetId);
-+ fprintf(stdout, "XclExpSupbookBuffer::StoreCell: supbook id = %d; sheet id = %d\n", nSupbookId, nSheetId);
+ XclExpSBIndexVec::iterator itrEnd = maSBIndexVec.end();
+ XclExpSBIndexVec::const_iterator itr = find_if(maSBIndexVec.begin(), itrEnd, f);
+ if (itr == itrEnd)
@@ -4682,8 +4306,6 @@
+
+void XclExpSupbookBuffer::StoreCellRange( sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange )
+{
-+ StackPrinter __stack_print__("XclExpSupbookBuffer::StoreCellRange");
-+
+ ScExternalRefManager* pRefMgr = GetDoc().GetExternalRefManager();
+ const String* pUrl = pRefMgr->getExternalFileName(nFileId);
+ if (!pUrl)
@@ -4714,7 +4336,7 @@
+ aMatrixList.push_back(p);
+ else if (p->GetOpCode() != ocSep)
+ {
-+ fprintf(stdout, "XclExpSupbookBuffer::StoreCellRange: this is supposed to be ocSep!!!\n");
++ // This is supposed to be ocSep!!!
+ return;
+ }
+ }
@@ -4744,7 +4366,6 @@
+ r.mnSBTab = nSheetId;
+ }
+
-+ fprintf(stdout, "XclExpSupbookBuffer::StoreCellRange: supbook sheet id = %d\n", nSheetId);
+ xSupbook->StoreCellRange(nSheetId, aRange, *aMatrixList[nTab]);
+ }
+}
@@ -4752,7 +4373,7 @@
bool XclExpSupbookBuffer::InsertAddIn(
sal_uInt16& rnSupbook, sal_uInt16& rnExtName, const String& rName )
{
-@@ -1383,6 +1852,83 @@ bool XclExpSupbookBuffer::InsertDde(
+@@ -1383,6 +1813,78 @@ bool XclExpSupbookBuffer::InsertDde(
return rnExtName > 0;
}
@@ -4773,10 +4394,6 @@
+XclExpXti XclExpSupbookBuffer::GetXti( sal_uInt16 nFileId, const String& rTabName, sal_uInt16 nXclTabSpan,
+ XclExpRefLogEntry* pRefLogEntry )
+{
-+ StackPrinter __stack_print__("XclExpSupbookBuffer::GetXti");
-+ fprintf(stdout, "XclExpSupbookBuffer::GetXti: tab name = '%s'; tab span = %d\n",
-+ rtl::OUStringToOString(rTabName, RTL_TEXTENCODING_UTF8).getStr(), nXclTabSpan);
-+
+ XclExpXti aXti(0, EXC_NOTAB, EXC_NOTAB);
+ ScExternalRefManager* pRefMgr = GetDoc().GetExternalRefManager();
+ const String* pUrl = pRefMgr->getExternalFileName(nFileId);
@@ -4795,8 +4412,7 @@
+ sal_uInt16 nFirstSheetId = xSupbook->GetTabIndex(rTabName);
+ if (nFirstSheetId == EXC_NOTAB)
+ {
-+ fprintf(stdout, "XclExpSupbookBuffer::GetXti: first sheet not found in SUPBOOK (%s)\n",
-+ rtl::OUStringToOString(rTabName, RTL_TEXTENCODING_UTF8).getStr());
++ // first sheet not found in SUPBOOK.
+ return aXti;
+ }
+ sal_uInt16 nSheetCount = xSupbook->GetTabCount();
@@ -4836,7 +4452,7 @@
void XclExpSupbookBuffer::Save( XclExpStream& rStrm )
{
maSupbookList.Save( rStrm );
-@@ -1424,27 +1970,6 @@ sal_uInt16 XclExpSupbookBuffer::Append( XclExpSupbookRef xSupbook )
+@@ -1424,27 +1926,6 @@ sal_uInt16 XclExpSupbookBuffer::Append( XclExpSupbookRef xSupbook )
return ulimit_cast< sal_uInt16 >( maSupbookList.GetSize() - 1 );
}
@@ -4864,7 +4480,7 @@
// Export link manager ========================================================
XclExpLinkManagerImpl::XclExpLinkManagerImpl( const XclExpRoot& rRoot ) :
-@@ -1485,11 +2010,29 @@ sal_uInt16 XclExpLinkManagerImpl5::FindExtSheet( sal_Unicode cCode )
+@@ -1485,11 +1966,29 @@ sal_uInt16 XclExpLinkManagerImpl5::FindExtSheet( sal_Unicode cCode )
return nExtSheet;
}
@@ -4894,7 +4510,7 @@
bool XclExpLinkManagerImpl5::InsertAddIn(
sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rName )
{
-@@ -1510,6 +2053,14 @@ bool XclExpLinkManagerImpl5::InsertDde(
+@@ -1510,6 +2009,14 @@ bool XclExpLinkManagerImpl5::InsertDde(
return false;
}
@@ -4909,7 +4525,7 @@
void XclExpLinkManagerImpl5::Save( XclExpStream& rStrm )
{
if( sal_uInt16 nExtSheetCount = GetExtSheetCount() )
-@@ -1630,6 +2181,17 @@ sal_uInt16 XclExpLinkManagerImpl8::FindExtSheet( sal_Unicode cCode )
+@@ -1630,6 +2137,17 @@ sal_uInt16 XclExpLinkManagerImpl8::FindExtSheet( sal_Unicode cCode )
return InsertXti( maSBBuffer.GetXti( EXC_TAB_EXTERNAL, EXC_TAB_EXTERNAL ) );
}
@@ -4927,7 +4543,7 @@
void XclExpLinkManagerImpl8::StoreCellRange( const SingleRefData& rRef1, const SingleRefData& rRef2 )
{
if( !rRef1.IsDeleted() && !rRef2.IsDeleted() && (rRef1.nTab >= 0) && (rRef2.nTab >= 0) )
-@@ -1652,6 +2214,19 @@ void XclExpLinkManagerImpl8::StoreCellRange( const SingleRefData& rRef1, const S
+@@ -1652,6 +2170,19 @@ void XclExpLinkManagerImpl8::StoreCellRange( const SingleRefData& rRef1, const S
}
}
@@ -4947,7 +4563,7 @@
bool XclExpLinkManagerImpl8::InsertAddIn(
sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rName )
{
-@@ -1677,6 +2252,18 @@ bool XclExpLinkManagerImpl8::InsertDde(
+@@ -1677,6 +2208,18 @@ bool XclExpLinkManagerImpl8::InsertDde(
return false;
}
@@ -4966,7 +4582,7 @@
void XclExpLinkManagerImpl8::Save( XclExpStream& rStrm )
{
if( !maXtiVec.empty() )
-@@ -1745,6 +2332,13 @@ sal_uInt16 XclExpLinkManager::FindExtSheet( sal_Unicode cCode )
+@@ -1745,6 +2288,13 @@ sal_uInt16 XclExpLinkManager::FindExtSheet( sal_Unicode cCode )
return mxImpl->FindExtSheet( cCode );
}
@@ -4980,7 +4596,7 @@
void XclExpLinkManager::StoreCell( const SingleRefData& rRef )
{
mxImpl->StoreCellRange( rRef, rRef );
-@@ -1755,6 +2349,16 @@ void XclExpLinkManager::StoreCellRange( const ComplRefData& rRef )
+@@ -1755,6 +2305,16 @@ void XclExpLinkManager::StoreCellRange( const ComplRefData& rRef )
mxImpl->StoreCellRange( rRef.Ref1, rRef.Ref2 );
}
@@ -4997,7 +4613,7 @@
bool XclExpLinkManager::InsertAddIn(
sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rName )
{
-@@ -1768,6 +2372,13 @@ bool XclExpLinkManager::InsertDde(
+@@ -1768,6 +2328,13 @@ bool XclExpLinkManager::InsertDde(
return mxImpl->InsertDde( rnExtSheet, rnExtName, rApplic, rTopic, rItem );
}
@@ -5012,10 +4628,10 @@
{
mxImpl->Save( rStrm );
diff --git sc/source/filter/excel/xilink.cxx sc/source/filter/excel/xilink.cxx
-index 01932a5..ae4623c 100644
+index 01932a5..b7bb04b 100644
--- sc/source/filter/excel/xilink.cxx
+++ sc/source/filter/excel/xilink.cxx
-@@ -38,6 +38,37 @@
+@@ -38,6 +38,13 @@
#include "xistream.hxx"
#include "xihelper.hxx"
#include "xiname.hxx"
@@ -5026,70 +4642,38 @@
+#include <vector>
+
+using ::std::vector;
-+
-+namespace {
-+
-+#include <string>
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
// ============================================================================
// *** Helper classes ***
-@@ -52,8 +83,12 @@ public:
+@@ -52,8 +59,7 @@ public:
/** Reads a cached value and stores it with its cell address. */
explicit XclImpCrn( XclImpStream& rStrm, const XclAddress& rXclPos );
+- /** Copies the cached value to sheet nTab in the document. */
+- void SetCell( const XclImpRoot& rRoot, SCTAB nScTab ) const;
+ const XclAddress& GetAddress() const;
-+
-+#if 0
- /** Copies the cached value to sheet nTab in the document. */
- void SetCell( const XclImpRoot& rRoot, SCTAB nScTab ) const;
-+#endif
private:
XclAddress maXclPos; /// Excel position of the cached cell.
-@@ -71,16 +106,21 @@ public:
+@@ -71,16 +77,11 @@ public:
~XclImpSupbookTab();
inline const String& GetTabName() const { return maTabName; }
-+#if 0
- inline SCTAB GetScTab() const { return mnScTab; }
--
-+#endif
+- inline SCTAB GetScTab() const { return mnScTab; }
+
/** Reads a CRN record (external referenced cell) at the specified address. */
void ReadCrn( XclImpStream& rStrm, const XclAddress& rXclPos );
-+#if 0
- /** Creates a new linked table in the passed document and fills it with the cached cells.
- @descr Stores the index of the new sheet, will be accessible with GetScTab(). */
- void CreateAndFillTable(
- const XclImpRoot& rRoot, const String& rAbsUrl,
- const String& rFilterName, const String& rFilterOpt );
-+#endif
-+
+- /** Creates a new linked table in the passed document and fills it with the cached cells.
+- @descr Stores the index of the new sheet, will be accessible with GetScTab(). */
+- void CreateAndFillTable(
+- const XclImpRoot& rRoot, const String& rAbsUrl,
+- const String& rFilterName, const String& rFilterOpt );
+ void LoadCachedValues(ScExternalRefCache::Table* pCacheTable);
private:
typedef ScfDelList< XclImpCrn > XclImpCrnList;
-@@ -105,18 +145,20 @@ public:
+@@ -105,7 +106,7 @@ public:
/** Reads a CRN record (external referenced cell). */
void ReadCrn( XclImpStream& rStrm );
/** Reads an EXTERNNAME record. */
@@ -5098,40 +4682,35 @@
/** Returns the SUPBOOK record type. */
inline XclSupbookType GetType() const { return meType; }
-
+@@ -113,11 +114,6 @@ public:
/** Returns the URL of the external document. */
inline const String& GetXclUrl() const { return maXclUrl; }
--
-+#if 0
- /** Returns Calc sheet index from Excel sheet index. */
- SCTAB GetScTabNum( sal_uInt16 nXclTab ) const;
- /** Returns Calc sheet index from sheet name. */
- SCTAB GetScTabNum( const String& rTabName ) const;
-+#endif
-+ sal_uInt16 GetXclTabNum( const String& rTabName ) const;
+- /** Returns Calc sheet index from Excel sheet index. */
+- SCTAB GetScTabNum( sal_uInt16 nXclTab ) const;
+- /** Returns Calc sheet index from sheet name. */
+- SCTAB GetScTabNum( const String& rTabName ) const;
+-
/** Returns the external name specified by an index from the Excel document (one-based). */
const XclImpExtName* GetExternName( sal_uInt16 nXclIndex ) const;
-@@ -128,10 +170,18 @@ public:
+ /** Tries to decode the URL to OLE or DDE link components.
+@@ -128,10 +124,11 @@ public:
/** Returns the specified macro name (1-based) or an empty string on error. */
const String& GetMacroName( sal_uInt16 nXclNameIdx ) const;
+- /** Creates all sheets of this external document.
+- @param nFirstTab The external Excel index of the first sheet to be created.
+- @param nLastTab The external Excel index of the last sheet to be created. */
+- void CreateTables( sal_uInt16 nSBTabFirst, sal_uInt16 nSBTabLast );
+ const String& GetTabName( sal_uInt16 nXtiTab ) const;
+
+ sal_uInt16 GetTabCount() const;
+
-+#if 0
- /** Creates all sheets of this external document.
- @param nFirstTab The external Excel index of the first sheet to be created.
- @param nLastTab The external Excel index of the last sheet to be created. */
- void CreateTables( sal_uInt16 nSBTabFirst, sal_uInt16 nSBTabLast );
-+#endif
-+
+ void LoadCachedValues();
private:
typedef ScfDelList< XclImpSupbookTab > XclImpSupbookTabList;
-@@ -180,7 +230,7 @@ public:
+@@ -180,7 +177,7 @@ public:
/** Reads a CRN record and appends it to the current SUPBOOK. */
void ReadCrn( XclImpStream& rStrm );
/** Reads an EXTERNNAME record and appends it to the current SUPBOOK. */
@@ -5140,7 +4719,7 @@
/** Returns true, if the specified XTI entry contains an internal reference. */
bool IsSelfRef( sal_uInt16 nXtiIndex ) const;
-@@ -191,6 +241,13 @@ public:
+@@ -191,6 +188,13 @@ public:
sal_uInt16 nXtiIndex ) const;
/** Returns the specified external name or 0 on error. */
const XclImpExtName* GetExternName( sal_uInt16 nXtiIndex, sal_uInt16 nExtName ) const;
@@ -5154,51 +4733,43 @@
/** Tries to decode the URL of the specified XTI entry to OLE or DDE link components.
@descr For DDE links: Decodes to application name and topic.
For OLE object links: Decodes to class name and document URL.
-@@ -198,19 +255,23 @@ public:
- bool GetLinkData( String& rApplic, String& rTopic, sal_uInt16 nXtiIndex ) const;
+@@ -199,18 +203,13 @@ public:
/** Returns the specified macro name or an empty string on error. */
const String& GetMacroName( sal_uInt16 nExtSheet, sal_uInt16 nExtName ) const;
--
-+#if 0
- /** Returns the Calc sheet index of a table in an external document.
- @return Calc sheet index or EXC_TAB_INVALID on error. */
- SCTAB GetScTab( const String& rUrl, const String& rTabName ) const;
-+#endif
-+ sal_uInt16 GetXclTab( const String& rUrl, const String& rTabName ) const;
+- /** Returns the Calc sheet index of a table in an external document.
+- @return Calc sheet index or EXC_TAB_INVALID on error. */
+- SCTAB GetScTab( const String& rUrl, const String& rTabName ) const;
+-
private:
/** Returns the specified SUPBOOK (external document). */
const XclImpSupbook* GetSupbook( sal_uInt32 nXtiIndex ) const;
/** Returns the SUPBOOK (external workbook) specified by its URL. */
const XclImpSupbook* GetSupbook( const String& rUrl ) const;
--
-+#if 0
- /** Creates all external sheets in the Calc document. */
- void CreateTables();
-+#endif
+
+- /** Creates all external sheets in the Calc document. */
+- void CreateTables();
+ void LoadCachedValues();
/** Finds the largest range of sheet indexes in a SUPBOOK after a start sheet index.
@param rnSBTabFirst (out-param) The first sheet index of the range in SUPBOOK is returned here.
-@@ -291,13 +352,16 @@ sal_uInt16 XclImpTabInfo::GetCurrentIndex( sal_uInt16 nCreatedId, sal_uInt16 nMa
+@@ -291,14 +290,13 @@ sal_uInt16 XclImpTabInfo::GetCurrentIndex( sal_uInt16 nCreatedId, sal_uInt16 nMa
// External names =============================================================
-XclImpExtName::XclImpExtName( XclImpStream& rStrm, bool bAddIn )
+XclImpExtName::XclImpExtName( const XclImpSupbook& rSupbook, XclImpStream& rStrm, bool bAddIn, ExcelToSc* pFormulaConv )
{
-+ StackPrinter __stack_print__("XclImpExtName::XclImpExtName");
sal_uInt16 nFlags;
sal_uInt8 nLen;
rStrm >> nFlags >> mnStorageId >> nLen ;
maName = rStrm.ReadUniString( nLen );
-+ fprintf(stdout, "XclImpExtName::XclImpExtName: flags = 0x%2.2X; storage id = %d; name = '%s'\n",
-+ nFlags, mnStorageId, rtl::OUStringToOString(maName, RTL_TEXTENCODING_UTF8).getStr());
-
+-
if( ::get_flag( nFlags, EXC_EXTN_BUILTIN ) || !::get_flag( nFlags, EXC_EXTN_OLE_OR_DDE ) )
{
-@@ -319,6 +383,35 @@ XclImpExtName::XclImpExtName( XclImpStream& rStrm, bool bAddIn )
+ if( bAddIn )
+@@ -319,6 +317,28 @@ XclImpExtName::XclImpExtName( XclImpStream& rStrm, bool bAddIn )
if( (meType == xlExtDDE) && (rStrm.GetRecLeft() > 1) )
mxDdeMatrix.reset( new XclImpCachedMatrix( rStrm ) );
@@ -5207,7 +4778,6 @@
+ {
+ if (mnStorageId == 0)
+ {
-+ fprintf(stdout, "XclImpExtName::XclImpExtName: global external name\n");
+ if (pFormulaConv)
+ {
+ const ScTokenArray* pArray = NULL;
@@ -5215,32 +4785,25 @@
+ rStrm >> nFmlaLen;
+ vector<String> aTabNames;
+ sal_uInt16 nCount = rSupbook.GetTabCount();
-+ fprintf(stdout, "XclImpExtName::XclImpExtName: tab count = %d\n", nCount);
+ aTabNames.reserve(nCount);
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ aTabNames.push_back(rSupbook.GetTabName(i));
+
+ pFormulaConv->ConvertExternName(pArray, rStrm, nFmlaLen, rSupbook.GetXclUrl(), aTabNames);
+ if (pArray)
-+ {
-+ fprintf(stdout, "XclImpExtName::XclImpExtName: formula token processed\n");
+ mxArray.reset(pArray->Clone());
-+ }
+ }
+ }
-+ else
-+ fprintf(stdout, "XclImpExtName::XclImpExtName: external name for sheet %ld\n", mnStorageId);
+ }
}
XclImpExtName::~XclImpExtName()
-@@ -333,6 +426,13 @@ void XclImpExtName::CreateDdeData( ScDocument& rDoc, const String& rApplic, cons
+@@ -333,6 +353,12 @@ void XclImpExtName::CreateDdeData( ScDocument& rDoc, const String& rApplic, cons
rDoc.CreateDdeLink( rApplic, rTopic, maName, SC_DDE_DEFAULT, xResults );
}
+void XclImpExtName::CreateExtNameData( ScDocument& rDoc, sal_uInt16 nFileId ) const
+{
-+ StackPrinter __stack_print__("XclImpExtName::CreateExtNameData");
+ ScExternalRefManager* pRefMgr = rDoc.GetExternalRefManager();
+ pRefMgr->storeRangeNameTokens(nFileId, maName, *mxArray);
+}
@@ -5248,143 +4811,128 @@
// Cached external cells ======================================================
XclImpCrn::XclImpCrn( XclImpStream& rStrm, const XclAddress& rXclPos ) :
-@@ -341,6 +441,12 @@ XclImpCrn::XclImpCrn( XclImpStream& rStrm, const XclAddress& rXclPos ) :
+@@ -341,29 +367,9 @@ XclImpCrn::XclImpCrn( XclImpStream& rStrm, const XclAddress& rXclPos ) :
{
}
+-void XclImpCrn::SetCell( const XclImpRoot& rRoot, SCTAB nScTab ) const
+const XclAddress& XclImpCrn::GetAddress() const
-+{
-+ return maXclPos;
-+}
-+
-+#if 0
- void XclImpCrn::SetCell( const XclImpRoot& rRoot, SCTAB nScTab ) const
{
- ScAddress aScPos( ScAddress::UNINITIALIZED );
-@@ -365,6 +471,7 @@ void XclImpCrn::SetCell( const XclImpRoot& rRoot, SCTAB nScTab ) const
- }
- }
+- ScAddress aScPos( ScAddress::UNINITIALIZED );
+- if( rRoot.GetAddressConverter().ConvertAddress( aScPos, maXclPos, nScTab, false ) )
+- {
+- switch( GetType() )
+- {
+- case EXC_CACHEDVAL_DOUBLE:
+- rRoot.GetDoc().SetValue( aScPos.Col(), aScPos.Row(), aScPos.Tab(), GetValue() );
+- break;
+- case EXC_CACHEDVAL_STRING:
+- rRoot.GetDoc().PutCell( aScPos, new ScStringCell( GetString() ) );
+- break;
+- case EXC_CACHEDVAL_BOOL:
+- case EXC_CACHEDVAL_ERROR:
+- {
+- ScFormulaCell* pFmlaCell = new ScFormulaCell( rRoot.GetDocPtr(), aScPos, GetBoolErrFmla() );
+- pFmlaCell->SetHybridDouble( GetBool() ? 1.0 : 0.0 ); // GetBool() returns false for error codes
+- rRoot.GetDoc().PutCell( aScPos, pFmlaCell );
+- }
+- break;
+- }
+- }
++ return maXclPos;
}
-+#endif
// Sheet in an external document ==============================================
-
-@@ -383,6 +490,7 @@ void XclImpSupbookTab::ReadCrn( XclImpStream& rStrm, const XclAddress& rXclPos )
+@@ -383,13 +389,40 @@ void XclImpSupbookTab::ReadCrn( XclImpStream& rStrm, const XclAddress& rXclPos )
maCrnList.Append( new XclImpCrn( rStrm, rXclPos ) );
}
-+#if 0
- void XclImpSupbookTab::CreateAndFillTable( const XclImpRoot& rRoot,
- const String& rAbsUrl, const String& rFilterName, const String& rFilterOpt )
- {
-@@ -391,6 +499,53 @@ void XclImpSupbookTab::CreateAndFillTable( const XclImpRoot& rRoot,
- for( const XclImpCrn* pCrn = maCrnList.First(); pCrn; pCrn = maCrnList.Next() )
- pCrn->SetCell( rRoot, mnScTab );
- }
-+#endif
-+
+-void XclImpSupbookTab::CreateAndFillTable( const XclImpRoot& rRoot,
+- const String& rAbsUrl, const String& rFilterName, const String& rFilterOpt )
+void XclImpSupbookTab::LoadCachedValues(ScExternalRefCache::Table* pCacheTable)
-+{
-+ StackPrinter __stack_print__("XclImpSupbookTab::LoadCachedValues");
+ {
+- if( mnScTab == SCTAB_INVALID )
+- if( rRoot.GetDoc().InsertLinkedEmptyTab( mnScTab, rAbsUrl, rFilterName, rFilterOpt, maTabName ) )
+- for( const XclImpCrn* pCrn = maCrnList.First(); pCrn; pCrn = maCrnList.Next() )
+- pCrn->SetCell( rRoot, mnScTab );
+ if (maCrnList.Empty())
-+ {
-+ fprintf(stdout, "XclImpSupbookTab::LoadCachedValues: no CRN record to speak of\n");
+ return;
-+ }
+
+ for (XclImpCrn* p = maCrnList.First(); p; p = maCrnList.Next())
+ {
+ const XclAddress& rAddr = p->GetAddress();
-+ fprintf(stdout, "XclImpSupbookTab::LoadCachedValues: col = %d; row = %d\n", rAddr.mnCol, rAddr.mnRow);
+ switch (p->GetType())
+ {
+ case EXC_CACHEDVAL_BOOL:
-+ fprintf(stdout, "XclImpSupbookTab::LoadCachedValues: bool\n");
+ break;
+ case EXC_CACHEDVAL_DOUBLE:
+ {
+ double f = p->GetValue();
+ ScExternalRefCache::TokenRef pToken(new ScDoubleToken(f));
+ pCacheTable->setCell(rAddr.mnRow, rAddr.mnCol, pToken);
-+ fprintf(stdout, "XclImpSupbookTab::LoadCachedValues: double (%g)\n", f);
+ }
+ break;
+ case EXC_CACHEDVAL_EMPTY:
-+ fprintf(stdout, "XclImpSupbookTab::LoadCachedValues: empty\n");
+ break;
+ case EXC_CACHEDVAL_ERROR:
-+ fprintf(stdout, "XclImpSupbookTab::LoadCachedValues: error\n");
+ break;
+ case EXC_CACHEDVAL_STRING:
+ {
+ const String& rStr = p->GetString();
+ ScExternalRefCache::TokenRef pToken(new ScStringToken(rStr));
+ pCacheTable->setCell(rAddr.mnRow, rAddr.mnCol, pToken);
-+ fprintf(stdout, "XclImpSupbookTab::LoadCachedValues: string (%s)\n", rtl::OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr());
+ }
+ break;
+ default:
-+ fprintf(stdout, "XclImpSupbookTab::LoadCachedValues: other type\n");
++ ;
+ }
+ }
-+}
+ }
// External document (SUPBOOK) ================================================
-
-@@ -453,17 +608,20 @@ void XclImpSupbook::ReadCrn( XclImpStream& rStrm )
+@@ -453,25 +486,9 @@ void XclImpSupbook::ReadCrn( XclImpStream& rStrm )
}
}
-void XclImpSupbook::ReadExternname( XclImpStream& rStrm )
-+void XclImpSupbook::ReadExternname( XclImpStream& rStrm, ExcelToSc* pFormulaConv )
- {
+-{
- maExtNameList.Append( new XclImpExtName( rStrm, meType == EXC_SBTYPE_ADDIN ) );
-+ StackPrinter __stack_print__("XclImpSupbook::ReadExternname");
-+ fprintf(stdout, "XclImpSupbook::ReadExternname: tab count = %ld %ld\n", GetTabCount(), maSupbTabList.Count());
-+ maExtNameList.Append( new XclImpExtName( *this, rStrm, meType == EXC_SBTYPE_ADDIN, pFormulaConv ) );
- }
+-}
-
-+#if 0
- SCTAB XclImpSupbook::GetScTabNum( sal_uInt16 nXclTab ) const
- {
- if( meType == EXC_SBTYPE_SELF )
- return static_cast< SCTAB >( nXclTab );
+-SCTAB XclImpSupbook::GetScTabNum( sal_uInt16 nXclTab ) const
+-{
+- if( meType == EXC_SBTYPE_SELF )
+- return static_cast< SCTAB >( nXclTab );
- const XclImpSupbookTab* pSBTab = maSupbTabList.GetObject( nXclTab );
- return pSBTab ? pSBTab->GetScTab() : SCTAB_INVALID;
-+ return SCTAB_INVALID;
-+// const XclImpSupbookTab* pSBTab = maSupbTabList.GetObject( nXclTab );
-+// return pSBTab ? pSBTab->GetScTab() : SCTAB_INVALID;
- }
-
- SCTAB XclImpSupbook::GetScTabNum( const String& rTabName ) const
-@@ -473,6 +631,15 @@ SCTAB XclImpSupbook::GetScTabNum( const String& rTabName ) const
- return pSBTab->GetScTab();
- return SCTAB_INVALID;
- }
-+#endif
-+sal_uInt16 XclImpSupbook::GetXclTabNum( const String& rTabName ) const
-+{
-+ sal_uInt16 nTabNum = 0;
-+ for (const XclImpSupbookTab* pSBTab = maSupbTabList.First(); pSBTab; pSBTab = maSupbTabList.Next(), ++nTabNum)
-+ if (pSBTab->GetTabName() == rTabName)
-+ return nTabNum;
-+ return EXC_NOTAB;
-+}
+-}
+-
+-SCTAB XclImpSupbook::GetScTabNum( const String& rTabName ) const
++void XclImpSupbook::ReadExternname( XclImpStream& rStrm, ExcelToSc* pFormulaConv )
+ {
+- for( const XclImpSupbookTab* pSBTab = maSupbTabList.First(); pSBTab; pSBTab = maSupbTabList.Next() )
+- if( pSBTab->GetTabName() == rTabName )
+- return pSBTab->GetScTab();
+- return SCTAB_INVALID;
++ maExtNameList.Append( new XclImpExtName( *this, rStrm, meType == EXC_SBTYPE_ADDIN, pFormulaConv ) );
+ }
const XclImpExtName* XclImpSupbook::GetExternName( sal_uInt16 nXclIndex ) const
- {
-@@ -492,6 +659,27 @@ const String& XclImpSupbook::GetMacroName( sal_uInt16 nXclNameIdx ) const
+@@ -492,20 +509,46 @@ const String& XclImpSupbook::GetMacroName( sal_uInt16 nXclNameIdx ) const
return (pName && pName->IsVBName()) ? pName->GetScName() : EMPTY_STRING;
}
+-void XclImpSupbook::CreateTables( sal_uInt16 nSBTabFirst, sal_uInt16 nSBTabLast )
+const String& XclImpSupbook::GetTabName( sal_uInt16 nXtiTab ) const
-+{
+ {
+- if( (meType == EXC_SBTYPE_EXTERN) && (GetExtDocOptions().GetDocSettings().mnLinkCnt == 0) && GetDocShell() )
+ if (maSupbTabList.Empty())
+ return EMPTY_STRING;
+
+ sal_uInt16 i = 0;
+ for (XclImpSupbookTab* p = maSupbTabList.First(); p; p = maSupbTabList.Next(), ++i)
-+ {
+ {
+- String aAbsUrl( ScGlobal::GetAbsDocName( maXclUrl, GetDocShell() ) );
+ if (i == nXtiTab)
+ return p->GetTabName();
+ }
@@ -5397,55 +4945,37 @@
+ return ulimit_cast<sal_uInt16>(maSupbTabList.Count());
+}
+
-+#if 0
- void XclImpSupbook::CreateTables( sal_uInt16 nSBTabFirst, sal_uInt16 nSBTabLast )
- {
- if( (meType == EXC_SBTYPE_EXTERN) && (GetExtDocOptions().GetDocSettings().mnLinkCnt == 0) && GetDocShell() )
-@@ -508,6 +696,43 @@ void XclImpSupbook::CreateTables( sal_uInt16 nSBTabFirst, sal_uInt16 nSBTabLast
- pSBTab->CreateAndFillTable( GetRoot(), aAbsUrl, maFilterName, maFilterOpt );
- }
- }
-+#endif
-+
+void XclImpSupbook::LoadCachedValues()
+{
-+ StackPrinter __stack_print__("XclImpSupbook::LoadCachedValues");
-+ if (meType == EXC_SBTYPE_SELF)
-+ fprintf(stdout, "XclImpSupbook::LoadCachedValues: internal book\n");
-+
+ if (meType != EXC_SBTYPE_EXTERN || GetExtDocOptions().GetDocSettings().mnLinkCnt > 0)
-+ {
-+ fprintf(stdout, "XclImpSupbook::LoadCachedValues: don't load cached values\n");
+ return;
-+ }
+
+ String aAbsUrl( ScGlobal::GetAbsDocName(maXclUrl, GetDocShell()) );
-+ fprintf(stdout, "XclImpSupbook::LoadCachedValues: doc url = '%s'\n",
-+ rtl::OUStringToOString(aAbsUrl, RTL_TEXTENCODING_UTF8).getStr());
-+
+
+- // get filter name for external document
+- if( !maFilterName.Len() )
+- ScDocumentLoader::GetFilterName( aAbsUrl, maFilterName, maFilterOpt, FALSE, FALSE );
+ ScExternalRefManager* pRefMgr = GetRoot().GetDoc().GetExternalRefManager();
+ sal_uInt16 nFileId = pRefMgr->getExternalFileId(aAbsUrl);
-+
+
+- // create tables
+- for( sal_uInt16 nSBTab = nSBTabFirst; nSBTab <= nSBTabLast; ++nSBTab )
+- if( XclImpSupbookTab* pSBTab = maSupbTabList.GetObject( nSBTab ) )
+- pSBTab->CreateAndFillTable( GetRoot(), aAbsUrl, maFilterName, maFilterOpt );
+ sal_uInt16 nCount = maSupbTabList.Count();
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ XclImpSupbookTab* pTab = maSupbTabList.GetObject(i);
+ if (!pTab)
-+ {
-+ fprintf(stdout, "XclImpSupbook::LoadCachedValues: supbook table instance is NULL!\n");
+ return;
-+ }
+
+ const String& rTabName = pTab->GetTabName();
-+ fprintf(stdout, "XclImpSupbook::LoadCachedValues: tab name = '%s'\n", rtl::OUStringToOString(rTabName, RTL_TEXTENCODING_UTF8).getStr());
+ ScExternalRefCache::Table* pCacheTable = pRefMgr->getCacheTable(nFileId, rTabName);
+ pTab->LoadCachedValues(pCacheTable);
-+ }
-+}
-
- // Import link manager ========================================================
+ }
+ }
-@@ -531,7 +756,7 @@ void XclImpLinkManagerImpl::ReadExternsheet( XclImpStream& rStrm )
+@@ -531,7 +574,7 @@ void XclImpLinkManagerImpl::ReadExternsheet( XclImpStream& rStrm )
--nXtiCount;
}
@@ -5454,7 +4984,7 @@
}
void XclImpLinkManagerImpl::ReadSupbook( XclImpStream& rStrm )
-@@ -551,10 +776,10 @@ void XclImpLinkManagerImpl::ReadCrn( XclImpStream& rStrm )
+@@ -551,10 +594,10 @@ void XclImpLinkManagerImpl::ReadCrn( XclImpStream& rStrm )
pSupbook->ReadCrn( rStrm );
}
@@ -5467,7 +4997,7 @@
}
bool XclImpLinkManagerImpl::IsSelfRef( sal_uInt16 nXtiIndex ) const
-@@ -570,8 +795,8 @@ bool XclImpLinkManagerImpl::GetScTabRange(
+@@ -570,8 +613,8 @@ bool XclImpLinkManagerImpl::GetScTabRange(
{
if( const XclImpSupbook* pSupbook = maSupbookList.GetObject( pXti->mnSupbook ) )
{
@@ -5478,7 +5008,7 @@
return true;
}
}
-@@ -584,6 +809,20 @@ const XclImpExtName* XclImpLinkManagerImpl::GetExternName( sal_uInt16 nXtiIndex,
+@@ -584,6 +627,20 @@ const XclImpExtName* XclImpLinkManagerImpl::GetExternName( sal_uInt16 nXtiIndex,
return pSupbook ? pSupbook->GetExternName( nExtName ) : 0;
}
@@ -5499,57 +5029,53 @@
bool XclImpLinkManagerImpl::GetLinkData( String& rApplic, String& rTopic, sal_uInt16 nXtiIndex ) const
{
const XclImpSupbook* pSupbook = GetSupbook( nXtiIndex );
-@@ -595,12 +834,18 @@ const String& XclImpLinkManagerImpl::GetMacroName( sal_uInt16 nExtSheet, sal_uIn
- const XclImpSupbook* pSupbook = GetSupbook( nExtSheet );
+@@ -596,12 +653,6 @@ const String& XclImpLinkManagerImpl::GetMacroName( sal_uInt16 nExtSheet, sal_uIn
return pSupbook ? pSupbook->GetMacroName( nExtName ) : EMPTY_STRING;
}
--
-+#if 0
- SCTAB XclImpLinkManagerImpl::GetScTab( const String& rUrl, const String& rTabName ) const
- {
- const XclImpSupbook* pSupbook = GetSupbook( rUrl );
- return pSupbook ? pSupbook->GetScTabNum( rTabName ) : SCTAB_INVALID;
- }
-+#endif
-+sal_uInt16 XclImpLinkManagerImpl::GetXclTab( const String& rUrl, const String& rTabName ) const
-+{
-+ const XclImpSupbook* pSupbook = GetSupbook( rUrl );
-+ return pSupbook ? pSupbook->GetXclTabNum( rTabName ) : EXC_NOTAB;
-+}
+-SCTAB XclImpLinkManagerImpl::GetScTab( const String& rUrl, const String& rTabName ) const
+-{
+- const XclImpSupbook* pSupbook = GetSupbook( rUrl );
+- return pSupbook ? pSupbook->GetScTabNum( rTabName ) : SCTAB_INVALID;
+-}
+-
const XclImpSupbook* XclImpLinkManagerImpl::GetSupbook( sal_uInt32 nXtiIndex ) const
{
-@@ -616,6 +861,7 @@ const XclImpSupbook* XclImpLinkManagerImpl::GetSupbook( const String& rUrl ) con
+ const XclImpXti* pXti = maXtiList.GetObject( nXtiIndex );
+@@ -616,26 +667,17 @@ const XclImpSupbook* XclImpLinkManagerImpl::GetSupbook( const String& rUrl ) con
return 0;
}
-+#if 0
- void XclImpLinkManagerImpl::CreateTables()
- {
- DBG_ASSERT( !mbCreated, "XclImpLinkManager::CreateTables - multiple call" );
-@@ -637,6 +883,21 @@ void XclImpLinkManagerImpl::CreateTables()
- }
- mbCreated = true;
- }
-+#endif
-+
+-void XclImpLinkManagerImpl::CreateTables()
+void XclImpLinkManagerImpl::LoadCachedValues()
-+{
-+ StackPrinter __stack_print__("XclImpLinkManagerImpl::LoadCachedValues");
+ {
+- DBG_ASSERT( !mbCreated, "XclImpLinkManager::CreateTables - multiple call" );
+- if( mbCreated ) return;
+ // Read all CRN records which can be accessed via XclImpSupbook, and store
+ // the cached values to the external reference manager.
-+
-+ sal_uInt32 nCount = maSupbookList.Count();
+
+- sal_uInt16 nSBTabFirst, nSBTabLast;
+ sal_uInt32 nCount = maSupbookList.Count();
+-
+- for( sal_uInt16 nSupbook = 0; nSupbook < nCount; ++nSupbook )
+ for (sal_uInt16 nSupbook = 0; nSupbook < nCount; ++nSupbook)
-+ {
+ {
+- XclImpSupbook* pSupbook = maSupbookList.GetObject( nSupbook );
+- bool bLoop = FindNextTabRange( nSBTabFirst, nSBTabLast, nSupbook, 0 );
+- while( bLoop && pSupbook )
+- {
+- pSupbook->CreateTables( nSBTabFirst, nSBTabLast );
+- // #96263# don't search again if last sheet == EXC_NOTAB
+- bLoop = (nSBTabLast != EXC_NOTAB) && FindNextTabRange( nSBTabFirst, nSBTabLast, nSupbook, nSBTabLast + 1 );
+- }
+ XclImpSupbook* pSupbook = maSupbookList.GetObject(nSupbook);
+ pSupbook->LoadCachedValues();
-+ }
-+}
+ }
+- mbCreated = true;
+ }
bool XclImpLinkManagerImpl::FindNextTabRange(
- sal_uInt16& rnSBTabFirst, sal_uInt16& rnSBTabLast,
-@@ -686,9 +947,9 @@ void XclImpLinkManager::ReadCrn( XclImpStream& rStrm )
+@@ -686,9 +728,9 @@ void XclImpLinkManager::ReadCrn( XclImpStream& rStrm )
mxImpl->ReadCrn( rStrm );
}
@@ -5561,7 +5087,7 @@
}
bool XclImpLinkManager::IsSelfRef( sal_uInt16 nXtiIndex ) const
-@@ -707,6 +968,16 @@ const XclImpExtName* XclImpLinkManager::GetExternName( sal_uInt16 nXtiIndex, sal
+@@ -707,6 +749,16 @@ const XclImpExtName* XclImpLinkManager::GetExternName( sal_uInt16 nXtiIndex, sal
return mxImpl->GetExternName( nXtiIndex, nExtName );
}
@@ -5578,22 +5104,15 @@
bool XclImpLinkManager::GetLinkData( String& rApplic, String& rTopic, sal_uInt16 nXtiIndex ) const
{
return mxImpl->GetLinkData( rApplic, rTopic, nXtiIndex );
-@@ -716,11 +987,16 @@ const String& XclImpLinkManager::GetMacroName( sal_uInt16 nExtSheet, sal_uInt16
- {
+@@ -717,10 +769,5 @@ const String& XclImpLinkManager::GetMacroName( sal_uInt16 nExtSheet, sal_uInt16
return mxImpl->GetMacroName( nExtSheet, nExtName );
}
--
-+#if 0
- SCTAB XclImpLinkManager::GetScTab( const String& rUrl, const String& rTabName ) const
- {
- return mxImpl->GetScTab( rUrl, rTabName );
- }
-+#endif
-+sal_uInt16 XclImpLinkManager::GetXclTab( const String& rUrl, const String& rTabName ) const
-+{
-+ return mxImpl->GetXclTab( rUrl, rTabName );
-+}
+-SCTAB XclImpLinkManager::GetScTab( const String& rUrl, const String& rTabName ) const
+-{
+- return mxImpl->GetScTab( rUrl, rTabName );
+-}
+-
// ============================================================================
diff --git sc/source/filter/inc/XclImpChangeTrack.hxx sc/source/filter/inc/XclImpChangeTrack.hxx
@@ -5678,19 +5197,6 @@
static inline BOOL IsComplRowRange( const UINT16 nRow1, const UINT16 nRow2 );
virtual BOOL GetAbsRefs( ScRangeList& rRangeList, XclImpStream& rStrm, sal_Size nLen );
-diff --git sc/source/filter/inc/fdumper.hxx sc/source/filter/inc/fdumper.hxx
-index aea8de6..8f57403 100644
---- sc/source/filter/inc/fdumper.hxx
-+++ sc/source/filter/inc/fdumper.hxx
-@@ -31,7 +31,7 @@
- #ifndef SC_FDUMPER_HXX
- #define SC_FDUMPER_HXX
-
--#define SCF_INCL_DUMPER (OSL_DEBUG_LEVEL > 0)
-+#define SCF_INCL_DUMPER (OSL_DEBUG_LEVEL > 0) && 0
-
- #include <map>
- #include <math.h>
diff --git sc/source/filter/inc/tokstack.hxx sc/source/filter/inc/tokstack.hxx
index 89e955a..5bb6772 100644
--- sc/source/filter/inc/tokstack.hxx
@@ -5821,7 +5327,7 @@
virtual void Save( XclExpStream& rStrm );
diff --git sc/source/filter/inc/xilink.hxx sc/source/filter/inc/xilink.hxx
-index 0d547fe..ffb9f4c 100644
+index 0d547fe..3983e4d 100644
--- sc/source/filter/inc/xilink.hxx
+++ sc/source/filter/inc/xilink.hxx
@@ -107,6 +107,8 @@ enum XclImpExtNameType
@@ -5882,59 +5388,30 @@
/** Tries to decode the URL of the specified XTI entry to OLE or DDE link components.
@descr For DDE links: Decodes to application name and topic.
For OLE object links: Decodes to class name and document URL.
-@@ -186,10 +198,12 @@ public:
- bool GetLinkData( String& rApplic, String& rTopic, sal_uInt16 nXtiIndex ) const;
+@@ -187,10 +199,6 @@ public:
/** Returns the specified macro name or an empty string on error. */
const String& GetMacroName( sal_uInt16 nExtSheet, sal_uInt16 nExtName ) const;
--
-+#if 0
- /** Returns the Calc sheet index of a table in an external document.
- @return Calc sheet index or EXC_TAB_INVALID on error. */
- SCTAB GetScTab( const String& rUrl, const String& rTabName ) const;
-+#endif
-+ sal_uInt16 GetXclTab( const String& rUrl, const String& rTabName ) const;
+- /** Returns the Calc sheet index of a table in an external document.
+- @return Calc sheet index or EXC_TAB_INVALID on error. */
+- SCTAB GetScTab( const String& rUrl, const String& rTabName ) const;
+-
private:
typedef ::std::auto_ptr< XclImpLinkManagerImpl > XclImpLinkMgrImplPtr;
+ XclImpLinkMgrImplPtr mxImpl;
diff --git sc/source/filter/xcl97/XclImpChangeTrack.cxx sc/source/filter/xcl97/XclImpChangeTrack.cxx
-index 022b472..1b60abc 100644
+index 022b472..a1efd3e 100644
--- sc/source/filter/xcl97/XclImpChangeTrack.cxx
+++ sc/source/filter/xcl97/XclImpChangeTrack.cxx
-@@ -40,6 +40,33 @@
+@@ -40,6 +40,7 @@
#include "chgtrack.hxx"
#include "xihelper.hxx"
#include "xilink.hxx"
+#include "externalrefmgr.hxx"
-+
-+
-+#include <stdio.h>
-+#include <string>
-+
-+namespace {
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
//___________________________________________________________________
// class XclImpChangeTrack
-@@ -153,10 +180,11 @@ sal_Bool XclImpChangeTrack::CheckRecord( sal_uInt16 nOpCode )
+@@ -153,10 +154,11 @@ sal_Bool XclImpChangeTrack::CheckRecord( sal_uInt16 nOpCode )
return aRecHeader.nIndex != 0;
}
@@ -5947,7 +5424,7 @@
// internal ref - read tab num and return sc tab num (position in TABID list)
pStrm->Ignore( 3 );
rFirstTab = static_cast< SCTAB >( GetTabInfo().GetCurrentIndex( pStrm->ReaduInt16(), nTabIdCount ) );
-@@ -176,7 +204,13 @@ sal_Bool XclImpChangeTrack::Read3DTabRefInfo( SCTAB& rFirstTab, SCTAB& rLastTab
+@@ -176,7 +178,13 @@ sal_Bool XclImpChangeTrack::Read3DTabRefInfo( SCTAB& rFirstTab, SCTAB& rLastTab
// - sheet name, always separated from URL
String aTabName( pStrm->ReadUniString() );
pStrm->Ignore( 1 );
@@ -5962,109 +5439,17 @@
}
return sal_True;
}
-@@ -215,14 +249,18 @@ void XclImpChangeTrack::ReadCell(
- sal_uInt16 nFlags,
- const ScAddress& rPosition )
- {
-+ StackPrinter __stack_print__("XclImpChangeTrack::ReadCell");
-+
- rpCell = NULL;
- rFormat = 0;
- switch( nFlags & EXC_CHTR_TYPE_MASK )
- {
- case EXC_CHTR_TYPE_EMPTY:
-+ fprintf(stdout, "XclImpChangeTrack::ReadCell: empty\n");
- break;
- case EXC_CHTR_TYPE_RK:
- {
-+ fprintf(stdout, "XclImpChangeTrack::ReadCell: rk\n");
- double fValue = ReadRK();
- if( pStrm->IsValid() )
- rpCell = new ScValueCell( fValue );
-@@ -230,6 +268,7 @@ void XclImpChangeTrack::ReadCell(
- break;
- case EXC_CHTR_TYPE_DOUBLE:
- {
-+ fprintf(stdout, "XclImpChangeTrack::ReadCell: double\n");
- double fValue;
- *pStrm >> fValue;
- if( pStrm->IsValid() )
-@@ -238,6 +277,7 @@ void XclImpChangeTrack::ReadCell(
- break;
- case EXC_CHTR_TYPE_STRING:
- {
-+ fprintf(stdout, "XclImpChangeTrack::ReadCell: string\n");
- String sString( pStrm->ReadUniString() );
- if( pStrm->IsValid() )
- rpCell = new ScStringCell( sString );
-@@ -245,6 +285,7 @@ void XclImpChangeTrack::ReadCell(
- break;
- case EXC_CHTR_TYPE_BOOL:
- {
-+ fprintf(stdout, "XclImpChangeTrack::ReadCell: bool\n");
- double fValue = (double) ReadBool();
- if( pStrm->IsValid() )
- {
-@@ -255,6 +296,7 @@ void XclImpChangeTrack::ReadCell(
- break;
- case EXC_CHTR_TYPE_FORMULA:
- {
-+ fprintf(stdout, "XclImpChangeTrack::ReadCell: formula\n");
- ScTokenArray* pTokenArray = NULL;
- ReadFormula( pTokenArray, rPosition );
- if( pStrm->IsValid() && pTokenArray )
-@@ -325,17 +367,33 @@ void XclImpChangeTrack::ReadChTrInfo()
-
- void XclImpChangeTrack::ReadChTrCellContent()
- {
-+ StackPrinter __stack_print__("XclImpChangeTrack::ReadChTrCellContent");
-+
- *pStrm >> aRecHeader;
-+ fprintf(stdout, "XclImpChangeTrack::ReadChTrCellContent: size = %ld; index = %ld; opcode = %d; accept = %d\n",
-+ aRecHeader.nSize, aRecHeader.nIndex, aRecHeader.nOpCode, aRecHeader.nAccept);
-+
+@@ -329,7 +337,8 @@ void XclImpChangeTrack::ReadChTrCellContent()
if( CheckRecord( EXC_CHTR_OP_CELL ) )
{
ScAddress aPosition;
- aPosition.SetTab( ReadTabNum() );
+ SCTAB nTab = ReadTabNum();
-+ fprintf(stdout, "XclImpChangeTrack::ReadChTrCellContent: tab = %d\n", nTab);
+ aPosition.SetTab( nTab );
sal_uInt16 nValueType;
*pStrm >> nValueType;
-+ fprintf(stdout, "XclImpChangeTrack::ReadChTrCellContent: value type = 0x%2.2X\n", nValueType);
sal_uInt16 nOldValueType = (nValueType >> 3) & EXC_CHTR_TYPE_MASK;
- sal_uInt16 nNewValueType = nValueType & EXC_CHTR_TYPE_MASK;
-+ fprintf(stdout, "XclImpChangeTrack::ReadChTrCellContent: old value type = 0x%2.2X; new value type = 0x%2.2X\n",
-+ nOldValueType, nNewValueType);
-+
- pStrm->Ignore( 2 );
- Read2DAddress( aPosition );
-+ String aAddrStr;
-+ aPosition.Format(aAddrStr, SCA_ABS_3D, &GetDoc());
-+ fprintf(stdout, "XclImpChangeTrack::ReadChTrCellContent: pos = '%s'\n",
-+ rtl::OUStringToOString(aAddrStr, RTL_TEXTENCODING_UTF8).getStr());
-+
- sal_uInt16 nOldSize;
- *pStrm >> nOldSize;
- DBG_ASSERT( (nOldSize == 0) == (nOldValueType == EXC_CHTR_TYPE_EMPTY),
-@@ -445,10 +503,15 @@ sal_Bool XclImpChangeTrack::EndNestedMode()
-
- void XclImpChangeTrack::ReadRecords()
- {
-+ StackPrinter __stack_print__("XclImpChangeTrack::ReadRecords");
-+
- sal_Bool bExitLoop = sal_False;
-
- while( !bExitLoop && !bGlobExit && pStrm->StartNextRecord() )
- {
-+ sal_uInt16 nRecId = pStrm->GetRecId();
-+ fprintf(stdout, "XclImpChangeTrack::ReadRecords: rec id = 0x%4.4X\n", nRecId);
-+
- switch( pStrm->GetRecId() )
- {
- case 0x000A: bGlobExit = sal_True; break;
-@@ -490,9 +553,9 @@ XclImpChTrFmlConverter::~XclImpChTrFmlConverter()
+@@ -490,9 +499,9 @@ XclImpChTrFmlConverter::~XclImpChTrFmlConverter()
}
// virtual, called from ExcToSc8::Convert()
@@ -6077,18 +5462,6 @@
+ return rChangeTrack.Read3DTabRefInfo( rFirstTab, rLastTab, rExtInfo );
}
-diff --git sc/source/ui/docshell/docsh.cxx sc/source/ui/docshell/docsh.cxx
-index c702954..219b227 100644
---- sc/source/ui/docshell/docsh.cxx
-+++ sc/source/ui/docshell/docsh.cxx
-@@ -2093,6 +2093,7 @@ bool lcl_NeedHashRegen(const ScDocument& rDoc, ScPasswordHash eHash)
-
- BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
- {
-+ fprintf(stdout, "ScDocShell::ConvertTo: ****************************************\n");
- RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ConvertTo" );
-
- ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
diff --git sc/source/ui/docshell/docsh4.cxx sc/source/ui/docshell/docsh4.cxx
index bc5975d..6701d1c 100644
--- sc/source/ui/docshell/docsh4.cxx
@@ -6111,10 +5484,10 @@
diff --git sc/source/ui/docshell/externalrefmgr.cxx sc/source/ui/docshell/externalrefmgr.cxx
new file mode 100644
-index 0000000..80425f0
+index 0000000..8b5858d
--- /dev/null
+++ sc/source/ui/docshell/externalrefmgr.cxx
-@@ -0,0 +1,1360 @@
+@@ -0,0 +1,1161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -6180,7 +5553,6 @@
+#include "unotools/ucbhelper.hxx"
+
+#include <memory>
-+#include <stdio.h>
+
+using ::std::auto_ptr;
+using ::com::sun::star::uno::Any;
@@ -6188,33 +5560,8 @@
+using ::std::find;
+using ::std::distance;
+
-+
-+namespace {
-+
-+#include <string>
-+
-+class StackPrinter
-+{
-+public:
-+ explicit StackPrinter(const char* msg) :
-+ msMsg(msg)
-+ {
-+ fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+ }
-+
-+ ~StackPrinter()
-+ {
-+ fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+ }
-+
-+private:
-+ ::std::string msMsg;
-+};
-+
-+}
-+
+#define SRCDOC_LIFE_SPAN 6000 // 1 minute (in 100th of a sec)
-+#define SRCDOC_SCAN_INTERVAL 1000*2 // every 2 seconds (in msec)
++#define SRCDOC_SCAN_INTERVAL 1000*5 // every 5 seconds (in msec)
+
+// ============================================================================
+
@@ -6228,8 +5575,6 @@
+
+void ScExternalRefCache::Table::setCell(SCROW nRow, SCCOL nCol, TokenRef pToken)
+{
-+ StackPrinter __stack_print__("ScExternalRefCache:Table::setCell");
-+ fprintf(stdout, "ScExternalRefCache:Table::setCell: row = %d; col = %d\n", nRow, nCol);
+ using ::std::pair;
+ RowsDataType::iterator itrRow = maRows.find(nRow);
+ if (itrRow == maRows.end())
@@ -6248,18 +5593,13 @@
+ // check for existing data. Just overwrite it.
+ RowDataType& rRow = itrRow->second;
+ rRow.insert(RowDataType::value_type(nCol, pToken));
-+ fprintf(stdout, "ScExternalRefCache:Table::setCell: token inserted (row = %d; col = %d)\n", nRow, nCol);
+}
+
+ScToken* ScExternalRefCache::Table::getCell(SCROW nRow, SCCOL nCol) const
+{
-+ StackPrinter __stack_print__("ScExternalRefCache:Table::getCell");
-+ fprintf(stdout, "ScExternalRefCache:Table::getCell: row = %d; col = %d\n", nRow, nCol);
-+
+ RowsDataType::const_iterator itrTable = maRows.find(nRow);
+ if (itrTable == maRows.end())
+ {
-+ fprintf(stdout, "ScExternalRefCache:Table::getCell: row not found\n");
+ // this table doesn't have the specified row.
+ return NULL;
+ }
@@ -6268,12 +5608,10 @@
+ RowDataType::const_iterator itrRow = rRowData.find(nCol);
+ if (itrRow == rRowData.end())
+ {
-+ fprintf(stdout, "ScExternalRefCache:Table::getCell: column not found\n");
+ // this row doesn't have the specified column.
+ return NULL;
+ }
+
-+ fprintf(stdout, "ScExternalRefCache:Table::getCell: cached cell found\n");
+ return itrRow->second.get();
+}
+
@@ -6288,12 +5626,9 @@
+
+ScToken* ScExternalRefCache::getCellData(sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol)
+{
-+ StackPrinter __stack_print__("ScExternalRefCache::getCellData");
-+
+ DocDataType::const_iterator itrDoc = maDocs.find(nFileId);
+ if (itrDoc == maDocs.end())
+ {
-+ fprintf(stdout, "ScExternalRefCache::getCellData: specified document not cached\n");
+ // specified document is not cached.
+ return NULL;
+ }
@@ -6302,7 +5637,6 @@
+ TableNameIndexMap::const_iterator itrTabId = rDoc.maTableNameIndex.find(rTabName);
+ if (itrTabId == rDoc.maTableNameIndex.end())
+ {
-+ fprintf(stdout, "ScExternalRefCache::getCellData: table not in cache\n");
+ // the specified table is not in cache.
+ return NULL;
+ }
@@ -6310,7 +5644,6 @@
+ const TableTypeRef& pTableData = rDoc.maTables[itrTabId->second];
+ if (!pTableData.get())
+ {
-+ fprintf(stdout, "ScExternalRefCache::getCellData: table instance is NULL\n");
+ // the table data is not instantiated yet.
+ return NULL;
+ }
@@ -6319,8 +5652,6 @@
+
+ScTokenArray* ScExternalRefCache::getCellRangeData(sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange)
+{
-+ StackPrinter __stack_print__("ScExternalRefCache::getCellRangeData");
-+
+ DocDataType::iterator itrDoc = maDocs.find(nFileId);
+ if (itrDoc == maDocs.end())
+ // specified document is not cached.
@@ -6330,7 +5661,6 @@
+ RangeArrayMap::const_iterator itrRange = rDoc.maRangeArrays.find(rRange);
+ if (itrRange != rDoc.maRangeArrays.end())
+ {
-+ fprintf(stdout, "ScExternalRefCache::getCellRangeData: range array cached. let's use this.\n");
+ return itrRange->second.get();
+ }
+
@@ -6402,8 +5732,6 @@
+
+ScTokenArray* ScExternalRefCache::getRangeNameTokens(sal_uInt16 nFileId, const String& rName)
+{
-+ StackPrinter __stack_print__("ScExternalRefCache::getRangeNameTokens");
-+
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return NULL;
@@ -6418,20 +5746,16 @@
+
+void ScExternalRefCache::setRangeNameTokens(sal_uInt16 nFileId, const String& rName, TokenArrayRef pArray)
+{
-+ StackPrinter __stack_print__("ScExternalRefCache::setRangeNameTokens");
-+
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return;
+
+ RangeNameMap& rMap = pDoc->maRangeNames;
+ rMap.insert(RangeNameMap::value_type(rName, pArray));
-+ fprintf(stdout, "ScExternalRefCache::setRangeNameTokens: name inserted into cache\n");
+}
+
+void ScExternalRefCache::setCellData(sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol, TokenRef pToken)
+{
-+ StackPrinter __stack_print__("ScExternalRefCache::setCellData");
+ if (!isDocInitialized(nFileId))
+ return;
+
@@ -6459,25 +5783,10 @@
+ TokenArrayRef pArray)
+{
+ using ::std::pair;
-+ StackPrinter __stack_print__("ScExternalRefCache::setCellRangeData");
+ if (rData.empty() || !isDocInitialized(nFileId))
+ // nothing to cache
+ return;
+
-+ {
-+ vector<SingleRangeData>::const_iterator itr = rData.begin(), itrEnd = rData.end();
-+ for (; itr != itrEnd; ++itr)
-+ {
-+ fprintf(stdout, "ScExternalRefCache::setCellRangeData: tab name to cache = '%s'\n",
-+ rtl::OUStringToOString(itr->maTableName, RTL_TEXTENCODING_UTF8).getStr());
-+ }
-+ }
-+
-+ String aStr;
-+ rRange.Format(aStr, SCR_ABS_3D, NULL);
-+ fprintf(stdout, "ScExternalRefCache::setCellRangeData: range = '%s'\n",
-+ rtl::OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr());
-+
+ // First, get the document item for the given file ID.
+ DocItem* pDocItem = getDocItem(nFileId);
+ if (!pDocItem)
@@ -6491,13 +5800,9 @@
+ if (itrTabName == rDoc.maTableNameIndex.end())
+ {
+ // table index not found.
-+ fprintf(stdout, "ScExternalRefCache::setCellRangeData: table index not found\n");
+ return;
+ }
+
-+ fprintf(stdout, "ScExternalRefCache::setCellRangeData: table index for cached table '%s' = %d\n",
-+ rtl::OUStringToOString(rFirstTabName, RTL_TEXTENCODING_UTF8).getStr(), itrTabName->second);
-+
+ size_t nTab1 = itrTabName->second;
+ SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
+ SCCOL nCol1 = rRange.aStart.Col(), nCol2 = rRange.aEnd.Col();
@@ -6552,15 +5857,11 @@
+
+void ScExternalRefCache::initializeDoc(sal_uInt16 nFileId, const vector<String>& rTabNames)
+{
-+ StackPrinter __stack_print__("ScExternalRefCache::initializeDoc");
-+
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return;
+
+ size_t n = rTabNames.size();
-+ for (size_t i = 0; i < n; ++i)
-+ fprintf(stdout, "ScExternalRefCache::initializeDoc: %d: '%s'\n", i, rtl::OUStringToOString(rTabNames[i], RTL_TEXTENCODING_UTF8).getStr());
+
+ // table name list - the list must include all table names in the source
+ // document and only to be populated when loading the source document, not
@@ -6575,7 +5876,6 @@
+ size_t nIndex;
+ if (lcl_getTableDataIndex(pDoc->maTableNameIndex, rTabNames[i], nIndex))
+ {
-+ fprintf(stdout, "ScExternalRefCache::initializeDoc: transferring '%s'\n", rtl::OUStringToOString(rTabNames[i], RTL_TEXTENCODING_UTF8).getStr());
+ aNewTables[i] = pDoc->maTables[nIndex];
+ }
+ }
@@ -6589,36 +5889,7 @@
+
+ pDoc->mbInitFromSource = true;
+}
-+#if 0
-+const String* ScExternalRefCache::getExternalTableName(sal_uInt16 nFileId, SCTAB nTab)
-+{
-+ DocItem* pDocItem = getDocItem(nFileId);
-+ if (!pDocItem || nTab < 0)
-+ return NULL;
-+
-+ const vector<String>& rNames = pDocItem->maTableNames;
-+ if (static_cast<size_t>(nTab) >= rNames.size())
-+ return NULL;
-+
-+ return &rNames[nTab];
-+}
-+
-+SCTAB ScExternalRefCache::getExternalTableId(sal_uInt16 nFileId, const String& rTabName)
-+{
-+ if (!isDocInitialized(nFileId))
-+ return -1;
+
-+ DocItem* pDocItem = getDocItem(nFileId);
-+ if (!pDocItem)
-+ return -1;
-+
-+ TableNameIndexMap::const_iterator itr = pDocItem->maTableNameIndex.find(rTabName);
-+ if (itr == pDocItem->maTableNameIndex.end())
-+ return -1;
-+
-+ return static_cast<SCTAB>(itr->second);
-+}
-+#endif
+const vector<String>* ScExternalRefCache::getAllTableNames(sal_uInt16 nFileId) const
+{
+ DocItem* pDoc = getDocItem(nFileId);
@@ -6630,11 +5901,6 @@
+
+ScExternalRefCache::Table* ScExternalRefCache::getCacheTable(sal_uInt16 nFileId, const String& rTabName)
+{
-+ StackPrinter __stack_print__("ScExternalRefCache::getCacheTable");
-+
-+ fprintf(stdout, "ScExternalRefCache::getCacheTable: tab name requested = '%s'\n",
-+ rtl::OUStringToOString(rTabName, RTL_TEXTENCODING_UTF8).getStr());
-+
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return NULL;
@@ -6644,12 +5910,9 @@
+ size_t nIndex;
+ if (lcl_getTableDataIndex(rDoc.maTableNameIndex, rTabName, nIndex))
+ {
-+ fprintf(stdout, "ScExternalRefCache::getCacheTable: exists\n");
+ return rDoc.maTables[nIndex].get();
+ }
+
-+ fprintf(stdout, "ScExternalRefCache::getCacheTable: creating a new cache table\n");
-+
+ // Specified table doesn't exist yet. Create one.
+ TableTypeRef pTab(new Table);
+ rDoc.maTables.push_back(pTab);
@@ -6758,7 +6021,6 @@
+ {
+ String aStr;
+ static_cast<ScStringCell*>(pCell)->GetString(aStr);
-+ fprintf(stdout, "lcl_convertToToken: string type (%s)\n", rtl::OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr());
+ ScStringToken aToken(aStr);
+ return aToken.Clone();
+ }
@@ -6767,13 +6029,11 @@
+ {
+ double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
+ ScDoubleToken aToken(fVal);
-+ fprintf(stdout, "lcl_convertToToken: value type (%g)\n", fVal);
+ return aToken.Clone();
+ }
+ break;
+ case CELLTYPE_FORMULA:
+ {
-+ fprintf(stdout, "lcl_convertToToken: formula type\n");
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ if (pFCell->IsValue())
+ {
@@ -6900,24 +6160,13 @@
+
+void ScExternalRefManager::storeRangeNameTokens(sal_uInt16 nFileId, const String& rName, const ScTokenArray& rArray)
+{
-+ StackPrinter __stack_print__("ScExternalRefManager::storeRangeNameTokens");
+ ScExternalRefCache::TokenArrayRef pArray(rArray.Clone());
+ maRefCache.setRangeNameTokens(nFileId, rName, pArray);
-+
-+ for (ScToken* pToken = pArray->First(); pToken; pToken = pArray->Next())
-+ {
-+ fprintf(stdout, "ScExternalRefManager::storeRangeNameTokens: type = %d; opcode = %d\n",
-+ pToken->GetType(), pToken->GetOpCode());
-+ }
+}
+
+ScToken* ScExternalRefManager::getSingleRefToken(sal_uInt16 nFileId, const String& rTabName, const ScAddress& rCell,
+ const ScAddress* pCurPos, SCTAB* pTab)
+{
-+ StackPrinter __stack_print__("ScExternalRefManager::getSingleRefToken");
-+ fprintf(stdout, "ScExternalRefManager::getSingleRefToken: file id = %d; tab name = '%s'\n", nFileId,
-+ rtl::OUStringToOString(rTabName, RTL_TEXTENCODING_UTF8).getStr());
-+
+ if (pCurPos)
+ insertReferencingCell(nFileId, *pCurPos);
+
@@ -6930,17 +6179,13 @@
+ ScToken* pToken = maRefCache.getCellData(nFileId, rTabName, rCell.Row(), rCell.Col());
+ if (pToken)
+ {
-+ fprintf(stdout, "ScExternalRefManager::getSingleRefToken: cell reference cached.\n");
+ return pToken;
+ }
+
-+ fprintf(stdout, "ScExternalRefManager::getSingleRefToken: cell reference not cached.\n");
-+
+ // reference not cached. read from the source document.
+ ScDocument* pSrcDoc = getSrcDocument(nFileId);
+ if (!pSrcDoc)
+ {
-+ fprintf(stdout, "ScExternalRefManager::getSingleRefToken: source document NULL\n");
+ return NULL;
+ }
+
@@ -6949,7 +6194,6 @@
+ if (!pSrcDoc->GetTable(rTabName, nTab))
+ {
+ // specified table name doesn't exist in the source document.
-+ fprintf(stdout, "ScExternalRefManager::getSingleRefToken: tab name doesn't exist in the source document.\n");
+ return NULL;
+ }
+
@@ -6980,29 +6224,16 @@
+ // Check if the given table name and the cell position is cached.
+ ScTokenArray* p = maRefCache.getCellRangeData(nFileId, rTabName, rRange);
+ if (p)
-+ {
-+ fprintf(stdout, "ScExternalRefManager::getDoubleRefTokens: range reference cached.\n");
+ return p;
-+ }
-+
-+ fprintf(stdout, "ScExternalRefManager::getDoubleRefTokens: range reference not cached.\n");
+
+ ScDocument* pSrcDoc = getSrcDocument(nFileId);
+ if (!pSrcDoc)
-+ {
-+ fprintf(stdout, "ScExternalRefManager::getDoubleRefTokens: source document is null\n");
+ return NULL;
-+ }
+
+ SCTAB nTab1;
+ if (!pSrcDoc->GetTable(rTabName, nTab1))
-+ {
+ // specified table name doesn't exist in the source document.
-+ fprintf(stdout, "ScExternalRefManager::getSingleRefToken: tab name doesn't exist in the source document.\n");
+ return NULL;
-+ }
-+
-+ fprintf(stdout, "ScExternalRefManager::getDoubleRefTokens: tab id = %d\n", nTab1);
+
+ ScRange aRange(rRange);
+ SCTAB nTabSpan = aRange.aEnd.Tab() - aRange.aStart.Tab();
@@ -7016,11 +6247,8 @@
+ {
+ String aTabName;
+ if (!pSrcDoc->GetName(nTab1 + 1, aTabName))
-+ {
-+ fprintf(stdout, "ScExternalRefManager::getDoubleRefTokens: src doc does not have a table named '%s'\n",
-+ rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr());
++ // source document doesn't have any table by the specified name.
+ break;
-+ }
+
+ aCacheData.push_back(ScExternalRefCache::SingleRangeData());
+ aCacheData.back().maTableName = aTabName;
@@ -7040,19 +6268,6 @@
+
+ScTokenArray* ScExternalRefManager::getRangeNameTokens(sal_uInt16 nFileId, const String& rName, const ScAddress* pCurPos)
+{
-+ StackPrinter __stack_print__("ScExternalRefManager::getRangeNameTokens");
-+ if (pCurPos)
-+ {
-+ String aCellStr;
-+ pCurPos->Format(aCellStr, SCA_ABS_3D);
-+ const String* pFile = getExternalFileName(nFileId);
-+ fprintf(stdout, "ScExternalRefManager::getRangeNameTokens: file = '%s' [%d]; name = '%s'; pos = '%s'\n",
-+ rtl::OUStringToOString(*pFile, RTL_TEXTENCODING_UTF8).getStr(),
-+ nFileId,
-+ rtl::OUStringToOString(rName, RTL_TEXTENCODING_UTF8).getStr(),
-+ rtl::OUStringToOString(aCellStr, RTL_TEXTENCODING_UTF8).getStr());
-+ }
-+
+ if (pCurPos)
+ insertReferencingCell(nFileId, *pCurPos);
+
@@ -7060,10 +6275,7 @@
+
+ ScTokenArray* pArray = maRefCache.getRangeNameTokens(nFileId, rName);
+ if (pArray)
-+ {
-+ fprintf(stdout, "ScExternalRefManager::getRangeNameTokens: name is cached\n");
+ return pArray;
-+ }
+
+ ScDocument* pSrcDoc = getSrcDocument(nFileId);
+ if (!pSrcDoc)
@@ -7125,13 +6337,10 @@
+
+void ScExternalRefManager::refreshAllReferencingCells(sal_uInt16 nFileId)
+{
-+ fprintf(stdout, "ScExternalRefManager::refreshAllReferencingCells: --begin\n");
+ RefCellMap::iterator itr = maRefCells.find(nFileId);
+ if (itr == maRefCells.end())
+ {
+ const String* pFile = getExternalFileName(nFileId);
-+ fprintf(stdout, "ScExternalRefManager::refreshAllReferencingCells: no referencing cells for names from '%s'\n",
-+ rtl::OUStringToOString(*pFile, RTL_TEXTENCODING_UTF8).getStr());
+ return;
+ }
+
@@ -7188,22 +6397,15 @@
+
+ const String* pFile = getExternalFileName(nFileId);
+ if (!pFile)
-+ {
-+ fprintf(stdout, "ScExternalRefManager::getSrcDocument: no file name associated with the ID of %d\n", nFileId);
++ // no file name associated with this ID.
+ return NULL;
-+ }
-+
-+ fprintf(stdout, "ScExternalRefManager::getSourceDocument: file not loaded yet: '%s'\n",
-+ rtl::OUStringToOString(*pFile, RTL_TEXTENCODING_UTF8).getStr());
-+
-+ // TODO: Check whether the file really exists. If not, return NULL.
+
+ String aFilter;
+ SrcDoc aSrcDoc;
+ aSrcDoc.maShell = loadSrcDocument(*pFile, aFilter);
+ if (!aSrcDoc.maShell.Is())
+ {
-+ fprintf(stdout, "ScExternalRefManager::getSrcDocument: source document could not be loaded.\n");
++ // source document could not be loaded.
+ return NULL;
+ }
+
@@ -7301,11 +6503,6 @@
+
+bool ScExternalRefManager::compileTokensByCell(const ScAddress& rCell)
+{
-+ String aStr;
-+ rCell.Format(aStr, SCA_ABS_3D);
-+ fprintf(stdout, "ScExternalRefManager::compileTokensByCell: --begin (cell = '%s')\n",
-+ rtl::OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr());
-+
+ ScBaseCell* pCell;
+ mpDoc->GetCell(rCell.Col(), rCell.Row(), rCell.Tab(), pCell);
+
@@ -7340,7 +6537,6 @@
+ pFC->CompileTokenArray();
+ pFC->SetDirty();
+
-+ fprintf(stdout, "ScExternalRefManager::compileTokensByCell: cell recompiled\n");
+ return true;
+}
+
@@ -7389,35 +6585,20 @@
+
+void ScExternalRefManager::refreshNames(sal_uInt16 nFileId)
+{
-+ fprintf(stdout, "ScExternalRefManager::refreshNames: --begin\n");
-+
+ removeSrcDocument(nFileId, false);
+
+ // Update all cells containing names from this source document.
+ refreshAllReferencingCells(nFileId);
-+ fprintf(stdout, "ScExternalRefManager::refreshNames: --end\n");
+}
+
+void ScExternalRefManager::switchSrcFile(sal_uInt16 nFileId, const String& rNewFile)
+{
-+ const String* pOldFile = getExternalFileName(nFileId);
-+ fprintf(stdout, "ScExternalRefManager::switchSrcFile: --begin (old file = '%s'; new file = '%s')\n",
-+ rtl::OUStringToOString(*pOldFile, RTL_TEXTENCODING_UTF8).getStr(),
-+ rtl::OUStringToOString(rNewFile, RTL_TEXTENCODING_UTF8).getStr());
-+
+ maFileNames[nFileId] = rNewFile;
+ refreshNames(nFileId);
+}
+
+void ScExternalRefManager::removeSrcDocument(sal_uInt16 nFileId, bool bBreakLink)
+{
-+ const String* pFile = getExternalFileName(nFileId);
-+ if (pFile)
-+ {
-+ fprintf(stdout, "ScExternalRefManager::removeSrcFile: --begin (file = '%s')\n",
-+ rtl::OUStringToOString(*pFile, RTL_TEXTENCODING_UTF8).getStr());
-+ }
-+
+ maRefCache.clearCache(nFileId);
+ lcl_removeByFileId(nFileId, maDocShells);
+
@@ -7426,8 +6607,6 @@
+
+ if (maDocShells.empty())
+ maSrcDocTimer.Stop();
-+
-+ fprintf(stdout, "ScExternalRefManager::removeSrcFile: --end\n");
+}
+
+void ScExternalRefManager::clear()
@@ -7453,11 +6632,6 @@
+ {
+ // in 100th of a second.
+ sal_Int32 nSinceLastAccess = (Time() - itr->second.maLastAccess).GetTime();
-+// const String* pStr = getExternalFileName(itr->first);
-+// if (pStr)
-+// fprintf(stdout, "ScExternalRefManager::purgeStaleSrcDocument: file = '%s'; since last access = %ld\n",
-+// rtl::OUStringToOString(*pStr, RTL_TEXTENCODING_UTF8).getStr(), nSinceLastAccess);
-+
+ if (nSinceLastAccess < nTimeOut)
+ aNewDocShells.insert(*itr);
+ }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]