fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / interaction / quietinteraction.cxx
blob3b27f1815d4da94fcc3769c8e5ea035113a86988
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "interaction/quietinteraction.hxx"
22 #include <macros/generic.hxx>
24 #include <com/sun/star/task/XInteractionAbort.hpp>
25 #include <com/sun/star/task/XInteractionApprove.hpp>
26 #include <com/sun/star/document/XInteractionFilterSelect.hpp>
27 #include <com/sun/star/document/XInteractionFilterOptions.hpp>
28 #include <com/sun/star/document/FilterOptionsRequest.hpp>
29 #include <com/sun/star/task/ErrorCodeRequest.hpp>
31 #include <com/sun/star/document/LockedDocumentRequest.hpp>
33 #include <vcl/svapp.hxx>
35 #ifndef __RSC
36 #include <tools/errinf.hxx>
37 #endif
39 namespace framework{
41 QuietInteraction::QuietInteraction()
42 : m_aRequest ( )
46 void SAL_CALL QuietInteraction::handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException, std::exception )
48 // safe the request for outside analyzing every time!
49 css::uno::Any aRequest = xRequest->getRequest();
51 SolarMutexGuard g;
52 m_aRequest = aRequest;
55 // analyze the request
56 // We need XAbort as possible continuation as minimum!
57 // An optional filter selection we can handle too.
58 css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations();
59 css::uno::Reference< css::task::XInteractionAbort > xAbort;
60 css::uno::Reference< css::task::XInteractionApprove > xApprove;
61 css::uno::Reference< css::document::XInteractionFilterSelect > xFilter;
62 css::uno::Reference< css::document::XInteractionFilterOptions > xFOptions;
64 sal_Int32 nCount=lContinuations.getLength();
65 for (sal_Int32 i=0; i<nCount; ++i)
67 if ( ! xAbort.is() )
68 xAbort = css::uno::Reference< css::task::XInteractionAbort >( lContinuations[i], css::uno::UNO_QUERY );
70 if( ! xApprove.is() )
71 xApprove = css::uno::Reference< css::task::XInteractionApprove >( lContinuations[i], css::uno::UNO_QUERY );
73 if ( ! xFilter.is() )
74 xFilter = css::uno::Reference< css::document::XInteractionFilterSelect >( lContinuations[i], css::uno::UNO_QUERY );
76 if ( ! xFOptions.is() )
77 xFOptions = css::uno::Reference< css::document::XInteractionFilterOptions >( lContinuations[i], css::uno::UNO_QUERY );
80 // differ between abortable interactions (error, unknown filter ...)
81 // and other ones (ambigous but not unknown filter ...)
82 css::task::ErrorCodeRequest aErrorCodeRequest;
83 css::document::LockedDocumentRequest aLockedDocumentRequest;
84 css::document::FilterOptionsRequest aFilterOptionsRequest;
86 if( aRequest >>= aErrorCodeRequest )
88 // warnings can be ignored => approve
89 // errors must break loading => abort
90 bool bWarning = (aErrorCodeRequest.ErrCode & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK;
91 if (xApprove.is() && bWarning)
92 xApprove->select();
93 else
94 if (xAbort.is())
95 xAbort->select();
97 else
98 if( aRequest >>= aLockedDocumentRequest )
100 // the locked document should be opened readonly by default
101 if (xApprove.is())
102 xApprove->select();
103 else
104 if (xAbort.is())
105 xAbort->select();
107 else
108 if (aRequest>>=aFilterOptionsRequest)
110 if (xFOptions.is())
112 // let the default filter options be used
113 xFOptions->select();
116 else
117 if (xAbort.is())
118 xAbort->select();
121 css::uno::Any QuietInteraction::getRequest() const
123 SolarMutexGuard g;
124 return m_aRequest;
127 bool QuietInteraction::wasUsed() const
129 SolarMutexGuard g;
130 return m_aRequest.hasValue();
133 } // namespace framework
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */