[ooo-build-commit] Branch 'ooo-build-3-1-1' - patches/dev300
Kohei Yoshida
kohei at kemper.freedesktop.org
Mon Aug 10 20:04:27 PDT 2009
patches/dev300/apply | 3
patches/dev300/calc-external-ref-decode-unicode-uri.diff | 303 +++++++++++++++
2 files changed, 306 insertions(+)
New commits:
commit 351434ad61d6529280bb310bcd08374308ada87c
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Aug 10 23:00:19 2009 -0400
Fixed several regressions in external references.
* patches/dev300/apply: apply the new patch.
* patches/dev300/calc-external-ref-decode-unicode-uri.diff: decode
unicode strings in external reference URIs when displaying formulas,
and fix chart listener instantiations upon file load, which wasn't
working due to regression. (i#103918)
diff --git a/patches/dev300/apply b/patches/dev300/apply
index 3252cac..4162003 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -3188,6 +3188,9 @@ calc-xls-import-array-size.diff, kohei
calc-copy-range-animated-border-sc.diff, kohei
calc-copy-range-animated-border-svx.diff, kohei
+# decode unicode string in external doc URIs when displaying formulas.
+calc-external-ref-decode-unicode-uri.diff, i#103918, kohei
+
[ CalcRowLimit ]
# The work to increase Calc's row size limit, and any work associated with it.
SectionOwner => kohei
diff --git a/patches/dev300/calc-external-ref-decode-unicode-uri.diff b/patches/dev300/calc-external-ref-decode-unicode-uri.diff
new file mode 100644
index 0000000..2643b9d
--- /dev/null
+++ b/patches/dev300/calc-external-ref-decode-unicode-uri.diff
@@ -0,0 +1,303 @@
+diff --git sc/inc/compiler.hxx sc/inc/compiler.hxx
+index 0c7b76d..958aacc 100644
+--- sc/inc/compiler.hxx
++++ 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
+@@ -373,6 +382,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 sc/inc/externalrefmgr.hxx sc/inc/externalrefmgr.hxx
+index f5b6e3f..22e114d 100644
+--- sc/inc/externalrefmgr.hxx
++++ 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 sc/source/core/tool/compiler.cxx sc/source/core/tool/compiler.cxx
+index bbb62c0..f89d00b 100644
+--- sc/source/core/tool/compiler.cxx
++++ 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_NEVER);
+ 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_NEVER);
+ 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_NEVER);
+ 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_NEVER);
+ 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 sc/source/core/tool/rangeutl.cxx sc/source/core/tool/rangeutl.cxx
+index b5bdfda..bdacf29 100644
+--- sc/source/core/tool/rangeutl.cxx
++++ sc/source/core/tool/rangeutl.cxx
+@@ -840,7 +840,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 sc/source/core/tool/reftokenhelper.cxx sc/source/core/tool/reftokenhelper.cxx
+index 635df6e..f2aba4e 100644
+--- sc/source/core/tool/reftokenhelper.cxx
++++ sc/source/core/tool/reftokenhelper.cxx
+@@ -51,7 +51,7 @@ using ::rtl::OUString;
+ void ScRefTokenHelper::compileRangeRepresentation(
+ vector<ScSharedTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc, FormulaGrammar::Grammar eGrammar)
+ {
+- const sal_Unicode cSep = ';';
++ const sal_Unicode cSep = GetScCompilerNativeSymbol(ocSep).GetChar(0);
+ const sal_Unicode cQuote = '\'';
+
+ bool bFailure = false;
+diff --git sc/source/ui/docshell/externalrefmgr.cxx sc/source/ui/docshell/externalrefmgr.cxx
+index 69a1afe..5304d46 100644
+--- sc/source/ui/docshell/externalrefmgr.cxx
++++ sc/source/ui/docshell/externalrefmgr.cxx
+@@ -2086,11 +2086,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