mav60: rebase to DEV300_m103
This commit is contained in:
commit
db79f11eaa
@ -465,6 +465,7 @@ void __EXPORT EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
{
|
{
|
||||||
pBindings->Invalidate( SID_SAVEDOC );
|
pBindings->Invalidate( SID_SAVEDOC );
|
||||||
pBindings->Invalidate( SID_DOC_MODIFIED );
|
pBindings->Invalidate( SID_DOC_MODIFIED );
|
||||||
|
pBindings->Invalidate( SID_UNDO );
|
||||||
}
|
}
|
||||||
if ( rKEvt.GetKeyCode().GetCode() == KEY_INSERT )
|
if ( rKEvt.GetKeyCode().GetCode() == KEY_INSERT )
|
||||||
pBindings->Invalidate( SID_ATTR_INSERT );
|
pBindings->Invalidate( SID_ATTR_INSERT );
|
||||||
|
@ -309,7 +309,10 @@ void BasicIDEShell::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
|
|||||||
|
|
||||||
void BasicIDEShell::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
|
void BasicIDEShell::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
|
||||||
{
|
{
|
||||||
// not interested in
|
// #i115671: Update SID_SAVEDOC after saving is completed
|
||||||
|
SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
|
||||||
|
if ( pBindings )
|
||||||
|
pBindings->Invalidate( SID_SAVEDOC );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicIDEShell::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
|
void BasicIDEShell::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
|
||||||
|
@ -383,7 +383,7 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const
|
|||||||
// dialogs
|
// dialogs
|
||||||
if ( nMode & BROWSEMODE_DIALOGS )
|
if ( nMode & BROWSEMODE_DIALOGS )
|
||||||
{
|
{
|
||||||
Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
|
Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
|
||||||
|
|
||||||
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLoaded( aOULibName ) )
|
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLoaded( aOULibName ) )
|
||||||
{
|
{
|
||||||
|
@ -613,6 +613,9 @@ IMPL_LINK(SvxBulletPickTabPage, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
|
|||||||
{
|
{
|
||||||
SvxNumberFormat aFmt(pActNum->GetLevel(i));
|
SvxNumberFormat aFmt(pActNum->GetLevel(i));
|
||||||
aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
|
aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
|
||||||
|
// #i93908# clear suffix for bullet lists
|
||||||
|
aFmt.SetPrefix(::rtl::OUString());
|
||||||
|
aFmt.SetSuffix(::rtl::OUString());
|
||||||
aFmt.SetBulletFont(&rActBulletFont);
|
aFmt.SetBulletFont(&rActBulletFont);
|
||||||
aFmt.SetBulletChar(cChar );
|
aFmt.SetBulletChar(cChar );
|
||||||
aFmt.SetCharFmtName(sBulletCharFmtName);
|
aFmt.SetCharFmtName(sBulletCharFmtName);
|
||||||
@ -859,6 +862,9 @@ IMPL_LINK(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
|
|||||||
sal_uInt16 nUpperLevelOrChar = (sal_uInt16)pLevelSettings->nParentNumbering;
|
sal_uInt16 nUpperLevelOrChar = (sal_uInt16)pLevelSettings->nParentNumbering;
|
||||||
if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL)
|
if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL)
|
||||||
{
|
{
|
||||||
|
// #i93908# clear suffix for bullet lists
|
||||||
|
aFmt.SetPrefix(::rtl::OUString());
|
||||||
|
aFmt.SetSuffix(::rtl::OUString());
|
||||||
if( pLevelSettings->sBulletFont.getLength() &&
|
if( pLevelSettings->sBulletFont.getLength() &&
|
||||||
pLevelSettings->sBulletFont.compareTo(
|
pLevelSettings->sBulletFont.compareTo(
|
||||||
rActBulletFont.GetName()))
|
rActBulletFont.GetName()))
|
||||||
@ -908,9 +914,10 @@ IMPL_LINK(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
|
|||||||
aFmt.SetCharFmtName(sNumCharFmtName);
|
aFmt.SetCharFmtName(sNumCharFmtName);
|
||||||
// #62069# // #92724#
|
// #62069# // #92724#
|
||||||
aFmt.SetBulletRelSize(100);
|
aFmt.SetBulletRelSize(100);
|
||||||
|
// #i93908#
|
||||||
|
aFmt.SetPrefix(pLevelSettings->sPrefix);
|
||||||
|
aFmt.SetSuffix(pLevelSettings->sSuffix);
|
||||||
}
|
}
|
||||||
aFmt.SetPrefix(pLevelSettings->sPrefix);
|
|
||||||
aFmt.SetSuffix(pLevelSettings->sSuffix);
|
|
||||||
pActNum->SetLevel(i, aFmt);
|
pActNum->SetLevel(i, aFmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
cui/source/tabpages/page.cxx
Normal file → Executable file
7
cui/source/tabpages/page.cxx
Normal file → Executable file
@ -608,6 +608,7 @@ void SvxPageDescPage::Reset( const SfxItemSet& rSet )
|
|||||||
ResStringArray aPaperAry( CUI_RES( nAryId ) );
|
ResStringArray aPaperAry( CUI_RES( nAryId ) );
|
||||||
sal_uInt32 nCnt = aPaperAry.Count();
|
sal_uInt32 nCnt = aPaperAry.Count();
|
||||||
|
|
||||||
|
sal_uInt16 nUserPos = LISTBOX_ENTRY_NOTFOUND;
|
||||||
for ( sal_uInt32 i = 0; i < nCnt; ++i )
|
for ( sal_uInt32 i = 0; i < nCnt; ++i )
|
||||||
{
|
{
|
||||||
String aStr = aPaperAry.GetString(i);
|
String aStr = aPaperAry.GetString(i);
|
||||||
@ -617,9 +618,11 @@ void SvxPageDescPage::Reset( const SfxItemSet& rSet )
|
|||||||
|
|
||||||
if ( eSize == ePaper )
|
if ( eSize == ePaper )
|
||||||
nActPos = nPos;
|
nActPos = nPos;
|
||||||
|
if( eSize == PAPER_USER )
|
||||||
|
nUserPos = nPos;
|
||||||
}
|
}
|
||||||
// aktuelles Papierformat selektieren
|
// preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead
|
||||||
aPaperSizeBox.SelectEntryPos( nActPos );
|
aPaperSizeBox.SelectEntryPos( nActPos != LISTBOX_ENTRY_NOTFOUND ? nActPos : nUserPos );
|
||||||
|
|
||||||
// Applikationsspezifisch
|
// Applikationsspezifisch
|
||||||
|
|
||||||
|
@ -931,7 +931,7 @@ HRESULT InterfaceOleWrapper_Impl::doInvoke( DISPPARAMS * pdispparams, VARIANT *
|
|||||||
// try to write back out parameter
|
// try to write back out parameter
|
||||||
if (outIndex.getLength() > 0)
|
if (outIndex.getLength() > 0)
|
||||||
{
|
{
|
||||||
const INT16* pOutIndex = outIndex.getConstArray();
|
const sal_Int16* pOutIndex = outIndex.getConstArray();
|
||||||
const Any* pOutParams = outParams.getConstArray();
|
const Any* pOutParams = outParams.getConstArray();
|
||||||
|
|
||||||
for (sal_Int32 i = 0; i < outIndex.getLength(); i++)
|
for (sal_Int32 i = 0; i < outIndex.getLength(); i++)
|
||||||
|
@ -109,7 +109,7 @@ UnxPluginComm::~UnxPluginComm()
|
|||||||
int status = 16777216;
|
int status = 16777216;
|
||||||
pid_t nExit = waitpid( m_nCommPID, &status, WUNTRACED );
|
pid_t nExit = waitpid( m_nCommPID, &status, WUNTRACED );
|
||||||
#if OSL_DEBUG_LEVEL > 1
|
#if OSL_DEBUG_LEVEL > 1
|
||||||
fprintf( stderr, "child %d (plugin app child %d) exited with status %d\n", nExit, m_nCommPID, WEXITSTATUS(status) );
|
fprintf( stderr, "child %d (plugin app child %d) exited with status %d\n", (int)nExit, (int)m_nCommPID, (int)WEXITSTATUS(status) );
|
||||||
#else
|
#else
|
||||||
(void)nExit;
|
(void)nExit;
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,7 +39,12 @@ namespace beans
|
|||||||
{
|
{
|
||||||
struct PropertyValue;
|
struct PropertyValue;
|
||||||
}
|
}
|
||||||
|
namespace packages
|
||||||
|
{
|
||||||
|
class ContentInfo;
|
||||||
|
}
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
class ZipFile;
|
class ZipFile;
|
||||||
class ZipPackage;
|
class ZipPackage;
|
||||||
class ZipOutputStream;
|
class ZipOutputStream;
|
||||||
@ -85,6 +90,8 @@ public:
|
|||||||
void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
|
void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
|
||||||
void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; }
|
void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; }
|
||||||
|
|
||||||
|
bool saveChild(const rtl::OUString &rShortName, const com::sun::star::packages::ContentInfo &rInfo, rtl::OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, com::sun::star::uno::Sequence < sal_Int8 > &rEncryptionKey, rtlRandomPool & rRandomPool);
|
||||||
|
|
||||||
// Recursive functions
|
// Recursive functions
|
||||||
void saveContents(rtl::OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence< sal_Int8 > &rEncryptionKey, rtlRandomPool & rRandomPool)
|
void saveContents(rtl::OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence< sal_Int8 > &rEncryptionKey, rtlRandomPool & rRandomPool)
|
||||||
throw(::com::sun::star::uno::RuntimeException);
|
throw(::com::sun::star::uno::RuntimeException);
|
||||||
|
@ -49,8 +49,8 @@
|
|||||||
using namespace com::sun::star;
|
using namespace com::sun::star;
|
||||||
using namespace com::sun::star::packages::zip::ZipConstants;
|
using namespace com::sun::star::packages::zip::ZipConstants;
|
||||||
using namespace com::sun::star::packages::zip;
|
using namespace com::sun::star::packages::zip;
|
||||||
using namespace com::sun::star::container;
|
|
||||||
using namespace com::sun::star::packages;
|
using namespace com::sun::star::packages;
|
||||||
|
using namespace com::sun::star::container;
|
||||||
using namespace com::sun::star::beans;
|
using namespace com::sun::star::beans;
|
||||||
using namespace com::sun::star::lang;
|
using namespace com::sun::star::lang;
|
||||||
using namespace com::sun::star::io;
|
using namespace com::sun::star::io;
|
||||||
@ -304,26 +304,391 @@ static void ImplSetStoredData( ZipEntry & rEntry, uno::Reference< XInputStream>
|
|||||||
rEntry.nCrc = aCRC32.getValue();
|
rEntry.nCrc = aCRC32.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZipPackageFolder::saveContents( ::rtl::OUString &rPath, std::vector < uno::Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, const uno::Sequence < sal_Int8 >&rEncryptionKey, rtlRandomPool &rRandomPool)
|
bool ZipPackageFolder::saveChild( const OUString &rShortName, const ContentInfo &rInfo, OUString &rPath, std::vector < Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, Sequence < sal_Int8 > &rEncryptionKey, rtlRandomPool &rRandomPool)
|
||||||
throw(uno::RuntimeException)
|
|
||||||
{
|
{
|
||||||
sal_Bool bWritingFailed = sal_False;
|
bool bSuccess = true;
|
||||||
ZipPackageFolder *pFolder = NULL;
|
|
||||||
ZipPackageStream *pStream = NULL;
|
const OUString sMediaTypeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
|
||||||
const ::rtl::OUString sMediaTypeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
|
const OUString sVersionProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Version" ) );
|
||||||
const ::rtl::OUString sVersionProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Version" ) );
|
const OUString sFullPathProperty ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
|
||||||
const ::rtl::OUString sFullPathProperty ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
|
const OUString sInitialisationVectorProperty ( RTL_CONSTASCII_USTRINGPARAM ( "InitialisationVector" ) );
|
||||||
const ::rtl::OUString sInitialisationVectorProperty ( RTL_CONSTASCII_USTRINGPARAM ( "InitialisationVector" ) );
|
const OUString sSaltProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Salt" ) );
|
||||||
const ::rtl::OUString sSaltProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Salt" ) );
|
const OUString sIterationCountProperty ( RTL_CONSTASCII_USTRINGPARAM ( "IterationCount" ) );
|
||||||
const ::rtl::OUString sIterationCountProperty ( RTL_CONSTASCII_USTRINGPARAM ( "IterationCount" ) );
|
const OUString sSizeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Size" ) );
|
||||||
const ::rtl::OUString sSizeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Size" ) );
|
const OUString sDigestProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Digest" ) );
|
||||||
const ::rtl::OUString sDigestProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Digest" ) );
|
|
||||||
const ::rtl::OUString sEncryptionAlgProperty ( RTL_CONSTASCII_USTRINGPARAM ( "EncryptionAlgorithm" ) );
|
const ::rtl::OUString sEncryptionAlgProperty ( RTL_CONSTASCII_USTRINGPARAM ( "EncryptionAlgorithm" ) );
|
||||||
const ::rtl::OUString sStartKeyAlgProperty ( RTL_CONSTASCII_USTRINGPARAM ( "StartKeyAlgorithm" ) );
|
const ::rtl::OUString sStartKeyAlgProperty ( RTL_CONSTASCII_USTRINGPARAM ( "StartKeyAlgorithm" ) );
|
||||||
const ::rtl::OUString sDigestAlgProperty ( RTL_CONSTASCII_USTRINGPARAM ( "DigestAlgorithm" ) );
|
const ::rtl::OUString sDigestAlgProperty ( RTL_CONSTASCII_USTRINGPARAM ( "DigestAlgorithm" ) );
|
||||||
const ::rtl::OUString sDerivedKeySizeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "DerivedKeySize" ) );
|
const ::rtl::OUString sDerivedKeySizeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "DerivedKeySize" ) );
|
||||||
|
|
||||||
sal_Bool bHaveEncryptionKey = rEncryptionKey.getLength() ? sal_True : sal_False;
|
Sequence < PropertyValue > aPropSet (PKG_SIZE_NOENCR_MNFST);
|
||||||
|
|
||||||
|
OSL_ENSURE( ( rInfo.bFolder && rInfo.pFolder ) || ( !rInfo.bFolder && rInfo.pStream ), "A valid child object is expected!" );
|
||||||
|
if ( rInfo.bFolder )
|
||||||
|
{
|
||||||
|
OUString sTempName = rPath + rShortName + OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
|
||||||
|
|
||||||
|
if ( rInfo.pFolder->GetMediaType().getLength() )
|
||||||
|
{
|
||||||
|
aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
|
||||||
|
aPropSet[PKG_MNFST_MEDIATYPE].Value <<= rInfo.pFolder->GetMediaType();
|
||||||
|
aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
|
||||||
|
aPropSet[PKG_MNFST_VERSION].Value <<= rInfo.pFolder->GetVersion();
|
||||||
|
aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
|
||||||
|
aPropSet[PKG_MNFST_FULLPATH].Value <<= sTempName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aPropSet.realloc( 0 );
|
||||||
|
|
||||||
|
rInfo.pFolder->saveContents( sTempName, rManList, rZipOut, rEncryptionKey, rRandomPool);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if pTempEntry is necessary, it will be released and passed to the ZipOutputStream
|
||||||
|
// and be deleted in the ZipOutputStream destructor
|
||||||
|
auto_ptr < ZipEntry > pAutoTempEntry ( new ZipEntry );
|
||||||
|
ZipEntry* pTempEntry = pAutoTempEntry.get();
|
||||||
|
|
||||||
|
// In case the entry we are reading is also the entry we are writing, we will
|
||||||
|
// store the ZipEntry data in pTempEntry
|
||||||
|
|
||||||
|
ZipPackageFolder::copyZipEntry ( *pTempEntry, rInfo.pStream->aEntry );
|
||||||
|
pTempEntry->sPath = rPath + rShortName;
|
||||||
|
pTempEntry->nPathLen = (sal_Int16)( ::rtl::OUStringToOString( pTempEntry->sPath, RTL_TEXTENCODING_UTF8 ).getLength() );
|
||||||
|
|
||||||
|
sal_Bool bToBeEncrypted = rInfo.pStream->IsToBeEncrypted() && (rEncryptionKey.getLength() || rInfo.pStream->HasOwnKey());
|
||||||
|
sal_Bool bToBeCompressed = bToBeEncrypted ? sal_True : rInfo.pStream->IsToBeCompressed();
|
||||||
|
|
||||||
|
aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
|
||||||
|
aPropSet[PKG_MNFST_MEDIATYPE].Value <<= rInfo.pStream->GetMediaType( );
|
||||||
|
aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
|
||||||
|
aPropSet[PKG_MNFST_VERSION].Value <<= ::rtl::OUString(); // no version is stored for streams currently
|
||||||
|
aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
|
||||||
|
aPropSet[PKG_MNFST_FULLPATH].Value <<= pTempEntry->sPath;
|
||||||
|
|
||||||
|
|
||||||
|
OSL_ENSURE( rInfo.pStream->GetStreamMode() != PACKAGE_STREAM_NOTSET, "Unacceptable ZipPackageStream mode!" );
|
||||||
|
|
||||||
|
sal_Bool bRawStream = sal_False;
|
||||||
|
if ( rInfo.pStream->GetStreamMode() == PACKAGE_STREAM_DETECT )
|
||||||
|
bRawStream = rInfo.pStream->ParsePackageRawStream();
|
||||||
|
else if ( rInfo.pStream->GetStreamMode() == PACKAGE_STREAM_RAW )
|
||||||
|
bRawStream = sal_True;
|
||||||
|
|
||||||
|
sal_Bool bTransportOwnEncrStreamAsRaw = sal_False;
|
||||||
|
// During the storing the original size of the stream can be changed
|
||||||
|
// TODO/LATER: get rid of this hack
|
||||||
|
sal_Int32 nOwnStreamOrigSize = bRawStream ? rInfo.pStream->GetMagicalHackSize() : rInfo.pStream->getSize();
|
||||||
|
|
||||||
|
sal_Bool bUseNonSeekableAccess = sal_False;
|
||||||
|
Reference < XInputStream > xStream;
|
||||||
|
if ( !rInfo.pStream->IsPackageMember() && !bRawStream && !bToBeEncrypted && bToBeCompressed )
|
||||||
|
{
|
||||||
|
// the stream is not a package member, not a raw stream,
|
||||||
|
// it should not be encrypted and it should be compressed,
|
||||||
|
// in this case nonseekable access can be used
|
||||||
|
|
||||||
|
xStream = rInfo.pStream->GetOwnStreamNoWrap();
|
||||||
|
Reference < XSeekable > xSeek ( xStream, UNO_QUERY );
|
||||||
|
|
||||||
|
bUseNonSeekableAccess = ( xStream.is() && !xSeek.is() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !bUseNonSeekableAccess )
|
||||||
|
{
|
||||||
|
xStream = rInfo.pStream->getRawData();
|
||||||
|
|
||||||
|
if ( !xStream.is() )
|
||||||
|
{
|
||||||
|
VOS_ENSURE( 0, "ZipPackageStream didn't have a stream associated with it, skipping!" );
|
||||||
|
bSuccess = false;
|
||||||
|
return bSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference < XSeekable > xSeek ( xStream, UNO_QUERY );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( xSeek.is() )
|
||||||
|
{
|
||||||
|
// If the stream is a raw one, then we should be positioned
|
||||||
|
// at the beginning of the actual data
|
||||||
|
if ( !bToBeCompressed || bRawStream )
|
||||||
|
{
|
||||||
|
// The raw stream can neither be encrypted nor connected
|
||||||
|
OSL_ENSURE( !bRawStream || !bToBeCompressed && !bToBeEncrypted, "The stream is already encrypted!\n" );
|
||||||
|
xSeek->seek ( bRawStream ? rInfo.pStream->GetMagicalHackPos() : 0 );
|
||||||
|
ImplSetStoredData ( *pTempEntry, xStream );
|
||||||
|
|
||||||
|
// TODO/LATER: Get rid of hacks related to switching of Flag Method and Size properties!
|
||||||
|
}
|
||||||
|
else if ( bToBeEncrypted )
|
||||||
|
{
|
||||||
|
// this is the correct original size
|
||||||
|
pTempEntry->nSize = static_cast < sal_Int32 > ( xSeek->getLength() );
|
||||||
|
nOwnStreamOrigSize = pTempEntry->nSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
xSeek->seek ( 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Okay, we don't have an xSeekable stream. This is possibly bad.
|
||||||
|
// check if it's one of our own streams, if it is then we know that
|
||||||
|
// each time we ask for it we'll get a new stream that will be
|
||||||
|
// at position zero...otherwise, assert and skip this stream...
|
||||||
|
if ( rInfo.pStream->IsPackageMember() )
|
||||||
|
{
|
||||||
|
// if the password has been changed than the stream should not be package member any more
|
||||||
|
if ( rInfo.pStream->IsEncrypted() && rInfo.pStream->IsToBeEncrypted() )
|
||||||
|
{
|
||||||
|
// Should be handled close to the raw stream handling
|
||||||
|
bTransportOwnEncrStreamAsRaw = sal_True;
|
||||||
|
pTempEntry->nMethod = STORED;
|
||||||
|
|
||||||
|
// TODO/LATER: get rid of this situation
|
||||||
|
// this size should be different from the one that will be stored in manifest.xml
|
||||||
|
// it is used in storing algorithms and after storing the correct size will be set
|
||||||
|
pTempEntry->nSize = pTempEntry->nCompressedSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VOS_ENSURE( 0, "The package component requires that every stream either be FROM a package or it must support XSeekable!" );
|
||||||
|
bSuccess = false;
|
||||||
|
return bSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( Exception& )
|
||||||
|
{
|
||||||
|
VOS_ENSURE( 0, "The stream provided to the package component has problems!" );
|
||||||
|
bSuccess = false;
|
||||||
|
return bSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( bToBeEncrypted || bRawStream || bTransportOwnEncrStreamAsRaw )
|
||||||
|
{
|
||||||
|
if ( bToBeEncrypted && !bTransportOwnEncrStreamAsRaw )
|
||||||
|
{
|
||||||
|
Sequence < sal_uInt8 > aSalt ( 16 ), aVector ( 8 );
|
||||||
|
rtl_random_getBytes ( rRandomPool, aSalt.getArray(), 16 );
|
||||||
|
rtl_random_getBytes ( rRandomPool, aVector.getArray(), 8 );
|
||||||
|
sal_Int32 nIterationCount = 1024;
|
||||||
|
|
||||||
|
if ( !rInfo.pStream->HasOwnKey() )
|
||||||
|
rInfo.pStream->setKey ( rEncryptionKey );
|
||||||
|
|
||||||
|
rInfo.pStream->setInitialisationVector ( aVector );
|
||||||
|
rInfo.pStream->setSalt ( aSalt );
|
||||||
|
rInfo.pStream->setIterationCount ( nIterationCount );
|
||||||
|
}
|
||||||
|
|
||||||
|
// last property is digest, which is inserted later if we didn't have
|
||||||
|
// a magic header
|
||||||
|
aPropSet.realloc(PKG_SIZE_ENCR_MNFST);
|
||||||
|
|
||||||
|
aPropSet[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
|
||||||
|
aPropSet[PKG_MNFST_INIVECTOR].Value <<= rInfo.pStream->getInitialisationVector();
|
||||||
|
aPropSet[PKG_MNFST_SALT].Name = sSaltProperty;
|
||||||
|
aPropSet[PKG_MNFST_SALT].Value <<= rInfo.pStream->getSalt();
|
||||||
|
aPropSet[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
|
||||||
|
aPropSet[PKG_MNFST_ITERATION].Value <<= rInfo.pStream->getIterationCount ();
|
||||||
|
|
||||||
|
// Need to store the uncompressed size in the manifest
|
||||||
|
OSL_ENSURE( nOwnStreamOrigSize >= 0, "The stream size was not correctly initialized!\n" );
|
||||||
|
aPropSet[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty;
|
||||||
|
aPropSet[PKG_MNFST_UCOMPSIZE].Value <<= nOwnStreamOrigSize;
|
||||||
|
|
||||||
|
if ( bRawStream || bTransportOwnEncrStreamAsRaw )
|
||||||
|
{
|
||||||
|
aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
|
||||||
|
aPropSet[PKG_MNFST_DIGEST].Value <<= rInfo.pStream->getDigest();
|
||||||
|
aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
|
||||||
|
aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg;
|
||||||
|
aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
|
||||||
|
aPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID;
|
||||||
|
aPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty;
|
||||||
|
aPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg;
|
||||||
|
aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty;
|
||||||
|
aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the entry is already stored in the zip file in the format we
|
||||||
|
// want for this write...copy it raw
|
||||||
|
if ( !bUseNonSeekableAccess
|
||||||
|
&& ( bRawStream || bTransportOwnEncrStreamAsRaw
|
||||||
|
|| ( rInfo.pStream->IsPackageMember() && !bToBeEncrypted
|
||||||
|
&& ( ( rInfo.pStream->aEntry.nMethod == DEFLATED && bToBeCompressed )
|
||||||
|
|| ( rInfo.pStream->aEntry.nMethod == STORED && !bToBeCompressed ) ) ) ) )
|
||||||
|
{
|
||||||
|
// If it's a PackageMember, then it's an unbuffered stream and we need
|
||||||
|
// to get a new version of it as we can't seek backwards.
|
||||||
|
if ( rInfo.pStream->IsPackageMember() )
|
||||||
|
{
|
||||||
|
xStream = rInfo.pStream->getRawData();
|
||||||
|
if ( !xStream.is() )
|
||||||
|
{
|
||||||
|
// Make sure that we actually _got_ a new one !
|
||||||
|
VOS_ENSURE( 0, "ZipPackageStream didn't have a stream associated with it, skipping!" );
|
||||||
|
bSuccess = false;
|
||||||
|
return bSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( bRawStream )
|
||||||
|
xStream->skipBytes( rInfo.pStream->GetMagicalHackPos() );
|
||||||
|
|
||||||
|
rZipOut.putNextEntry ( *pTempEntry, rInfo.pStream, sal_False );
|
||||||
|
// the entry is provided to the ZipOutputStream that will delete it
|
||||||
|
pAutoTempEntry.release();
|
||||||
|
|
||||||
|
Sequence < sal_Int8 > aSeq ( n_ConstBufferSize );
|
||||||
|
sal_Int32 nLength;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
nLength = xStream->readBytes( aSeq, n_ConstBufferSize );
|
||||||
|
rZipOut.rawWrite(aSeq, 0, nLength);
|
||||||
|
}
|
||||||
|
while ( nLength == n_ConstBufferSize );
|
||||||
|
|
||||||
|
rZipOut.rawCloseEntry();
|
||||||
|
}
|
||||||
|
catch ( ZipException& )
|
||||||
|
{
|
||||||
|
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
||||||
|
bSuccess = false;
|
||||||
|
}
|
||||||
|
catch ( IOException& )
|
||||||
|
{
|
||||||
|
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
||||||
|
bSuccess = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// This stream is defenitly not a raw stream
|
||||||
|
|
||||||
|
// If nonseekable access is used the stream should be at the beginning and
|
||||||
|
// is useless after the storing. Thus if the storing fails the package should
|
||||||
|
// be thrown away ( as actually it is done currently )!
|
||||||
|
// To allow to reuse the package after the error, the optimization must be removed!
|
||||||
|
|
||||||
|
// If it's a PackageMember, then our previous reference held a 'raw' stream
|
||||||
|
// so we need to re-get it, unencrypted, uncompressed and positioned at the
|
||||||
|
// beginning of the stream
|
||||||
|
if ( rInfo.pStream->IsPackageMember() )
|
||||||
|
{
|
||||||
|
xStream = rInfo.pStream->getInputStream();
|
||||||
|
if ( !xStream.is() )
|
||||||
|
{
|
||||||
|
// Make sure that we actually _got_ a new one !
|
||||||
|
VOS_ENSURE( 0, "ZipPackageStream didn't have a stream associated with it, skipping!" );
|
||||||
|
bSuccess = false;
|
||||||
|
return bSuccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( bToBeCompressed )
|
||||||
|
{
|
||||||
|
pTempEntry->nMethod = DEFLATED;
|
||||||
|
pTempEntry->nCrc = pTempEntry->nCompressedSize = pTempEntry->nSize = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rZipOut.putNextEntry ( *pTempEntry, rInfo.pStream, bToBeEncrypted);
|
||||||
|
// the entry is provided to the ZipOutputStream that will delete it
|
||||||
|
pAutoTempEntry.release();
|
||||||
|
|
||||||
|
sal_Int32 nLength;
|
||||||
|
Sequence < sal_Int8 > aSeq (n_ConstBufferSize);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
nLength = xStream->readBytes(aSeq, n_ConstBufferSize);
|
||||||
|
rZipOut.write(aSeq, 0, nLength);
|
||||||
|
}
|
||||||
|
while ( nLength == n_ConstBufferSize );
|
||||||
|
|
||||||
|
rZipOut.closeEntry();
|
||||||
|
}
|
||||||
|
catch ( ZipException& )
|
||||||
|
{
|
||||||
|
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
||||||
|
bSuccess = false;
|
||||||
|
}
|
||||||
|
catch ( IOException& )
|
||||||
|
{
|
||||||
|
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
||||||
|
bSuccess = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( bToBeEncrypted )
|
||||||
|
{
|
||||||
|
aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
|
||||||
|
aPropSet[PKG_MNFST_DIGEST].Value <<= rInfo.pStream->getDigest();
|
||||||
|
aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
|
||||||
|
aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg;
|
||||||
|
aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
|
||||||
|
aPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID;
|
||||||
|
aPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty;
|
||||||
|
aPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg;
|
||||||
|
aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty;
|
||||||
|
aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize;
|
||||||
|
|
||||||
|
rInfo.pStream->SetIsEncrypted ( sal_True );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( bSuccess )
|
||||||
|
{
|
||||||
|
if ( !rInfo.pStream->IsPackageMember() )
|
||||||
|
{
|
||||||
|
rInfo.pStream->CloseOwnStreamIfAny();
|
||||||
|
rInfo.pStream->SetPackageMember ( sal_True );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( bRawStream )
|
||||||
|
{
|
||||||
|
// the raw stream was integrated and now behaves
|
||||||
|
// as usual encrypted stream
|
||||||
|
rInfo.pStream->SetToBeEncrypted( sal_True );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove hacky bit from entry flags
|
||||||
|
if ( pTempEntry->nFlag & ( 1 << 4 ) )
|
||||||
|
{
|
||||||
|
pTempEntry->nFlag &= ~( 1 << 4 );
|
||||||
|
pTempEntry->nMethod = STORED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then copy it back afterwards...
|
||||||
|
ZipPackageFolder::copyZipEntry ( rInfo.pStream->aEntry, *pTempEntry );
|
||||||
|
|
||||||
|
// TODO/LATER: get rid of this hack ( the encrypted stream size property is changed during saving )
|
||||||
|
if ( rInfo.pStream->IsEncrypted() )
|
||||||
|
rInfo.pStream->setSize( nOwnStreamOrigSize );
|
||||||
|
|
||||||
|
rInfo.pStream->aEntry.nOffset *= -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// folder can have a mediatype only in package format
|
||||||
|
if ( aPropSet.getLength()
|
||||||
|
&& ( m_nFormat == embed::StorageFormats::PACKAGE || ( m_nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) ) )
|
||||||
|
rManList.push_back( aPropSet );
|
||||||
|
|
||||||
|
return bSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, Sequence < sal_Int8 > &rEncryptionKey, rtlRandomPool &rRandomPool)
|
||||||
|
throw(RuntimeException)
|
||||||
|
{
|
||||||
|
bool bWritingFailed = false;
|
||||||
|
|
||||||
if ( maContents.begin() == maContents.end() && rPath.getLength() && m_nFormat != embed::StorageFormats::OFOPXML )
|
if ( maContents.begin() == maContents.end() && rPath.getLength() && m_nFormat != embed::StorageFormats::OFOPXML )
|
||||||
{
|
{
|
||||||
@ -342,12 +707,25 @@ void ZipPackageFolder::saveContents( ::rtl::OUString &rPath, std::vector < uno::
|
|||||||
catch ( ZipException& )
|
catch ( ZipException& )
|
||||||
{
|
{
|
||||||
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
||||||
bWritingFailed = sal_True;
|
bWritingFailed = true;
|
||||||
}
|
}
|
||||||
catch ( IOException& )
|
catch ( IOException& )
|
||||||
{
|
{
|
||||||
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
||||||
bWritingFailed = sal_True;
|
bWritingFailed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bMimeTypeStreamStored = false;
|
||||||
|
::rtl::OUString aMimeTypeStreamName( RTL_CONSTASCII_USTRINGPARAM( "mimetype" ) );
|
||||||
|
if ( m_nFormat == embed::StorageFormats::ZIP && !rPath.getLength() )
|
||||||
|
{
|
||||||
|
// let the "mimtype" stream in root folder be stored as the first stream if it is zip format
|
||||||
|
ContentHash::iterator aIter = maContents.find ( aMimeTypeStreamName );
|
||||||
|
if ( aIter != maContents.end() && !(*aIter).second->bFolder )
|
||||||
|
{
|
||||||
|
bMimeTypeStreamStored = true;
|
||||||
|
bWritingFailed = !saveChild( (*aIter).first, *(*aIter).second, rPath, rManList, rZipOut, rEncryptionKey, rRandomPool );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,374 +736,8 @@ void ZipPackageFolder::saveContents( ::rtl::OUString &rPath, std::vector < uno::
|
|||||||
const ::rtl::OUString &rShortName = (*aCI).first;
|
const ::rtl::OUString &rShortName = (*aCI).first;
|
||||||
const ContentInfo &rInfo = *(*aCI).second;
|
const ContentInfo &rInfo = *(*aCI).second;
|
||||||
|
|
||||||
uno::Sequence < PropertyValue > aPropSet( PKG_SIZE_NOENCR_MNFST );
|
if ( !bMimeTypeStreamStored || !rShortName.equals( aMimeTypeStreamName ) )
|
||||||
|
bWritingFailed = !saveChild( rShortName, rInfo, rPath, rManList, rZipOut, rEncryptionKey, rRandomPool );
|
||||||
if ( rInfo.bFolder )
|
|
||||||
pFolder = rInfo.pFolder;
|
|
||||||
else
|
|
||||||
pStream = rInfo.pStream;
|
|
||||||
|
|
||||||
if ( rInfo.bFolder )
|
|
||||||
{
|
|
||||||
::rtl::OUString sTempName = rPath + rShortName + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
|
|
||||||
|
|
||||||
if ( pFolder->GetMediaType().getLength() )
|
|
||||||
{
|
|
||||||
aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
|
|
||||||
aPropSet[PKG_MNFST_MEDIATYPE].Value <<= pFolder->GetMediaType();
|
|
||||||
aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
|
|
||||||
aPropSet[PKG_MNFST_VERSION].Value <<= pFolder->GetVersion();
|
|
||||||
aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
|
|
||||||
aPropSet[PKG_MNFST_FULLPATH].Value <<= sTempName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
aPropSet.realloc( 0 );
|
|
||||||
|
|
||||||
pFolder->saveContents( sTempName, rManList, rZipOut, rEncryptionKey, rRandomPool);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// if pTempEntry is necessary, it will be released and passed to the ZipOutputStream
|
|
||||||
// and be deleted in the ZipOutputStream destructor
|
|
||||||
auto_ptr < ZipEntry > pAutoTempEntry ( new ZipEntry );
|
|
||||||
ZipEntry* pTempEntry = pAutoTempEntry.get();
|
|
||||||
|
|
||||||
// In case the entry we are reading is also the entry we are writing, we will
|
|
||||||
// store the ZipEntry data in pTempEntry
|
|
||||||
|
|
||||||
ZipPackageFolder::copyZipEntry ( *pTempEntry, pStream->aEntry );
|
|
||||||
pTempEntry->sPath = rPath + rShortName;
|
|
||||||
pTempEntry->nPathLen = (sal_Int16)( ::rtl::OUStringToOString( pTempEntry->sPath, RTL_TEXTENCODING_UTF8 ).getLength() );
|
|
||||||
|
|
||||||
sal_Bool bToBeEncrypted = pStream->IsToBeEncrypted() && (bHaveEncryptionKey || pStream->HasOwnKey());
|
|
||||||
sal_Bool bToBeCompressed = bToBeEncrypted ? sal_True : pStream->IsToBeCompressed();
|
|
||||||
|
|
||||||
aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
|
|
||||||
aPropSet[PKG_MNFST_MEDIATYPE].Value <<= pStream->GetMediaType( );
|
|
||||||
aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
|
|
||||||
aPropSet[PKG_MNFST_VERSION].Value <<= ::rtl::OUString(); // no version is stored for streams currently
|
|
||||||
aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
|
|
||||||
aPropSet[PKG_MNFST_FULLPATH].Value <<= pTempEntry->sPath;
|
|
||||||
|
|
||||||
|
|
||||||
OSL_ENSURE( pStream->GetStreamMode() != PACKAGE_STREAM_NOTSET, "Unacceptable ZipPackageStream mode!" );
|
|
||||||
|
|
||||||
sal_Bool bRawStream = sal_False;
|
|
||||||
if ( pStream->GetStreamMode() == PACKAGE_STREAM_DETECT )
|
|
||||||
bRawStream = pStream->ParsePackageRawStream();
|
|
||||||
else if ( pStream->GetStreamMode() == PACKAGE_STREAM_RAW )
|
|
||||||
bRawStream = sal_True;
|
|
||||||
|
|
||||||
sal_Bool bTransportOwnEncrStreamAsRaw = sal_False;
|
|
||||||
// During the storing the original size of the stream can be changed
|
|
||||||
// TODO/LATER: get rid of this hack
|
|
||||||
sal_Int32 nOwnStreamOrigSize = bRawStream ? pStream->GetMagicalHackSize() : pStream->getSize();
|
|
||||||
|
|
||||||
sal_Bool bUseNonSeekableAccess = sal_False;
|
|
||||||
uno::Reference < XInputStream > xStream;
|
|
||||||
if ( !pStream->IsPackageMember() && !bRawStream && !bToBeEncrypted && bToBeCompressed )
|
|
||||||
{
|
|
||||||
// the stream is not a package member, not a raw stream,
|
|
||||||
// it should not be encrypted and it should be compressed,
|
|
||||||
// in this case nonseekable access can be used
|
|
||||||
|
|
||||||
xStream = pStream->GetOwnStreamNoWrap();
|
|
||||||
uno::Reference < XSeekable > xSeek ( xStream, uno::UNO_QUERY );
|
|
||||||
|
|
||||||
bUseNonSeekableAccess = ( xStream.is() && !xSeek.is() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !bUseNonSeekableAccess )
|
|
||||||
{
|
|
||||||
xStream = pStream->getRawData();
|
|
||||||
|
|
||||||
if ( !xStream.is() )
|
|
||||||
{
|
|
||||||
VOS_ENSURE( 0, "ZipPackageStream didn't have a stream associated with it, skipping!" );
|
|
||||||
bWritingFailed = sal_True;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
uno::Reference < XSeekable > xSeek ( xStream, uno::UNO_QUERY );
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ( xSeek.is() )
|
|
||||||
{
|
|
||||||
// If the stream is a raw one, then we should be positioned
|
|
||||||
// at the beginning of the actual data
|
|
||||||
if ( !bToBeCompressed || bRawStream )
|
|
||||||
{
|
|
||||||
// The raw stream can neither be encrypted nor connected
|
|
||||||
OSL_ENSURE( !bRawStream || !bToBeCompressed && !bToBeEncrypted, "The stream is already encrypted!\n" );
|
|
||||||
xSeek->seek ( bRawStream ? pStream->GetMagicalHackPos() : 0 );
|
|
||||||
ImplSetStoredData ( *pTempEntry, xStream );
|
|
||||||
|
|
||||||
// TODO/LATER: Get rid of hacks related to switching of Flag Method and Size properties!
|
|
||||||
}
|
|
||||||
else if ( bToBeEncrypted )
|
|
||||||
{
|
|
||||||
// this is the correct original size
|
|
||||||
pTempEntry->nSize = static_cast < sal_Int32 > ( xSeek->getLength() );
|
|
||||||
nOwnStreamOrigSize = pTempEntry->nSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
xSeek->seek ( 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Okay, we don't have an xSeekable stream. This is possibly bad.
|
|
||||||
// check if it's one of our own streams, if it is then we know that
|
|
||||||
// each time we ask for it we'll get a new stream that will be
|
|
||||||
// at position zero...otherwise, assert and skip this stream...
|
|
||||||
if ( pStream->IsPackageMember() )
|
|
||||||
{
|
|
||||||
// if the password has been changed than the stream should not be package member any more
|
|
||||||
if ( pStream->IsEncrypted() && pStream->IsToBeEncrypted() )
|
|
||||||
{
|
|
||||||
// Should be handled close to the raw stream handling
|
|
||||||
bTransportOwnEncrStreamAsRaw = sal_True;
|
|
||||||
pTempEntry->nMethod = STORED;
|
|
||||||
|
|
||||||
// TODO/LATER: get rid of this situation
|
|
||||||
// this size should be different from the one that will be stored in manifest.xml
|
|
||||||
// it is used in storing algorithms and after storing the correct size will be set
|
|
||||||
pTempEntry->nSize = pTempEntry->nCompressedSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VOS_ENSURE( 0, "The package component requires that every stream either be FROM a package or it must support XSeekable!" );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch ( uno::Exception& )
|
|
||||||
{
|
|
||||||
VOS_ENSURE( 0, "The stream provided to the package component has problems!" );
|
|
||||||
bWritingFailed = sal_True;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( bToBeEncrypted || bRawStream || bTransportOwnEncrStreamAsRaw )
|
|
||||||
{
|
|
||||||
if ( bToBeEncrypted && !bTransportOwnEncrStreamAsRaw )
|
|
||||||
{
|
|
||||||
sal_Int32 nVectorLen = pStream->GetBlockSize();
|
|
||||||
uno::Sequence < sal_Int8 > aSalt ( 16 ), aVector ( nVectorLen );
|
|
||||||
rtl_random_getBytes ( rRandomPool, aSalt.getArray(), 16 );
|
|
||||||
rtl_random_getBytes ( rRandomPool, aVector.getArray(), nVectorLen );
|
|
||||||
sal_Int32 nIterationCount = 1024;
|
|
||||||
|
|
||||||
if ( !pStream->HasOwnKey() )
|
|
||||||
pStream->setKey ( rEncryptionKey );
|
|
||||||
|
|
||||||
pStream->setInitialisationVector ( aVector );
|
|
||||||
pStream->setSalt ( aSalt );
|
|
||||||
pStream->setIterationCount ( nIterationCount );
|
|
||||||
}
|
|
||||||
|
|
||||||
// last property is digest, which is inserted later if we didn't have
|
|
||||||
// a magic header
|
|
||||||
aPropSet.realloc( PKG_SIZE_ENCR_MNFST );
|
|
||||||
|
|
||||||
aPropSet[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
|
|
||||||
aPropSet[PKG_MNFST_INIVECTOR].Value <<= pStream->getInitialisationVector();
|
|
||||||
aPropSet[PKG_MNFST_SALT].Name = sSaltProperty;
|
|
||||||
aPropSet[PKG_MNFST_SALT].Value <<= pStream->getSalt();
|
|
||||||
aPropSet[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
|
|
||||||
aPropSet[PKG_MNFST_ITERATION].Value <<= pStream->getIterationCount ();
|
|
||||||
|
|
||||||
// Need to store the uncompressed size in the manifest
|
|
||||||
OSL_ENSURE( nOwnStreamOrigSize >= 0, "The stream size was not correctly initialized!\n" );
|
|
||||||
aPropSet[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty;
|
|
||||||
aPropSet[PKG_MNFST_UCOMPSIZE].Value <<= nOwnStreamOrigSize;
|
|
||||||
|
|
||||||
if ( bRawStream || bTransportOwnEncrStreamAsRaw )
|
|
||||||
{
|
|
||||||
::rtl::Reference< EncryptionData > xEncData = pStream->GetEncryptionData();
|
|
||||||
if ( xEncData.is() )
|
|
||||||
{
|
|
||||||
aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
|
|
||||||
aPropSet[PKG_MNFST_DIGEST].Value <<= xEncData->m_aDigest;
|
|
||||||
aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
|
|
||||||
aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg;
|
|
||||||
aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
|
|
||||||
aPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID;
|
|
||||||
aPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty;
|
|
||||||
aPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg;
|
|
||||||
aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty;
|
|
||||||
aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the entry is already stored in the zip file in the format we
|
|
||||||
// want for this write...copy it raw
|
|
||||||
if ( !bUseNonSeekableAccess
|
|
||||||
&& ( bRawStream || bTransportOwnEncrStreamAsRaw
|
|
||||||
|| ( pStream->IsPackageMember() && !bToBeEncrypted
|
|
||||||
&& ( ( pStream->aEntry.nMethod == DEFLATED && bToBeCompressed )
|
|
||||||
|| ( pStream->aEntry.nMethod == STORED && !bToBeCompressed ) ) ) ) )
|
|
||||||
{
|
|
||||||
// If it's a PackageMember, then it's an unbuffered stream and we need
|
|
||||||
// to get a new version of it as we can't seek backwards.
|
|
||||||
if ( pStream->IsPackageMember() )
|
|
||||||
{
|
|
||||||
xStream = pStream->getRawData();
|
|
||||||
if ( !xStream.is() )
|
|
||||||
{
|
|
||||||
// Make sure that we actually _got_ a new one !
|
|
||||||
VOS_ENSURE( 0, "ZipPackageStream didn't have a stream associated with it, skipping!" );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ( bRawStream )
|
|
||||||
xStream->skipBytes( pStream->GetMagicalHackPos() );
|
|
||||||
|
|
||||||
rZipOut.putNextEntry( *pTempEntry, pStream, sal_False );
|
|
||||||
// the entry is provided to the ZipOutputStream that will delete it
|
|
||||||
pAutoTempEntry.release();
|
|
||||||
|
|
||||||
uno::Sequence < sal_Int8 > aSeq ( n_ConstBufferSize );
|
|
||||||
sal_Int32 nLength;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
nLength = xStream->readBytes( aSeq, n_ConstBufferSize );
|
|
||||||
rZipOut.rawWrite(aSeq, 0, nLength);
|
|
||||||
}
|
|
||||||
while ( nLength == n_ConstBufferSize );
|
|
||||||
|
|
||||||
rZipOut.rawCloseEntry();
|
|
||||||
}
|
|
||||||
catch ( ZipException& )
|
|
||||||
{
|
|
||||||
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
|
||||||
bWritingFailed = sal_True;
|
|
||||||
}
|
|
||||||
catch ( IOException& )
|
|
||||||
{
|
|
||||||
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
|
|
||||||
bWritingFailed = sal_True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// This stream is defenitly not a raw stream
|
|
||||||
|
|
||||||
// If nonseekable access is used the stream should be at the beginning and
|
|
||||||
// is useless after the storing. Thus if the storing fails the package should
|
|
||||||
// be thrown away ( as actually it is done currently )!
|
|
||||||
// To allow to reuse the package after the error, the optimization must be removed!
|
|
||||||
|
|
||||||
// If it's a PackageMember, then our previous reference held a 'raw' stream
|
|
||||||
// so we need to re-get it, unencrypted, uncompressed and positioned at the
|
|
||||||
// beginning of the stream
|
|
||||||
if ( pStream->IsPackageMember() )
|
|
||||||
{
|
|
||||||
xStream = pStream->getInputStream();
|
|
||||||
if ( !xStream.is() )
|
|
||||||
{
|
|
||||||
// Make sure that we actually _got_ a new one !
|
|
||||||
VOS_ENSURE( 0, "ZipPackageStream didn't have a stream associated with it, skipping!" );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( bToBeCompressed )
|
|
||||||
{
|
|
||||||
pTempEntry->nMethod = DEFLATED;
|
|
||||||
pTempEntry->nCrc = pTempEntry->nCompressedSize = pTempEntry->nSize = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
rZipOut.putNextEntry ( *pTempEntry, pStream, bToBeEncrypted);
|
|
||||||
// the entry is provided to the ZipOutputStream that will delete it
|
|
||||||
pAutoTempEntry.release();
|
|
||||||
|
|
||||||
sal_Int32 nLength;
|
|
||||||
uno::Sequence < sal_Int8 > aSeq (n_ConstBufferSize);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
nLength = xStream->readBytes(aSeq, n_ConstBufferSize);
|
|
||||||
rZipOut.write(aSeq, 0, nLength);
|
|
||||||
}
|
|
||||||
while ( nLength == n_ConstBufferSize );
|
|
||||||
|
|
||||||
rZipOut.closeEntry();
|
|
||||||
}
|
|
||||||
catch ( ZipException& )
|
|
||||||
{
|
|
||||||
bWritingFailed = sal_True;
|
|
||||||
}
|
|
||||||
catch ( IOException& )
|
|
||||||
{
|
|
||||||
bWritingFailed = sal_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( bToBeEncrypted )
|
|
||||||
{
|
|
||||||
::rtl::Reference< EncryptionData > xEncData = pStream->GetEncryptionData();
|
|
||||||
if ( xEncData.is() )
|
|
||||||
{
|
|
||||||
aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
|
|
||||||
aPropSet[PKG_MNFST_DIGEST].Value <<= xEncData->m_aDigest;
|
|
||||||
aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
|
|
||||||
aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg;
|
|
||||||
aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
|
|
||||||
aPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID;
|
|
||||||
aPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty;
|
|
||||||
aPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg;
|
|
||||||
aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty;
|
|
||||||
aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize;
|
|
||||||
|
|
||||||
pStream->SetIsEncrypted ( sal_True );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !bWritingFailed )
|
|
||||||
{
|
|
||||||
if ( !pStream->IsPackageMember() )
|
|
||||||
{
|
|
||||||
pStream->CloseOwnStreamIfAny();
|
|
||||||
pStream->SetPackageMember ( sal_True );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( bRawStream )
|
|
||||||
{
|
|
||||||
// the raw stream was integrated and now behaves
|
|
||||||
// as usual encrypted stream
|
|
||||||
pStream->SetToBeEncrypted( sal_True );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove hacky bit from entry flags
|
|
||||||
if ( pTempEntry->nFlag & ( 1 << 4 ) )
|
|
||||||
{
|
|
||||||
pTempEntry->nFlag &= ~( 1 << 4 );
|
|
||||||
pTempEntry->nMethod = STORED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then copy it back afterwards...
|
|
||||||
ZipPackageFolder::copyZipEntry ( pStream->aEntry, *pTempEntry );
|
|
||||||
|
|
||||||
// TODO/LATER: get rid of this hack ( the encrypted stream size property is changed during saving )
|
|
||||||
if ( pStream->IsEncrypted() )
|
|
||||||
pStream->setSize( nOwnStreamOrigSize );
|
|
||||||
|
|
||||||
pStream->aEntry.nOffset *= -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// folder can have a mediatype only in package format
|
|
||||||
if ( aPropSet.getLength()
|
|
||||||
&& ( m_nFormat == embed::StorageFormats::PACKAGE || ( m_nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) ) )
|
|
||||||
rManList.push_back( aPropSet );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( bWritingFailed )
|
if( bWritingFailed )
|
||||||
|
@ -36,6 +36,7 @@ fi 1252 1035
|
|||||||
fo 1252 1080 # Faroese
|
fo 1252 1080 # Faroese
|
||||||
fr 1252 1036
|
fr 1252 1036
|
||||||
fr-CA 1252 3084
|
fr-CA 1252 3084
|
||||||
|
fur 0 1585
|
||||||
ga 0 2108 # Irish
|
ga 0 2108 # Irish
|
||||||
gd 0 1084 # Gaelic (Scotland)
|
gd 0 1084 # Gaelic (Scotland)
|
||||||
gl 1252 1110 # Galician
|
gl 1252 1110 # Galician
|
||||||
@ -51,7 +52,9 @@ id 1252 1057 # Indonesian
|
|||||||
is 1252 1039 # Icelandic
|
is 1252 1039 # Icelandic
|
||||||
it 1252 1040
|
it 1252 1040
|
||||||
ja 932 1041
|
ja 932 1041
|
||||||
|
jbo 0 1624
|
||||||
ka 0 1079 # Georgian
|
ka 0 1079 # Georgian
|
||||||
|
kab 0 1625
|
||||||
kid 1252 1033 # key id pseudo language
|
kid 1252 1033 # key id pseudo language
|
||||||
kk 0 1087
|
kk 0 1087
|
||||||
km 0 1107 # Khmer
|
km 0 1107 # Khmer
|
||||||
@ -84,6 +87,8 @@ nn 1252 2068
|
|||||||
no 1252 1044
|
no 1252 1044
|
||||||
nr 0 1580 # Ndebele South
|
nr 0 1580 # Ndebele South
|
||||||
ns 0 1132 # Northern Sotho (Sepedi)
|
ns 0 1132 # Northern Sotho (Sepedi)
|
||||||
|
nso 0 1132
|
||||||
|
ny 0 1598
|
||||||
oc 1252 1154 # Occitan-lengadocian
|
oc 1252 1154 # Occitan-lengadocian
|
||||||
om 0 2162
|
om 0 2162
|
||||||
or 0 1096 # Oriya
|
or 0 1096 # Oriya
|
||||||
@ -116,6 +121,7 @@ st 0 1072 # Southern Sotho, Sutu
|
|||||||
sv 1252 1053
|
sv 1252 1053
|
||||||
sw 1252 1089 # Swahili
|
sw 1252 1089 # Swahili
|
||||||
sw-TZ 1252 1089 # Swahili
|
sw-TZ 1252 1089 # Swahili
|
||||||
|
so 0 1143
|
||||||
ta 0 1097 # Tamil
|
ta 0 1097 # Tamil
|
||||||
ta-IN 0 1097 # Tamil
|
ta-IN 0 1097 # Tamil
|
||||||
te 0 1098
|
te 0 1098
|
||||||
|
Loading…
x
Reference in New Issue
Block a user