diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-03-10 16:55:21 -0500 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-03-10 20:21:13 -0500 |
commit | 12343c15568dcc2c9209d8ca41fda2263122448f (patch) | |
tree | 3212a89c6cd8ea2e0aee7103aa9669bbb8a6f307 /sc/source/ui/unoobj/scdetect.cxx | |
parent | 99745dbcbb25b61437914c9782475d0b67a4b0bd (diff) | |
parent | ce6308e4fad2281241bf4ca78280eba29f744d43 (diff) |
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101
Diffstat (limited to 'sc/source/ui/unoobj/scdetect.cxx')
-rw-r--r-- | sc/source/ui/unoobj/scdetect.cxx | 122 |
1 files changed, 59 insertions, 63 deletions
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index faf3a7eb3d68..89a358ad1408 100644 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -125,7 +125,7 @@ static const sal_Char pFilterHtmlWeb[] = "calc_HTML_WebQuery"; static const sal_Char pFilterRtf[] = "Rich Text Format (StarCalc)"; -static BOOL lcl_MayBeAscii( SvStream& rStream ) +static sal_Bool lcl_MayBeAscii( SvStream& rStream ) { // ASCII/CSV is considered possible if there are no null bytes, or a Byte // Order Mark is present, or if, for Unicode UCS2/UTF-16, all null bytes @@ -136,12 +136,12 @@ static BOOL lcl_MayBeAscii( SvStream& rStream ) const size_t nBufSize = 2048; sal_uInt16 aBuffer[ nBufSize ]; sal_uInt8* pByte = reinterpret_cast<sal_uInt8*>(aBuffer); - ULONG nBytesRead = rStream.Read( pByte, nBufSize*2); + sal_uLong nBytesRead = rStream.Read( pByte, nBufSize*2); if ( nBytesRead >= 2 && (aBuffer[0] == 0xfffe || aBuffer[0] == 0xfeff) ) { // Unicode BOM file may contain null bytes. - return TRUE; + return sal_True; } const sal_uInt16* p = aBuffer; @@ -159,13 +159,13 @@ static BOOL lcl_MayBeAscii( SvStream& rStream ) return nMask != 0; } -static BOOL lcl_MayBeDBase( SvStream& rStream ) +static sal_Bool lcl_MayBeDBase( SvStream& rStream ) { // Look for dbf marker, see connectivity/source/inc/dbase/DTable.hxx // DBFType for values. - const BYTE nValidMarks[] = { + const sal_uInt8 nValidMarks[] = { 0x03, 0x04, 0x05, 0x30, 0x43, 0xB3, 0x83, 0x8b, 0x8e, 0xf5 }; - BYTE nMark; + sal_uInt8 nMark; rStream.Seek(STREAM_SEEK_TO_BEGIN); rStream >> nMark; bool bValidMark = false; @@ -175,24 +175,24 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) bValidMark = true; } if ( !bValidMark ) - return FALSE; + return false; const size_t nHeaderBlockSize = 32; // Empty dbf is >= 32*2+1 bytes in size. const size_t nEmptyDbf = nHeaderBlockSize * 2 + 1; rStream.Seek(STREAM_SEEK_TO_END); - ULONG nSize = rStream.Tell(); + sal_uLong nSize = rStream.Tell(); if ( nSize < nEmptyDbf ) - return FALSE; + return false; // length of header starts at 8 rStream.Seek(8); - USHORT nHeaderLen; + sal_uInt16 nHeaderLen; rStream >> nHeaderLen; if ( nHeaderLen < nEmptyDbf || nSize < nHeaderLen ) - return FALSE; + return false; // Last byte of header must be 0x0d, this is how it's specified. // #i9581#,#i26407# but some applications don't follow the specification @@ -200,8 +200,8 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) // even boundary. Some (#i88577# ) even pad more or pad using a 0x1a ^Z // control character (#i8857#). This results in: // Last byte of header must be 0x0d on 32 bytes boundary. - USHORT nBlocks = (nHeaderLen - 1) / nHeaderBlockSize; - BYTE nEndFlag = 0; + sal_uInt16 nBlocks = (nHeaderLen - 1) / nHeaderBlockSize; + sal_uInt8 nEndFlag = 0; while ( nBlocks > 1 && nEndFlag != 0x0d ) { rStream.Seek( nBlocks-- * nHeaderBlockSize ); rStream >> nEndFlag; @@ -225,11 +225,11 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) // opening as template is done when a parameter tells to do so and a template filter can be detected // (otherwise no valid filter would be found) or if the detected filter is a template filter and // there is no parameter that forbids to open as template - sal_Bool bOpenAsTemplate = sal_False; - sal_Bool bWasReadOnly = sal_False, bReadOnly = sal_False; + sal_Bool bOpenAsTemplate = false; + sal_Bool bWasReadOnly = false, bReadOnly = false; - sal_Bool bRepairPackage = sal_False; - sal_Bool bRepairAllowed = sal_False; + sal_Bool bRepairPackage = false; + sal_Bool bRepairAllowed = false; // now some parameters that can already be in the array, but may be overwritten or new inserted here // remember their indices in the case new values must be added to the array @@ -294,7 +294,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) SfxAllItemSet *pSet = new SfxAllItemSet( SFX_APP()->GetPool() ); TransformParameters( SID_OPENDOC, lDescriptor, *pSet ); - SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, SID_DOC_READONLY, FALSE ); + SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, SID_DOC_READONLY, false ); bWasReadOnly = pItem && pItem->GetValue(); @@ -317,10 +317,10 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) pFilter = aMatcher.GetFilter4EA( aTypeName ); // ctor of SfxMedium uses owner transition of ItemSet - SfxMedium aMedium( aURL, bWasReadOnly ? STREAM_STD_READ : STREAM_STD_READWRITE, FALSE, NULL, pSet ); - aMedium.UseInteractionHandler( TRUE ); + SfxMedium aMedium( aURL, bWasReadOnly ? STREAM_STD_READ : STREAM_STD_READWRITE, false, NULL, pSet ); + aMedium.UseInteractionHandler( sal_True ); - BOOL bIsStorage = aMedium.IsStorage(); + sal_Bool bIsStorage = aMedium.IsStorage(); if ( aMedium.GetErrorCode() == ERRCODE_NONE ) { // remember input stream and content and put them into the descriptor later @@ -332,7 +332,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) // maybe that IsStorage() already created an error! if ( bIsStorage ) { - uno::Reference < embed::XStorage > xStorage(aMedium.GetStorage( sal_False )); + uno::Reference < embed::XStorage > xStorage(aMedium.GetStorage( false )); if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE ) { // error during storage creation means _here_ that the medium @@ -364,7 +364,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) String aFilterName; if ( pFilter ) aFilterName = pFilter->GetName(); - aTypeName = SfxFilter::GetTypeFromStorage( xStorage, pFilter ? pFilter->IsOwnTemplateFormat() : FALSE, &aFilterName ); + aTypeName = SfxFilter::GetTypeFromStorage( xStorage, pFilter ? pFilter->IsOwnTemplateFormat() : false, &aFilterName ); } catch( lang::WrappedTargetException& aWrap ) { @@ -384,20 +384,16 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) if ( !bRepairPackage ) { // ask the user whether he wants to try to repair - RequestPackageReparation* pRequest = new RequestPackageReparation( aDocumentTitle ); - uno::Reference< task::XInteractionRequest > xRequest ( pRequest ); - - xInteraction->handle( xRequest ); - - bRepairAllowed = pRequest->isApproved(); + RequestPackageReparation aRequest( aDocumentTitle ); + xInteraction->handle( aRequest.GetRequest() ); + bRepairAllowed = aRequest.isApproved(); } if ( !bRepairAllowed ) { // repair either not allowed or not successful - NotifyBrokenPackage* pNotifyRequest = new NotifyBrokenPackage( aDocumentTitle ); - uno::Reference< task::XInteractionRequest > xRequest ( pNotifyRequest ); - xInteraction->handle( xRequest ); + NotifyBrokenPackage aNotifyRequest( aDocumentTitle ); + xInteraction->handle( aNotifyRequest.GetRequest() ); } } @@ -430,22 +426,22 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) pFilter = 0; if ( pStream ) { - SotStorageRef aStorage = new SotStorage ( pStream, FALSE ); + SotStorageRef aStorage = new SotStorage ( pStream, false ); if ( !aStorage->GetError() ) { // Excel-5: detect through contained streams // there are some "excel" formats from 3rd party vendors that need to be distinguished String aStreamName(RTL_CONSTASCII_USTRINGPARAM("Workbook")); - BOOL bExcel97Stream = ( aStorage->IsStream( aStreamName ) ); + sal_Bool bExcel97Stream = ( aStorage->IsStream( aStreamName ) ); aStreamName = String(RTL_CONSTASCII_USTRINGPARAM("Book")); - BOOL bExcel5Stream = ( aStorage->IsStream( aStreamName ) ); + sal_Bool bExcel5Stream = ( aStorage->IsStream( aStreamName ) ); if ( bExcel97Stream || bExcel5Stream ) { if ( bExcel97Stream ) { String aOldName; - BOOL bIsCalcFilter = TRUE; + sal_Bool bIsCalcFilter = sal_True; if ( pPreselectedFilter ) { // cross filter; now this should be a type detection only, not a filter detection @@ -474,7 +470,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) else if ( bExcel5Stream ) { String aOldName; - BOOL bIsCalcFilter = TRUE; + sal_Bool bIsCalcFilter = sal_True; if ( pPreselectedFilter ) { // cross filter; now this should be a type detection only, not a filter detection @@ -518,18 +514,18 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) #define M_ALT(ANZ) (0x0200+(ANZ)) #define M_ENDE 0x8000 - static const UINT16 pLotus[] = // Lotus 1/1A/2 + static const sal_uInt16 pLotus[] = // Lotus 1/1A/2 { 0x0000, 0x0000, 0x0002, 0x0000, M_ALT(2), 0x0004, 0x0006, 0x0004, M_ENDE }; - static const UINT16 pLotusNew[] = // Lotus >= 9.7 + static const sal_uInt16 pLotusNew[] = // Lotus >= 9.7 { 0x0000, 0x0000, M_DC, 0x0000, // Rec# + Len (0x1a) M_ALT(3), 0x0003, 0x0004, 0x0005, // File Revision Code 97->ME 0x0010, 0x0004, 0x0000, 0x0000, M_ENDE }; - static const UINT16 pExcel1[] = // Excel BIFF2, BIFF3, BIFF4 + static const sal_uInt16 pExcel1[] = // Excel BIFF2, BIFF3, BIFF4 { 0x09, // lobyte of BOF rec ID (0x0009, 0x0209, 0x0409) M_ALT(3), 0x00, 0x02, 0x04, // hibyte of BOF rec ID (0x0009, 0x0209, 0x0409) M_ALT(3), 4, 6, 8, // lobyte of BOF rec size (4, 6, 8, 16) @@ -539,7 +535,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) 0x00, // hibyte of data type (0x0010, 0x0020, 0x0040) M_ENDE }; - static const UINT16 pExcel2[] = // Excel BIFF4 Workspace + static const sal_uInt16 pExcel2[] = // Excel BIFF4 Workspace { 0x09, // lobyte of BOF rec ID (0x0409) 0x04, // hibyte of BOF rec ID (0x0409) M_ALT(3), 4, 6, 8, // lobyte of BOF rec size (4, 6, 8, 16) @@ -549,7 +545,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) 0x01, // hibyte of data type (0x0100) M_ENDE }; - static const UINT16 pExcel3[] = // #i23425# Excel BIFF5, BIFF7, BIFF8 (simple book stream) + static const sal_uInt16 pExcel3[] = // #i23425# Excel BIFF5, BIFF7, BIFF8 (simple book stream) { 0x09, // lobyte of BOF rec ID (0x0809) 0x08, // hibyte of BOF rec ID (0x0809) M_ALT(4), 4, 6, 8, 16, // lobyte of BOF rec size @@ -559,7 +555,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) 0x00, // hibyte of data type M_ENDE }; - static const UINT16 pSc10[] = // StarCalc 1.0 Dokumente + static const sal_uInt16 pSc10[] = // StarCalc 1.0 Dokumente { 'B', 'l', 'a', 'i', 's', 'e', '-', 'T', 'a', 'b', 'e', 'l', 'l', 'e', 0x000A, 0x000D, 0x0000, // Sc10CopyRight[16] M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, @@ -568,21 +564,21 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) 0x0000, M_ENDE }; - static const UINT16 pLotus2[] = // Lotus >3 + static const sal_uInt16 pLotus2[] = // Lotus >3 { 0x0000, 0x0000, 0x001A, 0x0000, // Rec# + Len (26) M_ALT(2), 0x0000, 0x0002, // File Revision Code 0x0010, 0x0004, 0x0000, // File Revision Subcode M_ENDE }; - static const UINT16 pQPro[] = + static const sal_uInt16 pQPro[] = { 0x0000, 0x0000, 0x0002, 0x0000, M_ALT(4), 0x0001, 0x0002, // WB1, WB2 0x0006, 0x0007, // QPro 6/7 (?) 0x0010, M_ENDE }; - static const UINT16 pDIF1[] = // DIF mit CR-LF + static const sal_uInt16 pDIF1[] = // DIF mit CR-LF { 'T', 'A', 'B', 'L', 'E', M_DC, M_DC, @@ -591,7 +587,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) '\"', M_ENDE }; - static const UINT16 pDIF2[] = // DIF mit CR oder LF + static const sal_uInt16 pDIF2[] = // DIF mit CR oder LF { 'T', 'A', 'B', 'L', 'E', M_DC, @@ -600,13 +596,13 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) '\"', M_ENDE }; - static const UINT16 pSylk[] = // Sylk + static const sal_uInt16 pSylk[] = // Sylk { 'I', 'D', ';', M_ALT(3), 'P', 'N', 'E', // 'P' plus undocumented Excel extensions 'N' and 'E' M_ENDE }; - static const UINT16 *ppFilterPatterns[] = // Arrays mit Suchmustern + static const sal_uInt16 *ppFilterPatterns[] = // Arrays mit Suchmustern { pLotus, pExcel1, @@ -640,38 +636,38 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) // suchen Sie jetzt! // ... realisiert ueber 'Mustererkennung' - BYTE nAkt; - BOOL bSync; // Datei und Muster stimmen ueberein - USHORT nFilter; // Zaehler ueber alle Filter - const UINT16 *pSearch; // aktuelles Musterwort + sal_uInt8 nAkt; + sal_Bool bSync; // Datei und Muster stimmen ueberein + sal_uInt16 nFilter; // Zaehler ueber alle Filter + const sal_uInt16 *pSearch; // aktuelles Musterwort for ( nFilter = 0 ; nFilter < nFilterCount ; nFilter++ ) { rStr.Seek( 0 ); // am Anfang war alles Uebel... rStr >> nAkt; pSearch = ppFilterPatterns[ nFilter ]; - bSync = TRUE; + bSync = sal_True; while( !rStr.IsEof() && bSync ) { - register UINT16 nMuster = *pSearch; + register sal_uInt16 nMuster = *pSearch; if( nMuster < 0x0100 ) { // direkter Byte-Vergleich - if( ( BYTE ) nMuster != nAkt ) - bSync = FALSE; + if( ( sal_uInt8 ) nMuster != nAkt ) + bSync = false; } else if( nMuster & M_DC ) { // don't care } else if( nMuster & M_ALT(0) ) { // alternative Bytes - BYTE nAnzAlt = ( BYTE ) nMuster; - bSync = FALSE; // zunaechst unsynchron + sal_uInt8 nAnzAlt = ( sal_uInt8 ) nMuster; + bSync = false; // zunaechst unsynchron while( nAnzAlt > 0 ) { pSearch++; - if( ( BYTE ) *pSearch == nAkt ) - bSync = TRUE; // jetzt erst Synchronisierung + if( ( sal_uInt8 ) *pSearch == nAkt ) + bSync = sal_True; // jetzt erst Synchronisierung nAnzAlt--; } } @@ -687,7 +683,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream ) { // gefundenen Filter einstellen pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterName[ nFilter ]) ); } - bSync = FALSE; // leave inner loop + bSync = false; // leave inner loop nFilter = nFilterCount; // leave outer loop } else @@ -868,7 +864,7 @@ sal_Bool SAL_CALL ScFilterDetect::supportsService( const UNOOUSTRING& sServiceNa return sal_True ; } } - return sal_False ; + return false ; } /* XServiceInfo */ |