7e667da
From 49f2a69fa7d8eaa23d77519ac29748f4dc3e4c5a Mon Sep 17 00:00:00 2001
7e667da
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
7e667da
Date: Wed, 28 Nov 2012 11:15:56 +0000
7e667da
Subject: [PATCH] bigendian utext mixup triggering regression test failure
7e667da
7e667da
text takes a pointer to a sal_uInt8 buffer but
7e667da
utext takes a pointer to a sal_Unicode buffer
7e667da
7e667da
passing a sal_uInt8 sequence of e.g. "\x0D\x00" to utext only happens
7e667da
to work on little endian machines to represent 0x000D, its 0x0D00 on
7e667da
bigendian.
7e667da
7e667da
for more excitement text and utext do not share the same logic!
7e667da
Various special chars are treated different in text vs utext so
7e667da
we can't simply blindly change utext() calls to text() calls and
7e667da
get the same behaviour without reworking those.
7e667da
7e667da
So keep the text()/utext() calls as they are, but change what's
7e667da
passed to be the right thing.
7e667da
7e667da
Change-Id: I66696530c4a9482690c461146bdcf0a507b39b68
7e667da
---
7e667da
 .../source/ooxml/OOXMLFastContextHandler.cxx       | 51 +++++++++++-----------
7e667da
 1 file changed, 25 insertions(+), 26 deletions(-)
7e667da
7e667da
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
7e667da
index 920bf31..c6f03bb 100644
7e667da
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
7e667da
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
7e667da
@@ -39,19 +39,18 @@
7e667da
 #include "Handler.hxx"
7e667da
 #include "ooxmlLoggers.hxx"
7e667da
 
7e667da
-static const sal_uInt8 s0x7[] = { 0x7, 0x0 };
7e667da
-static const sal_uInt8 s0xd[] = { 0xd, 0x0 };
7e667da
-static const sal_uInt8 sCR[] = { 0xd, 0x0 };
7e667da
-static const sal_uInt8 sFtnEdnRef[] = { 0x2, 0x0 };
7e667da
-static const sal_uInt8 sFtnEdnSep[] = { 0x3, 0x0 };
7e667da
-static const sal_uInt8 sFtnEdnCont[] = { 0x4, 0x0 };
7e667da
-static const sal_uInt8 sTab[] = { 0x9, 0x0 };
7e667da
-static const sal_uInt8 sPgNum[] = { 0x0, 0x0 };
7e667da
-static const sal_uInt8 sFieldStart[] = { 0x13  };
7e667da
-static const sal_uInt8 sFieldSep[] = { 0x14 };
7e667da
-static const sal_uInt8 sFieldEnd[] = { 0x15 };
7e667da
-static const sal_uInt8 sNoBreakHyphen[] = { 0x1e, 0x0 };
7e667da
-static const sal_uInt8 sSoftHyphen[] = { 0x1f, 0x0 };
7e667da
+static const sal_Unicode uCR = 0xd;
7e667da
+static const sal_Unicode uFtnEdnRef = 0x2;
7e667da
+static const sal_Unicode uFtnEdnSep = 0x3;
7e667da
+static const sal_Unicode uTab = 0x9;
7e667da
+static const sal_Unicode uPgNum = 0x0;
7e667da
+static const sal_Unicode uNoBreakHyphen = 0x1e;
7e667da
+static const sal_Unicode uSoftHyphen = 0x1f;
7e667da
+
7e667da
+static const sal_uInt8 cFtnEdnCont = 0x4;
7e667da
+static const sal_uInt8 cFieldStart = 0x13;
7e667da
+static const sal_uInt8 cFieldSep = 0x14;
7e667da
+static const sal_uInt8 cFieldEnd = 0x15;
7e667da
 
7e667da
 namespace writerfilter {
7e667da
 namespace ooxml
7e667da
@@ -710,7 +709,7 @@ void OOXMLFastContextHandler::startField()
7e667da
 #endif
7e667da
     startCharacterGroup();
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->text(sFieldStart, 1);
7e667da
+        mpStream->text(&cFieldStart, 1);
7e667da
     endCharacterGroup();
7e667da
 }
7e667da
 
7e667da
@@ -721,7 +720,7 @@ void OOXMLFastContextHandler::fieldSeparator()
7e667da
 #endif
7e667da
     startCharacterGroup();
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->text(sFieldSep, 1);
7e667da
+        mpStream->text(&cFieldSep, 1);
7e667da
     endCharacterGroup();
7e667da
 }
7e667da
 
7e667da
@@ -732,7 +731,7 @@ void OOXMLFastContextHandler::endField()
7e667da
 #endif
7e667da
     startCharacterGroup();
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->text(sFieldEnd, 1);
7e667da
+        mpStream->text(&cFieldEnd, 1);
7e667da
     endCharacterGroup();
7e667da
 }
7e667da
 
7e667da
@@ -742,7 +741,7 @@ void OOXMLFastContextHandler::ftnednref()
7e667da
     debug_logger->element("contexthandler.ftnednref");
7e667da
 #endif
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->utext(sFtnEdnRef, 1);
7e667da
+        mpStream->utext((const sal_uInt8*)&uFtnEdnRef, 1);
7e667da
 }
7e667da
 
7e667da
 void OOXMLFastContextHandler::ftnednsep()
7e667da
@@ -751,7 +750,7 @@ void OOXMLFastContextHandler::ftnednsep()
7e667da
     debug_logger->element("contexthandler.ftnednsep");
7e667da
 #endif
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->utext(sFtnEdnSep, 1);
7e667da
+        mpStream->utext((const sal_uInt8*)&uFtnEdnSep, 1);
7e667da
 }
7e667da
 
7e667da
 void OOXMLFastContextHandler::ftnedncont()
7e667da
@@ -760,7 +759,7 @@ void OOXMLFastContextHandler::ftnedncont()
7e667da
     debug_logger->element("contexthandler.ftnedncont");
7e667da
 #endif
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->text(sFtnEdnCont, 1);
7e667da
+        mpStream->text(&cFtnEdnCont, 1);
7e667da
 }
7e667da
 
7e667da
 void OOXMLFastContextHandler::pgNum()
7e667da
@@ -769,7 +768,7 @@ void OOXMLFastContextHandler::pgNum()
7e667da
     debug_logger->element("contexthandler.pgNum");
7e667da
 #endif
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->utext((const sal_uInt8*)sPgNum, 1);
7e667da
+        mpStream->utext((const sal_uInt8*)&uPgNum, 1);
7e667da
 }
7e667da
 
7e667da
 void OOXMLFastContextHandler::tab()
7e667da
@@ -778,7 +777,7 @@ void OOXMLFastContextHandler::tab()
7e667da
     debug_logger->element("contexthandler.tab");
7e667da
 #endif
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->utext((const sal_uInt8*)sTab, 1);
7e667da
+        mpStream->utext((const sal_uInt8*)&uTab, 1);
7e667da
 }
7e667da
 
7e667da
 void OOXMLFastContextHandler::cr()
7e667da
@@ -787,7 +786,7 @@ void OOXMLFastContextHandler::cr()
7e667da
     debug_logger->element("contexthandler.cr");
7e667da
 #endif
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->utext((const sal_uInt8*)sCR, 1);
7e667da
+        mpStream->utext((const sal_uInt8*)&uCR, 1);
7e667da
 }
7e667da
 
7e667da
 void OOXMLFastContextHandler::noBreakHyphen()
7e667da
@@ -796,7 +795,7 @@ void OOXMLFastContextHandler::noBreakHyphen()
7e667da
     debug_logger->element("contexthandler.noBreakHyphen");
7e667da
 #endif
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->utext((const sal_uInt8*)sNoBreakHyphen, 1);
7e667da
+        mpStream->utext((const sal_uInt8*)&uNoBreakHyphen, 1);
7e667da
 }
7e667da
 
7e667da
 void OOXMLFastContextHandler::softHyphen()
7e667da
@@ -805,7 +804,7 @@ void OOXMLFastContextHandler::softHyphen()
7e667da
     debug_logger->element("contexthandler.softHyphen");
7e667da
 #endif
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->utext((const sal_uInt8*)sSoftHyphen, 1);
7e667da
+        mpStream->utext((const sal_uInt8*)&uSoftHyphen, 1);
7e667da
 }
7e667da
 
7e667da
 void OOXMLFastContextHandler::handleLastParagraphInSection()
7e667da
@@ -829,7 +828,7 @@ void OOXMLFastContextHandler::endOfParagraph()
7e667da
     if (! mpParserState->isInCharacterGroup())
7e667da
         startCharacterGroup();
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->utext((const sal_uInt8*)sCR, 1);
7e667da
+        mpStream->utext((const sal_uInt8*)&uCR, 1);
7e667da
 }
7e667da
 
7e667da
 void OOXMLFastContextHandler::startTxbxContent()
7e667da
@@ -1876,7 +1875,7 @@ void OOXMLFastContextHandlerTextTableRow::endRow()
7e667da
     startCharacterGroup();
7e667da
 
7e667da
     if (isForwardEvents())
7e667da
-        mpStream->utext(s0xd, 1);
7e667da
+        mpStream->utext((const sal_uInt8*)&uCR, 1);
7e667da
 
7e667da
     endCharacterGroup();
7e667da
     endParagraphGroup();
7e667da
-- 
7e667da
1.7.11.7
7e667da