Kaydet (Commit) 78706545 authored tarafından Noel Grandin's avatar Noel Grandin

convert FONTTOSUBSFONT constants to scoped enum

Change-Id: I994bfc76d709d01406404991dbfbd49b15bd03f4
üst 60e659ae
...@@ -1160,7 +1160,7 @@ void EditTextObjectImpl::StoreData( SvStream& rOStream ) const ...@@ -1160,7 +1160,7 @@ void EditTextObjectImpl::StoreData( SvStream& rOStream ) const
} }
// Convert StarSymbol back to StarBats // Convert StarSymbol back to StarBats
FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_EXPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FontToSubsFontFlags::EXPORT | FontToSubsFontFlags::ONLYOLDSOSYMBOLFONTS );
if ( hConv ) if ( hConv )
{ {
// Don't create a new Attrib with StarBats font, MBR changed the // Don't create a new Attrib with StarBats font, MBR changed the
...@@ -1184,7 +1184,7 @@ void EditTextObjectImpl::StoreData( SvStream& rOStream ) const ...@@ -1184,7 +1184,7 @@ void EditTextObjectImpl::StoreData( SvStream& rOStream ) const
FontToSubsFontConverter hConv = NULL; FontToSubsFontConverter hConv = NULL;
if (rC.GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SfxItemState::SET) if (rC.GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SfxItemState::SET)
{ {
hConv = CreateFontToSubsFontConverter( static_cast<const SvxFontItem&>(rC.GetParaAttribs().Get( EE_CHAR_FONTINFO )).GetFamilyName(), FONTTOSUBSFONT_EXPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); hConv = CreateFontToSubsFontConverter( static_cast<const SvxFontItem&>(rC.GetParaAttribs().Get( EE_CHAR_FONTINFO )).GetFamilyName(), FontToSubsFontFlags::EXPORT | FontToSubsFontFlags::ONLYOLDSOSYMBOLFONTS );
} }
if ( hConv ) if ( hConv )
{ {
...@@ -1411,7 +1411,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream ) ...@@ -1411,7 +1411,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
} }
// Convert StarMath and StarBats to StarSymbol // Convert StarMath and StarBats to StarSymbol
FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_IMPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FontToSubsFontFlags::IMPORT | FontToSubsFontFlags::ONLYOLDSOSYMBOLFONTS );
if ( hConv ) if ( hConv )
{ {
SvxFontItem aNewFontItem( rFontItem ); SvxFontItem aNewFontItem( rFontItem );
...@@ -1444,7 +1444,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream ) ...@@ -1444,7 +1444,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
if ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SfxItemState::SET ) if ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SfxItemState::SET )
{ {
const SvxFontItem& rFontItem = static_cast<const SvxFontItem&>(pC->GetParaAttribs().Get( EE_CHAR_FONTINFO )); const SvxFontItem& rFontItem = static_cast<const SvxFontItem&>(pC->GetParaAttribs().Get( EE_CHAR_FONTINFO ));
FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_IMPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FontToSubsFontFlags::IMPORT | FontToSubsFontFlags::ONLYOLDSOSYMBOLFONTS );
if ( hConv ) if ( hConv )
{ {
SvxFontItem aNewFontItem( rFontItem ); SvxFontItem aNewFontItem( rFontItem );
......
...@@ -697,7 +697,7 @@ SvStream& SvxNumRule::Store( SvStream &rStream ) ...@@ -697,7 +697,7 @@ SvStream& SvxNumRule::Store( SvStream &rStream )
if(!pConverter) if(!pConverter)
pConverter = pConverter =
CreateFontToSubsFontConverter(aFmts[i]->GetBulletFont()->GetName(), CreateFontToSubsFontConverter(aFmts[i]->GetBulletFont()->GetName(),
FONTTOSUBSFONT_EXPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS); FontToSubsFontFlags::EXPORT|FontToSubsFontFlags::ONLYOLDSOSYMBOLFONTS);
} }
aFmts[i]->Store(rStream, pConverter); aFmts[i]->Store(rStream, pConverter);
} }
......
...@@ -23,15 +23,23 @@ ...@@ -23,15 +23,23 @@
#include <unotools/unotoolsdllapi.h> #include <unotools/unotoolsdllapi.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <tools/solar.h> #include <tools/solar.h>
#include <o3tl/typed_flags_set.hxx>
// - FontToSubsFont - // - FontToSubsFont -
#define FONTTOSUBSFONT_IMPORT ((sal_uLong)0x00000001) enum class FontToSubsFontFlags
#define FONTTOSUBSFONT_EXPORT ((sal_uLong)0x00000002) {
#define FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ((sal_uLong)0x00000004) IMPORT = 0x01,
EXPORT = 0x02,
ONLYOLDSOSYMBOLFONTS = 0x04,
};
namespace o3tl
{
template<> struct typed_flags<FontToSubsFontFlags> : is_typed_flags<FontToSubsFontFlags, 0x07> {};
}
typedef void* FontToSubsFontConverter; typedef void* FontToSubsFontConverter;
UNOTOOLS_DLLPUBLIC FontToSubsFontConverter CreateFontToSubsFontConverter( const OUString& rFontName, sal_uLong nFlags ); UNOTOOLS_DLLPUBLIC FontToSubsFontConverter CreateFontToSubsFontConverter( const OUString& rFontName, FontToSubsFontFlags nFlags );
UNOTOOLS_DLLPUBLIC void DestroyFontToSubsFontConverter( FontToSubsFontConverter hConverter ); UNOTOOLS_DLLPUBLIC void DestroyFontToSubsFontConverter( FontToSubsFontConverter hConverter );
UNOTOOLS_DLLPUBLIC sal_Unicode ConvertFontToSubsFontChar( FontToSubsFontConverter hConverter, sal_Unicode c ); UNOTOOLS_DLLPUBLIC sal_Unicode ConvertFontToSubsFontChar( FontToSubsFontConverter hConverter, sal_Unicode c );
UNOTOOLS_DLLPUBLIC OUString GetFontToSubsFontName( FontToSubsFontConverter hConverter ); UNOTOOLS_DLLPUBLIC OUString GetFontToSubsFontName( FontToSubsFontConverter hConverter );
...@@ -65,6 +73,7 @@ public: ...@@ -65,6 +73,7 @@ public:
//The users of this might want to make a distinction between failed characters //The users of this might want to make a distinction between failed characters
//which were inside and those outside the unicode private area. //which were inside and those outside the unicode private area.
UNOTOOLS_DLLPUBLIC StarSymbolToMSMultiFont *CreateStarSymbolToMSMultiFont(bool bPerfectOnly=false); UNOTOOLS_DLLPUBLIC StarSymbolToMSMultiFont *CreateStarSymbolToMSMultiFont(bool bPerfectOnly=false);
#endif // INCLUDED_UNOTOOLS_FONTCVT_HXX #endif // INCLUDED_UNOTOOLS_FONTCVT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1455,29 +1455,34 @@ const ConvertChar* ConvertChar::GetRecodeData( const OUString& rOrgFontName, con ...@@ -1455,29 +1455,34 @@ const ConvertChar* ConvertChar::GetRecodeData( const OUString& rOrgFontName, con
return pCvt; return pCvt;
} }
FontToSubsFontConverter CreateFontToSubsFontConverter( const OUString& rOrgName, sal_uLong nFlags ) FontToSubsFontConverter CreateFontToSubsFontConverter( const OUString& rOrgName, FontToSubsFontFlags nFlags )
{ {
const ConvertChar* pCvt = NULL; const ConvertChar* pCvt = NULL;
OUString aName = GetEnglishSearchFontName( rOrgName ); OUString aName = GetEnglishSearchFontName( rOrgName );
if ( nFlags & FONTTOSUBSFONT_IMPORT ) if ( nFlags & FontToSubsFontFlags::IMPORT )
{ {
int nEntries = SAL_N_ELEMENTS(aStarSymbolRecodeTable); int nEntries = SAL_N_ELEMENTS(aStarSymbolRecodeTable);
if ( nFlags & FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ) // only StarMath+StarBats if ( nFlags & FontToSubsFontFlags::ONLYOLDSOSYMBOLFONTS ) // only StarMath+StarBats
nEntries = 2; nEntries = 2;
for( int i = 0; i < nEntries; ++i ) for( int i = 0; i < nEntries; ++i )
{ {
const RecodeTable& r = aStarSymbolRecodeTable[i]; const RecodeTable& r = aStarSymbolRecodeTable[i];
if( aName.equalsAscii( r.pOrgName ) ) if( aName.equalsAscii( r.pOrgName ) )
{ pCvt = &r.aCvt; break; } {
pCvt = &r.aCvt;
break;
}
} }
} }
else else
{ {
// TODO: FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS // TODO: FontToSubsFontFlags::ONLYOLDSOSYMBOLFONTS
if( aName == "starsymbol" ) pCvt = &aImplStarSymbolCvt; if( aName == "starsymbol" )
else if( aName == "opensymbol" ) pCvt = &aImplStarSymbolCvt; pCvt = &aImplStarSymbolCvt;
else if( aName == "opensymbol" )
pCvt = &aImplStarSymbolCvt;
} }
return (FontToSubsFontConverter)pCvt; return (FontToSubsFontConverter)pCvt;
......
...@@ -1739,7 +1739,7 @@ sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c ) ...@@ -1739,7 +1739,7 @@ sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c )
{ {
OUString sStarBats( "StarBats" ); OUString sStarBats( "StarBats" );
mpImpl->hBatsFontConv = CreateFontToSubsFontConverter( sStarBats, mpImpl->hBatsFontConv = CreateFontToSubsFontConverter( sStarBats,
FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); FontToSubsFontFlags::IMPORT|FontToSubsFontFlags::ONLYOLDSOSYMBOLFONTS );
SAL_WARN_IF( !mpImpl->hBatsFontConv, "xmloff.core", "Got no symbol font converter" ); SAL_WARN_IF( !mpImpl->hBatsFontConv, "xmloff.core", "Got no symbol font converter" );
} }
if( mpImpl->hBatsFontConv ) if( mpImpl->hBatsFontConv )
...@@ -1757,7 +1757,7 @@ sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c ) ...@@ -1757,7 +1757,7 @@ sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c )
{ {
OUString sStarMath( "StarMath" ); OUString sStarMath( "StarMath" );
mpImpl->hMathFontConv = CreateFontToSubsFontConverter( sStarMath, mpImpl->hMathFontConv = CreateFontToSubsFontConverter( sStarMath,
FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); FontToSubsFontFlags::IMPORT|FontToSubsFontFlags::ONLYOLDSOSYMBOLFONTS );
SAL_WARN_IF( !mpImpl->hMathFontConv, "xmloff.core", "Got no symbol font converter" ); SAL_WARN_IF( !mpImpl->hMathFontConv, "xmloff.core", "Got no symbol font converter" );
} }
if( mpImpl->hMathFontConv ) if( mpImpl->hMathFontConv )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment