diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-10-05 12:18:07 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-10-05 14:37:49 +0100 |
commit | 06e3724d1c166e6715455555788f5b11c310d60a (patch) | |
tree | 140db8973a3baed0986d6f3968aa9d24a91b8a8c /sfx2/source/dialog | |
parent | a65f48f375d218b592ba7c17752f9ca86e14bd65 (diff) |
convert password dialog to .ui
Change-Id: Ib2e9c5a72239fc0fa3a54ac3717d90fe1b779d63
Diffstat (limited to 'sfx2/source/dialog')
-rw-r--r-- | sfx2/source/dialog/dialog.hrc | 1 | ||||
-rw-r--r-- | sfx2/source/dialog/passwd.cxx | 261 | ||||
-rw-r--r-- | sfx2/source/dialog/passwd.hrc | 47 | ||||
-rw-r--r-- | sfx2/source/dialog/passwd.src | 144 |
4 files changed, 67 insertions, 386 deletions
diff --git a/sfx2/source/dialog/dialog.hrc b/sfx2/source/dialog/dialog.hrc index 27a9eab17f84..e27579d17cb2 100644 --- a/sfx2/source/dialog/dialog.hrc +++ b/sfx2/source/dialog/dialog.hrc @@ -32,7 +32,6 @@ #define RID_DLG_ALIEN_WARNING ( RC_DIALOG_BEGIN + 0) #define STR_RESET ( RC_DIALOG_BEGIN + 0) -#define DLG_PASSWD ( RC_DIALOG_BEGIN + 8) #define STR_TABPAGE_MANAGESTYLES ( RC_DIALOG_BEGIN + 12) #define MSG_TABPAGE_INVALIDNAME ( RC_DIALOG_BEGIN + 13) #define MSG_TABPAGE_INVALIDSTYLE ( RC_DIALOG_BEGIN + 14) diff --git a/sfx2/source/dialog/passwd.cxx b/sfx2/source/dialog/passwd.cxx index ae48a4880212..77dc3524b0e0 100644 --- a/sfx2/source/dialog/passwd.cxx +++ b/sfx2/source/dialog/passwd.cxx @@ -35,20 +35,17 @@ #include "sfx2/sfxresid.hxx" #include "dialog.hrc" -#include "passwd.hrc" - -#include "vcl/arrange.hxx" // ----------------------------------------------------------------------- IMPL_LINK_INLINE_START( SfxPasswordDialog, EditModifyHdl, Edit *, pEdit ) { - if( mbAsciiOnly && (pEdit == &maPasswordED || pEdit == &maPassword2ED) ) + if (mbAsciiOnly && (pEdit == mpPassword1ED || pEdit == mpPassword2ED)) { - rtl::OUString aTest( pEdit->GetText() ); + OUString aTest( pEdit->GetText() ); const sal_Unicode* pTest = aTest.getStr(); sal_Int32 nLen = aTest.getLength(); - rtl::OUStringBuffer aFilter( nLen ); + OUStringBuffer aFilter( nLen ); bool bReset = false; for( sal_Int32 i = 0; i < nLen; i++ ) { @@ -65,10 +62,10 @@ IMPL_LINK_INLINE_START( SfxPasswordDialog, EditModifyHdl, Edit *, pEdit ) } } - bool bEnable = maPasswordED.GetText().Len() >= mnMinLen; - if( maPassword2ED.IsVisible() ) - bEnable = (bEnable && (maPassword2ED.GetText().Len() >= mnMinLen)); - maOKBtn.Enable( bEnable ); + bool bEnable = mpPassword1ED->GetText().Len() >= mnMinLen; + if( mpPassword2ED->IsVisible() ) + bEnable = (bEnable && (mpPassword2ED->GetText().Len() >= mnMinLen)); + mpOKBtn->Enable( bEnable ); return 0; } IMPL_LINK_INLINE_END(SfxPasswordDialog, EditModifyHdl, Edit *, pEdit) @@ -85,8 +82,8 @@ IMPL_LINK_NOARG(SfxPasswordDialog, OKHdl) { ErrorBox aBox( this, SfxResId( MSG_ERROR_WRONG_CONFIRM ) ); aBox.Execute(); - maConfirmED.SetText( String() ); - maConfirmED.GrabFocus(); + mpConfirm1ED->SetText( String() ); + mpConfirm1ED->GrabFocus(); } else EndDialog( RET_OK ); @@ -95,103 +92,44 @@ IMPL_LINK_NOARG(SfxPasswordDialog, OKHdl) // CTOR / DTOR ----------------------------------------------------------- -SfxPasswordDialog::SfxPasswordDialog( Window* pParent, const String* pGroupText ) : - - ModalDialog( pParent, SfxResId ( DLG_PASSWD ) ), - - maPasswordBox ( this, SfxResId( GB_PASSWD_PASSWORD ) ), - maUserFT ( this, SfxResId( FT_PASSWD_USER ) ), - maUserED ( this, SfxResId( ED_PASSWD_USER ) ), - maPasswordFT ( this, SfxResId( FT_PASSWD_PASSWORD ) ), - maPasswordED ( this, SfxResId( ED_PASSWD_PASSWORD ) ), - maConfirmFT ( this, SfxResId( FT_PASSWD_CONFIRM ) ), - maConfirmED ( this, SfxResId( ED_PASSWD_CONFIRM ) ), - - maMinLengthFT ( this, SfxResId( FT_PASSWD_MINLEN ) ), - maPassword2Box ( this, 0 ), - maPassword2FT ( this, SfxResId( FT_PASSWD_PASSWORD2 ) ), - maPassword2ED ( this, SfxResId( ED_PASSWD_PASSWORD2 ) ), - maConfirm2FT ( this, SfxResId( FT_PASSWD_CONFIRM2 ) ), - maConfirm2ED ( this, SfxResId( ED_PASSWD_CONFIRM2 ) ), - maOKBtn ( this, SfxResId( BTN_PASSWD_OK ) ), - maCancelBtn ( this, SfxResId( BTN_PASSWD_CANCEL ) ), - maHelpBtn ( this, SfxResId( BTN_PASSWD_HELP ) ), - - maMinLenPwdStr ( SfxResId( STR_PASSWD_MIN_LEN ).toString() ), - maEmptyPwdStr ( SfxResId( STR_PASSWD_EMPTY ).toString() ), - maMainPwdStr ( ), - mnMinLen ( 5 ), - mnExtras ( 0 ), - mbAsciiOnly ( false ) - +SfxPasswordDialog::SfxPasswordDialog(Window* pParent, const String* pGroupText) + : ModalDialog(pParent, "PasswordDialog", "sfx/ui/password.ui") + , maMinLenPwdStr(SFX2_RESSTR(STR_PASSWD_MIN_LEN)) + , maEmptyPwdStr(SFX2_RESSTR(STR_PASSWD_EMPTY)) + , mnMinLen(5) + , mnExtras(0) + , mbAsciiOnly(false) { - maPasswordED.SetAccessibleName(SfxResId(TEXT_PASSWD).toString()); - FreeResource(); - - // setup layout - boost::shared_ptr<vcl::RowOrColumn> xLayout = - boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); - xLayout->setOuterBorder( 0 ); - - // get edit size, should be used as minimum - Size aEditSize( maUserED.GetSizePixel() ); - - // add labelcolumn for the labeled edit fields - boost::shared_ptr<vcl::LabelColumn> xEdits( new vcl::LabelColumn( xLayout.get() ) ); - size_t nChildIndex = xLayout->addChild( xEdits ); - xLayout->setBorders( nChildIndex, -2, -2, -2, 0 ); + get(mpPassword1Box, "password1frame"); + get(mpUserFT, "userft"); + get(mpUserED, "usered"); + get(mpPassword1FT, "pass1ft"); + get(mpPassword1ED, "pass1ed"); + get(mpConfirm1FT, "confirm1ft"); + get(mpConfirm1ED, "confirm1ed"); - // add group box - xEdits->addWindow( &maPasswordBox ); + get(mpPassword2Box, "password2frame"); + get(mpPassword2FT, "pass2ft"); + get(mpPassword2ED, "pass2ed"); + get(mpConfirm2FT, "confirm2ft"); + get(mpConfirm2ED, "confirm2ed"); - // add user line - xEdits->addRow( &maUserFT, &maUserED, -2, aEditSize ); + get(mpMinLengthFT, "minlenft"); - // add password line - xEdits->addRow( &maPasswordFT, &maPasswordED, -2, aEditSize ); + get(mpOKBtn, "ok"); - // add confirm line - xEdits->addRow( &maConfirmFT, &maConfirmED, -2, aEditSize ); - - // add second group box - xEdits->addWindow( &maPassword2Box ); - - // add second password line - xEdits->addRow( &maPassword2FT, &maPassword2ED, -2, aEditSize ); - - // add second confirm line - xEdits->addRow( &maConfirm2FT, &maConfirm2ED, -2, aEditSize ); - - // add password length warning line - xEdits->addWindow( &maMinLengthFT ); - - // add a FixedLine - FixedLine* pLine = new FixedLine( this, 0 ); - pLine->Show(); - addWindow( pLine, true ); - xLayout->addWindow( pLine ); - - // add button column - Size aBtnSize( maCancelBtn.GetSizePixel() ); - boost::shared_ptr<vcl::RowOrColumn> xButtons( new vcl::RowOrColumn( xLayout.get(), false ) ); - nChildIndex = xLayout->addChild( xButtons ); - xLayout->setBorders( nChildIndex, -2, 0, -2, -2 ); - - xButtons->addWindow( &maHelpBtn, 0, aBtnSize ); - xButtons->addChild( new vcl::Spacer( xButtons.get() ) ); - xButtons->addWindow( &maOKBtn, 0, aBtnSize ); - xButtons->addWindow( &maCancelBtn, 0, aBtnSize ); + mpPassword1ED->SetAccessibleName(SFX2_RESSTR(STR_PASSWD)); Link aLink = LINK( this, SfxPasswordDialog, EditModifyHdl ); - maPasswordED.SetModifyHdl( aLink ); - maPassword2ED.SetModifyHdl( aLink ); + mpPassword1ED->SetModifyHdl( aLink ); + mpPassword2ED->SetModifyHdl( aLink ); aLink = LINK( this, SfxPasswordDialog, OKHdl ); - maOKBtn.SetClickHdl( aLink ); + mpOKBtn->SetClickHdl( aLink ); - if ( pGroupText ) - maPasswordBox.SetText( *pGroupText ); + if (pGroupText) + mpPassword1Box->set_label(*pGroupText); -//set the text to the pasword length + //set the text to the pasword length SetPasswdText(); } @@ -201,13 +139,12 @@ void SfxPasswordDialog::SetPasswdText( ) { //set the new string to the minimum password length if( mnMinLen == 0 ) - maMinLengthFT.SetText( maEmptyPwdStr ); + mpMinLengthFT->SetText(maEmptyPwdStr); else { maMainPwdStr = maMinLenPwdStr; - maMainPwdStr.SearchAndReplace( rtl::OUString("$(MINLEN)"), String::CreateFromInt32((sal_Int32) mnMinLen ), 0); - maMinLengthFT.SetText( maMainPwdStr ); - maMinLengthFT.Show(); + maMainPwdStr.SearchAndReplace( OUString("$(MINLEN)"), String::CreateFromInt32((sal_Int32) mnMinLen ), 0); + mpMinLengthFT->SetText(maMainPwdStr); } } @@ -224,106 +161,42 @@ void SfxPasswordDialog::SetMinLen( sal_uInt16 nLen ) short SfxPasswordDialog::Execute() { - maUserFT.Hide(); - maUserED.Hide(); - maConfirmFT.Hide(); - maConfirmED.Hide(); - maPasswordFT.Hide(); - maPassword2Box.Hide(); - maPassword2FT.Hide(); - maPassword2ED.Hide(); - maPassword2FT.Hide(); - maConfirm2FT.Hide(); - maConfirm2ED.Hide(); - - if( mnExtras != SHOWEXTRAS_NONE ) - maPasswordFT.Show(); - if( (mnExtras & SHOWEXTRAS_USER ) ) + mpUserFT->Hide(); + mpUserED->Hide(); + mpConfirm1FT->Hide(); + mpConfirm1ED->Hide(); + mpPassword1FT->Hide(); + mpPassword2Box->Hide(); + mpPassword2FT->Hide(); + mpPassword2ED->Hide(); + mpPassword2FT->Hide(); + mpConfirm2FT->Hide(); + mpConfirm2ED->Hide(); + + if (mnExtras != SHOWEXTRAS_NONE) + mpPassword1FT->Show(); + if (mnExtras & SHOWEXTRAS_USER) { - //TODO: Inevitably this layout logic will be wrong post merge until we can see the dialog to test it. - Size a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT ); - Size a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT ); - long nMinHeight = maHelpBtn.GetPosPixel().Y() + - maHelpBtn.GetSizePixel().Height() + a6Size.Height(); - sal_uInt16 nRowHided = 1; - - if ( SHOWEXTRAS_NONE == mnExtras ) - { - maUserFT.Hide(); - maUserED.Hide(); - maConfirmFT.Hide(); - maConfirmED.Hide(); - maPasswordFT.Hide(); - - Point aPos = maUserFT.GetPosPixel(); - long nEnd = maUserED.GetPosPixel().X() + maUserED.GetSizePixel().Width(); - maPasswordED.SetPosPixel( aPos ); - Size aSize = maPasswordED.GetSizePixel(); - aSize.Width() = nEnd - aPos.X(); - maPasswordED.SetSizePixel( aSize ); - - nRowHided = 2; - } - else if ( SHOWEXTRAS_USER == mnExtras ) - { - maConfirmFT.Hide(); - maConfirmED.Hide(); - } - else if ( SHOWEXTRAS_CONFIRM == mnExtras ) - { - maUserFT.Hide(); - maUserED.Hide(); - - Point aPwdPos1 = maPasswordFT.GetPosPixel(); - Point aPwdPos2 = maPasswordED.GetPosPixel(); - - Point aPos = maUserFT.GetPosPixel(); - maPasswordFT.SetPosPixel( aPos ); - aPos = maUserED.GetPosPixel(); - maPasswordED.SetPosPixel( aPos ); - - aPos = maConfirmFT.GetPosPixel(); - maConfirmFT.SetPosPixel( aPwdPos1 ); - maConfirmED.SetPosPixel( aPwdPos2 ); - maMinLengthFT.SetPosPixel(aPos); - } - - Size aBoxSize = maPasswordBox.GetSizePixel(); - aBoxSize.Height() -= ( nRowHided * maUserED.GetSizePixel().Height() ); - aBoxSize.Height() -= ( nRowHided * a3Size.Height() ); - maPasswordBox.SetSizePixel( aBoxSize ); - - long nDlgHeight = maPasswordBox.GetPosPixel().Y() + aBoxSize.Height() + a6Size.Height(); - if ( nDlgHeight < nMinHeight ) - nDlgHeight = nMinHeight; - Size aDlgSize = GetOutputSizePixel(); - aDlgSize.Height() = nDlgHeight; - SetOutputSizePixel( aDlgSize ); - - maUserFT.Show(); - maUserED.Show(); + mpUserFT->Show(); + mpUserED->Show(); } - if( (mnExtras & SHOWEXTRAS_CONFIRM ) ) + if (mnExtras & SHOWEXTRAS_CONFIRM) { - maConfirmFT.Show(); - maConfirmED.Show(); + mpConfirm1FT->Show(); + mpConfirm1ED->Show(); } - if( (mnExtras & SHOWEXTRAS_PASSWORD2) ) + if (mnExtras & SHOWEXTRAS_PASSWORD2) { - maPassword2Box.Show(); - maPassword2FT.Show(); - maPassword2ED.Show(); + mpPassword2Box->Show(); + mpPassword2FT->Show(); + mpPassword2ED->Show(); } - if( (mnExtras & SHOWEXTRAS_CONFIRM2 ) ) + if (mnExtras & SHOWEXTRAS_CONFIRM2) { - maConfirm2FT.Show(); - maConfirm2ED.Show(); + mpConfirm2FT->Show(); + mpConfirm2ED->Show(); } - boost::shared_ptr<vcl::RowOrColumn> xLayout = - boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); - SetSizePixel( xLayout->getOptimalSize( WINDOWSIZE_PREFERRED ) ); - return ModalDialog::Execute(); } diff --git a/sfx2/source/dialog/passwd.hrc b/sfx2/source/dialog/passwd.hrc deleted file mode 100644 index cea12b57bf14..000000000000 --- a/sfx2/source/dialog/passwd.hrc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 . - */ -#ifndef _SFX_PASSWD_HRC -#define _SFX_PASSWD_HRC - -// defines --------------------------------------------------------------- - -#define GB_PASSWD_PASSWORD 10 -#define FT_PASSWD_USER 11 -#define ED_PASSWD_USER 12 -#define FT_PASSWD_PASSWORD 13 -#define ED_PASSWD_PASSWORD 14 -#define FT_PASSWD_CONFIRM 15 -#define ED_PASSWD_CONFIRM 16 -#define FT_PASSWD_MINLEN 17 - -#define BTN_PASSWD_OK 20 -#define BTN_PASSWD_CANCEL 21 -#define BTN_PASSWD_HELP 22 - -#define FT_PASSWD_PASSWORD2 25 -#define ED_PASSWD_PASSWORD2 26 -#define FT_PASSWD_CONFIRM2 27 -#define ED_PASSWD_CONFIRM2 28 - -#define STR_PASSWD_MIN_LEN 30 -#define STR_PASSWD_EMPTY 31 - -#define TEXT_PASSWD 32 - -#endif - diff --git a/sfx2/source/dialog/passwd.src b/sfx2/source/dialog/passwd.src deleted file mode 100644 index cc0393f7d9b9..000000000000 --- a/sfx2/source/dialog/passwd.src +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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 "helpid.hrc" -#include "dialog.hrc" -#include "passwd.hrc" - - // DLG_PASSWD ------------------------------------------------------------ -ModalDialog DLG_PASSWD -{ - HelpId = HID_PASSWD ; - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT( 200, 68 ); - Text [ en-US ] = "Enter Password" ; - Moveable = TRUE ; - FixedText FT_PASSWD_USER - { - Pos = MAP_APPFONT( 12, 15 ); - Size = MAP_APPFONT( 42, 10 ); - Text [ en-US ] = "~User"; - }; - Edit ED_PASSWD_USER - { - HelpID = "sfx2:Edit:DLG_PASSWD:ED_PASSWD_USER"; - Border = TRUE; - Pos = MAP_APPFONT( 57, 14 ); - Size = MAP_APPFONT( 75, 12 ); - }; - FixedText FT_PASSWD_PASSWORD - { - Pos = MAP_APPFONT( 12, 30 ); - Size = MAP_APPFONT( 42, 10 ); - Text [ en-US ] = "~Password"; - }; - Edit ED_PASSWD_PASSWORD - { - HelpID = "sfx2:Edit:DLG_PASSWD:ED_PASSWD_PASSWORD"; - Border = TRUE; - PassWord = TRUE; - Pos = MAP_APPFONT( 57, 29 ); - Size = MAP_APPFONT( 75, 12 ); - }; - FixedText FT_PASSWD_CONFIRM - { - Pos = MAP_APPFONT( 12, 45 ); - Size = MAP_APPFONT( 42, 10 ); - Text [ en-US ] = "~Confirm"; - }; - Edit ED_PASSWD_CONFIRM - { - HelpID = "sfx2:Edit:DLG_PASSWD:ED_PASSWD_CONFIRM"; - Border = TRUE; - PassWord = TRUE; - Pos = MAP_APPFONT( 57, 44 ); - Size = MAP_APPFONT( 75, 12 ); - }; - - String STR_PASSWD_MIN_LEN - { - Text [ en-US ] = "(Minimum $(MINLEN) characters)" ; - }; - String STR_PASSWD_EMPTY - { - Text [ en-US ] = "(The password can be empty)" ; - }; - - FixedText FT_PASSWD_MINLEN - { - Pos = MAP_APPFONT(12, 65 ); - Size = MAP_APPFONT( 126, 10 ); - }; - - FixedLine GB_PASSWD_PASSWORD - { - Pos = MAP_APPFONT( 6, 3 ); - Size = MAP_APPFONT( 132, 8 ); - Text [ en-US ] = "Password" ; - }; - FixedText FT_PASSWD_PASSWORD2 - { - Pos = MAP_APPFONT( 12, 30 ); - Size = MAP_APPFONT( 42, 10 ); - Text [ en-US ] = "P~assword"; - }; - Edit ED_PASSWD_PASSWORD2 - { - Border = TRUE; - PassWord = TRUE; - Pos = MAP_APPFONT( 57, 29 ); - Size = MAP_APPFONT( 75, 12 ); - }; - FixedText FT_PASSWD_CONFIRM2 - { - Pos = MAP_APPFONT( 12, 45 ); - Size = MAP_APPFONT( 42, 10 ); - Text [ en-US ] = "Confir~m"; - }; - Edit ED_PASSWD_CONFIRM2 - { - Border = TRUE; - PassWord = TRUE; - Pos = MAP_APPFONT( 57, 44 ); - Size = MAP_APPFONT( 75, 12 ); - }; - OKButton BTN_PASSWD_OK - { - Disable = TRUE; - Pos = MAP_APPFONT( 144, 6 ); - Size = MAP_APPFONT( 50, 14 ); - DefButton = TRUE; - }; - CancelButton BTN_PASSWD_CANCEL - { - Pos = MAP_APPFONT( 144, 23 ); - Size = MAP_APPFONT( 50, 14 ); - }; - HelpButton BTN_PASSWD_HELP - { - Pos = MAP_APPFONT( 144, 43 ); - Size = MAP_APPFONT( 50, 14 ); - }; - String TEXT_PASSWD - { - Text [ en-US ] = "Password" ; - }; - -}; - |