summaryrefslogtreecommitdiff
path: root/sc/source/ui/miscdlgs
diff options
context:
space:
mode:
authorPalenik Mihály <palenik.mihaly@gmail.com>2014-07-10 02:39:43 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-07-11 10:01:30 +0000
commit91ebd8825bf0ac6bf3daaba54cefc1a11a64451d (patch)
tree27b678f98e76ce6bbe4da38218ba12b491752a3d /sc/source/ui/miscdlgs
parent2df4f9425cf71aee638b4b9cb2498655483b417d (diff)
Convert RID_SCDLG_RETYPEPASS to .ui
Change-Id: I5d6e1ba67bf04c4a10e92f203fcbf36b58a8801c Reviewed-on: https://gerrit.libreoffice.org/10178 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui/miscdlgs')
-rw-r--r--sc/source/ui/miscdlgs/retypepassdlg.cxx260
-rw-r--r--sc/source/ui/miscdlgs/retypepassdlg.src217
2 files changed, 109 insertions, 368 deletions
diff --git a/sc/source/ui/miscdlgs/retypepassdlg.cxx b/sc/source/ui/miscdlgs/retypepassdlg.cxx
index 164e413c4be8..76a4a7104265 100644
--- a/sc/source/ui/miscdlgs/retypepassdlg.cxx
+++ b/sc/source/ui/miscdlgs/retypepassdlg.cxx
@@ -28,35 +28,7 @@
#include <vcl/msgbox.hxx>
ScRetypePassDlg::ScRetypePassDlg(Window* pParent) :
- ModalDialog(pParent, ScResId(RID_SCDLG_RETYPEPASS)),
-
- maBtnOk (this, ScResId(BTN_OK)),
- maBtnCancel (this, ScResId(BTN_CANCEL)),
- maBtnHelp (this, ScResId(BTN_HELP)),
-
- maTextDescription(this, ScResId(FT_DESC)),
- maLineDocument(this, ScResId(FL_DOCUMENT)),
- maTextDocStatus(this, ScResId(FT_DOCSTATUS)),
- maBtnRetypeDoc(this, ScResId(BTN_RETYPE_DOC)),
-
- maLineSheet(this, ScResId(FL_SHEET)),
- maTextSheetName1(this, ScResId(FT_SHEETNAME1)),
- maTextSheetStatus1(this, ScResId(FT_SHEETSTATUS1)),
- maBtnRetypeSheet1(this, ScResId(BTN_RETYPE_SHEET1)),
-
- maTextSheetName2(this, ScResId(FT_SHEETNAME2)),
- maTextSheetStatus2(this, ScResId(FT_SHEETSTATUS2)),
- maBtnRetypeSheet2(this, ScResId(BTN_RETYPE_SHEET2)),
-
- maTextSheetName3(this, ScResId(FT_SHEETNAME3)),
- maTextSheetStatus3(this, ScResId(FT_SHEETSTATUS3)),
- maBtnRetypeSheet3(this, ScResId(BTN_RETYPE_SHEET3)),
-
- maTextSheetName4(this, ScResId(FT_SHEETNAME4)),
- maTextSheetStatus4(this, ScResId(FT_SHEETSTATUS4)),
- maBtnRetypeSheet4(this, ScResId(BTN_RETYPE_SHEET4)),
-
- maScrollBar (this, ScResId(SB_SCROLL)),
+ ModalDialog(pParent, "RetypePass", "modules/scalc/ui/retypepassdialog.ui"),
maTextNotProtected(ScResId(STR_NOT_PROTECTED)),
maTextNotPassProtected(ScResId(STR_NOT_PASS_PROTECTED)),
@@ -68,12 +40,37 @@ ScRetypePassDlg::ScRetypePassDlg(Window* pParent) :
mnCurScrollPos(0),
meDesiredHash(PASSHASH_SHA1)
{
+ get(mpBtnOk ,"ok");
+ get(mpTextDocStatus, "docStatusLabel");
+ get(mpBtnRetypeDoc, "retypeDocButton");
+ Window *pScrolledWindow = get<Window>("scrolledwindow");
+ Size aSize(LogicToPixel(Size(190, 90), MAP_APPFONT));
+ pScrolledWindow->set_width_request(aSize.Width());
+ pScrolledWindow->set_height_request(aSize.Height());
+ get(mpSheetsBox, "sheetsBox");
+
Init();
- FreeResource();
}
ScRetypePassDlg::~ScRetypePassDlg()
{
+ DeleteSheets();
+}
+
+void ScRetypePassDlg::DeleteSheets()
+{
+ for(std::vector<VclHBox*>::iterator it = maSheets.begin(); it != maSheets.end(); ++it)
+ {
+ Window *pWindow = (*it);
+ Window *pChild = pWindow->GetWindow(WINDOW_FIRSTCHILD);
+ while (pChild)
+ {
+ Window *pOldChild = pChild;
+ pChild = pChild->GetWindow(WINDOW_NEXT);
+ delete pOldChild;
+ }
+ delete pWindow;
+ }
}
short ScRetypePassDlg::Execute()
@@ -85,12 +82,14 @@ short ScRetypePassDlg::Execute()
void ScRetypePassDlg::SetDataFromDocument(const ScDocument& rDoc)
{
+ DeleteSheets();
const ScDocProtection* pDocProtect = rDoc.GetDocProtection();
if (pDocProtect && pDocProtect->isProtected())
mpDocItem.reset(new ScDocProtection(*pDocProtect));
SCTAB nTabCount = rDoc.GetTableCount();
maTableItems.reserve(nTabCount);
+ maSheets.reserve(nTabCount);
for (SCTAB i = 0; i < nTabCount; ++i)
{
TableItem aTabItem;
@@ -101,6 +100,23 @@ void ScRetypePassDlg::SetDataFromDocument(const ScDocument& rDoc)
aTabItem.mpProtect.reset(new ScTableProtection(*pTabProtect));
maTableItems.push_back(aTabItem);
+ VclHBox* pSheet = new VclHBox(mpSheetsBox, false, 12);
+ pSheet->Show(true);
+
+ FixedText* pFtSheetName = new FixedText(pSheet);
+ pFtSheetName->Show(true);
+ pFtSheetName->SetStyle(WB_VCENTER);
+ FixedText* pFtSheetStatus = new FixedText(pSheet);
+ pFtSheetStatus->Show(true);
+ pFtSheetStatus->SetStyle(WB_VCENTER);
+
+ PushButton* pBtnSheet = new PushButton(pSheet);
+ pBtnSheet->SetText(ScResId(STR_RETYPE));
+ pBtnSheet->SetClickHdl(LINK(this, ScRetypePassDlg, RetypeBtnHdl));
+ pBtnSheet->Disable();
+ pBtnSheet->Show(true);
+
+ maSheets.push_back(pSheet);
}
}
@@ -130,52 +146,13 @@ void ScRetypePassDlg::WriteNewDataToDocument(ScDocument& rDoc) const
void ScRetypePassDlg::Init()
{
Link aLink = LINK( this, ScRetypePassDlg, OKHdl );
- maBtnOk.SetClickHdl(aLink);
+ mpBtnOk->SetClickHdl(aLink);
aLink = LINK( this, ScRetypePassDlg, RetypeBtnHdl );
- maBtnRetypeDoc.SetClickHdl(aLink);
- maBtnRetypeSheet1.SetClickHdl(aLink);
- maBtnRetypeSheet2.SetClickHdl(aLink);
- maBtnRetypeSheet3.SetClickHdl(aLink);
- maBtnRetypeSheet4.SetClickHdl(aLink);
-
- maTextDocStatus.SetText(maTextNotProtected);
- maTextSheetStatus1.SetText(maTextNotProtected);
- maTextSheetStatus2.SetText(maTextNotProtected);
- maTextSheetStatus3.SetText(maTextNotProtected);
- maTextSheetStatus4.SetText(maTextNotProtected);
- maBtnRetypeDoc.Disable();
-
- // Make all sheet rows invisible.
-
- maTextSheetName1.Show(false);
- maTextSheetStatus1.Show(false);
- maBtnRetypeSheet1.Show(false);
- maBtnRetypeSheet1.Disable();
-
- maTextSheetName2.Show(false);
- maTextSheetStatus2.Show(false);
- maBtnRetypeSheet2.Show(false);
- maBtnRetypeSheet2.Disable();
-
- maTextSheetName3.Show(false);
- maTextSheetStatus3.Show(false);
- maBtnRetypeSheet3.Show(false);
- maBtnRetypeSheet3.Disable();
-
- maTextSheetName4.Show(false);
- maTextSheetStatus4.Show(false);
- maBtnRetypeSheet4.Show(false);
- maBtnRetypeSheet4.Disable();
-
- maScrollBar.Show(false);
-
- maScrollBar.SetEndScrollHdl( LINK( this, ScRetypePassDlg, ScrollHdl ) );
- maScrollBar.SetScrollHdl( LINK( this, ScRetypePassDlg, ScrollHdl ) );
-
- maScrollBar.SetPageSize(4);
- maScrollBar.SetVisibleSize(4);
- maScrollBar.SetLineSize(1);
+ mpBtnRetypeDoc->SetClickHdl(aLink);
+
+ mpTextDocStatus->SetText(maTextNotProtected);
+ mpBtnRetypeDoc->Disable();
}
void ScRetypePassDlg::PopulateDialog()
@@ -183,17 +160,9 @@ void ScRetypePassDlg::PopulateDialog()
// Document protection first.
SetDocData();
- // Sheet protection next. We're only interested in the first 4 sheets
- // (or less).
- size_t n = maTableItems.size();
- for (size_t i = 0; i < n && i < 4; ++i)
+ // Sheet protection next.
+ for (size_t i = 0; i < maTableItems.size(); ++i)
SetTableData(i, static_cast< SCTAB >( i ));
-
- if (n > 4)
- {
- maScrollBar.Show(true);
- maScrollBar.SetRange(Range(0, n));
- }
}
void ScRetypePassDlg::SetDocData()
@@ -202,85 +171,48 @@ void ScRetypePassDlg::SetDocData()
if (mpDocItem.get() && mpDocItem->isProtected())
{
if (mpDocItem->isPasswordEmpty())
- maTextDocStatus.SetText(maTextNotPassProtected);
+ mpTextDocStatus->SetText(maTextNotPassProtected);
else if (mpDocItem->hasPasswordHash(meDesiredHash))
- maTextDocStatus.SetText(maTextHashGood);
+ mpTextDocStatus->SetText(maTextHashGood);
else
{
// incompatible hash
- maTextDocStatus.SetText(maTextHashBad);
+ mpTextDocStatus->SetText(maTextHashBad);
bBtnEnabled = true;
}
}
- maBtnRetypeDoc.Enable(bBtnEnabled);
+ mpBtnRetypeDoc->Enable(bBtnEnabled);
}
void ScRetypePassDlg::SetTableData(size_t nRowPos, SCTAB nTab)
{
- if (nRowPos >= 4)
- return;
-
- FixedText* pName = NULL;
- FixedText* pStatus = NULL;
- PushButton* pBtn = NULL;
- switch (nRowPos)
+ if(nRowPos < maSheets.size())
{
- case 0:
- pName = &maTextSheetName1;
- pStatus = &maTextSheetStatus1;
- pBtn = &maBtnRetypeSheet1;
- break;
- case 1:
- pName = &maTextSheetName2;
- pStatus = &maTextSheetStatus2;
- pBtn = &maBtnRetypeSheet2;
- break;
- case 2:
- pName = &maTextSheetName3;
- pStatus = &maTextSheetStatus3;
- pBtn = &maBtnRetypeSheet3;
- break;
- case 3:
- pName = &maTextSheetName4;
- pStatus = &maTextSheetStatus4;
- pBtn = &maBtnRetypeSheet4;
- break;
- default:
- return;
- }
+ FixedText* pName = static_cast<FixedText*>(maSheets[nRowPos]->GetChild(0));
+ FixedText* pStatus = static_cast<FixedText*>(maSheets[nRowPos]->GetChild(1));
+ PushButton* pBtn = static_cast<PushButton*>(maSheets[nRowPos]->GetChild(2));
- bool bBtnEnabled = false;
- pName->SetText(maTableItems[nTab].maName);
- pName->Show(true);
- const ScTableProtection* pTabProtect = maTableItems[nTab].mpProtect.get();
- if (pTabProtect && pTabProtect->isProtected())
- {
- if (pTabProtect->isPasswordEmpty())
- pStatus->SetText(maTextNotPassProtected);
- else if (pTabProtect->hasPasswordHash(meDesiredHash))
- pStatus->SetText(maTextHashGood);
- else
+ bool bBtnEnabled = false;
+ pName->SetText(maTableItems[nTab].maName);
+ const ScTableProtection* pTabProtect = maTableItems[nTab].mpProtect.get();
+ if (pTabProtect && pTabProtect->isProtected())
{
- // incompatible hash
- pStatus->SetText(maTextHashBad);
- bBtnEnabled = true;
+ if (pTabProtect->isPasswordEmpty())
+ pStatus->SetText(maTextNotPassProtected);
+ else if (pTabProtect->hasPasswordHash(meDesiredHash))
+ pStatus->SetText(maTextHashGood);
+ else
+ {
+ // incompatible hash
+ pStatus->SetText(maTextHashBad);
+ bBtnEnabled = true;
+ }
}
- }
- else
- pStatus->SetText(maTextNotProtected);
-
- pStatus->Show(true);
- pBtn->Show(true);
- pBtn->Enable(bBtnEnabled);
-}
+ else
+ pStatus->SetText(maTextNotProtected);
-void ScRetypePassDlg::ResetTableRows()
-{
- long nScrollPos = maScrollBar.GetThumbPos();
- mnCurScrollPos = nScrollPos < 0 ? 0 : nScrollPos;
- size_t nRowCount = maTableItems.size() - nScrollPos;
- for (size_t i = 0; i < nRowCount; ++i)
- SetTableData(i, static_cast< SCTAB >( i + nScrollPos ));
+ pBtn->Enable(bBtnEnabled);
+ }
}
static bool lcl_IsInGoodStatus(ScPassHashProtectable* pProtected, ScPasswordHash eDesiredHash)
@@ -315,12 +247,12 @@ void ScRetypePassDlg::CheckHashStatus()
if (!bStatusGood)
break;
- maBtnOk.Enable();
+ mpBtnOk->Enable();
return;
}
while (false);
- maBtnOk.Disable();
+ mpBtnOk->Disable();
}
IMPL_LINK_NOARG(ScRetypePassDlg, OKHdl)
@@ -332,7 +264,7 @@ IMPL_LINK_NOARG(ScRetypePassDlg, OKHdl)
IMPL_LINK( ScRetypePassDlg, RetypeBtnHdl, PushButton*, pBtn )
{
ScPassHashProtectable* pProtected = NULL;
- if (pBtn == &maBtnRetypeDoc)
+ if (pBtn == mpBtnRetypeDoc)
{
// document protection.
pProtected = mpDocItem.get();
@@ -340,22 +272,11 @@ IMPL_LINK( ScRetypePassDlg, RetypeBtnHdl, PushButton*, pBtn )
else
{
// sheet protection.
- size_t nTabPos = mnCurScrollPos;
- if (pBtn == &maBtnRetypeSheet2)
- nTabPos += 1;
- else if (pBtn == &maBtnRetypeSheet3)
- nTabPos += 2;
- else if (pBtn == &maBtnRetypeSheet4)
- nTabPos += 3;
- else if (pBtn != &maBtnRetypeSheet1)
- // This should never happen !
- return 0;
-
- if (nTabPos >= maTableItems.size())
- // Likewise, this should never happen !
- return 0;
-
- pProtected = maTableItems[nTabPos].mpProtect.get();
+ size_t aPos = 0;
+ while(aPos < maSheets.size() && pBtn != maSheets[aPos]->GetChild(2))
+ ++aPos;
+
+ pProtected = aPos < maSheets.size() ? maTableItems[aPos].mpProtect.get() : 0;
}
if (!pProtected)
@@ -379,18 +300,11 @@ IMPL_LINK( ScRetypePassDlg, RetypeBtnHdl, PushButton*, pBtn )
}
SetDocData();
- ResetTableRows();
CheckHashStatus();
}
return 0;
}
-IMPL_LINK_NOARG(ScRetypePassDlg, ScrollHdl)
-{
- ResetTableRows();
- return 0;
-}
-
ScRetypePassInputDlg::ScRetypePassInputDlg(Window* pParent, ScPassHashProtectable* pProtected)
: ModalDialog(pParent, "RetypePasswordDialog",
"modules/scalc/ui/retypepassworddialog.ui")
diff --git a/sc/source/ui/miscdlgs/retypepassdlg.src b/sc/source/ui/miscdlgs/retypepassdlg.src
index c3014bae6a8a..b88dde7e31ff 100644
--- a/sc/source/ui/miscdlgs/retypepassdlg.src
+++ b/sc/source/ui/miscdlgs/retypepassdlg.src
@@ -19,207 +19,34 @@
#include "retypepassdlg.hrc"
-ModalDialog RID_SCDLG_RETYPEPASS
+String STR_NOT_PROTECTED
{
- HelpID = "sc:ModalDialog:RID_SCDLG_RETYPEPASS";
- Text [ en-US ] = "Re-type Password" ;
- Size = MAP_APPFONT ( 260 , 165 ) ;
- Moveable = TRUE ;
- Closeable = TRUE ;
-
- OKButton BTN_OK
- {
- Pos = MAP_APPFONT ( 204, 6 ) ;
- Size = MAP_APPFONT ( 50, 14 ) ;
- DefButton = TRUE ;
- };
-
- CancelButton BTN_CANCEL
- {
- Pos = MAP_APPFONT ( 204, 23 ) ;
- Size = MAP_APPFONT ( 50, 14 ) ;
- };
-
- HelpButton BTN_HELP
- {
- Pos = MAP_APPFONT ( 204, 43 ) ;
- Size = MAP_APPFONT ( 50, 14 ) ;
- };
-
- FixedText FT_DESC
- {
- Pos = MAP_APPFONT ( 6, 6 ) ;
- Size = MAP_APPFONT ( 190, 36 );
-
- WordBreak = TRUE ;
-
- Text [ en-US ] = "The document you are about to export has one or more protected items with password that cannot be exported. Please re-type your password to be able to export your document." ;
- };
-
- FixedLine FL_DOCUMENT
- {
- Pos = MAP_APPFONT ( 6, 48 );
- Size = MAP_APPFONT ( 190, 8 );
-
- Text [ en-US ] = "Document protection" ;
- };
-
- FixedText FT_DOCSTATUS
- {
- Pos = MAP_APPFONT ( 10, 62 );
- Size = MAP_APPFONT ( 140, 8 );
-
- Text [ en-US ] = "Status unknown" ;
- };
-
- PushButton BTN_RETYPE_DOC
- {
- HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS:BTN_RETYPE_DOC";
- Pos = MAP_APPFONT ( 158, 59 );
- Size = MAP_APPFONT ( 30, 14 );
-
- Text [ en-US ] = "Re-type" ;
- };
-
- FixedLine FL_SHEET
- {
- Pos = MAP_APPFONT ( 6, 83 );
- Size = MAP_APPFONT ( 190, 8 );
-
- Text [ en-US ] = "Sheet protection" ;
- };
-
- FixedText FT_SHEETNAME1
- {
- Pos = MAP_APPFONT ( 10, 97 );
- Size = MAP_APPFONT ( 68, 8 );
-
- Text [ en-US ] = "Sheet1 has a really long name" ;
- };
-
- FixedText FT_SHEETSTATUS1
- {
- Pos = MAP_APPFONT ( 82, 97 );
- Size = MAP_APPFONT ( 72, 8 );
-
- Text [ en-US ] = "Status unknown" ;
- };
-
- PushButton BTN_RETYPE_SHEET1
- {
- HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS:BTN_RETYPE_SHEET1";
- Pos = MAP_APPFONT ( 158, 94 );
- Size = MAP_APPFONT ( 30, 14 );
-
- Text [ en-US ] = "Re-type" ;
- };
-
- FixedText FT_SHEETNAME2
- {
- Pos = MAP_APPFONT ( 10, 113 );
- Size = MAP_APPFONT ( 68, 8 );
-
- Text [ en-US ] = "Sheet2" ;
- };
-
- FixedText FT_SHEETSTATUS2
- {
- Pos = MAP_APPFONT ( 82, 113 );
- Size = MAP_APPFONT ( 72, 8 );
-
- Text [ en-US ] = "Status unknown" ;
- };
-
- PushButton BTN_RETYPE_SHEET2
- {
- HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS:BTN_RETYPE_SHEET2";
- Pos = MAP_APPFONT ( 158, 110 );
- Size = MAP_APPFONT ( 30, 14 );
-
- Text [ en-US ] = "Re-type" ;
- };
-
- FixedText FT_SHEETNAME3
- {
- Pos = MAP_APPFONT ( 10, 129 );
- Size = MAP_APPFONT ( 68, 8 );
-
- Text [ en-US ] = "Sheet3" ;
- };
-
- FixedText FT_SHEETSTATUS3
- {
- Pos = MAP_APPFONT ( 82, 129 );
- Size = MAP_APPFONT ( 72, 8 );
-
- Text [ en-US ] = "Status unknown" ;
- };
-
- PushButton BTN_RETYPE_SHEET3
- {
- HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS:BTN_RETYPE_SHEET3";
- Pos = MAP_APPFONT ( 158, 126 );
- Size = MAP_APPFONT ( 30, 14 );
-
- Text [ en-US ] = "Re-type" ;
- };
-
- FixedText FT_SHEETNAME4
- {
- Pos = MAP_APPFONT ( 10, 145 );
- Size = MAP_APPFONT ( 68, 8 );
-
- Text [ en-US ] = "Sheet4" ;
- };
-
- FixedText FT_SHEETSTATUS4
- {
- Pos = MAP_APPFONT ( 82, 145 );
- Size = MAP_APPFONT ( 72, 8 );
-
- Text [ en-US ] = "Status unknown" ;
- };
-
- PushButton BTN_RETYPE_SHEET4
- {
- HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS:BTN_RETYPE_SHEET4";
- Pos = MAP_APPFONT ( 158, 142 );
- Size = MAP_APPFONT ( 30, 14 );
-
- Text [ en-US ] = "Re-type" ;
- };
-
- ScrollBar SB_SCROLL
- {
- Pos = MAP_APPFONT ( 190, 94 ) ;
- Size = MAP_APPFONT ( 8, 61 ) ;
- VScroll = TRUE ;
- };
+ Text [ en-US ] = "Not protected" ;
+};
- String STR_NOT_PROTECTED
- {
- Text [ en-US ] = "Not protected" ;
- };
+String STR_NOT_PASS_PROTECTED
+{
+ Text [ en-US ] = "Not password-protected" ;
+};
- String STR_NOT_PASS_PROTECTED
- {
- Text [ en-US ] = "Not password-protected" ;
- };
+String STR_HASH_BAD
+{
+ Text [ en-US ] = "Hash incompatible" ;
+};
- String STR_HASH_BAD
- {
- Text [ en-US ] = "Hash incompatible" ;
- };
+String STR_HASH_GOOD
+{
+ Text [ en-US ] = "Hash compatible" ;
+};
- String STR_HASH_GOOD
- {
- Text [ en-US ] = "Hash compatible" ;
- };
+String STR_HASH_REGENERATED
+{
+ Text [ en-US ] = "Hash re-generated" ;
+};
- String STR_HASH_REGENERATED
- {
- Text [ en-US ] = "Hash re-generated" ;
- };
+String STR_RETYPE
+{
+ Text [ en-US ] = "Re-type" ;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */