diff options
Diffstat (limited to 'editeng/source/rtf/rtfgrf.cxx')
-rw-r--r-- | editeng/source/rtf/rtfgrf.cxx | 123 |
1 files changed, 38 insertions, 85 deletions
diff --git a/editeng/source/rtf/rtfgrf.cxx b/editeng/source/rtf/rtfgrf.cxx index b7f1162aba..6c9d9b18bb 100644 --- a/editeng/source/rtf/rtfgrf.cxx +++ b/editeng/source/rtf/rtfgrf.cxx @@ -41,44 +41,12 @@ using namespace ::rtl; -#ifndef DBG_UTIL -#undef DEBUG_JP -#endif - -#ifdef DEBUG_JP - -#include <tools/fsys.hxx> - -class GrfWindow : public WorkWindow -{ - Graphic aGrf; -public: - GrfWindow( const Graphic& rGrf ); - virtual void Paint( const Rectangle& rRect ); -}; - -GrfWindow::GrfWindow( const Graphic& rGrf ) - : WorkWindow( NULL ), - aGrf( rGrf ) -{ - SetPosSizePixel( Point( 100, 0 ), Size( 300, 300 )); - Show(); - Invalidate(); - Update(); -} - -void GrfWindow::Paint( const Rectangle& ) -{ - aGrf.Draw( this, Point(0,0), GetSizePixel() ); -} -#endif - -static BYTE __FAR_DATA aPal1[ 2 * 4 ] = { - 0x00, 0x00, 0x00, 0x00, // Schwarz - 0xFF, 0xFF, 0xFF, 0x00 // Weiss +static sal_uInt8 aPal1[ 2 * 4 ] = { + 0x00, 0x00, 0x00, 0x00, // Black + 0xFF, 0xFF, 0xFF, 0x00 // White }; -static BYTE __FAR_DATA aPal4[ 16 * 4 ] = { +static sal_uInt8 aPal4[ 16 * 4 ] = { 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, @@ -97,7 +65,7 @@ static BYTE __FAR_DATA aPal4[ 16 * 4 ] = { 0xFF, 0xFF, 0xFF, 0x00 }; -static BYTE __FAR_DATA aPal8[ 256 * 4 ] = +static sal_uInt8 aPal8[ 256 * 4 ] = { 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x80, 0x92, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x00, 0x80, 0x00, 0xAA, 0x00, @@ -213,14 +181,14 @@ inline short SwapShort( short n ) static void WriteBMPHeader( SvStream& rStream, const SvxRTFPictureType& rPicType ) { - ULONG n4Width = rPicType.nWidth; - ULONG n4Height = rPicType.nHeight; - USHORT n4ColBits = rPicType.nBitsPerPixel; + sal_uInt32 n4Width = rPicType.nWidth; + sal_uInt32 n4Height = rPicType.nHeight; + sal_uInt16 n4ColBits = rPicType.nBitsPerPixel; - USHORT nColors = (1 << n4ColBits); // Anzahl der Farben ( 1, 16, 256 ) - USHORT nWdtOut = rPicType.nWidthBytes; + sal_uInt16 nColors = (1 << n4ColBits); // Number of colors (1, 16, 256) + sal_uInt16 nWdtOut = rPicType.nWidthBytes; if( !nWdtOut ) - nWdtOut = (USHORT)((( n4Width * n4ColBits + 31 ) / 32 ) * 4 ); + nWdtOut = (sal_uInt16)((( n4Width * n4ColBits + 31 ) / 32 ) * 4 ); long nOffset = 14 + 40; // BMP_FILE_HD_SIZ + sizeof(*pBmpInfo); if( 256 >= nColors ) @@ -228,14 +196,14 @@ static void WriteBMPHeader( SvStream& rStream, long nSize = nOffset + nWdtOut * n4Height; rStream << "BM" // = "BM" << SwapLong(nSize) // Filesize in Bytes - << SwapShort(0) // Reserviert - << SwapShort(0) // Reserviert + << SwapShort(0) // Reserved + << SwapShort(0) // Reserved << SwapLong(nOffset); // Offset? rStream << SwapLong(40) // sizeof( BmpInfo ) << SwapLong(n4Width) << SwapLong(n4Height) - << (USHORT)1 + << (sal_uInt16)1 << n4ColBits << SwapLong(0) << SwapLong(0) @@ -257,21 +225,19 @@ static void WriteBMPHeader( SvStream& rStream, } } -/* */ - - // wandel die ASCII-HexCodes in binaere Zeichen um. Werden - // ungueltige Daten gefunden (Zeichen ausser 0-9|a-f|A-F, so - // wird USHRT_MAX returnt, ansonsten die Anzahl der umgewandelten Ze. + // Converts the ASCII characters to hexadecimal codes in binary. + // If invalid data is found (eg. characters outside 0-9|a-f|A-F), then + // USHRT_MAX is returned, else the number of converted charachters. xub_StrLen SvxRTFParser::HexToBin( String& rToken ) { - // dann mache aus den Hex-Werten mal "Binare Daten" - // (missbrauche den String als temp Buffer) - if( rToken.Len() & 1 ) // ungerade Anzahl, mit 0 auffuellen + // then create "Binary data" from the hex values. + // (missuse the String as temp Buffer) + if( rToken.Len() & 1 ) // odd number, fill out with 0 rToken += '0'; xub_StrLen n, nLen; sal_Unicode nVal; - BOOL bValidData = TRUE; + sal_Bool bValidData = sal_True; const sal_Unicode* pStr = rToken.GetBufferAccess(); sal_Char* pData = (sal_Char*)pStr; for( n = 0, nLen = rToken.Len(); n < nLen; ++n, ++pStr ) @@ -284,8 +250,8 @@ xub_StrLen SvxRTFParser::HexToBin( String& rToken ) nVal -= 'a' - 10; else { - DBG_ASSERT( !this, "ungueltiger Hex-Wert" ); - bValidData = FALSE; + DBG_ASSERT( !this, "invalid Hex value" ); + bValidData = sal_False; break; } @@ -298,11 +264,10 @@ xub_StrLen SvxRTFParser::HexToBin( String& rToken ) return bValidData ? nLen / 2 : STRING_NOTFOUND; } -BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) +sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) { - // die alten Daten loeschen + // Delete the old data rGrf.Clear(); -// ULONG nBmpSize = 0; rtl_TextEncoding eOldEnc = GetSrcEncoding(); SetSrcEncoding( RTL_TEXTENCODING_MS_1252 ); @@ -312,7 +277,7 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) int nToken = 0; bool bValidBmp = true, bFirstTextToken = true; - int _nOpenBrakets = 1, // die erste wurde schon vorher erkannt !! + int _nOpenBrakets = 1, // the first was already recognized before! nValidDataBraket = 1; if( RTF_SHPPICT == GetStackPtr(0)->nTokenId ) @@ -322,7 +287,7 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) while( _nOpenBrakets && IsParserWorking() && bValidBmp ) { nToken = GetNextToken(); - USHORT nVal = USHORT( nTokenValue ); + sal_uInt16 nVal = sal_uInt16( nTokenValue ); switch( nToken ) { case '}': @@ -359,7 +324,7 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) case RTF_MACPICT: { rPicType.eStyle = SvxRTFPictureType::MAC_QUICKDRAW; - // Mac-Pict bekommt einen leeren Header voran + // Mac-Pict gets a empty header above pTmpFile = new SvCacheStream; ByteString aStr; aStr.Fill( 512, '\0' ); @@ -423,11 +388,9 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) rPicType.uPicLen = nTokenValue; if (rPicType.uPicLen) { - ULONG nPos = rStrm.Tell(); - nPos = nPos; rStrm.SeekRel(-1); sal_uInt8 aData[4096]; - ULONG nSize = sizeof(aData); + sal_uInt32 nSize = sizeof(aData); while (rPicType.uPicLen > 0) { @@ -440,8 +403,6 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) } nNextCh = GetNextChar(); bValidBmp = !pTmpFile->GetError(); - nPos = rStrm.Tell(); - nPos = nPos; } break; case RTF_PICSCALEX: rPicType.nScalX = nVal; break; @@ -471,9 +432,6 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) nToken = SkipToken( -1 ); break; case RTF_TEXTTOKEN: - // JP 26.06.98: Bug #51719# - nur TextToken auf 1. Ebene - // auswerten. Alle anderen sind irgendwelche - // nicht auszuwertende Daten if( nValidDataBraket != _nOpenBrakets ) break; @@ -482,21 +440,21 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) switch( rPicType.eStyle ) { case SvxRTFPictureType::RTF_BITMAP: - // erstmal die Header und Info-Struktur schreiben + // first write the header and the info structure if( pTmpFile ) ::WriteBMPHeader( *pTmpFile, rPicType ); break; default: break; } - bFirstTextToken = FALSE; + bFirstTextToken = sal_False; } if( pTmpFile && SvxRTFPictureType::HEX_MODE == rPicType.nMode ) { xub_StrLen nTokenLen = HexToBin( aToken ); if( STRING_NOTFOUND == nTokenLen ) - bValidBmp = FALSE; + bValidBmp = sal_False; else { pTmpFile->Write( (sal_Char*)aToken.GetBuffer(), @@ -517,12 +475,12 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) if( bValidBmp ) { GraphicFilter* pGF = GraphicFilter::GetGraphicFilter(); - USHORT nImportFilter = GRFILTER_FORMAT_DONTKNOW; + sal_uInt16 nImportFilter = GRFILTER_FORMAT_DONTKNOW; if( pFilterNm ) { String sTmp; - for( USHORT n = pGF->GetImportFormatCount(); n; ) + for( sal_uInt16 n = pGF->GetImportFormatCount(); n; ) { sTmp = pGF->GetImportFormatShortName( --n ); if( sTmp.EqualsAscii( pFilterNm )) @@ -544,7 +502,7 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) if( !bValidBmp ) { rGrf.Clear(); - //TODO If nToken were not initialized to 0 above, it would potentially + // TODO: If nToken were not initialized to 0 above, it would potentially // be used uninitialized here (if IsParserWorking() is false at the // start of the while loop above): if( '}' != nToken ) @@ -554,7 +512,6 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) { switch( rPicType.eStyle ) { -//?? ENHANCED_MF, // in den Pict.Daten steht ein Enhanced-Metafile case SvxRTFPictureType::RTF_PNG: case SvxRTFPictureType::RTF_JPG: { @@ -566,22 +523,18 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) else aSize = OutputDevice::LogicToLogic( aSize, rGrf.GetPrefMapMode(), aMap ); - rPicType.nWidth = sal::static_int_cast< USHORT >(aSize.Width()); - rPicType.nHeight = sal::static_int_cast< USHORT >( + rPicType.nWidth = sal::static_int_cast< sal_uInt16 >(aSize.Width()); + rPicType.nHeight = sal::static_int_cast< sal_uInt16 >( aSize.Height()); } break; default: break; } - -#ifdef DEBUG_JP - new GrfWindow( rGrf ); -#endif } SetSrcEncoding( eOldEnc ); - SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet + SkipToken( -1 ); // the closing brace is evaluated "above" return bValidBmp; } |