So now UniString is gone we have the chance to make use of OUString for
= 64k paragraphs (#i17171#) but we basically have to decide what to do
with places that currently return STRING_LEN/STRING_MAXLEN in xub_Strlen
(unsigned short). Do we want to return -1 or SAL_MAX_INT32 as the
replacement. -1 is nice but there is so much code in existence that
expects the error/boundary condition return value to be any valid
number that I reckon SAL_MAX_INT32 might be safer as the default.
For a concrete place see OutputDevice::GetTextBreak where STRING_LEN is
returned for the boundary case. See also grepping for STRING_LEN in sw
and think mass search/replace STRING_LEN SAL_MAX_INT32 :-)
For reference, I attach the trivial patches to remove the 16bit length
limits in writer that stop anything larger that 0x entering it which
are the final bits to be applied once everything else is done.
C.
From 00a379e51e629b218bcdd281e8be25f5f6cc3b7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= caol...@redhat.com
Date: Thu, 7 Nov 2013 14:59:33 +
Subject: [PATCH 01/12] Related: fdo#17171 stop clipping strings to STRING_LEN
on .doc import
Change-Id: Ic99132d0ee7804dc3625bef88cd35b2894f342c2
---
sw/source/filter/ww8/ww8par.cxx | 42 +++--
1 file changed, 7 insertions(+), 35 deletions(-)
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 6a1c048..66107ff 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2974,19 +2974,13 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP rPos, sal_Int32 nEnd, sal_Int32 nCp
// Reset Unicode flag and correct FilePos if needed.
// Note: Seek is not expensive, as we're checking inline whether or not
// the correct FilePos has already been reached.
-xub_StrLen nStrLen;
-if (nValidStrLen = (STRING_MAXLEN-1))
-nStrLen = writer_castxub_StrLen(nValidStrLen);
-else
-nStrLen = STRING_MAXLEN-1;
-
const rtl_TextEncoding eSrcCharSet = bVer67 ? GetCurrentCharSet() :
RTL_TEXTENCODING_MS_1252;
const rtl_TextEncoding eSrcCJKCharSet = bVer67 ? GetCurrentCJKCharSet() :
RTL_TEXTENCODING_MS_1252;
// allocate unicode string data
-rtl_uString *pStr = rtl_uString_alloc(nStrLen);
+rtl_uString *pStr = rtl_uString_alloc(nValidStrLen);
sal_Unicode* pBuffer = pStr-buffer;
sal_Unicode* pWork = pBuffer;
@@ -2997,7 +2991,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP rPos, sal_Int32 nEnd, sal_Int32 nCp
hConverter = rtl_createTextToUnicodeConverter(eSrcCharSet);
if (!bIsUnicode)
-p8Bits = new sal_Char[nStrLen];
+p8Bits = new sal_Char[nValidStrLen];
// read the stream data
sal_uInt8 nBCode = 0;
@@ -3009,7 +3003,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP rPos, sal_Int32 nEnd, sal_Int32 nCp
if (pItem != NULL)
nCTLLang = dynamic_castconst SvxLanguageItem *(pItem)-GetLanguage();
-for( nL2 = 0; nL2 nStrLen; ++nL2, ++pWork )
+for( nL2 = 0; nL2 nValidStrLen; ++nL2, ++pWork )
{
if (bIsUnicode)
*pStrm nUCode; // unicode -- read 2 bytes
@@ -3064,9 +3058,9 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP rPos, sal_Int32 nEnd, sal_Int32 nCp
xub_StrLen nEndUsed = nL2;
if (!bIsUnicode)
-nEndUsed = Custom8BitToUnicode(hConverter, p8Bits, nL2, pBuffer, nStrLen);
+nEndUsed = Custom8BitToUnicode(hConverter, p8Bits, nL2, pBuffer, nValidStrLen);
-for( sal_Int32 nI = 0; nI nStrLen; ++nI, ++pBuffer )
+for( sal_Int32 nI = 0; nI nValidStrLen; ++nI, ++pBuffer )
if (m_bRegardHindiDigits bBidi LangUsesHindiNumbers(nCTLLang))
*pBuffer = TranslateToHindiNumbers(*pBuffer);
@@ -3085,7 +3079,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP rPos, sal_Int32 nEnd, sal_Int32 nCp
if (pStr)
rtl_uString_release(pStr);
delete [] p8Bits;
-return nL2 = nStrLen;
+return nL2 = nValidStrLen;
}
#define MSASCII SAL_MAX_INT16
@@ -3326,29 +3320,7 @@ void SwWW8ImplReader::simpleAddTextToParagraph(const OUString rAddString)
if (!pNd)
return;
-if ((pNd-GetTxt().getLength() + rAddString.getLength()) STRING_MAXLEN-1)
-{
-rDoc.InsertString(*pPaM, rAddString);
-}
-else
-{
-
-if (pNd-GetTxt().getLength() STRING_MAXLEN -1)
-{
-OUString sTempStr = rAddString.copy( 0,
-STRING_MAXLEN - pNd-GetTxt().getLength() -1);
-rDoc.InsertString(*pPaM, sTempStr);
-sTempStr = rAddString.copy(sTempStr.getLength(),
-rAddString.getLength() - sTempStr.getLength());
-AppendTxtNode(*pPaM-GetPoint());
-rDoc.InsertString(*pPaM, sTempStr);
-}
-else
-{
-AppendTxtNode(*pPaM-GetPoint());
-rDoc.InsertString(*pPaM, rAddString);
-}
-}
+