summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-11-23 14:05:26 +0000
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-12-07 14:30:09 +0100
commite438b6f7db20854463849366045d4da79adeb201 (patch)
treed6bac4b3f0356621f4bbbb0213e2242a79399419 /filter
parent11ea1b0751378e20ee5be8e708b58a5270524716 (diff)
set new document window as parent for dialogs during load
and exit typedetection early and completely if application quits while detecting During typedetection, before loading proper, we have the hidden window as parent so warnings are not modal to existing windows and they are cancelled on exit. Once we do have a window, then reinit interaction handler to have that window as the parent for any further dialogs. Change-Id: I5c6711557266bf7d1eb9291f1c454cbfaf766886 Reviewed-on: https://gerrit.libreoffice.org/45148 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/CppunitTest_filter_priority.mk1
-rw-r--r--filter/source/config/cache/typedetection.cxx12
-rw-r--r--filter/source/config/cache/typedetection.hxx41
3 files changed, 49 insertions, 5 deletions
diff --git a/filter/CppunitTest_filter_priority.mk b/filter/CppunitTest_filter_priority.mk
index e5046ac0e3a2..d412b922e7ea 100644
--- a/filter/CppunitTest_filter_priority.mk
+++ b/filter/CppunitTest_filter_priority.mk
@@ -11,6 +11,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,filter_priority))
$(eval $(call gb_CppunitTest_use_sdk_api,filter_priority))
$(eval $(call gb_CppunitTest_use_ure,filter_priority))
+$(eval $(call gb_CppunitTest_use_vcl,filter_priority))
$(eval $(call gb_CppunitTest_use_configuration,filter_priority))
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index 278115c8af6c..74b0b978f5f6 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -21,6 +21,7 @@
#include "constant.hxx"
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
@@ -50,7 +51,10 @@ namespace filter{
TypeDetection::TypeDetection(const css::uno::Reference< css::uno::XComponentContext >& rxContext)
: m_xContext(rxContext)
+ , m_xTerminateListener(new TerminateDetection(this))
+ , m_bCancel(false)
{
+ css::frame::Desktop::create(m_xContext)->addTerminateListener(m_xTerminateListener.get());
BaseContainer::init(rxContext ,
TypeDetection::impl_getImplementationName() ,
TypeDetection::impl_getSupportedServiceNames(),
@@ -60,6 +64,7 @@ TypeDetection::TypeDetection(const css::uno::Reference< css::uno::XComponentCont
TypeDetection::~TypeDetection()
{
+ css::frame::Desktop::create(m_xContext)->removeTerminateListener(m_xTerminateListener.get());
}
@@ -426,18 +431,17 @@ OUString SAL_CALL TypeDetection::queryTypeByDescriptor(css::uno::Sequence< css::
if (lFlatTypes.size()>0)
sType = impl_detectTypeFlatAndDeep(stlDescriptor, lFlatTypes, bAllowDeep, lUsedDetectors, sLastChance);
-
// flat detection failed
// pure deep detection failed
// => ask might existing InteractionHandler
// means: ask user for its decision
- if (sType.isEmpty())
+ if (sType.isEmpty() && !m_bCancel)
sType = impl_askUserForTypeAndFilterIfAllowed(stlDescriptor);
// no real detected type - but a might valid one.
// update descriptor and set last chance for return.
- if (sType.isEmpty() && !sLastChance.isEmpty())
+ if (sType.isEmpty() && !sLastChance.isEmpty() && !m_bCancel)
{
OSL_FAIL("set first flat detected type without a registered deep detection service as \"last chance\" ... nevertheless some other deep detections said \"NO\". I TRY IT!");
sType = sLastChance;
@@ -898,7 +902,7 @@ OUString TypeDetection::impl_detectTypeFlatAndDeep( utl::MediaDescriptor& r
// obtained from the cache => ignore it, and continue with search
for (FlatDetection::const_iterator pFlatIt = lFlatTypes.begin();
- pFlatIt != lFlatTypes.end() ;
+ pFlatIt != lFlatTypes.end() && !m_bCancel;
++pFlatIt )
{
const FlatDetectionInfo& aFlatTypeInfo = *pFlatIt;
diff --git a/filter/source/config/cache/typedetection.hxx b/filter/source/config/cache/typedetection.hxx
index 548a14343925..f948e6522697 100644
--- a/filter/source/config/cache/typedetection.hxx
+++ b/filter/source/config/cache/typedetection.hxx
@@ -21,14 +21,16 @@
#include "basecontainer.hxx"
#include <com/sun/star/document/XTypeDetection.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <unotools/mediadescriptor.hxx>
+#include <cppuhelper/compbase.hxx>
#include <cppuhelper/implbase.hxx>
-
namespace filter{ namespace config {
+class TerminateDetection;
/** @short implements the service <type scope="com.sun.star.document">TypeDetection</type>.
*/
@@ -39,6 +41,8 @@ class TypeDetection : public ::cppu::ImplInheritanceHelper< BaseContainer
// native interface
css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ rtl::Reference<TerminateDetection> m_xTerminateListener;
+ bool m_bCancel;
public:
@@ -53,6 +57,11 @@ public:
*/
explicit TypeDetection(const css::uno::Reference< css::uno::XComponentContext >& rxContext);
+ void cancel()
+ {
+ m_bCancel = true;
+ }
+
/** @short standard dtor.
*/
@@ -365,6 +374,36 @@ public:
static css::uno::Reference< css::uno::XInterface > impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
};
+class TerminateDetection : public cppu::WeakComponentImplHelper<css::frame::XTerminateListener>
+{
+private:
+ osl::Mutex m_aLock;
+ TypeDetection* m_pTypeDetection;
+
+public:
+
+ using cppu::WeakComponentImplHelperBase::disposing;
+ virtual void SAL_CALL disposing(const css::lang::EventObject&) override
+ {
+ }
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination(const css::lang::EventObject&) override
+ {
+ m_pTypeDetection->cancel();
+ }
+
+ virtual void SAL_CALL notifyTermination(const css::lang::EventObject&) override
+ {
+ }
+
+ TerminateDetection(TypeDetection* pTypeDetection)
+ : cppu::WeakComponentImplHelper<css::frame::XTerminateListener>(m_aLock)
+ , m_pTypeDetection(pTypeDetection)
+ {
+ }
+};
+
}}
#endif // INCLUDED_FILTER_SOURCE_CONFIG_CACHE_TYPEDETECTION_HXX