LCOV - code coverage report
Current view: top level - comphelper/source/misc - docpasswordrequest.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 58 0.0 %
Date: 2014-11-03 Functions: 0 31 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 ::com::sun::star::uno::Any;
      29             : using ::com::sun::star::uno::Type;
      30             : using ::com::sun::star::uno::Reference;
      31             : using ::com::sun::star::uno::RuntimeException;
      32             : using ::com::sun::star::uno::Sequence;
      33             : using ::com::sun::star::uno::XInterface;
      34             : using ::com::sun::star::task::InteractionClassification_QUERY;
      35             : using ::com::sun::star::task::DocumentMSPasswordRequest2;
      36             : using ::com::sun::star::task::DocumentPasswordRequest2;
      37             : using ::com::sun::star::task::PasswordRequest;
      38             : using ::com::sun::star::task::PasswordRequestMode;
      39             : using ::com::sun::star::task::XInteractionAbort;
      40             : using ::com::sun::star::task::XInteractionContinuation;
      41             : using ::com::sun::star::task::XInteractionPassword2;
      42             : using ::com::sun::star::task::XInteractionRequest;
      43             : 
      44             : namespace comphelper {
      45             : 
      46             : 
      47             : 
      48           0 : class AbortContinuation : public ::cppu::WeakImplHelper1< XInteractionAbort >
      49             : {
      50             : public:
      51           0 :     virtual void SAL_CALL select() throw( RuntimeException, std::exception ) SAL_OVERRIDE {}
      52             : };
      53             : 
      54             : 
      55             : 
      56           0 : class PasswordContinuation : public ::cppu::WeakImplHelper1< XInteractionPassword2 >
      57             : {
      58             : public:
      59           0 :     inline explicit     PasswordContinuation() : mbReadOnly( false ), mbSelected( false ) {}
      60             : 
      61           0 :     inline bool     isSelected() const { return mbSelected; }
      62             : 
      63           0 :     virtual void SAL_CALL select() throw( RuntimeException, std::exception ) SAL_OVERRIDE { mbSelected = true; }
      64             : 
      65           0 :     virtual void SAL_CALL setPassword( const OUString& rPass ) throw( RuntimeException, std::exception ) SAL_OVERRIDE { maPassword = rPass; }
      66           0 :     virtual OUString SAL_CALL getPassword() throw( RuntimeException, std::exception ) SAL_OVERRIDE { return maPassword; }
      67             : 
      68           0 :     virtual void SAL_CALL setPasswordToModify( const OUString& rPass ) throw( RuntimeException, std::exception ) SAL_OVERRIDE { maModifyPassword = rPass; }
      69           0 :     virtual OUString SAL_CALL getPasswordToModify() throw( RuntimeException, std::exception ) SAL_OVERRIDE { return maModifyPassword; }
      70             : 
      71           0 :     virtual void SAL_CALL setRecommendReadOnly( sal_Bool bReadOnly ) throw( RuntimeException, std::exception ) SAL_OVERRIDE { mbReadOnly = bReadOnly; }
      72           0 :     virtual sal_Bool SAL_CALL getRecommendReadOnly() throw( RuntimeException, std::exception ) SAL_OVERRIDE { return mbReadOnly; }
      73             : 
      74             : private:
      75             :     OUString            maPassword;
      76             :     OUString            maModifyPassword;
      77             :     bool            mbReadOnly;
      78             :     bool            mbSelected;
      79             : };
      80             : 
      81             : 
      82             : 
      83           0 : SimplePasswordRequest::SimplePasswordRequest( PasswordRequestMode eMode )
      84             : {
      85             :     PasswordRequest aRequest( OUString(), Reference< XInterface >(),
      86           0 :         InteractionClassification_QUERY, eMode );
      87           0 :     maRequest <<= aRequest;
      88             : 
      89           0 :     maContinuations.realloc( 2 );
      90           0 :     maContinuations[ 0 ].set( new AbortContinuation );
      91           0 :     mpPassword = new PasswordContinuation;
      92           0 :     maContinuations[ 1 ].set( mpPassword );
      93           0 : }
      94             : 
      95           0 : SimplePasswordRequest::~SimplePasswordRequest()
      96             : {
      97           0 : }
      98             : 
      99           0 : bool SimplePasswordRequest::isPassword() const
     100             : {
     101           0 :     return mpPassword->isSelected();
     102             : }
     103             : 
     104           0 : OUString SimplePasswordRequest::getPassword() const
     105             : {
     106           0 :     return mpPassword->getPassword();
     107             : }
     108             : 
     109           0 : Any SAL_CALL SimplePasswordRequest::getRequest() throw( RuntimeException, std::exception )
     110             : {
     111           0 :     return maRequest;
     112             : }
     113             : 
     114           0 : Sequence< Reference< XInteractionContinuation > > SAL_CALL SimplePasswordRequest::getContinuations() throw( RuntimeException, std::exception )
     115             : {
     116           0 :     return maContinuations;
     117             : }
     118             : 
     119             : 
     120             : 
     121           0 : DocPasswordRequest::DocPasswordRequest( DocPasswordRequestType eType,
     122           0 :         PasswordRequestMode eMode, const OUString& rDocumentName, bool bPasswordToModify )
     123             : {
     124           0 :     switch( eType )
     125             :     {
     126             :         case DocPasswordRequestType_STANDARD:
     127             :         {
     128             :             DocumentPasswordRequest2 aRequest( OUString(), Reference< XInterface >(),
     129           0 :                 InteractionClassification_QUERY, eMode, rDocumentName, bPasswordToModify );
     130           0 :             maRequest <<= aRequest;
     131             :         }
     132           0 :         break;
     133             :         case DocPasswordRequestType_MS:
     134             :         {
     135             :             DocumentMSPasswordRequest2 aRequest( OUString(), Reference< XInterface >(),
     136           0 :                 InteractionClassification_QUERY, eMode, rDocumentName, bPasswordToModify );
     137           0 :             maRequest <<= aRequest;
     138             :         }
     139           0 :         break;
     140             :         /*  no 'default', so compilers will complain about missing
     141             :             implementation of a new enum value. */
     142             :     }
     143             : 
     144           0 :     maContinuations.realloc( 2 );
     145           0 :     maContinuations[ 0 ].set( new AbortContinuation );
     146           0 :     mpPassword = new PasswordContinuation;
     147           0 :     maContinuations[ 1 ].set( mpPassword );
     148           0 : }
     149             : 
     150           0 : DocPasswordRequest::~DocPasswordRequest()
     151             : {
     152           0 : }
     153             : 
     154           0 : bool DocPasswordRequest::isPassword() const
     155             : {
     156           0 :     return mpPassword->isSelected();
     157             : }
     158             : 
     159           0 : OUString DocPasswordRequest::getPassword() const
     160             : {
     161           0 :     return mpPassword->getPassword();
     162             : }
     163             : 
     164           0 : OUString DocPasswordRequest::getPasswordToModify() const
     165             : {
     166           0 :     return mpPassword->getPasswordToModify();
     167             : }
     168             : 
     169           0 : bool DocPasswordRequest::getRecommendReadOnly() const
     170             : {
     171           0 :     return mpPassword->getRecommendReadOnly();
     172             : }
     173             : 
     174           0 : Any SAL_CALL DocPasswordRequest::getRequest() throw( RuntimeException, std::exception )
     175             : {
     176           0 :     return maRequest;
     177             : }
     178             : 
     179           0 : Sequence< Reference< XInteractionContinuation > > SAL_CALL DocPasswordRequest::getContinuations() throw( RuntimeException, std::exception )
     180             : {
     181           0 :     return maContinuations;
     182             : }
     183             : 
     184             : 
     185             : 
     186             : } // namespace comphelper
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10