[ooo-build-commit] Branch 'ooo/OOO310' - sc/inc sc/source
Jan Holesovsky
kendy at kemper.freedesktop.org
Fri Aug 14 17:17:01 PDT 2009
sc/inc/compiler.hxx | 13 ++++
sc/inc/externalrefmgr.hxx | 16 +++++-
sc/source/core/data/cell2.cxx | 4 -
sc/source/core/tool/compiler.cxx | 82 ++++++++++++++++++++++++++-----
sc/source/core/tool/rangeutl.cxx | 4 -
sc/source/core/tool/reftokenhelper.cxx | 2
sc/source/core/tool/token.cxx | 2
sc/source/ui/docshell/externalrefmgr.cxx | 5 +
8 files changed, 107 insertions(+), 21 deletions(-)
New commits:
commit 17caa802a622c781302a845f2c1f859a3a8d45e0
Author: Kurt Zenker <kz at openoffice.org>
Date: Fri Aug 14 11:29:25 2009 +0000
CWS-TOOLING: integrate CWS calcextref311
2009-08-12 16:36:49 +0200 er r274901 : #i103918# fix hex-encoded display of external references and loss of chart data range of such external references; patch from <kohei>
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 8f18f5a..ac0e5ff 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -64,7 +64,7 @@
// constants and data types also for external modules (ScInterpreter et al)
#define MAXCODE 512 /* maximum number of tokens in formula */
-#define MAXSTRLEN 256 /* maximum length of input string of one symbol */
+#define MAXSTRLEN 1024 /* maximum length of input string of one symbol */
#define MAXJUMPCOUNT 32 /* maximum number of jumps (ocChose) */
// flag values of CharTable
@@ -217,6 +217,14 @@ typedef formula::SimpleIntrusiveReference< struct ScRawToken > ScRawTokenRef;
class SC_DLLPUBLIC ScCompiler : public formula::FormulaCompiler
{
public:
+
+ enum EncodeUrlMode
+ {
+ ENCODE_BY_GRAMMAR,
+ ENCODE_ALWAYS,
+ ENCODE_NEVER,
+ };
+
struct Convention
{
const formula::FormulaGrammar::AddressConvention meConv;
@@ -313,6 +321,7 @@ private:
SCsTAB nMaxTab; // last sheet in document
sal_Int32 mnRangeOpPosInSymbol; // if and where a range operator is in symbol
const Convention *pConv;
+ EncodeUrlMode meEncodeUrlMode;
bool mbCloseBrackets; // whether to close open brackets automatically, default TRUE
bool mbExtendedErrorDetection;
bool mbRewind; // whether symbol is to be rewound to some step during lexical analysis
@@ -372,6 +381,8 @@ public:
void SetGrammar( const formula::FormulaGrammar::Grammar eGrammar );
+ void SetEncodeUrlMode( EncodeUrlMode eMode );
+ EncodeUrlMode GetEncodeUrlMode() const;
private:
/** Set grammar and reference convention from within SetFormulaLanguage()
or SetGrammar().
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index f5b6e3f..22e114d 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -579,7 +579,21 @@ public:
*/
void convertToAbsName(String& rFile) const;
sal_uInt16 getExternalFileId(const String& rFile);
- const String* getExternalFileName(sal_uInt16 nFileId);
+
+ /**
+ * It returns a pointer to the name of the URI associated with a given
+ * external file ID. In case the original document has moved, it returns
+ * an URI adjusted for the relocation.
+ *
+ * @param nFileId file ID for an external document
+ * @param bForceOriginal If true, it always returns the original document
+ * URI even if the referring document has relocated.
+ * If false, it returns an URI adjusted for
+ * relocated document.
+ *
+ * @return const String* external document URI.
+ */
+ const String* getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal = false);
bool hasExternalFile(sal_uInt16 nFileId) const;
bool hasExternalFile(const String& rFile) const;
const SrcFileData* getExternalFileData(sal_uInt16 nFileId) const;
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index f323920..3255939 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -130,8 +130,8 @@ void ScEditCell::GetString( String& rString ) const
EditEngine& rEngine = pDoc->GetEditEngine();
rEngine.SetText( *pData );
rString = ScEditUtil::GetSpaceDelimitedString(rEngine); // space between paragraphs
- // kurze Strings fuer Formeln merken
- if ( rString.Len() < MAXSTRLEN )
+ // cache short strings for formulas
+ if ( rString.Len() < 256 )
((ScEditCell*)this)->pString = new String( rString ); //! non-const
}
else
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 564f6cb..e45fe28 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -432,6 +432,15 @@ void ScCompiler::SetGrammar( const FormulaGrammar::Grammar eGrammar )
SetGrammarAndRefConvention( eMyGrammar, eOldGrammar);
}
+void ScCompiler::SetEncodeUrlMode( EncodeUrlMode eMode )
+{
+ meEncodeUrlMode = eMode;
+}
+
+ScCompiler::EncodeUrlMode ScCompiler::GetEncodeUrlMode() const
+{
+ return meEncodeUrlMode;
+}
void ScCompiler::SetFormulaLanguage( const ScCompiler::OpCodeMapPtr & xMap )
{
@@ -1055,14 +1064,19 @@ struct ConventionOOO_A1 : public Convention_A1
bool makeExternalSingleRefStr( ::rtl::OUStringBuffer& rBuffer, sal_uInt16 nFileId,
const String& rTabName, const ScSingleRefData& rRef,
- ScExternalRefManager* pRefMgr, bool bDisplayTabName ) const
+ ScExternalRefManager* pRefMgr, bool bDisplayTabName, bool bEncodeUrl ) const
{
if (bDisplayTabName)
{
String aFile;
const String* p = pRefMgr->getExternalFileName(nFileId);
if (p)
- aFile = *p;
+ {
+ if (bEncodeUrl)
+ aFile = *p;
+ else
+ aFile = INetURLObject::decode(*p, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
+ }
aFile.SearchAndReplaceAllAscii("'", String::CreateFromAscii("''"));
rBuffer.append(sal_Unicode('\''));
@@ -1096,7 +1110,23 @@ struct ConventionOOO_A1 : public Convention_A1
if (bODF)
rBuffer.append( sal_Unicode('['));
- makeExternalSingleRefStr(rBuffer, nFileId, rTabName, aRef, pRefMgr, true);
+
+ bool bEncodeUrl = true;
+ switch (rCompiler.GetEncodeUrlMode())
+ {
+ case ScCompiler::ENCODE_BY_GRAMMAR:
+ bEncodeUrl = bODF;
+ break;
+ case ScCompiler::ENCODE_ALWAYS:
+ bEncodeUrl = true;
+ break;
+ case ScCompiler::ENCODE_NEVER:
+ bEncodeUrl = false;
+ break;
+ default:
+ ;
+ }
+ makeExternalSingleRefStr(rBuffer, nFileId, rTabName, aRef, pRefMgr, true, bEncodeUrl);
if (bODF)
rBuffer.append( sal_Unicode(']'));
}
@@ -1118,9 +1148,25 @@ struct ConventionOOO_A1 : public Convention_A1
if (bODF)
rBuffer.append( sal_Unicode('['));
// Ensure that there's always a closing bracket, no premature returns.
+ bool bEncodeUrl = true;
+ switch (rCompiler.GetEncodeUrlMode())
+ {
+ case ScCompiler::ENCODE_BY_GRAMMAR:
+ bEncodeUrl = bODF;
+ break;
+ case ScCompiler::ENCODE_ALWAYS:
+ bEncodeUrl = true;
+ break;
+ case ScCompiler::ENCODE_NEVER:
+ bEncodeUrl = false;
+ break;
+ default:
+ ;
+ }
+
do
{
- if (!makeExternalSingleRefStr(rBuffer, nFileId, rTabName, aRef.Ref1, pRefMgr, true))
+ if (!makeExternalSingleRefStr(rBuffer, nFileId, rTabName, aRef.Ref1, pRefMgr, true, bEncodeUrl))
break;
rBuffer.append(sal_Unicode(':'));
@@ -1146,7 +1192,7 @@ struct ConventionOOO_A1 : public Convention_A1
else if (bODF)
rBuffer.append( sal_Unicode('.')); // need at least the sheet separator in ODF
makeExternalSingleRefStr( rBuffer, nFileId, aLastTabName,
- aRef.Ref2, pRefMgr, bDisplayTabName);
+ aRef.Ref2, pRefMgr, bDisplayTabName, bEncodeUrl);
} while (0);
if (bODF)
rBuffer.append( sal_Unicode(']'));
@@ -1308,7 +1354,7 @@ struct ConventionXL
return lcl_makeExternalNameStr( rFile, rName, sal_Unicode('!'), false);
}
- static void makeExternalDocStr( ::rtl::OUStringBuffer& rBuffer, const String& rFullName )
+ static void makeExternalDocStr( ::rtl::OUStringBuffer& rBuffer, const String& rFullName, bool bEncodeUrl )
{
// Format that is easier to deal with inside OOo, because we use file
// URL, and all characetrs are allowed. Check if it makes sense to do
@@ -1319,8 +1365,14 @@ struct ConventionXL
rBuffer.append(sal_Unicode('['));
rBuffer.append(sal_Unicode('\''));
- const sal_Unicode* pBuf = rFullName.GetBuffer();
- xub_StrLen nLen = rFullName.Len();
+ String aFullName;
+ if (bEncodeUrl)
+ aFullName = rFullName;
+ else
+ aFullName = INetURLObject::decode(rFullName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
+
+ const sal_Unicode* pBuf = aFullName.GetBuffer();
+ xub_StrLen nLen = aFullName.Len();
for (xub_StrLen i = 0; i < nLen; ++i)
{
const sal_Unicode c = pBuf[i];
@@ -1533,7 +1585,8 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
ScSingleRefData aRef(rRef);
aRef.CalcAbsIfRel(rCompiler.GetPos());
- ConventionXL::makeExternalDocStr(rBuffer, *pFullName);
+ ConventionXL::makeExternalDocStr(
+ rBuffer, *pFullName, rCompiler.GetEncodeUrlMode() == ScCompiler::ENCODE_ALWAYS);
ScRangeStringConverter::AppendTableName(rBuffer, rTabName);
rBuffer.append(sal_Unicode('!'));
@@ -1556,7 +1609,8 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
ScComplexRefData aRef(rRef);
aRef.CalcAbsIfRel(rCompiler.GetPos());
- ConventionXL::makeExternalDocStr(rBuffer, *pFullName);
+ ConventionXL::makeExternalDocStr(
+ rBuffer, *pFullName, rCompiler.GetEncodeUrlMode() == ScCompiler::ENCODE_ALWAYS);
ConventionXL::makeExternalTabNameRange(rBuffer, rTabName, aTabNames, aRef);
rBuffer.append(sal_Unicode('!'));
@@ -1737,7 +1791,8 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
ScSingleRefData aRef(rRef);
aRef.CalcAbsIfRel(rCompiler.GetPos());
- ConventionXL::makeExternalDocStr(rBuffer, *pFullName);
+ ConventionXL::makeExternalDocStr(
+ rBuffer, *pFullName, rCompiler.GetEncodeUrlMode() == ScCompiler::ENCODE_ALWAYS);
ScRangeStringConverter::AppendTableName(rBuffer, rTabName);
rBuffer.append(sal_Unicode('!'));
@@ -1761,7 +1816,8 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
ScComplexRefData aRef(rRef);
aRef.CalcAbsIfRel(rCompiler.GetPos());
- ConventionXL::makeExternalDocStr(rBuffer, *pFullName);
+ ConventionXL::makeExternalDocStr(
+ rBuffer, *pFullName, rCompiler.GetEncodeUrlMode() == ScCompiler::ENCODE_ALWAYS);
ConventionXL::makeExternalTabNameRange(rBuffer, rTabName, aTabNames, aRef);
rBuffer.append(sal_Unicode('!'));
@@ -1813,6 +1869,7 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos,ScTokenArra
mnPredetectedReference(0),
mnRangeOpPosInSymbol(-1),
pConv( pConvOOO_A1 ),
+ meEncodeUrlMode( ENCODE_BY_GRAMMAR ),
mbCloseBrackets( true ),
mbExtendedErrorDetection( false ),
mbRewind( false )
@@ -1828,6 +1885,7 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos)
mnPredetectedReference(0),
mnRangeOpPosInSymbol(-1),
pConv( pConvOOO_A1 ),
+ meEncodeUrlMode( ENCODE_BY_GRAMMAR ),
mbCloseBrackets( true ),
mbExtendedErrorDetection( false ),
mbRewind( false )
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index 62474c3..801cf17 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -786,7 +786,7 @@ static void lcl_appendCellAddress(
if (rExtInfo.mbExternal)
{
ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
- const String* pFilePath = pRefMgr->getExternalFileName(rExtInfo.mnFileId);
+ const String* pFilePath = pRefMgr->getExternalFileName(rExtInfo.mnFileId, true);
if (!pFilePath)
return;
@@ -821,7 +821,7 @@ static void lcl_appendCellRangeAddress(
DBG_ASSERT(rExtInfo1.mnFileId == rExtInfo2.mnFileId, "File IDs do not match between 1st and 2nd addresses.");
ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
- const String* pFilePath = pRefMgr->getExternalFileName(rExtInfo1.mnFileId);
+ const String* pFilePath = pRefMgr->getExternalFileName(rExtInfo1.mnFileId, true);
if (!pFilePath)
return;
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index 07db9fd..15f86a4 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -51,7 +51,7 @@ using ::rtl::OUString;
void ScRefTokenHelper::compileRangeRepresentation(
vector<ScSharedTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc)
{
- const sal_Unicode cSep = ';';
+ const sal_Unicode cSep = GetScCompilerNativeSymbol(ocSep).GetChar(0);
const sal_Unicode cQuote = '\'';
bool bFailure = false;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6571a07..fddce05 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -119,7 +119,7 @@ IMPL_FIXEDMEMPOOL_NEWDEL( ImpTokenIterator, 32, 16 )
// Align MemPools on 4k boundaries - 64 bytes (4k is a MUST for OS/2)
// Since RawTokens are temporary for the compiler, don't align on 4k and waste memory.
-// ScRawToken size is FixMembers + MAXSTRLEN ~= 264
+// ScRawToken size is FixMembers + MAXSTRLEN + ~4 ~= 1036
IMPL_FIXEDMEMPOOL_NEWDEL( ScRawToken, 8, 4 )
// Some ScDoubleRawToken, FixMembers + sizeof(double) ~= 16
const USHORT nMemPoolDoubleRawToken = 0x0400 / sizeof(ScDoubleRawToken);
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 15eaf67..1a4154c 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2085,11 +2085,14 @@ sal_uInt16 ScExternalRefManager::getExternalFileId(const String& rFile)
return static_cast<sal_uInt16>(maSrcFiles.size() - 1);
}
-const String* ScExternalRefManager::getExternalFileName(sal_uInt16 nFileId)
+const String* ScExternalRefManager::getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal)
{
if (nFileId >= maSrcFiles.size())
return NULL;
+ if (bForceOriginal)
+ return &maSrcFiles[nFileId].maFileName;
+
maybeCreateRealFileName(nFileId);
if (maSrcFiles[nFileId].maRealFileName.Len())
More information about the ooo-build-commit
mailing list