LCOV - code coverage report
Current view: top level - uui/source - passworddlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 44 0.0 %
Date: 2014-04-14 Functions: 0 3 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 "passworddlg.hxx"
      21             : #include "ids.hrc"
      22             : 
      23             : #include <vcl/msgbox.hxx>
      24             : 
      25             : using namespace ::com::sun::star;
      26             : 
      27           0 : PasswordDialog::PasswordDialog(Window* _pParent,
      28             :     task::PasswordRequestMode nDlgMode, ResMgr * pResMgr,
      29             :     const OUString& aDocURL, bool bOpenToModify, bool bIsSimplePasswordRequest)
      30             :     : ModalDialog(_pParent, "PasswordDialog", "uui/ui/password.ui")
      31             :     , nMinLen(1)
      32             :     , aPasswdMismatch(ResId(STR_PASSWORD_MISMATCH, *pResMgr))
      33             :     , nDialogMode(nDlgMode)
      34           0 :     , pResourceMgr(pResMgr)
      35             : {
      36           0 :     get(m_pFTPassword, "newpassFT");
      37           0 :     get(m_pEDPassword, "newpassEntry");
      38           0 :     get(m_pFTConfirmPassword, "confirmpassFT");
      39           0 :     get(m_pEDConfirmPassword, "confirmpassEntry");
      40           0 :     get(m_pOKBtn, "ok");
      41             : 
      42           0 :     if( nDialogMode == task::PasswordRequestMode_PASSWORD_REENTER )
      43             :     {
      44           0 :         const sal_uInt16 nOpenToModifyErrStrId = bOpenToModify ? STR_ERROR_PASSWORD_TO_MODIFY_WRONG : STR_ERROR_PASSWORD_TO_OPEN_WRONG;
      45           0 :         const sal_uInt16 nErrStrId = bIsSimplePasswordRequest ? STR_ERROR_SIMPLE_PASSWORD_WRONG : nOpenToModifyErrStrId;
      46           0 :         OUString aErrorMsg(ResId(nErrStrId, *pResourceMgr).toString());
      47           0 :         ErrorBox aErrorBox( GetParent(), WB_OK, aErrorMsg );
      48           0 :         aErrorBox.Execute();
      49             :     }
      50             : 
      51             :     // default settings for enter password or reenter passwd...
      52           0 :     OUString aTitle(ResId(STR_TITLE_ENTER_PASSWORD, *pResourceMgr).toString());
      53           0 :     m_pFTConfirmPassword->Hide();
      54           0 :     m_pEDConfirmPassword->Hide();
      55           0 :     m_pFTConfirmPassword->Enable( false );
      56           0 :     m_pEDConfirmPassword->Enable( false );
      57             : 
      58             :     // settings for create password
      59           0 :     if (nDialogMode == task::PasswordRequestMode_PASSWORD_CREATE)
      60             :     {
      61           0 :         aTitle = ResId(STR_TITLE_CREATE_PASSWORD, *pResourceMgr).toString();
      62             : 
      63           0 :         m_pFTConfirmPassword->SetText(ResId(STR_CONFIRM_SIMPLE_PASSWORD, *pResourceMgr).toString());
      64             : 
      65           0 :         m_pFTConfirmPassword->Show();
      66           0 :         m_pEDConfirmPassword->Show();
      67           0 :         m_pFTConfirmPassword->Enable( true );
      68           0 :         m_pEDConfirmPassword->Enable( true );
      69             :     }
      70             : 
      71           0 :     SetText( aTitle );
      72             : 
      73           0 :     sal_uInt16 nStrId = bOpenToModify ? STR_ENTER_PASSWORD_TO_MODIFY : STR_ENTER_PASSWORD_TO_OPEN;
      74           0 :     m_pFTPassword->SetText(ResId(nStrId, *pResourceMgr).toString());
      75           0 :     m_pFTPassword->SetText( m_pFTPassword->GetText() + aDocURL );
      76           0 :     if (bIsSimplePasswordRequest)
      77             :     {
      78             :         DBG_ASSERT( aDocURL.isEmpty(), "A simple password request should not have a document URL! Use document password request instead." );
      79           0 :         m_pFTPassword->SetText(ResId(STR_ENTER_SIMPLE_PASSWORD, *pResourceMgr).toString());
      80             :     }
      81             : 
      82           0 :     m_pOKBtn->SetClickHdl( LINK( this, PasswordDialog, OKHdl_Impl ) );
      83           0 : }
      84             : 
      85           0 : IMPL_LINK_NOARG(PasswordDialog, OKHdl_Impl)
      86             : {
      87           0 :     bool bEDPasswdValid = m_pEDPassword->GetText().getLength() >= nMinLen;
      88           0 :     bool bPasswdMismatch = m_pEDConfirmPassword->GetText() != m_pEDPassword->GetText();
      89           0 :     bool bValid = (!m_pEDConfirmPassword->IsVisible() && bEDPasswdValid) ||
      90           0 :             (m_pEDConfirmPassword->IsVisible() && bEDPasswdValid && !bPasswdMismatch);
      91             : 
      92           0 :     if (m_pEDConfirmPassword->IsVisible() && bPasswdMismatch)
      93             :     {
      94           0 :         ErrorBox aErrorBox( this, WB_OK, aPasswdMismatch );
      95           0 :         aErrorBox.Execute();
      96             :     }
      97           0 :     else if (bValid)
      98           0 :         EndDialog( RET_OK );
      99             : 
     100           0 :     return 1;
     101             : }
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
     104             : 

Generated by: LCOV version 1.10