sw/source/filter/ww8/ww8par.cxx | 9 +++ sw/source/filter/ww8/ww8par.hxx | 4 + sw/source/filter/ww8/ww8par5.cxx | 4 + sw/source/filter/ww8/ww8scan.cxx | 109 ++++++++++++++++++++++++++++++++++++++ sw/source/filter/ww8/ww8struc.hxx | 57 +++++++++++++++++++ 5 files changed, 183 insertions(+)
New commits: commit e0caeaa5be754c35742cec7ddf70c9021f66f2bf Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Dec 8 15:34:03 2015 +0100 WW8SmartTagData::Read: check seek result Change-Id: I0492c5b3018f59e4b783bb33f8b75ce67847dcf0 diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 0f2df7c..c39afcb 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -6363,7 +6363,8 @@ void MSOPropertyBag::Read(SvStream& rStream) void WW8SmartTagData::Read(SvStream& rStream, WW8_FC fcFactoidData, sal_uInt32 lcbFactoidData) { sal_uInt64 nOldPosition = rStream.Tell(); - rStream.Seek(fcFactoidData); + if (!checkSeek(rStream, fcFactoidData)) + return; m_aPropBagStore.Read(rStream); while (rStream.Tell() < fcFactoidData + lcbFactoidData) commit 0c3155f601b74eb369f47dc713d9e119e798da85 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Dec 8 15:16:50 2015 +0100 DOC import: read SmartTagData This only reads all the interesting info, SwWW8ImplReader::Read_FactoidBook() still has to put it on the filter stack in a later commit. Change-Id: Ic2e8b441367448b5bdf940bf8871f25afe8362c4 diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 84512a5..15a731b 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -5978,6 +5978,15 @@ const OUString* SwWW8ImplReader::GetAnnotationAuthor(sal_uInt16 nIdx) return pRet; } +void SwWW8ImplReader::GetSmartTagInfo(sal_uInt16 /*nIndex*/) +{ + if (!m_pSmartTagData && m_pWwFib->lcbFactoidData) + { + m_pSmartTagData.reset(new WW8SmartTagData()); + m_pSmartTagData->Read(*m_pTableStream, m_pWwFib->fcFactoidData, m_pWwFib->lcbFactoidData); + } +} + sal_uLong SwWW8ImplReader::LoadDoc(WW8Glossary *pGloss) { sal_uLong nErrRet = 0; diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 98669e3..d231d57 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1251,6 +1251,8 @@ private: std::vector<OUString>* m_pAtnNames; + std::unique_ptr<WW8SmartTagData> m_pSmartTagData; + sw::util::AuthorInfos m_aAuthorInfos; OUString m_sBaseURL; @@ -1638,6 +1640,8 @@ private: const OUString* GetAnnotationAuthor(sal_uInt16 nIdx); + void GetSmartTagInfo(sal_uInt16 nIndex); + // interfaces for the toggle attributes void SetToggleAttr(sal_uInt8 nAttrId, bool bOn); void SetToggleBiDiAttr(sal_uInt8 nAttrId, bool bOn); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 18747c3..5394be4 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -249,7 +249,11 @@ long SwWW8ImplReader::Read_FactoidBook(WW8PLCFManResult*) if (pFactoidBook->getIsEnd()) m_pReffedStck->SetAttr(*m_pPaM->GetPoint(), RES_FLTR_RDFMARK, true, pFactoidBook->getHandle()); else + { + // TODO make this non-void and put keys/values into the RDF mark. + GetSmartTagInfo(pFactoidBook->getHandle()); m_pReffedStck->NewAttr(*m_pPaM->GetPoint(), CntUInt16Item(RES_FLTR_RDFMARK, pFactoidBook->getHandle())); + } } return 0; } diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 1a39642..0f2df7c 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -6268,6 +6268,114 @@ rtl_TextEncoding WW8Fib::GetFIBCharset(sal_uInt16 chs, sal_uInt16 nLidLocale) return rtl_getTextEncodingFromWindowsCharset(static_cast<sal_uInt8>(chs)); } +MSOFactoidType::MSOFactoidType() + : m_nId(0) +{ +} + +namespace MSOPBString +{ +OUString Read(SvStream& rStream) +{ + OUString aRet; + + sal_uInt16 nBuf(0); + rStream.ReadUInt16(nBuf); + sal_uInt16 nCch = nBuf & 0x7fff; // Bits 1..15. + bool bAnsiString = (nBuf & (1 << 15)) >> 15; // 16th bit. + if (bAnsiString) + aRet = OStringToOUString(read_uInt8s_ToOString(rStream, nCch), RTL_TEXTENCODING_ASCII_US); + else + aRet = read_uInt16s_ToOUString(rStream, nCch); + + return aRet; +} +}; + +void MSOFactoidType::Read(SvStream& rStream) +{ + sal_uInt32 cbFactoid(0); + rStream.ReadUInt32(cbFactoid); + rStream.ReadUInt32(m_nId); + m_aUri = MSOPBString::Read(rStream); + m_aTag = MSOPBString::Read(rStream); + MSOPBString::Read(rStream); // rgbDownloadURL +} + +void MSOPropertyBagStore::Read(SvStream& rStream) +{ + sal_uInt32 cFactoidType(0); + rStream.ReadUInt32(cFactoidType); + for (sal_uInt32 i = 0; i < cFactoidType; ++i) + { + MSOFactoidType aFactoidType; + aFactoidType.Read(rStream); + m_aFactoidTypes.push_back(aFactoidType); + } + sal_uInt16 cbHdr(0); + rStream.ReadUInt16(cbHdr); + SAL_WARN_IF(cbHdr != 0xc, "sw.ww8", "MSOPropertyBagStore::Read: unexpected cbHdr"); + sal_uInt16 nVer(0); + rStream.ReadUInt16(nVer); + SAL_WARN_IF(nVer != 0x0100, "sw.ww8", "MSOPropertyBagStore::Read: unexpected nVer"); + rStream.SeekRel(4); // cfactoid + sal_uInt32 nCste(0); + rStream.ReadUInt32(nCste); + + for (sal_uInt32 i = 0; i < nCste; ++i) + { + OUString aString = MSOPBString::Read(rStream); + m_aStringTable.push_back(aString); + } +} + +MSOProperty::MSOProperty() + : m_nKey(0), + m_nValue(0) +{ +} + +void MSOProperty::Read(SvStream& rStream) +{ + rStream.ReadUInt32(m_nKey); + rStream.ReadUInt32(m_nValue); +} + +MSOPropertyBag::MSOPropertyBag() + : m_nId(0) +{ +} + +void MSOPropertyBag::Read(SvStream& rStream) +{ + rStream.ReadUInt16(m_nId); + sal_uInt16 cProp(0); + rStream.ReadUInt16(cProp); + rStream.SeekRel(2); // cbUnknown + for (sal_uInt16 i = 0; i < cProp; ++i) + { + MSOProperty aProperty; + aProperty.Read(rStream); + m_aProperties.push_back(aProperty); + } +} + +void WW8SmartTagData::Read(SvStream& rStream, WW8_FC fcFactoidData, sal_uInt32 lcbFactoidData) +{ + sal_uInt64 nOldPosition = rStream.Tell(); + rStream.Seek(fcFactoidData); + + m_aPropBagStore.Read(rStream); + while (rStream.Tell() < fcFactoidData + lcbFactoidData) + { + MSOPropertyBag aPropertyBag; + aPropertyBag.Read(rStream); + m_aPropBags.push_back(aPropertyBag); + } + + rStream.Seek(nOldPosition); +} + WW8Style::WW8Style(SvStream& rStream, WW8Fib& rFibPara) : rFib(rFibPara), rSt(rStream), cstd(0), cbSTDBaseInFile(0), fStdStylenamesWritten(0) , stiMaxWhenSaved(0), istdMaxFixedWhenSaved(0), nVerBuiltInNamesWhenSaved(0) diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx index 5d0f0fc..5181a1b 100644 --- a/sw/source/filter/ww8/ww8struc.hxx +++ b/sw/source/filter/ww8/ww8struc.hxx @@ -1088,6 +1088,63 @@ namespace wwUtility inline sal_uInt32 RGBToBGR(sal_uInt32 nColour) { return msfilter::util::BGRToRGB(nColour); } } +/// [MS-OSHARED] FactoidType: one smart tag type. +class MSOFactoidType +{ +public: + MSOFactoidType(); + void Read(SvStream& rStream); + + sal_uInt32 m_nId; + OUString m_aUri; + OUString m_aTag; +}; + +/// [MS-OSHARED] PropertyBagStore: smart tag types and string store. +class MSOPropertyBagStore +{ +public: + void Read(SvStream& rStream); + + std::vector<MSOFactoidType> m_aFactoidTypes; + std::vector<OUString> m_aStringTable; +}; + +/// [MS-OSHARED] Property: stores information about one smart-tag key/value. +class MSOProperty +{ +public: + MSOProperty(); + void Read(SvStream& rStream); + + /// Index into MSOPropertyBagStore::m_aStringTable. + sal_uInt32 m_nKey; + /// Index into MSOPropertyBagStore::m_aStringTable. + sal_uInt32 m_nValue; +}; + +/// [MS-OSHARED] PropertyBag: stores information about one smart tag. +class MSOPropertyBag +{ +public: + MSOPropertyBag(); + void Read(SvStream& rStream); + + /// Matches MSOFactoidType::m_nId in MSOPropertyBagStore::m_aFactoidTypes. + sal_uInt16 m_nId; + std::vector<MSOProperty> m_aProperties; +}; + +/// [MS-DOC] SmartTagData: stores information about all smart tags in the document. +class WW8SmartTagData +{ +public: + void Read(SvStream& rStream, WW8_FC fcFactoidData, sal_uInt32 lcbFactoidData); + + MSOPropertyBagStore m_aPropBagStore; + std::vector<MSOPropertyBag> m_aPropBags; +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits