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