summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rwxr-xr-xsw/inc/docsh.hxx7
-rwxr-xr-x[-rw-r--r--]sw/sdi/swriter.sdi2
-rwxr-xr-x[-rw-r--r--]sw/source/filter/ww8/wrtww8.cxx6
-rwxr-xr-x[-rw-r--r--]sw/source/ui/app/docsh.cxx66
4 files changed, 79 insertions, 2 deletions
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 0f1a15be56..5ac0a010b4 100755
--- 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,12 @@ 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 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 aede24688e..7d7bb04db3 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 916ad970df..1bfa70b5b3 100644..100755
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -2434,12 +2434,14 @@ typedef ::std::deque<SwNode *> SwNodeDeque;
void MSWordExportBase::WriteText()
{
#ifdef DEBUG
+#if 0
::std::clog << "<WriteText>" << ::std::endl;
::std::clog << dbg_out(pCurPam->GetDoc()->GetNodes()) << ::std::endl;
SwNodeHashSet aNodeSet;
SwNodeDeque aNodeDeque;
#endif
+#endif
while( pCurPam->GetPoint()->nNode < pCurPam->GetMark()->nNode ||
( pCurPam->GetPoint()->nNode == pCurPam->GetMark()->nNode &&
@@ -2448,6 +2450,7 @@ void MSWordExportBase::WriteText()
SwNode * pNd = pCurPam->GetNode();
#ifdef DEBUG
+#if 0
if (aNodeSet.find(pNd) == aNodeSet.end())
{
aNodeSet.insert(pNd);
@@ -2469,6 +2472,7 @@ void MSWordExportBase::WriteText()
::std::clog << "</nodes></already-done>" << ::std::endl;
}
#endif
+#endif
if ( pNd->IsTxtNode() )
SectionBreaksAndFrames( *pNd->GetTxtNode() );
@@ -3722,7 +3726,7 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer
void MSWordExportBase::OutputEndNode( const SwEndNode &rNode )
{
#ifdef DEBUG
- ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl;
+// ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl;
#endif
ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = mpTableInfo->getTableNodeInfo( &rNode );
diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx
index b80b567ebf..4e3931bbe7 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>
@@ -1361,3 +1362,68 @@ const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const
{
return pDoc ? &pDoc->GetXmlIdRegistry() : 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;
+}
+
+