diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 12:24:29 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 12:24:29 +0200 |
commit | 92667c8edbaee9a252b1d5d221eb62849f76697c (patch) | |
tree | 8f1d329f2259b7d5bff054bc14d0965637df6961 /editeng/source/rtf | |
parent | baecdfb578cb7bc992944857ad4d8882ef7e842c (diff) | |
parent | 48b4a99ce2451f1ddf2e8e128bbfcd6683072999 (diff) |
Merge branch 'master' into feature/gnumake4
Conflicts:
connectivity/source/cpool/Zregistration.cxx
connectivity/source/drivers/evoab/LCatalog.cxx
connectivity/source/drivers/evoab/LColumnAlias.cxx
connectivity/source/drivers/evoab/LColumnAlias.hxx
connectivity/source/drivers/evoab/LColumns.cxx
connectivity/source/drivers/evoab/LColumns.hxx
connectivity/source/drivers/evoab/LConfigAccess.cxx
connectivity/source/drivers/evoab/LConfigAccess.hxx
connectivity/source/drivers/evoab/LConnection.cxx
connectivity/source/drivers/evoab/LConnection.hxx
connectivity/source/drivers/evoab/LDatabaseMetaData.cxx
connectivity/source/drivers/evoab/LDatabaseMetaData.hxx
connectivity/source/drivers/evoab/LDriver.cxx
connectivity/source/drivers/evoab/LDriver.hxx
connectivity/source/drivers/evoab/LFolderList.cxx
connectivity/source/drivers/evoab/LFolderList.hxx
connectivity/source/drivers/evoab/LNoException.cxx
connectivity/source/drivers/evoab/LPreparedStatement.cxx
connectivity/source/drivers/evoab/LPreparedStatement.hxx
connectivity/source/drivers/evoab/LResultSet.cxx
connectivity/source/drivers/evoab/LResultSet.hxx
connectivity/source/drivers/evoab/LServices.cxx
connectivity/source/drivers/evoab/LStatement.cxx
connectivity/source/drivers/evoab/LStatement.hxx
connectivity/source/drivers/evoab/LTable.cxx
connectivity/source/drivers/evoab/LTable.hxx
connectivity/source/drivers/evoab/LTables.cxx
connectivity/source/drivers/evoab/LTables.hxx
connectivity/source/drivers/evoab/evoab.xml
connectivity/source/drivers/evoab/makefile.mk
editeng/Library_editeng.mk
framework/Library_fwe.mk
framework/test/test.cxx
idl/prj/d.lst
idl/util/idlpch.cxx
linguistic/Makefile
linguistic/Module_linguistic.mk
linguistic/inc/linguistic/lngdllapi.h
linguistic/inc/linguistic/lngprophelp.hxx
linguistic/inc/linguistic/misc.hxx
linguistic/prj/build.lst
linguistic/prj/d.lst
linguistic/qa/unoapi/Test.java
linguistic/source/grammarchecker.cxx
linguistic/source/grammarchecker.hxx
linguistic/source/hyphdta.cxx
linguistic/source/lngprophelp.cxx
linguistic/source/makefile.mk
linguistic/source/spelldta.cxx
sfx2/Library_qstart.mk
sfx2/Library_sfx.mk
sfx2/inc/sfx2/qswin32.h
sfx2/prj/build.lst
sfx2/qa/cppunit/makefile.mk
xmlscript/inc/xmlscript/xcrdllapi.h
xmlscript/prj/d.lst
xmlscript/util/makefile.mk
Diffstat (limited to 'editeng/source/rtf')
-rw-r--r-- | editeng/source/rtf/rtfgrf.cxx | 119 | ||||
-rw-r--r-- | editeng/source/rtf/rtfitem.cxx | 526 | ||||
-rw-r--r-- | editeng/source/rtf/svxrtf.cxx | 277 |
3 files changed, 310 insertions, 612 deletions
diff --git a/editeng/source/rtf/rtfgrf.cxx b/editeng/source/rtf/rtfgrf.cxx index 12e9c992070a..87a603946d92 100644 --- a/editeng/source/rtf/rtfgrf.cxx +++ b/editeng/source/rtf/rtfgrf.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,7 +29,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_editeng.hxx" -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ +#include <boost/scoped_ptr.hpp> + #include <osl/endian.h> #include <tools/cachestr.hxx> #include <vcl/graph.hxx> @@ -36,49 +38,18 @@ #include <svtools/rtfkeywd.hxx> #include <svtools/rtftoken.h> #include <svtools/filter.hxx> +#include <svtools/wmf.hxx> #include <editeng/svxrtf.hxx> 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 sal_uInt8 __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 sal_uInt8 __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 +68,7 @@ static sal_uInt8 __FAR_DATA aPal4[ 16 * 4 ] = { 0xFF, 0xFF, 0xFF, 0x00 }; -static sal_uInt8 __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, @@ -217,7 +188,7 @@ static void WriteBMPHeader( SvStream& rStream, sal_uInt32 n4Height = rPicType.nHeight; sal_uInt16 n4ColBits = rPicType.nBitsPerPixel; - sal_uInt16 nColors = (1 << n4ColBits); // Anzahl der Farben ( 1, 16, 256 ) + sal_uInt16 nColors = (1 << n4ColBits); // Number of colors (1, 16, 256) sal_uInt16 nWdtOut = rPicType.nWidthBytes; if( !nWdtOut ) nWdtOut = (sal_uInt16)((( n4Width * n4ColBits + 31 ) / 32 ) * 4 ); @@ -228,8 +199,8 @@ 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 ) @@ -257,16 +228,14 @@ 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; @@ -284,7 +253,7 @@ xub_StrLen SvxRTFParser::HexToBin( String& rToken ) nVal -= 'a' - 10; else { - DBG_ASSERT( !this, "ungueltiger Hex-Wert" ); + DBG_ASSERT( !this, "invalid Hex value" ); bValidData = sal_False; break; } @@ -300,19 +269,18 @@ xub_StrLen SvxRTFParser::HexToBin( String& rToken ) sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) { - // die alten Daten loeschen + // Delete the old data rGrf.Clear(); -// sal_uInt32 nBmpSize = 0; rtl_TextEncoding eOldEnc = GetSrcEncoding(); SetSrcEncoding( RTL_TEXTENCODING_MS_1252 ); const sal_Char* pFilterNm = 0; - SvCacheStream* pTmpFile = 0; + boost::scoped_ptr<SvCacheStream> pTmpFile; 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 ) @@ -359,8 +327,8 @@ sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) case RTF_MACPICT: { rPicType.eStyle = SvxRTFPictureType::MAC_QUICKDRAW; - // Mac-Pict bekommt einen leeren Header voran - pTmpFile = new SvCacheStream; + // Mac-Pict gets a empty header above + pTmpFile.reset(new SvCacheStream); ByteString aStr; aStr.Fill( 512, '\0' ); pTmpFile->Write( aStr.GetBuffer(), aStr.Len() ); @@ -407,7 +375,7 @@ sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) } rPicType.nType = nVal; - pTmpFile = new SvCacheStream; + pTmpFile.reset(new SvCacheStream); } break; @@ -423,8 +391,6 @@ sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) rPicType.uPicLen = nTokenValue; if (rPicType.uPicLen) { - sal_uInt32 nPos = rStrm.Tell(); - nPos = nPos; rStrm.SeekRel(-1); sal_uInt8 aData[4096]; sal_uInt32 nSize = sizeof(aData); @@ -440,8 +406,6 @@ sal_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 +435,6 @@ sal_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,7 +443,7 @@ sal_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; @@ -516,15 +477,15 @@ sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) if( bValidBmp ) { - GraphicFilter* pGF = GraphicFilter::GetGraphicFilter(); + GraphicFilter& rGF = GraphicFilter::GetGraphicFilter(); sal_uInt16 nImportFilter = GRFILTER_FORMAT_DONTKNOW; if( pFilterNm ) { String sTmp; - for( sal_uInt16 n = pGF->GetImportFormatCount(); n; ) + for( sal_uInt16 n = rGF.GetImportFormatCount(); n; ) { - sTmp = pGF->GetImportFormatShortName( --n ); + sTmp = rGF.GetImportFormatShortName( --n ); if( sTmp.EqualsAscii( pFilterNm )) { nImportFilter = n; @@ -534,17 +495,22 @@ sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) } String sTmpStr; + WMF_APMFILEHEADER aAPMHeader; + aAPMHeader.left=0; + aAPMHeader.top=0; + aAPMHeader.right=rPicType.nWidth; + aAPMHeader.bottom=rPicType.nHeight; + + WMF_APMFILEHEADER *pAPMHeader=(aAPMHeader.right>0 && aAPMHeader.bottom>0?&aAPMHeader:NULL); pTmpFile->Seek( STREAM_SEEK_TO_BEGIN ); - bValidBmp = 0 == pGF->ImportGraphic( rGrf, sTmpStr, *pTmpFile, - nImportFilter ); + bValidBmp = 0 == rGF.ImportGraphic( rGrf, sTmpStr, *pTmpFile, nImportFilter, NULL, 0, pAPMHeader ); } - delete pTmpFile; } 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 +520,6 @@ sal_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: { @@ -574,15 +539,11 @@ sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType ) 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; } -/* vi:set tabstop=4 shiftwidth=4 expandtab: */ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx index 63a8dd3aa6f6..d97c05b3d67f 100644 --- a/editeng/source/rtf/rtfitem.cxx +++ b/editeng/source/rtf/rtfitem.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,8 +29,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_editeng.hxx" -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ - #include <editeng/flstitem.hxx> #include <editeng/fontitem.hxx> #include <editeng/postitem.hxx> @@ -96,8 +95,9 @@ #define BRACELEFT '{' #define BRACERIGHT '}' +using namespace editeng; -// einige Hilfs-Funktionen +// Some helper functions // char inline const SvxEscapementItem& GetEscapement(const SfxItemSet& rSet,sal_uInt16 nId,sal_Bool bInP=sal_True) { return (const SvxEscapementItem&)rSet.Get( nId,bInP); } @@ -218,7 +218,7 @@ void SvxRTFParser::SetScriptAttr( RTF_CharTypeDef eType, SfxItemSet& rSet, void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) { - DBG_ASSERT( pSet, "Es muss ein SfxItemSet uebergeben werden!" ); + DBG_ASSERT( pSet, "A SfxItemSet has to be provided as argument!" ); int bFirstToken = sal_True, bWeiter = sal_True; sal_uInt16 nStyleNo = 0; // default FontUnderline eUnderline; @@ -230,7 +230,7 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) int bChkStkPos = !bNewGroup && !aAttrStack.empty(); - while( bWeiter && IsParserWorking() ) // solange bekannte Attribute erkannt werden + while( bWeiter && IsParserWorking() ) // as long as known Attribute are recognized { switch( nToken ) { @@ -262,12 +262,12 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) if( pAkt->aAttrSet.Count() || pAkt->pChildList || pAkt->nStyleNo ) { - // eine neue Gruppe aufmachen + // Open a new Group SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, sal_True ); pNew->SetRTFDefaults( GetRTFDefaults() ); - // alle bis hierher gueltigen Attribute "setzen" + // "Set" all valid attributes up until this point AttrGroupEnd(); pAkt = aAttrStack.empty() ? 0 : aAttrStack.back(); // can be changed after AttrGroupEnd! pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 ); @@ -276,7 +276,7 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) pAkt = pNew; } else - // diesen Eintrag als neuen weiterbenutzen + // continue to use this entry as a new one pAkt->SetStartPos( *pInsPos ); pSet = &pAkt->aAttrSet; @@ -311,34 +311,6 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) pAkt->nStyleNo = sal_uInt16( nStyleNo ); -#if 0 -// JP 05.09.95: zuruecksetzen der Style-Attribute fuehrt nur zu Problemen. -// Es muss reichen, wenn das ueber pard/plain erfolgt -// ansonsten Bugdoc 15304.rtf - nach nur "\pard" falscher Font !! - - SvxRTFStyleType* pStyle = aStyleTbl.Get( pAkt->nStyleNo ); - if( pStyle && pStyle->aAttrSet.Count() ) - { - //JP 07.07.95: - // alle Attribute, die in der Vorlage gesetzt werden - // auf defaults setzen. In RTF werden die Attribute - // der Vorlage danach ja wiederholt. - // WICHTIG: Attribute die in der Vorlage definiert - // sind, werden zurueckgesetzt !!!! - // pAkt->aAttrSet.Put( pStyle->aAttrSet ); - - SfxItemIter aIter( pStyle->aAttrSet ); - SfxItemPool* pPool = pStyle->aAttrSet.GetPool(); - sal_uInt16 nWh = aIter.GetCurItem()->Which(); - while( sal_True ) - { - pAkt->aAttrSet.Put( pPool->GetDefaultItem( nWh )); - if( aIter.IsAtEnd() ) - break; - nWh = aIter.NextItem()->Which(); - } - } -#endif } break; @@ -474,14 +446,14 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) case RTF_SLMULT: if( PARDID->nLinespacing && 1 == nTokenValue ) { - // dann wird auf mehrzeilig umgeschaltet! + // then switches to multi-line! SvxLineSpacingItem aLSpace( GetLineSpacing( *pSet, PARDID->nLinespacing, sal_False )); - // wieviel bekommt man aus dem LineHeight Wert heraus + // how much do you get from the line height value? - // Proportionale-Groesse: - // D.H. das Verhaeltnis ergibt sich aus ( n / 240 ) Twips + // Proportional-Size: + // Ie, the ratio is (n / 240) twips nTokenValue = 240; if( IsCalcValue() ) @@ -490,8 +462,8 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) nTokenValue = short( 100L * aLSpace.GetLineHeight() / long( nTokenValue ) ); - if( nTokenValue > 200 ) // Datenwert fuer PropLnSp - nTokenValue = 200; // ist ein sal_uInt8 !!! + if( nTokenValue > 200 ) // Data value for PropLnSp + nTokenValue = 200; // is one BYTE !!! aLSpace.SetPropLineSpace( (const sal_uInt8)nTokenValue ); aLSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; @@ -503,9 +475,9 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) case RTF_SL: if( PARDID->nLinespacing ) { - // errechne das Verhaeltnis aus dem default Font zu der - // Size Angabe. Der Abstand besteht aus der Zeilenhoehe - // (100%) und dem Leerraum ueber der Zeile (20%). + // Calculate the ratio between the default font and the + // specified size. The distance consists of the line height + // (100%) and the space above the line (20%). SvxLineSpacingItem aLSpace(0, PARDID->nLinespacing); nTokenValue = !bTokenHasValue ? 0 : nTokenValue; @@ -580,10 +552,9 @@ SET_FONTALIGNMENT: } break; -/* */ case RTF_B: case RTF_AB: - if( IsAttrSttPos() ) // nicht im Textfluss ? + if( IsAttrSttPos() ) // not in the text flow? { SvxWeightItem aTmpItem( @@ -596,7 +567,7 @@ SET_FONTALIGNMENT: case RTF_CAPS: case RTF_SCAPS: if( PLAINID->nCaseMap && - IsAttrSttPos() ) // nicht im Textfluss ? + IsAttrSttPos() ) // not in the text flow? { SvxCaseMap eCaseMap; if( !nTokenValue ) @@ -721,7 +692,7 @@ SET_FONTALIGNMENT: case RTF_I: case RTF_AI: - if( IsAttrSttPos() ) // nicht im Textfluss ? + if( IsAttrSttPos() ) // not in the text flow? { SvxPostureItem aTmpItem( nTokenValue ? ITALIC_NORMAL : ITALIC_NONE, @@ -732,7 +703,7 @@ SET_FONTALIGNMENT: case RTF_OUTL: if( PLAINID->nContour && - IsAttrSttPos() ) // nicht im Textfluss ? + IsAttrSttPos() ) // not in the text flow? { pSet->Put( SvxContourItem( nTokenValue ? sal_True : sal_False, PLAINID->nContour )); @@ -741,7 +712,7 @@ SET_FONTALIGNMENT: case RTF_SHAD: if( PLAINID->nShadowed && - IsAttrSttPos() ) // nicht im Textfluss ? + IsAttrSttPos() ) // not in the text flow? { pSet->Put( SvxShadowedItem( nTokenValue ? sal_True : sal_False, PLAINID->nShadowed )); @@ -750,7 +721,7 @@ SET_FONTALIGNMENT: case RTF_STRIKE: if( PLAINID->nCrossedOut && - IsAttrSttPos() ) // nicht im Textfluss ? + IsAttrSttPos() ) // not in the text flow? { pSet->Put( SvxCrossedOutItem( nTokenValue ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, @@ -759,7 +730,7 @@ SET_FONTALIGNMENT: break; case RTF_STRIKED: - if( PLAINID->nCrossedOut ) // nicht im Textfluss ? + if( PLAINID->nCrossedOut ) // not in the text flow? { pSet->Put( SvxCrossedOutItem( nTokenValue ? STRIKEOUT_DOUBLE : STRIKEOUT_NONE, @@ -990,9 +961,9 @@ ATTR_SETOVERLINE: PLAINID->nColor )); } break; -#if 0 //#i12501# While cb is clearly documented in the rtf spec, word //doesn't accept it at all +#if 0 case RTF_CB: if( PLAINID->nBgColor ) { @@ -1001,6 +972,7 @@ ATTR_SETOVERLINE: } break; #endif + case RTF_LANG: if( PLAINID->nLanguage ) { @@ -1144,12 +1116,9 @@ ATTR_SETEMPHASIS: ReadBackgroundAttr( nToken, *pSet ); break; - -/* */ - case BRACELEFT: { - // teste auf Swg-Interne Tokens + // tests on Swg internal tokens bool bHandled = false; short nSkip = 0; if( RTF_IGNOREFLAG != GetNextToken()) @@ -1163,16 +1132,16 @@ ATTR_SETEMPHASIS: case RTF_PGBRK: case RTF_SOUTLVL: UnknownAttrToken( nToken, pSet ); - // ueberlese die schliessende Klammer + // overwrite the closing parenthesis break; case RTF_SWG_ESCPROP: { - // prozentuale Veraenderung speichern ! + // Store percentage change! sal_uInt8 nProp = sal_uInt8( nTokenValue / 100 ); short nEsc = 0; if( 1 == ( nTokenValue % 100 )) - // Erkennung unseres AutoFlags! + // Recognize own auto-flags! nEsc = DFLT_ESC_AUTO_SUPER; if( PLAINID->nEscapement ) @@ -1204,7 +1173,7 @@ ATTR_SETEMPHASIS: pSet->Put( aHypenZone ); } else - SkipGroup(); // ans Ende der Gruppe + SkipGroup(); // at the end of the group } break; @@ -1219,8 +1188,6 @@ ATTR_SETEMPHASIS: if( RTF_SHDW_STYLE != GetNextToken() ) break; - //! (pb) class Brush removed -> obsolete - //! BrushStyle eStyle = BrushStyle( nTokenValue ); if( RTF_SHDW_COL != GetNextToken() ) break; @@ -1228,7 +1195,6 @@ ATTR_SETEMPHASIS: if( RTF_SHDW_FCOL != GetNextToken() ) break; -// sal_uInt16 nFillCol = sal_uInt16( nTokenValue ); Color aColor = GetColor( nCol ); @@ -1240,7 +1206,7 @@ ATTR_SETEMPHASIS: } while( sal_False ); if( bSkip ) - SkipGroup(); // ans Ende der Gruppe + SkipGroup(); // at the end of the group } break; @@ -1273,7 +1239,7 @@ ATTR_SETEMPHASIS: nToken = SkipToken( -2 ); ReadBorderAttr( nToken, *pSet ); } - else // also kein Attribut mehr + else // so no more attribute nSkip = -2; break; } @@ -1295,10 +1261,10 @@ ATTR_SETEMPHASIS: else nSkip = -2; - if( nSkip ) // alles voellig unbekannt + if( nSkip ) // all completely unknown { if (!bFirstToken) - --nSkip; // BRACELEFT: ist das naechste Token + --nSkip; // BRACELEFT: is the next token SkipToken( nSkip ); bWeiter = sal_False; } @@ -1313,7 +1279,7 @@ ATTR_SETEMPHASIS: ReadBackgroundAttr( nToken, *pSet ); else { - // kenne das Token nicht also das Token "in den Parser zurueck" + // unknown token, so token "returned in Parser" if( !bFirstToken ) SkipToken( -1 ); bWeiter = sal_False; @@ -1326,38 +1292,12 @@ ATTR_SETEMPHASIS: } bFirstToken = sal_False; } - -/* - // teste Attribute gegen ihre Styles - if( IsChkStyleAttr() && pSet->Count() && !pInsPos->GetCntIdx() ) - { - SvxRTFStyleType* pStyle = aStyleTbl.Get( nStyleNo ); - if( pStyle && pStyle->aAttrSet.Count() ) - { - // alle Attribute, die schon vom Style definiert sind, aus dem - // akt. Set entfernen - const SfxPoolItem* pItem; - SfxItemIter aIter( *pSet ); - sal_uInt16 nWhich = aIter.GetCurItem()->Which(); - while( sal_True ) - { - if( SFX_ITEM_SET == pStyle->aAttrSet.GetItemState( - nWhich, sal_False, &pItem ) && *pItem == *aIter.GetCurItem()) - pSet->ClearItem( nWhich ); // loeschen - - if( aIter.IsAtEnd() ) - break; - nWhich = aIter.NextItem()->Which(); - } - } - } -*/ } void SvxRTFParser::ReadTabAttr( int nToken, SfxItemSet& rSet ) { bool bMethodOwnsToken = false; // #i52542# patch from cmc. -// dann lese doch mal alle TabStops ein +// then read all the TabStops SvxTabStop aTabStop; SvxTabStopItem aAttr( 0, 0, SVX_TAB_ADJUST_DEFAULT, PARDID->nTabStop ); int bWeiter = sal_True; @@ -1371,7 +1311,7 @@ void SvxRTFParser::ReadTabAttr( int nToken, SfxItemSet& rSet ) CalcValue(); aTabStop.GetTabPos() = nTokenValue; aAttr.Insert( aTabStop ); - aTabStop = SvxTabStop(); // alle Werte default + aTabStop = SvxTabStop(); // all values default } break; @@ -1396,7 +1336,7 @@ void SvxRTFParser::ReadTabAttr( int nToken, SfxItemSet& rSet ) case BRACELEFT: { - // Swg - Kontrol BRACELEFT RTF_IGNOREFLAG RTF_TLSWG BRACERIGHT + // Swg - control BRACELEFT RTF_IGNOREFLAG RTF_TLSWG BRACERIGHT short nSkip = 0; if( RTF_IGNOREFLAG != GetNextToken() ) nSkip = -1; @@ -1406,13 +1346,13 @@ void SvxRTFParser::ReadTabAttr( int nToken, SfxItemSet& rSet ) { aTabStop.GetDecimal() = sal_uInt8(nTokenValue & 0xff); aTabStop.GetFill() = sal_uInt8((nTokenValue >> 8) & 0xff); - // ueberlese noch die schliessende Klammer + // overwrite the closing parenthesis if (bMethodOwnsToken) GetNextToken(); } if( nSkip ) { - SkipToken( nSkip ); // Ignore wieder zurueck + SkipToken( nSkip ); // Ignore back again bWeiter = sal_False; } } @@ -1428,7 +1368,7 @@ void SvxRTFParser::ReadTabAttr( int nToken, SfxItemSet& rSet ) } } while( bWeiter ); - // mit Defaults aufuellen fehlt noch !!! + // Fill with defaults is still missing! rSet.Put( aAttr ); SkipToken( -1 ); } @@ -1438,7 +1378,7 @@ static void SetBorderLine( int nBorderTyp, SvxBoxItem& rItem, { switch( nBorderTyp ) { - case RTF_BOX: // alle Stufen durchlaufen + case RTF_BOX: // run through all levels case RTF_BRDRT: rItem.SetLine( &rBorder, BOX_LINE_TOP ); @@ -1465,15 +1405,18 @@ static void SetBorderLine( int nBorderTyp, SvxBoxItem& rItem, void SvxRTFParser::ReadBorderAttr( int nToken, SfxItemSet& rSet, int bTableDef ) { - // dann lese doch mal das BoderAttribut ein + // then read the border attribute SvxBoxItem aAttr( PARDID->nBox ); const SfxPoolItem* pItem; if( SFX_ITEM_SET == rSet.GetItemState( PARDID->nBox, sal_False, &pItem ) ) aAttr = *(SvxBoxItem*)pItem; - SvxBorderLine aBrd( 0, DEF_LINE_WIDTH_0, 0, 0 ); // einfache Linien + SvxBorderLine aBrd( 0, DEF_LINE_WIDTH_0 ); // Simple plain line int bWeiter = sal_True, nBorderTyp = 0; + long nWidth = 1; + bool bDoubleWidth = false; + do { switch( nToken ) { @@ -1483,42 +1426,115 @@ void SvxRTFParser::ReadBorderAttr( int nToken, SfxItemSet& rSet, case RTF_BRDRL: case RTF_BRDRR: nBorderTyp = nToken; - goto SETBORDER; + break; - case RTF_CLBRDRT: - if( !bTableDef ) + case RTF_CLBRDRT: // Cell top border + { + if( bTableDef ) + { + if (nBorderTyp != 0) + SetBorderLine( nBorderTyp, aAttr, aBrd ); + nBorderTyp = RTF_BRDRT; + } break; - nBorderTyp = RTF_BRDRT; - goto SETBORDER; - case RTF_CLBRDRB: - if( !bTableDef ) + } + case RTF_CLBRDRB: // Cell bottom border + { + if( bTableDef ) + { + if (nBorderTyp != 0) + SetBorderLine( nBorderTyp, aAttr, aBrd ); + nBorderTyp = RTF_BRDRB; + } break; - nBorderTyp = RTF_BRDRB; - goto SETBORDER; - case RTF_CLBRDRL: - if( !bTableDef ) + } + case RTF_CLBRDRL: // Cell left border + { + if( bTableDef ) + { + if (nBorderTyp != 0) + SetBorderLine( nBorderTyp, aAttr, aBrd ); + nBorderTyp = RTF_BRDRL; + } break; - nBorderTyp = RTF_BRDRL; - goto SETBORDER; - case RTF_CLBRDRR: - if( !bTableDef ) + } + case RTF_CLBRDRR: // Cell right border + { + if( bTableDef ) + { + if (nBorderTyp != 0) + SetBorderLine( nBorderTyp, aAttr, aBrd ); + nBorderTyp = RTF_BRDRR; + } break; - nBorderTyp = RTF_BRDRR; - goto SETBORDER; + } -SETBORDER: + case RTF_BRDRDOT: // dotted border + aBrd.SetStyle( DOTTED ); + break; + case RTF_BRDRDASH: // dashed border + aBrd.SetStyle( DASHED ); + break; + case RTF_BRDRHAIR: // hairline border { - // auf defaults setzen - aBrd.SetOutWidth( DEF_LINE_WIDTH_0 ); - aBrd.SetInWidth( 0 ); - aBrd.SetDistance( 0 ); - aBrd.SetColor( Color( COL_BLACK ) ); + aBrd.SetStyle( SOLID ); + aBrd.SetWidth( DEF_LINE_WIDTH_0 ); } break; + case RTF_BRDRDB: // Double border + aBrd.SetStyle( DOUBLE ); + break; + case RTF_BRDRINSET: // inset border + aBrd.SetStyle( INSET ); + break; + case RTF_BRDROUTSET: // outset border + aBrd.SetStyle( OUTSET ); + break; + case RTF_BRDRTNTHSG: // ThinThick Small gap + aBrd.SetStyle( THINTHICK_SMALLGAP ); + break; + case RTF_BRDRTNTHMG: // ThinThick Medium gap + aBrd.SetStyle( THINTHICK_MEDIUMGAP ); + break; + case RTF_BRDRTNTHLG: // ThinThick Large gap + aBrd.SetStyle( THINTHICK_LARGEGAP ); + break; + case RTF_BRDRTHTNSG: // ThickThin Small gap + aBrd.SetStyle( THICKTHIN_SMALLGAP ); + break; + case RTF_BRDRTHTNMG: // ThickThin Medium gap + aBrd.SetStyle( THICKTHIN_MEDIUMGAP ); + break; + case RTF_BRDRTHTNLG: // ThickThin Large gap + aBrd.SetStyle( THICKTHIN_LARGEGAP ); + break; + case RTF_BRDREMBOSS: // Embossed border + aBrd.SetStyle( EMBOSSED ); + break; + case RTF_BRDRENGRAVE: // Engraved border + aBrd.SetStyle( ENGRAVED ); + break; + case RTF_BRDRS: // single thickness border + bDoubleWidth = false; + break; + case RTF_BRDRTH: // double thickness border width*2 + bDoubleWidth = true; + break; + case RTF_BRDRW: // border width <255 + nWidth = nTokenValue; + break; -// werden noch nicht ausgewertet - case RTF_BRSP: + case RTF_BRDRCF: // Border color + aBrd.SetColor( GetColor( sal_uInt16(nTokenValue) ) ); + break; + + case RTF_BRDRSH: // Shadowed border + rSet.Put( SvxShadowItem( PARDID->nShadow, (Color*) 0, 60 /*3pt*/, + SVX_SHADOW_BOTTOMRIGHT ) ); + break; + + case RTF_BRSP: // Spacing to content in twip { switch( nBorderTyp ) { @@ -1545,182 +1561,9 @@ SETBORDER: } break; -case RTF_BRDRBTW: -case RTF_BRDRBAR: break; - - - case RTF_BRDRCF: - { - aBrd.SetColor( GetColor( sal_uInt16(nTokenValue) ) ); - SetBorderLine( nBorderTyp, aAttr, aBrd ); - } - break; - - case RTF_BRDRTH: - aBrd.SetOutWidth( DEF_LINE_WIDTH_1 ); - aBrd.SetInWidth( 0 ); - aBrd.SetDistance( 0 ); - goto SETBORDERLINE; - - case RTF_BRDRDB: - aBrd.SetOutWidth( DEF_DOUBLE_LINE0_OUT ); - aBrd.SetInWidth( DEF_DOUBLE_LINE0_IN ); - aBrd.SetDistance( DEF_DOUBLE_LINE0_DIST ); - goto SETBORDERLINE; - - case RTF_BRDRSH: - // schattierte Box - { - rSet.Put( SvxShadowItem( PARDID->nShadow, (Color*) 0, 60 /*3pt*/, - SVX_SHADOW_BOTTOMRIGHT ) ); - } - break; - - case RTF_BRDRW: - if( -1 != nTokenValue ) - { - // sollte es eine "dicke" Linie sein ? - if( DEF_LINE_WIDTH_0 != aBrd.GetOutWidth() ) - nTokenValue *= 2; - - // eine Doppelline? - if( aBrd.GetInWidth() ) - { - // WinWord - Werte an StarOffice anpassen - if( nTokenValue < DEF_LINE_WIDTH_1 - (DEF_LINE_WIDTH_1/10)) - { - aBrd.SetOutWidth( DEF_DOUBLE_LINE0_OUT ); - aBrd.SetInWidth( DEF_DOUBLE_LINE0_IN ); - aBrd.SetDistance( DEF_DOUBLE_LINE0_DIST ); - } - else - if( nTokenValue < DEF_LINE_WIDTH_2 - (DEF_LINE_WIDTH_2/10)) - { - aBrd.SetOutWidth( DEF_DOUBLE_LINE1_OUT ); - aBrd.SetInWidth( DEF_DOUBLE_LINE1_IN ); - aBrd.SetDistance( DEF_DOUBLE_LINE1_DIST ); - } - else - { - aBrd.SetOutWidth( DEF_DOUBLE_LINE2_OUT ); - aBrd.SetInWidth( DEF_DOUBLE_LINE2_IN ); - aBrd.SetDistance( DEF_DOUBLE_LINE2_DIST ); - } - } - else - { - // WinWord - Werte an StarOffice anpassen - if( nTokenValue < DEF_LINE_WIDTH_1 - (DEF_LINE_WIDTH_1/10)) - aBrd.SetOutWidth( DEF_LINE_WIDTH_0 ); - else - if( nTokenValue < DEF_LINE_WIDTH_2 - (DEF_LINE_WIDTH_2/10)) - aBrd.SetOutWidth( DEF_LINE_WIDTH_1 ); - else - if( nTokenValue < DEF_LINE_WIDTH_3 - (DEF_LINE_WIDTH_3/10)) - aBrd.SetOutWidth( DEF_LINE_WIDTH_2 ); - else - if( nTokenValue < DEF_LINE_WIDTH_4 ) - aBrd.SetOutWidth( DEF_LINE_WIDTH_3 ); - else - aBrd.SetOutWidth( DEF_LINE_WIDTH_4 ); - } - } - goto SETBORDERLINE; - - case RTF_BRDRS: - case RTF_BRDRDOT: - case RTF_BRDRHAIR: - case RTF_BRDRDASH: -SETBORDERLINE: - SetBorderLine( nBorderTyp, aAttr, aBrd ); - break; - - case BRACELEFT: - { - short nSkip = 0; - if( RTF_IGNOREFLAG != GetNextToken() ) - nSkip = -1; - else - { - int bSwgControl = sal_True, bFirstToken = sal_True; - nToken = GetNextToken(); - do { - switch( nToken ) - { - case RTF_BRDBOX: - aAttr.SetDistance( sal_uInt16(nTokenValue) ); - break; - - case RTF_BRDRT: - case RTF_BRDRB: - case RTF_BRDRR: - case RTF_BRDRL: - nBorderTyp = nToken; - bFirstToken = sal_False; - if( RTF_BRDLINE_COL != GetNextToken() ) - { - bSwgControl = sal_False; - break; - } - aBrd.SetColor( GetColor( sal_uInt16(nTokenValue) )); - - if( RTF_BRDLINE_IN != GetNextToken() ) - { - bSwgControl = sal_False; - break; - } - aBrd.SetInWidth( sal_uInt16(nTokenValue)); - - if( RTF_BRDLINE_OUT != GetNextToken() ) - { - bSwgControl = sal_False; - break; - } - aBrd.SetOutWidth( sal_uInt16(nTokenValue)); - - if( RTF_BRDLINE_DIST != GetNextToken() ) - { - bSwgControl = sal_False; - break; - } - aBrd.SetDistance( sal_uInt16(nTokenValue)); - SetBorderLine( nBorderTyp, aAttr, aBrd ); - break; - - default: - bSwgControl = sal_False; - break; - } - - if( bSwgControl ) - { - nToken = GetNextToken(); - bFirstToken = sal_False; - } - } while( bSwgControl ); - - // Ende der Swg-Gruppe - // -> lese noch die schliessende Klammer - if( BRACERIGHT == nToken ) - ; - else if( !bFirstToken ) - { - // es ist ein Parser-Fehler, springe zum - // Ende der Gruppe - SkipGroup(); - // schliessende BRACERIGHT ueberspringen - GetNextToken(); - } - else - nSkip = -2; - } - - if( nSkip ) - { - SkipToken( nSkip ); // Ignore wieder zurueck - bWeiter = sal_False; - } - } + case RTF_BRDRBTW: // Border formatting group + case RTF_BRDRBAR: // Border outside + // TODO unhandled ATM break; default: @@ -1729,6 +1572,13 @@ SETBORDERLINE: if( bWeiter ) nToken = GetNextToken(); } while( bWeiter ); + + // Finally compute the border width + if ( bDoubleWidth ) nWidth *= 2; + aBrd.SetWidth( nWidth ); + + SetBorderLine( nBorderTyp, aAttr, aBrd ); + rSet.Put( aAttr ); SkipToken( -1 ); } @@ -1743,7 +1593,7 @@ inline sal_uInt32 CalcShading( sal_uInt32 nColor, sal_uInt32 nFillColor, sal_uIn void SvxRTFParser::ReadBackgroundAttr( int nToken, SfxItemSet& rSet, int bTableDef ) { - // dann lese doch mal das BoderAttribut ein + // then read the border attribute int bWeiter = sal_True; sal_uInt16 nColor = USHRT_MAX, nFillColor = USHRT_MAX; sal_uInt8 nFillValue = 0; @@ -1830,7 +1680,7 @@ void SvxRTFParser::ReadBackgroundAttr( int nToken, SfxItemSet& rSet, Color aCol( COL_WHITE ), aFCol; if( !nFillValue ) { - // es wurde nur eine von beiden Farben angegeben oder kein BrushTyp + // there was only one of two colors specified or no BrushTyp if( USHRT_MAX != nFillColor ) { nFillValue = 100; @@ -1881,11 +1731,11 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet ) { if( pAkt->aAttrSet.Count() || pAkt->pChildList || pAkt->nStyleNo ) { - // eine neue Gruppe aufmachen + // open a new group SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, sal_True ); pNew->SetRTFDefaults( GetRTFDefaults() ); - // alle bis hierher gueltigen Attribute "setzen" + // Set all until here valid attributes AttrGroupEnd(); pAkt = aAttrStack.empty() ? 0 : aAttrStack.back(); // can be changed after AttrGroupEnd! pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 ); @@ -1894,13 +1744,13 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet ) } else { - // diesen Eintrag als neuen weiterbenutzen + // continue to use this entry as new pAkt->SetStartPos( *pInsPos ); bNewStkEntry = sal_False; } } - // jetzt noch alle auf default zuruecksetzen + // now reset all to default if( bNewStkEntry && ( pAkt->aAttrSet.GetParent() || pAkt->aAttrSet.Count() )) { @@ -1922,10 +1772,7 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet ) for( sal_uInt16 n = 0; n < nCnt; ++n, ++pPtr ) { - // Item gesetzt und unterschiedlich -> das Pooldefault setzen - //JP 06.04.98: bei Items die nur SlotItems sind, darf nicht - // auf das Default zugefriffen werden. Diese - // werden gecleart + // Item set and different -> Set the Default Pool if( !*pPtr ) ; else if( SFX_WHICH_MAX < *pPtr ) @@ -1955,7 +1802,7 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet ) } } else if( bPard ) - pAkt->nStyleNo = 0; // Style-Nummer zuruecksetzen + pAkt->nStyleNo = 0; // reset Style number *ppSet = &pAkt->aAttrSet; @@ -2001,7 +1848,7 @@ void SvxRTFParser::SetDefault( int nToken, int nValue ) case RTF_ADEFLANG: bIsLeftToRightDef = sal_False; // no break! case RTF_DEFLANG: - // default Language merken + // store default Language if( -1 != nValue ) { SvxLanguageItem aTmpItem( (const LanguageType)nValue, @@ -2013,47 +1860,22 @@ void SvxRTFParser::SetDefault( int nToken, int nValue ) case RTF_DEFTAB: if( PARDID->nTabStop ) { - // RTF definiert 720 twips als default + // RTF defines 720 twips as default bIsSetDfltTab = sal_True; if( -1 == nValue || !nValue ) nValue = 720; - // wer keine Twips haben moechte ... + // who would like to have no twips ... if( IsCalcValue() ) { nTokenValue = nValue; CalcValue(); nValue = nTokenValue; } -#if 1 - /* - cmc: - This stuff looks a little hairy indeed, this should be totally - unnecessary where default tabstops are understood. Just make one - tabstop and stick the value in there, the first one is all that - matters. - - e.g. - - SvxTabStopItem aNewTab(1, sal_uInt16(nValue), SVX_TAB_ADJUST_DEFAULT, - PARDID->nTabStop); - ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT; - - - It must exist as a foul hack to support somebody that does not - have a true concept of default tabstops by making a tabsetting - result from the default tabstop, creating a lot of them all at - the default locations to give the effect of the first real - default tabstop being in use just in case the receiving - application doesn't do that for itself. - */ -#endif - // Verhaeltnis der def. TabWidth / Tabs errechnen und - // enstsprechend die neue Anzahl errechnen. -/*-----------------14.12.94 19:32------------------- - ?? wie kommt man auf die 13 ?? ---------------------------------------------------*/ + // Calculate the ratio of default TabWidth / Tabs and + // calculate the corresponding new number. + // ?? how did one come up with 13 ?? sal_uInt16 nAnzTabs = (SVX_TAB_DEFDIST * 13 ) / sal_uInt16(nValue); /* cmc, make sure we have at least one, or all hell breaks loose in @@ -2062,7 +1884,7 @@ void SvxRTFParser::SetDefault( int nToken, int nValue ) if (nAnzTabs < 1) nAnzTabs = 1; - // wir wollen Defaulttabs + // we want Defaulttabs SvxTabStopItem aNewTab( nAnzTabs, sal_uInt16(nValue), SVX_TAB_ADJUST_DEFAULT, PARDID->nTabStop ); while( nAnzTabs ) @@ -2088,14 +1910,14 @@ void SvxRTFParser::SetDefault( int nToken, int nValue ) } } -// default: keine Umrechnung, alles bei Twips lassen. +// default: no conversion, leaving everything in twips. void SvxRTFParser::CalcValue() { } - // fuer Tokens, die im ReadAttr nicht ausgewertet werden +// for tokens that are not evaluated in ReadAttr void SvxRTFParser::UnknownAttrToken( int, SfxItemSet* ) { } -/* vi:set tabstop=4 shiftwidth=4 expandtab: */ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx index 106ee9b61bbc..0b934cd22e8c 100644 --- a/editeng/source/rtf/svxrtf.cxx +++ b/editeng/source/rtf/svxrtf.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,9 +29,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_editeng.hxx" -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ - - #include <ctype.h> #include <tools/datetime.hxx> #include <rtl/tencinfo.h> @@ -66,16 +64,16 @@ CharSet lcl_GetDefaultTextEncodingForRTF() aLocale = Application::GetSettings().GetLocale(); aLangString = aLocale.Language; - if ( aLangString.equals( ::rtl::OUString::createFromAscii( "ru" ) ) - || aLangString.equals( ::rtl::OUString::createFromAscii( "uk" ) ) ) + if ( aLangString.equals( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ru" )) ) + || aLangString.equals( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "uk" )) ) ) return RTL_TEXTENCODING_MS_1251; - if ( aLangString.equals( ::rtl::OUString::createFromAscii( "tr" ) ) ) + if ( aLangString.equals( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "tr" )) ) ) return RTL_TEXTENCODING_MS_1254; else return RTL_TEXTENCODING_MS_1252; } -// -------------- Methoden -------------------- +// -------------- Methods -------------------- SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn, uno::Reference<document::XDocumentProperties> i_xDocProps, @@ -147,7 +145,7 @@ void SvxRTFParser::SetInsPos( const SvxPosition& rNew ) SvParserState SvxRTFParser::CallParser() { - DBG_ASSERT( pInsPos, "no insertion" ); + DBG_ASSERT( pInsPos, "no insertion position"); if( !pInsPos ) return SVPAR_ERROR; @@ -167,7 +165,7 @@ SvParserState SvxRTFParser::CallParser() sBaseURL.Erase(); - // erzeuge aus den gesetzten WhichIds die richtige WhichId-Tabelle. + // generate the correct WhichId table from the set WhichIds. BuildWhichTbl(); return SvRTFParser::CallParser(); @@ -180,18 +178,13 @@ void SvxRTFParser::Continue( int nToken ) if( SVPAR_PENDING != GetStatus() ) { SetAllAttrOfStk(); -#if 0 //Regardless of what "color 0" is, word defaults to auto as the default colour. //e.g. see #i7713# - if( bNewDoc && ((RTFPlainAttrMapIds*)aPlainMap.GetData())->nColor ) - pAttrPool->SetPoolDefaultItem( SvxColorItem( GetColor( 0 ), - ((RTFPlainAttrMapIds*)aPlainMap.GetData())->nColor )); -#endif } } -// wird fuer jedes Token gerufen, das in CallParser erkannt wird +// is called for each token that is recognized in CallParser void SvxRTFParser::NextToken( int nToken ) { sal_Unicode cCh; @@ -205,10 +198,10 @@ void SvxRTFParser::NextToken( int nToken ) if( bNewDoc ) { if( aFontTbl.Count() ) - // koennen wir sofort setzen + // Can immediately be set SetDefault( nToken, nTokenValue ); else - // wird nach einlesen der Fonttabelle gesetzt + // is set after reading the font table nDfltFont = int(nTokenValue); } break; @@ -237,11 +230,11 @@ INSINGLECHAR: aToken = ByteString::ConvertToUnicode( (sal_Char)cCh, RTL_TEXTENCODING_MS_1252 ); - // kein Break, aToken wird als Text gesetzt + // no Break, aToken is set as Text case RTF_TEXTTOKEN: { InsertText(); - // alle angesammelten Attribute setzen + // all collected Attributes are set for( sal_uInt16 n = aAttrSetList.Count(); n; ) { SvxRTFItemStackType* pStkSet = aAttrSetList[--n]; @@ -256,30 +249,28 @@ INSINGLECHAR: InsertPara(); break; case '{': - if (bNewGroup) // Verschachtelung !! + if (bNewGroup) // Nesting! _GetAttrSet(); EnterEnvironment(); bNewGroup = true; break; case '}': - if( !bNewGroup ) // leere Gruppe ?? + if( !bNewGroup ) // Empty Group ?? AttrGroupEnd(); LeaveEnvironment(); bNewGroup = false; break; case RTF_INFO: -#ifndef SVX_LIGHT if (bReadDocInfo && bNewDoc && m_xDocProps.is()) ReadInfo(); else -#endif SkipGroup(); break; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // erstmal gesamt ueberlesen (muessen alle in einer Gruppe stehen !!) - // Koennen auch ohne dem IGNORE-Flag im RTF-File auftreten; alle Gruppen - // mit IGNORE-Flag werden im default-Zweig ueberlesen. + // First overwrite all (all have to be in one group!!) + // Could also appear in the RTF-filewithout the IGNORE-Flag; all Groups + // with the IGNORE-Flag are overwritten in the default branch. case RTF_SWG_PRTDATA: case RTF_FIELD: @@ -293,10 +284,7 @@ INSINGLECHAR: case RTF_TC: case RTF_NEXTFILE: case RTF_TEMPLATE: -#if 0 - //disabled for #i19718# - case RTF_SHPRSLT: // RTF_SHP fehlt noch !! -#endif + // RTF_SHPRSLT disabled for #i19718# SkipGroup(); break; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -353,20 +341,20 @@ void SvxRTFParser::ReadStyleTable() { int nToken, bSaveChkStyleAttr = bChkStyleAttr; short nStyleNo = 0; - int _nOpenBrakets = 1; // die erste wurde schon vorher erkannt !! + int _nOpenBrakets = 1; // the first was already detected earlier!! SvxRTFStyleType* pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() ); pStyle->aAttrSet.Put( GetRTFDefaults() ); bIsInReadStyleTab = sal_True; - bChkStyleAttr = sal_False; // Attribute nicht gegen die Styles checken + bChkStyleAttr = sal_False; // Do not check Attribute against the Styles while( _nOpenBrakets && IsParserWorking() ) { switch( nToken = GetNextToken() ) { case '}': if( --_nOpenBrakets && IsParserWorking() ) - // Style konnte vollstaendig gelesen werden, - // also ist das noch ein stabiler Status + // Style has been completely read, + // so this is still a stable status SaveState( RTF_STYLESHEET ); break; case '{': @@ -378,7 +366,7 @@ void SvxRTFParser::ReadStyleTable() nToken = SkipToken( -2 ); else { - // gleich herausfiltern + // filter out at once ReadUnknownData(); nToken = GetNextToken(); if( '}' != nToken ) @@ -402,19 +390,13 @@ void SvxRTFParser::ReadStyleTable() { pStyle->sName = DelCharAtEnd( aToken, ';' ); -/* -??? soll man das umsetzen ??? - if( !pStyle->sName.Len() ) - pStyle->sName = "Standard"; -*/ - // sollte die Nummer doppelt vergeben werden ? if( aStyleTbl.Count() ) { SvxRTFStyleType* pOldSt = aStyleTbl.Remove( nStyleNo ); if( pOldSt ) delete pOldSt; } - // alle Daten vom Style vorhanden, also ab in die Tabelle + // All data from the font is available, so off to the table aStyleTbl.Insert( nStyleNo, pStyle ); pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() ); pStyle->aAttrSet.Put( GetRTFDefaults() ); @@ -440,9 +422,6 @@ void SvxRTFParser::ReadStyleTable() if( '{' == GetStackPtr( -1 )->nTokenId ) { nToken = SkipToken( -1 ); -#if 0 - --_nOpenBrakets; // korrigieren!! -#endif } } ReadAttr( nToken, &pStyle->aAttrSet ); @@ -451,10 +430,10 @@ void SvxRTFParser::ReadStyleTable() break; } } - delete pStyle; // loesche das letze Style - SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet + delete pStyle; // Delete the Last Style + SkipToken( -1 ); // the closing brace is evaluated "above" - // Flag wieder auf alten Zustand + // Flag back to old state bChkStyleAttr = bSaveChkStyleAttr; bIsInReadStyleTab = sal_False; } @@ -472,19 +451,19 @@ void SvxRTFParser::ReadColorTable() case RTF_GREEN: nGreen = sal_uInt8(nTokenValue); break; case RTF_BLUE: nBlue = sal_uInt8(nTokenValue); break; - case RTF_TEXTTOKEN: // oder sollte irgendein Unsin darumstehen? + case RTF_TEXTTOKEN: if( 1 == aToken.Len() ? aToken.GetChar( 0 ) != ';' : STRING_NOTFOUND == aToken.Search( ';' ) ) - break; // es muss zumindestens das ';' gefunden werden + break; // At least the ';' must be found - // else kein break !! + // else no break !! case ';': if( IsParserWorking() ) { - // eine Farbe ist Fertig, in die Tabelle eintragen - // versuche die Werte auf SV interne Namen zu mappen + // one color is finished, fill in the table + // try to map the values to SV internal names ColorPtr pColor = new Color( nRed, nGreen, nBlue ); if( aColorTbl.empty() && sal_uInt8(-1) == nRed && sal_uInt8(-1) == nGreen && sal_uInt8(-1) == nBlue ) @@ -492,20 +471,20 @@ void SvxRTFParser::ReadColorTable() aColorTbl.push_back( pColor ); nRed = 0, nGreen = 0, nBlue = 0; - // Color konnte vollstaendig gelesen werden, - // also ist das noch ein stabiler Status + // Color has been completely read, + // so this is still a stable status SaveState( RTF_COLORTBL ); } break; } } - SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet + SkipToken( -1 ); // the closing brace is evaluated "above" } void SvxRTFParser::ReadFontTable() { int nToken; - int _nOpenBrakets = 1; // die erste wurde schon vorher erkannt !! + int _nOpenBrakets = 1; // the first was already detected earlier!! Font* pFont = new Font(); short nFontNo(0), nInsFontNo (0); String sAltNm, sFntNm; @@ -522,8 +501,8 @@ void SvxRTFParser::ReadFontTable() { case '}': bIsAltFntNm = sal_False; - // Style konnte vollstaendig gelesen werden, - // also ist das noch ein stabiler Status + // Style has been completely read, + // so this is still a stable status if( --_nOpenBrakets <= 1 && IsParserWorking() ) SaveState( RTF_FONTTBL ); bCheckNewFont = sal_True; @@ -532,15 +511,15 @@ void SvxRTFParser::ReadFontTable() case '{': if( RTF_IGNOREFLAG != GetNextToken() ) nToken = SkipToken( -1 ); - // Unknown und alle bekannten nicht ausgewerteten Gruppen - // sofort ueberspringen + // immediately skip unknown and all known but non-evaluated + // groups else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ) && RTF_PANOSE != nToken && RTF_FNAME != nToken && RTF_FONTEMB != nToken && RTF_FONTFILE != nToken ) nToken = SkipToken( -2 ); else { - // gleich herausfiltern + // filter out at once ReadUnknownData(); nToken = GetNextToken(); if( '}' != nToken ) @@ -564,7 +543,7 @@ void SvxRTFParser::ReadFontTable() case RTF_FDECOR: pFont->SetFamily( FAMILY_DECORATIVE ); break; - // bei technischen/symbolischen Font wird der CharSet ungeschaltet!! + // for technical/symbolic font of the CharSet is changed! case RTF_FTECH: pFont->SetCharSet( RTL_TEXTENCODING_SYMBOL ); // deliberate fall through @@ -617,7 +596,7 @@ void SvxRTFParser::ReadFontTable() if( bCheckNewFont && 1 >= _nOpenBrakets && sFntNm.Len() ) // one font is ready { - // alle Daten vom Font vorhanden, also ab in die Tabelle + // All data from the font is available, so off to the table if (sAltNm.Len()) (sFntNm += ';' ) += sAltNm; @@ -629,11 +608,11 @@ void SvxRTFParser::ReadFontTable() sFntNm.Erase(); } } - // den letzen muessen wir selbst loeschen + // the last one we have to delete manually delete pFont; - SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet + SkipToken( -1 ); // the closing brace is evaluated "above" - // setze den default Font am Doc + // set the default font in the Document if( bNewDoc && IsParserWorking() ) SetDefault( RTF_DEFF, nDfltFont ); } @@ -651,7 +630,7 @@ void SvxRTFParser::ReadOLEData() String& SvxRTFParser::GetTextToEndGroup( String& rStr ) { rStr.Erase( 0 ); - int _nOpenBrakets = 1, nToken; // die erste wurde schon vorher erkannt !! + int _nOpenBrakets = 1, nToken; // the first was already detected earlier!! while( _nOpenBrakets && IsParserWorking() ) { @@ -666,7 +645,7 @@ String& SvxRTFParser::GetTextToEndGroup( String& rStr ) nToken = SkipToken( -2 ); else { - // gleich herausfiltern + // filter out at once ReadUnknownData(); nToken = GetNextToken(); if( '}' != nToken ) @@ -682,7 +661,7 @@ String& SvxRTFParser::GetTextToEndGroup( String& rStr ) break; } } - SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet + SkipToken( -1 ); // the closing brace is evaluated "above" return rStr; } @@ -704,14 +683,13 @@ util::DateTime SvxRTFParser::GetDateTimeStamp( ) bWeiter = sal_False; } } - SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet + SkipToken( -1 ); // the closing brace is evaluated "above" return aDT; } void SvxRTFParser::ReadInfo( const sal_Char* pChkForVerNo ) { -#ifndef SVX_LIGHT - int _nOpenBrakets = 1, nToken; // die erste wurde schon vorher erkannt !! + int _nOpenBrakets = 1, nToken; // the first was already detected earlier!! DBG_ASSERT(m_xDocProps.is(), "SvxRTFParser::ReadInfo: no DocumentProperties"); String sStr, sComment; @@ -730,7 +708,7 @@ void SvxRTFParser::ReadInfo( const sal_Char* pChkForVerNo ) nToken = SkipToken( -2 ); else { - // gleich herausfiltern + // filter out at once ReadUnknownData(); nToken = GetNextToken(); if( '}' != nToken ) @@ -809,8 +787,7 @@ void SvxRTFParser::ReadInfo( const sal_Char* pChkForVerNo ) COMPARE_EQUAL == sComment.CompareToAscii( pChkForVerNo )) nVersionNo = nVersNo; - SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet -#endif + SkipToken( -1 ); // the closing brace is evaluated "above" } @@ -909,35 +886,32 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType ) if( SFX_WHICH_MAX > nWhich && SFX_ITEM_SET == rSet.GetItemState( nWhich, sal_False, &pItem ) && rPool.GetDefaultItem( nWhich ) == *pItem ) - rSet.ClearItem( nWhich ); // loeschen + rSet.ClearItem( nWhich ); // delete } } else { - // alle Attribute, die schon vom Style definiert sind, aus dem - // akt. AttrSet entfernen + // Delete all Attributes, which are already defined in the Style, + // from the current AttrSet. SfxItemSet &rStyleSet = pStyle->aAttrSet; const SfxPoolItem* pSItem; for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() ) { if( SFX_ITEM_SET == rStyleSet.GetItemState( nWhich, sal_True, &pSItem )) { - // JP 22.06.99: im Style und im Set gleich gesetzt -> loeschen if( SFX_ITEM_SET == rSet.GetItemState( nWhich, sal_False, &pItem ) && *pItem == *pSItem ) - rSet.ClearItem( nWhich ); // loeschen + rSet.ClearItem( nWhich ); // delete } - // Bug 59571 - falls nicht im Style gesetzt und gleich mit - // dem PoolDefault -> auch dann loeschen else if( SFX_WHICH_MAX > nWhich && SFX_ITEM_SET == rSet.GetItemState( nWhich, sal_False, &pItem ) && rPool.GetDefaultItem( nWhich ) == *pItem ) - rSet.ClearItem( nWhich ); // loeschen + rSet.ClearItem( nWhich ); // delete } } } -void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen +void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack { if( !aAttrStack.empty() ) { @@ -951,9 +925,9 @@ void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen ((!pOld->aAttrSet.Count() && !pOld->nStyleNo ) || (nOldSttNdIdx == pInsPos->GetNodeIdx() && pOld->nSttCnt == pInsPos->GetCntIdx() ))) - break; // keine Attribute oder Bereich + break; // no attributes or Area - // setze nur die Attribute, die unterschiedlich zum Parent sind + // set only the attributes that are different from the parent if( pAkt && pOld->aAttrSet.Count() ) { SfxItemIter aIter( pOld->aAttrSet ); @@ -975,82 +949,54 @@ void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen break; } - // setze alle Attribute, die von Start bis hier - // definiert sind. + // Set all attributes which have been defined from start until here int bCrsrBack = !pInsPos->GetCntIdx(); if( bCrsrBack ) { - // am Absatzanfang ? eine Position zurueck + // at the beginning of a paragraph? Move back one position sal_uLong nNd = pInsPos->GetNodeIdx(); MovePos( sal_False ); // if can not move backward then later dont move forward ! bCrsrBack = nNd != pInsPos->GetNodeIdx(); } - //Bug #46608#: ungueltige Bereiche ignorieren! if( ( pOld->pSttNd->GetIdx() < pInsPos->GetNodeIdx() || ( pOld->pSttNd->GetIdx() == pInsPos->GetNodeIdx() && pOld->nSttCnt <= pInsPos->GetCntIdx() )) -#if 0 -//BUG 68555 - dont test for empty paragraph or any range - && ( nOldSttNdIdx != pInsPos->GetNodeIdx() || - pOld->nSttCnt != pInsPos->GetCntIdx() || - !pOld->nSttCnt ) -#endif ) { if( !bCrsrBack ) { - // alle pard-Attribute gelten nur bis zum vorherigen - // Absatz !! + // all pard attributes are only valid until the previous + // paragraph !! if( nOldSttNdIdx == pInsPos->GetNodeIdx() ) { -#if 0 -//BUG 68555 - dont reset pard attrs, if the group not begins not at start of -// paragraph - // Bereich innerhalb eines Absatzes: - // alle Absatz-Attribute und StyleNo loeschen - // aber nur wenn mitten drin angefangen wurde - if( pOld->nSttCnt ) - { - pOld->nStyleNo = 0; - for( sal_uInt16 n = 0; n < aPardMap.Count() && - pOld->aAttrSet.Count(); ++n ) - if( aPardMap[n] ) - pOld->aAttrSet.ClearItem( aPardMap[n] ); - - if( !pOld->aAttrSet.Count() && !pOld->pChildList && - !pOld->nStyleNo ) - break; // auch dieser verlaesst uns jetzt - } -#endif } else { - // jetzt wirds kompliziert: - // - alle Zeichen-Attribute behalten den Bereich, - // - alle Absatz-Attribute bekommen den Bereich - // bis zum vorherigen Absatz + // Now it gets complicated: + // - all character attributes sre keep the area + // - all paragraph attributes to get the area + // up to the previous paragraph SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pOld, *pInsPos, sal_True ); pNew->aAttrSet.SetParent( pOld->aAttrSet.GetParent() ); - // loesche aus pNew alle Absatz Attribute + // Delete all paragraph attributes from pNew for( sal_uInt16 n = 0; n < aPardMap.Count() && pNew->aAttrSet.Count(); ++n ) if( aPardMap[n] ) pNew->aAttrSet.ClearItem( aPardMap[n] ); pNew->SetRTFDefaults( GetRTFDefaults() ); - // gab es ueberhaupt welche ? + // Were there any? if( pNew->aAttrSet.Count() == pOld->aAttrSet.Count() ) - delete pNew; // das wars dann + delete pNew; else { pNew->nStyleNo = 0; - // spanne jetzt den richtigen Bereich auf - // pNew von alter + // Now span the real area of pNew from old SetEndPrevPara( pOld->pEndNd, pOld->nEndCnt ); pNew->nSttCnt = 0; @@ -1067,14 +1013,14 @@ void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen } else { - // letzter vom Stack, also zwischenspeichern, bis der - // naechste Text eingelesen wurde. (keine Attribute - // aufspannen!!) + // Last off the stack, thus cache it until the next text was + // read. (Span no attributes!) + aAttrSetList.Insert( pOld, aAttrSetList.Count() ); aAttrSetList.Insert( pNew, aAttrSetList.Count() ); } - pOld = 0; // pOld nicht loeschen - break; // das wars !! + pOld = 0; // Do not delete pOld + break; } } } @@ -1082,10 +1028,6 @@ void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen pOld->pEndNd = pInsPos->MakeNodeIdx(); pOld->nEndCnt = pInsPos->GetCntIdx(); -#if 0 - if( IsChkStyleAttr() ) - _ClearStyleAttr( *pOld ); -#else /* #i21422# If the parent (pAkt) sets something e.g. , and the child (pOld) @@ -1098,7 +1040,6 @@ void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen */ if (IsChkStyleAttr() && !pAkt) _ClearStyleAttr( *pOld ); -#endif if( pAkt ) { @@ -1107,16 +1048,16 @@ void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen // to create a "so long" depend list. Bug 95010 if( bCrsrBack && 50 < pAkt->pChildList->Count() ) { - // am Absatzanfang ? eine Position zurueck + // at the beginning of a paragraph? Move back one position MovePos( sal_True ); bCrsrBack = sal_False; - // eine neue Gruppe aufmachen + // Open a new Group. SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, sal_True ); pNew->SetRTFDefaults( GetRTFDefaults() ); - // alle bis hierher gueltigen Attribute "setzen" + // Set all until here valid Attributes AttrGroupEnd(); pAkt = aAttrStack.empty() ? 0 : aAttrStack.back(); // can be changed after AttrGroupEnd! pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 ); @@ -1125,16 +1066,15 @@ void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen } } else - // letzter vom Stack, also zwischenspeichern, bis der - // naechste Text eingelesen wurde. (keine Attribute - // aufspannen!!) + // Last off the stack, thus cache it until the next text was + // read. (Span no attributes!) aAttrSetList.Insert( pOld, aAttrSetList.Count() ); pOld = 0; } if( bCrsrBack ) - // am Absatzanfang ? eine Position zurueck + // at the beginning of a paragraph? Move back one position MovePos( sal_True ); } while( sal_False ); @@ -1160,10 +1100,10 @@ void SvxRTFParser::SetAllAttrOfStk() // end all Attr. and set it into doc } } -// setzt alle Attribute, die unterschiedlich zum aktuellen sind +// sets all the attributes that are different from the current void SvxRTFParser::SetAttrSet( SvxRTFItemStackType &rSet ) { - // wurde DefTab nie eingelesen? dann setze auf default + // Was DefTab never read? then set to default if( !bIsSetDfltTab ) SetDefault( RTF_DEFTAB, 720 ); @@ -1172,13 +1112,13 @@ void SvxRTFParser::SetAttrSet( SvxRTFItemStackType &rSet ) if( rSet.aAttrSet.Count() || rSet.nStyleNo ) SetAttrInDoc( rSet ); - // dann mal alle Childs abarbeiten + // then process all the children if( rSet.pChildList ) for( sal_uInt16 n = 0; n < rSet.pChildList->Count(); ++n ) SetAttrSet( *(*rSet.pChildList)[ n ] ); } - // Is text wasn't inserted? (Get SttPos from the top of stack!) + // Has no Text been inserted yet? (SttPos from the top Stack entry!) int SvxRTFParser::IsAttrSttPos() { SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back(); @@ -1191,27 +1131,15 @@ void SvxRTFParser::SetAttrInDoc( SvxRTFItemStackType & ) { } -#ifdef USED -void SvxRTFParser::SaveState( int nToken ) -{ - SvRTFParser::SaveState( nToken ); -} - -void SvxRTFParser::RestoreState() -{ - SvRTFParser::RestoreState(); -} -#endif - void SvxRTFParser::BuildWhichTbl() { if( aWhichMap.Count() ) aWhichMap.Remove( 0, aWhichMap.Count() ); aWhichMap.Insert( (sal_uInt16)0, (sal_uInt16)0 ); - // Aufbau einer Which-Map 'rWhichMap' aus einem Array von - // 'pWhichIds' von Which-Ids. Es hat die Lange 'nWhichIds'. - // Die Which-Map wird nicht geloescht. + // Building a Which-Map 'rWhichMap' from an Array of + // 'pWhichIds' frm Which-Ids. It has the long 'nWhichIds'. + // The Which-Map is not going to be deleted. SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16*)aPardMap.GetData(), aPardMap.Count() ); SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16*)aPlainMap.GetData(), aPlainMap.Count() ); } @@ -1239,7 +1167,7 @@ const SfxItemSet& SvxRTFParser::GetRTFDefaults() SvxRTFStyleType::SvxRTFStyleType( SfxItemPool& rPool, const sal_uInt16* pWhichRange ) : aAttrSet( rPool, pWhichRange ) { - nOutlineNo = sal_uInt8(-1); // nicht gesetzt + nOutlineNo = sal_uInt8(-1); // not set nBasedOn = 0; bBasedOnIsSet = sal_False; //$flr #117411# nNext = 0; @@ -1294,18 +1222,6 @@ void SvxRTFItemStackType::Add( SvxRTFItemStackType* pIns ) pChildList->Insert( pIns, pChildList->Count() ); } -#if 0 -//cmc: This is the original. nEndCnt is redundantly assigned to itself, and -//pEndNd can leak if not equal to pSttNd. -void SvxRTFItemStackType::SetStartPos( const SvxPosition& rPos ) -{ - delete pSttNd; - pSttNd = rPos.MakeNodeIdx(); - nSttCnt = rPos.GetCntIdx(); - pEndNd = pSttNd; - nEndCnt = nEndCnt; -} -#else void SvxRTFItemStackType::SetStartPos( const SvxPosition& rPos ) { if (pSttNd != pEndNd) @@ -1315,7 +1231,6 @@ void SvxRTFItemStackType::SetStartPos( const SvxPosition& rPos ) pEndNd = pSttNd; nSttCnt = rPos.GetCntIdx(); } -#endif void SvxRTFItemStackType::MoveFullNode(const SvxNodeIdx &rOldNode, const SvxNodeIdx &rNewNode) @@ -1352,7 +1267,7 @@ bool SvxRTFParser::UncompressableStackEntry(const SvxRTFItemStackType &) const void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser ) { - DBG_ASSERT( pChildList, "es gibt keine ChildListe" ); + DBG_ASSERT( pChildList, "There is no child list" ); sal_uInt16 n; SvxRTFItemStackType* pTmp = (*pChildList)[0]; @@ -1389,7 +1304,7 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser ) if( n ) { - // suche alle, die ueber den gesamten Bereich gesetzt sind + // Search for all which are set over the whole area SfxItemIter aIter( aMrgSet ); const SfxPoolItem* pItem; do { @@ -1414,7 +1329,7 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser ) if( pEndNd->GetIdx() != pLastNd->GetIdx() || nEndCnt != nLastCnt ) return; - // es kann zusammengefasst werden + // It can be merged aAttrSet.Put( aMrgSet ); for( n = 0; n < pChildList->Count(); ++n ) @@ -1515,4 +1430,4 @@ RTFPardAttrMapIds ::RTFPardAttrMapIds ( const SfxItemPool& rPool ) nDirection = rPool.GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False ); } -/* vi:set tabstop=4 shiftwidth=4 expandtab: */ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |