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

convert FONT_SUBSTITUTE constants to scoped enum

Change-Id: I8312f0117f33349218a09ccdfea946c66ceb1b3e
üst 456c379f
......@@ -266,9 +266,17 @@ namespace o3tl
template<> struct typed_flags<AntialiasingFlags> : is_typed_flags<AntialiasingFlags, 0x07> {};
}
// AddFontSubstitute
#define FONT_SUBSTITUTE_ALWAYS ((sal_uInt16)0x0001)
#define FONT_SUBSTITUTE_SCREENONLY ((sal_uInt16)0x0002)
// AddFontSubstitute() flags
enum class AddFontSubstituteFlags
{
NONE = 0x00,
ALWAYS = 0x01,
ScreenOnly = 0x02,
};
namespace o3tl
{
template<> struct typed_flags<AddFontSubstituteFlags> : is_typed_flags<AddFontSubstituteFlags, 0x03> {};
}
#define DEFAULTFONT_FLAGS_ONLYONE ((sal_uLong)0x00000001)
......@@ -1259,7 +1267,7 @@ public:
static void EndFontSubstitution();
static void AddFontSubstitute( const OUString& rFontName,
const OUString& rReplaceFontName,
sal_uInt16 nFlags = 0 );
AddFontSubstituteFlags nFlags = AddFontSubstituteFlags::NONE );
static void RemoveFontSubstitute( sal_uInt16 n );
static sal_uInt16 GetFontSubstituteCount();
......
......@@ -178,12 +178,12 @@ void SvtFontSubstConfig::Apply()
for (sal_Int32 i = 0; i < nCount; i++)
{
sal_uInt16 nFlags = 0;
AddFontSubstituteFlags nFlags = AddFontSubstituteFlags::NONE;
const SubstitutionStruct* pSubs = GetSubstitution(i);
if(pSubs->bReplaceAlways)
nFlags |= FONT_SUBSTITUTE_ALWAYS;
nFlags |= AddFontSubstituteFlags::ALWAYS;
if(pSubs->bReplaceOnScreenOnly)
nFlags |= FONT_SUBSTITUTE_SCREENONLY;
nFlags |= AddFontSubstituteFlags::ScreenOnly;
OutputDevice::AddFontSubstitute( pSubs->sFont, pSubs->sReplaceBy, nFlags );
}
......
......@@ -36,6 +36,8 @@ class VirtualDevice;
class ImplGetDevFontList;
class GetDevSizeList;
class PhysicalFontCollection;
enum class AddFontSubstituteFlags;
// an ImplGetDevFontList is created by an PhysicalFontCollection
// it becomes invalid when original PhysicalFontCollection is modified
class ImplGetDevFontList
......@@ -90,9 +92,9 @@ struct ImplFontSubstEntry
OUString maReplaceName;
OUString maSearchName;
OUString maSearchReplaceName;
sal_uInt16 mnFlags;
AddFontSubstituteFlags mnFlags;
ImplFontSubstEntry( const OUString& rFontName, const OUString& rSubstFontName, sal_uInt16 nSubstFlags );
ImplFontSubstEntry( const OUString& rFontName, const OUString& rSubstFontName, AddFontSubstituteFlags nSubstFlags );
};
class ImplDirectFontSubstitution
......@@ -102,13 +104,13 @@ private:
typedef std::list<ImplFontSubstEntry> FontSubstList;
FontSubstList maFontSubstList;
public:
void AddFontSubstitute( const OUString& rFontName, const OUString& rSubstName, sal_uInt16 nFlags );
void AddFontSubstitute( const OUString& rFontName, const OUString& rSubstName, AddFontSubstituteFlags nFlags );
void RemoveFontSubstitute( int nIndex );
int GetFontSubstituteCount() const { return maFontSubstList.size(); };
bool Empty() const { return maFontSubstList.empty(); }
void Clear() { maFontSubstList.clear(); }
bool FindFontSubstitute( OUString& rSubstName, const OUString& rFontName, sal_uInt16 nFlags ) const;
bool FindFontSubstitute( OUString& rSubstName, const OUString& rFontName, AddFontSubstituteFlags nFlags ) const;
};
// PreMatchFontSubstitution
......
......@@ -687,7 +687,7 @@ void OutputDevice::EndFontSubstitution()
void OutputDevice::AddFontSubstitute( const OUString& rFontName,
const OUString& rReplaceFontName,
sal_uInt16 nFlags )
AddFontSubstituteFlags nFlags )
{
ImplDirectFontSubstitution*& rpSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst;
if( !rpSubst )
......@@ -697,13 +697,13 @@ void OutputDevice::AddFontSubstitute( const OUString& rFontName,
}
void ImplDirectFontSubstitution::AddFontSubstitute( const OUString& rFontName,
const OUString& rSubstFontName, sal_uInt16 nFlags )
const OUString& rSubstFontName, AddFontSubstituteFlags nFlags )
{
maFontSubstList.push_back( ImplFontSubstEntry( rFontName, rSubstFontName, nFlags ) );
}
ImplFontSubstEntry::ImplFontSubstEntry( const OUString& rFontName,
const OUString& rSubstFontName, sal_uInt16 nSubstFlags )
const OUString& rSubstFontName, AddFontSubstituteFlags nSubstFlags )
: maName( rFontName )
, maReplaceName( rSubstFontName )
, mnFlags( nSubstFlags )
......@@ -737,14 +737,14 @@ sal_uInt16 OutputDevice::GetFontSubstituteCount()
}
bool ImplDirectFontSubstitution::FindFontSubstitute( OUString& rSubstName,
const OUString& rSearchName, sal_uInt16 nFlags ) const
const OUString& rSearchName, AddFontSubstituteFlags nFlags ) const
{
// TODO: get rid of O(N) searches
FontSubstList::const_iterator it = maFontSubstList.begin();
for(; it != maFontSubstList.end(); ++it )
{
const ImplFontSubstEntry& rEntry = *it;
if( ((rEntry.mnFlags & nFlags) || !nFlags)
if( ((rEntry.mnFlags & nFlags) || nFlags == AddFontSubstituteFlags::NONE)
&& (rEntry.maSearchName == rSearchName) )
{
rSubstName = rEntry.maSearchReplaceName;
......@@ -764,7 +764,7 @@ void ImplFontSubstitute( OUString& rFontName )
// apply user-configurable font replacement (eg, from the list in Tools->Options)
const ImplDirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst;
if( pSubst && pSubst->FindFontSubstitute( aSubstFontName, rFontName, FONT_SUBSTITUTE_ALWAYS ) )
if( pSubst && pSubst->FindFontSubstitute( aSubstFontName, rFontName, AddFontSubstituteFlags::ALWAYS ) )
{
rFontName = aSubstFontName;
return;
......
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