diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-05-29 12:00:11 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-05-29 14:21:47 +0200 |
commit | d4992bb36efb15da91a70e86e68a80f13b97e947 (patch) | |
tree | e17ad8f8c013fef98d63473fed58eea4d5f5e830 /vcl | |
parent | 0611e0643101c9282934de872249b438bd1a7f53 (diff) |
Change SFErrCodes to scoped enum
Change-Id: Ib2f267397e419e8164bb2d732f7cbcca7acad1a6
Reviewed-on: https://gerrit.libreoffice.org/54996
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/sft.hxx | 36 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 4 | ||||
-rw-r--r-- | vcl/quartz/salgdicommon.cxx | 6 | ||||
-rw-r--r-- | vcl/source/font/font.cxx | 2 | ||||
-rw-r--r-- | vcl/source/fontsubset/fontsubset.cxx | 4 | ||||
-rw-r--r-- | vcl/source/fontsubset/sft.cxx | 79 | ||||
-rw-r--r-- | vcl/source/fontsubset/ttcr.cxx | 22 | ||||
-rw-r--r-- | vcl/source/fontsubset/ttcr.hxx | 8 | ||||
-rw-r--r-- | vcl/source/gdi/embeddedfontshelper.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontmanager.cxx | 8 | ||||
-rw-r--r-- | vcl/unx/generic/print/glyphset.cxx | 4 | ||||
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 14 |
12 files changed, 95 insertions, 94 deletions
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx index 1888f8bf79f6..c4bdee9f2a76 100644 --- a/vcl/inc/sft.hxx +++ b/vcl/inc/sft.hxx @@ -61,16 +61,16 @@ namespace vcl /*@}*/ /** Return value of OpenTTFont() and CreateT3FromTTGlyphs() */ - enum SFErrCodes { - SF_OK, /**< no error */ - SF_BADFILE, /**< file not found */ - SF_FILEIO, /**< file I/O error */ - SF_MEMORY, /**< memory allocation error */ - SF_GLYPHNUM, /**< incorrect number of glyphs */ - SF_BADARG, /**< incorrect arguments */ - SF_TTFORMAT, /**< incorrect TrueType font format */ - SF_TABLEFORMAT, /**< incorrect format of a TrueType table */ - SF_FONTNO /**< incorrect logical font number of a TTC font */ + enum class SFErrCodes { + Ok, /**< no error */ + BadFile, /**< file not found */ + FileIo, /**< file I/O error */ + Memory, /**< memory allocation error */ + GlyphNum, /**< incorrect number of glyphs */ + BadArg, /**< incorrect arguments */ + TtFormat, /**< incorrect TrueType font format */ + TableFormat, /**< incorrect format of a TrueType table */ + FontNo /**< incorrect logical font number of a TTC font */ }; #ifndef FW_THIN /* WIN32 compilation would conflict */ @@ -213,7 +213,7 @@ namespace vcl * @return value of SFErrCodes enum * @ingroup sft */ - int VCL_DLLPUBLIC OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf); + SFErrCodes VCL_DLLPUBLIC OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf); #if !defined(_WIN32) /** * TrueTypeFont constructor. @@ -226,7 +226,7 @@ namespace vcl * @return value of SFErrCodes enum * @ingroup sft */ - int VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf); + SFErrCodes VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf); #endif bool VCL_DLLPUBLIC getTTCoverage( @@ -326,7 +326,7 @@ namespace vcl * @ingroup sft * */ - int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode); + SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode); /** * Generates a new TrueType font and dumps it to <b>outf</b> file. @@ -345,7 +345,7 @@ namespace vcl * @ingroup sft * */ - int CreateTTFromTTGlyphs(TrueTypeFont *ttf, + SFErrCodes CreateTTFromTTGlyphs(TrueTypeFont *ttf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 const *encoding, @@ -363,15 +363,15 @@ namespace vcl * the glyphID glyphArray[i]. Character code 0 usually points to a default * glyph (glyphID 0) * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding - * @return SF_OK - no errors - * SF_GLYPHNUM - too many glyphs (> 255) - * SF_TTFORMAT - corrupted TrueType fonts + * @return SFErrCodes::Ok - no errors + * SFErrCodes::GlyphNum - too many glyphs (> 255) + * SFErrCodes::TtFormat - corrupted TrueType fonts * * @see SFErrCodes * @ingroup sft * */ - int CreateT42FromTTGlyphs(TrueTypeFont *ttf, + SFErrCodes CreateT42FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *psname, sal_uInt16 const *glyphArray, diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index b0f074b61303..3189ddcb271e 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -775,8 +775,8 @@ void AquaSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFontData, bool bV // use the font subsetter to get the widths TrueTypeFont* pSftFont = nullptr; - int nRC = ::OpenTTFontBuffer( static_cast<void*>(&aBuffer[0]), aBuffer.size(), 0, &pSftFont); - if( nRC != SF_OK ) + SFErrCodes nRC = ::OpenTTFontBuffer( static_cast<void*>(&aBuffer[0]), aBuffer.size(), 0, &pSftFont); + if( nRC != SFErrCodes::Ok ) return; const int nGlyphCount = ::GetTTGlyphCount( pSftFont ); diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx index 2c4fd043fe5e..e0dfdd721f5f 100644 --- a/vcl/quartz/salgdicommon.cxx +++ b/vcl/quartz/salgdicommon.cxx @@ -225,8 +225,8 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile, // prepare data for psprint's font subsetter TrueTypeFont* pSftFont = nullptr; - int nRC = ::OpenTTFontBuffer( static_cast<void*>(&aBuffer[0]), aBuffer.size(), 0, &pSftFont); - if( nRC != SF_OK ) + SFErrCodes nRC = ::OpenTTFontBuffer( static_cast<void*>(&aBuffer[0]), aBuffer.size(), 0, &pSftFont); + if( nRC != SFErrCodes::Ok ) { return false; } @@ -320,7 +320,7 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile, nRC = ::CreateTTFromTTGlyphs( pSftFont, aToFile.getStr(), aShortIDs, aTempEncs, nGlyphCount ); ::CloseTTFont(pSftFont); - return (nRC == SF_OK); + return (nRC == SFErrCodes::Ok); } static inline void alignLinePoint( const SalPoint* i_pIn, float& o_fX, float& o_fY ) diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index 0d4cc3a480e0..e8981996e09a 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -457,7 +457,7 @@ namespace { bool bResult = false; TrueTypeFont* pTTF = nullptr; - if( OpenTTFontBuffer( i_pBuffer, i_nSize, 0, &pTTF ) == SF_OK ) + if( OpenTTFontBuffer( i_pBuffer, i_nSize, 0, &pTTF ) == SFErrCodes::Ok ) { TTGlobalFontInfo aInfo; GetTTGlobalFontInfo( pTTF, &aInfo ); diff --git a/vcl/source/fontsubset/fontsubset.cxx b/vcl/source/fontsubset/fontsubset.cxx index b15b0956e971..8d2e1cf14218 100644 --- a/vcl/source/fontsubset/fontsubset.cxx +++ b/vcl/source/fontsubset/fontsubset.cxx @@ -132,7 +132,7 @@ bool FontSubsetInfo::CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths ) // remove const_cast when sft-subsetter is const-correct sal_uInt8* pEncArray = const_cast<sal_uInt8*>( mpReqEncodedIds ); #endif - int nSFTErr = vcl::SF_BADARG; + vcl::SFErrCodes nSFTErr = vcl::SFErrCodes::BadArg; if( mnReqFontTypeMask & FontType::TYPE42_FONT ) { nSFTErr = CreateT42FromTTGlyphs( mpSftTTFont, mpOutFile, mpReqFontName, @@ -150,7 +150,7 @@ bool FontSubsetInfo::CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths ) // TODO: move functionality from callers here } - return (nSFTErr != vcl::SF_OK); + return (nSFTErr != vcl::SFErrCodes::Ok); } // TODO: replace dummy implementation diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index bcb1ba251132..dfe167b9f901 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -1375,36 +1375,37 @@ static void allocTrueTypeFont( TrueTypeFont** ttf ) } /* forward declaration for the two entry points to use*/ -static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ); +static SFErrCodes doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ); #if !defined(_WIN32) -int OpenTTFontFile( const char* fname, sal_uInt32 facenum, TrueTypeFont** ttf ) +SFErrCodes OpenTTFontFile( const char* fname, sal_uInt32 facenum, TrueTypeFont** ttf ) { - int ret, fd = -1; + SFErrCodes ret; + int fd = -1; struct stat st; - if (!fname || !*fname) return SF_BADFILE; + if (!fname || !*fname) return SFErrCodes::BadFile; allocTrueTypeFont( ttf ); if( ! *ttf ) - return SF_MEMORY; + return SFErrCodes::Memory; (*ttf)->fname = strdup(fname); if( ! (*ttf)->fname ) { - ret = SF_MEMORY; + ret = SFErrCodes::Memory; goto cleanup; } fd = open(fname, O_RDONLY); if (fd == -1) { - ret = SF_BADFILE; + ret = SFErrCodes::BadFile; goto cleanup; } if (fstat(fd, &st) == -1) { - ret = SF_FILEIO; + ret = SFErrCodes::FileIo; goto cleanup; } @@ -1415,12 +1416,12 @@ int OpenTTFontFile( const char* fname, sal_uInt32 facenum, TrueTypeFont** ttf ) * Size will be 0, but fonts smaller than 4 bytes would be broken anyway. */ if ((*ttf)->fsize == 0) { - ret = SF_BADFILE; + ret = SFErrCodes::BadFile; goto cleanup; } if (((*ttf)->ptr = static_cast<sal_uInt8 *>(mmap(nullptr, (*ttf)->fsize, PROT_READ, MAP_SHARED, fd, 0))) == MAP_FAILED) { - ret = SF_MEMORY; + ret = SFErrCodes::Memory; goto cleanup; } close(fd); @@ -1437,11 +1438,11 @@ cleanup: } #endif -int OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf) +SFErrCodes OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf) { allocTrueTypeFont( ttf ); if( *ttf == nullptr ) - return SF_MEMORY; + return SFErrCodes::Memory; (*ttf)->fname = nullptr; (*ttf)->fsize = nLen; @@ -1480,12 +1481,12 @@ public: } -static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) +static SFErrCodes doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) { TTFontCloser aCloseGuard(t); if (t->fsize < 4) { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } int i; sal_uInt32 length, tag; @@ -1499,18 +1500,18 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) tdoffset = 0; } else if (TTCTag == T_ttcf) { /* TrueType collection */ if (!withinBounds(12, 4 * facenum, sizeof(sal_uInt32), t->fsize)) { - return SF_FONTNO; + return SFErrCodes::FontNo; } sal_uInt32 Version = GetUInt32(t->ptr, 4); if (Version != 0x00010000 && Version != 0x00020000) { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } if (facenum >= GetUInt32(t->ptr, 8)) { - return SF_FONTNO; + return SFErrCodes::FontNo; } tdoffset = GetUInt32(t->ptr, 12 + 4 * facenum); } else { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } if (withinBounds(tdoffset, 0, 4 + sizeof(sal_uInt16), t->fsize)) { @@ -1518,7 +1519,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) } if (t->ntables >= 128 || t->ntables == 0) { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } t->tables = static_cast<const sal_uInt8**>(calloc(NUM_TAGS, sizeof(sal_uInt8 *))); @@ -1568,7 +1569,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) if( facenum == sal_uInt32(~0) ) { sal_uInt8* pHead = const_cast<sal_uInt8*>(t->tables[O_head]); if (!pHead) { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } /* limit Head candidate to TTC extract's limits */ if( pHead > t->ptr + (t->fsize - 54) ) @@ -1586,7 +1587,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) } } if (p <= t->ptr) { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } } @@ -1627,7 +1628,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) */ if( !(getTable(t, O_maxp) && getTable(t, O_head) && getTable(t, O_name) && getTable(t, O_cmap)) ) { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } const sal_uInt8* table = getTable(t, O_maxp); @@ -1637,13 +1638,13 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) table = getTable(t, O_head); table_size = getTableSize(t, O_head); if (table_size < 52) { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } t->unitsPerEm = GetUInt16(table, 18); int indexfmt = GetInt16(table, 50); if( ((indexfmt != 0) && (indexfmt != 1)) || (t->unitsPerEm <= 0) ) { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } if( getTable(t, O_glyf) && getTable(t, O_loca) ) /* TTF or TTF-OpenType */ @@ -1666,7 +1667,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) /* TODO: implement to get subsetting */ assert(t->goffsets != nullptr); } else { - return SF_TTFORMAT; + return SFErrCodes::TtFormat; } table = getTable(t, O_hhea); @@ -1682,7 +1683,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) aCloseGuard.clear(); - return SF_OK; + return SFErrCodes::Ok; } void CloseTTFont(TrueTypeFont *ttf) @@ -1755,7 +1756,7 @@ int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal return n; } -int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, +SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode) { @@ -1813,8 +1814,8 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, const char * const h41 = "(%s) cvn exch definefont pop\n"; - if (!((nGlyphs > 0) && (nGlyphs <= 256))) return SF_GLYPHNUM; - if (!glyphArray) return SF_BADARG; + if (!((nGlyphs > 0) && (nGlyphs <= 256))) return SFErrCodes::GlyphNum; + if (!glyphArray) return SFErrCodes::BadArg; if (!fname) fname = ttf->psname; fprintf(outf, h01, GetInt16(table, 0), GetUInt16(table, 2), GetInt16(table, 4), GetUInt16(table, 6)); @@ -1904,10 +1905,10 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, fprintf(outf, "%s", h40); fprintf(outf, h41, fname); - return SF_OK; + return SFErrCodes::Ok; } -int CreateTTFromTTGlyphs(TrueTypeFont *ttf, +SFErrCodes CreateTTFromTTGlyphs(TrueTypeFont *ttf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 const *encoding, @@ -1916,7 +1917,7 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, TrueTypeCreator *ttcr; TrueTypeTable *head=nullptr, *hhea=nullptr, *maxp=nullptr, *cvt=nullptr, *prep=nullptr, *glyf=nullptr, *fpgm=nullptr, *cmap=nullptr, *name=nullptr, *post = nullptr, *os2 = nullptr; int i; - int res; + SFErrCodes res; TrueTypeCreatorNewEmpty(T_true, &ttcr); @@ -1997,9 +1998,9 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, AddTable(ttcr, cvt ); AddTable(ttcr, prep); AddTable(ttcr, fpgm); AddTable(ttcr, post); AddTable(ttcr, os2); - if ((res = StreamToFile(ttcr, fname)) != SF_OK) { + if ((res = StreamToFile(ttcr, fname)) != SFErrCodes::Ok) { #if OSL_DEBUG_LEVEL > 1 - fprintf(stderr, "StreamToFile: error code: %d.\n", res); + fprintf(stderr, "StreamToFile: error code: %d.\n", int(res)); #endif } @@ -2155,7 +2156,7 @@ static void DumpSfnts(FILE *outf, sal_uInt8 *sfntP, sal_uInt32 sfntLen) free(offs); } -int CreateT42FromTTGlyphs(TrueTypeFont *ttf, +SFErrCodes CreateT42FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *psname, sal_uInt16 const *glyphArray, @@ -2165,7 +2166,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, TrueTypeCreator *ttcr; TrueTypeTable *head=nullptr, *hhea=nullptr, *maxp=nullptr, *cvt=nullptr, *prep=nullptr, *glyf=nullptr, *fpgm=nullptr; int i; - int res; + SFErrCodes res; sal_uInt32 ver, rev; @@ -2173,7 +2174,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, sal_uInt32 sfntLen; int UPEm = ttf->unitsPerEm; - if (nGlyphs >= 256) return SF_GLYPHNUM; + if (nGlyphs >= 256) return SFErrCodes::GlyphNum; assert(psname != nullptr); @@ -2224,7 +2225,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, AddTable(ttcr, head); AddTable(ttcr, hhea); AddTable(ttcr, maxp); AddTable(ttcr, cvt); AddTable(ttcr, prep); AddTable(ttcr, glyf); AddTable(ttcr, fpgm); - if ((res = StreamToMemory(ttcr, &sfntP, &sfntLen)) != SF_OK) { + if ((res = StreamToMemory(ttcr, &sfntP, &sfntLen)) != SFErrCodes::Ok) { TrueTypeCreatorDispose(ttcr); free(gID); return res; @@ -2264,7 +2265,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, TrueTypeCreatorDispose(ttcr); free(gID); free(sfntP); - return SF_OK; + return SFErrCodes::Ok; } #if defined(_WIN32) || defined(MACOSX) || defined(IOS) diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx index fd6703e5a0b7..0a6ca74b20db 100644 --- a/vcl/source/fontsubset/ttcr.cxx +++ b/vcl/source/fontsubset/ttcr.cxx @@ -161,12 +161,12 @@ void TrueTypeCreatorNewEmpty(sal_uInt32 tag, TrueTypeCreator **_this) *_this = ptr; } -int AddTable(TrueTypeCreator *_this, TrueTypeTable *table) +SFErrCodes AddTable(TrueTypeCreator *_this, TrueTypeTable *table) { if (table != nullptr) { listAppend(_this->tables, table); } - return SF_OK; + return SFErrCodes::Ok; } void RemoveTable(TrueTypeCreator *_this, sal_uInt32 tag) @@ -193,14 +193,14 @@ void RemoveTable(TrueTypeCreator *_this, sal_uInt32 tag) static void ProcessTables(TrueTypeCreator *); -int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) +SFErrCodes StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) { sal_uInt16 searchRange=1, entrySelector=0, rangeShift; sal_uInt32 s, offset, checkSumAdjustment = 0; sal_uInt32 *p; sal_uInt8 *head = nullptr; /* saved pointer to the head table data for checkSumAdjustment calculation */ - if (listIsEmpty(_this->tables)) return SF_TTFORMAT; + if (listIsEmpty(_this->tables)) return SFErrCodes::TtFormat; ProcessTables(_this); @@ -269,29 +269,29 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) *ptr = ttf; *length = s; - return SF_OK; + return SFErrCodes::Ok; } -int StreamToFile(TrueTypeCreator *_this, const char* fname) +SFErrCodes StreamToFile(TrueTypeCreator *_this, const char* fname) { sal_uInt8 *ptr; sal_uInt32 length; - int r; + SFErrCodes r; FILE* fd; - if ((r = StreamToMemory(_this, &ptr, &length)) != SF_OK) return r; + if ((r = StreamToMemory(_this, &ptr, &length)) != SFErrCodes::Ok) return r; if (fname && (fd = fopen(fname, "wb")) != nullptr) { if (fwrite(ptr, 1, length, fd) != length) { - r = SF_FILEIO; + r = SFErrCodes::FileIo; } else { - r = SF_OK; + r = SFErrCodes::Ok; } fclose(fd); } else { - r = SF_BADFILE; + r = SFErrCodes::BadFile; } free(ptr); return r; diff --git a/vcl/source/fontsubset/ttcr.hxx b/vcl/source/fontsubset/ttcr.hxx index a5a28e612652..5acd5230ecd8 100644 --- a/vcl/source/fontsubset/ttcr.hxx +++ b/vcl/source/fontsubset/ttcr.hxx @@ -64,10 +64,10 @@ namespace vcl /** * Adds a TrueType table to the TrueType creator. - * SF_TABLEFORMAT value. + * SFErrCodes::TableFormat value. * @return value of SFErrCodes type */ - int AddTable(TrueTypeCreator *_this, TrueTypeTable *table); + SFErrCodes AddTable(TrueTypeCreator *_this, TrueTypeTable *table); /** * Removes a TrueType table from the TrueType creator if it is stored there. @@ -84,13 +84,13 @@ namespace vcl * is supposed to call free() on it. * @return value of SFErrCodes type */ - int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length); + SFErrCodes StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length); /** * Writes a TrueType font generated by the TrueTypeCreator to a file * @return value of SFErrCodes type */ - int StreamToFile(TrueTypeCreator *_this, const char* fname); + SFErrCodes StreamToFile(TrueTypeCreator *_this, const char* fname); /** * This function converts the data of a TrueType table to a raw array of bytes. diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx index ca744e70d850..55ff565988b8 100644 --- a/vcl/source/gdi/embeddedfontshelper.cxx +++ b/vcl/source/gdi/embeddedfontshelper.cxx @@ -189,7 +189,7 @@ void EmbeddedFontsHelper::activateFont( const OUString& fontName, const OUString bool EmbeddedFontsHelper::sufficientTTFRights( const void* data, long size, FontRights rights ) { TrueTypeFont* font; - if( OpenTTFontBuffer( data, size, 0 /*TODO*/, &font ) == SF_OK ) + if( OpenTTFontBuffer( data, size, 0 /*TODO*/, &font ) == SFErrCodes::Ok ) { TTGlobalFontInfo info; GetTTGlobalFontInfo( font, &info ); diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx index 390158e48cf8..460a07c3c145 100644 --- a/vcl/unx/generic/fontmanager/fontmanager.cxx +++ b/vcl/unx/generic/fontmanager/fontmanager.cxx @@ -562,7 +562,7 @@ bool PrintFontManager::analyzeSfntFile( PrintFont* pFont ) const OString aFile = getFontFile( pFont ); TrueTypeFont* pTTFont = nullptr; - if( OpenTTFontFile( aFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) == SF_OK ) + if( OpenTTFontFile( aFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) == SFErrCodes::Ok ) { TTGlobalFontInfo aInfo; GetTTGlobalFontInfo( pTTFont, & aInfo ); @@ -1018,7 +1018,7 @@ bool PrintFontManager::createFontSubset( const OString aFromFile = getFontFile( pFont ); TrueTypeFont* pTTFont = nullptr; // TODO: rename to SfntFont - if( OpenTTFontFile( aFromFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) != SF_OK ) + if( OpenTTFontFile( aFromFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) != SFErrCodes::Ok ) return false; // prepare system name for write access for subset file target @@ -1097,7 +1097,7 @@ bool PrintFontManager::createFontSubset( return false; } - bool bSuccess = ( SF_OK == CreateTTFromTTGlyphs( pTTFont, + bool bSuccess = ( SFErrCodes::Ok == CreateTTFromTTGlyphs( pTTFont, aToFile.getStr(), pGID, pEnc, @@ -1117,7 +1117,7 @@ void PrintFontManager::getGlyphWidths( fontID nFont, return; TrueTypeFont* pTTFont = nullptr; OString aFromFile = getFontFile( pFont ); - if( OpenTTFontFile( aFromFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) != SF_OK ) + if( OpenTTFontFile( aFromFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) != SFErrCodes::Ok ) return; int nGlyphs = GetTTGlyphCount(pTTFont); if (nGlyphs > 0) diff --git a/vcl/unx/generic/print/glyphset.cxx b/vcl/unx/generic/print/glyphset.cxx index 9dacabb7dfb0..f688cb252dc1 100644 --- a/vcl/unx/generic/print/glyphset.cxx +++ b/vcl/unx/generic/print/glyphset.cxx @@ -249,8 +249,8 @@ GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAllowType42 TrueTypeFont *pTTFont; OString aTTFileName (rGfx.GetFontMgr().getFontFileSysPath(mnFontID)); int nFace = rGfx.GetFontMgr().getFontFaceNumber(mnFontID); - sal_Int32 nSuccess = OpenTTFontFile(aTTFileName.getStr(), nFace, &pTTFont); - if (nSuccess != SF_OK) + SFErrCodes nSuccess = OpenTTFontFile(aTTFileName.getStr(), nFace, &pTTFont); + if (nSuccess != SFErrCodes::Ok) return; utl::TempFile aTmpFile; diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 2d6512154e2a..1313778ccebb 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1613,7 +1613,7 @@ public: ~ScopedTrueTypeFont(); - int open(void const * pBuffer, sal_uInt32 nLen, sal_uInt32 nFaceNum); + SFErrCodes open(void const * pBuffer, sal_uInt32 nLen, sal_uInt32 nFaceNum); TrueTypeFont * get() const { return m_pFont; } @@ -1627,7 +1627,7 @@ ScopedTrueTypeFont::~ScopedTrueTypeFont() CloseTTFont(m_pFont); } -int ScopedTrueTypeFont::open(void const * pBuffer, sal_uInt32 nLen, +SFErrCodes ScopedTrueTypeFont::open(void const * pBuffer, sal_uInt32 nLen, sal_uInt32 nFaceNum) { OSL_ENSURE(m_pFont == nullptr, "already open"); @@ -1698,8 +1698,8 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, nFaceNum = ~0U; // indicate "TTC font extracts only" ScopedTrueTypeFont aSftTTF; - int nRC = aSftTTF.open( xRawFontData.get(), xRawFontData.size(), nFaceNum ); - if( nRC != SF_OK ) + SFErrCodes nRC = aSftTTF.open( xRawFontData.get(), xRawFontData.size(), nFaceNum ); + if( nRC != SFErrCodes::Ok ) return FALSE; TTGlobalFontInfo aTTInfo; @@ -1757,7 +1757,7 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, // write subset into destination file nRC = ::CreateTTFromTTGlyphs( aSftTTF.get(), aToFile.getStr(), aShortIDs, aTempEncs, nGlyphCount ); - return (nRC == SF_OK); + return (nRC == SFErrCodes::Ok); } const void* WinSalGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen) @@ -1811,8 +1811,8 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont, nFaceNum = ~0U; // indicate "TTC font extracts only" ScopedTrueTypeFont aSftTTF; - int nRC = aSftTTF.open( xRawFontData.get(), xRawFontData.size(), nFaceNum ); - if( nRC != SF_OK ) + SFErrCodes nRC = aSftTTF.open( xRawFontData.get(), xRawFontData.size(), nFaceNum ); + if( nRC != SFErrCodes::Ok ) return; int nGlyphs = GetTTGlyphCount( aSftTTF.get() ); |