summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authordante <dante19031999@gmail.com>2020-12-28 21:19:43 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-30 07:46:05 +0100
commitcda385ac10ac0deb46c2c04e6d1b4d9f05555c26 (patch)
tree944c15c3f4de6ba8bf71f4b25fe75fd802d860b9 /sax
parent3b352e846e7244c34182fcc925e6653431880ac9 (diff)
Clang-format saxwriter
Change-Id: I4793d81e2ba3405b9ed07a2c5547572ed7e0bee6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108425 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sax')
-rw-r--r--sax/source/expatwrap/saxwriter.cxx663
1 files changed, 313 insertions, 350 deletions
diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx
index 03ca1f765d82..f6a58b0bb4cb 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -64,8 +64,8 @@ using namespace ::com::sun::star::io;
*
*****/
-namespace {
-
+namespace
+{
enum SaxInvalidCharacterError
{
SAX_NONE,
@@ -92,13 +92,13 @@ public:
#endif
private:
- Reference< XOutputStream > m_out;
- Sequence < sal_Int8 > m_Sequence;
- sal_Int8* mp_Sequence;
+ Reference<XOutputStream> m_out;
+ Sequence<sal_Int8> m_Sequence;
+ sal_Int8* mp_Sequence;
- sal_Int32 nLastLineFeedPos; // is negative after writing a sequence
- sal_uInt32 nCurrentPos;
- bool m_bStartElementFinished;
+ sal_Int32 nLastLineFeedPos; // is negative after writing a sequence
+ sal_uInt32 nCurrentPos;
+ bool m_bStartElementFinished;
std::vector<ReplacementPair> m_Replacements;
@@ -109,19 +109,16 @@ private:
// so the sequence has to write out and reset rPos to 0
// writes sequence only on overflow, sequence could be full on the end (rPos == SEQUENCESIZE)
/// @throws SAXException
- void AddBytes(sal_Int8* pTarget, sal_uInt32& rPos,
- const sal_Int8* pBytes, sal_uInt32 nBytesCount);
+ void AddBytes(sal_Int8* pTarget, sal_uInt32& rPos, const sal_Int8* pBytes,
+ sal_uInt32 nBytesCount);
/// @throws SAXException
- bool convertToXML(const sal_Unicode * pStr,
- sal_Int32 nStrLen,
- bool bDoNormalization,
- bool bNormalizeWhitespace,
- sal_Int8 *pTarget,
- sal_uInt32& rPos);
+ bool convertToXML(const sal_Unicode* pStr, sal_Int32 nStrLen, bool bDoNormalization,
+ bool bNormalizeWhitespace, sal_Int8* pTarget, sal_uInt32& rPos);
/// @throws SAXException
void FinishStartElement();
+
public:
- explicit SaxWriterHelper(Reference< XOutputStream > const & m_TempOut)
+ explicit SaxWriterHelper(Reference<XOutputStream> const& m_TempOut)
: m_out(m_TempOut)
, m_Sequence(SEQUENCESIZE)
, mp_Sequence(nullptr)
@@ -141,39 +138,41 @@ public:
/// @throws SAXException
void insertIndentation(sal_uInt32 m_nLevel);
-// returns whether it works correct or invalid characters were in the string
-// If there are invalid characters in the string it returns sal_False.
-// Than the calling method has to throw the needed Exception.
+ // returns whether it works correct or invalid characters were in the string
+ // If there are invalid characters in the string it returns sal_False.
+ // Than the calling method has to throw the needed Exception.
/// @throws SAXException
- bool writeString(const OUString& rWriteOutString,
- bool bDoNormalization,
- bool bNormalizeWhitespace);
+ bool writeString(const OUString& rWriteOutString, bool bDoNormalization,
+ bool bNormalizeWhitespace);
sal_uInt32 GetLastColumnCount() const throw()
- { return static_cast<sal_uInt32>(nCurrentPos - nLastLineFeedPos); }
+ {
+ return static_cast<sal_uInt32>(nCurrentPos - nLastLineFeedPos);
+ }
/// @throws SAXException
void startDocument();
-// returns whether it works correct or invalid characters were in the strings
-// If there are invalid characters in one of the strings it returns sal_False.
-// Than the calling method has to throw the needed Exception.
+ // returns whether it works correct or invalid characters were in the strings
+ // If there are invalid characters in one of the strings it returns sal_False.
+ // Than the calling method has to throw the needed Exception.
/// @throws SAXException
- SaxInvalidCharacterError startElement(const OUString& rName, const Reference< XAttributeList >& xAttribs);
+ SaxInvalidCharacterError startElement(const OUString& rName,
+ const Reference<XAttributeList>& xAttribs);
/// @throws SAXException
bool FinishEmptyElement();
-// returns whether it works correct or invalid characters were in the string
-// If there are invalid characters in the string it returns sal_False.
-// Than the calling method has to throw the needed Exception.
+ // returns whether it works correct or invalid characters were in the string
+ // If there are invalid characters in the string it returns sal_False.
+ // Than the calling method has to throw the needed Exception.
/// @throws SAXException
bool endElement(const OUString& rName);
/// @throws SAXException
void endDocument();
-// returns whether it works correct or invalid characters were in the strings
-// If there are invalid characters in the string it returns sal_False.
-// Than the calling method has to throw the needed Exception.
+ // returns whether it works correct or invalid characters were in the strings
+ // If there are invalid characters in the string it returns sal_False.
+ // Than the calling method has to throw the needed Exception.
/// @throws SAXException
bool processingInstruction(const OUString& rTarget, const OUString& rData);
/// @throws SAXException
@@ -181,9 +180,9 @@ public:
/// @throws SAXException
void endCDATA();
-// returns whether it works correct or invalid characters were in the strings
-// If there are invalid characters in the string it returns sal_False.
-// Than the calling method has to throw the needed Exception.
+ // returns whether it works correct or invalid characters were in the strings
+ // If there are invalid characters in the string it returns sal_False.
+ // Than the calling method has to throw the needed Exception.
/// @throws SAXException
bool comment(const OUString& rComment);
@@ -192,26 +191,26 @@ public:
// Use custom entity names
void setCustomEntityNames(
- const ::css::uno::Sequence<::css::beans::Pair<::rtl::OUString, ::rtl::OUString>>& replacements);
+ const ::css::uno::Sequence<::css::beans::Pair<::rtl::OUString, ::rtl::OUString>>&
+ replacements);
};
-const bool g_bValidCharsBelow32[32] =
-{
-// 0 1 2 3 4 5 6 7
- false,false,false,false,false,false,false,false, //0
- false,true, true, false,false,true, false,false, //8
- false,false,false,false,false,false,false,false, //16
- false,false,false,false,false,false,false,false
+const bool g_bValidCharsBelow32[32] = {
+ // clang-format off
+// 0 1 2 3 4 5 6 7
+ false, false, false, false, false, false, false, false, //0
+ false, true, true, false, false, true, false, false, //8
+ false, false, false, false, false, false, false, false, //16
+ false, false, false, false, false, false, false, false
+ // clang-format on
};
bool IsInvalidChar(const sal_Unicode aChar)
{
bool bRet(false);
// check first for the most common characters
- if( aChar < 32 || aChar >= 0xd800 )
- bRet = ( (aChar < 32 && ! g_bValidCharsBelow32[aChar]) ||
- aChar == 0xffff ||
- aChar == 0xfffe );
+ if (aChar < 32 || aChar >= 0xd800)
+ bRet = ((aChar < 32 && !g_bValidCharsBelow32[aChar]) || aChar == 0xffff || aChar == 0xfffe);
return bRet;
}
@@ -223,26 +222,23 @@ sal_uInt32 SaxWriterHelper::writeSequence()
{
try
{
- m_out->writeBytes( m_Sequence );
+ m_out->writeBytes(m_Sequence);
}
- catch (const IOException &)
+ catch (const IOException&)
{
css::uno::Any anyEx = cppu::getCaughtException();
- throw SAXException(
- "IO exception during writing",
- Reference< XInterface > (),
- anyEx );
+ throw SAXException("IO exception during writing", Reference<XInterface>(), anyEx);
}
nLastLineFeedPos -= SEQUENCESIZE;
return 0;
}
-void SaxWriterHelper::AddBytes(sal_Int8* pTarget, sal_uInt32& rPos,
- const sal_Int8* pBytes, sal_uInt32 nBytesCount)
+void SaxWriterHelper::AddBytes(sal_Int8* pTarget, sal_uInt32& rPos, const sal_Int8* pBytes,
+ sal_uInt32 nBytesCount)
{
OSL_ENSURE((rPos + nBytesCount) > SEQUENCESIZE, "wrong use of AddBytesMethod");
sal_uInt32 nCount(SEQUENCESIZE - rPos);
- memcpy( &(pTarget[rPos]) , pBytes, nCount);
+ memcpy(&(pTarget[rPos]), pBytes, nCount);
OSL_ENSURE(rPos + nCount == SEQUENCESIZE, "the position should be the at the end");
@@ -250,7 +246,7 @@ void SaxWriterHelper::AddBytes(sal_Int8* pTarget, sal_uInt32& rPos,
sal_uInt32 nRestCount(nBytesCount - nCount);
if ((rPos + nRestCount) <= SEQUENCESIZE)
{
- memcpy( &(pTarget[rPos]), &pBytes[nCount], nRestCount);
+ memcpy(&(pTarget[rPos]), &pBytes[nCount], nRestCount);
rPos += nRestCount;
}
else
@@ -277,34 +273,31 @@ void SaxWriterHelper::setCustomEntityNames(
must call calcXMLByteLength on the same string, to ensure,
that there is enough memory for converting.
*/
-bool SaxWriterHelper::convertToXML( const sal_Unicode * pStr,
- sal_Int32 nStrLen,
- bool bDoNormalization,
- bool bNormalizeWhitespace,
- sal_Int8 *pTarget,
- sal_uInt32& rPos )
+bool SaxWriterHelper::convertToXML(const sal_Unicode* pStr, sal_Int32 nStrLen,
+ bool bDoNormalization, bool bNormalizeWhitespace,
+ sal_Int8* pTarget, sal_uInt32& rPos)
{
bool bRet(true);
sal_uInt32 nSurrogate = 0;
- for( sal_Int32 i = 0 ; i < nStrLen ; i ++ )
+ for (sal_Int32 i = 0; i < nStrLen; i++)
{
sal_uInt16 c = pStr[i];
if (IsInvalidChar(c))
bRet = false;
- else if( (c >= 0x0001) && (c <= 0x007F) )
+ else if ((c >= 0x0001) && (c <= 0x007F))
{
- if( bDoNormalization )
+ if (bDoNormalization)
{
- switch( c )
+ switch (c)
{
- case '&': // resemble to &amp;
+ case '&': // resemble to &amp;
{
if ((rPos + 5) > SEQUENCESIZE)
- AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const *>("&amp;"), 5);
+ AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const*>("&amp;"), 5);
else
{
- memcpy( &(pTarget[rPos]) , "&amp;", 5 );
+ memcpy(&(pTarget[rPos]), "&amp;", 5);
rPos += 5;
}
}
@@ -312,67 +305,68 @@ bool SaxWriterHelper::convertToXML( const sal_Unicode * pStr,
case '<':
{
if ((rPos + 4) > SEQUENCESIZE)
- AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const *>("&lt;"), 4);
+ AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const*>("&lt;"), 4);
else
{
- memcpy( &(pTarget[rPos]) , "&lt;" , 4 );
- rPos += 4; // &lt;
+ memcpy(&(pTarget[rPos]), "&lt;", 4);
+ rPos += 4; // &lt;
}
}
break;
case '>':
{
if ((rPos + 4) > SEQUENCESIZE)
- AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const *>("&gt;"), 4);
+ AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const*>("&gt;"), 4);
else
{
- memcpy( &(pTarget[rPos]) , "&gt;" , 4 );
- rPos += 4; // &gt;
+ memcpy(&(pTarget[rPos]), "&gt;", 4);
+ rPos += 4; // &gt;
}
}
break;
case '\'':
{
if ((rPos + 6) > SEQUENCESIZE)
- AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const *>("&apos;"), 6);
+ AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const*>("&apos;"), 6);
else
{
- memcpy( &(pTarget[rPos]) , "&apos;" , 6 );
- rPos += 6; // &apos;
+ memcpy(&(pTarget[rPos]), "&apos;", 6);
+ rPos += 6; // &apos;
}
}
break;
case '"':
{
if ((rPos + 6) > SEQUENCESIZE)
- AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const *>("&quot;"), 6);
+ AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const*>("&quot;"), 6);
else
{
- memcpy( &(pTarget[rPos]) , "&quot;" , 6 );
- rPos += 6; // &quot;
+ memcpy(&(pTarget[rPos]), "&quot;", 6);
+ rPos += 6; // &quot;
}
}
break;
case 13:
{
if ((rPos + 6) > SEQUENCESIZE)
- AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const *>("&#x0d;"), 6);
+ AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const*>("&#x0d;"), 6);
else
{
- memcpy( &(pTarget[rPos]) , "&#x0d;" , 6 );
+ memcpy(&(pTarget[rPos]), "&#x0d;", 6);
rPos += 6;
}
}
break;
case LINEFEED:
{
- if( bNormalizeWhitespace )
+ if (bNormalizeWhitespace)
{
if ((rPos + 6) > SEQUENCESIZE)
- AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const *>("&#x0a;"), 6);
+ AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const*>("&#x0a;"),
+ 6);
else
{
- memcpy( &(pTarget[rPos]) , "&#x0a;" , 6 );
+ memcpy(&(pTarget[rPos]), "&#x0a;", 6);
rPos += 6;
}
}
@@ -380,33 +374,34 @@ bool SaxWriterHelper::convertToXML( const sal_Unicode * pStr,
{
pTarget[rPos] = LINEFEED;
nLastLineFeedPos = rPos;
- rPos ++;
+ rPos++;
}
}
break;
case 9:
{
- if( bNormalizeWhitespace )
+ if (bNormalizeWhitespace)
{
if ((rPos + 6) > SEQUENCESIZE)
- AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const *>("&#x09;"), 6);
+ AddBytes(pTarget, rPos, reinterpret_cast<sal_Int8 const*>("&#x09;"),
+ 6);
else
{
- memcpy( &(pTarget[rPos]) , "&#x09;" , 6 );
+ memcpy(&(pTarget[rPos]), "&#x09;", 6);
rPos += 6;
}
}
else
{
pTarget[rPos] = 9;
- rPos ++;
+ rPos++;
}
}
break;
default:
{
pTarget[rPos] = static_cast<sal_Int8>(c);
- rPos ++;
+ rPos++;
}
break;
}
@@ -416,79 +411,79 @@ bool SaxWriterHelper::convertToXML( const sal_Unicode * pStr,
pTarget[rPos] = static_cast<sal_Int8>(c);
if (static_cast<sal_Int8>(c) == LINEFEED)
nLastLineFeedPos = rPos;
- rPos ++;
+ rPos++;
}
}
- else if( c >= 0xd800 && c < 0xdc00 )
+ else if (c >= 0xd800 && c < 0xdc00)
{
// 1. surrogate: save (until 2. surrogate)
- OSL_ENSURE( nSurrogate == 0, "left-over Unicode surrogate" );
- nSurrogate = ( ( c & 0x03ff ) + 0x0040 );
+ OSL_ENSURE(nSurrogate == 0, "left-over Unicode surrogate");
+ nSurrogate = ((c & 0x03ff) + 0x0040);
}
- else if( c >= 0xdc00 && c < 0xe000 )
+ else if (c >= 0xdc00 && c < 0xe000)
{
// 2. surrogate: write as UTF-8
- OSL_ENSURE( nSurrogate != 0, "lone 2nd Unicode surrogate" );
+ OSL_ENSURE(nSurrogate != 0, "lone 2nd Unicode surrogate");
- nSurrogate = ( nSurrogate << 10 ) | ( c & 0x03ff );
- if( rtl::isUnicodeScalarValue(nSurrogate) && nSurrogate >= 0x00010000 )
+ nSurrogate = (nSurrogate << 10) | (c & 0x03ff);
+ if (rtl::isUnicodeScalarValue(nSurrogate) && nSurrogate >= 0x00010000)
{
sal_Int8 aBytes[] = { sal_Int8(0xF0 | ((nSurrogate >> 18) & 0x0F)),
sal_Int8(0x80 | ((nSurrogate >> 12) & 0x3F)),
- sal_Int8(0x80 | ((nSurrogate >> 6) & 0x3F)),
- sal_Int8(0x80 | ((nSurrogate >> 0) & 0x3F)) };
+ sal_Int8(0x80 | ((nSurrogate >> 6) & 0x3F)),
+ sal_Int8(0x80 | ((nSurrogate >> 0) & 0x3F)) };
if ((rPos + 4) > SEQUENCESIZE)
AddBytes(pTarget, rPos, aBytes, 4);
else
{
pTarget[rPos] = aBytes[0];
- rPos ++;
+ rPos++;
pTarget[rPos] = aBytes[1];
- rPos ++;
+ rPos++;
pTarget[rPos] = aBytes[2];
- rPos ++;
+ rPos++;
pTarget[rPos] = aBytes[3];
- rPos ++;
+ rPos++;
}
}
else
{
- OSL_FAIL( "illegal Unicode character" );
+ OSL_FAIL("illegal Unicode character");
bRet = false;
}
// reset surrogate
nSurrogate = 0;
}
- else if( c > 0x07FF )
+ else if (c > 0x07FF)
{
- sal_Int8 aBytes[] = { sal_Int8(0xE0 | ((c >> 12) & 0x0F)),
- sal_Int8(0x80 | ((c >> 6) & 0x3F)),
- sal_Int8(0x80 | ((c >> 0) & 0x3F)) };
+ sal_Int8 aBytes[]
+ = { sal_Int8(0xE0 | ((c >> 12) & 0x0F)), sal_Int8(0x80 | ((c >> 6) & 0x3F)),
+ sal_Int8(0x80 | ((c >> 0) & 0x3F)) };
if ((rPos + 3) > SEQUENCESIZE)
AddBytes(pTarget, rPos, aBytes, 3);
else
{
pTarget[rPos] = aBytes[0];
- rPos ++;
+ rPos++;
pTarget[rPos] = aBytes[1];
- rPos ++;
+ rPos++;
pTarget[rPos] = aBytes[2];
- rPos ++;
+ rPos++;
}
}
else
{
- sal_Int8 aBytes[] = { sal_Int8(0xC0 | ((c >> 6) & 0x1F)),
- sal_Int8(0x80 | ((c >> 0) & 0x3F)) };
+ sal_Int8 aBytes[]
+ = { sal_Int8(0xC0 | ((c >> 6) & 0x1F)), sal_Int8(0x80 | ((c >> 0) & 0x3F)) };
if ((rPos + 2) > SEQUENCESIZE)
AddBytes(pTarget, rPos, aBytes, 2);
else
{
pTarget[rPos] = aBytes[0];
- rPos ++;
+ rPos++;
pTarget[rPos] = aBytes[1];
- rPos ++;
+ rPos++;
}
}
OSL_ENSURE(rPos <= SEQUENCESIZE, "not reset current position");
@@ -496,9 +491,9 @@ bool SaxWriterHelper::convertToXML( const sal_Unicode * pStr,
rPos = writeSequence();
// reset left-over surrogate
- if( ( nSurrogate != 0 ) && ( c < 0xd800 || c >= 0xdc00 ) )
+ if ((nSurrogate != 0) && (c < 0xd800 || c >= 0xdc00))
{
- OSL_ENSURE( nSurrogate != 0, "left-over Unicode surrogate" );
+ OSL_ENSURE(nSurrogate != 0, "left-over Unicode surrogate");
nSurrogate = 0;
bRet = false;
}
@@ -528,7 +523,7 @@ void SaxWriterHelper::insertIndentation(sal_uInt32 m_nLevel)
mp_Sequence[nCurrentPos] = LINEFEED;
nLastLineFeedPos = nCurrentPos;
nCurrentPos++;
- memset( &(mp_Sequence[nCurrentPos]) , 32 , m_nLevel );
+ memset(&(mp_Sequence[nCurrentPos]), 32, m_nLevel);
nCurrentPos += m_nLevel;
if (nCurrentPos == SEQUENCESIZE)
nCurrentPos = writeSequence();
@@ -538,7 +533,7 @@ void SaxWriterHelper::insertIndentation(sal_uInt32 m_nLevel)
sal_uInt32 nCount(m_nLevel + 1);
std::unique_ptr<sal_Int8[]> pBytes(new sal_Int8[nCount]);
pBytes[0] = LINEFEED;
- memset( &(pBytes[1]), 32, m_nLevel );
+ memset(&(pBytes[1]), 32, m_nLevel);
AddBytes(mp_Sequence, nCurrentPos, pBytes.get(), nCount);
pBytes.reset();
nLastLineFeedPos = nCurrentPos - nCount;
@@ -556,31 +551,26 @@ void SaxWriterHelper::insertIndentation(sal_uInt32 m_nLevel)
}
}
-bool SaxWriterHelper::writeString( const OUString& rWriteOutString,
- bool bDoNormalization,
- bool bNormalizeWhitespace )
+bool SaxWriterHelper::writeString(const OUString& rWriteOutString, bool bDoNormalization,
+ bool bNormalizeWhitespace)
{
FinishStartElement();
- return convertToXML(rWriteOutString.getStr(),
- rWriteOutString.getLength(),
- bDoNormalization,
- bNormalizeWhitespace,
- mp_Sequence,
- nCurrentPos);
+ return convertToXML(rWriteOutString.getStr(), rWriteOutString.getLength(), bDoNormalization,
+ bNormalizeWhitespace, mp_Sequence, nCurrentPos);
}
void SaxWriterHelper::startDocument()
{
const char pc[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
- const int nLen = strlen( pc );
+ const int nLen = strlen(pc);
if ((nCurrentPos + nLen) <= SEQUENCESIZE)
{
- memcpy( mp_Sequence, pc , nLen );
+ memcpy(mp_Sequence, pc, nLen);
nCurrentPos += nLen;
}
else
{
- AddBytes(mp_Sequence, nCurrentPos, reinterpret_cast<sal_Int8 const *>(pc), nLen);
+ AddBytes(mp_Sequence, nCurrentPos, reinterpret_cast<sal_Int8 const*>(pc), nLen);
}
OSL_ENSURE(nCurrentPos <= SEQUENCESIZE, "not reset current position");
if (nCurrentPos == SEQUENCESIZE)
@@ -592,16 +582,13 @@ void SaxWriterHelper::startDocument()
}
#ifndef NDEBUG
-bool inrange(sal_Unicode c, sal_Unicode start, sal_Unicode end)
-{
- return c >= start && c <= end;
-}
+bool inrange(sal_Unicode c, sal_Unicode start, sal_Unicode end) { return c >= start && c <= end; }
#endif
void CheckValidName(OUString const& rName)
{
#ifdef NDEBUG
- (void) rName;
+ (void)rName;
#else
assert(!rName.isEmpty());
bool hasColon(false);
@@ -615,14 +602,14 @@ void CheckValidName(OUString const& rName)
assert(!hasColon && "only one colon allowed");
hasColon = true;
}
- else if (!rtl::isAsciiAlphanumeric(c) && c != '_' && c != '-' && c != '.' &&
- !inrange(c, 0x00C0, 0x00D6) && !inrange(c, 0x00D8, 0x00F6) &&
- !inrange(c, 0x00F8, 0x02FF) && !inrange(c, 0x0370, 0x037D) &&
- !inrange(c, 0x037F, 0x1FFF) && !inrange(c, 0x200C, 0x200D) &&
- !inrange(c, 0x2070, 0x218F) && !inrange(c, 0x2C00, 0x2FEF) &&
- !inrange(c, 0x3001, 0xD7FF) && !inrange(c, 0xF900, 0xFDCF) &&
- !inrange(c, 0xFDF0, 0xFFFD) && c != 0x00B7 &&
- !inrange(c, 0x0300, 0x036F) && !inrange(c, 0x203F, 0x2040))
+ else if (!rtl::isAsciiAlphanumeric(c) && c != '_' && c != '-' && c != '.'
+ && !inrange(c, 0x00C0, 0x00D6) && !inrange(c, 0x00D8, 0x00F6)
+ && !inrange(c, 0x00F8, 0x02FF) && !inrange(c, 0x0370, 0x037D)
+ && !inrange(c, 0x037F, 0x1FFF) && !inrange(c, 0x200C, 0x200D)
+ && !inrange(c, 0x2070, 0x218F) && !inrange(c, 0x2C00, 0x2FEF)
+ && !inrange(c, 0x3001, 0xD7FF) && !inrange(c, 0xF900, 0xFDCF)
+ && !inrange(c, 0xFDF0, 0xFFFD) && c != 0x00B7 && !inrange(c, 0x0300, 0x036F)
+ && !inrange(c, 0x203F, 0x2040))
{
// https://www.w3.org/TR/xml11/#NT-NameChar
// (currently we don't warn about invalid start chars)
@@ -633,7 +620,8 @@ void CheckValidName(OUString const& rName)
#endif
}
-SaxInvalidCharacterError SaxWriterHelper::startElement(const OUString& rName, const Reference< XAttributeList >& xAttribs)
+SaxInvalidCharacterError SaxWriterHelper::startElement(const OUString& rName,
+ const Reference<XAttributeList>& xAttribs)
{
FinishStartElement();
@@ -653,7 +641,7 @@ SaxInvalidCharacterError SaxWriterHelper::startElement(const OUString& rName, co
eRet = SAX_ERROR;
sal_Int16 nAttribCount = xAttribs.is() ? xAttribs->getLength() : 0;
- for(sal_Int16 i = 0 ; i < nAttribCount ; i++ )
+ for (sal_Int16 i = 0; i < nAttribCount; i++)
{
mp_Sequence[nCurrentPos] = ' ';
nCurrentPos++;
@@ -679,8 +667,7 @@ SaxInvalidCharacterError SaxWriterHelper::startElement(const OUString& rName, co
if (nCurrentPos == SEQUENCESIZE)
nCurrentPos = writeSequence();
- if (!writeString(xAttribs->getValueByIndex( i ), true, true) &&
- eRet != SAX_ERROR)
+ if (!writeString(xAttribs->getValueByIndex(i), true, true) && eRet != SAX_ERROR)
eRet = SAX_WARNING;
mp_Sequence[nCurrentPos] = '"';
@@ -689,9 +676,9 @@ SaxInvalidCharacterError SaxWriterHelper::startElement(const OUString& rName, co
nCurrentPos = writeSequence();
}
- m_bStartElementFinished = false; // because the '>' character is not added,
- // because it is possible, that the "/>"
- // characters have to add
+ m_bStartElementFinished = false; // because the '>' character is not added,
+ // because it is possible, that the "/>"
+ // characters have to add
return eRet;
}
@@ -728,7 +715,7 @@ bool SaxWriterHelper::endElement(const OUString& rName)
nCurrentPos = writeSequence();
CheckValidName(rName);
- bool bRet(writeString( rName, false, false));
+ bool bRet(writeString(rName, false, false));
mp_Sequence[nCurrentPos] = '>';
nCurrentPos++;
@@ -773,14 +760,14 @@ bool SaxWriterHelper::processingInstruction(const OUString& rTarget, const OUStr
if (nCurrentPos == SEQUENCESIZE)
nCurrentPos = writeSequence();
- bool bRet(writeString( rTarget, false, false ));
+ bool bRet(writeString(rTarget, false, false));
mp_Sequence[nCurrentPos] = ' ';
nCurrentPos++;
if (nCurrentPos == SEQUENCESIZE)
nCurrentPos = writeSequence();
- if (!writeString( rData, false, false ))
+ if (!writeString(rData, false, false))
bRet = false;
mp_Sequence[nCurrentPos] = '?';
@@ -800,11 +787,11 @@ void SaxWriterHelper::startCDATA()
FinishStartElement();
if ((nCurrentPos + 9) <= SEQUENCESIZE)
{
- memcpy( &(mp_Sequence[nCurrentPos]), "<![CDATA[" , 9 );
+ memcpy(&(mp_Sequence[nCurrentPos]), "<![CDATA[", 9);
nCurrentPos += 9;
}
else
- AddBytes(mp_Sequence, nCurrentPos, reinterpret_cast<sal_Int8 const *>("<![CDATA["), 9);
+ AddBytes(mp_Sequence, nCurrentPos, reinterpret_cast<sal_Int8 const*>("<![CDATA["), 9);
if (nCurrentPos == SEQUENCESIZE)
nCurrentPos = writeSequence();
}
@@ -814,11 +801,11 @@ void SaxWriterHelper::endCDATA()
FinishStartElement();
if ((nCurrentPos + 3) <= SEQUENCESIZE)
{
- memcpy( &(mp_Sequence[nCurrentPos]), "]]>" , 3 );
+ memcpy(&(mp_Sequence[nCurrentPos]), "]]>", 3);
nCurrentPos += 3;
}
else
- AddBytes(mp_Sequence, nCurrentPos, reinterpret_cast<sal_Int8 const *>("]]>"), 3);
+ AddBytes(mp_Sequence, nCurrentPos, reinterpret_cast<sal_Int8 const*>("]]>"), 3);
if (nCurrentPos == SEQUENCESIZE)
nCurrentPos = writeSequence();
}
@@ -843,7 +830,7 @@ bool SaxWriterHelper::comment(const OUString& rComment)
if (nCurrentPos == SEQUENCESIZE)
nCurrentPos = writeSequence();
- bool bRet(writeString( rComment, false, false));
+ bool bRet(writeString(rComment, false, false));
mp_Sequence[nCurrentPos] = '-';
nCurrentPos++;
@@ -861,71 +848,69 @@ bool SaxWriterHelper::comment(const OUString& rComment)
return bRet;
}
-sal_Int32 calcXMLByteLength( const OUString& rStr,
- bool bDoNormalization,
- bool bNormalizeWhitespace )
+sal_Int32 calcXMLByteLength(const OUString& rStr, bool bDoNormalization, bool bNormalizeWhitespace)
{
sal_Int32 nOutputLength = 0;
sal_uInt32 nSurrogate = 0;
- const sal_Unicode *pStr = rStr.getStr();
+ const sal_Unicode* pStr = rStr.getStr();
sal_Int32 nStrLen = rStr.getLength();
- for( sal_Int32 i = 0 ; i < nStrLen ; i++ )
+ for (sal_Int32 i = 0; i < nStrLen; i++)
{
sal_uInt16 c = pStr[i];
- if( !IsInvalidChar(c) && (c >= 0x0001) && (c <= 0x007F) )
+ if (!IsInvalidChar(c) && (c >= 0x0001) && (c <= 0x007F))
{
- if( bDoNormalization )
+ if (bDoNormalization)
{
- switch( c )
+ switch (c)
{
- case '&': // resemble to &amp;
- nOutputLength +=5;
- break;
- case '<': // &lt;
- case '>': // &gt;
- nOutputLength +=4;
- break;
- case '\'': // &apos;
- case '"': // &quot;
- case 13: // &#x0d;
- nOutputLength += 6;
- break;
-
- case 10: // &#x0a;
- case 9: // &#x09;
- if( bNormalizeWhitespace )
- {
+ case '&': // resemble to &amp;
+ nOutputLength += 5;
+ break;
+ case '<': // &lt;
+ case '>': // &gt;
+ nOutputLength += 4;
+ break;
+ case '\'': // &apos;
+ case '"': // &quot;
+ case 13: // &#x0d;
nOutputLength += 6;
- }
- else
- {
- nOutputLength ++;
- }
- break;
- default:
- nOutputLength ++;
+ break;
+
+ case 10: // &#x0a;
+ case 9: // &#x09;
+ if (bNormalizeWhitespace)
+ {
+ nOutputLength += 6;
+ }
+ else
+ {
+ nOutputLength++;
+ }
+ break;
+ default:
+ nOutputLength++;
}
}
else
{
- nOutputLength ++;
+ nOutputLength++;
}
}
- else if( c >= 0xd800 && c < 0xdc00 )
+ else if (c >= 0xd800 && c < 0xdc00)
{
// save surrogate
- nSurrogate = ( ( c & 0x03ff ) + 0x0040 );
+ nSurrogate = ((c & 0x03ff) + 0x0040);
}
- else if( c >= 0xdc00 && c < 0xe000 )
+ else if (c >= 0xdc00 && c < 0xe000)
{
// 2. surrogate: write as UTF-8 (if range is OK
- nSurrogate = ( nSurrogate << 10 ) | ( c & 0x03ff );
- if( rtl::isUnicodeScalarValue(nSurrogate) && nSurrogate >= 0x00010000 )
+ nSurrogate = (nSurrogate << 10) | (c & 0x03ff);
+ if (rtl::isUnicodeScalarValue(nSurrogate) && nSurrogate >= 0x00010000)
nOutputLength += 4;
nSurrogate = 0;
}
- else if( c > 0x07FF )
+ else if (c > 0x07FF)
{
nOutputLength += 3;
}
@@ -935,7 +920,7 @@ sal_Int32 calcXMLByteLength( const OUString& rStr,
}
// surrogate processing
- if( ( nSurrogate != 0 ) && ( c < 0xd800 || c >= 0xdc00 ) )
+ if ((nSurrogate != 0) && (c < 0xd800 || c >= 0xdc00))
nSurrogate = 0;
}
@@ -944,24 +929,22 @@ sal_Int32 calcXMLByteLength( const OUString& rStr,
/** returns position of first ascii 10 within the string, -1 when no 10 in string.
*/
-sal_Int32 getFirstLineBreak( const OUString & str ) throw ()
+sal_Int32 getFirstLineBreak(const OUString& str) throw()
{
- const sal_Unicode *pSource = str.getStr();
- sal_Int32 nLen = str.getLength();
+ const sal_Unicode* pSource = str.getStr();
+ sal_Int32 nLen = str.getLength();
- for( int n = 0; n < nLen ; n ++ )
+ for (int n = 0; n < nLen; n++)
{
- if( LINEFEED == pSource[n] ) {
+ if (LINEFEED == pSource[n])
+ {
return n;
}
}
return -1;
}
-class SAXWriter :
- public WeakImplHelper<
- XWriter,
- XServiceInfo >
+class SAXWriter : public WeakImplHelper<XWriter, XServiceInfo>
{
public:
SAXWriter()
@@ -974,17 +957,17 @@ public:
}
public: // XActiveDataSource
- virtual void SAL_CALL setOutputStream(const Reference< XOutputStream > & aStream) override
+ virtual void SAL_CALL setOutputStream(const Reference<XOutputStream>& aStream) override
{
try
{
// temporary: set same stream again to clear buffer
- if ( m_out == aStream && m_pSaxWriterHelper && m_bDocStarted )
+ if (m_out == aStream && m_pSaxWriterHelper && m_bDocStarted)
m_pSaxWriterHelper->clearBuffer();
else
{
m_out = aStream;
- m_pSaxWriterHelper.reset( new SaxWriterHelper(m_out) );
+ m_pSaxWriterHelper.reset(new SaxWriterHelper(m_out));
m_bDocStarted = false;
m_nLevel = 0;
m_bIsCDATA = false;
@@ -993,15 +976,10 @@ public: // XActiveDataSource
catch (const SAXException& e)
{
throw css::lang::WrappedTargetRuntimeException(
- e.Message,
- static_cast < OWeakObject * > ( this ),
- e.WrappedException);
+ e.Message, static_cast<OWeakObject*>(this), e.WrappedException);
}
}
- virtual Reference< XOutputStream > SAL_CALL getOutputStream() override
- {
- return m_out;
- }
+ virtual Reference<XOutputStream> SAL_CALL getOutputStream() override { return m_out; }
public: // XDocumentHandler
virtual void SAL_CALL startDocument() override;
@@ -1009,7 +987,7 @@ public: // XDocumentHandler
virtual void SAL_CALL endDocument() override;
virtual void SAL_CALL startElement(const OUString& aName,
- const Reference< XAttributeList > & xAttribs) override;
+ const Reference<XAttributeList>& xAttribs) override;
virtual void SAL_CALL endElement(const OUString& aName) override;
@@ -1018,10 +996,10 @@ public: // XDocumentHandler
virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
virtual void SAL_CALL processingInstruction(const OUString& aTarget,
const OUString& aData) override;
- virtual void SAL_CALL setDocumentLocator(const Reference< XLocator > & xLocator) override;
+ virtual void SAL_CALL setDocumentLocator(const Reference<XLocator>& xLocator) override;
virtual void SAL_CALL setCustomEntityNames(
- const ::css::uno::Sequence<::css::beans::Pair<::rtl::OUString, ::rtl::OUString>>& replacements)
- override;
+ const ::css::uno::Sequence<::css::beans::Pair<::rtl::OUString, ::rtl::OUString>>&
+ replacements) override;
public: // XExtendedDocumentHandler
virtual void SAL_CALL startCDATA() override;
@@ -1031,15 +1009,15 @@ public: // XExtendedDocumentHandler
virtual void SAL_CALL allowLineBreak() override;
public: // XServiceInfo
- OUString SAL_CALL getImplementationName() override;
- Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
- sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+ OUString SAL_CALL getImplementationName() override;
+ Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+ sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
private:
- sal_Int32 getIndentPrefixLength( sal_Int32 nFirstLineBreakOccurrence ) throw();
+ sal_Int32 getIndentPrefixLength(sal_Int32 nFirstLineBreakOccurrence) throw();
- Reference< XOutputStream > m_out;
- std::unique_ptr<SaxWriterHelper> m_pSaxWriterHelper;
+ Reference<XOutputStream> m_out;
+ std::unique_ptr<SaxWriterHelper> m_pSaxWriterHelper;
// Status information
bool m_bDocStarted : 1;
@@ -1049,14 +1027,15 @@ private:
sal_Int32 m_nLevel;
};
-sal_Int32 SAXWriter::getIndentPrefixLength( sal_Int32 nFirstLineBreakOccurrence ) throw()
+sal_Int32 SAXWriter::getIndentPrefixLength(sal_Int32 nFirstLineBreakOccurrence) throw()
{
- sal_Int32 nLength =-1;
+ sal_Int32 nLength = -1;
if (m_pSaxWriterHelper)
{
- if ( m_bForceLineBreak ||
- (m_bAllowLineBreak &&
- ((nFirstLineBreakOccurrence + m_pSaxWriterHelper->GetLastColumnCount()) > MAXCOLUMNCOUNT)) )
+ if (m_bForceLineBreak
+ || (m_bAllowLineBreak
+ && ((nFirstLineBreakOccurrence + m_pSaxWriterHelper->GetLastColumnCount())
+ > MAXCOLUMNCOUNT)))
nLength = m_nLevel;
}
m_bForceLineBreak = false;
@@ -1064,16 +1043,10 @@ sal_Int32 SAXWriter::getIndentPrefixLength( sal_Int32 nFirstLineBreakOccurrence
return nLength;
}
-bool isFirstCharWhitespace( const sal_Unicode *p ) throw()
-{
- return *p == ' ';
-}
+bool isFirstCharWhitespace(const sal_Unicode* p) throw() { return *p == ' '; }
// XServiceInfo
-OUString SAXWriter::getImplementationName()
-{
- return "com.sun.star.extensions.xml.sax.Writer";
-}
+OUString SAXWriter::getImplementationName() { return "com.sun.star.extensions.xml.sax.Writer"; }
// XServiceInfo
sal_Bool SAXWriter::supportsService(const OUString& ServiceName)
@@ -1082,62 +1055,57 @@ sal_Bool SAXWriter::supportsService(const OUString& ServiceName)
}
// XServiceInfo
-Sequence< OUString > SAXWriter::getSupportedServiceNames()
+Sequence<OUString> SAXWriter::getSupportedServiceNames()
{
return { "com.sun.star.xml.sax.Writer" };
}
void SAXWriter::startDocument()
{
- if( m_bDocStarted || ! m_out.is() || !m_pSaxWriterHelper ) {
+ if (m_bDocStarted || !m_out.is() || !m_pSaxWriterHelper)
+ {
throw SAXException();
}
m_bDocStarted = true;
m_pSaxWriterHelper->startDocument();
}
-
void SAXWriter::endDocument()
{
- if( ! m_bDocStarted )
+ if (!m_bDocStarted)
{
- throw SAXException(
- "endDocument called before startDocument",
- Reference< XInterface >() , Any() );
+ throw SAXException("endDocument called before startDocument", Reference<XInterface>(),
+ Any());
}
- if( m_nLevel ) {
- throw SAXException(
- "unexpected end of document",
- Reference< XInterface >() , Any() );
+ if (m_nLevel)
+ {
+ throw SAXException("unexpected end of document", Reference<XInterface>(), Any());
}
m_pSaxWriterHelper->endDocument();
try
{
m_out->closeOutput();
}
- catch (const IOException &)
+ catch (const IOException&)
{
css::uno::Any anyEx = cppu::getCaughtException();
- throw SAXException(
- "IO exception during closing the IO Stream",
- Reference< XInterface > (),
- anyEx );
+ throw SAXException("IO exception during closing the IO Stream", Reference<XInterface>(),
+ anyEx);
}
}
-
-void SAXWriter::startElement(const OUString& aName, const Reference< XAttributeList >& xAttribs)
+void SAXWriter::startElement(const OUString& aName, const Reference<XAttributeList>& xAttribs)
{
- if( ! m_bDocStarted )
+ if (!m_bDocStarted)
{
SAXException except;
except.Message = "startElement called before startDocument";
throw except;
}
- if( m_bIsCDATA )
+ if (m_bIsCDATA)
{
SAXException except;
- except.Message = "startElement call not allowed with CDATA sections";
+ except.Message = "startElement call not allowed with CDATA sections";
throw except;
}
@@ -1146,34 +1114,35 @@ void SAXWriter::startElement(const OUString& aName, const Reference< XAttributeL
{
sal_Int32 nAttribCount = xAttribs.is() ? xAttribs->getLength() : 0;
- nLength ++; // "<"
- nLength += calcXMLByteLength( aName, false, false ); // the tag name
+ nLength++; // "<"
+ nLength += calcXMLByteLength(aName, false, false); // the tag name
sal_Int16 n;
- for( n = 0 ; n < static_cast<sal_Int16>(nAttribCount) ; n ++ ) {
- nLength ++; // " "
- OUString tmp = xAttribs->getNameByIndex( n );
+ for (n = 0; n < static_cast<sal_Int16>(nAttribCount); n++)
+ {
+ nLength++; // " "
+ OUString tmp = xAttribs->getNameByIndex(n);
- nLength += calcXMLByteLength( tmp, false, false );
+ nLength += calcXMLByteLength(tmp, false, false);
nLength += 2; // ="
- tmp = xAttribs->getValueByIndex( n );
+ tmp = xAttribs->getValueByIndex(n);
- nLength += calcXMLByteLength( tmp, true, true );
+ nLength += calcXMLByteLength(tmp, true, true);
nLength += 1; // "
}
- nLength ++; // '>'
+ nLength++; // '>'
}
// Is there a new indentation necessary ?
- sal_Int32 nPrefix(getIndentPrefixLength( nLength ));
+ sal_Int32 nPrefix(getIndentPrefixLength(nLength));
// write into sequence
- if( nPrefix >= 0 )
- m_pSaxWriterHelper->insertIndentation( nPrefix );
+ if (nPrefix >= 0)
+ m_pSaxWriterHelper->insertIndentation(nPrefix);
SaxInvalidCharacterError eRet(m_pSaxWriterHelper->startElement(aName, xAttribs));
@@ -1195,12 +1164,14 @@ void SAXWriter::startElement(const OUString& aName, const Reference< XAttributeL
void SAXWriter::endElement(const OUString& aName)
{
- if( ! m_bDocStarted ) {
- throw SAXException ();
+ if (!m_bDocStarted)
+ {
+ throw SAXException();
}
- m_nLevel --;
+ m_nLevel--;
- if( m_nLevel < 0 ) {
+ if (m_nLevel < 0)
+ {
throw SAXException();
}
bool bRet(true);
@@ -1213,18 +1184,18 @@ void SAXWriter::endElement(const OUString& aName)
m_pSaxWriterHelper->m_DebugStartedElements.pop();
#endif
- if( m_pSaxWriterHelper->FinishEmptyElement() )
+ if (m_pSaxWriterHelper->FinishEmptyElement())
m_bForceLineBreak = false;
else
{
// only ascii chars allowed
sal_Int32 nLength(0);
if (m_bAllowLineBreak)
- nLength = 3 + calcXMLByteLength( aName, false, false );
- sal_Int32 nPrefix = getIndentPrefixLength( nLength );
+ nLength = 3 + calcXMLByteLength(aName, false, false);
+ sal_Int32 nPrefix = getIndentPrefixLength(nLength);
- if( nPrefix >= 0 )
- m_pSaxWriterHelper->insertIndentation( nPrefix );
+ if (nPrefix >= 0)
+ m_pSaxWriterHelper->insertIndentation(nPrefix);
bRet = m_pSaxWriterHelper->endElement(aName);
}
@@ -1239,7 +1210,7 @@ void SAXWriter::endElement(const OUString& aName)
void SAXWriter::characters(const OUString& aChars)
{
- if( ! m_bDocStarted )
+ if (!m_bDocStarted)
{
SAXException except;
except.Message = "characters method called before startDocument";
@@ -1247,10 +1218,10 @@ void SAXWriter::characters(const OUString& aChars)
}
bool bThrowException(false);
- if( !aChars.isEmpty() )
+ if (!aChars.isEmpty())
{
- if( m_bIsCDATA )
- bThrowException = !m_pSaxWriterHelper->writeString( aChars, false, false );
+ if (m_bIsCDATA)
+ bThrowException = !m_pSaxWriterHelper->writeString(aChars, false, false);
else
{
// Note : nFirstLineBreakOccurrence is not exact, because we don't know, how
@@ -1260,24 +1231,24 @@ void SAXWriter::characters(const OUString& aChars)
sal_Int32 nIndentPrefix(-1);
if (m_bAllowLineBreak)
{
- sal_Int32 nFirstLineBreakOccurrence = getFirstLineBreak( aChars );
+ sal_Int32 nFirstLineBreakOccurrence = getFirstLineBreak(aChars);
- nLength = calcXMLByteLength( aChars, ! m_bIsCDATA , false );
+ nLength = calcXMLByteLength(aChars, !m_bIsCDATA, false);
nIndentPrefix = getIndentPrefixLength(
- nFirstLineBreakOccurrence >= 0 ? nFirstLineBreakOccurrence : nLength );
+ nFirstLineBreakOccurrence >= 0 ? nFirstLineBreakOccurrence : nLength);
}
else
nIndentPrefix = getIndentPrefixLength(nLength);
// insert indentation
- if( nIndentPrefix >= 0 )
+ if (nIndentPrefix >= 0)
{
- if( isFirstCharWhitespace( aChars.getStr() ) )
- m_pSaxWriterHelper->insertIndentation( nIndentPrefix - 1 );
+ if (isFirstCharWhitespace(aChars.getStr()))
+ m_pSaxWriterHelper->insertIndentation(nIndentPrefix - 1);
else
- m_pSaxWriterHelper->insertIndentation( nIndentPrefix );
+ m_pSaxWriterHelper->insertIndentation(nIndentPrefix);
}
- bThrowException = !m_pSaxWriterHelper->writeString(aChars, true , false);
+ bThrowException = !m_pSaxWriterHelper->writeString(aChars, true, false);
}
}
if (bThrowException)
@@ -1288,12 +1259,11 @@ void SAXWriter::characters(const OUString& aChars)
}
}
-
void SAXWriter::ignorableWhitespace(const OUString&)
{
- if( ! m_bDocStarted )
+ if (!m_bDocStarted)
{
- throw SAXException ();
+ throw SAXException();
}
m_bForceLineBreak = true;
@@ -1301,7 +1271,7 @@ void SAXWriter::ignorableWhitespace(const OUString&)
void SAXWriter::processingInstruction(const OUString& aTarget, const OUString& aData)
{
- if( ! m_bDocStarted || m_bIsCDATA )
+ if (!m_bDocStarted || m_bIsCDATA)
{
throw SAXException();
}
@@ -1309,20 +1279,20 @@ void SAXWriter::processingInstruction(const OUString& aTarget, const OUString& a
sal_Int32 nLength(0);
if (m_bAllowLineBreak)
{
- nLength = 2; // "<?"
- nLength += calcXMLByteLength( aTarget, false, false );
+ nLength = 2; // "<?"
+ nLength += calcXMLByteLength(aTarget, false, false);
- nLength += 1; // " "
+ nLength += 1; // " "
- nLength += calcXMLByteLength( aData, false, false );
+ nLength += calcXMLByteLength(aData, false, false);
nLength += 2; // "?>"
}
- sal_Int32 nPrefix = getIndentPrefixLength( nLength );
+ sal_Int32 nPrefix = getIndentPrefixLength(nLength);
- if( nPrefix >= 0 )
- m_pSaxWriterHelper->insertIndentation( nPrefix );
+ if (nPrefix >= 0)
+ m_pSaxWriterHelper->insertIndentation(nPrefix);
if (!m_pSaxWriterHelper->processingInstruction(aTarget, aData))
{
@@ -1332,11 +1302,7 @@ void SAXWriter::processingInstruction(const OUString& aTarget, const OUString& a
}
}
-
-void SAXWriter::setDocumentLocator(const Reference< XLocator >&)
-{
-
-}
+void SAXWriter::setDocumentLocator(const Reference<XLocator>&) {}
void SAXWriter::setCustomEntityNames(
const ::css::uno::Sequence<::css::beans::Pair<::rtl::OUString, ::rtl::OUString>>& replacements)
@@ -1346,14 +1312,14 @@ void SAXWriter::setCustomEntityNames(
void SAXWriter::startCDATA()
{
- if( ! m_bDocStarted || m_bIsCDATA)
+ if (!m_bDocStarted || m_bIsCDATA)
{
- throw SAXException ();
+ throw SAXException();
}
- sal_Int32 nPrefix = getIndentPrefixLength( 9 );
- if( nPrefix >= 0 )
- m_pSaxWriterHelper->insertIndentation( nPrefix );
+ sal_Int32 nPrefix = getIndentPrefixLength(9);
+ if (nPrefix >= 0)
+ m_pSaxWriterHelper->insertIndentation(nPrefix);
m_pSaxWriterHelper->startCDATA();
@@ -1362,26 +1328,25 @@ void SAXWriter::startCDATA()
void SAXWriter::endCDATA()
{
- if( ! m_bDocStarted || ! m_bIsCDATA)
+ if (!m_bDocStarted || !m_bIsCDATA)
{
SAXException except;
except.Message = "endCDATA was called without startCDATA";
throw except;
}
- sal_Int32 nPrefix = getIndentPrefixLength( 3 );
- if( nPrefix >= 0 )
- m_pSaxWriterHelper->insertIndentation( nPrefix );
+ sal_Int32 nPrefix = getIndentPrefixLength(3);
+ if (nPrefix >= 0)
+ m_pSaxWriterHelper->insertIndentation(nPrefix);
m_pSaxWriterHelper->endCDATA();
m_bIsCDATA = false;
}
-
void SAXWriter::comment(const OUString& sComment)
{
- if( ! m_bDocStarted || m_bIsCDATA )
+ if (!m_bDocStarted || m_bIsCDATA)
{
throw SAXException();
}
@@ -1390,14 +1355,14 @@ void SAXWriter::comment(const OUString& sComment)
if (m_bAllowLineBreak)
{
nLength = 4; // "<!--"
- nLength += calcXMLByteLength( sComment, false, false);
+ nLength += calcXMLByteLength(sComment, false, false);
nLength += 3;
}
- sal_Int32 nPrefix = getIndentPrefixLength( nLength );
- if( nPrefix >= 0 )
- m_pSaxWriterHelper->insertIndentation( nPrefix );
+ sal_Int32 nPrefix = getIndentPrefixLength(nLength);
+ if (nPrefix >= 0)
+ m_pSaxWriterHelper->insertIndentation(nPrefix);
if (!m_pSaxWriterHelper->comment(sComment))
{
@@ -1407,10 +1372,10 @@ void SAXWriter::comment(const OUString& sComment)
}
}
-
-void SAXWriter::allowLineBreak( )
+void SAXWriter::allowLineBreak()
{
- if( ! m_bDocStarted || m_bAllowLineBreak ) {
+ if (!m_bDocStarted || m_bAllowLineBreak)
+ {
throw SAXException();
}
@@ -1419,28 +1384,27 @@ void SAXWriter::allowLineBreak( )
void SAXWriter::unknown(const OUString& sString)
{
-
- if( ! m_bDocStarted )
+ if (!m_bDocStarted)
{
- throw SAXException ();
+ throw SAXException();
}
- if( m_bIsCDATA )
+ if (m_bIsCDATA)
{
throw SAXException();
}
- if( sString.startsWith( "<?xml" ) )
+ if (sString.startsWith("<?xml"))
return;
sal_Int32 nLength(0);
if (m_bAllowLineBreak)
- nLength = calcXMLByteLength( sString, false, false );
+ nLength = calcXMLByteLength(sString, false, false);
- sal_Int32 nPrefix = getIndentPrefixLength( nLength );
- if( nPrefix >= 0 )
- m_pSaxWriterHelper->insertIndentation( nPrefix );
+ sal_Int32 nPrefix = getIndentPrefixLength(nLength);
+ if (nPrefix >= 0)
+ m_pSaxWriterHelper->insertIndentation(nPrefix);
- if (!m_pSaxWriterHelper->writeString( sString, false, false))
+ if (!m_pSaxWriterHelper->writeString(sString, false, false))
{
SAXException except;
except.Message = "Invalid character during XML-Export";
@@ -1450,10 +1414,9 @@ void SAXWriter::unknown(const OUString& sString)
} // namespace
-extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
-com_sun_star_extensions_xml_sax_Writer_get_implementation(
- css::uno::XComponentContext *,
- css::uno::Sequence<css::uno::Any> const &)
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+com_sun_star_extensions_xml_sax_Writer_get_implementation(css::uno::XComponentContext*,
+ css::uno::Sequence<css::uno::Any> const&)
{
return cppu::acquire(new SAXWriter);
}