diff options
author | obo <obo@openoffice.org> | 2010-06-18 13:31:23 +0200 |
---|---|---|
committer | obo <obo@openoffice.org> | 2010-06-18 13:31:23 +0200 |
commit | 1049a5b33e6c2b40c4557bc6932956cc2431b03f (patch) | |
tree | d89910dcff61363f801790d9a6541275baaebf7e | |
parent | 9827d16734c9e1984a0fd7aab43209df07d992ff (diff) | |
parent | 86307827b3b671154a44b552e2f8a8bb94791442 (diff) |
CWS-TOOLING: integrate CWS tl79
25 files changed, 1975 insertions, 1046 deletions
diff --git a/sfx2/inc/sfx2/htmlmode.hxx b/sfx2/inc/sfx2/htmlmode.hxx new file mode 100644 index 000000000000..51f341c5c3c0 --- /dev/null +++ b/sfx2/inc/sfx2/htmlmode.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SFX_HTMLMODE_HXX_ +#define _SFX_HTMLMODE_HXX_ + + +#define HTMLMODE_ON 0x0001 +#define HTMLMODE_PARA_BORDER 0x0002 /* Absatzumrandungen */ +#define HTMLMODE_PARA_DISTANCE 0x0004 /* bestimmte Absatzabstaende */ +#define HTMLMODE_SMALL_CAPS 0x0008 /* Kapitaelchen */ +#define HTMLMODE_FRM_COLUMNS 0x0010 /* spaltige Rahmen */ +#define HTMLMODE_SOME_STYLES 0x0020 /* mind. MS IE */ +#define HTMLMODE_FULL_STYLES 0x0040 /* == SW */ +#define HTMLMODE_BLINK 0x0080 /* blinkende Zeichen*/ +#define HTMLMODE_PARA_BLOCK 0x0100 /* Blocksatz */ +#define HTMLMODE_DROPCAPS 0x0200 /* Initialen*/ +#define HTMLMODE_FIRSTLINE 0x0400 /* Erstzeileneinzug mit Spacer == NS 3.0 */ +#define HTMLMODE_GRAPH_POS 0x0800 /* Grafikpositionen Hintergrund */ +#define HTMLMODE_FULL_ABS_POS 0x1000 /* abs. Rahmenpositionierung */ +#define HTMLMODE_SOME_ABS_POS 0x2000 /* abs. Rahmenpositionierung vollst.*/ +#define HTMLMODE_RESERVED1 0x4000 +#define HTMLMODE_RESERVED0 0x8000 + + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 6d2b6611991e..63eb9e8c876f 100644..100755 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -693,6 +693,15 @@ public: sal_Int32 nVersion, sal_Bool bTemplate = sal_False) const = 0; + // change recording and respective passwword protection for Writer and Calc + // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON + // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT + virtual bool IsChangeRecording() const; + virtual bool HasChangeRecordProtection() const; + virtual void SetChangeRecording( bool bActivate ); + virtual bool SetProtectionPassword( const String &rPassword ); + virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); + // ================================= //#if 0 // _SOLAR__PRIVATE diff --git a/sfx2/inc/sfx2/securitypage.hxx b/sfx2/inc/sfx2/securitypage.hxx new file mode 100755 index 000000000000..d25f0ee0b967 --- /dev/null +++ b/sfx2/inc/sfx2/securitypage.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SECURITYPAGE_HXX_ +#define _SECURITYPAGE_HXX_ + +#include "sfx2/tabdlg.hxx" +#include "sfx2/htmlmode.hxx" + +#include <memory> + + +////////////////////////////////////////////////////////////////////// + +struct SfxSecurityPage_Impl; + +class SfxSecurityPage : public SfxTabPage +{ + std::auto_ptr< SfxSecurityPage_Impl > m_pImpl; + +protected: + SfxSecurityPage( Window* pParent, const SfxItemSet& ); + virtual ~SfxSecurityPage(); + + virtual BOOL FillItemSet( SfxItemSet& ); + virtual void Reset( const SfxItemSet& ); + +public: + static SfxTabPage* Create( Window* pParent, const SfxItemSet& ); +}; + +////////////////////////////////////////////////////////////////////// + +#endif // #ifndef _SECURITYPAGE_HXX_ + diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc index 917bd75e4138..a49b003b5b49 100644..100755 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -229,10 +229,15 @@ #define TP_DOCINFOUSER (RID_SFX_START+5) #define TP_DOCINFORELOAD (RID_SFX_START+13) #define TP_CUSTOMPROPERTIES (RID_SFX_START+14) +#define TP_DOCINFOSECURITY (RID_SFX_START+215) #define DLG_DOCINFO_EDT (RID_SFX_START+6) #define TP_MANAGE_STYLES (RID_SFX_START+7) #define DLG_STYLE_DESIGNER (RID_SFX_START+8) +#define RID_SFX_PROTECT_RECORDS (RID_SFX_START+216) +#define RID_SFX_UNPROTECT_RECORDS (RID_SFX_START+217) +#define RID_SFX_INCORRECT_PASSWORD (RID_SFX_START+218) + #define STR_STYLE_FILTER_AUTO (RID_SFX_START+9) #define STR_STYLE_FILTER_USED (RID_SFX_START+10) #define STR_STYLE_FILTER_USERDEF (RID_SFX_START+11) diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index b5782b5d4f19..26e1991c24b8 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -155,6 +155,7 @@ #define SID_RELOAD (SID_SFX_START + 508) #define SID_PRINTDOCDIRECT (SID_SFX_START + 509) #define SID_PICKLIST (SID_SFX_START + 510) +#define SID_ATTR_XWINDOW (SID_SFX_START + 777) #define SID_PLUGIN_MODE (SID_SFX_START + 827) #define SID_EXPORTDOC (SID_SFX_START + 829) #define SID_EXPORTDOCASPDF (SID_SFX_START + 1673) @@ -1004,5 +1005,30 @@ #endif // #ifndef _SFXSIDS_HRC +//----------------------------------------------------------------------- +// SfxSecurityPage related stuff + +#define FN_EDIT2 (SID_SW_START + 1800) +#define FN_REDLINE_PROTECT (FN_EDIT2 + 23) +#define FN_REDLINE_ON (FN_EDIT2 + 25) + +#define SID_HTML_MODE (SID_SVX_START + 414) + +// Calc-Id's used for SfxSecurityPage +#ifndef SC_FUNCTION_START +#define SC_FUNCTION_START (SID_SC_START + 200) +#endif +#ifndef FILE_MENU_END +#define FILE_MENU_END (SC_FUNCTION_START + 20) +#endif +#ifndef EDIT_MENU_START +#define EDIT_MENU_START (FILE_MENU_END) +#endif +#ifndef SC_VIEW_START +#define SC_VIEW_START (SID_SC_START) +#endif +#define FID_CHG_RECORD (EDIT_MENU_START + 18) +#define SID_CHG_PROTECT (SC_VIEW_START + 84) + // eof ------------------------------------------------------------------------ diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 8ca8645a05ff..8ca8645a05ff 100644..100755 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 45ebfeac69f9..0ad62ae1eec1 100644..100755 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sfx2.hxx" + #include <tools/urlobj.hxx> #include <vcl/msgbox.hxx> #include <svl/eitem.hxx> @@ -59,7 +60,8 @@ #include <com/sun/star/document/XDocumentProperties.hpp> #include <vcl/timer.hxx> -#include <sfx2/dinfdlg.hxx> +#include "sfx2/dinfdlg.hxx" +#include "sfx2/securitypage.hxx" #include "sfxresid.hxx" #include "dinfedt.hxx" #include <sfx2/frame.hxx> @@ -1564,6 +1566,7 @@ SfxDocumentInfoDialog::SfxDocumentInfoDialog( Window* pParent, AddTabPage(TP_DOCINFODOC, SfxDocumentPage::Create, 0); AddTabPage(TP_CUSTOMPROPERTIES, SfxCustomPropertiesPage::Create, 0); AddTabPage(TP_DOCINFORELOAD, SfxInternetPage::Create, 0); + AddTabPage(TP_DOCINFOSECURITY, SfxSecurityPage::Create, 0); } // ----------------------------------------------------------------------- diff --git a/sfx2/source/dialog/dinfdlg.src b/sfx2/source/dialog/dinfdlg.src index 99a062c4aecf..53b0f35685cb 100644..100755 --- a/sfx2/source/dialog/dinfdlg.src +++ b/sfx2/source/dialog/dinfdlg.src @@ -27,11 +27,11 @@ // include --------------------------------------------------------------- -#include <sfx2/sfx.hrc> +#include "sfx2/sfx.hrc" #include "helpid.hrc" #include "sfxlocal.hrc" #include "dinfdlg.hrc" -#include <dialog.hrc> +#include "dialog.hrc" // TP_DOCINFODESC -------------------------------------------------------- String STR_SFX_NEWOFFICEDOC @@ -685,8 +685,6 @@ QueryBox SFX_QB_WRONG_TYPE Message [ en-US ] = "The value entered does not match the specified type.\nThe value will be stored as text." ; }; - // SID_DOCINFO ----------------------------------------------------------- - TabDialog SID_DOCINFO { OutputSize = TRUE ; @@ -718,6 +716,11 @@ TabDialog SID_DOCINFO Identifier = TP_DOCINFORELOAD ; Text [ en-US ] = "Internet" ; }; + PageItem + { + Identifier = TP_DOCINFOSECURITY ; + Text [ en-US ] = "Security" ; + }; }; }; }; diff --git a/sfx2/source/dialog/makefile.mk b/sfx2/source/dialog/makefile.mk index 3d0c53cdb932..4c56cd683e34 100644..100755 --- a/sfx2/source/dialog/makefile.mk +++ b/sfx2/source/dialog/makefile.mk @@ -69,6 +69,7 @@ SLOFILES =\ $(SLO)$/tplcitem.obj \ $(SLO)$/tplpitem.obj \ $(SLO)$/versdlg.obj \ + $(SLO)$/securitypage.obj \ $(SLO)$/titledockwin.obj SRS1NAME=$(TARGET) @@ -87,6 +88,7 @@ SRC1FILES =\ versdlg.src \ printopt.src \ srchdlg.src \ + securitypage.src \ titledockwin.src \ taskpane.src diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx new file mode 100755 index 000000000000..d32ee843cbf2 --- /dev/null +++ b/sfx2/source/dialog/securitypage.cxx @@ -0,0 +1,523 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sfx2.hxx" + +#include "sfx2/securitypage.hxx" + +#include "securitypage.hrc" +#include "sfxresid.hxx" + +#include <sfx2/sfx.hrc> +#include <sfx2/sfxsids.hrc> +#include <sfx2/objsh.hxx> +#include <sfx2/viewsh.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/passwd.hxx> + +#include <vcl/button.hxx> +#include <vcl/edit.hxx> +#include <vcl/fixed.hxx> +#include <vcl/msgbox.hxx> +#include <svl/eitem.hxx> +#include <svl/poolitem.hxx> +#include <svl/intitem.hxx> +#include <svl/PasswordHelper.hxx> +#include <svtools/xwindowitem.hxx> + + +using namespace ::com::sun::star; + +////////////////////////////////////////////////////////////////////// + + +namespace +{ + enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; + enum RedlineFunc { RF_ON, RF_PROTECT }; + +/* + bool QueryIsEnabled( USHORT _nSlot ) + { + bool bRes = false; + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + const SfxPoolItem* pItem; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + SfxItemState eState = pDisp->QueryState( _nSlot, pItem ); + bRes = (eState & SFX_ITEM_DISABLED) == 0; + } + return bRes; + } +*/ + + bool QueryState( USHORT _nSlot, bool& _rValue ) + { + bool bRet = false; + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + const SfxPoolItem* pItem; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + SfxItemState nState = pDisp->QueryState( _nSlot, pItem ); + bRet = SFX_ITEM_AVAILABLE <= nState; + if (bRet) + _rValue = ( static_cast< const SfxBoolItem* >( pItem ) )->GetValue(); + } + return bRet; + } + + + bool QueryRecordChangesProtectionState( RedliningMode _eMode, bool& _rValue ) + { + bool bRet = false; + if (_eMode != RL_NONE) + { + USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_PROTECT : SID_CHG_PROTECT; + bRet = QueryState( nSlot, _rValue ); + } + return bRet; + } + + + bool QueryRecordChangesState( RedliningMode _eMode, bool& _rValue ) + { + bool bRet = false; + if (_eMode != RL_NONE) + { + USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_ON : FID_CHG_RECORD; + bRet = QueryState( nSlot, _rValue ); + } + return bRet; + } +} + + +////////////////////////////////////////////////////////////////////// + + +static short lcl_GetPassword( + Window *pParent, + bool bProtect, + /*out*/String &rPassword ) +{ + bool bRes = false; + SfxPasswordDialog aPasswdDlg( pParent ); + const String aTitle( SfxResId( bProtect ? RID_SFX_PROTECT_RECORDS : RID_SFX_UNPROTECT_RECORDS ) ); + aPasswdDlg.SetText( aTitle ); + aPasswdDlg.SetMinLen( 1 ); + if (bProtect) + aPasswdDlg.ShowExtras( SHOWEXTRAS_CONFIRM ); + if (RET_OK == aPasswdDlg.Execute() && aPasswdDlg.GetPassword().Len() > 0) + { + rPassword = aPasswdDlg.GetPassword(); + bRes = true; + } + return bRes; +} + + +static bool lcl_IsPasswordCorrect( const String &rPassword ) +{ + bool bRes = false; + + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + uno::Sequence< sal_Int8 > aPasswordHash; + pCurDocShell->GetProtectionHash( aPasswordHash ); + + // check if supplied password was correct + uno::Sequence< sal_Int8 > aNewPasswd( aPasswordHash ); + SvPasswordHelper::GetHashPassword( aNewPasswd, rPassword ); + if (SvPasswordHelper::CompareHashPassword( aPasswordHash, rPassword )) + bRes = true; // password was correct + else + InfoBox( NULL, String( SfxResId( RID_SFX_INCORRECT_PASSWORD ) ) ).Execute(); + + return bRes; +} + + +////////////////////////////////////////////////////////////////////// + + +struct SfxSecurityPage_Impl +{ + SfxSecurityPage & m_rMyTabPage; + + FixedLine m_aNewPasswordToOpenFL; + FixedText m_aNewPasswordToOpenFT; + Edit m_aNewPasswordToOpenED; + FixedText m_aConfirmPasswordToOpenFT; + Edit m_aConfirmPasswordToOpenED; + FixedText m_aNewPasswordInfoFT; + + FixedLine m_aNewPasswordToModifyFL; + FixedText m_aNewPasswordToModifyFT; + Edit m_aNewPasswordToModifyED; + FixedText m_aConfirmPasswordToModifyFT; + Edit m_aConfirmPasswordToModifyED; + + FixedLine m_aOptionsFL; + CheckBox m_aOpenReadonlyCB; + CheckBox m_aRecordChangesCB; // for record changes + PushButton m_aChangeProtectionPB; // for record changes + String m_aProtectSTR; // for record changes + String m_aUnProtectSTR; // for record changes + RedliningMode m_eRedlingMode; // for record changes + + bool m_bOrigPasswordIsConfirmed; + bool m_bNewPasswordIsValid; + String m_aNewPassword; + + String m_aEndRedliningWarning; + bool m_bEndRedliningWarningDone; + + DECL_LINK( RecordChangesCBToggleHdl, void* ); + DECL_LINK( ChangeProtectionPBHdl, void* ); + + SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet &rItemSet ); + ~SfxSecurityPage_Impl(); + + BOOL FillItemSet_Impl( SfxItemSet & ); + void Reset_Impl( const SfxItemSet & ); +}; + + +SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rTabPage, const SfxItemSet & ) : + m_rMyTabPage (rTabPage), + m_aNewPasswordToOpenFL (&rTabPage, SfxResId( PASSWORD_TO_OPEN_FL ) ), + m_aNewPasswordToOpenFT (&rTabPage, SfxResId( PASSWORD_TO_OPEN_FT ) ), + m_aNewPasswordToOpenED (&rTabPage, SfxResId( PASSWORD_TO_OPEN_ED ) ), + m_aConfirmPasswordToOpenFT (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_OPEN_FT ) ), + m_aConfirmPasswordToOpenED (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_OPEN_ED ) ), + m_aNewPasswordInfoFT (&rTabPage, SfxResId( PASSWORD_INFO_FT ) ), + m_aNewPasswordToModifyFL (&rTabPage, SfxResId( PASSWORD_TO_MODIFY_FL ) ), + m_aNewPasswordToModifyFT (&rTabPage, SfxResId( PASSWORD_TO_MODIFY_FT ) ), + m_aNewPasswordToModifyED (&rTabPage, SfxResId( PASSWORD_TO_MODIFY_ED ) ), + m_aConfirmPasswordToModifyFT (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_FT ) ), + m_aConfirmPasswordToModifyED (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_ED ) ), + m_aOptionsFL (&rTabPage, SfxResId( OPTIONS_FL ) ), + m_aOpenReadonlyCB (&rTabPage, SfxResId( OPEN_READONLY_CB ) ), + m_aRecordChangesCB (&rTabPage, SfxResId( RECORD_CHANGES_CB ) ), + m_aChangeProtectionPB (&rTabPage, SfxResId( CHANGE_PROTECTION_PB ) ), + m_aProtectSTR ( SfxResId( STR_PROTECT ) ), + m_aUnProtectSTR ( SfxResId( STR_UNPROTECT ) ), + m_eRedlingMode ( RL_NONE ), + m_bOrigPasswordIsConfirmed ( false ), + m_bNewPasswordIsValid ( false ), + m_aEndRedliningWarning ( SfxResId( STR_END_REDLINING_WARNING ) ), + m_bEndRedliningWarningDone ( false ) +{ + m_aChangeProtectionPB.SetText( m_aProtectSTR ); + // adjust button width if necessary + long nBtnTextWidth = 0; + long nTemp = m_aChangeProtectionPB.GetCtrlTextWidth( m_aChangeProtectionPB.GetText() ); + if (nTemp > nBtnTextWidth) + nBtnTextWidth = nTemp; + + // force toggle hdl called before visual change of checkbox + m_aRecordChangesCB.SetStyle( m_aRecordChangesCB.GetStyle() | WB_EARLYTOGGLE ); + m_aRecordChangesCB.SetToggleHdl( LINK( this, SfxSecurityPage_Impl, RecordChangesCBToggleHdl ) ); + m_aChangeProtectionPB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, ChangeProtectionPBHdl ) ); +} + + +SfxSecurityPage_Impl::~SfxSecurityPage_Impl() +{ +} + + +BOOL SfxSecurityPage_Impl::FillItemSet_Impl( SfxItemSet & ) +{ + bool bModified = false; + + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + if (pCurDocShell&& !pCurDocShell->IsReadOnly()) + { + if (m_eRedlingMode != RL_NONE ) + { + const bool bDoRecordChanges = m_aRecordChangesCB.IsChecked(); + const bool bDoChangeProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; + + // sanity checks + DBG_ASSERT( bDoRecordChanges || !bDoChangeProtection, "no change recording should imply no change protection" ); + DBG_ASSERT( bDoChangeProtection || !bDoRecordChanges, "no change protection should imply no change recording" ); + DBG_ASSERT( !bDoChangeProtection || m_aNewPassword.Len() > 0, "change protection should imply password length is > 0" ); + DBG_ASSERT( bDoChangeProtection || m_aNewPassword.Len() == 0, "no change protection should imply password length is 0" ); + + // change recording + if (bDoRecordChanges != pCurDocShell->IsChangeRecording()) + { + pCurDocShell->SetChangeRecording( bDoRecordChanges ); + bModified = true; + } + + // change record protection + if (m_bNewPasswordIsValid && + bDoChangeProtection != pCurDocShell->HasChangeRecordProtection()) + { + DBG_ASSERT( !bDoChangeProtection || bDoRecordChanges, + "change protection requires record changes to be active!" ); + pCurDocShell->SetProtectionPassword( m_aNewPassword ); + bModified = true; + } + } + + // open read-only? + const sal_Bool bDoOpenReadonly = m_aOpenReadonlyCB.IsChecked(); + if (pCurDocShell->HasSecurityOptOpenReadOnly() && + bDoOpenReadonly != pCurDocShell->IsSecurityOptOpenReadOnly()) + { + pCurDocShell->SetSecurityOptOpenReadOnly( bDoOpenReadonly ); + bModified = true; + } + } + + return bModified; +} + + +void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) +{ + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + + String sNewText = m_aProtectSTR; + if (!pCurDocShell) + { + // no doc -> hide document settings + m_aOpenReadonlyCB.Disable(); + m_aRecordChangesCB.Disable(); + m_aChangeProtectionPB.Disable(); + } + else + { + bool bIsHTMLDoc = false; + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + const SfxPoolItem* pItem; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + if (SFX_ITEM_AVAILABLE <= pDisp->QueryState( SID_HTML_MODE, pItem )) + { + USHORT nMode = static_cast< const SfxUInt16Item* >( pItem )->GetValue(); + bIsHTMLDoc = ( ( nMode & HTMLMODE_ON ) != 0 ); + } + } + + sal_Bool bIsReadonly = pCurDocShell->IsReadOnly(); + if (pCurDocShell->HasSecurityOptOpenReadOnly() && !bIsHTMLDoc) + { + m_aOpenReadonlyCB.Check( pCurDocShell->IsSecurityOptOpenReadOnly() ); + m_aOpenReadonlyCB.Enable( !bIsReadonly ); + } + else + m_aOpenReadonlyCB.Disable(); + + bool bRecordChanges; + if (QueryRecordChangesState( RL_WRITER, bRecordChanges ) && !bIsHTMLDoc) + m_eRedlingMode = RL_WRITER; + else if (QueryRecordChangesState( RL_CALC, bRecordChanges )) + m_eRedlingMode = RL_CALC; + else + m_eRedlingMode = RL_NONE; + + if (m_eRedlingMode != RL_NONE) + { + bool bProtection; + QueryRecordChangesProtectionState( m_eRedlingMode, bProtection ); + + m_aChangeProtectionPB.Enable( !bIsReadonly ); + // set the right text + if (bProtection) + sNewText = m_aUnProtectSTR; + + m_aRecordChangesCB.Check( bRecordChanges ); + m_aRecordChangesCB.Enable( /*!bProtection && */!bIsReadonly ); + + m_bOrigPasswordIsConfirmed = true; // default case if no password is set + uno::Sequence< sal_Int8 > aPasswordHash; + // check if password is available + if (pCurDocShell->GetProtectionHash( aPasswordHash ) && + aPasswordHash.getLength() > 0) + m_bOrigPasswordIsConfirmed = false; // password found, needs to be confirmed later on + } + else + { + // A Calc document that is shared will have 'm_eRedlingMode == RL_NONE' + // In shared documents change recording and protection must be disabled, + // similar to documents that do not support change recording at all. + m_aRecordChangesCB.Check( FALSE ); + m_aRecordChangesCB.Disable(); + m_aChangeProtectionPB.Check( FALSE ); + m_aChangeProtectionPB.Disable(); + } + } + + m_aChangeProtectionPB.SetText( sNewText ); +} + + +IMPL_LINK( SfxSecurityPage_Impl, RecordChangesCBToggleHdl, void*, EMPTYARG ) +{ + // when change recording gets disabled protection must be disabled as well + if (!m_aRecordChangesCB.IsChecked()) // the new check state is already present, thus the '!' + { + bool bAlreadyDone = false; + if (!m_bEndRedliningWarningDone) + { + WarningBox aBox( m_rMyTabPage.GetParent(), WinBits(WB_YES_NO | WB_DEF_NO), + m_aEndRedliningWarning ); + if (aBox.Execute() != RET_YES) + bAlreadyDone = true; + else + m_bEndRedliningWarningDone = true; + } + + const bool bNeedPasssword = !m_bOrigPasswordIsConfirmed + && m_aChangeProtectionPB.GetText() != m_aProtectSTR; + if (!bAlreadyDone && bNeedPasssword) + { + String aPasswordText; + + // dialog canceled or no password provided + if (!lcl_GetPassword( m_rMyTabPage.GetParent(), false, aPasswordText )) + bAlreadyDone = true; + + // ask for password and if dialog is canceled or no password provided return + if (lcl_IsPasswordCorrect( aPasswordText )) + m_bOrigPasswordIsConfirmed = true; + else + bAlreadyDone = true; + } + + if (bAlreadyDone) + m_aRecordChangesCB.Check( true ); // restore original state + else + { + // remember required values to change protection and change recording in + // FillItemSet_Impl later on if password was correct. + m_bNewPasswordIsValid = true; + m_aNewPassword = String(); + + m_aChangeProtectionPB.SetText( m_aProtectSTR ); + } + } + + return 0; +} + + +IMPL_LINK( SfxSecurityPage_Impl, ChangeProtectionPBHdl, void*, EMPTYARG ) +{ + if (m_eRedlingMode == RL_NONE) + return 0; + + // the push button text is always the opposite of the current state. Thus: + const bool bCurrentProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; + + // ask user for password (if still necessary) + String aPasswordText; + bool bNewProtection = !bCurrentProtection; + const bool bNeedPassword = bNewProtection || !m_bOrigPasswordIsConfirmed; + if (bNeedPassword) + { + // ask for password and if dialog is canceled or no password provided return + if (!lcl_GetPassword( m_rMyTabPage.GetParent(), bNewProtection, aPasswordText )) + return 0; + + // provided password still needs to be checked? + if (!bNewProtection && !m_bOrigPasswordIsConfirmed) + { + if (lcl_IsPasswordCorrect( aPasswordText )) + m_bOrigPasswordIsConfirmed = true; + else + return 0; + } + } + DBG_ASSERT( m_bOrigPasswordIsConfirmed, "ooops... this should not have happened!" ); + + // remember required values to change protection and change recording in + // FillItemSet_Impl later on if password was correct. + m_bNewPasswordIsValid = true; + m_aNewPassword = bNewProtection? aPasswordText : String(); + +// // RecordChangesCB is enabled if protection is off +// m_aRecordChangesCB.Enable( !bNewProtection ); + m_aRecordChangesCB.Check( bNewProtection ); + // toggle text of button "Protect" <-> "Unprotect" + m_aChangeProtectionPB.SetText( bNewProtection ? m_aUnProtectSTR : m_aProtectSTR ); + + return 0; +} + + +////////////////////////////////////////////////////////////////////// + + +SfxTabPage* SfxSecurityPage::Create( Window * pParent, const SfxItemSet & rItemSet ) +{ + return new SfxSecurityPage( pParent, rItemSet ); +} + + +SfxSecurityPage::SfxSecurityPage( Window* pParent, const SfxItemSet& rItemSet ) : + SfxTabPage( pParent, SfxResId( TP_DOCINFOSECURITY ), rItemSet ) +{ + m_pImpl = std::auto_ptr< SfxSecurityPage_Impl >(new SfxSecurityPage_Impl( *this, rItemSet )); + + FreeResource(); +} + + +SfxSecurityPage::~SfxSecurityPage() +{ +} + + +BOOL SfxSecurityPage::FillItemSet( SfxItemSet & rItemSet ) +{ + bool bModified = false; + DBG_ASSERT( m_pImpl.get(), "implementation pointer is 0. Still in c-tor?" ); + if (m_pImpl.get() != 0) + bModified = m_pImpl->FillItemSet_Impl( rItemSet ); + return bModified; +} + + +void SfxSecurityPage::Reset( const SfxItemSet & rItemSet ) +{ + DBG_ASSERT( m_pImpl.get(), "implementation pointer is 0. Still in c-tor?" ); + if (m_pImpl.get() != 0) + m_pImpl->Reset_Impl( rItemSet ); +} + + +////////////////////////////////////////////////////////////////////// + + diff --git a/sfx2/source/dialog/securitypage.hrc b/sfx2/source/dialog/securitypage.hrc new file mode 100755 index 000000000000..d425131b4772 --- /dev/null +++ b/sfx2/source/dialog/securitypage.hrc @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SECURITYPAGE_HRC_ +#define _SECURITYPAGE_HRC_ + + +#define PASSWORD_TO_OPEN_FL 1 +#define PASSWORD_TO_OPEN_FT 2 +#define PASSWORD_TO_OPEN_ED 3 +#define CONFIRM_PASSWORD_TO_OPEN_FT 4 +#define CONFIRM_PASSWORD_TO_OPEN_ED 5 +#define PASSWORD_INFO_FT 6 +#define PASSWORD_TO_MODIFY_FL 7 +#define PASSWORD_TO_MODIFY_FT 8 +#define PASSWORD_TO_MODIFY_ED 9 +#define CONFIRM_PASSWORD_TO_MODIFY_FT 10 +#define CONFIRM_PASSWORD_TO_MODIFY_ED 11 +#define OPTIONS_FL 12 +#define OPEN_READONLY_CB 13 +#define RECORD_CHANGES_CB 14 +#define CHANGE_PROTECTION_PB 15 + +#define STR_PROTECT 101 +#define STR_UNPROTECT 102 +#define STR_END_REDLINING_WARNING 103 + +#endif + diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src new file mode 100755 index 000000000000..fee60404d01c --- /dev/null +++ b/sfx2/source/dialog/securitypage.src @@ -0,0 +1,174 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "sfx2/sfx.hrc" +#include "securitypage.hrc" +#include "helpid.hrc" +#include "dialog.hrc" +#include "sfxlocal.hrc" + +#include <svtools/controldims.hrc> + + +TabPage TP_DOCINFOSECURITY +{ + HelpId = HID_DOCINFOSECURITY ; + Hide = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + + FixedLine PASSWORD_TO_OPEN_FL + { + Pos = MAP_APPFONT( 6, 6 ); + Size = MAP_APPFONT( 248, RSC_CD_FIXEDLINE_HEIGHT ); + Text [ en-US ] = "File encryption password"; + }; + FixedText PASSWORD_TO_OPEN_FT + { + Pos = MAP_APPFONT( 12, 20 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "~Enter password to open"; + }; + Edit PASSWORD_TO_OPEN_ED + { + HelpId = HID_SECURITYTAB_PASSWORD_TO_OPEN; + Pos = MAP_APPFONT( 100, 18 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedText CONFIRM_PASSWORD_TO_OPEN_FT + { + Pos = MAP_APPFONT( 12, 34 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "~Reenter password to open"; + }; + Edit CONFIRM_PASSWORD_TO_OPEN_ED + { + HelpId = HID_SECURITYTAB_CONFIRM_PASSWORD_TO_OPEN; + Pos = MAP_APPFONT( 100, 32 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedText PASSWORD_INFO_FT + { + 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 "\ + "is case-sensitive."; + WordBreak = TRUE; + }; + FixedLine PASSWORD_TO_MODIFY_FL + { + Pos = MAP_APPFONT( 6, 78 ); + Size = MAP_APPFONT( 248, RSC_CD_FIXEDLINE_HEIGHT ); + Text [ en-US ] = "File sharing password"; + }; + FixedText PASSWORD_TO_MODIFY_FT + { + Pos = MAP_APPFONT( 12, 92 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "Enter password to modify"; + }; + Edit PASSWORD_TO_MODIFY_ED + { + HelpId = HID_SECURITYTAB_PASSWORD_TO_MODIFY; + Pos = MAP_APPFONT( 100, 90 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedText CONFIRM_PASSWORD_TO_MODIFY_FT + { + Pos = MAP_APPFONT( 12, 106 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "Reenter password to modify"; + }; + Edit CONFIRM_PASSWORD_TO_MODIFY_ED + { + HelpId = HID_SECURITYTAB_CONFIRM_PASSWORD_TO_MODIFY; + Pos = MAP_APPFONT( 100, 104 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedLine OPTIONS_FL + { + Pos = MAP_APPFONT( 6, 120 ); + Size = MAP_APPFONT( 248, RSC_CD_FIXEDLINE_HEIGHT ); + Text [ en-US ] = "File sharing options"; + }; + CheckBox OPEN_READONLY_CB + { + HelpId = HID_SECURITYTAB_OPEN_FILE_READONLY; + Pos = MAP_APPFONT( 12, 133 ); + Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); + Text [ en-US ] = "~Open file read-only"; + }; + CheckBox RECORD_CHANGES_CB + { + HelpId = HID_SECURITYTAB_RECORD_CHANGES; + Pos = MAP_APPFONT( 12, 147 ); + Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); + Text [ en-US ] = "Record ~changes"; + }; + PushButton CHANGE_PROTECTION_PB + { + HelpId = HID_SECURITYTAB_PROTECTION; + Pos = MAP_APPFONT( 194, 145 ); + Size = MAP_APPFONT( 60, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + String STR_PROTECT + { + Text [ en-US ] = "~Protect..."; + }; + String STR_UNPROTECT + { + Text [ en-US ] = "~Unprotect..."; + }; + String STR_END_REDLINING_WARNING + { + Text [ en-US ] = "This action will exit the change recording mode.\nAny information about changes will be lost.\n\nExit change recording mode?\n\n" ; + }; +}; + +String RID_SFX_PROTECT_RECORDS +{ + Text [ en-US ] = "Protect Records" ; +}; +String RID_SFX_UNPROTECT_RECORDS +{ + Text [ en-US ] = "Unprotect Records" ; +}; +String RID_SFX_INCORRECT_PASSWORD +{ + Text [ en-US ] = "Incorrect password" ; +}; + diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 45fc31774f5f..f202266dd74e 100644..100755 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -1076,3 +1076,43 @@ void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew ) SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) ); } } + + +bool SfxObjectShell::IsChangeRecording() const +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + + +bool SfxObjectShell::HasChangeRecordProtection() const +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + + +void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ ) +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); +} + + +bool SfxObjectShell::SetProtectionPassword( const String & /*rPassword*/ ) +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + + +bool SfxObjectShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > & /*rPasswordHash*/ ) +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc index 848446a774e9..79dba3208729 100644..100755 --- a/sfx2/source/inc/helpid.hrc +++ b/sfx2/source/inc/helpid.hrc @@ -46,6 +46,7 @@ #define HID_DOCINFODESC (HID_SFX_START + 8) #define HID_DOCINFODOC (HID_SFX_START + 9) #define HID_DOCINFOUSER (HID_SFX_START + 10) +#define HID_DOCINFOSECURITY (HID_SFX_START + 11) #define HID_BOOKMARKPROPS (HID_SFX_START + 14) #define HID_BOOKGROUPPROPS (HID_SFX_START + 15) #define HID_BOOKFILEPROPS (HID_SFX_START + 16) @@ -346,7 +347,15 @@ #define HID_CTRL_CUSTOMPROPS_YES_NO (HID_SFX_START + 326) #define HID_DLG_CUSTOMPROPS_DURATION (HID_SFX_START + 327) -#define ACT_SFX_HID_END HID_DLG_CUSTOMPROPS_DURATION +#define HID_SECURITYTAB_PASSWORD_TO_OPEN (HID_SFX_START + 328) +#define HID_SECURITYTAB_CONFIRM_PASSWORD_TO_OPEN (HID_SFX_START + 329) +#define HID_SECURITYTAB_PASSWORD_TO_MODIFY (HID_SFX_START + 330) +#define HID_SECURITYTAB_CONFIRM_PASSWORD_TO_MODIFY (HID_SFX_START + 331) +#define HID_SECURITYTAB_OPEN_FILE_READONLY (HID_SFX_START + 332) +#define HID_SECURITYTAB_RECORD_CHANGES (HID_SFX_START + 333) +#define HID_SECURITYTAB_PROTECTION (HID_SFX_START + 334) + +#define ACT_SFX_HID_END HID_SECURITYTAB_PROTECTION // "Uberlaufpr"ufung -------------------------------------------------------- diff --git a/sfx2/util/hidother.src b/sfx2/util/hidother.src index bbea19100df9..38e5577a72be 100644 --- a/sfx2/util/hidother.src +++ b/sfx2/util/hidother.src @@ -165,4 +165,6 @@ hidspecial HID_DID_SAVE_PACKED_XML { HelpID = HID_DID_SAVE_PACKED_X hidspecial HID_HELP_ONHELP { HelpID = HID_HELP_ONHELP; }; hidspecial HID_HELP_TEXT_SELECTION_MODE { HelpID = HID_HELP_TEXT_SELECTION_MODE; }; hidspecial HID_DLG_CHECKFORONLINEUPDATE { HelpID = HID_DLG_CHECKFORONLINEUPDATE; }; -hidspecial HID_TASKPANE_VIEW_MENU { HelpID = HID_TASKPANE_VIEW_MENU; };
\ No newline at end of file +hidspecial HID_DOCINFOSECURITY { HelpID = HID_DOCINFOSECURITY; }; +hidspecial HID_TASKPANE_VIEW_MENU { HelpID = HID_TASKPANE_VIEW_MENU; }; + diff --git a/svx/inc/htmlmode.hxx b/svx/inc/htmlmode.hxx index a1c5bf0cdf11..dab1b5b1db70 100644 --- a/svx/inc/htmlmode.hxx +++ b/svx/inc/htmlmode.hxx @@ -27,28 +27,7 @@ #ifndef _SVX_HTMLMODE_HXX #define _SVX_HTMLMODE_HXX -// include --------------------------------------------------------------- - -// define ---------------------------------------------------------------- - -#define HTMLMODE_ON 0x0001 -#define HTMLMODE_PARA_BORDER 0x0002 /* Absatzumrandungen */ -#define HTMLMODE_PARA_DISTANCE 0x0004 /* bestimmte Absatzabstaende */ -#define HTMLMODE_SMALL_CAPS 0x0008 /* Kapitaelchen */ -#define HTMLMODE_FRM_COLUMNS 0x0010 /* spaltige Rahmen */ -#define HTMLMODE_SOME_STYLES 0x0020 /* mind. MS IE */ -#define HTMLMODE_FULL_STYLES 0x0040 /* == SW */ -#define HTMLMODE_BLINK 0x0080 /* blinkende Zeichen*/ -#define HTMLMODE_PARA_BLOCK 0x0100 /* Blocksatz */ -#define HTMLMODE_DROPCAPS 0x0200 /* Initialen*/ -#define HTMLMODE_FIRSTLINE 0x0400 /* Erstzeileneinzug mit Spacer == NS 3.0 */ -#define HTMLMODE_GRAPH_POS 0x0800 /* Grafikpositionen Hintergrund */ -#define HTMLMODE_FULL_ABS_POS 0x1000 /* abs. Rahmenpositionierung */ -#define HTMLMODE_SOME_ABS_POS 0x2000 /* abs. Rahmenpositionierung vollst.*/ -#define HTMLMODE_RESERVED1 0x4000 -#define HTMLMODE_RESERVED0 0x8000 - - +#include <sfx2/htmlmode.hxx> #endif diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc index 7a90b5c75526..1cdfc9fb2b9e 100644..100755 --- a/svx/inc/svx/svxids.hrc +++ b/svx/inc/svx/svxids.hrc @@ -342,18 +342,19 @@ // Calc-Id's // -------------------------------------------------------------------------- -#ifndef SC_FUNCTION_START -#define SC_FUNCTION_START (SID_SC_START + 200) -#endif -#ifndef FILE_MENU_END -#define FILE_MENU_END (SC_FUNCTION_START + 20) -#endif -#ifndef EDIT_MENU_START -#define EDIT_MENU_START (FILE_MENU_END) -#endif -#ifndef SC_VIEW_START -#define SC_VIEW_START (SID_SC_START) -#endif +//! moved to sfx2, still in use: +//#ifndef SC_FUNCTION_START +//#define SC_FUNCTION_START (SID_SC_START + 200) +//#endif +//#ifndef FILE_MENU_END +//#define FILE_MENU_END (SC_FUNCTION_START + 20) +//#endif +//#ifndef EDIT_MENU_START +//#define EDIT_MENU_START (FILE_MENU_END) +//#endif +//#ifndef SC_VIEW_START +//#define SC_VIEW_START (SID_SC_START) +//#endif #define SID_OUTLINE_HIDE (SID_SC_START + 329) #define SID_OUTLINE_SHOW (SID_SC_START + 330) @@ -365,8 +366,9 @@ #define SID_ATTR_SECIALCHAR (SID_SC_START + 581) #define SID_ATTR_SPECIALCHAR (SID_SC_START + 581) -#define FID_CHG_RECORD (EDIT_MENU_START + 18) -#define SID_CHG_PROTECT (SC_VIEW_START + 84) +//! moved to sfx2, still in use: +//#define FID_CHG_RECORD (EDIT_MENU_START + 18) +//#define SID_CHG_PROTECT (SC_VIEW_START + 84) // -------------------------------------------------------------------------- // Writer-Id's @@ -402,9 +404,10 @@ #define FN_PGPREVIEW (SID_SW_START + 1250) #define FN_SHOW_MULTIPLE_PAGES (FN_PGPREVIEW + 2) -#define FN_EDIT2 (SID_SW_START + 1800) -#define FN_REDLINE_PROTECT (FN_EDIT2 + 23) -#define FN_REDLINE_ON (FN_EDIT2 + 25) +//! moved to sfx2, still in use: +//#define FN_EDIT2 (SID_SW_START + 1800) +//#define FN_REDLINE_PROTECT (FN_EDIT2 + 23) +//#define FN_REDLINE_ON (FN_EDIT2 + 25) // -------------------------------------------------------------------------- // Svx-Id's @@ -749,7 +752,10 @@ #define SID_ATTR_3D_AMBIENTINTENSITY ( SID_SVX_START + 410 ) /* --> Slots mit --> koennen demnaechst entfallen ( heute 12.03.1998 ) */ #define SID_ATTR_3D_AMBIENTCOLOR ( SID_SVX_START + 411 ) #define SID_IMPORT_GRAPH_LINK ( SID_SVX_START + 412 ) -#define SID_HTML_MODE ( SID_SVX_START + 414 ) + +//! moved to sfx2, still in use: +//#define SID_HTML_MODE ( SID_SVX_START + 414 ) + #define SID_RULER_PROTECT ( SID_SVX_START + 415 ) //#define SID_INET_DLG ( SID_SVX_START + 416 ) -> sfxsids.hrc #define SID_COLOR_CONTROL ( SID_SVX_START + 417 ) diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx index 729d4f748921..551f682abda0 100644 --- a/svx/source/dialog/hdft.cxx +++ b/svx/source/dialog/hdft.cxx @@ -37,6 +37,8 @@ #include <vcl/msgbox.hxx> #include <vcl/graph.hxx> +#include <sfx2/sfxsids.hrc> +#include <svx/svxids.hrc> #include <svx/dialogs.hrc> #include "hdft.hrc" #include <svl/intitem.hxx> diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index deea16ccad98..91aa3fed73a6 100755 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -1,751 +1,751 @@ -/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "com/sun/star/task/DocumentPasswordRequest.hpp"
-#include "com/sun/star/task/DocumentPasswordRequest2.hpp"
-#include "com/sun/star/task/DocumentMSPasswordRequest.hpp"
-#include "com/sun/star/task/DocumentMSPasswordRequest2.hpp"
-#include "com/sun/star/task/MasterPasswordRequest.hpp"
-#include "com/sun/star/task/XInteractionAbort.hpp"
-#include "com/sun/star/task/XInteractionPassword.hpp"
-#include "com/sun/star/task/XInteractionPassword2.hpp"
-#include "com/sun/star/task/XInteractionRetry.hpp"
-#include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp"
-#include "com/sun/star/ucb/URLAuthenticationRequest.hpp"
-
-#include "osl/diagnose.h"
-#include "rtl/digest.h"
-#include "vos/mutex.hxx"
-#include "tools/errcode.hxx"
-#include "vcl/msgbox.hxx"
-#include "vcl/abstdlg.hxx"
-#include "vcl/svapp.hxx"
-
-#include "ids.hrc"
-#include "getcontinuations.hxx"
-#include "passwordcontainer.hxx"
-#include "loginerr.hxx"
-#include "logindlg.hxx"
-#include "masterpasscrtdlg.hxx"
-#include "masterpassworddlg.hxx"
-#include "passcrtdlg.hxx"
-#include "passworddlg.hxx"
-
-#include "iahndl.hxx"
-
-using namespace com::sun::star;
-
-namespace {
-
-void
-executeLoginDialog(
- Window * pParent,
- LoginErrorInfo & rInfo,
- rtl::OUString const & rRealm)
- SAL_THROW((uno::RuntimeException))
-{
- try
- {
- vos::OGuard aGuard(Application::GetSolarMutex());
-
- bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0;
- bool bSavePassword = rInfo.GetCanRememberPassword();
- bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials();
-
- sal_uInt16 nFlags = 0;
- if (rInfo.GetPath().Len() == 0)
- nFlags |= LF_NO_PATH;
- if (rInfo.GetErrorText().Len() == 0)
- nFlags |= LF_NO_ERRORTEXT;
- if (!bAccount)
- nFlags |= LF_NO_ACCOUNT;
- if (!(rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME))
- nFlags |= LF_USERNAME_READONLY;
-
- if (!bSavePassword)
- nFlags |= LF_NO_SAVEPASSWORD;
-
- if (!bCanUseSysCreds)
- nFlags |= LF_NO_USESYSCREDS;
-
- std::auto_ptr< ResMgr > xManager( ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
- UniString aRealm(rRealm);
- std::auto_ptr< LoginDialog > xDialog(
- new LoginDialog( pParent, nFlags, rInfo.GetServer(), &aRealm, xManager.get()));
- if (rInfo.GetErrorText().Len() != 0)
- xDialog->SetErrorText(rInfo.GetErrorText());
- xDialog->SetName(rInfo.GetUserName());
- if (bAccount)
- xDialog->ClearAccount();
- else
- xDialog->ClearPassword();
- xDialog->SetPassword(rInfo.GetPassword());
-
- if (bSavePassword)
- {
- xDialog->SetSavePasswordText(
- ResId(rInfo.GetIsRememberPersistent()
- ? RID_SAVE_PASSWORD
- : RID_KEEP_PASSWORD,
- *xManager.get()));
-
- xDialog->SetSavePassword(rInfo.GetIsRememberPassword());
- }
-
- if ( bCanUseSysCreds )
- xDialog->SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() );
-
- rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK :
- ERRCODE_BUTTON_CANCEL);
- rInfo.SetUserName(xDialog->GetName());
- rInfo.SetPassword(xDialog->GetPassword());
- rInfo.SetAccount(xDialog->GetAccount());
- rInfo.SetIsRememberPassword(xDialog->IsSavePassword());
-
- if ( bCanUseSysCreds )
- rInfo.SetIsUseSystemCredentials( xDialog->IsUseSystemCredentials() );
- }
- catch (std::bad_alloc const &)
- {
- throw uno::RuntimeException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
- uno::Reference< uno::XInterface >());
- }
-}
-
-void getRememberModes(
- uno::Sequence< ucb::RememberAuthentication > const & rRememberModes,
- ucb::RememberAuthentication & rPreferredMode,
- ucb::RememberAuthentication & rAlternateMode )
-{
- sal_Int32 nCount = rRememberModes.getLength();
- OSL_ENSURE( (nCount > 0) && (nCount < 4),
- "ucb::RememberAuthentication sequence size mismatch!" );
- if ( nCount == 1 )
- {
- rPreferredMode = rAlternateMode = rRememberModes[ 0 ];
- return;
- }
- else
- {
- //bool bHasRememberModeNo = false;
- bool bHasRememberModeSession = false;
- bool bHasRememberModePersistent = false;
-
- for (sal_Int32 i = 0; i < nCount; ++i)
- {
- switch ( rRememberModes[i] )
- {
- case ucb::RememberAuthentication_NO:
- //bHasRememberModeNo = true;
- break;
- case ucb::RememberAuthentication_SESSION:
- bHasRememberModeSession = true;
- break;
- case ucb::RememberAuthentication_PERSISTENT:
- bHasRememberModePersistent = true;
- break;
- default:
- OSL_TRACE( "Unsupported RememberAuthentication value" );
- break;
- }
- }
-
- if (bHasRememberModePersistent)
- {
- rPreferredMode = ucb::RememberAuthentication_PERSISTENT;
- if (bHasRememberModeSession)
- rAlternateMode = ucb::RememberAuthentication_SESSION;
- else
- rAlternateMode = ucb::RememberAuthentication_NO;
- }
- else
- {
- rPreferredMode = ucb::RememberAuthentication_SESSION;
- rAlternateMode = ucb::RememberAuthentication_NO;
- }
- }
-}
-
-void
-handleAuthenticationRequest_(
- Window * pParent,
- uno::Reference< task::XInteractionHandler > const & xIH,
- uno::Reference< lang::XMultiServiceFactory > const & xServiceFactory,
- ucb::AuthenticationRequest const & rRequest,
- uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
- rContinuations,
- const rtl::OUString & rURL)
- SAL_THROW((uno::RuntimeException))
-{
- uno::Reference< task::XInteractionRetry > xRetry;
- uno::Reference< task::XInteractionAbort > xAbort;
- uno::Reference< ucb::XInteractionSupplyAuthentication >
- xSupplyAuthentication;
- uno::Reference< ucb::XInteractionSupplyAuthentication2 >
- xSupplyAuthentication2;
- getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
- if (xSupplyAuthentication.is())
- xSupplyAuthentication2.set(xSupplyAuthentication, uno::UNO_QUERY);
-
- //////////////////////////
- // First, try to obtain credentials from password container service.
- uui::PasswordContainerHelper aPwContainerHelper(xServiceFactory);
- if (aPwContainerHelper.handleAuthenticationRequest(rRequest,
- xSupplyAuthentication,
- rURL,
- xIH))
- {
- xSupplyAuthentication->select();
- return;
- }
-
- //////////////////////////
- // Second, try to obtain credentials from user via password dialog.
- ucb::RememberAuthentication eDefaultRememberMode
- = ucb::RememberAuthentication_SESSION;
- ucb::RememberAuthentication ePreferredRememberMode
- = eDefaultRememberMode;
- ucb::RememberAuthentication eAlternateRememberMode
- = ucb::RememberAuthentication_NO;
-
- if (xSupplyAuthentication.is())
- {
- getRememberModes(
- xSupplyAuthentication->getRememberPasswordModes(
- eDefaultRememberMode),
- ePreferredRememberMode,
- eAlternateRememberMode);
- }
-
- sal_Bool bCanUseSystemCredentials;
- sal_Bool bDefaultUseSystemCredentials;
- if (xSupplyAuthentication2.is())
- {
- bCanUseSystemCredentials
- = xSupplyAuthentication2->canUseSystemCredentials(
- bDefaultUseSystemCredentials);
- }
- else
- {
- bCanUseSystemCredentials = sal_False;
- bDefaultUseSystemCredentials = sal_False;
- }
-
- LoginErrorInfo aInfo;
- aInfo.SetTitle(rRequest.ServerName);
- aInfo.SetServer(rRequest.ServerName);
- if (rRequest.HasAccount)
- aInfo.SetAccount(rRequest.Account);
- if (rRequest.HasUserName)
- aInfo.SetUserName(rRequest.UserName);
- if (rRequest.HasPassword)
- aInfo.SetPassword(rRequest.Password);
- aInfo.SetErrorText(rRequest.Diagnostic);
-
- aInfo.SetCanRememberPassword(
- ePreferredRememberMode != eAlternateRememberMode);
- aInfo.SetIsRememberPassword(
- eDefaultRememberMode != ucb::RememberAuthentication_NO);
- aInfo.SetIsRememberPersistent(
- ePreferredRememberMode == ucb::RememberAuthentication_PERSISTENT);
-
- aInfo.SetCanUseSystemCredentials(bCanUseSystemCredentials);
- aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials );
- aInfo.SetModifyAccount(rRequest.HasAccount
- && xSupplyAuthentication.is()
- && xSupplyAuthentication->canSetAccount());
- aInfo.SetModifyUserName(rRequest.HasUserName
- && xSupplyAuthentication.is()
- && xSupplyAuthentication->canSetUserName());
- executeLoginDialog(pParent,
- aInfo,
- rRequest.HasRealm ? rRequest.Realm : rtl::OUString());
- switch (aInfo.GetResult())
- {
- case ERRCODE_BUTTON_OK:
- if (xSupplyAuthentication.is())
- {
- if (xSupplyAuthentication->canSetUserName())
- xSupplyAuthentication->setUserName(aInfo.GetUserName());
- if (xSupplyAuthentication->canSetPassword())
- xSupplyAuthentication->setPassword(aInfo.GetPassword());
-
- if (ePreferredRememberMode != eAlternateRememberMode)
- {
- // user had te choice.
- if (aInfo.GetIsRememberPassword())
- xSupplyAuthentication->setRememberPassword(
- ePreferredRememberMode);
- else
- xSupplyAuthentication->setRememberPassword(
- eAlternateRememberMode);
- }
- else
- {
- // user had no choice.
- xSupplyAuthentication->setRememberPassword(
- ePreferredRememberMode);
- }
-
- if (rRequest.HasRealm)
- {
- if (xSupplyAuthentication->canSetRealm())
- xSupplyAuthentication->setRealm(aInfo.GetAccount());
- }
- else if (xSupplyAuthentication->canSetAccount())
- xSupplyAuthentication->setAccount(aInfo.GetAccount());
-
- if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials )
- xSupplyAuthentication2->setUseSystemCredentials(
- aInfo.GetIsUseSystemCredentials() );
-
- xSupplyAuthentication->select();
- }
-
- //////////////////////////
- // Third, store credentials in password container.
-
- if ( aInfo.GetIsUseSystemCredentials() )
- {
- if (aInfo.GetIsRememberPassword())
- {
- if (!aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- rtl::OUString(), // empty u/p -> sys creds
- uno::Sequence< rtl::OUString >(),
- xIH,
- ePreferredRememberMode
- == ucb::RememberAuthentication_PERSISTENT))
- {
- xSupplyAuthentication->setRememberPassword(
- ucb::RememberAuthentication_NO);
- }
- }
- else if (eAlternateRememberMode
- == ucb::RememberAuthentication_SESSION)
- {
- if (!aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- rtl::OUString(), // empty u/p -> sys creds
- uno::Sequence< rtl::OUString >(),
- xIH,
- false /* SESSION */))
- {
- xSupplyAuthentication->setRememberPassword(
- ucb::RememberAuthentication_NO);
- }
- }
- }
- // Empty user name can not be valid:
- else if (aInfo.GetUserName().Len() != 0)
- {
- uno::Sequence< rtl::OUString >
- aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2);
- aPassList[0] = aInfo.GetPassword();
- if (aInfo.GetAccount().Len() != 0)
- aPassList[1] = aInfo.GetAccount();
-
- if (aInfo.GetIsRememberPassword())
- {
- if (!aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- aInfo.GetUserName(),
- aPassList,
- xIH,
- ePreferredRememberMode
- == ucb::RememberAuthentication_PERSISTENT))
- {
- xSupplyAuthentication->setRememberPassword(
- ucb::RememberAuthentication_NO);
- }
- }
- else if (eAlternateRememberMode
- == ucb::RememberAuthentication_SESSION)
- {
- if (!aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- aInfo.GetUserName(),
- aPassList,
- xIH,
- false /* SESSION */))
- {
- xSupplyAuthentication->setRememberPassword(
- ucb::RememberAuthentication_NO);
- }
- }
- }
- break;
-
- case ERRCODE_BUTTON_RETRY:
- if (xRetry.is())
- xRetry->select();
- break;
-
- default:
- if (xAbort.is())
- xAbort->select();
- break;
- }
-}
-
-void
-executeMasterPasswordDialog(
- Window * pParent,
- LoginErrorInfo & rInfo,
- task::PasswordRequestMode nMode)
- SAL_THROW((uno::RuntimeException))
-{
- rtl::OString aMaster;
- try
- {
- vos::OGuard aGuard(Application::GetSolarMutex());
-
- std::auto_ptr< ResMgr > xManager(
- ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
- if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
- {
- std::auto_ptr< MasterPasswordCreateDialog > xDialog(
- new MasterPasswordCreateDialog(pParent, xManager.get()));
- rInfo.SetResult(xDialog->Execute()
- == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
- aMaster = rtl::OUStringToOString(
- xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
- }
- else
- {
- std::auto_ptr< MasterPasswordDialog > xDialog(
- new MasterPasswordDialog(pParent, nMode, xManager.get()));
- rInfo.SetResult(xDialog->Execute()
- == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
- aMaster = rtl::OUStringToOString(
- xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
- }
- }
- catch (std::bad_alloc const &)
- {
- throw uno::RuntimeException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
- uno::Reference< uno::XInterface >());
- }
-
- sal_uInt8 aKey[RTL_DIGEST_LENGTH_MD5];
- rtl_digest_PBKDF2(aKey,
- RTL_DIGEST_LENGTH_MD5,
- reinterpret_cast< sal_uInt8 const * >(aMaster.getStr()),
- aMaster.getLength(),
- reinterpret_cast< sal_uInt8 const * >(
- "3B5509ABA6BC42D9A3A1F3DAD49E56A51"),
- 32,
- 1000);
-
- rtl::OUStringBuffer aBuffer;
- for (int i = 0; i < RTL_DIGEST_LENGTH_MD5; ++i)
- {
- aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] >> 4)));
- aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] & 15)));
- }
- rInfo.SetPassword(aBuffer.makeStringAndClear());
-}
-
-void
-handleMasterPasswordRequest_(
- Window * pParent,
- task::PasswordRequestMode nMode,
- uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
- rContinuations)
- SAL_THROW((uno::RuntimeException))
-{
- uno::Reference< task::XInteractionRetry > xRetry;
- uno::Reference< task::XInteractionAbort > xAbort;
- uno::Reference< ucb::XInteractionSupplyAuthentication >
- xSupplyAuthentication;
- getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
- LoginErrorInfo aInfo;
-
- // in case of master password a hash code is returned
- executeMasterPasswordDialog(pParent, aInfo, nMode);
-
- switch (aInfo.GetResult())
- {
- case ERRCODE_BUTTON_OK:
- if (xSupplyAuthentication.is())
- {
- if (xSupplyAuthentication->canSetPassword())
- xSupplyAuthentication->setPassword(aInfo.GetPassword());
- xSupplyAuthentication->select();
- }
- break;
-
- case ERRCODE_BUTTON_RETRY:
- if (xRetry.is())
- xRetry->select();
- break;
-
- default:
- if (xAbort.is())
- xAbort->select();
- break;
- }
-}
-
-void
-executePasswordDialog(
- Window * pParent,
- LoginErrorInfo & rInfo,
- task::PasswordRequestMode nMode,
- ::rtl::OUString aDocName,
- bool bMSCryptoMode,
- bool bIsPasswordToModify )
- SAL_THROW((uno::RuntimeException))
-{
- try
- {
- vos::OGuard aGuard(Application::GetSolarMutex());
-
- std::auto_ptr< ResMgr > xManager(
- ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
- if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
- {
- 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 );
-
- 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
- {
- std::auto_ptr< PasswordDialog > pDialog(
- new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) );
-
- rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
- rInfo.SetPassword( bIsPasswordToModify ? String() : pDialog->GetPassword() );
- rInfo.SetPasswordToModify( bIsPasswordToModify ? pDialog->GetPassword() : String() );
- }
- }
- catch (std::bad_alloc const &)
- {
- throw uno::RuntimeException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
- uno::Reference< uno::XInterface>());
- }
-}
-
-void
-handlePasswordRequest_(
- Window * pParent,
- task::PasswordRequestMode nMode,
- uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
- rContinuations,
- ::rtl::OUString aDocumentName,
- bool bMSCryptoMode,
- bool bIsPasswordToModify )
- SAL_THROW((uno::RuntimeException))
-{
- uno::Reference< task::XInteractionRetry > xRetry;
- uno::Reference< task::XInteractionAbort > xAbort;
- uno::Reference< task::XInteractionPassword > xPassword;
- uno::Reference< task::XInteractionPassword2 > xPassword2;
- getContinuations(rContinuations, &xRetry, &xAbort, &xPassword2, &xPassword);
-
- if ( xPassword2.is() && !xPassword.is() )
- xPassword.set( xPassword2, uno::UNO_QUERY_THROW );
-
- LoginErrorInfo aInfo;
-
- executePasswordDialog( pParent, aInfo, nMode,
- aDocumentName, bMSCryptoMode, bIsPasswordToModify );
-
- switch (aInfo.GetResult())
- {
- case ERRCODE_BUTTON_OK:
- OSL_ENSURE( !bIsPasswordToModify || xPassword2.is(), "PasswordToModify is requested, but there is no Interaction!" );
- if (xPassword.is())
- {
- if (xPassword2.is())
- {
- xPassword2->setPasswordToModify( aInfo.GetPasswordToModify() );
- xPassword2->setRecommendReadOnly( aInfo.IsRecommendToOpenReadonly() );
- }
-
- xPassword->setPassword(aInfo.GetPassword());
- xPassword->select();
- }
- break;
-
- case ERRCODE_BUTTON_RETRY:
- if (xRetry.is())
- xRetry->select();
- break;
-
- default:
- if (xAbort.is())
- xAbort->select();
- break;
- }
-}
-
-} // namespace
-
-bool
-UUIInteractionHelper::handleAuthenticationRequest(
- uno::Reference< task::XInteractionRequest > const & rRequest)
- SAL_THROW((uno::RuntimeException))
-{
- uno::Any aAnyRequest(rRequest->getRequest());
-
- ucb::URLAuthenticationRequest aURLAuthenticationRequest;
- if (aAnyRequest >>= aURLAuthenticationRequest)
- {
- handleAuthenticationRequest_(getParentProperty(),
- getInteractionHandler(),
- m_xServiceFactory,
- aURLAuthenticationRequest,
- rRequest->getContinuations(),
- aURLAuthenticationRequest.URL);
- return true;
- }
-
- ucb::AuthenticationRequest aAuthenticationRequest;
- if (aAnyRequest >>= aAuthenticationRequest)
- {
- handleAuthenticationRequest_(getParentProperty(),
- getInteractionHandler(),
- m_xServiceFactory,
- aAuthenticationRequest,
- rRequest->getContinuations(),
- rtl::OUString());
- return true;
- }
- return false;
-}
-
-bool
-UUIInteractionHelper::handleMasterPasswordRequest(
- uno::Reference< task::XInteractionRequest > const & rRequest)
- SAL_THROW((uno::RuntimeException))
-{
- uno::Any aAnyRequest(rRequest->getRequest());
-
- task::MasterPasswordRequest aMasterPasswordRequest;
- if (aAnyRequest >>= aMasterPasswordRequest)
- {
- handleMasterPasswordRequest_(getParentProperty(),
- aMasterPasswordRequest.Mode,
- rRequest->getContinuations());
- return true;
- }
- return false;
-}
-
-bool
-UUIInteractionHelper::handlePasswordRequest(
- uno::Reference< task::XInteractionRequest > const & rRequest)
- SAL_THROW((uno::RuntimeException))
-{
- // parameters to be filled for the call to handlePasswordRequest_
- Window * pParent = getParentProperty();
- task::PasswordRequestMode nMode = task::PasswordRequestMode_PASSWORD_ENTER;
- uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations = rRequest->getContinuations();
- ::rtl::OUString aDocumentName;
- bool bMSCryptoMode = false;
- bool bIsPasswordToModify = false;
-
- bool bDoHandleRequest = false;
-
- uno::Any aAnyRequest(rRequest->getRequest());
-
- task::DocumentPasswordRequest2 aDocumentPasswordRequest2;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest2))
- {
- nMode = aDocumentPasswordRequest2.Mode;
- aDocumentName = aDocumentPasswordRequest2.Name;
- OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" );
- bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify;
-
- bDoHandleRequest = true;
- }
-
- task::DocumentPasswordRequest aDocumentPasswordRequest;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest))
- {
- nMode = aDocumentPasswordRequest.Mode;
- aDocumentName = aDocumentPasswordRequest.Name;
- OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" );
- OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" );
-
- bDoHandleRequest = true;
- }
-
- task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest2))
- {
- nMode = aDocumentMSPasswordRequest2.Mode;
- aDocumentName = aDocumentMSPasswordRequest2.Name;
- bMSCryptoMode = true;
- bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify;
-
- bDoHandleRequest = true;
- }
-
- task::DocumentMSPasswordRequest aDocumentMSPasswordRequest;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest))
- {
- nMode = aDocumentMSPasswordRequest.Mode;
- aDocumentName = aDocumentMSPasswordRequest.Name;
- bMSCryptoMode = true;
- OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" );
-
- bDoHandleRequest = true;
- }
-
- if (bDoHandleRequest)
- {
- handlePasswordRequest_( pParent, nMode, rContinuations,
- aDocumentName, bMSCryptoMode, bIsPasswordToModify );
- return true;
- }
-
- task::PasswordRequest aPasswordRequest;
- if( aAnyRequest >>= aPasswordRequest )
- {
- handlePasswordRequest_(getParentProperty(),
- aPasswordRequest.Mode,
- rRequest->getContinuations(),
- rtl::OUString(),
- false /* bool bMSCryptoMode */);
- return true;
- }
-
- return false;
-}
-
+/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "com/sun/star/task/DocumentPasswordRequest.hpp" +#include "com/sun/star/task/DocumentPasswordRequest2.hpp" +#include "com/sun/star/task/DocumentMSPasswordRequest.hpp" +#include "com/sun/star/task/DocumentMSPasswordRequest2.hpp" +#include "com/sun/star/task/MasterPasswordRequest.hpp" +#include "com/sun/star/task/XInteractionAbort.hpp" +#include "com/sun/star/task/XInteractionPassword.hpp" +#include "com/sun/star/task/XInteractionPassword2.hpp" +#include "com/sun/star/task/XInteractionRetry.hpp" +#include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp" +#include "com/sun/star/ucb/URLAuthenticationRequest.hpp" + +#include "osl/diagnose.h" +#include "rtl/digest.h" +#include "vos/mutex.hxx" +#include "tools/errcode.hxx" +#include "vcl/msgbox.hxx" +#include "vcl/abstdlg.hxx" +#include "vcl/svapp.hxx" + +#include "ids.hrc" +#include "getcontinuations.hxx" +#include "passwordcontainer.hxx" +#include "loginerr.hxx" +#include "logindlg.hxx" +#include "masterpasscrtdlg.hxx" +#include "masterpassworddlg.hxx" +#include "passcrtdlg.hxx" +#include "passworddlg.hxx" + +#include "iahndl.hxx" + +using namespace com::sun::star; + +namespace { + +void +executeLoginDialog( + Window * pParent, + LoginErrorInfo & rInfo, + rtl::OUString const & rRealm) + SAL_THROW((uno::RuntimeException)) +{ + try + { + vos::OGuard aGuard(Application::GetSolarMutex()); + + bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0; + bool bSavePassword = rInfo.GetCanRememberPassword(); + bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials(); + + sal_uInt16 nFlags = 0; + if (rInfo.GetPath().Len() == 0) + nFlags |= LF_NO_PATH; + if (rInfo.GetErrorText().Len() == 0) + nFlags |= LF_NO_ERRORTEXT; + if (!bAccount) + nFlags |= LF_NO_ACCOUNT; + if (!(rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME)) + nFlags |= LF_USERNAME_READONLY; + + if (!bSavePassword) + nFlags |= LF_NO_SAVEPASSWORD; + + if (!bCanUseSysCreds) + nFlags |= LF_NO_USESYSCREDS; + + std::auto_ptr< ResMgr > xManager( ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); + UniString aRealm(rRealm); + std::auto_ptr< LoginDialog > xDialog( + new LoginDialog( pParent, nFlags, rInfo.GetServer(), &aRealm, xManager.get())); + if (rInfo.GetErrorText().Len() != 0) + xDialog->SetErrorText(rInfo.GetErrorText()); + xDialog->SetName(rInfo.GetUserName()); + if (bAccount) + xDialog->ClearAccount(); + else + xDialog->ClearPassword(); + xDialog->SetPassword(rInfo.GetPassword()); + + if (bSavePassword) + { + xDialog->SetSavePasswordText( + ResId(rInfo.GetIsRememberPersistent() + ? RID_SAVE_PASSWORD + : RID_KEEP_PASSWORD, + *xManager.get())); + + xDialog->SetSavePassword(rInfo.GetIsRememberPassword()); + } + + if ( bCanUseSysCreds ) + xDialog->SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() ); + + rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : + ERRCODE_BUTTON_CANCEL); + rInfo.SetUserName(xDialog->GetName()); + rInfo.SetPassword(xDialog->GetPassword()); + rInfo.SetAccount(xDialog->GetAccount()); + rInfo.SetIsRememberPassword(xDialog->IsSavePassword()); + + if ( bCanUseSysCreds ) + rInfo.SetIsUseSystemCredentials( xDialog->IsUseSystemCredentials() ); + } + catch (std::bad_alloc const &) + { + throw uno::RuntimeException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")), + uno::Reference< uno::XInterface >()); + } +} + +void getRememberModes( + uno::Sequence< ucb::RememberAuthentication > const & rRememberModes, + ucb::RememberAuthentication & rPreferredMode, + ucb::RememberAuthentication & rAlternateMode ) +{ + sal_Int32 nCount = rRememberModes.getLength(); + OSL_ENSURE( (nCount > 0) && (nCount < 4), + "ucb::RememberAuthentication sequence size mismatch!" ); + if ( nCount == 1 ) + { + rPreferredMode = rAlternateMode = rRememberModes[ 0 ]; + return; + } + else + { + //bool bHasRememberModeNo = false; + bool bHasRememberModeSession = false; + bool bHasRememberModePersistent = false; + + for (sal_Int32 i = 0; i < nCount; ++i) + { + switch ( rRememberModes[i] ) + { + case ucb::RememberAuthentication_NO: + //bHasRememberModeNo = true; + break; + case ucb::RememberAuthentication_SESSION: + bHasRememberModeSession = true; + break; + case ucb::RememberAuthentication_PERSISTENT: + bHasRememberModePersistent = true; + break; + default: + OSL_TRACE( "Unsupported RememberAuthentication value" ); + break; + } + } + + if (bHasRememberModePersistent) + { + rPreferredMode = ucb::RememberAuthentication_PERSISTENT; + if (bHasRememberModeSession) + rAlternateMode = ucb::RememberAuthentication_SESSION; + else + rAlternateMode = ucb::RememberAuthentication_NO; + } + else + { + rPreferredMode = ucb::RememberAuthentication_SESSION; + rAlternateMode = ucb::RememberAuthentication_NO; + } + } +} + +void +handleAuthenticationRequest_( + Window * pParent, + uno::Reference< task::XInteractionHandler > const & xIH, + uno::Reference< lang::XMultiServiceFactory > const & xServiceFactory, + ucb::AuthenticationRequest const & rRequest, + uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & + rContinuations, + const rtl::OUString & rURL) + SAL_THROW((uno::RuntimeException)) +{ + uno::Reference< task::XInteractionRetry > xRetry; + uno::Reference< task::XInteractionAbort > xAbort; + uno::Reference< ucb::XInteractionSupplyAuthentication > + xSupplyAuthentication; + uno::Reference< ucb::XInteractionSupplyAuthentication2 > + xSupplyAuthentication2; + getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication); + if (xSupplyAuthentication.is()) + xSupplyAuthentication2.set(xSupplyAuthentication, uno::UNO_QUERY); + + ////////////////////////// + // First, try to obtain credentials from password container service. + uui::PasswordContainerHelper aPwContainerHelper(xServiceFactory); + if (aPwContainerHelper.handleAuthenticationRequest(rRequest, + xSupplyAuthentication, + rURL, + xIH)) + { + xSupplyAuthentication->select(); + return; + } + + ////////////////////////// + // Second, try to obtain credentials from user via password dialog. + ucb::RememberAuthentication eDefaultRememberMode + = ucb::RememberAuthentication_SESSION; + ucb::RememberAuthentication ePreferredRememberMode + = eDefaultRememberMode; + ucb::RememberAuthentication eAlternateRememberMode + = ucb::RememberAuthentication_NO; + + if (xSupplyAuthentication.is()) + { + getRememberModes( + xSupplyAuthentication->getRememberPasswordModes( + eDefaultRememberMode), + ePreferredRememberMode, + eAlternateRememberMode); + } + + sal_Bool bCanUseSystemCredentials; + sal_Bool bDefaultUseSystemCredentials; + if (xSupplyAuthentication2.is()) + { + bCanUseSystemCredentials + = xSupplyAuthentication2->canUseSystemCredentials( + bDefaultUseSystemCredentials); + } + else + { + bCanUseSystemCredentials = sal_False; + bDefaultUseSystemCredentials = sal_False; + } + + LoginErrorInfo aInfo; + aInfo.SetTitle(rRequest.ServerName); + aInfo.SetServer(rRequest.ServerName); + if (rRequest.HasAccount) + aInfo.SetAccount(rRequest.Account); + if (rRequest.HasUserName) + aInfo.SetUserName(rRequest.UserName); + if (rRequest.HasPassword) + aInfo.SetPassword(rRequest.Password); + aInfo.SetErrorText(rRequest.Diagnostic); + + aInfo.SetCanRememberPassword( + ePreferredRememberMode != eAlternateRememberMode); + aInfo.SetIsRememberPassword( + eDefaultRememberMode != ucb::RememberAuthentication_NO); + aInfo.SetIsRememberPersistent( + ePreferredRememberMode == ucb::RememberAuthentication_PERSISTENT); + + aInfo.SetCanUseSystemCredentials(bCanUseSystemCredentials); + aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials ); + aInfo.SetModifyAccount(rRequest.HasAccount + && xSupplyAuthentication.is() + && xSupplyAuthentication->canSetAccount()); + aInfo.SetModifyUserName(rRequest.HasUserName + && xSupplyAuthentication.is() + && xSupplyAuthentication->canSetUserName()); + executeLoginDialog(pParent, + aInfo, + rRequest.HasRealm ? rRequest.Realm : rtl::OUString()); + switch (aInfo.GetResult()) + { + case ERRCODE_BUTTON_OK: + if (xSupplyAuthentication.is()) + { + if (xSupplyAuthentication->canSetUserName()) + xSupplyAuthentication->setUserName(aInfo.GetUserName()); + if (xSupplyAuthentication->canSetPassword()) + xSupplyAuthentication->setPassword(aInfo.GetPassword()); + + if (ePreferredRememberMode != eAlternateRememberMode) + { + // user had te choice. + if (aInfo.GetIsRememberPassword()) + xSupplyAuthentication->setRememberPassword( + ePreferredRememberMode); + else + xSupplyAuthentication->setRememberPassword( + eAlternateRememberMode); + } + else + { + // user had no choice. + xSupplyAuthentication->setRememberPassword( + ePreferredRememberMode); + } + + if (rRequest.HasRealm) + { + if (xSupplyAuthentication->canSetRealm()) + xSupplyAuthentication->setRealm(aInfo.GetAccount()); + } + else if (xSupplyAuthentication->canSetAccount()) + xSupplyAuthentication->setAccount(aInfo.GetAccount()); + + if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials ) + xSupplyAuthentication2->setUseSystemCredentials( + aInfo.GetIsUseSystemCredentials() ); + + xSupplyAuthentication->select(); + } + + ////////////////////////// + // Third, store credentials in password container. + + if ( aInfo.GetIsUseSystemCredentials() ) + { + if (aInfo.GetIsRememberPassword()) + { + if (!aPwContainerHelper.addRecord( + rURL.getLength() ? rURL : rRequest.ServerName, + rtl::OUString(), // empty u/p -> sys creds + uno::Sequence< rtl::OUString >(), + xIH, + ePreferredRememberMode + == ucb::RememberAuthentication_PERSISTENT)) + { + xSupplyAuthentication->setRememberPassword( + ucb::RememberAuthentication_NO); + } + } + else if (eAlternateRememberMode + == ucb::RememberAuthentication_SESSION) + { + if (!aPwContainerHelper.addRecord( + rURL.getLength() ? rURL : rRequest.ServerName, + rtl::OUString(), // empty u/p -> sys creds + uno::Sequence< rtl::OUString >(), + xIH, + false /* SESSION */)) + { + xSupplyAuthentication->setRememberPassword( + ucb::RememberAuthentication_NO); + } + } + } + // Empty user name can not be valid: + else if (aInfo.GetUserName().Len() != 0) + { + uno::Sequence< rtl::OUString > + aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2); + aPassList[0] = aInfo.GetPassword(); + if (aInfo.GetAccount().Len() != 0) + aPassList[1] = aInfo.GetAccount(); + + if (aInfo.GetIsRememberPassword()) + { + if (!aPwContainerHelper.addRecord( + rURL.getLength() ? rURL : rRequest.ServerName, + aInfo.GetUserName(), + aPassList, + xIH, + ePreferredRememberMode + == ucb::RememberAuthentication_PERSISTENT)) + { + xSupplyAuthentication->setRememberPassword( + ucb::RememberAuthentication_NO); + } + } + else if (eAlternateRememberMode + == ucb::RememberAuthentication_SESSION) + { + if (!aPwContainerHelper.addRecord( + rURL.getLength() ? rURL : rRequest.ServerName, + aInfo.GetUserName(), + aPassList, + xIH, + false /* SESSION */)) + { + xSupplyAuthentication->setRememberPassword( + ucb::RememberAuthentication_NO); + } + } + } + break; + + case ERRCODE_BUTTON_RETRY: + if (xRetry.is()) + xRetry->select(); + break; + + default: + if (xAbort.is()) + xAbort->select(); + break; + } +} + +void +executeMasterPasswordDialog( + Window * pParent, + LoginErrorInfo & rInfo, + task::PasswordRequestMode nMode) + SAL_THROW((uno::RuntimeException)) +{ + rtl::OString aMaster; + try + { + vos::OGuard aGuard(Application::GetSolarMutex()); + + std::auto_ptr< ResMgr > xManager( + ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); + if( nMode == task::PasswordRequestMode_PASSWORD_CREATE ) + { + std::auto_ptr< MasterPasswordCreateDialog > xDialog( + new MasterPasswordCreateDialog(pParent, xManager.get())); + rInfo.SetResult(xDialog->Execute() + == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); + aMaster = rtl::OUStringToOString( + xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8); + } + else + { + std::auto_ptr< MasterPasswordDialog > xDialog( + new MasterPasswordDialog(pParent, nMode, xManager.get())); + rInfo.SetResult(xDialog->Execute() + == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); + aMaster = rtl::OUStringToOString( + xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8); + } + } + catch (std::bad_alloc const &) + { + throw uno::RuntimeException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")), + uno::Reference< uno::XInterface >()); + } + + sal_uInt8 aKey[RTL_DIGEST_LENGTH_MD5]; + rtl_digest_PBKDF2(aKey, + RTL_DIGEST_LENGTH_MD5, + reinterpret_cast< sal_uInt8 const * >(aMaster.getStr()), + aMaster.getLength(), + reinterpret_cast< sal_uInt8 const * >( + "3B5509ABA6BC42D9A3A1F3DAD49E56A51"), + 32, + 1000); + + rtl::OUStringBuffer aBuffer; + for (int i = 0; i < RTL_DIGEST_LENGTH_MD5; ++i) + { + aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] >> 4))); + aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] & 15))); + } + rInfo.SetPassword(aBuffer.makeStringAndClear()); +} + +void +handleMasterPasswordRequest_( + Window * pParent, + task::PasswordRequestMode nMode, + uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & + rContinuations) + SAL_THROW((uno::RuntimeException)) +{ + uno::Reference< task::XInteractionRetry > xRetry; + uno::Reference< task::XInteractionAbort > xAbort; + uno::Reference< ucb::XInteractionSupplyAuthentication > + xSupplyAuthentication; + getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication); + LoginErrorInfo aInfo; + + // in case of master password a hash code is returned + executeMasterPasswordDialog(pParent, aInfo, nMode); + + switch (aInfo.GetResult()) + { + case ERRCODE_BUTTON_OK: + if (xSupplyAuthentication.is()) + { + if (xSupplyAuthentication->canSetPassword()) + xSupplyAuthentication->setPassword(aInfo.GetPassword()); + xSupplyAuthentication->select(); + } + break; + + case ERRCODE_BUTTON_RETRY: + if (xRetry.is()) + xRetry->select(); + break; + + default: + if (xAbort.is()) + xAbort->select(); + break; + } +} + +void +executePasswordDialog( + Window * pParent, + LoginErrorInfo & rInfo, + task::PasswordRequestMode nMode, + ::rtl::OUString aDocName, + bool bMSCryptoMode, + bool bIsPasswordToModify ) + SAL_THROW((uno::RuntimeException)) +{ + try + { + vos::OGuard aGuard(Application::GetSolarMutex()); + + std::auto_ptr< ResMgr > xManager( + ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); + if( nMode == task::PasswordRequestMode_PASSWORD_CREATE ) + { + 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 ); + + 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 + { + std::auto_ptr< PasswordDialog > pDialog( + new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) ); + + rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); + rInfo.SetPassword( bIsPasswordToModify ? String() : pDialog->GetPassword() ); + rInfo.SetPasswordToModify( bIsPasswordToModify ? pDialog->GetPassword() : String() ); + } + } + catch (std::bad_alloc const &) + { + throw uno::RuntimeException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")), + uno::Reference< uno::XInterface>()); + } +} + +void +handlePasswordRequest_( + Window * pParent, + task::PasswordRequestMode nMode, + uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & + rContinuations, + ::rtl::OUString aDocumentName, + bool bMSCryptoMode, + bool bIsPasswordToModify ) + SAL_THROW((uno::RuntimeException)) +{ + uno::Reference< task::XInteractionRetry > xRetry; + uno::Reference< task::XInteractionAbort > xAbort; + uno::Reference< task::XInteractionPassword > xPassword; + uno::Reference< task::XInteractionPassword2 > xPassword2; + getContinuations(rContinuations, &xRetry, &xAbort, &xPassword2, &xPassword); + + if ( xPassword2.is() && !xPassword.is() ) + xPassword.set( xPassword2, uno::UNO_QUERY_THROW ); + + LoginErrorInfo aInfo; + + executePasswordDialog( pParent, aInfo, nMode, + aDocumentName, bMSCryptoMode, bIsPasswordToModify ); + + switch (aInfo.GetResult()) + { + case ERRCODE_BUTTON_OK: + OSL_ENSURE( !bIsPasswordToModify || xPassword2.is(), "PasswordToModify is requested, but there is no Interaction!" ); + if (xPassword.is()) + { + if (xPassword2.is()) + { + xPassword2->setPasswordToModify( aInfo.GetPasswordToModify() ); + xPassword2->setRecommendReadOnly( aInfo.IsRecommendToOpenReadonly() ); + } + + xPassword->setPassword(aInfo.GetPassword()); + xPassword->select(); + } + break; + + case ERRCODE_BUTTON_RETRY: + if (xRetry.is()) + xRetry->select(); + break; + + default: + if (xAbort.is()) + xAbort->select(); + break; + } +} + +} // namespace + +bool +UUIInteractionHelper::handleAuthenticationRequest( + uno::Reference< task::XInteractionRequest > const & rRequest) + SAL_THROW((uno::RuntimeException)) +{ + uno::Any aAnyRequest(rRequest->getRequest()); + + ucb::URLAuthenticationRequest aURLAuthenticationRequest; + if (aAnyRequest >>= aURLAuthenticationRequest) + { + handleAuthenticationRequest_(getParentProperty(), + getInteractionHandler(), + m_xServiceFactory, + aURLAuthenticationRequest, + rRequest->getContinuations(), + aURLAuthenticationRequest.URL); + return true; + } + + ucb::AuthenticationRequest aAuthenticationRequest; + if (aAnyRequest >>= aAuthenticationRequest) + { + handleAuthenticationRequest_(getParentProperty(), + getInteractionHandler(), + m_xServiceFactory, + aAuthenticationRequest, + rRequest->getContinuations(), + rtl::OUString()); + return true; + } + return false; +} + +bool +UUIInteractionHelper::handleMasterPasswordRequest( + uno::Reference< task::XInteractionRequest > const & rRequest) + SAL_THROW((uno::RuntimeException)) +{ + uno::Any aAnyRequest(rRequest->getRequest()); + + task::MasterPasswordRequest aMasterPasswordRequest; + if (aAnyRequest >>= aMasterPasswordRequest) + { + handleMasterPasswordRequest_(getParentProperty(), + aMasterPasswordRequest.Mode, + rRequest->getContinuations()); + return true; + } + return false; +} + +bool +UUIInteractionHelper::handlePasswordRequest( + uno::Reference< task::XInteractionRequest > const & rRequest) + SAL_THROW((uno::RuntimeException)) +{ + // parameters to be filled for the call to handlePasswordRequest_ + Window * pParent = getParentProperty(); + task::PasswordRequestMode nMode = task::PasswordRequestMode_PASSWORD_ENTER; + uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations = rRequest->getContinuations(); + ::rtl::OUString aDocumentName; + bool bMSCryptoMode = false; + bool bIsPasswordToModify = false; + + bool bDoHandleRequest = false; + + uno::Any aAnyRequest(rRequest->getRequest()); + + task::DocumentPasswordRequest2 aDocumentPasswordRequest2; + if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest2)) + { + nMode = aDocumentPasswordRequest2.Mode; + aDocumentName = aDocumentPasswordRequest2.Name; + OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" ); + bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify; + + bDoHandleRequest = true; + } + + task::DocumentPasswordRequest aDocumentPasswordRequest; + if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest)) + { + nMode = aDocumentPasswordRequest.Mode; + aDocumentName = aDocumentPasswordRequest.Name; + OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" ); + OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" ); + + bDoHandleRequest = true; + } + + task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2; + if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest2)) + { + nMode = aDocumentMSPasswordRequest2.Mode; + aDocumentName = aDocumentMSPasswordRequest2.Name; + bMSCryptoMode = true; + bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify; + + bDoHandleRequest = true; + } + + task::DocumentMSPasswordRequest aDocumentMSPasswordRequest; + if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest)) + { + nMode = aDocumentMSPasswordRequest.Mode; + aDocumentName = aDocumentMSPasswordRequest.Name; + bMSCryptoMode = true; + OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" ); + + bDoHandleRequest = true; + } + + if (bDoHandleRequest) + { + handlePasswordRequest_( pParent, nMode, rContinuations, + aDocumentName, bMSCryptoMode, bIsPasswordToModify ); + return true; + } + + task::PasswordRequest aPasswordRequest; + if( aAnyRequest >>= aPasswordRequest ) + { + handlePasswordRequest_(getParentProperty(), + aPasswordRequest.Mode, + rRequest->getContinuations(), + rtl::OUString(), + false /* bool bMSCryptoMode */); + return true; + } + + return false; +} + diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc index 6a6f38385013..796186fd5140 100755 --- a/uui/source/ids.hrc +++ b/uui/source/ids.hrc @@ -170,17 +170,25 @@ #define ERRCODE_UUI_SSLWARN_INVALID_1 (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 1) #define TITLE_UUI_SSLWARN_INVALID (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 3) -#define HID_DLG_LOGIN (HID_UUI_START + 0) -#define HID_DLG_COOKIES (HID_UUI_START + 1) -#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START + 2) -#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START + 3) -#define HID_DLG_FILTER_SELECT (HID_UUI_START + 4) -#define HID_DLG_PASSWORD_UUI (HID_UUI_START + 5) -#define HID_DLG_PASSWORD_CRT (HID_UUI_START + 6) -#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START + 7) -#define HID_DLG_SSLWARN_UUI (HID_UUI_START + 8) -#define HID_XMLSECDLG_MACROWARN (HID_UUI_START + 9) -#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START +10) +#define HID_DLG_LOGIN (HID_UUI_START + 0) +#define HID_DLG_COOKIES (HID_UUI_START + 1) +#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START + 2) +#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START + 3) +#define HID_DLG_FILTER_SELECT (HID_UUI_START + 4) +#define HID_DLG_PASSWORD_UUI (HID_UUI_START + 5) +#define HID_DLG_PASSWORD_CRT (HID_UUI_START + 6) +#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START + 7) +#define HID_DLG_SSLWARN_UUI (HID_UUI_START + 8) +#define HID_XMLSECDLG_MACROWARN (HID_UUI_START + 9) +#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START +10) + +#define HID_LOGIN_DLG_PATH (HID_UUI_START +11) +#define HID_LOGIN_DLG_BROWSE (HID_UUI_START +12) +#define HID_LOGIN_DLG_USER_NAME (HID_UUI_START +13) +#define HID_LOGIN_DLG_PASSWORD (HID_UUI_START +14) +#define HID_LOGIN_DLG_ACCOUNT (HID_UUI_START +15) +#define HID_LOGIN_DLG_REMEMBER_PASSWORD (HID_UUI_START +16) +#define HID_LOGIN_DLG_USE_SYSTEM_CREDENTIALS (HID_UUI_START +17) // HID_UUI_END (aka HID_CHAOS_NEW_DATABASE) is reserved in // sfx2/util/hidother.src diff --git a/uui/source/logindlg.cxx b/uui/source/logindlg.cxx index 53ea243c9577..d7ded58b5dde 100644..100755 --- a/uui/source/logindlg.cxx +++ b/uui/source/logindlg.cxx @@ -47,12 +47,20 @@ //............................................................................ //............................................................................ +static void lcl_Move( Window &rWin, long nOffset ) +{ + Point aTmp( rWin.GetPosPixel() ); + aTmp.Y() -= nOffset; + rWin.SetPosPixel( aTmp ); +} + + void LoginDialog::HideControls_Impl( USHORT nFlags ) { - FASTBOOL bPathHide = FALSE; - FASTBOOL bErrorHide = FALSE; - FASTBOOL bAccountHide = FALSE; - FASTBOOL bUseSysCredsHide = FALSE; + bool bPathHide = FALSE; + bool bErrorHide = FALSE; + bool bAccountHide = FALSE; + bool bUseSysCredsHide = FALSE; if ( ( nFlags & LF_NO_PATH ) == LF_NO_PATH ) { @@ -63,9 +71,8 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) } else if ( ( nFlags & LF_PATH_READONLY ) == LF_PATH_READONLY ) { - aPathED.Hide(); - aPathInfo.Show(); - aPathBtn.Hide(); + aPathED.Enable( FALSE ); + aPathBtn.Enable( FALSE ); } if ( ( nFlags & LF_NO_USERNAME ) == LF_NO_USERNAME ) @@ -75,8 +82,7 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) } else if ( ( nFlags & LF_USERNAME_READONLY ) == LF_USERNAME_READONLY ) { - aNameED.Hide(); - aNameInfo.Show(); + aNameED.Enable( FALSE ); } if ( ( nFlags & LF_NO_PASSWORD ) == LF_NO_PASSWORD ) @@ -91,7 +97,8 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) if ( ( nFlags & LF_NO_ERRORTEXT ) == LF_NO_ERRORTEXT ) { aErrorInfo.Hide(); - aErrorGB.Hide(); + aErrorFT.Hide(); + aLogin1FL.Hide(); bErrorHide = TRUE; } @@ -110,53 +117,26 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) if ( bErrorHide ) { - long nOffset = aLoginGB.GetPosPixel().Y() - - aErrorGB.GetPosPixel().Y(); - Point aNewPnt = aRequestInfo.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aRequestInfo.SetPosPixel( aNewPnt ); - aNewPnt = aPathFT.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPathFT.SetPosPixel( aNewPnt ); - aNewPnt = aPathED.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPathED.SetPosPixel( aNewPnt ); - aNewPnt = aPathInfo.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPathInfo.SetPosPixel( aNewPnt ); - aNewPnt = aPathBtn.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPathBtn.SetPosPixel( aNewPnt ); - aNewPnt = aNameFT.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aNameFT.SetPosPixel( aNewPnt ); - aNewPnt = aNameED.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aNameED.SetPosPixel( aNewPnt ); - aNewPnt = aNameInfo.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aNameInfo.SetPosPixel( aNewPnt ); - aNewPnt = aPasswordFT.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPasswordFT.SetPosPixel( aNewPnt ); - aNewPnt = aPasswordED.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPasswordED.SetPosPixel( aNewPnt ); - aNewPnt = aAccountFT.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aAccountFT.SetPosPixel( aNewPnt ); - aNewPnt = aAccountED.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aAccountED.SetPosPixel( aNewPnt ); - aNewPnt = aSavePasswdBtn.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aSavePasswdBtn.SetPosPixel( aNewPnt ); - aNewPnt = aUseSysCredsCB.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aUseSysCredsCB.SetPosPixel( aNewPnt ); - aNewPnt = aLoginGB.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aLoginGB.SetPosPixel( aNewPnt ); + long nOffset = aRequestInfo.GetPosPixel().Y() - + aErrorFT.GetPosPixel().Y(); + lcl_Move( aRequestInfo, nOffset ); + lcl_Move( aLogin2FL, nOffset ); + lcl_Move( aPathFT, nOffset ); + lcl_Move( aPathED, nOffset ); + lcl_Move( aPathBtn, nOffset ); + lcl_Move( aNameFT, nOffset ); + lcl_Move( aNameED, nOffset ); + lcl_Move( aPasswordFT, nOffset ); + lcl_Move( aPasswordED, nOffset ); + lcl_Move( aAccountFT, nOffset ); + lcl_Move( aAccountED, nOffset ); + lcl_Move( aSavePasswdBtn, nOffset ); + lcl_Move( aUseSysCredsCB, nOffset ); + lcl_Move( aButtonsFL, nOffset ); + lcl_Move( aOKBtn, nOffset ); + lcl_Move( aCancelBtn, nOffset ); + lcl_Move( aHelpBtn, nOffset ); + Size aNewSiz = GetSizePixel(); aNewSiz.Height() -= nOffset; SetSizePixel( aNewSiz ); @@ -166,24 +146,19 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) { long nOffset = aNameED.GetPosPixel().Y() - aPathED.GetPosPixel().Y(); + lcl_Move( aNameFT, nOffset ); + lcl_Move( aNameED, nOffset ); + lcl_Move( aPasswordFT, nOffset ); + lcl_Move( aPasswordED, nOffset ); + lcl_Move( aAccountFT, nOffset ); + lcl_Move( aAccountED, nOffset ); + lcl_Move( aSavePasswdBtn, nOffset ); + lcl_Move( aUseSysCredsCB, nOffset ); + lcl_Move( aButtonsFL, nOffset ); + lcl_Move( aOKBtn, nOffset ); + lcl_Move( aCancelBtn, nOffset ); + lcl_Move( aHelpBtn, nOffset ); - Point aTmpPnt1 = aNameFT.GetPosPixel(); - Point aTmpPnt2 = aPasswordFT.GetPosPixel(); - aNameFT.SetPosPixel( aPathFT.GetPosPixel() ); - aPasswordFT.SetPosPixel( aTmpPnt1 ); - aAccountFT.SetPosPixel( aTmpPnt2 ); - aTmpPnt1 = aNameED.GetPosPixel(); - aTmpPnt2 = aPasswordED.GetPosPixel(); - aNameED.SetPosPixel( aPathED.GetPosPixel() ); - aPasswordED.SetPosPixel( aTmpPnt1 ); - aAccountED.SetPosPixel( aTmpPnt2 ); - aNameInfo.SetPosPixel( aPathInfo.GetPosPixel() ); - aTmpPnt1 = aSavePasswdBtn.GetPosPixel(); - aTmpPnt1.Y() -= nOffset; - aSavePasswdBtn.SetPosPixel( aTmpPnt1 ); - aTmpPnt1 = aUseSysCredsCB.GetPosPixel(); - aTmpPnt1.Y() -= nOffset; - aUseSysCredsCB.SetPosPixel( aTmpPnt1 ); Size aNewSz = GetSizePixel(); aNewSz.Height() -= nOffset; SetSizePixel( aNewSz ); @@ -191,14 +166,15 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) if ( bAccountHide ) { - long nOffset = aAccountED.GetPosPixel().Y() - aPasswordED.GetPosPixel().Y(); - - Point aTmpPnt = aSavePasswdBtn.GetPosPixel(); - aTmpPnt.Y() -= nOffset; - aSavePasswdBtn.SetPosPixel( aTmpPnt ); - aTmpPnt = aUseSysCredsCB.GetPosPixel(); - aTmpPnt.Y() -= nOffset; - aUseSysCredsCB.SetPosPixel( aTmpPnt ); + long nOffset = aAccountED.GetPosPixel().Y() - + aPasswordED.GetPosPixel().Y(); + lcl_Move( aSavePasswdBtn, nOffset ); + lcl_Move( aUseSysCredsCB, nOffset ); + lcl_Move( aButtonsFL, nOffset ); + lcl_Move( aOKBtn, nOffset ); + lcl_Move( aCancelBtn, nOffset ); + lcl_Move( aHelpBtn, nOffset ); + Size aNewSz = GetSizePixel(); aNewSz.Height() -= nOffset; SetSizePixel( aNewSz ); @@ -208,6 +184,10 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) { long nOffset = aUseSysCredsCB.GetPosPixel().Y() - aSavePasswdBtn.GetPosPixel().Y(); + lcl_Move( aButtonsFL, nOffset ); + lcl_Move( aOKBtn, nOffset ); + lcl_Move( aCancelBtn, nOffset ); + lcl_Move( aHelpBtn, nOffset ); Size aNewSz = GetSizePixel(); aNewSz.Height() -= nOffset; @@ -219,15 +199,13 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) void LoginDialog::EnableUseSysCredsControls_Impl( BOOL bUseSysCredsEnabled ) { aErrorInfo.Enable( !bUseSysCredsEnabled ); - aErrorGB.Enable( !bUseSysCredsEnabled ); + aErrorFT.Enable( !bUseSysCredsEnabled ); aRequestInfo.Enable( !bUseSysCredsEnabled ); aPathFT.Enable( !bUseSysCredsEnabled ); aPathED.Enable( !bUseSysCredsEnabled ); - aPathInfo.Enable( !bUseSysCredsEnabled ); aPathBtn.Enable( !bUseSysCredsEnabled ); aNameFT.Enable( !bUseSysCredsEnabled ); aNameED.Enable( !bUseSysCredsEnabled ); - aNameInfo.Enable( !bUseSysCredsEnabled ); aPasswordFT.Enable( !bUseSysCredsEnabled ); aPasswordED.Enable( !bUseSysCredsEnabled ); aAccountFT.Enable( !bUseSysCredsEnabled ); @@ -282,23 +260,23 @@ LoginDialog::LoginDialog ModalDialog( pParent, ResId( DLG_UUI_LOGIN, *pResMgr ) ), - aErrorInfo ( this, ResId( INFO_LOGIN_ERROR, *pResMgr ) ), - aErrorGB ( this, ResId( GB_LOGIN_ERROR, *pResMgr ) ), - aRequestInfo ( this, ResId( INFO_LOGIN_REQUEST, *pResMgr ) ), + aErrorFT ( this, ResId( FT_LOGIN_ERROR, *pResMgr ) ), + aErrorInfo ( this, ResId( FT_INFO_LOGIN_ERROR, *pResMgr ) ), + aLogin1FL ( this, ResId( FL_LOGIN_1, *pResMgr ) ), + aRequestInfo ( this, ResId( FT_INFO_LOGIN_REQUEST, *pResMgr ) ), + aLogin2FL ( this, ResId( FL_LOGIN_2, *pResMgr ) ), aPathFT ( this, ResId( FT_LOGIN_PATH, *pResMgr ) ), aPathED ( this, ResId( ED_LOGIN_PATH, *pResMgr ) ), - aPathInfo ( this, ResId( INFO_LOGIN_PATH, *pResMgr ) ), aPathBtn ( this, ResId( BTN_LOGIN_PATH, *pResMgr ) ), aNameFT ( this, ResId( FT_LOGIN_USERNAME, *pResMgr ) ), aNameED ( this, ResId( ED_LOGIN_USERNAME, *pResMgr ) ), - aNameInfo ( this, ResId( INFO_LOGIN_USERNAME, *pResMgr ) ), aPasswordFT ( this, ResId( FT_LOGIN_PASSWORD, *pResMgr ) ), aPasswordED ( this, ResId( ED_LOGIN_PASSWORD, *pResMgr ) ), aAccountFT ( this, ResId( FT_LOGIN_ACCOUNT, *pResMgr ) ), aAccountED ( this, ResId( ED_LOGIN_ACCOUNT, *pResMgr ) ), aSavePasswdBtn ( this, ResId( CB_LOGIN_SAVEPASSWORD, *pResMgr ) ), aUseSysCredsCB ( this, ResId( CB_LOGIN_USESYSCREDS, *pResMgr ) ), - aLoginGB ( this, ResId( GB_LOGIN_LOGIN, *pResMgr ) ), + aButtonsFL ( this, ResId( FL_BUTTONS, *pResMgr ) ), aOKBtn ( this, ResId( BTN_LOGIN_OK, *pResMgr ) ), aCancelBtn ( this, ResId( BTN_LOGIN_CANCEL, *pResMgr ) ), aHelpBtn ( this, ResId( BTN_LOGIN_HELP, *pResMgr ) ) @@ -333,10 +311,8 @@ LoginDialog::LoginDialog // ----------------------------------------------------------------------- -void LoginDialog::SetName( const String& rNewName ) +LoginDialog::~LoginDialog() { - aNameED.SetText( rNewName ); - aNameInfo.SetText( rNewName ); } // ----------------------------------------------------------------------- diff --git a/uui/source/logindlg.hrc b/uui/source/logindlg.hrc index 68162fb620cd..b541740bd768 100644..100755 --- a/uui/source/logindlg.hrc +++ b/uui/source/logindlg.hrc @@ -30,24 +30,24 @@ //============================================================================ -#define INFO_LOGIN_ERROR 10 -#define GB_LOGIN_ERROR 11 +#define FT_INFO_LOGIN_ERROR 10 +#define FT_LOGIN_ERROR 11 -#define INFO_LOGIN_REQUEST 20 +#define FT_INFO_LOGIN_REQUEST 20 #define FT_LOGIN_PATH 21 #define ED_LOGIN_PATH 22 -#define INFO_LOGIN_PATH 23 -#define BTN_LOGIN_PATH 24 -#define FT_LOGIN_USERNAME 25 -#define ED_LOGIN_USERNAME 26 -#define INFO_LOGIN_USERNAME 27 -#define FT_LOGIN_PASSWORD 28 -#define ED_LOGIN_PASSWORD 29 -#define FT_LOGIN_ACCOUNT 30 -#define ED_LOGIN_ACCOUNT 31 -#define CB_LOGIN_SAVEPASSWORD 32 -#define GB_LOGIN_LOGIN 33 -#define CB_LOGIN_USESYSCREDS 34 +#define BTN_LOGIN_PATH 23 +#define FT_LOGIN_USERNAME 24 +#define ED_LOGIN_USERNAME 25 +#define FT_LOGIN_PASSWORD 26 +#define ED_LOGIN_PASSWORD 27 +#define FT_LOGIN_ACCOUNT 28 +#define ED_LOGIN_ACCOUNT 29 +#define CB_LOGIN_SAVEPASSWORD 30 +#define CB_LOGIN_USESYSCREDS 31 +#define FL_LOGIN_1 32 +#define FL_LOGIN_2 33 +#define FL_BUTTONS 34 #define BTN_LOGIN_OK 50 #define BTN_LOGIN_CANCEL 51 diff --git a/uui/source/logindlg.hxx b/uui/source/logindlg.hxx index 0a4637d89251..05ba8e8d55d4 100644..100755 --- a/uui/source/logindlg.hxx +++ b/uui/source/logindlg.hxx @@ -53,23 +53,23 @@ //============================================================================ class LoginDialog : public ModalDialog { + FixedText aErrorFT; FixedInfo aErrorInfo; - FixedLine aErrorGB; + FixedLine aLogin1FL; FixedInfo aRequestInfo; + FixedLine aLogin2FL; FixedText aPathFT; Edit aPathED; - FixedInfo aPathInfo; PushButton aPathBtn; FixedText aNameFT; Edit aNameED; - FixedInfo aNameInfo; FixedText aPasswordFT; Edit aPasswordED; FixedText aAccountFT; Edit aAccountED; CheckBox aSavePasswdBtn; CheckBox aUseSysCredsCB; - FixedLine aLoginGB; + FixedLine aButtonsFL; OKButton aOKBtn; CancelButton aCancelBtn; HelpButton aHelpBtn; @@ -85,36 +85,30 @@ public: LoginDialog( Window* pParent, USHORT nFlags, const String& rServer, const String* pRealm, ResMgr * pResMgr ); + virtual ~LoginDialog(); - String GetPath() const { return aPathED.GetText(); } - void SetPath( const String& rNewPath ) - { aPathED.SetText( rNewPath ); - aPathInfo.SetText( rNewPath );} - String GetName() const { return aNameED.GetText(); } - void SetName( const String& rNewName ); - String GetPassword() const { return aPasswordED.GetText(); } - void SetPassword( const String& rNew ) - { aPasswordED.SetText( rNew ); } - String GetAccount() const { return aAccountED.GetText(); } - void SetAccount( const String& rNew ) - { aAccountED.SetText( rNew ); } - BOOL IsSavePassword() const - { return aSavePasswdBtn.IsChecked(); } - void SetSavePassword( BOOL bSave ) - { aSavePasswdBtn.Check( bSave ); } - void SetSavePasswordText( const String& rTxt ) - { aSavePasswdBtn.SetText( rTxt ); } - BOOL IsUseSystemCredentials() const - { return aUseSysCredsCB.IsChecked(); } + String GetPath() const { return aPathED.GetText(); } + void SetPath( const String& rNewPath ) { aPathED.SetText( rNewPath ); } + String GetName() const { return aNameED.GetText(); } + void SetName( const String& rNewName ) { aNameED.SetText( rNewName ); } + String GetPassword() const { return aPasswordED.GetText(); } + void SetPassword( const String& rNew ) { aPasswordED.SetText( rNew ); } + String GetAccount() const { return aAccountED.GetText(); } + void SetAccount( const String& rNew ) { aAccountED.SetText( rNew ); } + BOOL IsSavePassword() const { return aSavePasswdBtn.IsChecked(); } + void SetSavePassword( BOOL bSave ) { aSavePasswdBtn.Check( bSave ); } + void SetSavePasswordText( const String& rTxt ) { aSavePasswdBtn.SetText( rTxt ); } + BOOL IsUseSystemCredentials() const { return aUseSysCredsCB.IsChecked(); } void SetUseSystemCredentials( BOOL bUse ); - void SetErrorText( const String& rTxt ) - { aErrorInfo.SetText( rTxt ); } - void SetLoginRequestText( const String& rTxt ) - { aRequestInfo.SetText( rTxt ); } + void SetErrorText( const String& rTxt ) { aErrorInfo.SetText( rTxt ); } + void SetLoginRequestText( const String& rTxt ) { aRequestInfo.SetText( rTxt ); } void ClearPassword(); void ClearAccount(); }; +// ----------------------------------------------------------------------- + + //............................................................................ //............................................................................ diff --git a/uui/source/logindlg.src b/uui/source/logindlg.src index ce998f4945be..bf6a97c3b0ff 100644..100755 --- a/uui/source/logindlg.src +++ b/uui/source/logindlg.src @@ -16,7 +16,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). + *(a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see @@ -42,166 +42,156 @@ ModalDialog DLG_UUI_LOGIN Moveable = TRUE ; OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT ( 265 , 170 ) ; - FixedText INFO_LOGIN_ERROR + Size = MAP_APPFONT( 177 , 247 ) ; + Text [ en-US ] = "Authentication Required" ; + + FixedText FT_LOGIN_ERROR { - Pos = MAP_APPFONT ( 12 , 14 ) ; - Size = MAP_APPFONT ( 185 , 18 ) ; + Pos = MAP_APPFONT( 6 , 6 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; + Text [ en-US ] = "Message from server:" ; + }; + + FixedText FT_INFO_LOGIN_ERROR + { + Pos = MAP_APPFONT( 6 , 14 ) ; + Size = MAP_APPFONT( 165 , 3*8 ) ; WordBreak = TRUE ; }; - FixedLine GB_LOGIN_ERROR + + FixedLine FL_LOGIN_1 { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 197 , 8 ) ; - Text [ en-US ] = "Message from server" ; + Pos = MAP_APPFONT( 6 , 41 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; }; - FixedText INFO_LOGIN_REQUEST + + FixedText FT_INFO_LOGIN_REQUEST { - Pos = MAP_APPFONT ( 12 , 55 ) ; - Size = MAP_APPFONT ( 185 , 18 ) ; + Pos = MAP_APPFONT( 6 , 52 ) ; + Size = MAP_APPFONT( 165 , 2*8 ) ; WordBreak = TRUE ; - Text [ en-US ] = "Enter the user name and password for %1 here." ; + Text [ en-US ] = "Enter user name and password for: \n%1" ; }; + + String STR_LOGIN_REALM + { + Text [ en-US ] = "Enter user name and password for: \n\"%2\" on %1" ; + }; + + FixedLine FL_LOGIN_2 + { + Pos = MAP_APPFONT( 6 , 71 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; + }; + FixedText FT_LOGIN_PATH { - Pos = MAP_APPFONT ( 12 , 77 ) ; - Size = MAP_APPFONT ( 57 , 10 ) ; + Pos = MAP_APPFONT( 6 , 84 ) ; + Size = MAP_APPFONT( 112 , 8 ) ; Text [ en-US ] = "~Path" ; }; + Edit ED_LOGIN_PATH { + HelpId = HID_LOGIN_DLG_PATH; Border = TRUE ; - Pos = MAP_APPFONT ( 72 , 76 ) ; - Size = MAP_APPFONT ( 108 , 12 ) ; - }; - FixedText INFO_LOGIN_PATH - { - Hide = TRUE ; - Pos = MAP_APPFONT ( 72 , 77 ) ; - Size = MAP_APPFONT ( 125 , 10 ) ; + Pos = MAP_APPFONT( 6 , 95 ) ; + Size = MAP_APPFONT( 112 , 12 ) ; }; PushButton BTN_LOGIN_PATH { - Pos = MAP_APPFONT ( 183 , 75 ) ; - Size = MAP_APPFONT ( 14 , 14 ) ; - Text = "~..." ; + HelpId = HID_LOGIN_DLG_BROWSE; + Pos = MAP_APPFONT( 121 , 94 ) ; + Size = MAP_APPFONT( 50 , 14 ) ; + Text = "~Browse..." ; }; + FixedText FT_LOGIN_USERNAME { - Pos = MAP_APPFONT ( 12 , 92 ) ; - Size = MAP_APPFONT ( 57 , 10 ) ; + Pos = MAP_APPFONT( 6 , 110 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; Text [ en-US ] = "~User name" ; }; + Edit ED_LOGIN_USERNAME { + HelpId = HID_LOGIN_DLG_USER_NAME; Border = TRUE ; - Pos = MAP_APPFONT ( 72 , 91 ) ; - Size = MAP_APPFONT ( 125 , 12 ) ; - }; - FixedText INFO_LOGIN_USERNAME - { - Hide = TRUE ; - Pos = MAP_APPFONT ( 72 , 92 ) ; - Size = MAP_APPFONT ( 125 , 10 ) ; + Pos = MAP_APPFONT( 6 , 121 ) ; + Size = MAP_APPFONT( 165 , 12 ) ; }; + FixedText FT_LOGIN_PASSWORD { - Pos = MAP_APPFONT ( 12 , 107 ) ; - Size = MAP_APPFONT ( 57 , 10 ) ; + Pos = MAP_APPFONT( 6 , 136 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; Text [ en-US ] = "Pass~word" ; }; + Edit ED_LOGIN_PASSWORD { + HelpId = HID_LOGIN_DLG_PASSWORD; Border = TRUE ; - Pos = MAP_APPFONT ( 72 , 106 ) ; - Size = MAP_APPFONT ( 125 , 12 ) ; + Pos = MAP_APPFONT( 6 , 147 ) ; + Size = MAP_APPFONT( 165 , 12 ) ; PassWord = TRUE ; }; + FixedText FT_LOGIN_ACCOUNT { - Pos = MAP_APPFONT ( 12 , 122 ) ; - Size = MAP_APPFONT ( 57 , 10 ) ; + Pos = MAP_APPFONT( 6 , 162 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; Text [ en-US ] = "A~ccount"; }; + Edit ED_LOGIN_ACCOUNT { + HelpId = HID_LOGIN_DLG_ACCOUNT; Border = TRUE ; - Pos = MAP_APPFONT ( 72 , 121 ) ; - Size = MAP_APPFONT ( 125 , 12 ) ; + Pos = MAP_APPFONT( 6 , 173 ) ; + Size = MAP_APPFONT( 165 , 12 ) ; PassWord = TRUE ; }; + CheckBox CB_LOGIN_SAVEPASSWORD { - Pos = MAP_APPFONT ( 12 , 136 ) ; - Size = MAP_APPFONT ( 185 , 10 ) ; - Text [ en-US ] = "~Save password" ; + HelpId = HID_LOGIN_DLG_REMEMBER_PASSWORD; + Pos = MAP_APPFONT( 6 , 190 ) ; + Size = MAP_APPFONT( 165 , 10 ) ; + Text [ en-US ] = "~Remember password" ; }; + CheckBox CB_LOGIN_USESYSCREDS { - Pos = MAP_APPFONT ( 12 , 148 ) ; - Size = MAP_APPFONT ( 185 , 10 ) ; - Text [ en-US ] = "~Use System Credentials" ; + HelpId = HID_LOGIN_DLG_USE_SYSTEM_CREDENTIALS; + Pos = MAP_APPFONT( 6 , 203 ) ; + Size = MAP_APPFONT( 165 , 10 ) ; + Text [ en-US ] = "~Use system credentials" ; }; - FixedLine GB_LOGIN_LOGIN + + FixedLine FL_BUTTONS { - Pos = MAP_APPFONT ( 7 , 44 ) ; - Size = MAP_APPFONT ( 197 , 8 ) ; - Text [ en-US ] = "Log in" ; + Pos = MAP_APPFONT( 0 , 216 ) ; + Size = MAP_APPFONT( 177 , 8 ) ; }; + OKButton BTN_LOGIN_OK { - Pos = MAP_APPFONT ( 209 , 6 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + Pos = MAP_APPFONT( 6 , 227 ) ; + Size = MAP_APPFONT( 50 , 14 ) ; DefButton = TRUE ; }; + CancelButton BTN_LOGIN_CANCEL { - Pos = MAP_APPFONT ( 209 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + Pos = MAP_APPFONT( 66 , 227 ) ; + Size = MAP_APPFONT( 50 , 14 ) ; }; + HelpButton BTN_LOGIN_HELP { - Pos = MAP_APPFONT ( 209 , 43 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - }; - String STR_LOGIN_REALM - { - Text [ en-US ] = "Please enter user name and password for \"%2\" on %1 here." ; + Pos = MAP_APPFONT( 121 , 227 ) ; + Size = MAP_APPFONT( 50 , 14 ) ; }; - Text [ en-US ] = "User Name and Password Required" ; }; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx index 73d61bea359f..ec1317dbd805 100755 --- a/uui/source/loginerr.hxx +++ b/uui/source/loginerr.hxx @@ -81,7 +81,7 @@ public: { return ( m_nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) == LOGINERROR_FLAG_IS_USE_SYSCREDS; } BYTE GetFlags() const { return m_nFlags; } - USHORT GetResult() const { return m_nRet; } + USHORT GetResult() const { return m_nRet; } void SetTitle( const String& aTitle ) { m_aTitle = aTitle; } |