Kaydet (Commit) adfacdd9 authored tarafından Caolán McNamara's avatar Caolán McNamara

adapt code to protect sheet .ui

Change-Id: Ic3c375e87cf89a3956f3703c6facbcbe5ffd5d58
üst f6b05adf
......@@ -132,6 +132,9 @@
<glade-widget-class title="Tab List" name="svtlo-SvTabListBox"
generic-name="Tab List" parent="svtlo-SvTreeListBox"
icon-name="widget-gtk-treeview"/>
<glade-widget-class title="Checked Tree List" name="svxlo-SvxCheckListBox"
generic-name="Checked Tree List" parent="GtkTreeView"
icon-name="widget-gtk-treeview"/>
<glade-widget-class title="Dial Control" name="svxlo-DialControl"
generic-name="Dial Control" parent="GtkSpinner"
icon-name="widget-gtk-spinner"/>
......
......@@ -82,7 +82,6 @@ $(eval $(call gb_SrsTarget_add_files,sc/res,\
sc/source/ui/miscdlgs/retypepassdlg.src \
sc/source/ui/miscdlgs/highred.src \
sc/source/ui/miscdlgs/conflictsdlg.src \
sc/source/ui/miscdlgs/protectiondlg.src \
sc/source/ui/miscdlgs/acredlin.src \
sc/source/ui/formdlg/formdlgs.src \
sc/source/ui/formdlg/dwfunctr.src \
......
......@@ -72,6 +72,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/insertsheet \
sc/uiconfig/scalc/ui/managenamesdialog \
sc/uiconfig/scalc/ui/printeroptions \
sc/uiconfig/scalc/ui/protectsheetdlg \
sc/uiconfig/scalc/ui/sheetprintpage \
sc/uiconfig/scalc/ui/selectrange \
sc/uiconfig/scalc/ui/selectsource \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sc.hrc>
#define BTN_OK 1
#define BTN_CANCEL 2
#define BTN_HELP 3
#define BTN_PROTECT 4
#define FT_PASSWORD1 5
#define ED_PASSWORD1 6
#define FT_PASSWORD2 7
#define ED_PASSWORD2 8
#define FL_OPTIONS 9
#define FT_OPTIONS 10
#define CLB_OPTIONS 11
#define ST_SELECT_PROTECTED_CELLS 50
#define ST_SELECT_UNPROTECTED_CELLS 51
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -24,6 +24,7 @@
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/edit.hxx>
#include <vcl/layout.hxx>
#include <svx/checklbx.hxx>
class Window;
......@@ -48,23 +49,19 @@ private:
void EnableOptionalWidgets(bool bEnable = true);
CheckBox maBtnProtect;
CheckBox* m_pBtnProtect;
FixedText maPassword1Text;
Edit maPassword1Edit;
FixedText maPassword2Text;
Edit maPassword2Edit;
VclContainer* m_pPasswords;
VclContainer* m_pOptions;
Edit* m_pPassword1Edit;
Edit* m_pPassword2Edit;
FixedLine maOptionsLine;
FixedText maOptionsText;
SvxCheckListBox maOptionsListBox;
SvxCheckListBox* m_pOptionsListBox;
OKButton maBtnOk;
CancelButton maBtnCancel;
HelpButton maBtnHelp;
OKButton* m_pBtnOk;
String maSelectLockedCells;
String maSelectUnlockedCells;
OUString m_aSelectLockedCells;
OUString m_aSelectUnlockedCells;
DECL_LINK( OKHdl, void* );
DECL_LINK( CheckBoxHdl, CheckBox* );
......
......@@ -19,7 +19,6 @@
#include "protectiondlg.hxx"
#include "protectiondlg.hrc"
#include "scresid.hxx"
#include "tabprotection.hxx"
......@@ -35,27 +34,21 @@ static const ScTableProtection::Option aOptions[] = {
static const sal_uInt16 nOptionCount = sizeof(aOptions) / sizeof (aOptions[0]);
ScTableProtectionDlg::ScTableProtectionDlg(Window* pParent) :
ModalDialog(pParent, ScResId(RID_SCDLG_TABPROTECTION)),
maBtnProtect (this, ScResId(BTN_PROTECT)),
maPassword1Text (this, ScResId(FT_PASSWORD1)),
maPassword1Edit (this, ScResId(ED_PASSWORD1)),
maPassword2Text (this, ScResId(FT_PASSWORD2)),
maPassword2Edit (this, ScResId(ED_PASSWORD2)),
maOptionsLine (this, ScResId(FL_OPTIONS)),
maOptionsText (this, ScResId(FT_OPTIONS)),
maOptionsListBox(this, ScResId(CLB_OPTIONS)),
ScTableProtectionDlg::ScTableProtectionDlg(Window* pParent)
: ModalDialog( pParent, "ProtectSheetDialog", "modules/scalc/ui/protectsheetdlg.ui" )
{
get(m_pPasswords, "passwords");
get(m_pOptions, "options");
get(m_pBtnProtect, "protect");
get(m_pOptionsListBox, "checklist");
get(m_pPassword1Edit, "password1");
get(m_pPassword2Edit, "password2");
get(m_pBtnOk, "ok");
maBtnOk (this, ScResId(BTN_OK)),
maBtnCancel (this, ScResId(BTN_CANCEL)),
maBtnHelp (this, ScResId(BTN_HELP)),
m_aSelectLockedCells = get<FixedText>("protected")->GetText();
m_aSelectUnlockedCells = get<FixedText>("unprotected")->GetText();
maSelectLockedCells(ScResId(ST_SELECT_PROTECTED_CELLS)),
maSelectUnlockedCells(ScResId(ST_SELECT_UNPROTECTED_CELLS))
{
Init();
FreeResource();
}
ScTableProtectionDlg::~ScTableProtectionDlg()
......@@ -70,68 +63,62 @@ short ScTableProtectionDlg::Execute()
void ScTableProtectionDlg::SetDialogData(const ScTableProtection& rData)
{
for (sal_uInt16 i = 0; i < nOptionCount; ++i)
maOptionsListBox.CheckEntryPos(i, rData.isOptionEnabled(aOptions[i]));
m_pOptionsListBox->CheckEntryPos(i, rData.isOptionEnabled(aOptions[i]));
}
void ScTableProtectionDlg::WriteData(ScTableProtection& rData) const
{
rData.setProtected(maBtnProtect.IsChecked());
rData.setProtected(m_pBtnProtect->IsChecked());
// We assume that the two password texts match.
rData.setPassword(maPassword1Edit.GetText());
rData.setPassword(m_pPassword1Edit->GetText());
for (sal_uInt16 i = 0; i < nOptionCount; ++i)
rData.setOption(aOptions[i], maOptionsListBox.IsChecked(i));
rData.setOption(aOptions[i], m_pOptionsListBox->IsChecked(i));
}
void ScTableProtectionDlg::Init()
{
Link aLink = LINK( this, ScTableProtectionDlg, CheckBoxHdl );
maBtnProtect.SetClickHdl(aLink);
m_pBtnProtect->SetClickHdl(aLink);
aLink = LINK( this, ScTableProtectionDlg, OKHdl );
maBtnOk.SetClickHdl(aLink);
m_pBtnOk->SetClickHdl(aLink);
aLink = LINK( this, ScTableProtectionDlg, PasswordModifyHdl );
maPassword1Edit.SetModifyHdl(aLink);
maPassword2Edit.SetModifyHdl(aLink);
m_pPassword1Edit->SetModifyHdl(aLink);
m_pPassword2Edit->SetModifyHdl(aLink);
maOptionsListBox.SetUpdateMode(false);
maOptionsListBox.Clear();
m_pOptionsListBox->SetUpdateMode(false);
m_pOptionsListBox->Clear();
maOptionsListBox.InsertEntry(maSelectLockedCells);
maOptionsListBox.InsertEntry(maSelectUnlockedCells);
m_pOptionsListBox->InsertEntry(m_aSelectLockedCells);
m_pOptionsListBox->InsertEntry(m_aSelectUnlockedCells);
maOptionsListBox.CheckEntryPos(0, true);
maOptionsListBox.CheckEntryPos(1, true);
m_pOptionsListBox->CheckEntryPos(0, true);
m_pOptionsListBox->CheckEntryPos(1, true);
maOptionsListBox.SetUpdateMode(true);
m_pOptionsListBox->SetUpdateMode(true);
// Set the default state of the dialog.
maBtnProtect.Check(true);
maPassword1Edit.GrabFocus();
m_pBtnProtect->Check(true);
m_pPassword1Edit->GrabFocus();
}
void ScTableProtectionDlg::EnableOptionalWidgets(bool bEnable)
{
maPassword1Text.Enable(bEnable);
maPassword1Edit.Enable(bEnable);
maPassword2Text.Enable(bEnable);
maPassword2Edit.Enable(bEnable);
maOptionsLine.Enable(bEnable);
maOptionsText.Enable(bEnable);
maOptionsListBox.Enable(bEnable);
maOptionsListBox.Invalidate();
m_pPasswords->Enable(bEnable);
m_pOptions->Enable(bEnable);
m_pOptionsListBox->Invalidate();
}
IMPL_LINK( ScTableProtectionDlg, CheckBoxHdl, CheckBox*, pBtn )
{
if (pBtn == &maBtnProtect)
if (pBtn == m_pBtnProtect)
{
bool bChecked = maBtnProtect.IsChecked();
bool bChecked = m_pBtnProtect->IsChecked();
EnableOptionalWidgets(bChecked);
maBtnOk.Enable(bChecked);
m_pBtnOk->Enable(bChecked);
}
return 0;
......@@ -145,9 +132,9 @@ IMPL_LINK_NOARG(ScTableProtectionDlg, OKHdl)
IMPL_LINK_NOARG(ScTableProtectionDlg, PasswordModifyHdl)
{
String aPass1 = maPassword1Edit.GetText();
String aPass2 = maPassword2Edit.GetText();
maBtnOk.Enable(aPass1.Equals(aPass2));
OUString aPass1 = m_pPassword1Edit->GetText();
OUString aPass2 = m_pPassword2Edit->GetText();
m_pBtnOk->Enable(aPass1 == aPass2);
return 0;
}
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "protectiondlg.hrc"
ModalDialog RID_SCDLG_TABPROTECTION
{
HelpID = "sc:ModalDialog:RID_SCDLG_TABPROTECTION";
Text [ en-US ] = "Protect Sheet" ;
Size = MAP_APPFONT ( 250 , 135 ) ;
Moveable = TRUE ;
Closeable = TRUE ;
OKButton BTN_OK
{
Pos = MAP_APPFONT ( 194 , 6 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
DefButton = TRUE ;
};
CancelButton BTN_CANCEL
{
Pos = MAP_APPFONT ( 194 , 23 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
};
HelpButton BTN_HELP
{
Pos = MAP_APPFONT ( 194 , 43 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
};
CheckBox BTN_PROTECT
{
HelpID = "sc:CheckBox:RID_SCDLG_TABPROTECTION:BTN_PROTECT";
Pos = MAP_APPFONT ( 6 , 6 ) ;
Size = MAP_APPFONT ( 180 , 10 );
Text [ en-US ] = "P~rotect this sheet and the contents of protected cells" ;
};
FixedText FT_PASSWORD1
{
Pos = MAP_APPFONT ( 11, 23 );
Size = MAP_APPFONT ( 42, 10 );
Text [ en-US ] = "~Password" ;
};
Edit ED_PASSWORD1
{
HelpID = "sc:Edit:RID_SCDLG_TABPROTECTION:ED_PASSWORD1";
Border = TRUE;
PassWord = TRUE;
Pos = MAP_APPFONT ( 56, 22 );
Size = MAP_APPFONT ( 75, 12 );
};
FixedText FT_PASSWORD2
{
Pos = MAP_APPFONT ( 11, 40 );
Size = MAP_APPFONT ( 42, 10 );
Text [ en-US ] = "~Confirm" ;
};
Edit ED_PASSWORD2
{
HelpID = "sc:Edit:RID_SCDLG_TABPROTECTION:ED_PASSWORD2";
Border = TRUE;
PassWord = TRUE;
Pos = MAP_APPFONT ( 56, 39 );
Size = MAP_APPFONT ( 75, 12 );
};
FixedLine FL_OPTIONS
{
Pos = MAP_APPFONT ( 6, 60 );
Size = MAP_APPFONT ( 180, 8 );
Text [ en-US ] = "Options";
};
FixedText FT_OPTIONS
{
Pos = MAP_APPFONT ( 11, 74 );
Size = MAP_APPFONT ( 140, 8 );
Text [ en-US ] = "Allow all users of this sheet to:";
};
Control CLB_OPTIONS
{
Pos = MAP_APPFONT ( 11, 85 );
Size = MAP_APPFONT ( 140, 40 );
Border = TRUE ;
TabStop = TRUE ;
};
String ST_SELECT_PROTECTED_CELLS
{
Text [ en-US ] = "Select protected cells";
};
String ST_SELECT_UNPROTECTED_CELLS
{
Text [ en-US ] = "Select unprotected cells";
};
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -19,6 +19,8 @@
#include <tools/shl.hxx>
#include <svtools/treelistentry.hxx>
#define _SVX_CHECKLBX_CXX
#include <svx/checklbx.hxx>
......@@ -26,7 +28,7 @@
#include <svx/dialogs.hrc>
#include "svtools/treelistentry.hxx"
#include <vcl/builder.hxx>
// class SvxCheckListBox -------------------------------------------------
......@@ -38,6 +40,15 @@ SvxCheckListBox::SvxCheckListBox( Window* pParent, WinBits nWinStyle ) :
Init_Impl();
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxCheckListBox(Window *pParent, VclBuilder::stringmap &rMap)
{
WinBits nWinStyle = WB_TABSTOP;
OString sBorder = VclBuilder::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
return new SvxCheckListBox(pParent, nWinStyle);
}
// -----------------------------------------------------------------------
SvxCheckListBox::SvxCheckListBox( Window* pParent, const ResId& rResId ) :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment