summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2014-02-25 14:16:25 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-02-25 16:23:32 +0000
commit27c3b8bca22353dfdcf4c248539a727522fc4e76 (patch)
tree6e56d23130f59cb7c5c41012bc81578f205426d5 /sc
parentb8ebdae0345aa331cf6d6dabf40a6f26dc7d2371 (diff)
Don't write compound header to zero length files
Change-Id: Ie964ca8b870714d1c3e92469a771fab9a71f0633 Reviewed-on: https://gerrit.libreoffice.org/8220 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/unoobj/scdetect.cxx76
1 files changed, 33 insertions, 43 deletions
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
index 41f3623055da..d56e4feb4768 100644
--- a/sc/source/ui/unoobj/scdetect.cxx
+++ b/sc/source/ui/unoobj/scdetect.cxx
@@ -510,57 +510,47 @@ OUString SAL_CALL ScFilterDetect::detect( uno::Sequence<beans::PropertyValue>& l
pFilter = NULL;
- pStream->Seek( STREAM_SEEK_TO_END);
- sal_Size nSize = pStream->Tell();
- pStream->Seek( 0);
- // Do not attempt to create an SotStorage on a
- // 0-length stream as that would create the compound
- // document header on the stream and effectively write to
- // disk!
- if (nSize > 0)
+ const char* pSearchFilterName = NULL;
+ if (aTypeName == "calc_Lotus")
{
- const char* pSearchFilterName = NULL;
- if (aTypeName == "calc_Lotus")
- {
- if (!detectThisFormat(*pStream, pLotus) && !detectThisFormat(*pStream, pLotusNew) && !detectThisFormat(*pStream, pLotus2))
- return OUString();
-
- pSearchFilterName = pFilterLotus;
- }
- else if (aTypeName == "calc_QPro")
- {
- if (!detectThisFormat(*pStream, pQPro))
- return OUString();
-
- pSearchFilterName = pFilterQPro6;
- }
- else if (aTypeName == "calc_SYLK")
- {
- if (!detectThisFormat(*pStream, pSylk))
- return OUString();
+ if (!detectThisFormat(*pStream, pLotus) && !detectThisFormat(*pStream, pLotusNew) && !detectThisFormat(*pStream, pLotus2))
+ return OUString();
- pSearchFilterName = pFilterSylk;
- }
- else if (aTypeName == "calc_DIF")
- {
- if (!detectThisFormat(*pStream, pDIF1) && !detectThisFormat(*pStream, pDIF2))
- return OUString();
+ pSearchFilterName = pFilterLotus;
+ }
+ else if (aTypeName == "calc_QPro")
+ {
+ if (!detectThisFormat(*pStream, pQPro))
+ return OUString();
- pSearchFilterName = pFilterDif;
- }
- else if (aTypeName == "calc_dBase")
- {
- if (!lcl_MayBeDBase(*pStream))
- return OUString();
+ pSearchFilterName = pFilterQPro6;
+ }
+ else if (aTypeName == "calc_SYLK")
+ {
+ if (!detectThisFormat(*pStream, pSylk))
+ return OUString();
- pSearchFilterName = pFilterDBase;
- }
+ pSearchFilterName = pFilterSylk;
+ }
+ else if (aTypeName == "calc_DIF")
+ {
+ if (!detectThisFormat(*pStream, pDIF1) && !detectThisFormat(*pStream, pDIF2))
+ return OUString();
- if (!pSearchFilterName)
+ pSearchFilterName = pFilterDif;
+ }
+ else if (aTypeName == "calc_dBase")
+ {
+ if (!lcl_MayBeDBase(*pStream))
return OUString();
- pFilter = aMatcher.GetFilter4FilterName(OUString::createFromAscii(pSearchFilterName));
+ pSearchFilterName = pFilterDBase;
}
+
+ if (!pSearchFilterName)
+ return OUString();
+
+ pFilter = aMatcher.GetFilter4FilterName(OUString::createFromAscii(pSearchFilterName));
}
}
}