CWS-TOOLING: integrate CWS fwk123
2009-10-14 10:18:49 +0200 cd r276885 : #i99971# Use AttachThreadInput to force SetForegroundWindow 2009-10-14 08:56:20 +0200 mav r276881 : #i105476# let the allocated memory live long anough 2009-10-14 08:53:51 +0200 mav r276880 : #i105476# let ZipFile use mutex while creating the requested stream 2009-10-14 08:51:52 +0200 mav r276879 : #i105476# let buffered IO use mutex ( patch from MHU ) 2009-10-09 12:20:22 +0200 cd r276803 : #i99971# Use configuration to control window to front/focus handling 2009-10-09 12:19:22 +0200 cd r276802 : #i99971# New configuration item to force set focus and window to front for new document windows 2009-10-09 12:18:23 +0200 cd r276801 : #i99971# Introduction of a new show flag to force window to front 2009-10-06 11:04:16 +0200 ab r276695 : #i105386# Call xmlInitParser() before registering input callbacks
This commit is contained in:
@@ -38,12 +38,16 @@
|
||||
#include <com/sun/star/uno/RuntimeException.hpp>
|
||||
#include <com/sun/star/lang/IllegalArgumentException.hpp>
|
||||
|
||||
#include <osl/mutex.hxx>
|
||||
|
||||
namespace com { namespace sun { namespace star {
|
||||
namespace io { class XSeekable; class XInputStream; }
|
||||
} } }
|
||||
class ByteGrabber
|
||||
{
|
||||
protected:
|
||||
::osl::Mutex m_aMutex;
|
||||
|
||||
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
|
||||
com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
|
||||
com::sun::star::uno::Sequence < sal_Int8 > aSequence;
|
||||
|
@@ -65,6 +65,8 @@ class EncryptionData;
|
||||
class ZipFile
|
||||
{
|
||||
protected:
|
||||
::osl::Mutex m_aMutex;
|
||||
|
||||
::rtl::OUString sComment; /* zip file comment */
|
||||
EntryHash aEntries;
|
||||
ByteGrabber aGrabber;
|
||||
|
@@ -51,8 +51,10 @@ ByteGrabber::ByteGrabber(uno::Reference < io::XInputStream > xIstream)
|
||||
ByteGrabber::~ByteGrabber()
|
||||
{
|
||||
}
|
||||
|
||||
void ByteGrabber::setInputStream (uno::Reference < io::XInputStream > xNewStream)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
xStream = xNewStream;
|
||||
xSeek = uno::Reference < io::XSeekable > (xNewStream, uno::UNO_QUERY);
|
||||
}
|
||||
@@ -62,6 +64,7 @@ sal_Int32 SAL_CALL ByteGrabber::readBytes( uno::Sequence< sal_Int8 >& aData,
|
||||
sal_Int32 nBytesToRead )
|
||||
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
return xStream->readBytes(aData, nBytesToRead );
|
||||
}
|
||||
|
||||
@@ -69,6 +72,7 @@ sal_Int32 SAL_CALL ByteGrabber::readBytes( uno::Sequence< sal_Int8 >& aData,
|
||||
sal_Int64 SAL_CALL ByteGrabber::seek( sal_Int64 location )
|
||||
throw(lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
if (xSeek.is() )
|
||||
{
|
||||
sal_Int64 nLen = xSeek->getLength();
|
||||
@@ -82,32 +86,40 @@ sal_Int64 SAL_CALL ByteGrabber::seek( sal_Int64 location )
|
||||
else
|
||||
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
|
||||
}
|
||||
|
||||
sal_Int64 SAL_CALL ByteGrabber::getPosition( )
|
||||
throw(io::IOException, uno::RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
if (xSeek.is() )
|
||||
return xSeek->getPosition();
|
||||
else
|
||||
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
|
||||
}
|
||||
|
||||
sal_Int64 SAL_CALL ByteGrabber::getLength( )
|
||||
throw(io::IOException, uno::RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
if (xSeek.is() )
|
||||
return xSeek->getLength();
|
||||
else
|
||||
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
|
||||
}
|
||||
|
||||
ByteGrabber& ByteGrabber::operator >> (sal_Int8& rInt8)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
if (xStream->readBytes(aSequence,1) != 1)
|
||||
rInt8 = 0;
|
||||
else
|
||||
rInt8 = aSequence[0] & 0xFF;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteGrabber& ByteGrabber::operator >> (sal_Int16& rInt16)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
if (xStream->readBytes ( aSequence, 2) != 2)
|
||||
rInt16 = 0;
|
||||
else
|
||||
@@ -119,8 +131,11 @@ ByteGrabber& ByteGrabber::operator >> (sal_Int16& rInt16)
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteGrabber& ByteGrabber::operator >> (sal_Int32& rInt32)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
if (xStream->readBytes(aSequence, 4) != 4)
|
||||
rInt32 = 0;
|
||||
else
|
||||
@@ -137,6 +152,8 @@ ByteGrabber& ByteGrabber::operator >> (sal_Int32& rInt32)
|
||||
|
||||
ByteGrabber& ByteGrabber::operator >> (sal_uInt8& rInt8)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
if (xStream->readBytes(aSequence,1) != 1)
|
||||
rInt8 = 0;
|
||||
else
|
||||
@@ -145,6 +162,8 @@ ByteGrabber& ByteGrabber::operator >> (sal_uInt8& rInt8)
|
||||
}
|
||||
ByteGrabber& ByteGrabber::operator >> (sal_uInt16& rInt16)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
if (xStream->readBytes(aSequence, 2) != 2)
|
||||
rInt16 = 0;
|
||||
else
|
||||
@@ -158,6 +177,8 @@ ByteGrabber& ByteGrabber::operator >> (sal_uInt16& rInt16)
|
||||
}
|
||||
ByteGrabber& ByteGrabber::operator >> (sal_uInt32& ruInt32)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
if (xStream->readBytes(aSequence, 4) != 4)
|
||||
ruInt32 = 0;
|
||||
else
|
||||
|
@@ -122,6 +122,8 @@ ZipFile::~ZipFile()
|
||||
|
||||
void ZipFile::setInputStream ( Reference < XInputStream > xNewStream )
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
xStream = xNewStream;
|
||||
xSeek = Reference < XSeekable > ( xStream, UNO_QUERY );
|
||||
aGrabber.setInputStream ( xStream );
|
||||
@@ -381,6 +383,8 @@ sal_Bool ZipFile::StaticHasValidPassword( const Sequence< sal_Int8 > &aReadBuffe
|
||||
|
||||
sal_Bool ZipFile::hasValidPassword ( ZipEntry & rEntry, const ORef < EncryptionData > &rData )
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
sal_Bool bRet = sal_False;
|
||||
if ( rData->aKey.getLength() )
|
||||
{
|
||||
@@ -499,6 +503,8 @@ Reference < XInputStream > ZipFile::createUnbufferedStream(
|
||||
sal_Bool bIsEncrypted,
|
||||
::rtl::OUString aMediaType )
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
return new XUnbufferedStream ( aMutexHolder, rEntry, xStream, rData, nStreamMode, bIsEncrypted, aMediaType, bRecoveryMode );
|
||||
}
|
||||
|
||||
@@ -514,6 +520,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
|
||||
SotMutexHolderRef aMutexHolder )
|
||||
throw(IOException, ZipException, RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
if ( rEntry.nOffset <= 0 )
|
||||
readLOC( rEntry );
|
||||
|
||||
@@ -543,6 +551,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry,
|
||||
ZipException,
|
||||
RuntimeException )
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
if ( rEntry.nOffset <= 0 )
|
||||
readLOC( rEntry );
|
||||
|
||||
@@ -579,6 +589,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getRawData( ZipEntry& rEntry,
|
||||
SotMutexHolderRef aMutexHolder )
|
||||
throw(IOException, ZipException, RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
if ( rEntry.nOffset <= 0 )
|
||||
readLOC( rEntry );
|
||||
|
||||
@@ -595,6 +607,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getWrappedRawStream(
|
||||
ZipException,
|
||||
RuntimeException )
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
if ( rData.isEmpty() )
|
||||
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
|
||||
|
||||
@@ -607,6 +621,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getWrappedRawStream(
|
||||
sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
|
||||
throw(IOException, ZipException, RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
sal_Int32 nTestSig, nTime, nCRC, nSize, nCompressedSize;
|
||||
sal_Int16 nVersion, nFlag, nHow, nPathLen, nExtraLen;
|
||||
sal_Int32 nPos = -rEntry.nOffset;
|
||||
@@ -660,6 +676,7 @@ sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
|
||||
sal_Int32 ZipFile::findEND( )
|
||||
throw(IOException, ZipException, RuntimeException)
|
||||
{
|
||||
// this method is called in constructor only, no need for mutex
|
||||
sal_Int32 nLength, nPos, nEnd;
|
||||
Sequence < sal_Int8 > aBuffer;
|
||||
try
|
||||
@@ -701,6 +718,7 @@ sal_Int32 ZipFile::findEND( )
|
||||
sal_Int32 ZipFile::readCEN()
|
||||
throw(IOException, ZipException, RuntimeException)
|
||||
{
|
||||
// this method is called in constructor only, no need for mutex
|
||||
sal_Int32 nCenLen, nCenPos = -1, nCenOff, nEndPos, nLocPos;
|
||||
sal_uInt16 nCount, nTotal;
|
||||
|
||||
@@ -807,6 +825,8 @@ sal_Int32 ZipFile::readCEN()
|
||||
sal_Int32 ZipFile::recover()
|
||||
throw(IOException, ZipException, RuntimeException)
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
sal_Int32 nLength;
|
||||
Sequence < sal_Int8 > aBuffer;
|
||||
Sequence < sal_Int32 > aHeaderOffsets;
|
||||
@@ -974,6 +994,8 @@ sal_Int32 ZipFile::recover()
|
||||
|
||||
sal_Bool ZipFile::checkSizeAndCRC( const ZipEntry& aEntry )
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
sal_Int32 nSize = 0, nCRC = 0;
|
||||
|
||||
if( aEntry.nMethod == STORED )
|
||||
@@ -985,6 +1007,8 @@ sal_Bool ZipFile::checkSizeAndCRC( const ZipEntry& aEntry )
|
||||
|
||||
sal_Int32 ZipFile::getCRC( sal_Int32 nOffset, sal_Int32 nSize )
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
Sequence < sal_Int8 > aBuffer;
|
||||
CRC32 aCRC;
|
||||
sal_Int32 nBlockSize = ::std::min( nSize, static_cast< sal_Int32 >( 32000 ) );
|
||||
@@ -1002,6 +1026,8 @@ sal_Int32 ZipFile::getCRC( sal_Int32 nOffset, sal_Int32 nSize )
|
||||
|
||||
void ZipFile::getSizeAndCRC( sal_Int32 nOffset, sal_Int32 nCompressedSize, sal_Int32 *nSize, sal_Int32 *nCRC )
|
||||
{
|
||||
::osl::MutexGuard aGuard( m_aMutex );
|
||||
|
||||
Sequence < sal_Int8 > aBuffer;
|
||||
CRC32 aCRC;
|
||||
sal_Int32 nRealSize = 0;
|
||||
|
Reference in New Issue
Block a user