Kaydet (Commit) ac2ee597 authored tarafından Kohei Yoshida's avatar Kohei Yoshida Kaydeden (comit) Caolán McNamara

fdo#59426: Don't try to repair package during flat detection phase.

Change-Id: I35968241a79db0aabe06e25c0efac2aa3d1c5b84
Reviewed-on: https://gerrit.libreoffice.org/1984Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst f5b58a5e
...@@ -94,6 +94,8 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap ...@@ -94,6 +94,8 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap
static const ::rtl::OUString& PROP_VIEWONLY(); static const ::rtl::OUString& PROP_VIEWONLY();
static const ::rtl::OUString& PROP_DOCUMENTBASEURL(); static const ::rtl::OUString& PROP_DOCUMENTBASEURL();
static const OUString& PROP_DEEPDETECTION();
//------------------------------------------- //-------------------------------------------
// interface // interface
public: public:
......
...@@ -296,6 +296,12 @@ const ::rtl::OUString& MediaDescriptor::PROP_DOCUMENTBASEURL() ...@@ -296,6 +296,12 @@ const ::rtl::OUString& MediaDescriptor::PROP_DOCUMENTBASEURL()
return sProp; return sProp;
} }
const OUString& MediaDescriptor::PROP_DEEPDETECTION()
{
static const OUString aProp("DeepDetection");
return aProp;
}
MediaDescriptor::MediaDescriptor() MediaDescriptor::MediaDescriptor()
: SequenceAsHashMap() : SequenceAsHashMap()
{ {
......
...@@ -305,6 +305,8 @@ struct EqualByName : public std::binary_function<FlatDetectionInfo, FlatDetectio ...@@ -305,6 +305,8 @@ struct EqualByName : public std::binary_function<FlatDetectionInfo, FlatDetectio
(bAllowDeep ) (bAllowDeep )
) )
{ {
// Let's the detection service know we are in a deep detection phase.
stlDescriptor[comphelper::MediaDescriptor::PROP_DEEPDETECTION()] <<= sal_True;
sType = impl_detectTypeDeepOnly(stlDescriptor, lUsedDetectors); sType = impl_detectTypeDeepOnly(stlDescriptor, lUsedDetectors);
} }
......
...@@ -244,6 +244,7 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) ...@@ -244,6 +244,7 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream )
sal_Bool bRepairPackage = false; sal_Bool bRepairPackage = false;
sal_Bool bRepairAllowed = false; sal_Bool bRepairAllowed = false;
bool bDeepDetection = false;
// now some parameters that can already be in the array, but may be overwritten or new inserted here // now some parameters that can already be in the array, but may be overwritten or new inserted here
// remember their indices in the case new values must be added to the array // remember their indices in the case new values must be added to the array
...@@ -300,6 +301,8 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) ...@@ -300,6 +301,8 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream )
lDescriptor[nProperty].Value >>= bRepairPackage; lDescriptor[nProperty].Value >>= bRepairPackage;
else if ( lDescriptor[nProperty].Name == "DocumentTitle" ) else if ( lDescriptor[nProperty].Name == "DocumentTitle" )
nIndexOfDocumentTitle = nProperty; nIndexOfDocumentTitle = nProperty;
else if (lDescriptor[nProperty].Name == "DeepDetection")
bDeepDetection = lDescriptor[nProperty].Value.get<sal_Bool>();
} }
// can't check the type for external filters, so set the "dont" flag accordingly // can't check the type for external filters, so set the "dont" flag accordingly
...@@ -382,6 +385,10 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) ...@@ -382,6 +385,10 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream )
} }
catch( const lang::WrappedTargetException& aWrap ) catch( const lang::WrappedTargetException& aWrap )
{ {
if (!bDeepDetection)
// Bail out early unless it's a deep detection.
return OUString();
packages::zip::ZipIOException aZipException; packages::zip::ZipIOException aZipException;
// repairing is done only if this type is requested from outside // repairing is done only if this type is requested from outside
...@@ -424,9 +431,8 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) ...@@ -424,9 +431,8 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream )
aTypeName.Erase(); aTypeName.Erase();
} }
if ( aTypeName.Len() ) if ( aTypeName.Len() )
pFilter = SfxFilterMatcher( rtl::OUString("scalc") ).GetFilter4EA( aTypeName ); pFilter = SfxFilterMatcher( rtl::OUString("scalc") ).GetFilter4EA( aTypeName );
} }
} }
else else
......
...@@ -102,6 +102,7 @@ SdFilterDetect::~SdFilterDetect() ...@@ -102,6 +102,7 @@ SdFilterDetect::~SdFilterDetect()
sal_Bool bRepairPackage = sal_False; sal_Bool bRepairPackage = sal_False;
sal_Bool bRepairAllowed = sal_False; sal_Bool bRepairAllowed = sal_False;
bool bDeepDetection = false;
// now some parameters that can already be in the array, but may be overwritten or new inserted here // now some parameters that can already be in the array, but may be overwritten or new inserted here
// remember their indices in the case new values must be added to the array // remember their indices in the case new values must be added to the array
...@@ -152,6 +153,8 @@ SdFilterDetect::~SdFilterDetect() ...@@ -152,6 +153,8 @@ SdFilterDetect::~SdFilterDetect()
lDescriptor[nProperty].Value >>= bRepairPackage; lDescriptor[nProperty].Value >>= bRepairPackage;
else if ( lDescriptor[nProperty].Name == "DocumentTitle" ) else if ( lDescriptor[nProperty].Name == "DocumentTitle" )
nIndexOfDocumentTitle = nProperty; nIndexOfDocumentTitle = nProperty;
else if (lDescriptor[nProperty].Name == "DeepDetection")
bDeepDetection = lDescriptor[nProperty].Value.get<sal_Bool>();
} }
// can't check the type for external filters, so set the "dont" flag accordingly // can't check the type for external filters, so set the "dont" flag accordingly
...@@ -258,6 +261,10 @@ SdFilterDetect::~SdFilterDetect() ...@@ -258,6 +261,10 @@ SdFilterDetect::~SdFilterDetect()
} }
catch( const lang::WrappedTargetException& aWrap ) catch( const lang::WrappedTargetException& aWrap )
{ {
if (!bDeepDetection)
// Bail out early unless it's a deep detection.
return OUString();
packages::zip::ZipIOException aZipException; packages::zip::ZipIOException aZipException;
if ( ( aWrap.TargetException >>= aZipException ) && aTypeName.Len() ) if ( ( aWrap.TargetException >>= aZipException ) && aTypeName.Len() )
{ {
......
...@@ -97,6 +97,7 @@ SwFilterDetect::~SwFilterDetect() ...@@ -97,6 +97,7 @@ SwFilterDetect::~SwFilterDetect()
sal_Bool bRepairPackage = sal_False; sal_Bool bRepairPackage = sal_False;
sal_Bool bRepairAllowed = sal_False; sal_Bool bRepairAllowed = sal_False;
bool bDeepDetection = false;
// now some parameters that can already be in the array, but may be overwritten or new inserted here // now some parameters that can already be in the array, but may be overwritten or new inserted here
// remember their indices in the case new values must be added to the array // remember their indices in the case new values must be added to the array
...@@ -151,6 +152,8 @@ SwFilterDetect::~SwFilterDetect() ...@@ -151,6 +152,8 @@ SwFilterDetect::~SwFilterDetect()
lDescriptor[nProperty].Value >>= bRepairPackage; lDescriptor[nProperty].Value >>= bRepairPackage;
else if ( lDescriptor[nProperty].Name == "DocumentTitle" ) else if ( lDescriptor[nProperty].Name == "DocumentTitle" )
nIndexOfDocumentTitle = nProperty; nIndexOfDocumentTitle = nProperty;
else if (lDescriptor[nProperty].Name == "DeepDetection")
bDeepDetection = lDescriptor[nProperty].Value.get<sal_Bool>();
} }
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
...@@ -239,6 +242,10 @@ SwFilterDetect::~SwFilterDetect() ...@@ -239,6 +242,10 @@ SwFilterDetect::~SwFilterDetect()
} }
catch (const lang::WrappedTargetException& aWrap) catch (const lang::WrappedTargetException& aWrap)
{ {
if (!bDeepDetection)
// Bail out early unless it's a deep detection.
return OUString();
packages::zip::ZipIOException aZipException; packages::zip::ZipIOException aZipException;
// repairing is done only if this type is requested from outside // repairing is done only if this type is requested from outside
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment