LCOV - code coverage report
Current view: top level - libreoffice/comphelper/source/misc - docpasswordrequest.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 74 0.0 %
Date: 2012-12-27 Functions: 0 37 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             : 
      21             : #include "comphelper/docpasswordrequest.hxx"
      22             : #include <com/sun/star/task/DocumentMSPasswordRequest2.hpp>
      23             : #include <com/sun/star/task/DocumentPasswordRequest2.hpp>
      24             : #include <com/sun/star/task/PasswordRequest.hpp>
      25             : #include <com/sun/star/task/XInteractionAbort.hpp>
      26             : #include <com/sun/star/task/XInteractionPassword2.hpp>
      27             : 
      28             : using ::rtl::OUString;
      29             : using ::com::sun::star::uno::Any;
      30             : using ::com::sun::star::uno::Type;
      31             : using ::com::sun::star::uno::Reference;
      32             : using ::com::sun::star::uno::RuntimeException;
      33             : using ::com::sun::star::uno::Sequence;
      34             : using ::com::sun::star::uno::XInterface;
      35             : using ::com::sun::star::task::InteractionClassification_QUERY;
      36             : using ::com::sun::star::task::DocumentMSPasswordRequest2;
      37             : using ::com::sun::star::task::DocumentPasswordRequest2;
      38             : using ::com::sun::star::task::PasswordRequest;
      39             : using ::com::sun::star::task::PasswordRequestMode;
      40             : using ::com::sun::star::task::XInteractionAbort;
      41             : using ::com::sun::star::task::XInteractionContinuation;
      42             : using ::com::sun::star::task::XInteractionPassword2;
      43             : using ::com::sun::star::task::XInteractionRequest;
      44             : 
      45             : namespace comphelper {
      46             : 
      47             : // ============================================================================
      48             : 
      49           0 : class AbortContinuation : public ::cppu::WeakImplHelper1< XInteractionAbort >
      50             : {
      51             : public:
      52           0 :     inline explicit     AbortContinuation() : mbSelected( false ) {}
      53             : 
      54             :     inline sal_Bool     isSelected() const { return mbSelected; }
      55             :     inline void         reset() { mbSelected = false; }
      56             : 
      57           0 :     virtual void SAL_CALL select() throw( RuntimeException ) { mbSelected = true; }
      58             : 
      59             : private:
      60             :     sal_Bool            mbSelected;
      61             : };
      62             : 
      63             : // ============================================================================
      64             : 
      65           0 : class PasswordContinuation : public ::cppu::WeakImplHelper1< XInteractionPassword2 >
      66             : {
      67             : public:
      68           0 :     inline explicit     PasswordContinuation() : mbReadOnly( sal_False ), mbSelected( sal_False ) {}
      69             : 
      70           0 :     inline sal_Bool     isSelected() const { return mbSelected; }
      71             :     inline void         reset() { mbSelected = sal_False; }
      72             : 
      73           0 :     virtual void SAL_CALL select() throw( RuntimeException ) { mbSelected = sal_True; }
      74             : 
      75           0 :     virtual void SAL_CALL setPassword( const OUString& rPass ) throw( RuntimeException ) { maPassword = rPass; }
      76           0 :     virtual OUString SAL_CALL getPassword() throw( RuntimeException ) { return maPassword; }
      77             : 
      78           0 :     virtual void SAL_CALL setPasswordToModify( const OUString& rPass ) throw( RuntimeException ) { maModifyPassword = rPass; }
      79           0 :     virtual OUString SAL_CALL getPasswordToModify() throw( RuntimeException ) { return maModifyPassword; }
      80             : 
      81           0 :     virtual void SAL_CALL setRecommendReadOnly( sal_Bool bReadOnly ) throw( RuntimeException ) { mbReadOnly = bReadOnly; }
      82           0 :     virtual sal_Bool SAL_CALL getRecommendReadOnly() throw( RuntimeException ) { return mbReadOnly; }
      83             : 
      84             : private:
      85             :     OUString            maPassword;
      86             :     OUString            maModifyPassword;
      87             :     sal_Bool            mbReadOnly;
      88             :     sal_Bool            mbSelected;
      89             : };
      90             : 
      91             : // ============================================================================
      92             : 
      93           0 : SimplePasswordRequest::SimplePasswordRequest( PasswordRequestMode eMode )
      94             : : mpAbort( NULL )
      95           0 : , mpPassword( NULL )
      96             : {
      97             :     PasswordRequest aRequest( OUString(), Reference< XInterface >(),
      98           0 :         InteractionClassification_QUERY, eMode );
      99           0 :     maRequest <<= aRequest;
     100             : 
     101           0 :     maContinuations.realloc( 2 );
     102           0 :     maContinuations[ 0 ].set( mpAbort = new AbortContinuation );
     103           0 :     maContinuations[ 1 ].set( mpPassword = new PasswordContinuation );
     104           0 : }
     105             : 
     106           0 : SimplePasswordRequest::~SimplePasswordRequest()
     107             : {
     108           0 : }
     109             : 
     110           0 : /*uno::*/Any SAL_CALL SimplePasswordRequest::queryInterface( const /*uno::*/Type& rType ) throw (RuntimeException)
     111             : {
     112             :     return ::cppu::queryInterface ( rType,
     113             :             // OWeakObject interfaces
     114             :             dynamic_cast< XInterface* > ( (XInteractionRequest *) this ),
     115             :             static_cast< XWeak* > ( this ),
     116             :             // my own interfaces
     117           0 :             static_cast< XInteractionRequest*  > ( this ) );
     118             : }
     119             : 
     120           0 : void SAL_CALL SimplePasswordRequest::acquire(  ) throw ()
     121             : {
     122           0 :     OWeakObject::acquire();
     123           0 : }
     124             : 
     125           0 : void SAL_CALL SimplePasswordRequest::release(  ) throw ()
     126             : {
     127           0 :     OWeakObject::release();
     128           0 : }
     129             : 
     130           0 : sal_Bool SimplePasswordRequest::isPassword() const
     131             : {
     132           0 :     return mpPassword->isSelected();
     133             : }
     134             : 
     135           0 : OUString SimplePasswordRequest::getPassword() const
     136             : {
     137           0 :     return mpPassword->getPassword();
     138             : }
     139             : 
     140           0 : Any SAL_CALL SimplePasswordRequest::getRequest() throw( RuntimeException )
     141             : {
     142           0 :     return maRequest;
     143             : }
     144             : 
     145           0 : Sequence< Reference< XInteractionContinuation > > SAL_CALL SimplePasswordRequest::getContinuations() throw( RuntimeException )
     146             : {
     147           0 :     return maContinuations;
     148             : }
     149             : 
     150             : // ============================================================================
     151             : 
     152           0 : DocPasswordRequest::DocPasswordRequest( DocPasswordRequestType eType,
     153             :         PasswordRequestMode eMode, const OUString& rDocumentName, sal_Bool bPasswordToModify )
     154             : : mpAbort( NULL )
     155           0 : , mpPassword( NULL )
     156             : {
     157           0 :     switch( eType )
     158             :     {
     159             :         case DocPasswordRequestType_STANDARD:
     160             :         {
     161             :             DocumentPasswordRequest2 aRequest( OUString(), Reference< XInterface >(),
     162           0 :                 InteractionClassification_QUERY, eMode, rDocumentName, bPasswordToModify );
     163           0 :             maRequest <<= aRequest;
     164             :         }
     165           0 :         break;
     166             :         case DocPasswordRequestType_MS:
     167             :         {
     168             :             DocumentMSPasswordRequest2 aRequest( OUString(), Reference< XInterface >(),
     169           0 :                 InteractionClassification_QUERY, eMode, rDocumentName, bPasswordToModify );
     170           0 :             maRequest <<= aRequest;
     171             :         }
     172           0 :         break;
     173             :         /*  no 'default', so compilers will complain about missing
     174             :             implementation of a new enum value. */
     175             :     }
     176             : 
     177           0 :     maContinuations.realloc( 2 );
     178           0 :     maContinuations[ 0 ].set( mpAbort = new AbortContinuation );
     179           0 :     maContinuations[ 1 ].set( mpPassword = new PasswordContinuation );
     180           0 : }
     181             : 
     182           0 : DocPasswordRequest::~DocPasswordRequest()
     183             : {
     184           0 : }
     185             : 
     186           0 : /*uno::*/Any SAL_CALL DocPasswordRequest::queryInterface( const /*uno::*/Type& rType ) throw (RuntimeException)
     187             : {
     188             :     return ::cppu::queryInterface ( rType,
     189             :             // OWeakObject interfaces
     190             :             dynamic_cast< XInterface* > ( (XInteractionRequest *) this ),
     191             :             static_cast< XWeak* > ( this ),
     192             :             // my own interfaces
     193           0 :             static_cast< XInteractionRequest*  > ( this ) );
     194             : }
     195             : 
     196           0 : void SAL_CALL DocPasswordRequest::acquire(  ) throw ()
     197             : {
     198           0 :     OWeakObject::acquire();
     199           0 : }
     200             : 
     201           0 : void SAL_CALL DocPasswordRequest::release(  ) throw ()
     202             : {
     203           0 :     OWeakObject::release();
     204           0 : }
     205             : 
     206           0 : sal_Bool DocPasswordRequest::isPassword() const
     207             : {
     208           0 :     return mpPassword->isSelected();
     209             : }
     210             : 
     211           0 : OUString DocPasswordRequest::getPassword() const
     212             : {
     213           0 :     return mpPassword->getPassword();
     214             : }
     215             : 
     216           0 : OUString DocPasswordRequest::getPasswordToModify() const
     217             : {
     218           0 :     return mpPassword->getPasswordToModify();
     219             : }
     220             : 
     221           0 : sal_Bool DocPasswordRequest::getRecommendReadOnly() const
     222             : {
     223           0 :     return mpPassword->getRecommendReadOnly();
     224             : }
     225             : 
     226           0 : Any SAL_CALL DocPasswordRequest::getRequest() throw( RuntimeException )
     227             : {
     228           0 :     return maRequest;
     229             : }
     230             : 
     231           0 : Sequence< Reference< XInteractionContinuation > > SAL_CALL DocPasswordRequest::getContinuations() throw( RuntimeException )
     232             : {
     233           0 :     return maContinuations;
     234             : }
     235             : 
     236             : // ============================================================================
     237             : 
     238             : } // namespace comphelper
     239             : 
     240             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10