LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - protectiondlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 65 0.0 %
Date: 2014-04-14 Functions: 0 16 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 "protectiondlg.hxx"
      22             : #include "scresid.hxx"
      23             : #include "tabprotection.hxx"
      24             : 
      25             : #include <sal/macros.h>
      26             : #include <vcl/msgbox.hxx>
      27             : 
      28             : 
      29             : // The order must match that of the list box.
      30             : static const ScTableProtection::Option aOptions[] = {
      31             :     ScTableProtection::SELECT_LOCKED_CELLS,
      32             :     ScTableProtection::SELECT_UNLOCKED_CELLS,
      33             : };
      34             : static const sal_uInt16 nOptionCount = sizeof(aOptions) / sizeof (aOptions[0]);
      35             : 
      36             : 
      37           0 : ScTableProtectionDlg::ScTableProtectionDlg(Window* pParent)
      38           0 :     : ModalDialog( pParent, "ProtectSheetDialog", "modules/scalc/ui/protectsheetdlg.ui" )
      39             : {
      40           0 :     get(m_pPasswords, "passwords");
      41           0 :     get(m_pOptions, "options");
      42           0 :     get(m_pBtnProtect, "protect");
      43           0 :     get(m_pOptionsListBox, "checklist");
      44           0 :     get(m_pPassword1Edit, "password1");
      45           0 :     get(m_pPassword2Edit, "password2");
      46           0 :     get(m_pBtnOk, "ok");
      47             : 
      48           0 :     m_aSelectLockedCells = get<FixedText>("protected")->GetText();
      49           0 :     m_aSelectUnlockedCells = get<FixedText>("unprotected")->GetText();
      50             : 
      51           0 :     Init();
      52           0 : }
      53             : 
      54           0 : ScTableProtectionDlg::~ScTableProtectionDlg()
      55             : {
      56           0 : }
      57             : 
      58           0 : short ScTableProtectionDlg::Execute()
      59             : {
      60           0 :     return ModalDialog::Execute();
      61             : }
      62             : 
      63           0 : void ScTableProtectionDlg::SetDialogData(const ScTableProtection& rData)
      64             : {
      65           0 :     for (sal_uInt16 i = 0; i < nOptionCount; ++i)
      66           0 :         m_pOptionsListBox->CheckEntryPos(i, rData.isOptionEnabled(aOptions[i]));
      67           0 : }
      68             : 
      69           0 : void ScTableProtectionDlg::WriteData(ScTableProtection& rData) const
      70             : {
      71           0 :     rData.setProtected(m_pBtnProtect->IsChecked());
      72             : 
      73             :     // We assume that the two password texts match.
      74           0 :     rData.setPassword(m_pPassword1Edit->GetText());
      75             : 
      76           0 :     for (sal_uInt16 i = 0; i < nOptionCount; ++i)
      77           0 :         rData.setOption(aOptions[i], m_pOptionsListBox->IsChecked(i));
      78           0 : }
      79             : 
      80           0 : void ScTableProtectionDlg::Init()
      81             : {
      82           0 :     Link aLink = LINK( this, ScTableProtectionDlg, CheckBoxHdl );
      83           0 :     m_pBtnProtect->SetClickHdl(aLink);
      84             : 
      85           0 :     aLink = LINK( this, ScTableProtectionDlg, OKHdl );
      86           0 :     m_pBtnOk->SetClickHdl(aLink);
      87             : 
      88           0 :     aLink = LINK( this, ScTableProtectionDlg, PasswordModifyHdl );
      89           0 :     m_pPassword1Edit->SetModifyHdl(aLink);
      90           0 :     m_pPassword2Edit->SetModifyHdl(aLink);
      91             : 
      92           0 :     m_pOptionsListBox->SetUpdateMode(false);
      93           0 :     m_pOptionsListBox->Clear();
      94             : 
      95           0 :     m_pOptionsListBox->InsertEntry(m_aSelectLockedCells);
      96           0 :     m_pOptionsListBox->InsertEntry(m_aSelectUnlockedCells);
      97             : 
      98           0 :     m_pOptionsListBox->CheckEntryPos(0, true);
      99           0 :     m_pOptionsListBox->CheckEntryPos(1, true);
     100             : 
     101           0 :     m_pOptionsListBox->SetUpdateMode(true);
     102             : 
     103             :     // Set the default state of the dialog.
     104           0 :     m_pBtnProtect->Check(true);
     105           0 :     m_pPassword1Edit->GrabFocus();
     106           0 : }
     107             : 
     108           0 : void ScTableProtectionDlg::EnableOptionalWidgets(bool bEnable)
     109             : {
     110           0 :     m_pPasswords->Enable(bEnable);
     111           0 :     m_pOptions->Enable(bEnable);
     112           0 :     m_pOptionsListBox->Invalidate();
     113           0 : }
     114             : 
     115           0 : IMPL_LINK( ScTableProtectionDlg, CheckBoxHdl, CheckBox*, pBtn )
     116             : {
     117           0 :     if (pBtn == m_pBtnProtect)
     118             :     {
     119           0 :         bool bChecked = m_pBtnProtect->IsChecked();
     120           0 :         EnableOptionalWidgets(bChecked);
     121           0 :         m_pBtnOk->Enable(bChecked);
     122             :     }
     123             : 
     124           0 :     return 0;
     125             : }
     126             : 
     127           0 : IMPL_LINK_NOARG(ScTableProtectionDlg, OKHdl)
     128             : {
     129           0 :     EndDialog(RET_OK);
     130           0 :     return 0;
     131             : }
     132             : 
     133           0 : IMPL_LINK_NOARG(ScTableProtectionDlg, PasswordModifyHdl)
     134             : {
     135           0 :     OUString aPass1 = m_pPassword1Edit->GetText();
     136           0 :     OUString aPass2 = m_pPassword2Edit->GetText();
     137           0 :     m_pBtnOk->Enable(aPass1 == aPass2);
     138           0 :     return 0;
     139           0 : }
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10