diff options
Diffstat (limited to 'sw/source/filter/ascii/parasc.cxx')
-rw-r--r-- | sw/source/filter/ascii/parasc.cxx | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx index ff537818a13f..fd4ab7226e1a 100644 --- a/sw/source/filter/ascii/parasc.cxx +++ b/sw/source/filter/ascii/parasc.cxx @@ -51,6 +51,8 @@ #include <mdiexp.hxx> // ...Percent() #include <poolfmt.hxx> +#include "vcl/metric.hxx" + #define ASC_BUFFLEN 4096 class SwASCIIParser @@ -62,10 +64,10 @@ class SwASCIIParser const SwAsciiOptions& rOpt; SfxItemSet* pItemSet; long nFileSize; - USHORT nScript; + sal_uInt16 nScript; bool bNewDoc; - ULONG ReadChars(); + sal_uLong ReadChars(); void InsertText( const String& rStr ); public: @@ -73,12 +75,12 @@ public: int bReadNewDoc, const SwAsciiOptions& rOpts ); ~SwASCIIParser(); - ULONG CallParser(); + sal_uLong CallParser(); }; // Aufruf fuer die allg. Reader-Schnittstelle -ULONG AsciiReader::Read( SwDoc &rDoc, const String&, SwPaM &rPam, const String & ) +sal_uLong AsciiReader::Read( SwDoc &rDoc, const String&, SwPaM &rPam, const String & ) { if( !pStrm ) { @@ -93,7 +95,7 @@ ULONG AsciiReader::Read( SwDoc &rDoc, const String&, SwPaM &rPam, const String & SwASCIIParser* pParser = new SwASCIIParser( &rDoc, rPam, *pStrm, !bInsertMode, aOpt.GetASCIIOpts() ); - ULONG nRet = pParser->CallParser(); + sal_uLong nRet = pParser->CallParser(); delete pParser; // after Read reset the options @@ -126,24 +128,14 @@ SwASCIIParser::SwASCIIParser(SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn, } if( rOpt.GetFontName().Len() ) { - bool bDelete = false; - const SfxFont* pFnt = 0; + Font aTextFont( rOpt.GetFontName(), Size( 0, 10 ) ); if( pDoc->getPrinter( false ) ) - pFnt = pDoc->getPrinter( false )->GetFontByName( rOpt.GetFontName() ); - - if( !pFnt ) - { - pFnt = new SfxFont( FAMILY_DONTKNOW, rOpt.GetFontName() ); - bDelete = true; - } - SvxFontItem aFont( pFnt->GetFamily(), pFnt->GetName(), - aEmptyStr, pFnt->GetPitch(), pFnt->GetCharSet(), RES_CHRATR_FONT ); + aTextFont = pDoc->getPrinter( false )->GetFontMetric( aTextFont ); + SvxFontItem aFont( aTextFont.GetFamily(), aTextFont.GetName(), + aEmptyStr, aTextFont.GetPitch(), aTextFont.GetCharSet(), RES_CHRATR_FONT ); pItemSet->Put( aFont ); pItemSet->Put( aFont, RES_CHRATR_CJK_FONT ); pItemSet->Put( aFont, RES_CHRATR_CTL_FONT ); - - if( bDelete ) - delete (SfxFont*)pFnt; } } @@ -156,7 +148,7 @@ SwASCIIParser::~SwASCIIParser() // Aufruf des Parsers -ULONG SwASCIIParser::CallParser() +sal_uLong SwASCIIParser::CallParser() { rInput.Seek(STREAM_SEEK_TO_END); rInput.ResetError(); @@ -187,7 +179,7 @@ ULONG SwASCIIParser::CallParser() pDoc->SetTxtFmtColl(*pPam, pColl); } - ULONG nError = ReadChars(); + sal_uLong nError = ReadChars(); if( pItemSet ) { @@ -268,7 +260,7 @@ ULONG SwASCIIParser::CallParser() return nError; } -ULONG SwASCIIParser::ReadChars() +sal_uLong SwASCIIParser::ReadChars() { sal_Unicode *pStt = 0, *pEnd = 0, *pLastStt = 0; long nReadCnt = 0, nLineLen = 0; @@ -283,7 +275,7 @@ ULONG SwASCIIParser::ReadChars() aEmpty.GetLanguage() == rOpt.GetLanguage() && aEmpty.GetParaFlags() == rOpt.GetParaFlags()) { - ULONG nLen, nOrig; + sal_uLong nLen, nOrig; nOrig = nLen = rInput.Read(pArr, ASC_BUFFLEN); CharSet eCharSet; bool bRet = SwIoSystem::IsDetectableText(pArr, nLen, &eCharSet, &bSwapUnicode); @@ -315,12 +307,12 @@ ULONG SwASCIIParser::ReadChars() } else if (pUseMe != &aEmpty) //Already successfully figured out type { - rInput.StartReadingUnicodeText(); + rInput.StartReadingUnicodeText( currentCharSet ); bSwapUnicode = rInput.IsEndianSwap(); } String sWork; - ULONG nArrOffset = 0; + sal_uLong nArrOffset = 0; do { if( pStt >= pEnd ) @@ -329,7 +321,7 @@ ULONG SwASCIIParser::ReadChars() InsertText( String( pLastStt )); // lese einen neuen Block ein - ULONG lGCount; + sal_uLong lGCount; if( SVSTREAM_OK != rInput.GetError() || 0 == (lGCount = rInput.Read( pArr + nArrOffset, ASC_BUFFLEN - nArrOffset ))) @@ -374,7 +366,7 @@ ULONG SwASCIIParser::ReadChars() if( bSwapUnicode ) { sal_Char* pF = pArr, *pN = pArr + 1; - for( ULONG n = 0; n < lGCount; n += 2, pF += 2, pN += 2 ) + for( sal_uLong n = 0; n < lGCount; n += 2, pF += 2, pN += 2 ) { sal_Char c = *pF; *pF = *pN; |