summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-11-18 10:41:27 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-11-18 10:53:10 +0000
commitc80a0fcdd9a4389616e92cfeafa9d932a784ee71 (patch)
tree7152e67b54bd5dd728c938c69d3d1ee70596c453 /sw
parent0a840edcc19ad1b8bb1525717d91ce8ade0c0092 (diff)
Resolves: tdf#91916 different word 6/7 vers have ambiguous sprms
See tdf#91916, #i8726, #i42685# there is an ambiguity around certain properties as to what they mean, which appears to be a problem with different versions of the file format where properties conflict, i.e. ooo40606-2.doc, magic is a699 : 0x6f 0x4 0x0 0x71 0x4 0x0 ooo40635-1.doc, magic is a699 : 0x6f 0x4 0x0 0x71 0x4 0x0 ooo31093/SIMPCHIN.doc, magic is a699 : 0x6f 0x2 0x0 0x70 0x0 0x0 0x71 0x2 0x0 : 0x6f 0x5 0x0 0x70 0x5 0x0 ooo31093/TRADCHIN.doc, magic is a699 : 0x6f 0x1 0x0 0x70 0x0 0x0 0x71 0x1 0x0 ooo31093/JAPANESE.doc, magic is a697 : 0x6f 0x2 0x0 0x70 0x0 0x0 0x71 0x2 0x0 ooo31093/KOREAN.doc, magic is a698 : 0x6f 0x2 0x0 0x70 0x0 0x0 0x71 0x2 0x0 ooo31093-1.doc, magic is a698 : 0x6f 0x5 0x0 0x70 0x5 0x0 ooo31093-1.doc, magic is a698 : 0x6f 0x5 0x0 0x70 0x5 0x0 meanwhile... ooo27954-1.doc, magic is a5dc : 0x6f 0x1 0x81 0x71 0x2 0x4 0x0 0x74 0x2 0x20 0x0 ooo33251-1.doc, magic is a5dc : 0x6f 0x1 0x81 0x71 0x2 0x3 0x0 0x74 0x2 0x1c 0x0 --- So we have the same sprm values, but different payloads, where the a5dc versions appear to use a len argument, followed by len bytes, while the a698<->a699 versions use a 2byte argument commit c2213db9ed70c1fd546482d22e36e4029c10aa45 INTEGRATION: CWS tl28 (1.169.24); FILE MERGED 2006/10/25 13:40:41 tl 1.169.24.2: RESYNC: (1.169-1.170); FILE MERGED 2006/09/20 11:55:50 hbrinkm 1.169.24.1: #i42685# applied patch changed 0x6f and 0x70 from Read_BoldBiDiUsw to Read_FontCode for all versions. In the Word for Window 2 spec we have... 78 //sprmCMajority 80 //sprmCFBoldBi 81 //sprmCFItalicBi 82 //sprmCFtcBi 83 //sprmClidBi 84 //sprmCIcoBi 85 //sprmCHpsBi as see in GetWW2SprmDispatcher, different numbers, but the sequence starts with the same sprmCMajority as appears before 0x6f in word 6/95 I think the easiest explanation is that the CJK Word for Window 95, or whatever the product was went rogue, and did their own things with at least first three slots after sprmCMajority to do a different thing. I have no reason to think Tono was wrong with what they do in the a698<->a699 versions versions, but with magic a5dc they probably did mean sprmCFBoldBi, sprmCFItalicBi cause they have that 0x81 pattern which has significance for those types of properties. Change-Id: I44aabf7443391bae21ed5adb074780a1c929a80d
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/core/data/ww6/pass/ooo17498-1.docbin0 -> 5632 bytes
-rw-r--r--sw/qa/core/data/ww6/pass/ooo17498-2.docbin0 -> 5632 bytes
-rw-r--r--sw/qa/core/data/ww6/pass/ooo17498-3.docbin0 -> 5632 bytes
-rw-r--r--sw/qa/core/data/ww6/pass/ooo17498-4.docbin0 -> 5120 bytes
-rw-r--r--sw/qa/core/data/ww6/pass/ooo8726-1.docbin0 -> 5120 bytes
-rw-r--r--sw/source/filter/ww8/ww8par.cxx4
-rw-r--r--sw/source/filter/ww8/ww8par.hxx1
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx7
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx2
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx89
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx93
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx44
12 files changed, 174 insertions, 66 deletions
diff --git a/sw/qa/core/data/ww6/pass/ooo17498-1.doc b/sw/qa/core/data/ww6/pass/ooo17498-1.doc
new file mode 100644
index 000000000000..258c6ff63ec7
--- /dev/null
+++ b/sw/qa/core/data/ww6/pass/ooo17498-1.doc
Binary files differ
diff --git a/sw/qa/core/data/ww6/pass/ooo17498-2.doc b/sw/qa/core/data/ww6/pass/ooo17498-2.doc
new file mode 100644
index 000000000000..9955f782092e
--- /dev/null
+++ b/sw/qa/core/data/ww6/pass/ooo17498-2.doc
Binary files differ
diff --git a/sw/qa/core/data/ww6/pass/ooo17498-3.doc b/sw/qa/core/data/ww6/pass/ooo17498-3.doc
new file mode 100644
index 000000000000..c0db457ca0a9
--- /dev/null
+++ b/sw/qa/core/data/ww6/pass/ooo17498-3.doc
Binary files differ
diff --git a/sw/qa/core/data/ww6/pass/ooo17498-4.doc b/sw/qa/core/data/ww6/pass/ooo17498-4.doc
new file mode 100644
index 000000000000..be0df8195410
--- /dev/null
+++ b/sw/qa/core/data/ww6/pass/ooo17498-4.doc
Binary files differ
diff --git a/sw/qa/core/data/ww6/pass/ooo8726-1.doc b/sw/qa/core/data/ww6/pass/ooo8726-1.doc
new file mode 100644
index 000000000000..e78dab155102
--- /dev/null
+++ b/sw/qa/core/data/ww6/pass/ooo8726-1.doc
Binary files differ
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index d42e3c909b57..045cf7353279 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4977,7 +4977,7 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
RedlineFlags eMode = RedlineFlags::ShowInsert;
- m_pSprmParser = new wwSprmParser(m_pWwFib->GetFIBVersion());
+ m_pSprmParser = new wwSprmParser(*m_pWwFib);
// Set handy helper variables
m_bVer6 = (6 == m_pWwFib->m_nVersion);
@@ -6387,7 +6387,7 @@ bool SwMSDffManager::GetOLEStorageName(long nOLEId, OUString& rStorageName,
nStartCp += rReader.m_nDrawCpO;
nEndCp += rReader.m_nDrawCpO;
WW8PLCFx_Cp_FKP* pChp = rReader.m_pPlcxMan->GetChpPLCF();
- wwSprmParser aSprmParser(rReader.m_pWwFib->GetFIBVersion());
+ wwSprmParser aSprmParser(*rReader.m_pWwFib);
while (nStartCp <= nEndCp && !nPictureId)
{
if (!pChp->SeekPos( nStartCp))
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 54c9fd14e798..7d9dd965277d 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1693,6 +1693,7 @@ public: // really private, but can only be done public
void Read_BoldUsw(sal_uInt16 nId, const sal_uInt8*, short nLen);
void Read_Bidi(sal_uInt16 nId, const sal_uInt8*, short nLen);
void Read_BoldBiDiUsw(sal_uInt16 nId, const sal_uInt8*, short nLen);
+ void Read_AmbiguousSPRM(sal_uInt16 nId, const sal_uInt8*, short nLen);
void Read_SubSuper( sal_uInt16, const sal_uInt8*, short nLen );
bool ConvertSubToGraphicPlacement();
static SwFrameFormat *ContainsSingleInlineGraphic(const SwPaM &rRegion);
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index d7375533feb6..c777532778b8 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -1785,7 +1785,7 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
WW8TabBandDesc* pNewBand = new WW8TabBandDesc;
- wwSprmParser aSprmParser(m_pIo->GetFib().GetFIBVersion());
+ wwSprmParser aSprmParser(m_pIo->GetFib());
// process pPap until end of table found
do
@@ -3638,6 +3638,9 @@ void WW8RStyle::ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap)
WW8SprmIter aSprmIter(pSprms, nLen, maSprmParser);
while (const sal_uInt8* pSprm = aSprmIter.GetSprms())
{
+#ifdef DEBUGSPRMREADER
+ fprintf(stderr, "id is %x\n", aIter.GetAktId());
+#endif
pIo->ImportSprm(pSprm);
aSprmIter.advance();
}
@@ -3740,7 +3743,7 @@ void WW8RStyle::ImportGrupx(short nLen, bool bPara, bool bOdd)
WW8RStyle::WW8RStyle(WW8Fib& _rFib, SwWW8ImplReader* pI)
: WW8Style(*pI->m_pTableStream, _rFib)
- , maSprmParser(_rFib.GetFIBVersion())
+ , maSprmParser(_rFib)
, pIo(pI)
, pStStrm(pI->m_pTableStream)
, pStyRule(nullptr)
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 3f41f87415ea..5c34fe8c74aa 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1136,7 +1136,7 @@ SwNumRule* WW8ListManager::GetNumRule(size_t i)
// oeffentliche Methoden
WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
- : maSprmParser(rReader_.GetFib().GetFIBVersion()), rReader(rReader_)
+ : maSprmParser(rReader_.GetFib()), rReader(rReader_)
, rDoc(rReader.GetDoc())
, rFib(rReader.GetFib()), rSt(rSt_)
, nUniqueList(1)
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index f28b3a832d22..59112cbb4d74 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2944,6 +2944,83 @@ void SwWW8ImplReader::Read_Bidi(sal_uInt16, const sal_uInt8* pData, short nLen)
}
}
+/*
+ tdf#91916, #i8726, #i42685# there is an ambiguity
+ around certain properties as to what they mean,
+ which appears to be a problem with different versions
+ of the file format where properties conflict, i.e.
+
+ooo40606-2.doc, magic is a699
+ : 0x6f 0x4 0x0 0x71 0x4 0x0
+ooo40635-1.doc, magic is a699
+ : 0x6f 0x4 0x0 0x71 0x4 0x0
+ooo31093/SIMPCHIN.doc, magic is a699
+ : 0x6f 0x2 0x0 0x70 0x0 0x0 0x71 0x2 0x0
+ : 0x6f 0x5 0x0 0x70 0x5 0x0
+ooo31093/TRADCHIN.doc, magic is a699
+ : 0x6f 0x1 0x0 0x70 0x0 0x0 0x71 0x1 0x0
+ooo31093/JAPANESE.doc, magic is a697
+ : 0x6f 0x2 0x0 0x70 0x0 0x0 0x71 0x2 0x0
+ooo31093/KOREAN.doc, magic is a698
+ : 0x6f 0x2 0x0 0x70 0x0 0x0 0x71 0x2 0x0
+ooo31093-1.doc, magic is a698
+ : 0x6f 0x5 0x0 0x70 0x5 0x0
+ooo31093-1.doc, magic is a698
+ : 0x6f 0x5 0x0 0x70 0x5 0x0
+
+meanwhile...
+
+ooo27954-1.doc, magic is a5dc
+ : 0x6f 0x1 0x81 0x71 0x2 0x4 0x0 0x74 0x2 0x20 0x0
+
+ooo33251-1.doc, magic is a5dc
+ : 0x6f 0x1 0x81 0x71 0x2 0x3 0x0 0x74 0x2 0x1c 0x0
+
+---
+
+So we have the same sprm values, but different payloads, where
+the a5dc versions appear to use a len argument, followed by len
+bytes, while the a698<->a699 versions use a 2byte argument
+
+commit c2213db9ed70c1fd546482d22e36e4029c10aa45
+
+ INTEGRATION: CWS tl28 (1.169.24); FILE MERGED
+ 2006/10/25 13:40:41 tl 1.169.24.2: RESYNC: (1.169-1.170); FILE MERGED
+ 2006/09/20 11:55:50 hbrinkm 1.169.24.1: #i42685# applied patch
+
+changed 0x6f and 0x70 from Read_BoldBiDiUsw to Read_FontCode for all versions.
+
+In the Word for Window 2 spec we have...
+ 78 //sprmCMajority
+ 80 //sprmCFBoldBi
+ 81 //sprmCFItalicBi
+ 82 //sprmCFtcBi
+ 83 //sprmClidBi
+ 84 //sprmCIcoBi
+ 85 //sprmCHpsBi
+as see in GetWW2SprmDispatcher, different numbers, but the sequence starts with
+the same sprmCMajority as appears before 0x6f in word 6/95
+
+I think the easiest explanation is that the CJK Word for Window 95, or whatever
+the product was went rogue, and did their own things with at least first three
+slots after sprmCMajority to do a different thing. I have no reason to think Tono
+was wrong with what they do in the a698<->a699 versions versions, but with magic
+a5dc they probably did mean sprmCFBoldBi, sprmCFItalicBi cause they have that 0x81
+pattern which has significance for those types of properties.
+*/
+void SwWW8ImplReader::Read_AmbiguousSPRM(sal_uInt16 nId, const sal_uInt8* pData,
+ short nLen)
+{
+ if (m_pWwFib->m_wIdent >= 0xa697 && m_pWwFib->m_wIdent <= 0xa699)
+ {
+ Read_FontCode(nId, pData, nLen);
+ }
+ else
+ {
+ Read_BoldBiDiUsw(nId, pData, nLen);
+ }
+}
+
// Read_BoldUsw for BiDi Italic, Bold
void SwWW8ImplReader::Read_BoldBiDiUsw(sal_uInt16 nId, const sal_uInt8* pData,
short nLen)
@@ -5429,12 +5506,12 @@ const wwSprmDispatcher *GetWW6SprmDispatcher()
//percentage to grow hps short
{110, nullptr}, //"sprmCCondHyhen", chp.ysri
//ysri short
- {111, &SwWW8ImplReader::Read_FontCode}, //ww7 font
- {112, &SwWW8ImplReader::Read_FontCode}, //ww7 CJK font
- {113, &SwWW8ImplReader::Read_FontCode}, //ww7 rtl font
- {114, &SwWW8ImplReader::Read_Language}, //ww7 lid
- {115, &SwWW8ImplReader::Read_TextColor}, //ww7 rtl colour ?
- {116, &SwWW8ImplReader::Read_FontSize},
+ {111, &SwWW8ImplReader::Read_AmbiguousSPRM}, //sprmCFBoldBi or font code
+ {112, &SwWW8ImplReader::Read_AmbiguousSPRM}, //sprmCFItalicBi or font code
+ {113, &SwWW8ImplReader::Read_FontCode}, //sprmCFtcBi
+ {114, &SwWW8ImplReader::Read_Language}, //sprmClidBi
+ {115, &SwWW8ImplReader::Read_TextColor}, //sprmCIcoBi
+ {116, &SwWW8ImplReader::Read_FontSize}, //sprmCHpsBi
{117, &SwWW8ImplReader::Read_Special}, //"sprmCFSpec", chp.fSpec 1
//or 0 bit
{118, &SwWW8ImplReader::Read_Obj}, //"sprmCFObj", chp.fObj 1 or 0
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 2192aae2296b..76029777121b 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -250,7 +250,7 @@ const wwSprmSearcher *wwSprmParser::GetWW2SprmSearcher()
return &aSprmSrch;
};
-const wwSprmSearcher *wwSprmParser::GetWW6SprmSearcher()
+const wwSprmSearcher *wwSprmParser::GetWW6SprmSearcher(const WW8Fib& rFib)
{
//double lock me
// WW7- Sprms
@@ -352,12 +352,12 @@ const wwSprmSearcher *wwSprmParser::GetWW6SprmSearcher()
{108, { 0, L_VAR} }, // "sprmCMajority50" chp.fBold, chp.fItalic, ...
{109, { 2, L_FIX} }, // "sprmCHpsMul" chp.hps percentage to grow hps
{110, { 2, L_FIX} }, // "sprmCCondHyhen" chp.ysri ysri
- {111, { 2, L_FIX} }, // ww7 font
- {112, { 2, L_FIX} }, // ww7 CJK font
- {113, { 2, L_FIX} }, // ww7 rtl font
- {114, { 2, L_FIX} }, // ww7 lid
- {115, { 2, L_FIX} }, // ww7 rtl colour ?
- {116, { 2, L_FIX} }, // ww7 fontsize
+ {111, { 0, L_VAR} }, // sprmCFBoldBi or font code
+ {112, { 0, L_VAR} }, // sprmCFItalicBi or font code
+ {113, { 0, L_VAR} }, // ww7 rtl font
+ {114, { 0, L_VAR} }, // ww7 lid
+ {115, { 0, L_VAR} }, // ww7 CJK font
+ {116, { 0, L_VAR} }, // ww7 fontsize
{117, { 1, L_FIX} }, // "sprmCFSpec" chp.fSpec 1 or 0 bit
{118, { 1, L_FIX} }, // "sprmCFObj" chp.fObj 1 or 0 bit
{119, { 1, L_FIX} }, // "sprmPicBrcl" pic.brcl brcl (see PIC definition)
@@ -429,10 +429,27 @@ const wwSprmSearcher *wwSprmParser::GetWW6SprmSearcher()
{207, { 0, L_VAR} } // rtl property ?
};
+ if (rFib.m_wIdent >= 0xa697 && rFib.m_wIdent <= 0xa699)
+ {
+ //see Read_AmbiguousSPRM for this oddity
+ static wwSprmSearcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms), true);
+ return &aSprmSrch;
+ }
+
static wwSprmSearcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms));
return &aSprmSrch;
};
+void wwSprmSearcher::patchCJKVariant()
+{
+ for (sal_uInt16 nId = 111; nId <= 113; ++nId)
+ {
+ SprmInfo& amb1 = map_[nId];
+ amb1.nLen = 2;
+ amb1.nVari = wwSprmParser::L_FIX;
+ }
+}
+
const wwSprmSearcher *wwSprmParser::GetWW8SprmSearcher()
{
//double lock me
@@ -773,7 +790,7 @@ const wwSprmSearcher *wwSprmParser::GetWW8SprmSearcher()
return &aSprmSrch;
};
-wwSprmParser::wwSprmParser(ww::WordVersion eVersion) : meVersion(eVersion)
+wwSprmParser::wwSprmParser(const WW8Fib& rFib) : meVersion(rFib.GetFIBVersion())
{
OSL_ENSURE((meVersion >= ww::eWW1 && meVersion <= ww::eWW8),
"Impossible value for version");
@@ -783,7 +800,7 @@ wwSprmParser::wwSprmParser(ww::WordVersion eVersion) : meVersion(eVersion)
if (meVersion <= ww::eWW2)
mpKnownSprms = GetWW2SprmSearcher();
else if (meVersion < ww::eWW8)
- mpKnownSprms = GetWW6SprmSearcher();
+ mpKnownSprms = GetWW6SprmSearcher(rFib);
else
mpKnownSprms = GetWW8SprmSearcher();
}
@@ -930,9 +947,9 @@ const sal_uInt8* WW8SprmIter::FindSprm(sal_uInt16 nId)
// temporary test
// WW8PLCFx_PCDAttrs cling to WW8PLCF_Pcd and therefore do not have their own iterators.
// All methods relating to iterators are therefore dummies.
-WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs(ww::WordVersion eVersion,
+WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs(const WW8Fib& rFib,
WW8PLCFx_PCD* pPLCFx_PCD, const WW8ScannerBase* pBase)
- : WW8PLCFx(eVersion, true), pPcdI(pPLCFx_PCD->GetPLCFIter()),
+ : WW8PLCFx(rFib, true), pPcdI(pPLCFx_PCD->GetPLCFIter()),
pPcd(pPLCFx_PCD), pGrpprls(pBase->m_aPieceGrpprls.data()),
nGrpprls(pBase->m_aPieceGrpprls.size())
{
@@ -1116,9 +1133,9 @@ void WW8PLCFx_PCDAttrs::GetSprms(WW8PLCFxDesc* p)
}
}
-WW8PLCFx_PCD::WW8PLCFx_PCD(ww::WordVersion eVersion, WW8PLCFpcd* pPLCFpcd,
+WW8PLCFx_PCD::WW8PLCFx_PCD(const WW8Fib& rFib, WW8PLCFpcd* pPLCFpcd,
WW8_CP nStartCp, bool bVer67P)
- : WW8PLCFx(eVersion, false), nClipStart(-1)
+ : WW8PLCFx(rFib, false), nClipStart(-1)
{
// construct own iterator
pPcdI = new WW8PLCFpcd_Iter(*pPLCFpcd, nStartCp);
@@ -1564,9 +1581,9 @@ WW8ScannerBase::WW8ScannerBase( SvStream* pSt, SvStream* pTableSt,
if( m_pPiecePLCF )
{
m_pPieceIter = new WW8PLCFpcd_Iter( *m_pPiecePLCF );
- m_pPLCFx_PCD = new WW8PLCFx_PCD(pWwFib->GetFIBVersion(), m_pPiecePLCF, 0,
+ m_pPLCFx_PCD = new WW8PLCFx_PCD(*pWwFib, m_pPiecePLCF, 0,
IsSevenMinus(m_pWw8Fib->GetFIBVersion()));
- m_pPLCFx_PCDAttrs = new WW8PLCFx_PCDAttrs(pWwFib->GetFIBVersion(),
+ m_pPLCFx_PCDAttrs = new WW8PLCFx_PCDAttrs(*pWwFib,
m_pPLCFx_PCD, this);
}
else
@@ -1583,15 +1600,15 @@ WW8ScannerBase::WW8ScannerBase( SvStream* pSt, SvStream* pTableSt,
m_pSepPLCF = new WW8PLCFx_SEPX( pSt, pTableSt, *pWwFib, 0 ); // SEPX
// Footnotes
- m_pFootnotePLCF = new WW8PLCFx_SubDoc( pTableSt, pWwFib->GetFIBVersion(), 0,
+ m_pFootnotePLCF = new WW8PLCFx_SubDoc( pTableSt, *pWwFib, 0,
pWwFib->m_fcPlcffndRef, pWwFib->m_lcbPlcffndRef, pWwFib->m_fcPlcffndText,
pWwFib->m_lcbPlcffndText, 2 );
// Endnotes
- m_pEdnPLCF = new WW8PLCFx_SubDoc( pTableSt, pWwFib->GetFIBVersion(), 0,
+ m_pEdnPLCF = new WW8PLCFx_SubDoc( pTableSt, *pWwFib, 0,
pWwFib->m_fcPlcfendRef, pWwFib->m_lcbPlcfendRef, pWwFib->m_fcPlcfendText,
pWwFib->m_lcbPlcfendText, 2 );
// Comments
- m_pAndPLCF = new WW8PLCFx_SubDoc( pTableSt, pWwFib->GetFIBVersion(), 0,
+ m_pAndPLCF = new WW8PLCFx_SubDoc( pTableSt, *pWwFib, 0,
pWwFib->m_fcPlcfandRef, pWwFib->m_lcbPlcfandRef, pWwFib->m_fcPlcfandText,
pWwFib->m_lcbPlcfandText, IsSevenMinus(pWwFib->GetFIBVersion()) ? 20 : 30);
@@ -2396,14 +2413,16 @@ void WW8PLCFx_Fc_FKP::WW8Fkp::FillEntry(WW8PLCFx_Fc_FKP::WW8Fkp::Entry &rEntry,
rEntry.mpData = maRawData + nDataOffset;
}
-WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(ww::WordVersion eVersion, SvStream* pSt,
+WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt,
SvStream* pDataSt, long _nFilePos, long nItemSiz, ePLCFT ePl,
WW8_FC nStartFc)
- : nItemSize(nItemSiz), nFilePos(_nFilePos), mnIdx(0), ePLCF(ePl),
- maSprmParser(eVersion)
+ : nItemSize(nItemSiz), nFilePos(_nFilePos), mnIdx(0), ePLCF(ePl)
+ , maSprmParser(rFib)
{
memset(maRawData, 0, 512);
+ const ww::WordVersion eVersion = rFib.GetFIBVersion();
+
sal_uInt64 const nOldPos = pSt->Tell();
bool bCouldSeek = checkSeek(*pSt, nFilePos);
@@ -2580,7 +2599,6 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(ww::WordVersion eVersion, SvStream* pSt,
{
sal_Int32 nLen;
sal_uInt8* pSprms = GetLenAndIStdAndSprms( nLen );
-
WW8SprmIter aIter(pSprms, nLen, maSprmParser);
while (aIter.GetSprms())
{
@@ -2750,6 +2768,11 @@ void WW8PLCFx_Fc_FKP::WW8Fkp::HasSprm(sal_uInt16 nId,
};
}
+ww::WordVersion WW8PLCFx::GetFIBVersion() const
+{
+ return mrFib.GetFIBVersion();
+}
+
void WW8PLCFx::GetSprms( WW8PLCFxDesc* p )
{
OSL_ENSURE( false, "Called wrong GetSprms" );
@@ -2850,7 +2873,7 @@ bool WW8PLCFx_Fc_FKP::NewFkp()
}
else
{
- pFkp = new WW8Fkp(GetFIBVersion(), pFKPStrm, pDataStrm, nPo,
+ pFkp = new WW8Fkp(GetFIB(), pFKPStrm, pDataStrm, nPo,
pFkpSizeTab[ ePLCF ], ePLCF, GetStartFc());
maFkpCache.push_back(pFkp);
@@ -2868,8 +2891,8 @@ bool WW8PLCFx_Fc_FKP::NewFkp()
WW8PLCFx_Fc_FKP::WW8PLCFx_Fc_FKP(SvStream* pSt, SvStream* pTableSt,
SvStream* pDataSt, const WW8Fib& rFib, ePLCFT ePl, WW8_FC nStartFcL)
- : WW8PLCFx(rFib.GetFIBVersion(), true), pFKPStrm(pSt), pDataStrm(pDataSt),
- pFkp(nullptr), ePLCF(ePl), pPCDAttrs(nullptr)
+ : WW8PLCFx(rFib, true), pFKPStrm(pSt), pDataStrm(pDataSt)
+ , pFkp(nullptr), ePLCF(ePl), pPCDAttrs(nullptr)
{
SetStartFc(nStartFcL);
long nLenStruct = (8 > rFib.m_nVersion) ? 2 : 4;
@@ -3087,7 +3110,7 @@ WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTableSt,
{
ResetAttrStartEnd();
- pPcd = rSBase.m_pPiecePLCF ? new WW8PLCFx_PCD(GetFIBVersion(),
+ pPcd = rSBase.m_pPiecePLCF ? new WW8PLCFx_PCD(GetFIB(),
rBase.m_pPiecePLCF, 0, IsSevenMinus(GetFIBVersion())) : nullptr;
/*
@@ -3099,7 +3122,7 @@ WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTableSt,
if (pPcd)
{
pPCDAttrs = rSBase.m_pPLCFx_PCDAttrs ? new WW8PLCFx_PCDAttrs(
- rSBase.m_pWw8Fib->GetFIBVersion(), pPcd, &rSBase) : nullptr;
+ *rSBase.m_pWw8Fib, pPcd, &rSBase) : nullptr;
}
pPieceIter = rSBase.m_pPieceIter;
@@ -3357,7 +3380,7 @@ void WW8PLCFx_Cp_FKP::advance()
WW8PLCFx_SEPX::WW8PLCFx_SEPX(SvStream* pSt, SvStream* pTableSt,
const WW8Fib& rFib, WW8_CP nStartCp)
- : WW8PLCFx(rFib.GetFIBVersion(), true), maSprmParser(rFib.GetFIBVersion()),
+ : WW8PLCFx(rFib, true), maSprmParser(rFib),
pStrm(pSt), nArrMax(256), nSprmSiz(0)
{
pPLCF = rFib.m_lcbPlcfsed
@@ -3538,10 +3561,10 @@ const sal_uInt8* WW8PLCFx_SEPX::HasSprm( sal_uInt16 nId, sal_uInt8 n2nd ) const
return nullptr; // Sprm not found
}
-WW8PLCFx_SubDoc::WW8PLCFx_SubDoc(SvStream* pSt, ww::WordVersion eVersion,
+WW8PLCFx_SubDoc::WW8PLCFx_SubDoc(SvStream* pSt, const WW8Fib& rFib,
WW8_CP nStartCp, long nFcRef, long nLenRef, long nFcText, long nLenText,
long nStruct)
- : WW8PLCFx(eVersion, true), pRef(nullptr), pText(nullptr)
+ : WW8PLCFx(rFib, true), pRef(nullptr), pText(nullptr)
{
if( nLenRef && nLenText )
{
@@ -3632,7 +3655,7 @@ void WW8PLCFx_SubDoc::advance()
// fields
WW8PLCFx_FLD::WW8PLCFx_FLD( SvStream* pSt, const WW8Fib& rMyFib, short nType)
- : WW8PLCFx(rMyFib.GetFIBVersion(), true), pPLCF(nullptr), rFib(rMyFib)
+ : WW8PLCFx(rMyFib, true), pPLCF(nullptr), rFib(rMyFib)
{
long nFc, nLen;
@@ -3927,7 +3950,7 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen
}
WW8PLCFx_Book::WW8PLCFx_Book(SvStream* pTableSt, const WW8Fib& rFib)
- : WW8PLCFx(rFib.GetFIBVersion(), false), nIsEnd(0), nBookmarkId(1)
+ : WW8PLCFx(rFib, false), nIsEnd(0), nBookmarkId(1)
{
if( !rFib.m_fcPlcfbkf || !rFib.m_lcbPlcfbkf || !rFib.m_fcPlcfbkl ||
!rFib.m_lcbPlcfbkl || !rFib.m_fcSttbfbkmk || !rFib.m_lcbSttbfbkmk )
@@ -4190,7 +4213,7 @@ const OUString* WW8PLCFx_Book::GetName() const
}
WW8PLCFx_AtnBook::WW8PLCFx_AtnBook(SvStream* pTableSt, const WW8Fib& rFib)
- : WW8PLCFx(rFib.GetFIBVersion(), /*bSprm=*/false),
+ : WW8PLCFx(rFib, /*bSprm=*/false),
m_bIsEnd(false)
{
if (!rFib.m_fcPlcfAtnbkf || !rFib.m_lcbPlcfAtnbkf || !rFib.m_fcPlcfAtnbkl || !rFib.m_lcbPlcfAtnbkl)
@@ -4322,7 +4345,7 @@ bool WW8PLCFx_AtnBook::getIsEnd() const
}
WW8PLCFx_FactoidBook::WW8PLCFx_FactoidBook(SvStream* pTableSt, const WW8Fib& rFib)
- : WW8PLCFx(rFib.GetFIBVersion(), /*bSprm=*/false),
+ : WW8PLCFx(rFib, /*bSprm=*/false),
m_bIsEnd(false)
{
if (!rFib.m_fcPlcfBkfFactoid || !rFib.m_lcbPlcfBkfFactoid || !rFib.m_fcPlcfBklFactoid || !rFib.m_lcbPlcfBklFactoid)
@@ -4581,7 +4604,7 @@ sal_uInt16 WW8PLCFMan::GetId(const WW8PLCFxDesc* p) const
WW8PLCFMan::WW8PLCFMan(WW8ScannerBase* pBase, ManTypes nType, long nStartCp,
bool bDoingDrawTextBox)
- : maSprmParser(pBase->m_pWw8Fib->GetFIBVersion()),
+ : maSprmParser(*pBase->m_pWw8Fib),
mbDoingDrawTextBox(bDoingDrawTextBox)
{
pWwFib = pBase->m_pWw8Fib;
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 5241578da95e..e538df65db20 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -72,12 +72,15 @@ struct SprmInfoRow {
class wwSprmSearcher {
public:
- wwSprmSearcher(SprmInfoRow const * rows, std::size_t size) {
+ //see Read_AmbiguousSPRM for the bPatchCJK oddity
+ wwSprmSearcher(SprmInfoRow const * rows, std::size_t size, bool bPatchCJK = false) {
for (std::size_t i = 0; i != size; ++i) {
bool ins = map_.insert(Map::value_type(rows[i].nId, rows[i].info))
.second;
assert(ins); (void) ins;
}
+ if (bPatchCJK)
+ patchCJKVariant();
}
SprmInfo const * search(sal_uInt16 id) const {
@@ -89,8 +92,12 @@ private:
typedef std::unordered_map<sal_uInt16, SprmInfo> Map;
Map map_;
+
+ void patchCJKVariant();
};
+class WW8Fib;
+
/**
wwSprmParser knows how to take a sequence of bytes and split it up into
sprms and their arguments
@@ -102,18 +109,18 @@ private:
sal_uInt8 mnDelta;
const wwSprmSearcher *mpKnownSprms;
static const wwSprmSearcher* GetWW8SprmSearcher();
- static const wwSprmSearcher* GetWW6SprmSearcher();
+ static const wwSprmSearcher* GetWW6SprmSearcher(const WW8Fib& rFib);
static const wwSprmSearcher* GetWW2SprmSearcher();
SprmInfo GetSprmInfo(sal_uInt16 nId) const;
sal_uInt8 SprmDataOfs(sal_uInt16 nId) const;
+public:
enum SprmType {L_FIX=0, L_VAR=1, L_VAR2=2};
-public:
//7- ids are very different to 8+ ones
- explicit wwSprmParser(ww::WordVersion eVersion);
+ explicit wwSprmParser(const WW8Fib& rFib);
/// Return the SPRM id at the beginning of this byte sequence
sal_uInt16 GetSprmId(const sal_uInt8* pSp) const;
@@ -156,7 +163,6 @@ OUString read_uInt16_BeltAndBracesString(SvStream& rStrm);
//--Line above which the code has meaningful comments
-class WW8Fib;
class WW8ScannerBase;
class WW8PLCFspecial;
struct WW8PLCFxDesc;
@@ -378,7 +384,7 @@ enum eExtSprm { eFTN = 256, eEDN = 257, eFLD = 258, eBKN = 259, eAND = 260, eATN
class WW8PLCFx // virtual iterator for Piece Table Exceptions
{
private:
- ww::WordVersion meVer; // Version number of FIB
+ const WW8Fib& mrFib;
bool bIsSprm; // PLCF of Sprms or other stuff ( Footnote, ... )
WW8_FC nStartFc;
bool bDirty;
@@ -387,8 +393,8 @@ private:
WW8PLCFx& operator=(const WW8PLCFx&) = delete;
public:
- WW8PLCFx(ww::WordVersion eVersion, bool bSprm)
- : meVer(eVersion)
+ WW8PLCFx(const WW8Fib& rFib, bool bSprm)
+ : mrFib(rFib)
, bIsSprm(bSprm)
, nStartFc(-1)
, bDirty(false)
@@ -408,7 +414,8 @@ public:
virtual sal_uInt16 GetIstd() const { return 0xffff; }
virtual void Save( WW8PLCFxSave1& rSave ) const;
virtual void Restore( const WW8PLCFxSave1& rSave );
- ww::WordVersion GetFIBVersion() const { return meVer; }
+ ww::WordVersion GetFIBVersion() const;
+ const WW8Fib& GetFIB() const { return mrFib; }
void SetStartFc( WW8_FC nFc ) { nStartFc = nFc; }
WW8_FC GetStartFc() const { return nStartFc; }
void SetDirty(bool bIn) {bDirty=bIn;}
@@ -429,7 +436,7 @@ private:
WW8PLCFx_PCDAttrs& operator=(const WW8PLCFx_PCDAttrs&) = delete;
public:
- WW8PLCFx_PCDAttrs(ww::WordVersion eVersion, WW8PLCFx_PCD* pPLCFx_PCD,
+ WW8PLCFx_PCDAttrs(const WW8Fib& rFib, WW8PLCFx_PCD* pPLCFx_PCD,
const WW8ScannerBase* pBase );
virtual sal_uInt32 GetIdx() const override;
virtual void SetIdx( sal_uLong nI ) override;
@@ -452,7 +459,7 @@ private:
WW8PLCFx_PCD& operator=(const WW8PLCFx_PCD&) = delete;
public:
- WW8PLCFx_PCD(ww::WordVersion eVersion, WW8PLCFpcd* pPLCFpcd,
+ WW8PLCFx_PCD(const WW8Fib& rFib, WW8PLCFpcd* pPLCFpcd,
WW8_CP nStartCp, bool bVer67P);
virtual ~WW8PLCFx_PCD() override;
sal_uLong GetIMax() const;
@@ -522,7 +529,7 @@ public:
void FillEntry(Entry &rEntry, std::size_t nDataOffset, sal_uInt16 nLen);
public:
- WW8Fkp (ww::WordVersion eVersion, SvStream* pFKPStrm,
+ WW8Fkp (const WW8Fib& rFib, SvStream* pFKPStrm,
SvStream* pDataStrm, long _nFilePos, long nItemSiz, ePLCFT ePl,
WW8_FC nStartFc);
void Reset(WW8_FC nPos);
@@ -678,7 +685,7 @@ private:
WW8PLCFx_SubDoc& operator=(const WW8PLCFx_SubDoc&) = delete;
public:
- WW8PLCFx_SubDoc(SvStream* pSt, ww::WordVersion eVersion, WW8_CP nStartCp,
+ WW8PLCFx_SubDoc(SvStream* pSt, const WW8Fib& rFib, WW8_CP nStartCp,
long nFcRef, long nLenRef, long nFcText, long nLenText, long nStruc);
virtual ~WW8PLCFx_SubDoc() override;
virtual sal_uInt32 GetIdx() const override;
@@ -1002,7 +1009,7 @@ struct WW8PLCFxSaveAll
class WW8ScannerBase
{
-friend WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs(ww::WordVersion eVersion,
+friend WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs(const WW8Fib& rFib,
WW8PLCFx_PCD* pPLCFx_PCD, const WW8ScannerBase* pBase );
friend WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream*, SvStream*, SvStream*,
const WW8ScannerBase&, ePLCFT );
@@ -1504,13 +1511,10 @@ public:
they couldn't read any format with nFib > some constant
*/
sal_uInt16 m_nFib_actual; // 0x05bc #i56856#
- /*
- now we only need a Ctor
- */
- WW8Fib( SvStream& rStrm, sal_uInt8 nWantedVersion,sal_uInt32 nOffset=0 );
- /* unfortunately incorrect, you still need one for the export */
- WW8Fib( sal_uInt8 nVersion = 6, bool bDot = false );
+ WW8Fib(SvStream& rStrm, sal_uInt8 nWantedVersion,sal_uInt32 nOffset=0);
+ explicit WW8Fib(sal_uInt8 nVersion = 6, bool bDot = false);
+
void WriteHeader(SvStream& rStrm);
void Write(SvStream& rStrm);
static rtl_TextEncoding GetFIBCharset(sal_uInt16 chs, sal_uInt16 nLidLocale);