LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/uui/source - iahndl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 600 1.5 %
Date: 2013-07-09 Functions: 5 32 15.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <memory>
      21             : 
      22             : #include "com/sun/star/awt/XWindow.hpp"
      23             : #include "com/sun/star/beans/PropertyValue.hpp"
      24             : #include "com/sun/star/configuration/theDefaultProvider.hpp"
      25             : #include "com/sun/star/configuration/backend/MergeRecoveryRequest.hpp"
      26             : #include "com/sun/star/configuration/backend/StratumCreationException.hpp"
      27             : #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
      28             : #include "com/sun/star/document/BrokenPackageRequest.hpp"
      29             : #include "com/sun/star/task/DocumentMacroConfirmationRequest.hpp"
      30             : #include "com/sun/star/java/WrongJavaVersionException.hpp"
      31             : #include "com/sun/star/lang/XInitialization.hpp"
      32             : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
      33             : #include "com/sun/star/script/ModuleSizeExceededRequest.hpp"
      34             : #include "com/sun/star/task/ErrorCodeIOException.hpp"
      35             : #include "com/sun/star/task/ErrorCodeRequest.hpp"
      36             : #include "com/sun/star/task/FutureDocumentVersionProductUpdateRequest.hpp"
      37             : #include "com/sun/star/task/InteractionHandler.hpp"
      38             : #include "com/sun/star/task/XInteractionAbort.hpp"
      39             : #include "com/sun/star/task/XInteractionApprove.hpp"
      40             : #include "com/sun/star/task/XInteractionAskLater.hpp"
      41             : #include "com/sun/star/task/XInteractionDisapprove.hpp"
      42             : #include "com/sun/star/task/XInteractionHandler2.hpp"
      43             : #include "com/sun/star/task/XInteractionRequest.hpp"
      44             : #include "com/sun/star/task/XInteractionRetry.hpp"
      45             : #include "com/sun/star/ucb/InteractiveAppException.hpp"
      46             : #include "com/sun/star/ucb/InteractiveLockingLockedException.hpp"
      47             : #include "com/sun/star/ucb/InteractiveLockingNotLockedException.hpp"
      48             : #include "com/sun/star/ucb/InteractiveLockingLockExpiredException.hpp"
      49             : #include "com/sun/star/ucb/InteractiveNetworkConnectException.hpp"
      50             : #include "com/sun/star/ucb/InteractiveNetworkOffLineException.hpp"
      51             : #include "com/sun/star/ucb/InteractiveNetworkReadException.hpp"
      52             : #include "com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp"
      53             : #include "com/sun/star/ucb/InteractiveNetworkWriteException.hpp"
      54             : #include "com/sun/star/ucb/InteractiveWrongMediumException.hpp"
      55             : #include "com/sun/star/ucb/NameClashException.hpp"
      56             : #include "com/sun/star/ucb/NameClashResolveRequest.hpp"
      57             : #include "com/sun/star/ucb/UnsupportedNameClashException.hpp"
      58             : #include "com/sun/star/ucb/XInteractionReplaceExistingData.hpp"
      59             : #include "com/sun/star/ucb/XInteractionSupplyName.hpp"
      60             : #include "com/sun/star/xforms/InvalidDataOnSubmitException.hpp"
      61             : #include "com/sun/star/loader/CannotActivateFactoryException.hpp"
      62             : 
      63             : #include <rtl/strbuf.hxx>
      64             : #include "osl/conditn.hxx"
      65             : #include "tools/rcid.h" // RSC_STRING
      66             : #include "tools/errinf.hxx" // ErrorHandler, ErrorContext, ...
      67             : #include "osl/mutex.hxx"
      68             : #include "tools/diagnose_ex.h"
      69             : #include "comphelper/documentconstants.hxx" // ODFVER_012_TEXT
      70             : #include "svtools/sfxecode.hxx" // ERRCODE_SFX_*
      71             : #include "vcl/msgbox.hxx"
      72             : #include "vcl/svapp.hxx"
      73             : #include "unotools/configmgr.hxx"
      74             : #include "toolkit/helper/vclunohelper.hxx"
      75             : #include "comphelper/processfactory.hxx"
      76             : #include "comphelper/namedvaluecollection.hxx"
      77             : #include "typelib/typedescription.hxx"
      78             : #include "unotools/confignode.hxx"
      79             : 
      80             : #include "ids.hrc"
      81             : 
      82             : #include "getcontinuations.hxx"
      83             : #include "secmacrowarnings.hxx"
      84             : #include "newerverwarn.hxx"
      85             : 
      86             : #include "iahndl.hxx"
      87             : #include "nameclashdlg.hxx"
      88             : 
      89             : #include <boost/scoped_ptr.hpp>
      90             : 
      91             : using ::com::sun::star::uno::Sequence;
      92             : using ::com::sun::star::uno::UNO_QUERY;
      93             : using ::com::sun::star::uno::Reference;
      94             : using ::com::sun::star::task::XInteractionContinuation;
      95             : using ::com::sun::star::task::XInteractionAbort;
      96             : using ::com::sun::star::task::XInteractionApprove;
      97             : using ::com::sun::star::task::XInteractionAskLater;
      98             : using ::com::sun::star::task::FutureDocumentVersionProductUpdateRequest;
      99             : using ::com::sun::star::uno::XInterface;
     100             : using ::com::sun::star::lang::XInitialization;
     101             : using ::com::sun::star::uno::UNO_QUERY_THROW;
     102             : using ::com::sun::star::task::InteractionHandler;
     103             : using ::com::sun::star::task::XInteractionHandler2;
     104             : using ::com::sun::star::uno::Exception;
     105             : using ::com::sun::star::uno::Any;
     106             : using ::com::sun::star::task::XInteractionRequest;
     107             : using ::com::sun::star::lang::XMultiServiceFactory;
     108             : 
     109             : using namespace ::com::sun::star;
     110             : 
     111             : namespace {
     112             : 
     113           0 : class HandleData : public osl::Condition
     114             : {
     115             : public:
     116           0 :     HandleData(
     117             :         uno::Reference< task::XInteractionRequest > const & rRequest)
     118             :         : osl::Condition(),
     119             :           m_rRequest(rRequest),
     120           0 :           bHandled( false )
     121             :     {
     122           0 :     }
     123             :     uno::Reference< task::XInteractionRequest > m_rRequest;
     124             :     bool                                        bHandled;
     125             :     beans::Optional< OUString >            m_aResult;
     126             : };
     127             : 
     128             : } /* namespace */
     129             : 
     130         425 : UUIInteractionHelper::UUIInteractionHelper(
     131             :     uno::Reference< uno::XComponentContext > const & rxContext,
     132             :     uno::Reference< awt::XWindow > const & rxWindowParam,
     133             :     const OUString & rContextParam)
     134             :     SAL_THROW(()):
     135             :         m_xContext(rxContext),
     136             :         m_xWindowParam(rxWindowParam),
     137         425 :         m_aContextParam(rContextParam)
     138             : {
     139         425 : }
     140             : 
     141         428 : UUIInteractionHelper::UUIInteractionHelper(
     142             :     uno::Reference< uno::XComponentContext > const & rxContext)
     143             :     SAL_THROW(()):
     144         428 :         m_xContext(rxContext)
     145             : {
     146         428 : }
     147             : 
     148         851 : UUIInteractionHelper::~UUIInteractionHelper()
     149             : {
     150         851 : }
     151             : 
     152             : long
     153           0 : UUIInteractionHelper::handlerequest(
     154             :     void* pHandleData, void* pInteractionHelper)
     155             : {
     156             :     HandleData* pHND
     157           0 :         = static_cast< HandleData * >(pHandleData);
     158             :     UUIInteractionHelper* pUUI
     159           0 :         = static_cast< UUIInteractionHelper * >(pInteractionHelper);
     160           0 :     bool bDummy = false;
     161           0 :     OUString aDummy;
     162             :     pHND->bHandled
     163           0 :         = pUUI->handleRequest_impl(pHND->m_rRequest, false, bDummy, aDummy);
     164           0 :     pHND->set();
     165           0 :     return 0;
     166             : }
     167             : 
     168             : bool
     169           0 : UUIInteractionHelper::handleRequest(
     170             :     uno::Reference< task::XInteractionRequest > const & rRequest)
     171             :     SAL_THROW((uno::RuntimeException))
     172             : {
     173           0 :     Application* pApp = 0;
     174           0 :     if(
     175             :         // be aware,it is the same type
     176             :         static_cast< oslThreadIdentifier >(
     177           0 :             Application::GetMainThreadIdentifier())
     178           0 :         != osl_getThreadIdentifier(NULL)
     179           0 :         &&
     180             :         (pApp = GetpApp())
     181             :         != 0
     182             :     ) {
     183             :         // we are not in the main thread, let it handle that stuff
     184           0 :         HandleData aHD(rRequest);
     185           0 :         Link aLink(&aHD,handlerequest);
     186           0 :         pApp->PostUserEvent(aLink,this);
     187           0 :         sal_uLong locks = Application::ReleaseSolarMutex();
     188           0 :         aHD.wait();
     189           0 :         Application::AcquireSolarMutex(locks);
     190           0 :         return aHD.bHandled;
     191             :     }
     192             :     else
     193             :     {
     194           0 :         bool bDummy = false;
     195           0 :         OUString aDummy;
     196           0 :         return handleRequest_impl(rRequest, false, bDummy, aDummy);
     197             :     }
     198             : }
     199             : 
     200             : long
     201           0 : UUIInteractionHelper::getstringfromrequest(
     202             :     void* pHandleData,void* pInteractionHelper)
     203             : {
     204           0 :     HandleData* pHND = (HandleData*) pHandleData;
     205           0 :     UUIInteractionHelper* pUUI = (UUIInteractionHelper*) pInteractionHelper;
     206           0 :     pHND->m_aResult = pUUI->getStringFromRequest_impl(pHND->m_rRequest);
     207           0 :     pHND->set();
     208           0 :     return 0;
     209             : }
     210             : 
     211             : beans::Optional< OUString >
     212           0 : UUIInteractionHelper::getStringFromRequest_impl(
     213             :     uno::Reference< task::XInteractionRequest > const & rRequest)
     214             :     SAL_THROW((uno::RuntimeException))
     215             : {
     216           0 :     bool bSuccess = false;
     217           0 :     OUString aMessage;
     218           0 :     handleRequest_impl(rRequest, true, bSuccess, aMessage);
     219             : 
     220             :     OSL_ENSURE(bSuccess ||
     221             :                !isInformationalErrorMessageRequest(
     222             :                    rRequest->getContinuations()),
     223             :                "Interaction request is a candidate for a string representation."
     224             :                "Please implement!");
     225             : 
     226           0 :     return beans::Optional< OUString >(bSuccess, aMessage);
     227             : }
     228             : 
     229             : beans::Optional< OUString >
     230           0 : UUIInteractionHelper::getStringFromRequest(
     231             :     uno::Reference< task::XInteractionRequest > const & rRequest)
     232             :     SAL_THROW((uno::RuntimeException))
     233             : {
     234           0 :     Application* pApp = 0;
     235           0 :     if(
     236             :         // be aware,it is the same type
     237             :         static_cast< oslThreadIdentifier >(
     238           0 :             Application::GetMainThreadIdentifier())
     239           0 :         != osl_getThreadIdentifier(NULL)
     240           0 :         &&
     241             :         (pApp = GetpApp())
     242             :         != 0
     243             :     ) {
     244             :         // we are not in the main thread, let it handle that stuff
     245           0 :         HandleData aHD(rRequest);
     246           0 :         Link aLink(&aHD,getstringfromrequest);
     247           0 :         pApp->PostUserEvent(aLink,this);
     248           0 :         sal_uLong locks = Application::ReleaseSolarMutex();
     249           0 :         aHD.wait();
     250           0 :         Application::AcquireSolarMutex(locks);
     251           0 :         return aHD.m_aResult;
     252             :     }
     253             :     else
     254           0 :         return getStringFromRequest_impl(rRequest);
     255             : }
     256             : 
     257             : OUString
     258           0 : UUIInteractionHelper::replaceMessageWithArguments(
     259             :     OUString aMessage,
     260             :     std::vector< OUString > const & rArguments )
     261             : {
     262           0 :     for (sal_Int32 i = 0;;)
     263             :     {
     264           0 :         i = aMessage.indexOf("$(ARG", i);
     265           0 :         if (i == -1)
     266           0 :             break;
     267           0 :         if (aMessage.getLength() - i >= RTL_CONSTASCII_LENGTH("$(ARGx)")
     268           0 :             && aMessage.getStr()[i + RTL_CONSTASCII_LENGTH("$(ARGx")] == ')')
     269             :         {
     270             :             sal_Unicode c
     271           0 :                 = aMessage.getStr()[i + RTL_CONSTASCII_LENGTH("$(ARG")];
     272           0 :             if (c >= '1' && c <= '2')
     273             :             {
     274             :                 std::vector< OUString >::size_type nIndex
     275             :                     = static_cast< std::vector< OUString >::size_type >(
     276           0 :                         c - '1');
     277           0 :                 if (nIndex < rArguments.size())
     278             :                 {
     279             :                     aMessage
     280           0 :                         = aMessage.replaceAt(i,
     281           0 :                                              RTL_CONSTASCII_LENGTH("$(ARGx)"),
     282           0 :                                              rArguments[nIndex]);
     283           0 :                     i += rArguments[nIndex].getLength();
     284           0 :                     continue;
     285             :                 }
     286             :             }
     287             :         }
     288           0 :         ++i;
     289           0 :     }
     290             : 
     291           0 :     return aMessage;
     292             : }
     293             : 
     294             : bool
     295           0 : UUIInteractionHelper::isInformationalErrorMessageRequest(
     296             :     uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
     297             :         rContinuations)
     298             : {
     299             :     // Only requests with a single continuation (user has no choice, request
     300             :     // is just informational)
     301           0 :     if (rContinuations.getLength() != 1 )
     302           0 :         return false;
     303             : 
     304             :     // user can only abort or approve, all other continuations are not
     305             :     // considered to be informational.
     306             :     uno::Reference< task::XInteractionApprove > xApprove(
     307           0 :         rContinuations[0], uno::UNO_QUERY);
     308           0 :     if (xApprove.is())
     309           0 :         return true;
     310             : 
     311             :     uno::Reference< task::XInteractionAbort > xAbort(
     312           0 :         rContinuations[0], uno::UNO_QUERY);
     313           0 :     if (xAbort.is())
     314           0 :         return true;
     315             : 
     316           0 :     return false;
     317             : }
     318             : 
     319             : bool
     320           0 : UUIInteractionHelper::tryOtherInteractionHandler(
     321             :     uno::Reference< task::XInteractionRequest > const & rRequest)
     322             :     SAL_THROW((uno::RuntimeException))
     323             : {
     324           0 :     InteractionHandlerDataList dataList;
     325           0 :     getInteractionHandlerList(dataList);
     326             : 
     327           0 :     InteractionHandlerDataList::const_iterator aEnd(dataList.end());
     328           0 :     for (InteractionHandlerDataList::const_iterator aIt(dataList.begin());
     329             :          aIt != aEnd;
     330             :          ++aIt)
     331             :     {
     332           0 :         if ( handleCustomRequest( rRequest, aIt->ServiceName ) )
     333           0 :             return true;
     334             :     }
     335           0 :     return false;
     336             : }
     337             : 
     338             : namespace
     339             : {
     340             :     // .................................................................................................................
     341           0 :     static bool lcl_matchesRequest( const Any& i_rRequest, const OUString& i_rTypeName, const OUString& i_rPropagation )
     342             :     {
     343           0 :         const ::com::sun::star::uno::TypeDescription aTypeDesc( i_rTypeName );
     344           0 :         const typelib_TypeDescription* pTypeDesc = aTypeDesc.get();
     345           0 :         if ( !pTypeDesc || !pTypeDesc->pWeakRef )
     346             :         {
     347             : #if OSL_DEBUG_LEVEL > 0
     348             :             OStringBuffer aMessage;
     349             :             aMessage.append( "no type found for '" );
     350             :             aMessage.append( OUStringToOString( i_rTypeName, RTL_TEXTENCODING_UTF8 ) );
     351             :             aMessage.append( "'" );
     352             :             OSL_FAIL( aMessage.makeStringAndClear().getStr() );
     353             : #endif
     354           0 :             return false;
     355             :         }
     356           0 :         const ::com::sun::star::uno::Type aType( pTypeDesc->pWeakRef );
     357             : 
     358           0 :         const bool bExactMatch = ( i_rPropagation.compareToAscii( "named-only" ) == 0 );
     359           0 :         if ( bExactMatch )
     360           0 :             return i_rRequest.getValueType().equals( aType );
     361             : 
     362           0 :         return i_rRequest.isExtractableTo( aType );
     363             :     }
     364             : }
     365             : 
     366             : // ---------------------------------------------------------------------------------------------------------------------
     367           0 : bool UUIInteractionHelper::handleCustomRequest( const Reference< XInteractionRequest >& i_rRequest, const OUString& i_rServiceName ) const
     368             : {
     369             :     try
     370             :     {
     371           0 :         Reference< XInteractionHandler2 > xHandler( m_xContext->getServiceManager()->createInstanceWithContext( i_rServiceName, m_xContext ), UNO_QUERY_THROW );
     372             : 
     373           0 :         Reference< XInitialization > xHandlerInit( xHandler, UNO_QUERY );
     374           0 :         if ( xHandlerInit.is() )
     375             :         {
     376           0 :             ::comphelper::NamedValueCollection aInitArgs;
     377           0 :             aInitArgs.put( "Parent", getParentXWindow() );
     378           0 :             xHandlerInit->initialize( aInitArgs.getWrappedPropertyValues() );
     379             :         }
     380             : 
     381           0 :         if ( xHandler->handleInteractionRequest( i_rRequest ) )
     382           0 :             return true;
     383             :     }
     384           0 :     catch( const Exception& )
     385             :     {
     386             :         DBG_UNHANDLED_EXCEPTION();
     387             :     }
     388           0 :     return false;
     389             : }
     390             : 
     391             : // ---------------------------------------------------------------------------------------------------------------------
     392           0 : bool UUIInteractionHelper::handleTypedHandlerImplementations( Reference< XInteractionRequest > const & rRequest )
     393             : {
     394             :     // the request
     395           0 :     const Any aRequest( rRequest->getRequest() );
     396             : 
     397           0 :     const StringHashMap::const_iterator aCacheHitTest = m_aTypedCustomHandlers.find( aRequest.getValueTypeName() );
     398           0 :     if ( aCacheHitTest != m_aTypedCustomHandlers.end() )
     399           0 :         return handleCustomRequest( rRequest, aCacheHitTest->second );
     400             : 
     401             :     // the base registration node for "typed" interaction handlers
     402             :     const ::utl::OConfigurationTreeRoot aConfigRoot( ::utl::OConfigurationTreeRoot::createWithComponentContext(
     403             :         m_xContext,
     404             :         OUString( "/org.openoffice.Interaction/InteractionHandlers" ),
     405             :         -1,
     406             :         ::utl::OConfigurationTreeRoot::CM_READONLY
     407           0 :     ) );
     408             : 
     409             :     // loop through all registered implementations
     410           0 :     const Sequence< OUString > aRegisteredHandlers( aConfigRoot.getNodeNames() );
     411           0 :     const OUString* pHandlerName = aRegisteredHandlers.getConstArray();
     412           0 :     const OUString* pHandlersEnd = aRegisteredHandlers.getConstArray() + aRegisteredHandlers.getLength();
     413           0 :     for ( ; pHandlerName != pHandlersEnd; ++pHandlerName )
     414             :     {
     415           0 :         const ::utl::OConfigurationNode aHandlerNode( aConfigRoot.openNode( *pHandlerName ) );
     416           0 :         const ::utl::OConfigurationNode aTypesNode( aHandlerNode.openNode( "HandledRequestTypes" ) );
     417             : 
     418             :         // loop through all the types which the current handler is registered for
     419           0 :         const Sequence< OUString > aHandledTypes( aTypesNode.getNodeNames() );
     420           0 :         const OUString* pType = aHandledTypes.getConstArray();
     421           0 :         const OUString* pTypesEnd = aHandledTypes.getConstArray() + aHandledTypes.getLength();
     422           0 :         for ( ; pType != pTypesEnd; ++pType )
     423             :         {
     424             :             // the UNO type is the node name
     425           0 :             ::utl::OConfigurationNode aType( aTypesNode.openNode( *pType ) );
     426             :             // and there's a child denoting how the responsibility propagates
     427           0 :             OUString sPropagation;
     428           0 :             OSL_VERIFY( aType.getNodeValue( "Propagation" ) >>= sPropagation );
     429           0 :             if ( lcl_matchesRequest( aRequest, *pType, sPropagation ) )
     430             :             {
     431             :                 // retrieve the service/implementation name of the handler
     432           0 :                 OUString sServiceName;
     433           0 :                 OSL_VERIFY( aHandlerNode.getNodeValue( "ServiceName" ) >>= sServiceName );
     434             :                 // cache the information who feels responsible for requests of this type
     435           0 :                 m_aTypedCustomHandlers[ aRequest.getValueTypeName() ] = sServiceName;
     436             :                 // actually handle the request
     437           0 :                 return handleCustomRequest( rRequest, sServiceName );
     438             :             }
     439           0 :         }
     440           0 :     }
     441             : 
     442           0 :     return false;
     443             : }
     444             : 
     445             : bool
     446           0 : UUIInteractionHelper::handleRequest_impl(
     447             :     uno::Reference< task::XInteractionRequest > const & rRequest,
     448             :     bool bObtainErrorStringOnly,
     449             :     bool & bHasErrorString,
     450             :     OUString & rErrorString)
     451             :     SAL_THROW((uno::RuntimeException))
     452             : {
     453             :     try
     454             :     {
     455           0 :         if (!rRequest.is())
     456           0 :             return false;
     457             : 
     458           0 :         uno::Any aAnyRequest(rRequest->getRequest());
     459             : 
     460           0 :         script::ModuleSizeExceededRequest aModSizeException;
     461           0 :         if (aAnyRequest >>= aModSizeException )
     462             :         {
     463           0 :             ErrCode nErrorCode = ERRCODE_UUI_IO_MODULESIZEEXCEEDED;
     464           0 :             std::vector< OUString > aArguments;
     465             :             uno::Sequence< OUString > sModules
     466           0 :                 = aModSizeException.Names;
     467           0 :             if ( sModules.getLength() )
     468             :             {
     469           0 :                 OUString aName;
     470           0 :                 for ( sal_Int32 index=0; index< sModules.getLength(); ++index )
     471             :                 {
     472           0 :                     if ( index )
     473           0 :                         aName = aName + OUString( ',' ) + sModules[index];
     474             :                     else
     475           0 :                         aName = sModules[index]; // 1st name
     476             :                 }
     477           0 :                 aArguments.push_back( aName );
     478             :             }
     479             :             handleErrorHandlerRequest( task::InteractionClassification_WARNING,
     480             :                                        nErrorCode,
     481             :                                        aArguments,
     482           0 :                                        rRequest->getContinuations(),
     483             :                                        bObtainErrorStringOnly,
     484             :                                        bHasErrorString,
     485           0 :                                        rErrorString);
     486           0 :             return true;
     487             :         }
     488             : 
     489           0 :         ucb::NameClashException aNCException;
     490           0 :         if (aAnyRequest >>= aNCException)
     491             :         {
     492           0 :             ErrCode nErrorCode = ERRCODE_UUI_IO_TARGETALREADYEXISTS;
     493           0 :             std::vector< OUString > aArguments;
     494             : 
     495           0 :             if( !aNCException.Name.isEmpty() )
     496             :             {
     497           0 :                 nErrorCode = ERRCODE_UUI_IO_ALREADYEXISTS;
     498           0 :                 aArguments.push_back( aNCException.Name );
     499             :             }
     500             : 
     501             :             handleErrorHandlerRequest( aNCException.Classification,
     502             :                                        nErrorCode,
     503             :                                        aArguments,
     504           0 :                                        rRequest->getContinuations(),
     505             :                                        bObtainErrorStringOnly,
     506             :                                        bHasErrorString,
     507           0 :                                        rErrorString);
     508           0 :             return true;
     509             :         }
     510             : 
     511           0 :         ucb::UnsupportedNameClashException aUORequest;
     512           0 :         if (aAnyRequest >>= aUORequest)
     513             :         {
     514           0 :             ErrCode nErrorCode = ERRCODE_UUI_IO_UNSUPPORTEDOVERWRITE;
     515           0 :             std::vector< OUString > aArguments;
     516             : 
     517           0 :             uno::Reference< task::XInteractionApprove > xApprove;
     518           0 :             uno::Reference< task::XInteractionDisapprove > xDisapprove;
     519             :             getContinuations(
     520           0 :                 rRequest->getContinuations(), &xApprove, &xDisapprove);
     521             : 
     522           0 :             if ( xApprove.is() && xDisapprove.is() )
     523             :             {
     524             :                 handleErrorHandlerRequest( task::InteractionClassification_QUERY,
     525             :                                            nErrorCode,
     526             :                                            aArguments,
     527           0 :                                            rRequest->getContinuations(),
     528             :                                            bObtainErrorStringOnly,
     529             :                                            bHasErrorString,
     530           0 :                                            rErrorString);
     531             :             }
     532           0 :             return true;
     533             :         }
     534             : 
     535           0 :         if ( handleInteractiveIOException( rRequest,
     536             :                                            bObtainErrorStringOnly,
     537             :                                            bHasErrorString,
     538           0 :                                            rErrorString ) )
     539           0 :             return true;
     540             : 
     541           0 :         ucb::InteractiveAppException aAppException;
     542           0 :         if (aAnyRequest >>= aAppException)
     543             :         {
     544           0 :             std::vector< OUString > aArguments;
     545             :             handleErrorHandlerRequest( aAppException.Classification,
     546             :                                        aAppException.Code,
     547             :                                        aArguments,
     548           0 :                                        rRequest->getContinuations(),
     549             :                                        bObtainErrorStringOnly,
     550             :                                        bHasErrorString,
     551           0 :                                        rErrorString);
     552           0 :             return true;
     553             :         }
     554             : 
     555           0 :         ucb::InteractiveNetworkException aNetworkException;
     556           0 :         if (aAnyRequest >>= aNetworkException)
     557             :         {
     558             :             ErrCode nErrorCode;
     559           0 :             std::vector< OUString > aArguments;
     560           0 :             ucb::InteractiveNetworkOffLineException aOffLineException;
     561           0 :             ucb::InteractiveNetworkResolveNameException aResolveNameException;
     562           0 :             ucb::InteractiveNetworkConnectException aConnectException;
     563           0 :             ucb::InteractiveNetworkReadException aReadException;
     564           0 :             ucb::InteractiveNetworkWriteException aWriteException;
     565           0 :             if (aAnyRequest >>= aOffLineException)
     566           0 :                 nErrorCode = ERRCODE_INET_OFFLINE;
     567           0 :             else if (aAnyRequest >>= aResolveNameException)
     568             :             {
     569           0 :                 nErrorCode = ERRCODE_INET_NAME_RESOLVE;
     570           0 :                 aArguments.push_back(aResolveNameException.Server);
     571             :             }
     572           0 :             else if (aAnyRequest >>= aConnectException)
     573             :             {
     574           0 :                 nErrorCode = ERRCODE_INET_CONNECT;
     575           0 :                 aArguments.push_back(aConnectException.Server);
     576             :             }
     577           0 :             else if (aAnyRequest >>= aReadException)
     578             :             {
     579           0 :                 nErrorCode = ERRCODE_INET_READ;
     580           0 :                 aArguments.push_back(aReadException.Diagnostic);
     581             :             }
     582           0 :             else if (aAnyRequest >>= aWriteException)
     583             :             {
     584           0 :                 nErrorCode = ERRCODE_INET_WRITE;
     585           0 :                 aArguments.push_back(aWriteException.Diagnostic);
     586             :             }
     587             :             else
     588           0 :                 nErrorCode = ERRCODE_INET_GENERAL;
     589             : 
     590             :             handleErrorHandlerRequest(aNetworkException.Classification,
     591             :                                       nErrorCode,
     592             :                                       aArguments,
     593           0 :                                       rRequest->getContinuations(),
     594             :                                       bObtainErrorStringOnly,
     595             :                                       bHasErrorString,
     596           0 :                                       rErrorString);
     597           0 :             return true;
     598             :         }
     599             : 
     600           0 :         ucb::InteractiveWrongMediumException aWrongMediumException;
     601           0 :         if (aAnyRequest >>= aWrongMediumException)
     602             :         {
     603           0 :             sal_Int32 nMedium = 0;
     604           0 :             aWrongMediumException.Medium >>= nMedium;
     605           0 :             std::vector< OUString > aArguments;
     606           0 :             aArguments.push_back(OUString::valueOf(nMedium + 1));
     607             :             handleErrorHandlerRequest(aWrongMediumException.Classification,
     608             :                                       ERRCODE_UUI_WRONGMEDIUM,
     609             :                                       aArguments,
     610           0 :                                       rRequest->getContinuations(),
     611             :                                       bObtainErrorStringOnly,
     612             :                                       bHasErrorString,
     613           0 :                                       rErrorString);
     614           0 :             return true;
     615             :         }
     616             : 
     617           0 :         java::WrongJavaVersionException aWrongJavaVersionException;
     618           0 :         if (aAnyRequest >>= aWrongJavaVersionException)
     619             :         {
     620             :             ErrCode nErrorCode;
     621           0 :             std::vector< OUString > aArguments;
     622           0 :             if (aWrongJavaVersionException.DetectedVersion.isEmpty())
     623           0 :                 if (aWrongJavaVersionException.LowestSupportedVersion.isEmpty())
     624           0 :                     nErrorCode = ERRCODE_UUI_WRONGJAVA;
     625             :                 else
     626             :                 {
     627           0 :                     nErrorCode = ERRCODE_UUI_WRONGJAVA_MIN;
     628           0 :                     aArguments.push_back(aWrongJavaVersionException.LowestSupportedVersion);
     629             :                 }
     630           0 :             else if (aWrongJavaVersionException.LowestSupportedVersion.isEmpty())
     631             :             {
     632           0 :                 nErrorCode = ERRCODE_UUI_WRONGJAVA_VERSION;
     633           0 :                 aArguments.push_back(aWrongJavaVersionException.DetectedVersion);
     634             :             }
     635             :             else
     636             :             {
     637           0 :                 nErrorCode = ERRCODE_UUI_WRONGJAVA_VERSION_MIN;
     638           0 :                 aArguments.reserve(2);
     639           0 :                 aArguments.push_back(aWrongJavaVersionException.DetectedVersion);
     640           0 :                 aArguments.push_back(aWrongJavaVersionException.LowestSupportedVersion);
     641             :             }
     642             :             handleErrorHandlerRequest(task::InteractionClassification_ERROR,
     643             :                                       nErrorCode,
     644             :                                       aArguments,
     645           0 :                                       rRequest->getContinuations(),
     646             :                                       bObtainErrorStringOnly,
     647             :                                       bHasErrorString,
     648           0 :                                       rErrorString);
     649           0 :             return true;
     650             :         }
     651             : 
     652           0 :         configuration::backend::MergeRecoveryRequest aMergeRecoveryRequest;
     653           0 :         if (aAnyRequest >>= aMergeRecoveryRequest)
     654             :         {
     655             :             ErrCode nErrorCode = aMergeRecoveryRequest.IsRemovalRequest
     656             :                 ? ERRCODE_UUI_CONFIGURATION_BROKENDATA_WITHREMOVE
     657           0 :                 : ERRCODE_UUI_CONFIGURATION_BROKENDATA_NOREMOVE;
     658             : 
     659           0 :             std::vector< OUString > aArguments;
     660           0 :             aArguments.push_back(aMergeRecoveryRequest.ErrorLayerId);
     661             : 
     662             :             handleErrorHandlerRequest(task::InteractionClassification_ERROR,
     663             :                                       nErrorCode,
     664             :                                       aArguments,
     665           0 :                                       rRequest->getContinuations(),
     666             :                                       bObtainErrorStringOnly,
     667             :                                       bHasErrorString,
     668           0 :                                       rErrorString);
     669           0 :             return true;
     670             :         }
     671             : 
     672             :         configuration::backend::StratumCreationException
     673           0 :             aStratumCreationException;
     674             : 
     675           0 :         if (aAnyRequest >>= aStratumCreationException)
     676             :         {
     677           0 :             const ErrCode nErrorCode = ERRCODE_UUI_CONFIGURATION_BACKENDMISSING;
     678             : 
     679           0 :             OUString aStratum = aStratumCreationException.StratumData;
     680           0 :             if (aStratum.isEmpty())
     681           0 :                 aStratum = aStratumCreationException.StratumService;
     682             : 
     683           0 :             std::vector< OUString > aArguments;
     684           0 :             aArguments.push_back(aStratum);
     685             : 
     686             :             handleErrorHandlerRequest(task::InteractionClassification_ERROR,
     687             :                                       nErrorCode,
     688             :                                       aArguments,
     689           0 :                                       rRequest->getContinuations(),
     690             :                                       bObtainErrorStringOnly,
     691             :                                       bHasErrorString,
     692           0 :                                       rErrorString);
     693           0 :             return true;
     694             :         }
     695             : 
     696           0 :         xforms::InvalidDataOnSubmitException aInvalidDataOnSubmitException;
     697           0 :         if (aAnyRequest >>= aInvalidDataOnSubmitException)
     698             :         {
     699             :             const ErrCode nErrorCode =
     700           0 :                 ERRCODE_UUI_INVALID_XFORMS_SUBMISSION_DATA;
     701             : 
     702           0 :             std::vector< OUString > aArguments;
     703             : 
     704             :             handleErrorHandlerRequest(task::InteractionClassification_QUERY,
     705             :                                       nErrorCode,
     706             :                                       aArguments,
     707           0 :                                       rRequest->getContinuations(),
     708             :                                       bObtainErrorStringOnly,
     709             :                                       bHasErrorString,
     710           0 :                                       rErrorString);
     711           0 :             return true;
     712             :         }
     713             : 
     714           0 :         ucb::InteractiveLockingLockedException aLLException;
     715           0 :         if (aAnyRequest >>= aLLException)
     716             :         {
     717             :             ErrCode nErrorCode = aLLException.SelfOwned
     718           0 :                 ? ERRCODE_UUI_LOCKING_LOCKED_SELF : ERRCODE_UUI_LOCKING_LOCKED;
     719           0 :             std::vector< OUString > aArguments;
     720           0 :             aArguments.push_back( aLLException.Url );
     721             : 
     722             :             handleErrorHandlerRequest( aLLException.Classification,
     723             :                                        nErrorCode,
     724             :                                        aArguments,
     725           0 :                                        rRequest->getContinuations(),
     726             :                                        bObtainErrorStringOnly,
     727             :                                        bHasErrorString,
     728           0 :                                        rErrorString );
     729           0 :             return true;
     730             :         }
     731             : 
     732           0 :         ucb::InteractiveLockingNotLockedException aLNLException;
     733           0 :         if (aAnyRequest >>= aLNLException)
     734             :         {
     735           0 :             ErrCode nErrorCode = ERRCODE_UUI_LOCKING_NOT_LOCKED;
     736           0 :             std::vector< OUString > aArguments;
     737           0 :             aArguments.push_back( aLNLException.Url );
     738             : 
     739             :             handleErrorHandlerRequest( aLNLException.Classification,
     740             :                                        nErrorCode,
     741             :                                        aArguments,
     742           0 :                                        rRequest->getContinuations(),
     743             :                                        bObtainErrorStringOnly,
     744             :                                        bHasErrorString,
     745           0 :                                        rErrorString );
     746           0 :             return true;
     747             :         }
     748             : 
     749           0 :         ucb::InteractiveLockingLockExpiredException aLLEException;
     750           0 :         if (aAnyRequest >>= aLLEException)
     751             :         {
     752           0 :             ErrCode nErrorCode = ERRCODE_UUI_LOCKING_LOCK_EXPIRED;
     753           0 :             std::vector< OUString > aArguments;
     754           0 :             aArguments.push_back( aLLEException.Url );
     755             : 
     756             :             handleErrorHandlerRequest( aLLEException.Classification,
     757             :                                        nErrorCode,
     758             :                                        aArguments,
     759           0 :                                        rRequest->getContinuations(),
     760             :                                        bObtainErrorStringOnly,
     761             :                                        bHasErrorString,
     762           0 :                                        rErrorString );
     763           0 :             return true;
     764             :         }
     765             : 
     766           0 :         document::BrokenPackageRequest aBrokenPackageRequest;
     767           0 :         if (aAnyRequest >>= aBrokenPackageRequest)
     768             :         {
     769           0 :             std::vector< OUString > aArguments;
     770             : 
     771           0 :             if( !aBrokenPackageRequest.aName.isEmpty() )
     772           0 :                 aArguments.push_back( aBrokenPackageRequest.aName );
     773             : 
     774             :             handleBrokenPackageRequest( aArguments,
     775           0 :                                         rRequest->getContinuations(),
     776             :                                         bObtainErrorStringOnly,
     777             :                                         bHasErrorString,
     778           0 :                                         rErrorString );
     779           0 :             return true;
     780             :         }
     781             : 
     782           0 :         task::ErrorCodeRequest aErrorCodeRequest;
     783           0 :         if (aAnyRequest >>= aErrorCodeRequest)
     784             :         {
     785             :             // Sucky special handling for xlsx macro filter warning
     786           0 :             if ( (sal_uInt32)ERRCODE_SFX_VBASIC_CANTSAVE_STORAGE == (sal_uInt32)aErrorCodeRequest.ErrCode)
     787             :             {
     788           0 :                 std::vector< OUString > aArguments;
     789             :                 handleErrorHandlerRequest( task::InteractionClassification_WARNING,
     790             :                                        ERRCODE_UUI_IO_WARN_CANTSAVE_MACROS,
     791             :                                        aArguments,
     792           0 :                                        rRequest->getContinuations(),
     793             :                                        bObtainErrorStringOnly,
     794             :                                        bHasErrorString,
     795           0 :                                        rErrorString);
     796             :             }
     797             :             else
     798             :             {
     799             :                 handleGenericErrorRequest( aErrorCodeRequest.ErrCode,
     800           0 :                                        rRequest->getContinuations(),
     801             :                                        bObtainErrorStringOnly,
     802             :                                        bHasErrorString,
     803           0 :                                        rErrorString);
     804             :             }
     805           0 :             return true;
     806             :         }
     807             : 
     808           0 :         task::ErrorCodeIOException aErrorCodeIOException;
     809           0 :         if (aAnyRequest >>= aErrorCodeIOException)
     810             :         {
     811             :             handleGenericErrorRequest( aErrorCodeIOException.ErrCode,
     812           0 :                                        rRequest->getContinuations(),
     813             :                                        bObtainErrorStringOnly,
     814             :                                        bHasErrorString,
     815           0 :                                        rErrorString);
     816           0 :             return true;
     817             :         }
     818             : 
     819           0 :         loader::CannotActivateFactoryException aCannotActivateFactoryException;
     820           0 :         if (aAnyRequest >>= aCannotActivateFactoryException)
     821             :         {
     822           0 :             ErrCode nErrorCode = ERRCODE_UUI_CANNOT_ACTIVATE_FACTORY;
     823           0 :             std::vector< OUString > aArguments;
     824           0 :             aArguments.push_back( aCannotActivateFactoryException.Message );
     825             : 
     826             :             handleErrorHandlerRequest( task::InteractionClassification_ERROR,
     827             :                                        nErrorCode,
     828             :                                        aArguments,
     829           0 :                                        rRequest->getContinuations(),
     830             :                                        bObtainErrorStringOnly,
     831             :                                        bHasErrorString,
     832           0 :                                        rErrorString );
     833           0 :             return true;
     834             :         }
     835             : 
     836             : 
     837             :         ///////////////////////////////////////////////////////////////////
     838             :         // Handle requests which do not have a plain string representation.
     839             :         ///////////////////////////////////////////////////////////////////
     840           0 :         if (!bObtainErrorStringOnly)
     841             :         {
     842           0 :             if ( handleAuthenticationRequest( rRequest ) )
     843           0 :                 return true;
     844             : 
     845           0 :             if ( handleCertificateValidationRequest( rRequest ) )
     846           0 :                 return true;
     847             : 
     848           0 :             ucb::NameClashResolveRequest aNameClashResolveRequest;
     849           0 :             if (aAnyRequest >>= aNameClashResolveRequest)
     850             :             {
     851             :                 handleNameClashResolveRequest(aNameClashResolveRequest,
     852           0 :                                               rRequest->getContinuations());
     853           0 :                 return true;
     854             :             }
     855             : 
     856           0 :             if ( handleMasterPasswordRequest( rRequest ) )
     857           0 :                 return true;
     858             : 
     859           0 :             if ( handlePasswordRequest( rRequest ) )
     860           0 :                 return true;
     861             : 
     862           0 :             if ( handleNoSuchFilterRequest( rRequest ) )
     863           0 :                 return true;
     864             : 
     865           0 :             if ( handleAmbigousFilterRequest( rRequest ) )
     866           0 :                 return true;
     867             : 
     868           0 :             if ( handleFilterOptionsRequest( rRequest ) )
     869           0 :                 return true;
     870             : 
     871           0 :             if ( handleLockedDocumentRequest( rRequest ) )
     872           0 :                 return true;
     873             : 
     874           0 :             if ( handleChangedByOthersRequest( rRequest ) )
     875           0 :                 return true;
     876             : 
     877           0 :             if ( handleLockFileIgnoreRequest( rRequest ) )
     878           0 :                 return true;
     879             : 
     880           0 :             task::DocumentMacroConfirmationRequest aMacroConfirmRequest;
     881           0 :             if (aAnyRequest >>= aMacroConfirmRequest)
     882             :             {
     883             :                 handleMacroConfirmRequest(
     884             :                     aMacroConfirmRequest.DocumentURL,
     885             :                     aMacroConfirmRequest.DocumentStorage,
     886           0 :                     !aMacroConfirmRequest.DocumentVersion.isEmpty() ? aMacroConfirmRequest.DocumentVersion : ODFVER_012_TEXT,
     887             :                     aMacroConfirmRequest.DocumentSignatureInformation,
     888           0 :                     rRequest->getContinuations());
     889           0 :                 return true;
     890             :             }
     891             : 
     892             :             task::FutureDocumentVersionProductUpdateRequest
     893           0 :                 aProductUpdateRequest;
     894           0 :             if (aAnyRequest >>= aProductUpdateRequest)
     895             :             {
     896             :                 handleFutureDocumentVersionUpdateRequest(
     897             :                     aProductUpdateRequest,
     898           0 :                     rRequest->getContinuations());
     899           0 :                 return true;
     900             :             }
     901             : 
     902             :             ///////////////////////////////////////////////////////////////
     903             :             // Last chance: interaction handlers registered in the configuration
     904             :             ///////////////////////////////////////////////////////////////
     905             : 
     906             :             // typed InteractionHandlers (ooo.Interactions)
     907           0 :             if ( handleTypedHandlerImplementations( rRequest ) )
     908           0 :                 return true;
     909             : 
     910             :             // legacy configuration (ooo.ucb.InteractionHandlers)
     911           0 :             if (tryOtherInteractionHandler( rRequest ))
     912           0 :                 return true;
     913             :         }
     914             : 
     915             :         // Not handled.
     916           0 :         return false;
     917             :     }
     918           0 :     catch (std::bad_alloc const &)
     919             :     {
     920             :         throw uno::RuntimeException("out of memory",
     921           0 :             uno::Reference< uno::XInterface >());
     922             :     }
     923           0 :     catch( const uno::RuntimeException& )
     924             :     {
     925           0 :         throw;  // allowed to leave here
     926             :     }
     927           0 :     catch( const uno::Exception& )
     928             :     {
     929             :         DBG_UNHANDLED_EXCEPTION();
     930             :     }
     931           0 :     return false;
     932             : }
     933             : 
     934             : void
     935           0 : UUIInteractionHelper::getInteractionHandlerList(
     936             :     InteractionHandlerDataList &rdataList)
     937             :     SAL_THROW((uno::RuntimeException))
     938             : {
     939             :     try
     940             :     {
     941             :         uno::Reference< lang::XMultiServiceFactory > xConfigProv =
     942           0 :             configuration::theDefaultProvider::get( m_xContext );
     943             : 
     944           0 :         OUStringBuffer aFullPath;
     945             :         aFullPath.appendAscii(
     946           0 :             "/org.openoffice.ucb.InteractionHandler/InteractionHandlers" );
     947             : 
     948           0 :         uno::Sequence< uno::Any > aArguments( 1 );
     949           0 :         beans::PropertyValue      aProperty;
     950           0 :         aProperty.Name = OUString( "nodepath" );
     951           0 :         aProperty.Value <<= aFullPath.makeStringAndClear();
     952           0 :         aArguments[ 0 ] <<= aProperty;
     953             : 
     954             :         uno::Reference< uno::XInterface > xInterface(
     955           0 :                 xConfigProv->createInstanceWithArguments(
     956           0 :                     "com.sun.star.configuration.ConfigurationAccess" , aArguments ) );
     957             : 
     958           0 :         if ( !xInterface.is() )
     959             :             throw uno::RuntimeException("unable to instanciate config access",
     960           0 :                 uno::Reference< uno::XInterface >());
     961             : 
     962             :         uno::Reference< container::XNameAccess > xNameAccess(
     963           0 :             xInterface, uno::UNO_QUERY );
     964           0 :         if ( !xNameAccess.is() )
     965             :             throw uno::RuntimeException(OUString(
     966             :                     "config access does not implement XNameAccess"),
     967           0 :                 uno::Reference< uno::XInterface >());
     968             : 
     969           0 :         uno::Sequence< OUString > aElems = xNameAccess->getElementNames();
     970           0 :         const OUString* pElems = aElems.getConstArray();
     971           0 :         sal_Int32 nCount = aElems.getLength();
     972             : 
     973           0 :         if ( nCount > 0 )
     974             :         {
     975             :             uno::Reference< container::XHierarchicalNameAccess >
     976           0 :                                 xHierNameAccess( xInterface, uno::UNO_QUERY );
     977             : 
     978           0 :             if ( !xHierNameAccess.is() )
     979             :                 throw uno::RuntimeException(OUString(
     980             :                     "config access does not implement XHierarchicalNameAccess"),
     981           0 :                     uno::Reference< uno::XInterface >());
     982             : 
     983             :             // Iterate over children.
     984           0 :             for ( sal_Int32 n = 0; n < nCount; ++n )
     985             :             {
     986           0 :                 OUStringBuffer aElemBuffer;
     987           0 :                 aElemBuffer.appendAscii( "['" );
     988           0 :                 aElemBuffer.append( pElems[ n ] );
     989             : 
     990             :                 try
     991             :                 {
     992           0 :                     InteractionHandlerData aInfo;
     993             : 
     994             :                     // Obtain service name.
     995           0 :                     OUStringBuffer aKeyBuffer = aElemBuffer;
     996           0 :                     aKeyBuffer.appendAscii( "']/ServiceName" );
     997             : 
     998           0 :                     OUString aValue;
     999           0 :                     if ( !( xHierNameAccess->getByHierarchicalName(
    1000           0 :                                 aKeyBuffer.makeStringAndClear() ) >>= aValue ) )
    1001             :                     {
    1002             :                         OSL_FAIL( "GetInteractionHandlerList - "
    1003             :                                     "Error getting item value!" );
    1004           0 :                         continue;
    1005             :                     }
    1006             : 
    1007           0 :                     aInfo.ServiceName = aValue;
    1008             : 
    1009             :                     // Append info to list.
    1010           0 :                     rdataList.push_back( aInfo );
    1011             :                 }
    1012           0 :                 catch ( container::NoSuchElementException& )
    1013             :                 {
    1014             :                     // getByHierarchicalName
    1015             : 
    1016             :                     OSL_FAIL( "GetInteractionHandlerList - "
    1017             :                                 "caught NoSuchElementException!" );
    1018             :                 }
    1019           0 :             }
    1020           0 :         }
    1021             :     }
    1022           0 :     catch ( uno::RuntimeException const & )
    1023             :     {
    1024           0 :         throw;
    1025             :     }
    1026           0 :     catch ( uno::Exception const & )
    1027             :     {
    1028             :         OSL_FAIL( "GetInteractionHandlerList - Caught Exception!" );
    1029             :     }
    1030           0 : }
    1031             : 
    1032             : Window *
    1033           0 : UUIInteractionHelper::getParentProperty()
    1034             :     SAL_THROW(())
    1035             : {
    1036           0 :     uno::Reference< awt::XWindow > xWindow = getParentXWindow();
    1037           0 :     if ( xWindow.is() )
    1038           0 :         return VCLUnoHelper::GetWindow(xWindow);
    1039             : 
    1040           0 :     return 0;
    1041             : }
    1042             : 
    1043             : uno::Reference< awt::XWindow>
    1044           0 : UUIInteractionHelper::getParentXWindow() const
    1045             :     SAL_THROW(())
    1046             : {
    1047           0 :     return m_xWindowParam;
    1048             : }
    1049             : 
    1050             : OUString
    1051           0 : UUIInteractionHelper::getContextProperty()
    1052             :     SAL_THROW(())
    1053             : {
    1054           0 :     return m_aContextParam;
    1055             : }
    1056             : 
    1057             : uno::Reference< task::XInteractionHandler2 >
    1058           0 : UUIInteractionHelper::getInteractionHandler()
    1059             :     SAL_THROW((uno::RuntimeException))
    1060             : {
    1061             :     return InteractionHandler::createWithParentAndContext(
    1062             :         m_xContext, m_xWindowParam,
    1063           0 :         m_aContextParam);
    1064             : }
    1065             : 
    1066             : namespace {
    1067             : 
    1068             : sal_uInt16
    1069           0 : executeMessageBox(
    1070             :     Window * pParent,
    1071             :     OUString const & rTitle,
    1072             :     OUString const & rMessage,
    1073             :     WinBits nButtonMask )
    1074             :     SAL_THROW((uno::RuntimeException))
    1075             : {
    1076           0 :     SolarMutexGuard aGuard;
    1077             : 
    1078           0 :     MessBox xBox( pParent, nButtonMask, rTitle, rMessage );
    1079             : 
    1080           0 :     sal_uInt16 aResult = xBox.Execute();
    1081           0 :     switch( aResult )
    1082             :     {
    1083             :     case RET_OK:
    1084           0 :         aResult = ERRCODE_BUTTON_OK;
    1085           0 :         break;
    1086             :     case RET_CANCEL:
    1087           0 :         aResult = ERRCODE_BUTTON_CANCEL;
    1088           0 :         break;
    1089             :     case RET_YES:
    1090           0 :         aResult = ERRCODE_BUTTON_YES;
    1091           0 :         break;
    1092             :     case RET_NO:
    1093           0 :         aResult = ERRCODE_BUTTON_NO;
    1094           0 :         break;
    1095             :     case RET_RETRY:
    1096           0 :         aResult = ERRCODE_BUTTON_RETRY;
    1097           0 :         break;
    1098             :     }
    1099             : 
    1100           0 :     return aResult;
    1101             : }
    1102             : 
    1103           0 : NameClashResolveDialogResult executeSimpleNameClashResolveDialog( Window *pParent,
    1104             :                                                                   OUString const & rTargetFolderURL,
    1105             :                                                                   OUString const & rClashingName,
    1106             :                                                                   OUString & rProposedNewName,
    1107             :                                                                   bool bAllowOverwrite )
    1108             : {
    1109           0 :     boost::scoped_ptr< ResMgr > xManager( ResMgr::CreateResMgr( "uui" ) );
    1110           0 :     if ( !xManager.get() )
    1111           0 :         return ABORT;
    1112             : 
    1113             :     NameClashDialog aDialog( pParent, xManager.get(), rTargetFolderURL,
    1114           0 :                              rClashingName, rProposedNewName, bAllowOverwrite );
    1115             : 
    1116           0 :     NameClashResolveDialogResult eResult = (NameClashResolveDialogResult) aDialog.Execute();
    1117           0 :     rProposedNewName = aDialog.getNewName();
    1118           0 :     return eResult;
    1119             : }
    1120             : 
    1121             : } // namespace
    1122             : 
    1123             : void
    1124           0 : UUIInteractionHelper::handleNameClashResolveRequest(
    1125             :     ucb::NameClashResolveRequest const & rRequest,
    1126             :     uno::Sequence< uno::Reference<
    1127             :         task::XInteractionContinuation > > const & rContinuations)
    1128             :   SAL_THROW((uno::RuntimeException))
    1129             : {
    1130             :     OSL_ENSURE(!rRequest.TargetFolderURL.isEmpty(),
    1131             :         "NameClashResolveRequest must not contain empty TargetFolderURL" );
    1132             : 
    1133             :     OSL_ENSURE(!rRequest.ClashingName.isEmpty(),
    1134             :         "NameClashResolveRequest must not contain empty ClashingName" );
    1135             : 
    1136           0 :     uno::Reference< task::XInteractionAbort > xAbort;
    1137           0 :     uno::Reference< ucb::XInteractionSupplyName > xSupplyName;
    1138           0 :     uno::Reference< ucb::XInteractionReplaceExistingData > xReplaceExistingData;
    1139             :     getContinuations(
    1140           0 :         rContinuations, &xAbort, &xSupplyName, &xReplaceExistingData);
    1141             : 
    1142             :     OSL_ENSURE( xAbort.is(),
    1143             :         "NameClashResolveRequest must contain Abort continuation" );
    1144             : 
    1145             :     OSL_ENSURE( xSupplyName.is(),
    1146             :         "NameClashResolveRequest must contain SupplyName continuation" );
    1147             : 
    1148           0 :     NameClashResolveDialogResult eResult = ABORT;
    1149           0 :     OUString aProposedNewName( rRequest.ProposedNewName );
    1150             : 
    1151             :     eResult = executeSimpleNameClashResolveDialog( getParentProperty(),
    1152             :                     rRequest.TargetFolderURL,
    1153             :                     rRequest.ClashingName,
    1154             :                     aProposedNewName,
    1155           0 :                     xReplaceExistingData.is() );
    1156             : 
    1157           0 :     switch ( eResult )
    1158             :     {
    1159             :     case ABORT:
    1160           0 :         xAbort->select();
    1161           0 :         break;
    1162             : 
    1163             :     case RENAME:
    1164           0 :         xSupplyName->setName( aProposedNewName );
    1165           0 :         xSupplyName->select();
    1166           0 :         break;
    1167             : 
    1168             :     case OVERWRITE:
    1169             :         OSL_ENSURE(
    1170             :             xReplaceExistingData.is(),
    1171             :             "Invalid NameClashResolveDialogResult: OVERWRITE - "
    1172             :             "No ReplaceExistingData continuation available!" );
    1173           0 :         xReplaceExistingData->select();
    1174           0 :         break;
    1175           0 :     }
    1176           0 : }
    1177             : 
    1178             : void
    1179           0 : UUIInteractionHelper::handleGenericErrorRequest(
    1180             :     sal_Int32 nErrorCode,
    1181             :     uno::Sequence< uno::Reference<
    1182             :         task::XInteractionContinuation > > const & rContinuations,
    1183             :     bool bObtainErrorStringOnly,
    1184             :     bool & bHasErrorString,
    1185             :     OUString & rErrorString)
    1186             :     SAL_THROW((uno::RuntimeException))
    1187             : {
    1188           0 :     if (bObtainErrorStringOnly)
    1189             :     {
    1190           0 :         bHasErrorString = isInformationalErrorMessageRequest(rContinuations);
    1191           0 :         if (bHasErrorString)
    1192             :         {
    1193           0 :             OUString aErrorString;
    1194           0 :             ErrorHandler::GetErrorString(nErrorCode, aErrorString);
    1195           0 :             rErrorString = aErrorString;
    1196             :         }
    1197             :     }
    1198             :     else
    1199             :     {
    1200           0 :         uno::Reference< task::XInteractionAbort > xAbort;
    1201           0 :         uno::Reference< task::XInteractionApprove > xApprove;
    1202           0 :         getContinuations(rContinuations, &xApprove, &xAbort);
    1203             : 
    1204             :         // Note: It's important to convert the transported long to the
    1205             :         // required  unsigned long value. Otherwhise using as flag field
    1206             :         // can fail ...
    1207           0 :         ErrCode  nError   = static_cast< ErrCode >(nErrorCode);
    1208           0 :         sal_Bool bWarning = !ERRCODE_TOERROR(nError);
    1209             : 
    1210           0 :         if ( nError == ERRCODE_SFX_BROKENSIGNATURE
    1211           0 :              || nError == ERRCODE_SFX_INCOMPLETE_ENCRYPTION )
    1212             :         {
    1213             :             // the security warning box needs a special title
    1214           0 :             OUString aErrorString;
    1215           0 :             ErrorHandler::GetErrorString( nErrorCode, aErrorString );
    1216             : 
    1217             :             boost::scoped_ptr< ResMgr > xManager(
    1218           0 :                 ResMgr::CreateResMgr( "uui" ) );
    1219           0 :             OUString aTitle( utl::ConfigManager::getProductName() );
    1220             : 
    1221             :             OUString aErrTitle
    1222             :                   = ResId( nError == ERRCODE_SFX_BROKENSIGNATURE
    1223             :                                        ? STR_WARNING_BROKENSIGNATURE_TITLE
    1224             :                                        : STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE,
    1225           0 :                                    *xManager.get() ).toString();
    1226             : 
    1227           0 :             if ( !aTitle.isEmpty() && !aErrTitle.isEmpty() )
    1228           0 :                 aTitle += " - " ;
    1229           0 :             aTitle += aErrTitle;
    1230             : 
    1231             :             executeMessageBox(
    1232           0 :                 getParentProperty(), aTitle, aErrorString, WB_OK );
    1233             :         }
    1234             :         else
    1235           0 :             ErrorHandler::HandleError(nErrorCode);
    1236             : 
    1237           0 :         if (xApprove.is() && bWarning)
    1238           0 :             xApprove->select();
    1239           0 :         else if (xAbort.is())
    1240           0 :             xAbort->select();
    1241             :     }
    1242           0 : }
    1243             : 
    1244             : void
    1245           0 : UUIInteractionHelper::handleMacroConfirmRequest(
    1246             :     const OUString& aDocumentURL,
    1247             :     const uno::Reference< embed::XStorage >& xZipStorage,
    1248             :     const OUString& aDocumentVersion,
    1249             :     const uno::Sequence< security::DocumentSignatureInformation > aSignInfo,
    1250             :     uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
    1251             :         rContinuations )
    1252             :     SAL_THROW((uno::RuntimeException))
    1253             : {
    1254           0 :     uno::Reference< task::XInteractionAbort > xAbort;
    1255           0 :     uno::Reference< task::XInteractionApprove > xApprove;
    1256           0 :     getContinuations( rContinuations, &xApprove, &xAbort );
    1257             : 
    1258           0 :     bool bApprove = false;
    1259             : 
    1260           0 :     boost::scoped_ptr< ResMgr > pResMgr( ResMgr::CreateResMgr( "uui" ) );
    1261           0 :     if ( pResMgr.get() )
    1262             :     {
    1263           0 :         bool bShowSignatures = aSignInfo.getLength() > 0;
    1264             :         MacroWarning aWarning(
    1265           0 :             getParentProperty(), bShowSignatures, *pResMgr.get() );
    1266             : 
    1267           0 :         aWarning.SetDocumentURL( aDocumentURL );
    1268           0 :         if ( aSignInfo.getLength() > 1 )
    1269             :         {
    1270           0 :             aWarning.SetStorage( xZipStorage, aDocumentVersion, aSignInfo );
    1271             :         }
    1272           0 :         else if ( aSignInfo.getLength() == 1 )
    1273             :         {
    1274           0 :             aWarning.SetCertificate( aSignInfo[ 0 ].Signer );
    1275             :         }
    1276             : 
    1277           0 :         bApprove = aWarning.Execute() == RET_OK;
    1278             :     }
    1279             : 
    1280           0 :     if ( bApprove && xApprove.is() )
    1281           0 :         xApprove->select();
    1282           0 :     else if ( xAbort.is() )
    1283           0 :         xAbort->select();
    1284           0 : }
    1285             : 
    1286             : void
    1287           0 : UUIInteractionHelper::handleFutureDocumentVersionUpdateRequest(
    1288             :     const task::FutureDocumentVersionProductUpdateRequest& _rRequest,
    1289             :     uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
    1290             :         rContinuations )
    1291             :     SAL_THROW((uno::RuntimeException))
    1292             : {
    1293           0 :     uno::Reference< task::XInteractionAbort > xAbort;
    1294           0 :     uno::Reference< task::XInteractionApprove > xApprove;
    1295           0 :     uno::Reference< task::XInteractionAskLater > xAskLater;
    1296           0 :     getContinuations( rContinuations, &xApprove, &xAbort, &xAskLater );
    1297             : 
    1298           0 :     short nResult = RET_CANCEL;
    1299             : 
    1300             :     static bool s_bDeferredToNextSession = false;
    1301             :     // TODO: this static variable is somewhat hacky. Formerly (before the dialog was moved from SFX2 to the
    1302             :     // interaction handler implementation), this was stored in SFX_APP()'s impl structure, in member
    1303             :     // bODFVersionWarningLater. Of course, we do not have access to it here.
    1304             :     //
    1305             :     // A proper solution which I would envision would be:
    1306             :     // - There's a central implementation (this one here) of css.task.InteractionHandler
    1307             :     // - There's a configuration which maps UNO names to service names
    1308             :     // - If the handler is confronted with a request, it tries to find the name of the UNO structure describing
    1309             :     //   the request in the said configuration.
    1310             :     //   - If an entry is found, then
    1311             :     //     - the respective service is instantiated
    1312             :     //     - the component is queried for css.task.XInteractionHandler, and the request is delegated
    1313             :     //   - if no entry is found, then the request is silenced (with calling the AbortContinuation, if possible)
    1314             :     // This way, the FutureDocumentVersionProductUpdateRequest could be handled in SFX (or any other
    1315             :     // suitable place), again, and we would only have one place where we remember the s_bDeferredToNextSession
    1316             :     // flag.
    1317             :     //
    1318             :     // Note: The above pattern has been implemented in CWS autorecovery. Now the remaining task is to move the
    1319             :     // handling of this interaction to SFX, again.
    1320             : 
    1321           0 :     if ( !s_bDeferredToNextSession )
    1322             :     {
    1323           0 :         boost::scoped_ptr< ResMgr > pResMgr( ResMgr::CreateResMgr( "uui" ) );
    1324           0 :         if ( pResMgr.get() )
    1325             :         {
    1326             :             ::uui::NewerVersionWarningDialog aDialog(
    1327             :                 getParentProperty(),
    1328             :                 _rRequest.DocumentODFVersion,
    1329           0 :                 *pResMgr.get() );
    1330           0 :             nResult = aDialog.Execute();
    1331           0 :         }
    1332             :     }
    1333             : 
    1334           0 :     switch ( nResult )
    1335             :     {
    1336             :     case RET_OK:
    1337           0 :         if ( xApprove.is() )
    1338           0 :             xApprove->select();
    1339           0 :         break;
    1340             :     case RET_CANCEL:
    1341           0 :         if ( xAbort.is() )
    1342           0 :             xAbort->select();
    1343           0 :         break;
    1344             :     case RET_ASK_LATER:
    1345           0 :         if ( xAskLater.is() )
    1346           0 :             xAskLater->select();
    1347           0 :         s_bDeferredToNextSession = true;
    1348           0 :         break;
    1349             :     default:
    1350             :         OSL_FAIL( "UUIInteractionHelper::handleFutureDocumentVersionUpdateRequest: "
    1351             :                     "unexpected dialog return value!" );
    1352           0 :         break;
    1353           0 :     }
    1354           0 : }
    1355             : 
    1356             : void
    1357           0 : UUIInteractionHelper::handleBrokenPackageRequest(
    1358             :     std::vector< OUString > const & rArguments,
    1359             :     uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
    1360             :         rContinuations,
    1361             :     bool bObtainErrorStringOnly,
    1362             :     bool & bHasErrorString,
    1363             :     OUString & rErrorString)
    1364             :     SAL_THROW((uno::RuntimeException))
    1365             : {
    1366           0 :     if (bObtainErrorStringOnly)
    1367             :     {
    1368           0 :         bHasErrorString = isInformationalErrorMessageRequest(rContinuations);
    1369           0 :         if (!bHasErrorString)
    1370           0 :             return;
    1371             :     }
    1372             : 
    1373           0 :     uno::Reference< task::XInteractionApprove > xApprove;
    1374           0 :     uno::Reference< task::XInteractionDisapprove > xDisapprove;
    1375           0 :     uno::Reference< task::XInteractionAbort > xAbort;
    1376           0 :     getContinuations(rContinuations, &xApprove, &xDisapprove, &xAbort);
    1377             : 
    1378             :     ErrCode nErrorCode;
    1379           0 :     if( xApprove.is() && xDisapprove.is() )
    1380             :     {
    1381           0 :         nErrorCode = ERRCODE_UUI_IO_BROKENPACKAGE;
    1382             :     }
    1383           0 :     else if ( xAbort.is() )
    1384             :     {
    1385           0 :         nErrorCode = ERRCODE_UUI_IO_BROKENPACKAGE_CANTREPAIR;
    1386             :     }
    1387             :     else
    1388           0 :         return;
    1389             : 
    1390           0 :     OUString aMessage;
    1391             :     {
    1392           0 :         SolarMutexGuard aGuard;
    1393           0 :         boost::scoped_ptr< ResMgr > xManager(ResMgr::CreateResMgr("uui"));
    1394           0 :         if (!xManager.get())
    1395           0 :             return;
    1396             : 
    1397           0 :         ResId aResId( RID_UUI_ERRHDL, *xManager.get() );
    1398           0 :         if ( !ErrorResource(aResId).getString(nErrorCode, aMessage) )
    1399           0 :             return;
    1400             :     }
    1401             : 
    1402           0 :     aMessage = replaceMessageWithArguments( aMessage, rArguments );
    1403             : 
    1404           0 :     if (bObtainErrorStringOnly)
    1405             :     {
    1406           0 :         rErrorString = aMessage;
    1407           0 :         return;
    1408             :     }
    1409             : 
    1410             :     WinBits nButtonMask;
    1411           0 :     if( xApprove.is() && xDisapprove.is() )
    1412             :     {
    1413           0 :         nButtonMask = WB_YES_NO | WB_DEF_YES;
    1414             :     }
    1415           0 :     else if ( xAbort.is() )
    1416             :     {
    1417           0 :         nButtonMask = WB_OK;
    1418             :     }
    1419             :     else
    1420           0 :         return;
    1421             : 
    1422             :     OUString title(
    1423           0 :         utl::ConfigManager::getProductName() +
    1424           0 :         OUString( " " ) +
    1425           0 :         utl::ConfigManager::getProductVersion() );
    1426             : 
    1427           0 :     switch (
    1428           0 :         executeMessageBox( getParentProperty(), title, aMessage, nButtonMask ) )
    1429             :     {
    1430             :     case ERRCODE_BUTTON_OK:
    1431             :         OSL_ENSURE( xAbort.is(), "unexpected situation" );
    1432           0 :         if (xAbort.is())
    1433           0 :             xAbort->select();
    1434           0 :         break;
    1435             : 
    1436             :     case ERRCODE_BUTTON_NO:
    1437             :         OSL_ENSURE(xDisapprove.is(), "unexpected situation");
    1438           0 :         if (xDisapprove.is())
    1439           0 :             xDisapprove->select();
    1440           0 :         break;
    1441             : 
    1442             :     case ERRCODE_BUTTON_YES:
    1443             :         OSL_ENSURE(xApprove.is(), "unexpected situation");
    1444           0 :         if (xApprove.is())
    1445           0 :             xApprove->select();
    1446           0 :         break;
    1447           0 :     }
    1448             : }
    1449             : 
    1450             : //=========================================================================
    1451             : // ErrorResource Implementation
    1452             : //=========================================================================
    1453             : 
    1454             : bool
    1455           0 : ErrorResource::getString(ErrCode nErrorCode, OUString &rString)
    1456             :     const SAL_THROW(())
    1457             : {
    1458             :     ResId aResId(static_cast< sal_uInt16 >(nErrorCode & ERRCODE_RES_MASK),
    1459           0 :                  *m_pResMgr);
    1460           0 :     aResId.SetRT(RSC_STRING);
    1461           0 :     if (!IsAvailableRes(aResId))
    1462           0 :         return false;
    1463           0 :     aResId.SetAutoRelease(false);
    1464           0 :     rString = aResId.toString();
    1465           0 :     m_pResMgr->PopContext();
    1466           0 :     return true;
    1467          36 : }
    1468             : 
    1469             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10