summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-10-07 10:01:27 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-10-07 10:43:55 +0100
commit4dab1026198907dc7821dc5fdf1971945d552cb7 (patch)
treeabd3b0bcb2cde63b0ac91c34021ead63192d320e
parenta47d1a47184e84755f0f28300a1e477b2a6c1176 (diff)
merge copies of flushing code together
and give it descriptive name cause it confused me as to what it did Change-Id: I37b761ab917a75c8364db9c3f7b4896c2dd217bc
-rw-r--r--svtools/source/svhtml/htmlout.cxx60
1 files changed, 27 insertions, 33 deletions
diff --git a/svtools/source/svhtml/htmlout.cxx b/svtools/source/svhtml/htmlout.cxx
index 7a0df72542e2..a8a3fb510891 100644
--- a/svtools/source/svhtml/htmlout.cxx
+++ b/svtools/source/svhtml/htmlout.cxx
@@ -388,6 +388,17 @@ static const sal_Char *lcl_svhtml_GetEntityForChar( sal_Unicode c,
return pStr;
}
+static sal_Size lcl_FlushContext(HTMLOutContext& rContext, sal_Char* pBuffer, sal_uInt32 nFlags)
+{
+ sal_uInt32 nInfo = 0;
+ sal_Size nSrcChars;
+ sal_Size nLen = rtl_convertUnicodeToText(rContext.m_hConv, rContext.m_hContext, nullptr, 0,
+ pBuffer, TXTCONV_BUFFER_SIZE, nFlags|RTL_UNICODETOTEXT_FLAGS_FLUSH,
+ &nInfo, &nSrcChars);
+ DBG_ASSERT((nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing");
+ return nLen;
+}
+
static OString lcl_ConvertCharToHTML( sal_Unicode c,
HTMLOutContext& rContext,
OUString *pNonConvertableChars )
@@ -418,20 +429,13 @@ static OString lcl_ConvertCharToHTML( sal_Unicode c,
}
sal_Char cBuffer[TXTCONV_BUFFER_SIZE];
- sal_uInt32 nInfo = 0;
- sal_Size nSrcChars;
const sal_uInt32 nFlags = RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE|
- RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE|
- RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR|
- RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
+ RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE|
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR|
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
if( pStr )
{
- sal_Size nLen = rtl_convertUnicodeToText(
- rContext.m_hConv, rContext.m_hContext, nullptr, 0,
- cBuffer, TXTCONV_BUFFER_SIZE,
- nFlags|RTL_UNICODETOTEXT_FLAGS_FLUSH,
- &nInfo, &nSrcChars );
- DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
+ sal_Size nLen = lcl_FlushContext(rContext, cBuffer, nFlags);
sal_Char *pBuffer = cBuffer;
while( nLen-- )
aDest.append(*pBuffer++);
@@ -439,11 +443,13 @@ static OString lcl_ConvertCharToHTML( sal_Unicode c,
}
else
{
- sal_Size nLen = rtl_convertUnicodeToText( rContext.m_hConv,
- rContext.m_hContext, &c, 1,
- cBuffer, TXTCONV_BUFFER_SIZE,
- nFlags,
- &nInfo, &nSrcChars );
+ sal_uInt32 nInfo = 0;
+ sal_Size nSrcChars;
+
+ sal_Size nLen = rtl_convertUnicodeToText(rContext.m_hConv,
+ rContext.m_hContext, &c, 1,
+ cBuffer, TXTCONV_BUFFER_SIZE,
+ nFlags, &nInfo, &nSrcChars);
if( nLen > 0 && (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0 )
{
sal_Char *pBuffer = cBuffer;
@@ -456,12 +462,7 @@ static OString lcl_ConvertCharToHTML( sal_Unicode c,
// character set, the UNICODE character is exported as character
// entity.
// coverity[callee_ptr_arith]
- nLen = rtl_convertUnicodeToText(
- rContext.m_hConv, rContext.m_hContext, nullptr, 0,
- cBuffer, TXTCONV_BUFFER_SIZE,
- nFlags|RTL_UNICODETOTEXT_FLAGS_FLUSH,
- &nInfo, &nSrcChars );
- DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
+ nLen = lcl_FlushContext(rContext, cBuffer, nFlags);
sal_Char *pBuffer = cBuffer;
while( nLen-- )
aDest.append(*pBuffer++);
@@ -481,18 +482,11 @@ static OString lcl_FlushToAscii( HTMLOutContext& rContext )
OStringBuffer aDest;
sal_Char cBuffer[TXTCONV_BUFFER_SIZE];
- sal_uInt32 nInfo = 0;
- sal_Size nSrcChars;
const sal_uInt32 nFlags = RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE|
- RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE|
- RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR|
- RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
- sal_Size nLen = rtl_convertUnicodeToText(
- rContext.m_hConv, rContext.m_hContext, nullptr, 0,
- cBuffer, TXTCONV_BUFFER_SIZE,
- nFlags|RTL_UNICODETOTEXT_FLAGS_FLUSH,
- &nInfo, &nSrcChars );
- DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
+ RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE|
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR|
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
+ sal_Size nLen = lcl_FlushContext(rContext, cBuffer, nFlags);
sal_Char *pBuffer = cBuffer;
while( nLen-- )
aDest.append(*pBuffer++);