LCOV - code coverage report
Current view: top level - ucbhelper/source/provider - simplenameclashresolverequest.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 50 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 15 0.0 %
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 <com/sun/star/ucb/NameClashResolveRequest.hpp>
      21             : #include <com/sun/star/ucb/XInteractionSupplyName.hpp>
      22             : #include <cppuhelper/typeprovider.hxx>
      23             : #include <cppuhelper/queryinterface.hxx>
      24             : #include <ucbhelper/simplenameclashresolverequest.hxx>
      25             : 
      26             : using namespace com::sun::star;
      27             : 
      28             : namespace ucbhelper {
      29             : 
      30             : /**
      31             :   * This class implements a standard interaction continuation, namely the
      32             :   * interface XInteractionSupplyName. Instances of this class can be passed
      33             :   * along with an interaction request to indicate the possibility to
      34             :   * supply a new name.
      35             :   */
      36           0 : class InteractionSupplyName : public InteractionContinuation,
      37             :                               public com::sun::star::lang::XTypeProvider,
      38             :                               public com::sun::star::ucb::XInteractionSupplyName
      39             : {
      40             :     OUString m_aName;
      41             : 
      42             : public:
      43           0 :     explicit InteractionSupplyName( InteractionRequest * pRequest )
      44           0 :     : InteractionContinuation( pRequest ) {}
      45             : 
      46             :     // XInterface
      47             :     virtual com::sun::star::uno::Any SAL_CALL
      48             :     queryInterface( const com::sun::star::uno::Type & rType )
      49             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      50             :     virtual void SAL_CALL acquire()
      51             :         throw() SAL_OVERRIDE;
      52             :     virtual void SAL_CALL release()
      53             :         throw() SAL_OVERRIDE;
      54             : 
      55             :     // XTypeProvider
      56             :     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL
      57             :     getTypes()
      58             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      59             :     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
      60             :     getImplementationId()
      61             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      62             : 
      63             :     // XInteractionContinuation
      64             :     virtual void SAL_CALL select()
      65             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      66             : 
      67             :     // XInteractionSupplyName
      68             :     virtual void SAL_CALL setName( const OUString& Name )
      69             :         throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      70             : 
      71             :     // Non-interface methods.
      72             : 
      73             :     /**
      74             :       * This method returns the name that was supplied by the interaction
      75             :       * handler.
      76             :       *
      77             :       * @return the name.
      78             :       */
      79           0 :     const OUString & getName() const { return m_aName; }
      80             : };
      81             : 
      82           0 : void SAL_CALL InteractionSupplyName::acquire()
      83             :     throw()
      84             : {
      85           0 :     OWeakObject::acquire();
      86           0 : }
      87             : 
      88           0 : void SAL_CALL InteractionSupplyName::release()
      89             :     throw()
      90             : {
      91           0 :     OWeakObject::release();
      92           0 : }
      93             : 
      94             : uno::Any SAL_CALL
      95           0 : InteractionSupplyName::queryInterface( const uno::Type & rType )
      96             :     throw ( uno::RuntimeException, std::exception )
      97             : {
      98             :     uno::Any aRet = cppu::queryInterface( rType,
      99             :                 static_cast< lang::XTypeProvider * >( this ),
     100             :                 static_cast< task::XInteractionContinuation * >( this ),
     101           0 :                 static_cast< ucb::XInteractionSupplyName * >( this ) );
     102             : 
     103           0 :     return aRet.hasValue()
     104           0 :             ? aRet : InteractionContinuation::queryInterface( rType );
     105             : }
     106             : 
     107           0 : uno::Sequence< sal_Int8 > SAL_CALL InteractionSupplyName::getImplementationId()
     108             :     throw( uno::RuntimeException, std::exception )
     109             : {
     110           0 :     return css::uno::Sequence<sal_Int8>();
     111             : }
     112             : 
     113           0 : uno::Sequence< uno::Type > SAL_CALL InteractionSupplyName::getTypes()
     114             :     throw( uno::RuntimeException, std::exception )
     115             : {
     116             :     static cppu::OTypeCollection* pCollection = 0;
     117           0 :       if ( !pCollection )
     118             :       {
     119           0 :         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
     120           0 :         if ( !pCollection )
     121             :         {
     122             :             static cppu::OTypeCollection collection(
     123           0 :                 cppu::UnoType<lang::XTypeProvider>::get(),
     124           0 :                 cppu::UnoType<ucb::XInteractionSupplyName>::get() );
     125           0 :             pCollection = &collection;
     126           0 :         }
     127             :     }
     128           0 :     return (*pCollection).getTypes();
     129             : }
     130             : 
     131           0 : void SAL_CALL InteractionSupplyName::select()
     132             :     throw( uno::RuntimeException, std::exception )
     133             : {
     134           0 :     recordSelection();
     135           0 : }
     136             : 
     137             : void SAL_CALL
     138           0 : InteractionSupplyName::setName( const OUString& Name )
     139             :     throw( uno::RuntimeException, std::exception )
     140             : {
     141           0 :     m_aName = Name;
     142           0 : }
     143             : 
     144           0 : SimpleNameClashResolveRequest::~SimpleNameClashResolveRequest() {}
     145             : 
     146           0 : SimpleNameClashResolveRequest::SimpleNameClashResolveRequest(
     147             :                                     const OUString & rTargetFolderURL,
     148             :                                     const OUString & rClashingName,
     149             :                                     const OUString & rProposedNewName,
     150           0 :                                     bool bSupportsOverwriteData )
     151             : {
     152             :     // Fill request...
     153           0 :     ucb::NameClashResolveRequest aRequest;
     154             : //    aRequest.Message        = // OUString
     155             : //    aRequest.Context        = // XInterface
     156           0 :     aRequest.Classification  = task::InteractionClassification_QUERY;
     157           0 :     aRequest.TargetFolderURL = rTargetFolderURL;
     158           0 :     aRequest.ClashingName    = rClashingName;
     159           0 :     aRequest.ProposedNewName = rProposedNewName;
     160             : 
     161           0 :     setRequest( uno::makeAny( aRequest ) );
     162             : 
     163             :     // Fill continuations...
     164           0 :     m_xNameSupplier = new InteractionSupplyName( this );
     165             : 
     166             :     uno::Sequence< uno::Reference< task::XInteractionContinuation > >
     167           0 :                             aContinuations( bSupportsOverwriteData ? 3 : 2 );
     168           0 :     aContinuations[ 0 ] = new InteractionAbort( this );
     169           0 :     aContinuations[ 1 ] = m_xNameSupplier.get();
     170             : 
     171           0 :     if ( bSupportsOverwriteData )
     172           0 :         aContinuations[ 2 ] = new InteractionReplaceExistingData( this );
     173             : 
     174           0 :     setContinuations( aContinuations );
     175           0 : }
     176             : 
     177           0 : const OUString SimpleNameClashResolveRequest::getNewName() const
     178             : {
     179           0 :     return m_xNameSupplier->getName();
     180             : }
     181             : 
     182             : }
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11