LCOV - code coverage report
Current view: top level - sdext/source/pdfimport/misc - pwdinteract.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 38 0.0 %
Date: 2012-08-25 Functions: 0 10 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 62 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "pdfihelper.hxx"
      31                 :            : 
      32                 :            : #include <com/sun/star/task/XInteractionHandler.hpp>
      33                 :            : #include <com/sun/star/task/XInteractionRequest.hpp>
      34                 :            : #include <com/sun/star/task/XInteractionPassword.hpp>
      35                 :            : #include <com/sun/star/task/DocumentPasswordRequest.hpp>
      36                 :            : 
      37                 :            : #include <cppuhelper/exc_hlp.hxx>
      38                 :            : #include <cppuhelper/compbase2.hxx>
      39                 :            : #include <cppuhelper/basemutex.hxx>
      40                 :            : 
      41                 :            : 
      42                 :            : using namespace com::sun::star;
      43                 :            : 
      44                 :            : namespace
      45                 :            : {
      46                 :            : 
      47                 :            : typedef ::cppu::WeakComponentImplHelper2<
      48                 :            :     com::sun::star::task::XInteractionRequest,
      49                 :            :     com::sun::star::task::XInteractionPassword > PDFPasswordRequestBase;
      50                 :            : 
      51 [ #  # ][ #  # ]:          0 : class PDFPasswordRequest : private cppu::BaseMutex,
                 [ #  # ]
      52                 :            :                            public PDFPasswordRequestBase
      53                 :            : {
      54                 :            : private:
      55                 :            :     task::DocumentPasswordRequest m_aRequest;
      56                 :            :     rtl::OUString                 m_aPassword;
      57                 :            :     bool                          m_bSelected;
      58                 :            : 
      59                 :            : public:
      60                 :            :     explicit PDFPasswordRequest(bool bFirstTry, const rtl::OUString& rName);
      61                 :            : 
      62                 :            :     // XInteractionRequest
      63                 :            :     virtual uno::Any SAL_CALL getRequest(  ) throw (uno::RuntimeException);
      64                 :            :     virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations(  ) throw (uno::RuntimeException);
      65                 :            : 
      66                 :            :     // XInteractionPassword
      67                 :            :     virtual void SAL_CALL setPassword( const rtl::OUString& rPwd ) throw (uno::RuntimeException);
      68                 :            :     virtual rtl::OUString SAL_CALL getPassword() throw (uno::RuntimeException);
      69                 :            : 
      70                 :            :     // XInteractionContinuation
      71                 :            :     virtual void SAL_CALL select() throw (uno::RuntimeException);
      72                 :            : 
      73 [ #  # ][ #  # ]:          0 :     bool isSelected() const { osl::MutexGuard const guard( m_aMutex ); return m_bSelected; }
      74                 :            : };
      75                 :            : 
      76                 :          0 : PDFPasswordRequest::PDFPasswordRequest( bool bFirstTry, const rtl::OUString& rName ) :
      77                 :            :     PDFPasswordRequestBase( m_aMutex ),
      78                 :            :     m_aRequest(),
      79                 :            :     m_aPassword(),
      80         [ #  # ]:          0 :     m_bSelected(false)
      81                 :            : {
      82                 :            :     m_aRequest.Mode = bFirstTry ?
      83                 :            :         task::PasswordRequestMode_PASSWORD_ENTER :
      84         [ #  # ]:          0 :         task::PasswordRequestMode_PASSWORD_REENTER;
      85                 :          0 :     m_aRequest.Classification = task::InteractionClassification_QUERY;
      86                 :          0 :     m_aRequest.Name = rName;
      87                 :          0 : }
      88                 :            : 
      89                 :          0 : uno::Any SAL_CALL PDFPasswordRequest::getRequest() throw (uno::RuntimeException)
      90                 :            : {
      91         [ #  # ]:          0 :     osl::MutexGuard const guard( m_aMutex );
      92                 :            : 
      93                 :          0 :     uno::Any aRet;
      94         [ #  # ]:          0 :     aRet <<= m_aRequest;
      95         [ #  # ]:          0 :     return aRet;
      96                 :            : }
      97                 :            : 
      98                 :          0 : uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL PDFPasswordRequest::getContinuations() throw (uno::RuntimeException)
      99                 :            : {
     100         [ #  # ]:          0 :     osl::MutexGuard const guard( m_aMutex );
     101                 :            : 
     102         [ #  # ]:          0 :     uno::Sequence< uno::Reference< task::XInteractionContinuation > > aRet( 1 );
     103 [ #  # ][ #  # ]:          0 :     aRet.getArray()[0] = static_cast<task::XInteractionContinuation*>(this);
     104         [ #  # ]:          0 :     return aRet;
     105                 :            : }
     106                 :            : 
     107                 :          0 : void SAL_CALL PDFPasswordRequest::setPassword( const rtl::OUString& rPwd ) throw (uno::RuntimeException)
     108                 :            : {
     109         [ #  # ]:          0 :     osl::MutexGuard const guard( m_aMutex );
     110                 :            : 
     111         [ #  # ]:          0 :     m_aPassword = rPwd;
     112                 :          0 : }
     113                 :            : 
     114                 :          0 : rtl::OUString SAL_CALL PDFPasswordRequest::getPassword() throw (uno::RuntimeException)
     115                 :            : {
     116         [ #  # ]:          0 :     osl::MutexGuard const guard( m_aMutex );
     117                 :            : 
     118         [ #  # ]:          0 :     return m_aPassword;
     119                 :            : }
     120                 :            : 
     121                 :          0 : void SAL_CALL PDFPasswordRequest::select() throw (uno::RuntimeException)
     122                 :            : {
     123         [ #  # ]:          0 :     osl::MutexGuard const guard( m_aMutex );
     124                 :            : 
     125         [ #  # ]:          0 :     m_bSelected = true;
     126                 :          0 : }
     127                 :            : 
     128                 :            : } // namespace
     129                 :            : 
     130                 :            : namespace pdfi
     131                 :            : {
     132                 :            : 
     133                 :          0 : bool getPassword( const uno::Reference< task::XInteractionHandler >& xHandler,
     134                 :            :                   rtl::OUString&                                     rOutPwd,
     135                 :            :                   bool                                               bFirstTry,
     136                 :            :                   const rtl::OUString&                               rDocName
     137                 :            :                   )
     138                 :            : {
     139                 :          0 :     bool bSuccess = false;
     140                 :            : 
     141                 :            :     PDFPasswordRequest* pRequest;
     142                 :            :     uno::Reference< task::XInteractionRequest > xReq(
     143 [ #  # ][ #  # ]:          0 :         pRequest = new PDFPasswordRequest( bFirstTry, rDocName ) );
           [ #  #  #  # ]
     144                 :            :     try
     145                 :            :     {
     146 [ #  # ][ #  # ]:          0 :         xHandler->handle( xReq );
     147                 :            :     }
     148         [ #  # ]:          0 :     catch( uno::Exception& )
     149                 :            :     {
     150                 :            :     }
     151                 :            : 
     152                 :            :     OSL_TRACE( "request %s selected", pRequest->isSelected() ? "was" : "was not" );
     153 [ #  # ][ #  # ]:          0 :     if( pRequest->isSelected() )
     154                 :            :     {
     155                 :          0 :         bSuccess = true;
     156         [ #  # ]:          0 :         rOutPwd = pRequest->getPassword();
     157                 :            :     }
     158                 :            : 
     159                 :          0 :     return bSuccess;
     160                 :            : }
     161                 :            : 
     162                 :            : }
     163                 :            : 
     164                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10