diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-11-03 13:20:14 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-11-06 20:28:57 +0100 |
commit | cc88a2bcfddd19e90a44f1b0bc1c1ef31a86768f (patch) | |
tree | 65d79b588e733436c565146e042bb15454185c9d /sw | |
parent | b3cfb849b19dc1e40c12586bebd2b76fc41007fa (diff) |
sw: read both platform dependent binary table autoformats
The WriterSpecificAutoFormatBlock class actually writes a length
into the file that covers the offending SwFormatVertOrient item.
Put in a gross hack to read either 32-bit or 64-bit in
SwFormatVertOrient::Store depending on that length.
The length also covers another item, so we'll just hope nobody ever
changes this stuff ever again!
Change-Id: Idf2f05cc00c098571508adb849f60940966c3328
Reviewed-on: https://gerrit.libreoffice.org/44254
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/tblafmt.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 32 |
2 files changed, 32 insertions, 15 deletions
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 4c66817309de..8235c52f77dd 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -149,13 +149,13 @@ namespace }; /// Checks whether a writer-specific block exists (i.e. size is not zero) - bool WriterSpecificBlockExists(SvStream &stream) + sal_Int64 WriterSpecificBlockExists(SvStream &stream) { sal_uInt64 endOfSwBlock = 0; stream.ReadUInt64( endOfSwBlock ); // end-of-block pointing to itself indicates a zero-size block. - return endOfSwBlock != stream.Tell(); + return endOfSwBlock - stream.Tell(); } } @@ -452,10 +452,15 @@ bool SwBoxAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions, sa SetAdjust( *static_cast<SvxAdjustItem*>(pNew) ); delete pNew; - if (nVer >= AUTOFORMAT_DATA_ID_31005 && WriterSpecificBlockExists(rStream)) + if (nVer >= AUTOFORMAT_DATA_ID_31005) { - READ(m_aTextOrientation, SvxFrameDirectionItem, rVersions.m_nTextOrientationVersion); - READ(m_aVerticalAlignment, SwFormatVertOrient, rVersions.m_nVerticalAlignmentVersion); + sal_Int64 const nSize(WriterSpecificBlockExists(rStream)); + if (0 < nSize && nSize < std::numeric_limits<sal_uInt16>::max()) + { + READ(m_aTextOrientation, SvxFrameDirectionItem, rVersions.m_nTextOrientationVersion); + // HORRIBLE HACK to read both 32-bit and 64-bit "long": abuse nSize + READ(m_aVerticalAlignment, SwFormatVertOrient, /*rVersions.m_nVerticalAlignmentVersion*/ nSize); + } } READ( m_aHorJustify, SvxHorJustifyItem , rVersions.nHorJustifyVersion) diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index d03983a46fd4..76bc2b14a944 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -1265,20 +1265,32 @@ SvStream& SwFormatVertOrient::Store(SvStream &rStream, sal_uInt16 /*version*/) c return rStream; } -SfxPoolItem* SwFormatVertOrient::Create(SvStream &rStream, sal_uInt16 /*itemVersion*/) const +SfxPoolItem* SwFormatVertOrient::Create(SvStream &rStream, sal_uInt16 nVersionAbusedAsSize) const { SwTwips yPos(0); sal_Int16 orient(0); sal_Int16 relation(0); - // compatibility hack for Table Auto Format: SwTwips is "long" :( - // (this means that the file format is platform dependent) -#if SAL_TYPES_SIZEOFLONG == 8 - rStream.ReadInt64(yPos); -#else - sal_Int32 n; - rStream.ReadInt32(n); - yPos = n; -#endif + switch (nVersionAbusedAsSize) + { + // compatibility hack for Table Auto Format: SwTwips is "long" :( + // (this means that the file format is platform dependent) + case 14: + { + sal_Int64 n(0); + rStream.ReadInt64(n); + yPos = n; + } + break; + case 10: + { + sal_Int32 n(0); + rStream.ReadInt32(n); + yPos = n; + } + break; + default: + SAL_WARN("sw.core", "SwFormatVertOrient::Create: unknown size"); + } rStream.ReadInt16( orient ).ReadInt16( relation ); return new SwFormatVertOrient(yPos, orient, relation); |