diff options
-rw-r--r--[-rwxr-xr-x] | sw/inc/docsh.hxx | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/sdi/swriter.sdi | 2 | ||||
-rwxr-xr-x | sw/source/filter/ww8/wrtww8.cxx | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/source/ui/app/docsh.cxx | 77 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/source/ui/uiview/view2.cxx | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/source/ui/uiview/viewstat.cxx | 8 |
6 files changed, 100 insertions, 12 deletions
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 16e6cd047fb6..3dd338a5e129 100755..100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -29,6 +29,7 @@ #include <rtl/ref.hxx> #include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/uno/Sequence.h> #include <vcl/timer.hxx> #include <sfx2/docfac.hxx> #include <sfx2/objsh.hxx> @@ -302,6 +303,14 @@ public: SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef ); virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const; + + // passwword protection for Writer (derived from SfxObjectShell) + // see also: FN_REDLINE_ON, FN_REDLINE_ON + 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 ); }; class Graphic; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index c27ac20b0013..aae7ec7a019c 100644..100755 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -6623,7 +6623,7 @@ SfxBoolItem ProtectTraceChangeMode FN_REDLINE_PROTECT FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, - ReadOnlyDoc = TRUE, + ReadOnlyDoc = FALSE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE, diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 09876173eac4..4e62d37a9692 100755 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2472,7 +2472,7 @@ typedef ::std::deque<SwNode *> SwNodeDeque; void MSWordExportBase::WriteText() { // whoever has need of the missing function should go and implement it! -// This damned piece of code always breaks builds... +// This piece of code always breaks builds... //#ifdef DEBUG // ::std::clog << "<WriteText>" << ::std::endl; // ::std::clog << dbg_out(pCurPam->GetDoc()->GetNodes()) << ::std::endl; @@ -2488,9 +2488,10 @@ void MSWordExportBase::WriteText() SwNode * pNd = pCurPam->GetNode(); // whoever has need of the missing function should go and implement it! -// This damned piece of code always breaks builds... +// This piece of code always breaks builds... #if 0 #ifdef DEBUG +#if 0 if (aNodeSet.find(pNd) == aNodeSet.end()) { aNodeSet.insert(pNd); diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index c3f6585e325e..3c14ed6c46f0 100644..100755 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -39,6 +39,7 @@ #include <svl/zforlist.hxx> #include <svl/eitem.hxx> #include <svl/stritem.hxx> +#include <svl/PasswordHelper.hxx> #include <editeng/adjitem.hxx> #include <basic/sbx.hxx> #include <unotools/moduleoptions.hxx> @@ -1367,3 +1368,79 @@ const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const { return pDoc ? &pDoc->GetXmlIdRegistry() : 0; } + + +bool SwDocShell::IsChangeRecording() const +{ + return (pWrtShell->GetRedlineMode() & nsRedlineMode_t::REDLINE_ON) != 0; +} + + +bool SwDocShell::HasChangeRecordProtection() const +{ + return pWrtShell->getIDocumentRedlineAccess()->GetRedlinePassword().getLength() > 0; +} + + +void SwDocShell::SetChangeRecording( bool bActivate ) +{ + USHORT nOn = bActivate ? nsRedlineMode_t::REDLINE_ON : 0; + USHORT nMode = pWrtShell->GetRedlineMode(); + pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn); +} + + +bool SwDocShell::SetProtectionPassword( const String &rNewPassword ) +{ + const SfxAllItemSet aSet( GetPool() ); + const SfxItemSet* pArgs = &aSet; + const SfxPoolItem* pItem = NULL; + + IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess(); + Sequence< sal_Int8 > aPasswd = pIDRA->GetRedlinePassword(); + if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_REDLINE_PROTECT, FALSE, &pItem ) + && ((SfxBoolItem*)pItem)->GetValue() == aPasswd.getLength() > 0) + return false; + + bool bRes = false; + + if (rNewPassword.Len()) + { + // when password protection is applied change tracking must always be active + SetChangeRecording( true ); + + Sequence< sal_Int8 > aNewPasswd; + SvPasswordHelper::GetHashPassword( aNewPasswd, rNewPassword ); + pIDRA->SetRedlinePassword( aNewPasswd ); + bRes = true; + } + else + { + pIDRA->SetRedlinePassword( Sequence< sal_Int8 >() ); + bRes = true; + } + + return bRes; +} + + +bool SwDocShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ) +{ + bool bRes = false; + + const SfxAllItemSet aSet( GetPool() ); + const SfxItemSet* pArgs = &aSet; + const SfxPoolItem* pItem = NULL; + + IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess(); + Sequence< sal_Int8 > aPasswdHash( pIDRA->GetRedlinePassword() ); + if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_REDLINE_PROTECT, FALSE, &pItem ) + && ((SfxBoolItem*)pItem)->GetValue() == (aPasswdHash.getLength() != 0)) + return false; + rPasswordHash = aPasswdHash; + bRes = true; + + return bRes; +} + + diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index e19e06916145..3a7003ff7bca 100644..100755 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -55,6 +55,7 @@ #include <editeng/langitem.hxx> #include <svx/viewlayoutitem.hxx> #include <svx/zoomslideritem.hxx> +#include <svtools/xwindowitem.hxx> #include <svx/htmlmode.hxx> #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> @@ -538,11 +539,12 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) // xmlsec05: new password dialog Window* pParent; const SfxPoolItem* pParentItem; - if( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_PARENTWINDOW, FALSE, &pParentItem ) ) - pParent = ( Window* ) ( ( const OfaPtrItem* ) pParentItem )->GetValue(); + if( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, FALSE, &pParentItem ) ) + pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr(); else pParent = &GetViewFrame()->GetWindow(); SfxPasswordDialog aPasswdDlg( pParent ); + aPasswdDlg.SetMinLen( 1 ); //#i69751# the result of Execute() can be ignored aPasswdDlg.Execute(); String sNewPasswd( aPasswdDlg.GetPassword() ); @@ -574,11 +576,12 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) // message box for wrong password Window* pParent; const SfxPoolItem* pParentItem; - if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_PARENTWINDOW, FALSE, &pParentItem ) ) - pParent = ( Window* ) ( ( const OfaPtrItem* ) pParentItem )->GetValue(); + if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, FALSE, &pParentItem ) ) + pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr(); else pParent = &GetViewFrame()->GetWindow(); SfxPasswordDialog aPasswdDlg( pParent ); + aPasswdDlg.SetMinLen( 1 ); if(!aPasswd.getLength()) aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM); if (aPasswdDlg.Execute()) diff --git a/sw/source/ui/uiview/viewstat.cxx b/sw/source/ui/uiview/viewstat.cxx index f23b73f5dfad..b0d5f71744c9 100644..100755 --- a/sw/source/ui/uiview/viewstat.cxx +++ b/sw/source/ui/uiview/viewstat.cxx @@ -269,12 +269,10 @@ void SwView::GetState(SfxItemSet &rSet) } break; case FN_REDLINE_ON: - rSet.Put( SfxBoolItem( nWhich, (pWrtShell->GetRedlineMode() & nsRedlineMode_t::REDLINE_ON) != 0 ) ); - break; + rSet.Put( SfxBoolItem( nWhich, GetDocShell()->IsChangeRecording() ) ); + break; case FN_REDLINE_PROTECT : - { - rSet.Put( SfxBoolItem( nWhich, pWrtShell->getIDocumentRedlineAccess()->GetRedlinePassword().getLength() > 0 ) ); - } + rSet.Put( SfxBoolItem( nWhich, GetDocShell()->HasChangeRecordProtection() ) ); break; case FN_REDLINE_SHOW: { |