diff options
author | Tor Lillqvist <tml@collabora.com> | 2019-02-19 11:03:20 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2019-02-19 17:42:29 +0200 |
commit | a7d09d82ee25a0880a5d4adb59d102cbf886f7cc (patch) | |
tree | 8b8c6ba6bcc7b91c02ab5b9bfeb9c65065b94cc0 /sw/source | |
parent | bbf4f2594b114a72d718e292fc18581200bc2e37 (diff) |
tdf#110987: Don't mis-detect .doc files as .dot
Also add a unit test for that.
Change-Id: I86c195cebbe12b2bdf498954956db882f6f0d12b
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/ui/uno/swdetect.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sw/source/ui/uno/swdetect.cxx b/sw/source/ui/uno/swdetect.cxx index 44d5c205eb6a..1f7bc3a76bc9 100644 --- a/sw/source/ui/uno/swdetect.cxx +++ b/sw/source/ui/uno/swdetect.cxx @@ -95,7 +95,29 @@ OUString SAL_CALL SwFilterDetect::detect( Sequence< PropertyValue >& lDescriptor { bIsDetected = aStorage->IsContained( "WordDocument" ); if ( bIsDetected && aTypeName.startsWith( "writer_MS_Word_97" ) ) + { bIsDetected = ( aStorage->IsContained("0Table") || aStorage->IsContained("1Table") ); + + // If we are checking the template type, and the document is not a .dot, don't + // mis-detect it. + if ( bIsDetected && aTypeName == "writer_MS_Word_97_Vorlage" ) + { + // Super ugly hack, but we don't want to use the whole WW8Fib thing here in + // the swd library, apparently. We know (do we?) that the "aBits1" byte, as + // the variable is called in WW8Fib::WW8Fib(SvStream&,sal_uInt8,sal_uInt32), + // is at offset 10 in the WordDocument stream. The fDot bit is bit 0x01 of + // that byte. + tools::SvRef<SotStorageStream> xWordDocument = aStorage->OpenSotStream("WordDocument", StreamMode::STD_READ); + xWordDocument->Seek( 10 ); + if ( xWordDocument->Tell() == 10 ) + { + sal_uInt8 aBits1; + xWordDocument->ReadUChar( aBits1 ); + // Check fDot bit + bIsDetected = ((aBits1 & 0x01) == 0x01); + } + } + } } } catch (...) |