From f8576de2b3cf01d808079dec4a2a7b9f9399bb06 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 5 Jul 2010 08:06:21 +0200 Subject: cws tl82: #i112898# memory leak fixed --- linguistic/source/lngsvcmgr.cxx | 34 ++++++++++++++++++++++------------ linguistic/source/lngsvcmgr.hxx | 2 ++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index 82caafe02e..5761f955f2 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -45,6 +45,8 @@ #include #include +#include + #include "lngsvcmgr.hxx" #include "lngopt.hxx" #include "misc.hxx" @@ -605,6 +607,14 @@ LngSvcMgr::LngSvcMgr() : EnableNotification( aNames ); } +void LngSvcMgr::clearSvcInfoArray(SvcInfoArray* pInfo) +{ + if (pInfo) + { + std::for_each(pInfo->begin(), pInfo->end(), boost::checked_deleter()); + delete pInfo; + } +} LngSvcMgr::~LngSvcMgr() { @@ -612,10 +622,10 @@ LngSvcMgr::~LngSvcMgr() // will be freed in the destructor of the respective Reference's // xSpellDsp, xGrammarDsp, xHyphDsp, xThesDsp - delete pAvailSpellSvcs; - delete pAvailGrammarSvcs; - delete pAvailHyphSvcs; - delete pAvailThesSvcs; + clearSvcInfoArray(pAvailSpellSvcs); + clearSvcInfoArray(pAvailGrammarSvcs); + clearSvcInfoArray(pAvailHyphSvcs); + clearSvcInfoArray(pAvailThesSvcs); } @@ -652,7 +662,7 @@ void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames ) if (0 == rName.compareTo( aSpellCheckerList, aSpellCheckerList.getLength() )) { // delete old cached data, needs to be acquired new on demand - delete pAvailSpellSvcs; pAvailSpellSvcs = 0; + clearSvcInfoArray(pAvailSpellSvcs); pAvailSpellSvcs = 0; OUString aNode( aSpellCheckerList ); if (lcl_SeqHasString( aSpellCheckerListEntries, aKeyText )) @@ -677,7 +687,7 @@ void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames ) else if (0 == rName.compareTo( aGrammarCheckerList, aGrammarCheckerList.getLength() )) { // delete old cached data, needs to be acquired new on demand - delete pAvailGrammarSvcs; pAvailGrammarSvcs = 0; + clearSvcInfoArray(pAvailGrammarSvcs); pAvailGrammarSvcs = 0; OUString aNode( aGrammarCheckerList ); if (lcl_SeqHasString( aGrammarCheckerListEntries, aKeyText )) @@ -705,7 +715,7 @@ void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames ) else if (0 == rName.compareTo( aHyphenatorList, aHyphenatorList.getLength() )) { // delete old cached data, needs to be acquired new on demand - delete pAvailHyphSvcs; pAvailHyphSvcs = 0; + clearSvcInfoArray(pAvailHyphSvcs); pAvailHyphSvcs = 0; OUString aNode( aHyphenatorList ); if (lcl_SeqHasString( aHyphenatorListEntries, aKeyText )) @@ -730,7 +740,7 @@ void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames ) else if (0 == rName.compareTo( aThesaurusList, aThesaurusList.getLength() )) { // delete old cached data, needs to be acquired new on demand - delete pAvailThesSvcs; pAvailThesSvcs = 0; + clearSvcInfoArray(pAvailThesSvcs); pAvailThesSvcs = 0; OUString aNode( aThesaurusList ); if (lcl_SeqHasString( aThesaurusListEntries, aKeyText )) @@ -1402,7 +1412,7 @@ uno::Sequence< OUString > SAL_CALL { // don't used cached data here (force re-evaluation in order to have downloaded dictionaries // already found without the need to restart the office - delete pAvailSpellSvcs; pAvailSpellSvcs = 0; + clearSvcInfoArray(pAvailSpellSvcs); pAvailSpellSvcs = 0; GetAvailableSpellSvcs_Impl(); pInfoArray = pAvailSpellSvcs; } @@ -1410,7 +1420,7 @@ uno::Sequence< OUString > SAL_CALL { // don't used cached data here (force re-evaluation in order to have downloaded dictionaries // already found without the need to restart the office - delete pAvailGrammarSvcs; pAvailGrammarSvcs = 0; + clearSvcInfoArray(pAvailGrammarSvcs); pAvailGrammarSvcs = 0; GetAvailableGrammarSvcs_Impl(); pInfoArray = pAvailGrammarSvcs; } @@ -1418,7 +1428,7 @@ uno::Sequence< OUString > SAL_CALL { // don't used cached data here (force re-evaluation in order to have downloaded dictionaries // already found without the need to restart the office - delete pAvailHyphSvcs; pAvailHyphSvcs = 0; + clearSvcInfoArray(pAvailHyphSvcs); pAvailHyphSvcs = 0; GetAvailableHyphSvcs_Impl(); pInfoArray = pAvailHyphSvcs; } @@ -1426,7 +1436,7 @@ uno::Sequence< OUString > SAL_CALL { // don't used cached data here (force re-evaluation in order to have downloaded dictionaries // already found without the need to restart the office - delete pAvailThesSvcs; pAvailThesSvcs = 0; + clearSvcInfoArray(pAvailThesSvcs); pAvailThesSvcs = 0; GetAvailableThesSvcs_Impl(); pInfoArray = pAvailThesSvcs; } diff --git a/linguistic/source/lngsvcmgr.hxx b/linguistic/source/lngsvcmgr.hxx index 5ffb9defdb..51f44d90c5 100644 --- a/linguistic/source/lngsvcmgr.hxx +++ b/linguistic/source/lngsvcmgr.hxx @@ -143,6 +143,8 @@ class LngSvcMgr : void SetAvailableCfgServiceLists( LinguDispatcher &rDispatcher, const SvcInfoArray &rAvailSvcs ); + static void clearSvcInfoArray(SvcInfoArray *pInfo); + // utl::ConfigItem (to allow for listening of changes of relevant properties) virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames ); virtual void Commit(); -- cgit v1.2.3 From d112ae35a2dde7830676a4417f15886f99c16ea4 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 7 Jul 2010 08:44:22 +0200 Subject: cws tl82: automatic and silent conversion of user dictionaries to human readable UTF-8 format (DIC_VERSION_7) --- linguistic/source/dicimp.cxx | 115 ++++++++++++------------------------------- 1 file changed, 31 insertions(+), 84 deletions(-) diff --git a/linguistic/source/dicimp.cxx b/linguistic/source/dicimp.cxx index 04fc03b497..3460246dbc 100755 --- a/linguistic/source/dicimp.cxx +++ b/linguistic/source/dicimp.cxx @@ -438,101 +438,48 @@ ULONG DictionaryNeo::saveEntries(const OUString &rURL) return static_cast< ULONG >(-1); SvStreamPtr pStream = SvStreamPtr( utl::UcbStreamHelper::CreateStream( xStream ) ); - ULONG nErr = sal::static_int_cast< ULONG >(-1); - rtl_TextEncoding eEnc = osl_getThreadTextEncoding(); - if (nDicVersion >= DIC_VERSION_6) - eEnc = RTL_TEXTENCODING_UTF8; - - if (nDicVersion == DIC_VERSION_7) + // + // Always write as the latest version, i.e. DIC_VERSION_7 + // + rtl_TextEncoding eEnc = RTL_TEXTENCODING_UTF8; + pStream->WriteLine(ByteString (pVerOOo7)); + if (0 != (nErr = pStream->GetError())) + return nErr; + if (nLanguage == LANGUAGE_NONE) + pStream->WriteLine(ByteString("lang: ")); + else { - pStream->WriteLine(ByteString (pVerOOo7)); - if (0 != (nErr = pStream->GetError())) - return nErr; - - if (nLanguage == LANGUAGE_NONE) - pStream->WriteLine(ByteString("lang: ")); - else - { - ByteString aLine("lang: "); - aLine += ByteString( String( MsLangId::convertLanguageToIsoString( nLanguage ) ), eEnc); - pStream->WriteLine( aLine ); - } - if (0 != (nErr = pStream->GetError())) - return nErr; - - if (eDicType == DictionaryType_POSITIVE) - pStream->WriteLine(ByteString("type: positive")); - else - pStream->WriteLine(ByteString("type: negative")); - if (0 != (nErr = pStream->GetError())) - return nErr; - - pStream->WriteLine(ByteString("---")); - if (0 != (nErr = pStream->GetError())) - return nErr; - - const uno::Reference< XDictionaryEntry > *pEntry = aEntries.getConstArray(); - for (INT32 i = 0; i < nCount; i++) - { - ByteString aOutStr = formatForSave(pEntry[i], eEnc); - pStream->WriteLine (aOutStr); - if (0 != (nErr = pStream->GetError())) - return nErr; - } + ByteString aLine("lang: "); + aLine += ByteString( String( MsLangId::convertLanguageToIsoString( nLanguage ) ), eEnc); + pStream->WriteLine( aLine ); } + if (0 != (nErr = pStream->GetError())) + return nErr; + if (eDicType == DictionaryType_POSITIVE) + pStream->WriteLine(ByteString("type: positive")); else + pStream->WriteLine(ByteString("type: negative")); + if (0 != (nErr = pStream->GetError())) + return nErr; + pStream->WriteLine(ByteString("---")); + if (0 != (nErr = pStream->GetError())) + return nErr; + const uno::Reference< XDictionaryEntry > *pEntry = aEntries.getConstArray(); + for (INT32 i = 0; i < nCount; i++) { - sal_Char aWordBuf[BUFSIZE]; - - // write version - const sal_Char *pVerStr = NULL; - if (DIC_VERSION_6 == nDicVersion) - pVerStr = pVerStr6; - else - pVerStr = eDicType == DictionaryType_POSITIVE ? pVerStr2 : pVerStr5; - strcpy( aWordBuf, pVerStr ); // #100211# - checked - USHORT nLen = sal::static_int_cast< USHORT >(strlen( aWordBuf )); - *pStream << nLen; + ByteString aOutStr = formatForSave(pEntry[i], eEnc); + pStream->WriteLine (aOutStr); if (0 != (nErr = pStream->GetError())) return nErr; - pStream->Write(aWordBuf, nLen); - if (0 != (nErr = pStream->GetError())) - return nErr; - - *pStream << nLanguage; - if (0 != (nErr = pStream->GetError())) - return nErr; - *pStream << (sal_Char) (eDicType == DictionaryType_NEGATIVE ? TRUE : FALSE); - if (0 != (nErr = pStream->GetError())) - return nErr; - - const uno::Reference< XDictionaryEntry > *pEntry = aEntries.getConstArray(); - for (INT32 i = 0; i < nCount; i++) - { - ByteString aOutStr = formatForSave(pEntry[i], eEnc); - - // the old format would fail (mis-calculation of nLen) and write - // uninitialized junk for combined len >= BUFSIZE - we truncate - // silently here, but BUFSIZE is large anyway. - nLen = aOutStr.Len(); - if (nLen >= BUFSIZE) - nLen = BUFSIZE - 1; - - *pStream << nLen; - if (0 != (nErr = pStream->GetError())) - return nErr; - pStream->Write(aOutStr.GetBuffer(), nLen); - if (0 != (nErr = pStream->GetError())) - return nErr; - } } - //! get return value before Stream is destroyed - ULONG nError = pStream->GetError(); + //If we are migrating from an older version, then on first successful + //write, we're now converted to the latest version, i.e. DIC_VERSION_7 + nDicVersion = DIC_VERSION_7; - return nError; + return nErr; } void DictionaryNeo::launchEvent(INT16 nEvent, -- cgit v1.2.3 From 5b31df5499d2ed5ff503b6e466e8c7e9cf4bfe70 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 26 Jul 2010 13:11:58 +0200 Subject: cws tl82: #i106993# thesaurus code clean-up --- sfx2/source/menu/mnumgr.cxx | 3 ++- sfx2/source/menu/thessubmenu.cxx | 33 --------------------------------- sfx2/source/menu/thessubmenu.hxx | 4 ---- 3 files changed, 2 insertions(+), 38 deletions(-) mode change 100644 => 100755 sfx2/source/menu/thessubmenu.hxx diff --git a/sfx2/source/menu/mnumgr.cxx b/sfx2/source/menu/mnumgr.cxx index 8269611c97..882f6ae8a6 100755 --- a/sfx2/source/menu/mnumgr.cxx +++ b/sfx2/source/menu/mnumgr.cxx @@ -60,6 +60,7 @@ #include #include #include +#include #include @@ -244,7 +245,7 @@ PopupMenu* InsertThesaurusSubmenu_Impl( SfxBindings* pBindings, Menu* pSVMenu ) //! item ids should start with values > 0, since 0 has special meaning const USHORT nId = i + 1; - String aItemText( GetThesaurusReplaceText_Impl( aSynonyms[i] ) ); + String aItemText( linguistic::GetThesaurusReplaceText( aSynonyms[i] ) ); pThesSubMenu->InsertItem( nId, aItemText ); ::rtl::OUString aCmd( ::rtl::OUString::createFromAscii( ".uno:ThesaurusFromContext?WordReplace:string=" ) ); aCmd += aItemText; diff --git a/sfx2/source/menu/thessubmenu.cxx b/sfx2/source/menu/thessubmenu.cxx index a47e1b18a4..b153196cd5 100755 --- a/sfx2/source/menu/thessubmenu.cxx +++ b/sfx2/source/menu/thessubmenu.cxx @@ -61,39 +61,6 @@ SFX_IMPL_MENU_CONTROL(SfxThesSubMenuControl, SfxStringItem); //////////////////////////////////////////////////////////// -String GetThesaurusReplaceText_Impl( const ::rtl::OUString &rText ) -{ - // The strings returned by the thesaurus sometimes have some - // explanation text put in between '(' and ')' or a trailing '*'. - // These parts should not be put in the ReplaceEdit Text that may get - // inserted into the document. Thus we strip them from the text. - - String aText( rText ); - - xub_StrLen nPos = aText.Search( sal_Unicode('(') ); - while (STRING_NOTFOUND != nPos) - { - xub_StrLen nEnd = aText.Search( sal_Unicode(')'), nPos ); - if (STRING_NOTFOUND != nEnd) - aText.Erase( nPos, nEnd-nPos+1 ); - else - break; - nPos = aText.Search( sal_Unicode('(') ); - } - - nPos = aText.Search( sal_Unicode('*') ); - if (STRING_NOTFOUND != nPos) - aText.Erase( nPos ); - - // remove any possible remaining ' ' that may confuse the thesaurus - // when it gets called with the text - aText.EraseLeadingAndTrailingChars( sal_Unicode(' ') ); - - return aText; -} - -//////////////////////////////////////////////////////////// - /* Ctor; setzt Select-Handler am Menu und traegt Menu diff --git a/sfx2/source/menu/thessubmenu.hxx b/sfx2/source/menu/thessubmenu.hxx old mode 100644 new mode 100755 index 13438a917a..ccc5ccde66 --- a/sfx2/source/menu/thessubmenu.hxx +++ b/sfx2/source/menu/thessubmenu.hxx @@ -46,10 +46,6 @@ namespace css = ::com::sun::star; //////////////////////////////////////////////////////////// -String GetThesaurusReplaceText_Impl( const ::rtl::OUString &rText ); - -//////////////////////////////////////////////////////////// - class SfxThesSubMenuControl : public SfxMenuControl { PopupMenu* pMenu; -- cgit v1.2.3 From 7e660a75ce794438ef80bc36bb56ff7eccb951a5 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 20 Aug 2010 12:33:43 +0200 Subject: cws tl82: #i113440# string resource fixed --- sfx2/source/dialog/securitypage.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 sfx2/source/dialog/securitypage.src diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src old mode 100644 new mode 100755 index 4818068990..1111075403 --- a/sfx2/source/dialog/securitypage.src +++ b/sfx2/source/dialog/securitypage.src @@ -79,9 +79,9 @@ TabPage TP_DOCINFOSECURITY Pos = MAP_APPFONT( 12, 48 ); Size = MAP_APPFONT( 236, 3 * RSC_CD_FIXEDTEXT_HEIGHT ); Text [ en-US ] = - "Note: After a password has been set, the document will only open "\ - "with the password. Should you lose the password, there will be "\ - "no way to recover the document. Please also note that this password "\ + "Note: After a password has been set, the document will only open " + "with the password. Should you lose the password, there will be " + "no way to recover the document. Please also note that this password " "is case-sensitive."; WordBreak = TRUE; }; -- cgit v1.2.3 From 71549d59af8a695b672cd4649edcd9ae0514d87d Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 25 Aug 2010 14:39:15 +0200 Subject: cws tl82: #i114087# uno slot name fixed --- officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu diff --git a/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu old mode 100644 new mode 100755 index 7570fda066..4ed9be5a3d --- a/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu @@ -38,7 +38,7 @@ ~Text Mode - + ~Import Formula... -- cgit v1.2.3 From 8f39fa027f4ee42398357a1a3ca866f8e88f016f Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 2 Sep 2010 14:48:49 +0200 Subject: cws tl82: #i114272# password dialog messages and min password length changed --- uui/source/masterpasscrtdlg.cxx | 2 +- uui/source/masterpasscrtdlg.src | 2 +- uui/source/passworderrs.src | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 uui/source/masterpasscrtdlg.cxx mode change 100644 => 100755 uui/source/masterpasscrtdlg.src mode change 100644 => 100755 uui/source/passworderrs.src diff --git a/uui/source/masterpasscrtdlg.cxx b/uui/source/masterpasscrtdlg.cxx old mode 100644 new mode 100755 index b9e82b862f..b7e70233ce --- a/uui/source/masterpasscrtdlg.cxx +++ b/uui/source/masterpasscrtdlg.cxx @@ -93,7 +93,7 @@ MasterPasswordCreateDialog::MasterPasswordCreateDialog aHelpBtn ( this, ResId( BTN_MASTERPASSCRT_HELP, *pResMgr ) ), pResourceMgr ( pResMgr ), - nMinLen ( 5 ) + nMinLen ( 1 ) { FreeResource(); diff --git a/uui/source/masterpasscrtdlg.src b/uui/source/masterpasscrtdlg.src old mode 100644 new mode 100755 index 65e24205a5..7f933fd0c2 --- a/uui/source/masterpasscrtdlg.src +++ b/uui/source/masterpasscrtdlg.src @@ -86,7 +86,7 @@ ModalDialog DLG_UUI_MASTERPASSWORD_CRT Pos = MAP_APPFONT ( COL_0 , ROW_6 ) ; Size = MAP_APPFONT ( CTRL_WIDTH , 8*RSC_CD_FIXEDTEXT_HEIGHT ) ; WordBreak = TRUE ; - Text [ en-US ] = "Caution: Make sure you remember the Master Password you have set. If you forget your Master Password, you will be unable to access any of the information protected by it. Passwords are case-sensitive and at least five characters long."; + Text [ en-US ] = "Caution: If you forget the master password, you will be unable to access any of the information protected by it. Passwords are case-sensitive."; }; FixedLine FL_CAUTIONTEXT { diff --git a/uui/source/passworderrs.src b/uui/source/passworderrs.src old mode 100644 new mode 100755 index 6476e28319..ed96e28e07 --- a/uui/source/passworderrs.src +++ b/uui/source/passworderrs.src @@ -43,7 +43,7 @@ String STR_ERROR_PASSWORD_TO_MODIFY_WRONG String STR_ERROR_MASTERPASSWORD_WRONG { - Text [ en-US ] = "The wrong Master Password has been entered. %PRODUCTNAME could not access web login information protected by Master Password.\n\nNote: Passwords are case-sensitive and at least five characters long."; + Text [ en-US ] = "Caution: If you forget the master password, you will be unable to access any of the information protected by it. Passwords are case-sensitive."; }; String STR_ERROR_PASSWORDS_NOT_IDENTICAL -- cgit v1.2.3 From 8a3287c7e3204937f9f02a2dc5dc9c369a8af794 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 6 Sep 2010 09:19:49 +0200 Subject: cws tl82: #i114292# button order changed --- uui/source/logindlg.src | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) mode change 100644 => 100755 uui/source/logindlg.src diff --git a/uui/source/logindlg.src b/uui/source/logindlg.src old mode 100644 new mode 100755 index d9a0e538c9..822547faf3 --- a/uui/source/logindlg.src +++ b/uui/source/logindlg.src @@ -174,21 +174,21 @@ ModalDialog DLG_UUI_LOGIN Pos = MAP_APPFONT( 0 , 216 ) ; Size = MAP_APPFONT( 177 , 8 ) ; }; - - OKButton BTN_LOGIN_OK + + HelpButton BTN_LOGIN_HELP { Pos = MAP_APPFONT( 6 , 227 ) ; Size = MAP_APPFONT( 50 , 14 ) ; - DefButton = TRUE ; }; - - CancelButton BTN_LOGIN_CANCEL + + OKButton BTN_LOGIN_OK { Pos = MAP_APPFONT( 66 , 227 ) ; Size = MAP_APPFONT( 50 , 14 ) ; + DefButton = TRUE ; }; - HelpButton BTN_LOGIN_HELP + CancelButton BTN_LOGIN_CANCEL { Pos = MAP_APPFONT( 121 , 227 ) ; Size = MAP_APPFONT( 50 , 14 ) ; -- cgit v1.2.3 From c4e900eaf8284467f75d842f0da25b60208c8fbf Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 6 Sep 2010 10:02:33 +0200 Subject: cws tl82: #i114160# SimplePasswordRequest and respective dialog --- uui/source/iahndl-authentication.cxx | 46 +++++++++---- uui/source/ids.hrc | 3 + uui/source/passworddlg.cxx | 126 +++++++++++++++++++++++++++-------- uui/source/passworddlg.hrc | 18 +++-- uui/source/passworddlg.hxx | 10 ++- uui/source/passworddlg.src | 76 +++++++++++++++------ uui/source/passworderrs.src | 5 ++ 7 files changed, 216 insertions(+), 68 deletions(-) mode change 100644 => 100755 uui/source/ids.hrc mode change 100644 => 100755 uui/source/passworddlg.cxx mode change 100644 => 100755 uui/source/passworddlg.hrc mode change 100644 => 100755 uui/source/passworddlg.hxx mode change 100644 => 100755 uui/source/passworddlg.src diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index fe326f6bdc..3816c84d1b 100644 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -519,7 +519,8 @@ executePasswordDialog( task::PasswordRequestMode nMode, ::rtl::OUString aDocName, bool bMSCryptoMode, - bool bIsPasswordToModify ) + bool bIsPasswordToModify, + bool bIsSimplePasswordRequest ) SAL_THROW((uno::RuntimeException)) { try @@ -530,21 +531,36 @@ executePasswordDialog( ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); if( nMode == task::PasswordRequestMode_PASSWORD_CREATE ) { - const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length + if (bIsSimplePasswordRequest) + { + std::auto_ptr< PasswordDialog > pDialog( + new PasswordDialog( pParent, nMode, xManager.get(), aDocName, + bIsPasswordToModify, bIsSimplePasswordRequest ) ); + pDialog->SetMinLen(0); + + rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); + rInfo.SetPassword( pDialog->GetPassword() ); + } + else + { + const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length - VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create(); - AbstractPasswordToOpenModifyDialog *pTmp = pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen, bIsPasswordToModify ); - std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog( pTmp ); + VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create(); + AbstractPasswordToOpenModifyDialog *pTmp = pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen, bIsPasswordToModify ); + std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog( pTmp ); - rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); - rInfo.SetPassword( pDialog->GetPasswordToOpen() ); - rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() ); - rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() ); + rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); + rInfo.SetPassword( pDialog->GetPasswordToOpen() ); + rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() ); + rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() ); + } } - else + else // enter password or reenter password { std::auto_ptr< PasswordDialog > pDialog( - new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) ); + new PasswordDialog( pParent, nMode, xManager.get(), aDocName, + bIsPasswordToModify, bIsSimplePasswordRequest ) ); + pDialog->SetMinLen(0); rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); rInfo.SetPassword( bIsPasswordToModify ? String() : pDialog->GetPassword() ); @@ -567,7 +583,8 @@ handlePasswordRequest_( rContinuations, ::rtl::OUString aDocumentName, bool bMSCryptoMode, - bool bIsPasswordToModify ) + bool bIsPasswordToModify, + bool bIsSimplePasswordRequest = false ) SAL_THROW((uno::RuntimeException)) { uno::Reference< task::XInteractionRetry > xRetry; @@ -582,7 +599,7 @@ handlePasswordRequest_( LoginErrorInfo aInfo; executePasswordDialog( pParent, aInfo, nMode, - aDocumentName, bMSCryptoMode, bIsPasswordToModify ); + aDocumentName, bMSCryptoMode, bIsPasswordToModify, bIsSimplePasswordRequest ); switch (aInfo.GetResult()) { @@ -742,7 +759,8 @@ UUIInteractionHelper::handlePasswordRequest( rRequest->getContinuations(), rtl::OUString(), false /* bool bMSCryptoMode */, - false /* bool bIsPasswordToModify */); + false /* bool bIsPasswordToModify */, + true /* bool bIsSimplePasswordRequest */ ); return true; } diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc old mode 100644 new mode 100755 index 2228856101..58bc69ee4a --- a/uui/source/ids.hrc +++ b/uui/source/ids.hrc @@ -56,6 +56,7 @@ #define RID_UUI_ERRHDL (RID_UUI_START + 20) #define DLG_UUI_MASTERPASSWORD_CRT (RID_UUI_START + 21) #define DLG_UUI_PASSWORD (RID_UUI_START + 22) +#define STR_ERROR_SIMPLE_PASSWORD_WRONG (RID_UUI_START + 23) #define STR_ERROR_PASSWORD_TO_OPEN_WRONG (RID_UUI_START + 24) #define STR_ERROR_PASSWORD_TO_MODIFY_WRONG (RID_UUI_START + 25) #define DLG_UUI_UNKNOWNAUTH (RID_UUI_START + 26) @@ -93,6 +94,8 @@ #define STR_RENAME_OR_REPLACE (RID_UUI_START + 58) #define STR_NAME_CLASH_RENAME_ONLY (RID_UUI_START + 59) #define STR_SAME_NAME_USED (RID_UUI_START + 60) +#define STR_ENTER_SIMPLE_PASSWORD (RID_UUI_START + 61) +#define STR_CONFIRM_SIMPLE_PASSWORD (RID_UUI_START + 62) #define ERRCODE_UUI_IO_ABORT (ERRCODE_AREA_UUI + 0) #define ERRCODE_UUI_IO_ACCESSDENIED (ERRCODE_AREA_UUI + 1) diff --git a/uui/source/passworddlg.cxx b/uui/source/passworddlg.cxx old mode 100644 new mode 100755 index b66659ff6e..5c584a559f --- a/uui/source/passworddlg.cxx +++ b/uui/source/passworddlg.cxx @@ -25,67 +25,119 @@ * ************************************************************************/ +#include "passworddlg.hxx" +#include "passworddlg.hrc" +#include "ids.hrc" + #include #include -#ifndef UUI_IDS_HRC -#include -#endif -#ifndef UUI_PASSWORDDLG_HRC -#include -#endif -#include -// PasswordDialog--------------------------------------------------------- +using namespace ::com::sun::star; + // ----------------------------------------------------------------------- -IMPL_LINK( PasswordDialog, OKHdl_Impl, OKButton *, EMPTYARG ) +static void lcl_Move( Window &rWin, long nOffset ) { - EndDialog( RET_OK ); - return 1; + Point aTmp( rWin.GetPosPixel() ); + aTmp.Y() += nOffset; + rWin.SetPosPixel( aTmp ); } // ----------------------------------------------------------------------- PasswordDialog::PasswordDialog( Window* _pParent, - ::com::sun::star::task::PasswordRequestMode nDlgMode, + task::PasswordRequestMode nDlgMode, ResMgr * pResMgr, rtl::OUString& aDocURL, - bool bOpenToModify ) + bool bOpenToModify, + bool bIsSimplePasswordRequest ) :ModalDialog( _pParent, ResId( DLG_UUI_PASSWORD, *pResMgr ) ) ,aFTPassword( this, ResId( FT_PASSWORD, *pResMgr )) ,aEDPassword( this, ResId( ED_PASSWORD, *pResMgr )) + ,aFTConfirmPassword( this, ResId( FT_CONFIRM_PASSWORD, *pResMgr )) + ,aEDConfirmPassword( this, ResId( ED_CONFIRM_PASSWORD, *pResMgr )) ,aOKBtn ( this, ResId( BTN_PASSWORD_OK, *pResMgr )) ,aCancelBtn ( this, ResId( BTN_PASSWORD_CANCEL, *pResMgr )) ,aHelpBtn ( this, ResId( BTN_PASSWORD_HELP, *pResMgr )) ,aFixedLine1( this, ResId( FL_FIXED_LINE_1, *pResMgr )) + ,nMinLen(1) + ,aPasswdMismatch( ResId( STR_PASSWORD_MISMATCH, *pResMgr )) ,nDialogMode( nDlgMode ) ,pResourceMgr ( pResMgr ) { - if( nDialogMode == ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER ) + if( nDialogMode == task::PasswordRequestMode_PASSWORD_REENTER ) { - USHORT nErrStrId = bOpenToModify ? STR_ERROR_PASSWORD_TO_MODIFY_WRONG : STR_ERROR_PASSWORD_TO_OPEN_WRONG; + const USHORT nOpenToModifyErrStrId = bOpenToModify ? STR_ERROR_PASSWORD_TO_MODIFY_WRONG : STR_ERROR_PASSWORD_TO_OPEN_WRONG; + const USHORT nErrStrId = bIsSimplePasswordRequest ? STR_ERROR_SIMPLE_PASSWORD_WRONG : nOpenToModifyErrStrId; String aErrorMsg( ResId( nErrStrId, *pResourceMgr )); - ErrorBox aErrorBox( _pParent, WB_OK, aErrorMsg ); + ErrorBox aErrorBox( this, WB_OK, aErrorMsg ); aErrorBox.Execute(); } + // default settings for enter password or reenter passwd... + String aTitle( ResId( STR_TITLE_ENTER_PASSWORD, *pResourceMgr ) ); + aFTConfirmPassword.Hide(); + aEDConfirmPassword.Hide(); + aFTConfirmPassword.Enable( FALSE ); + aEDConfirmPassword.Enable( FALSE ); + + // settings for create password + if (nDialogMode == task::PasswordRequestMode_PASSWORD_CREATE) + { + aTitle = String( ResId( STR_TITLE_CREATE_PASSWORD, *pResourceMgr ) ); + + aFTConfirmPassword.SetText( String( ResId( STR_CONFIRM_SIMPLE_PASSWORD, *pResourceMgr ) ) ); + + aFTConfirmPassword.Show(); + aEDConfirmPassword.Show(); + aFTConfirmPassword.Enable( TRUE ); + aEDConfirmPassword.Enable( TRUE ); + } + else + { + // shrink dialog by size of hidden controls and move rest up accordingly + + long nDelta = aFixedLine1.GetPosPixel().Y() - aFTConfirmPassword.GetPosPixel().Y(); + + lcl_Move( aFixedLine1, -nDelta ); + lcl_Move( aOKBtn, -nDelta ); + lcl_Move( aCancelBtn, -nDelta ); + lcl_Move( aHelpBtn, -nDelta ); + + Size aNewDlgSize = GetSizePixel(); + aNewDlgSize.Height() -= nDelta; + SetSizePixel( aNewDlgSize ); + } + + SetText( aTitle ); + USHORT nStrId = bOpenToModify ? STR_ENTER_PASSWORD_TO_MODIFY : STR_ENTER_PASSWORD_TO_OPEN; aFTPassword.SetText( String( ResId( nStrId, *pResourceMgr ) ) ); + aFTPassword.SetText( aFTPassword.GetText() + aDocURL ); + if (bIsSimplePasswordRequest) + { + DBG_ASSERT( aDocURL.getLength() == 0, "A simple password request should not have a document URL! Use document password request instead." ); + aFTPassword.SetText( String( ResId( STR_ENTER_SIMPLE_PASSWORD, *pResourceMgr ) ) ); + } FreeResource(); - aFTPassword.SetText( aFTPassword.GetText() + aDocURL ); - aOKBtn.SetClickHdl( LINK( this, PasswordDialog, OKHdl_Impl ) ); - long nLabelWidth = aFTPassword.GetSizePixel().Width(); - long nLabelHeight = aFTPassword.GetSizePixel().Height(); - long nTextWidth = aFTPassword.GetCtrlTextWidth( aFTPassword.GetText() ); - long nTextHeight = aFTPassword.GetTextHeight(); + + // + // move controls down by extra height needed for aFTPassword + // (usually only needed if a URL was provided) + // + + long nLabelWidth = aFTPassword.GetSizePixel().Width(); + long nLabelHeight = aFTPassword.GetSizePixel().Height(); + long nTextWidth = aFTPassword.GetCtrlTextWidth( aFTPassword.GetText() ); + long nTextHeight = aFTPassword.GetTextHeight(); Rectangle aLabelRect( aFTPassword.GetPosPixel(), aFTPassword.GetSizePixel() ); Rectangle aRect = aFTPassword.GetTextRect( aLabelRect, aFTPassword.GetText() ); @@ -105,13 +157,31 @@ PasswordDialog::PasswordDialog( aNewLabelSize.Height() = nNewLabelHeight; aFTPassword.SetPosSizePixel( aFTPassword.GetPosPixel(), aNewLabelSize ); - Window* pControls[] = { &aEDPassword, &aFixedLine1, &aOKBtn, &aCancelBtn, &aHelpBtn }; - const sal_Int32 nCCount = sizeof( pControls ) / sizeof( pControls[0] ); - for ( int i = 0; i < nCCount; ++i ) + lcl_Move( aEDPassword, nDelta ); + lcl_Move( aFTConfirmPassword, nDelta ); + lcl_Move( aEDConfirmPassword, nDelta ); + lcl_Move( aFixedLine1, nDelta ); + lcl_Move( aOKBtn, nDelta ); + lcl_Move( aCancelBtn, nDelta ); + lcl_Move( aHelpBtn, nDelta ); +} + + +IMPL_LINK( PasswordDialog, OKHdl_Impl, OKButton *, EMPTYARG ) +{ + bool bEDPasswdValid = aEDPassword.GetText().Len() >= nMinLen; + bool bPasswdMismatch = aEDConfirmPassword.GetText() != aEDPassword.GetText(); + bool bValid = (!aEDConfirmPassword.IsVisible() && bEDPasswdValid) || + (aEDConfirmPassword.IsVisible() && bEDPasswdValid && !bPasswdMismatch); + + if (aEDConfirmPassword.IsVisible() && bPasswdMismatch) { - Point aNewPos =(*pControls[i]).GetPosPixel(); - aNewPos.Y() += nDelta; - pControls[i]->SetPosSizePixel( aNewPos, pControls[i]->GetSizePixel() ); + ErrorBox aErrorBox( this, WB_OK, aPasswdMismatch ); + aErrorBox.Execute(); } + else if (bValid) + EndDialog( RET_OK ); + return 1; } + diff --git a/uui/source/passworddlg.hrc b/uui/source/passworddlg.hrc old mode 100644 new mode 100755 index edda2504c1..24ec8aca9d --- a/uui/source/passworddlg.hrc +++ b/uui/source/passworddlg.hrc @@ -29,12 +29,18 @@ #define PASSWORDDLG_HRC // local identifiers -#define BTN_PASSWORD_OK 1 -#define ED_PASSWORD 2 -#define FT_PASSWORD 3 -#define FL_FIXED_LINE_1 4 -#define BTN_PASSWORD_HELP 5 -#define BTN_PASSWORD_CANCEL 6 +#define BTN_PASSWORD_OK 1 +#define ED_PASSWORD 2 +#define FT_PASSWORD 3 +#define FT_CONFIRM_PASSWORD 4 +#define ED_CONFIRM_PASSWORD 5 +#define FL_FIXED_LINE_1 6 +#define BTN_PASSWORD_HELP 7 +#define BTN_PASSWORD_CANCEL 8 + +#define STR_TITLE_CREATE_PASSWORD 9 +#define STR_TITLE_ENTER_PASSWORD 10 +#define STR_PASSWORD_MISMATCH 11 #endif // PASSWORDDLG_HRC diff --git a/uui/source/passworddlg.hxx b/uui/source/passworddlg.hxx old mode 100644 new mode 100755 index e5a0a7885b..9e959a6aba --- a/uui/source/passworddlg.hxx +++ b/uui/source/passworddlg.hxx @@ -37,21 +37,28 @@ #include //============================================================================ + class PasswordDialog : public ModalDialog { FixedText aFTPassword; Edit aEDPassword; + FixedText aFTConfirmPassword; + Edit aEDConfirmPassword; OKButton aOKBtn; CancelButton aCancelBtn; HelpButton aHelpBtn; FixedLine aFixedLine1; + USHORT nMinLen; + String aPasswdMismatch; DECL_LINK( OKHdl_Impl, OKButton * ); public: - PasswordDialog( Window* pParent, ::com::sun::star::task::PasswordRequestMode nDlgMode, ResMgr * pResMgr, ::rtl::OUString& aDocURL, bool bOpenToModify = false ); + PasswordDialog( Window* pParent, ::com::sun::star::task::PasswordRequestMode nDlgMode, ResMgr * pResMgr, ::rtl::OUString& aDocURL, + bool bOpenToModify = false, bool bIsSimplePasswordRequest = false ); + void SetMinLen( USHORT nMin ) { nMinLen = nMin; } String GetPassword() const { return aEDPassword.GetText(); } private: @@ -60,3 +67,4 @@ private: }; #endif // PASSWORDDLG_HXX + diff --git a/uui/source/passworddlg.src b/uui/source/passworddlg.src old mode 100644 new mode 100755 index 7a96c4aa5a..ba6c2ad9fd --- a/uui/source/passworddlg.src +++ b/uui/source/passworddlg.src @@ -41,48 +41,61 @@ ModalDialog DLG_UUI_PASSWORD Moveable = TRUE ; OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT( 145, 91 ); - Text [ en-US ] = "Enter password"; + Size = MAP_APPFONT( 165, 95 ); FixedText FT_PASSWORD { - Pos = MAP_APPFONT( 3, 4 ); - Size = MAP_APPFONT( 139, 28 ); + Pos = MAP_APPFONT( 3, 6 ); + Size = MAP_APPFONT( 159, 8 ); WordBreak = TRUE; }; Edit ED_PASSWORD { - Pos = MAP_APPFONT( 3, 51 ); - Size = MAP_APPFONT( 139, 13 ); + Pos = MAP_APPFONT( 3, 17 ); + Size = MAP_APPFONT( 159, 12 ); Border = TRUE ; PassWord = TRUE ; }; - FixedLine FL_FIXED_LINE_1 + FixedText FT_CONFIRM_PASSWORD { - Pos = MAP_APPFONT( 0, 66 ); - Size = MAP_APPFONT( 145, 6 ); + Pos = MAP_APPFONT( 3, 34 ); + Size = MAP_APPFONT( 159, 8 ); + WordBreak = TRUE; }; - OKButton BTN_PASSWORD_OK + Edit ED_CONFIRM_PASSWORD { - Pos = MAP_APPFONT( 27, 72 ); - Size = MAP_APPFONT( 37, 15 ); - DefButton = TRUE ; - DefButton = TRUE; + Pos = MAP_APPFONT( 3, 45 ); + Size = MAP_APPFONT( 159, 12 ); + Border = TRUE ; + PassWord = TRUE ; }; - CancelButton BTN_PASSWORD_CANCEL + FixedLine FL_FIXED_LINE_1 { - Pos = MAP_APPFONT( 66, 72 ); - Size = MAP_APPFONT( 37, 15 ); + Pos = MAP_APPFONT( 0, 63 ); + Size = MAP_APPFONT( 165, 8 ); }; HelpButton BTN_PASSWORD_HELP { - Pos = MAP_APPFONT( 105, 72 ); - Size = MAP_APPFONT( 37, 15 ); + Pos = MAP_APPFONT( 3, 76 ); + Size = MAP_APPFONT( 50, 14 ); + }; + + OKButton BTN_PASSWORD_OK + { + Pos = MAP_APPFONT( 59, 76 ); + Size = MAP_APPFONT( 50, 14 ); + DefButton = TRUE ; + }; + + CancelButton BTN_PASSWORD_CANCEL + { + Pos = MAP_APPFONT( 112, 76 ); + Size = MAP_APPFONT( 50, 14 ); }; String STR_ENTER_PASSWORD_TO_OPEN @@ -94,5 +107,30 @@ ModalDialog DLG_UUI_PASSWORD { Text [ en-US ] = "Enter password to modify file: \n"; }; + + String STR_ENTER_SIMPLE_PASSWORD + { + Text [ en-US ] = "Enter password: "; + }; + + String STR_CONFIRM_SIMPLE_PASSWORD + { + Text [ en-US ] = "Confirm password: "; + }; + + String STR_TITLE_CREATE_PASSWORD + { + Text [ en-US ] = "Set Password"; + }; + + String STR_TITLE_ENTER_PASSWORD + { + Text [ en-US ] = "Enter Password"; + }; + + String STR_PASSWORD_MISMATCH + { + Text [ en-US ] = "The confirmation password did not match the password. Set the password again by entering the same password in both boxes." ; + }; }; diff --git a/uui/source/passworderrs.src b/uui/source/passworderrs.src index ed96e28e07..4d132f834d 100755 --- a/uui/source/passworderrs.src +++ b/uui/source/passworderrs.src @@ -46,6 +46,11 @@ String STR_ERROR_MASTERPASSWORD_WRONG Text [ en-US ] = "Caution: If you forget the master password, you will be unable to access any of the information protected by it. Passwords are case-sensitive."; }; +String STR_ERROR_SIMPLE_PASSWORD_WRONG +{ + Text [ en-US ] = "The password is incorrect."; +}; + String STR_ERROR_PASSWORDS_NOT_IDENTICAL { Text [ en-US ] = "The password confirmation does not match."; -- cgit v1.2.3 From b6f6c6ee848288c7404794f4255936fe70870f1f Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 7 Sep 2010 10:46:02 +0200 Subject: cws tl82: #i114272# error message changed --- uui/source/passworderrs.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uui/source/passworderrs.src b/uui/source/passworderrs.src index 4d132f834d..249aa1f559 100755 --- a/uui/source/passworderrs.src +++ b/uui/source/passworderrs.src @@ -43,7 +43,7 @@ String STR_ERROR_PASSWORD_TO_MODIFY_WRONG String STR_ERROR_MASTERPASSWORD_WRONG { - Text [ en-US ] = "Caution: If you forget the master password, you will be unable to access any of the information protected by it. Passwords are case-sensitive."; + Text [ en-US ] = "The master password is incorrect."; }; String STR_ERROR_SIMPLE_PASSWORD_WRONG -- cgit v1.2.3