LCOV - code coverage report
Current view: top level - cui/source/dialogs - passwdomdlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 73 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 13 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 "passwdomdlg.hxx"
      21             : 
      22             : #include "cuires.hrc"
      23             : #include "dialmgr.hxx"
      24             : 
      25             : #include <sfx2/tabdlg.hxx>
      26             : #include <vcl/fixed.hxx>
      27             : #include <vcl/edit.hxx>
      28             : #include <vcl/button.hxx>
      29             : #include <vcl/layout.hxx>
      30             : #include <vcl/settings.hxx>
      31             : 
      32           0 : struct PasswordToOpenModifyDialog_Impl
      33             : {
      34             :     VclPtr<PasswordToOpenModifyDialog>    m_pParent;
      35             : 
      36             :     VclPtr<Edit>                       m_pPasswdToOpenED;
      37             :     VclPtr<Edit>                       m_pReenterPasswdToOpenED;
      38             :     VclPtr<VclExpander>                m_pOptionsExpander;
      39             :     VclPtr<OKButton>                   m_pOk;
      40             :     VclPtr<CheckBox>                   m_pOpenReadonlyCB;
      41             :     VclPtr<Edit>                       m_pPasswdToModifyED;
      42             :     VclPtr<Edit>                       m_pReenterPasswdToModifyED;
      43             : 
      44             :     OUString                    m_aOneMismatch;
      45             :     OUString                    m_aTwoMismatch;
      46             :     OUString                    m_aInvalidStateForOkButton;
      47             :     OUString                    m_aInvalidStateForOkButton_v2;
      48             : 
      49             :     bool                        m_bIsPasswordToModify;
      50             : 
      51             : 
      52             :     DECL_LINK( OkBtnClickHdl, OKButton * );
      53             : 
      54             :     PasswordToOpenModifyDialog_Impl( PasswordToOpenModifyDialog * pParent,
      55             :             sal_uInt16 nMinPasswdLen, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify );
      56             : };
      57             : 
      58           0 : PasswordToOpenModifyDialog_Impl::PasswordToOpenModifyDialog_Impl(
      59             :         PasswordToOpenModifyDialog * pParent,
      60             :         sal_uInt16 nMinPasswdLen,
      61             :         sal_uInt16 nMaxPasswdLen,
      62             :         bool bIsPasswordToModify )
      63             :     : m_pParent( pParent )
      64           0 :     , m_aOneMismatch( CUI_RES( RID_SVXSTR_ONE_PASSWORD_MISMATCH ) )
      65           0 :     , m_aTwoMismatch( CUI_RES( RID_SVXSTR_TWO_PASSWORDS_MISMATCH ) )
      66           0 :     , m_aInvalidStateForOkButton( CUI_RES( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON ) )
      67           0 :     , m_aInvalidStateForOkButton_v2( CUI_RES( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON_V2 ) )
      68           0 :     , m_bIsPasswordToModify( bIsPasswordToModify )
      69             : {
      70           0 :     pParent->get(m_pPasswdToOpenED, "newpassEntry");
      71           0 :     pParent->get(m_pReenterPasswdToOpenED, "confirmpassEntry");
      72           0 :     pParent->get(m_pOk, "ok");
      73           0 :     pParent->get(m_pOpenReadonlyCB, "readonly");
      74           0 :     pParent->get(m_pPasswdToModifyED, "newpassroEntry");
      75           0 :     pParent->get(m_pReenterPasswdToModifyED, "confirmropassEntry");
      76           0 :     pParent->get(m_pOptionsExpander, "expander");
      77             : 
      78           0 :     m_pOk->SetClickHdl( LINK( this, PasswordToOpenModifyDialog_Impl, OkBtnClickHdl ) );
      79             : 
      80           0 :     if (nMaxPasswdLen)
      81             :     {
      82           0 :         m_pPasswdToOpenED->SetMaxTextLen( nMaxPasswdLen );
      83           0 :         m_pReenterPasswdToOpenED->SetMaxTextLen( nMaxPasswdLen );
      84           0 :         m_pPasswdToModifyED->SetMaxTextLen( nMaxPasswdLen );
      85           0 :         m_pReenterPasswdToModifyED->SetMaxTextLen( nMaxPasswdLen );
      86             :     }
      87             : 
      88             :     (void) nMinPasswdLen;   // currently not supported
      89             : 
      90           0 :     m_pPasswdToOpenED->GrabFocus();
      91             : 
      92           0 :     m_pOptionsExpander->Enable(bIsPasswordToModify);
      93           0 :     if (!bIsPasswordToModify)
      94           0 :         m_pOptionsExpander->Hide();
      95           0 : }
      96             : 
      97           0 : IMPL_LINK( PasswordToOpenModifyDialog_Impl, OkBtnClickHdl, OKButton *, /*pBtn*/ )
      98             : {
      99           0 :     bool bInvalidState = !m_pOpenReadonlyCB->IsChecked() &&
     100           0 :             m_pPasswdToOpenED->GetText().isEmpty() &&
     101           0 :             m_pPasswdToModifyED->GetText().isEmpty();
     102           0 :     if (bInvalidState)
     103             :     {
     104             :         ScopedVclPtrInstance<MessageDialog> aErrorBox(m_pParent,
     105           0 :             m_bIsPasswordToModify? m_aInvalidStateForOkButton : m_aInvalidStateForOkButton_v2);
     106           0 :         aErrorBox->Execute();
     107             :     }
     108             :     else // check for mismatched passwords...
     109             :     {
     110           0 :         const bool bToOpenMatch     = m_pPasswdToOpenED->GetText()   == m_pReenterPasswdToOpenED->GetText();
     111           0 :         const bool bToModifyMatch   = m_pPasswdToModifyED->GetText() == m_pReenterPasswdToModifyED->GetText();
     112           0 :         const int nMismatch = (bToOpenMatch? 0 : 1) + (bToModifyMatch? 0 : 1);
     113           0 :         if (nMismatch > 0)
     114             :         {
     115           0 :             ScopedVclPtrInstance< MessageDialog > aErrorBox(m_pParent, nMismatch == 1 ? m_aOneMismatch : m_aTwoMismatch);
     116           0 :             aErrorBox->Execute();
     117             : 
     118           0 :             Edit* pEdit = !bToOpenMatch ? m_pPasswdToOpenED : m_pPasswdToModifyED;
     119           0 :             Edit* pRepeatEdit = !bToOpenMatch? m_pReenterPasswdToOpenED : m_pReenterPasswdToModifyED;
     120           0 :             OUString aEmpty;
     121           0 :             if (nMismatch == 1)
     122             :             {
     123           0 :                 pEdit->SetText( aEmpty );
     124           0 :                 pRepeatEdit->SetText( aEmpty );
     125             :             }
     126           0 :             else if (nMismatch == 2)
     127             :             {
     128           0 :                 m_pPasswdToOpenED->SetText( aEmpty );
     129           0 :                 m_pReenterPasswdToOpenED->SetText( aEmpty );
     130           0 :                 m_pPasswdToModifyED->SetText( aEmpty );
     131           0 :                 m_pReenterPasswdToModifyED->SetText( aEmpty );
     132             :             }
     133           0 :             pEdit->GrabFocus();
     134             :         }
     135             :         else
     136             :         {
     137           0 :             m_pParent->EndDialog( RET_OK );
     138             :         }
     139             :     }
     140             : 
     141           0 :     return 0;
     142             : }
     143             : 
     144           0 : PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(
     145             :     vcl::Window * pParent, sal_uInt16 nMinPasswdLen,
     146             :     sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify)
     147           0 :     : SfxModalDialog( pParent, "PasswordDialog", "cui/ui/password.ui" )
     148             : {
     149             :     m_pImpl.reset(new PasswordToOpenModifyDialog_Impl(this,
     150           0 :         nMinPasswdLen, nMaxPasswdLen, bIsPasswordToModify ) );
     151           0 : }
     152             : 
     153             : 
     154           0 : PasswordToOpenModifyDialog::~PasswordToOpenModifyDialog()
     155             : {
     156           0 :     disposeOnce();
     157           0 : }
     158             : 
     159           0 : void PasswordToOpenModifyDialog::dispose()
     160             : {
     161           0 :     SfxModalDialog::dispose();
     162           0 : }
     163             : 
     164             : 
     165           0 : OUString PasswordToOpenModifyDialog::GetPasswordToOpen() const
     166             : {
     167             :     const bool bPasswdOk =
     168           0 :             !m_pImpl->m_pPasswdToOpenED->GetText().isEmpty() &&
     169           0 :             m_pImpl->m_pPasswdToOpenED->GetText() == m_pImpl->m_pReenterPasswdToOpenED->GetText();
     170           0 :     return bPasswdOk ? m_pImpl->m_pPasswdToOpenED->GetText() : OUString();
     171             : }
     172             : 
     173             : 
     174           0 : OUString PasswordToOpenModifyDialog::GetPasswordToModify() const
     175             : {
     176             :     const bool bPasswdOk =
     177           0 :             !m_pImpl->m_pPasswdToModifyED->GetText().isEmpty() &&
     178           0 :             m_pImpl->m_pPasswdToModifyED->GetText() == m_pImpl->m_pReenterPasswdToModifyED->GetText();
     179           0 :     return bPasswdOk ? m_pImpl->m_pPasswdToModifyED->GetText() : OUString();
     180             : }
     181             : 
     182             : 
     183           0 : bool PasswordToOpenModifyDialog::IsRecommendToOpenReadonly() const
     184             : {
     185           0 :     return m_pImpl->m_pOpenReadonlyCB->IsChecked();
     186           0 : }
     187             : 
     188             : 
     189             : 
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11