summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/wrtww8.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/filter/ww8/wrtww8.cxx')
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx42
1 files changed, 31 insertions, 11 deletions
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index c158514fdd2c..745907044b52 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3119,7 +3119,7 @@ namespace
{
const sal_uLong WW_BLOCKSIZE = 0x200;
- void EncryptRC4(msfilter::MSCodec_Std97& rCtx, SvStream &rIn, SvStream &rOut)
+ ErrCode EncryptRC4(msfilter::MSCodec_Std97& rCtx, SvStream &rIn, SvStream &rOut)
{
rIn.Seek(STREAM_SEEK_TO_END);
sal_uLong nLen = rIn.Tell();
@@ -3130,14 +3130,17 @@ namespace
{
std::size_t nBS = std::min(nLen - nI, WW_BLOCKSIZE);
nBS = rIn.ReadBytes(in, nBS);
- rCtx.InitCipher(nBlock);
+ if (!rCtx.InitCipher(nBlock)) {
+ return ERRCODE_IO_NOTSUPPORTED;
+ }
rCtx.Encode(in, nBS, in, nBS);
rOut.WriteBytes(in, nBS);
}
+ return ERRCODE_NONE;
}
}
-void MSWordExportBase::ExportDocument( bool bWriteAll )
+ErrCode MSWordExportBase::ExportDocument( bool bWriteAll )
{
m_nCharFormatStart = DEFAULT_STYLES_COUNT;
m_nFormatCollStart = m_nCharFormatStart + m_pDoc->GetCharFormats()->size() - 1;
@@ -3204,7 +3207,7 @@ void MSWordExportBase::ExportDocument( bool bWriteAll )
if ( m_pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
m_pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )->RecalcObjOrdNums();
- ExportDocument_Impl();
+ ErrCode err = ExportDocument_Impl();
m_aFrames.clear();
@@ -3217,6 +3220,8 @@ void MSWordExportBase::ExportDocument( bool bWriteAll )
*m_pCurPam = *m_pOrigPam;
m_pDoc->getIDocumentRedlineAccess().SetRedlineFlags(m_nOrigRedlineFlags);
+
+ return err;
}
bool SwWW8Writer::InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec )
@@ -3267,7 +3272,7 @@ bool SwWW8Writer::InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec
return ( aEncryptionData.getLength() != 0 );
}
-void WW8Export::ExportDocument_Impl()
+ErrCode WW8Export::ExportDocument_Impl()
{
PrepareStorage();
@@ -3365,6 +3370,7 @@ void WW8Export::ExportDocument_Impl()
StoreDoc1();
+ ErrCode err = ERRCODE_NONE;
if ( bEncrypt )
{
SvStream *pStrmTemp, *pTableStrmTemp, *pDataStrmTemp;
@@ -3372,10 +3378,17 @@ void WW8Export::ExportDocument_Impl()
pTableStrmTemp = xTableStrm.get();
pDataStrmTemp = xDataStrm.get();
- if ( pDataStrmTemp && pDataStrmTemp != pStrmTemp)
- EncryptRC4(aCtx, *pDataStrm, *pDataStrmTemp);
+ if ( pDataStrmTemp && pDataStrmTemp != pStrmTemp) {
+ err = EncryptRC4(aCtx, *pDataStrm, *pDataStrmTemp);
+ if (err != ERRCODE_NONE) {
+ goto done;
+ }
+ }
- EncryptRC4(aCtx, *pTableStrm, *pTableStrmTemp);
+ err = EncryptRC4(aCtx, *pTableStrm, *pTableStrmTemp);
+ if (err != ERRCODE_NONE) {
+ goto done;
+ }
// Write Unencrypted Header 52 bytes to the start of the table stream
// EncryptionVersionInfo (4 bytes): A Version structure where Version.vMajor MUST be 0x0001, and Version.vMinor MUST be 0x0001.
@@ -3393,7 +3406,10 @@ void WW8Export::ExportDocument_Impl()
pTableStrmTemp->WriteBytes(pSaltData, 16);
pTableStrmTemp->WriteBytes(pSaltDigest, 16);
- EncryptRC4(aCtx, GetWriter().Strm(), *pStrmTemp);
+ err = EncryptRC4(aCtx, GetWriter().Strm(), *pStrmTemp);
+ if (err != ERRCODE_NONE) {
+ goto done;
+ }
// Write Unencrypted Fib 68 bytes to the start of the workdocument stream
pFib->m_fEncrypted = true; // fEncrypted indicates the document is encrypted.
@@ -3403,6 +3419,7 @@ void WW8Export::ExportDocument_Impl()
pStrmTemp->Seek( 0 );
pFib->WriteHeader( *pStrmTemp );
+ done:;
}
DELETEZ( m_pGrf );
@@ -3443,6 +3460,8 @@ void WW8Export::ExportDocument_Impl()
pDataStrm = nullptr;
GetWriter().GetStorage().Remove(SL::aData);
}
+
+ return err;
}
void WW8Export::PrepareStorage()
@@ -3522,16 +3541,17 @@ ErrCode SwWW8Writer::WriteStorage()
}
// Do the actual export
+ ErrCode err = ERRCODE_NONE;
{
bool bDot = mpMedium->GetFilter()->GetName().endsWith("Vorlage");
WW8Export aExport(this, m_pDoc, m_pCurrentPam, m_pOrigPam, bDot);
m_pExport = &aExport;
- aExport.ExportDocument( m_bWriteAll );
+ err = aExport.ExportDocument( m_bWriteAll );
m_pExport = nullptr;
}
::EndProgress( m_pDoc->GetDocShell() );
- return ERRCODE_NONE;
+ return err;
}
ErrCode SwWW8Writer::WriteMedium( SfxMedium& )