1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
|
/*--------------------------------------------------------------------*//*:Ignore this sentence.
Copyright (C) 1999, 2001 SIL International. All rights reserved.
Distributable under the terms of either the Common Public License or the
GNU Lesser General Public License, as specified in the LICENSING.txt file.
File: GdlGlyphClass.cpp
Responsibility: Sharon Correll
Last reviewed: Not yet.
Description:
Implements definitions of classes of glyphs..
-------------------------------------------------------------------------------*//*:End Ignore*/
/***********************************************************************************************
Include files
***********************************************************************************************/
#include "main.h"
#ifdef _MSC_VER
#pragma hdrstop
#endif
#undef THIS_FILE
DEFINE_THIS_FILE
/***********************************************************************************************
Forward declarations
***********************************************************************************************/
/***********************************************************************************************
Local Constants and static variables
***********************************************************************************************/
// None
/***********************************************************************************************
Methods: Destruction
***********************************************************************************************/
GdlGlyphClassDefn::~GdlGlyphClassDefn()
{
for (size_t i = 0; i < m_vpglfaAttrs.size(); ++i)
delete m_vpglfaAttrs[i];
}
void GdlGlyphClassDefn::DeleteGlyphDefns()
{
for (size_t i = 0; i < m_vpglfdMembers.size(); ++i)
{
if (dynamic_cast<GdlGlyphDefn * >(m_vpglfdMembers[i]))
delete m_vpglfdMembers[i];
}
}
/***********************************************************************************************
Methods: Post-parser
***********************************************************************************************/
/*----------------------------------------------------------------------------------------------
Add a simple glyph to the class.
----------------------------------------------------------------------------------------------*/
GdlGlyphClassMember * GdlGlyphClassDefn::AddGlyphToClass(GrpLineAndFile const& lnf,
GlyphType glft, int nFirst)
{
GdlGlyphDefn * pglf = new GdlGlyphDefn(glft, nFirst);
pglf->SetLineAndFile(lnf);
AddMember(pglf, lnf);
return pglf;
}
GdlGlyphClassMember * GdlGlyphClassDefn::AddGlyphToClass(GrpLineAndFile const& lnf,
GlyphType glft, int nFirst, int nLast)
{
GdlGlyphDefn * pglf = new GdlGlyphDefn(glft, nFirst, nLast);
pglf->SetLineAndFile(lnf);
AddMember(pglf, lnf);
return pglf;
}
GdlGlyphClassMember * GdlGlyphClassDefn::AddGlyphToClass(GrpLineAndFile const& lnf,
GlyphType glft, int nFirst, int nLast, utf16 wCodePage)
{
GdlGlyphDefn * pglf = new GdlGlyphDefn(glft, nFirst, nLast, wCodePage);
pglf->SetLineAndFile(lnf);
AddMember(pglf, lnf);
return pglf;
}
GdlGlyphClassMember * GdlGlyphClassDefn::AddGlyphToClass(GrpLineAndFile const& lnf,
GlyphType glft, std::string staPostscript)
{
GdlGlyphDefn * pglf = new GdlGlyphDefn(glft, staPostscript);
pglf->SetLineAndFile(lnf);
AddMember(pglf, lnf);
return pglf;
}
GdlGlyphClassMember * GdlGlyphClassDefn::AddGlyphToClass(GrpLineAndFile const& lnf,
GlyphType glft, std::string staCodepoints, utf16 wCodePage)
{
GdlGlyphDefn * pglf = new GdlGlyphDefn(glft, staCodepoints, wCodePage);
pglf->SetLineAndFile(lnf);
AddMember(pglf, lnf);
return pglf;
}
GdlGlyphClassMember * GdlGlyphClassDefn::AddGlyphToClass(GrpLineAndFile const& lnf,
GlyphType glft, GdlGlyphDefn * pglfOutput, utf16 wPseudoInput)
{
GdlGlyphDefn * pglf = new GdlGlyphDefn(glft, pglfOutput, (int)wPseudoInput);
pglf->SetLineAndFile(lnf);
AddMember(pglf, lnf);
return pglf;
}
GdlGlyphClassMember * GdlGlyphClassDefn::AddGlyphToClass(GrpLineAndFile const& lnf,
GlyphType glft, GdlGlyphDefn * pglfOutput)
{
GdlGlyphDefn * pglf = new GdlGlyphDefn(glft, pglfOutput);
pglf->SetLineAndFile(lnf);
AddMember(pglf, lnf);
return pglf;
}
GdlGlyphClassMember * GdlGlyphClassDefn::AddClassToClass(GrpLineAndFile const& lnf,
GdlGlyphClassDefn * pglfcMember)
{
AddMember(pglfcMember, lnf);
return pglfcMember;
}
/*----------------------------------------------------------------------------------------------
Add a member to the class.
----------------------------------------------------------------------------------------------*/
void GdlGlyphClassDefn::AddMember(GdlGlyphClassMember * pglfd, GrpLineAndFile const& lnf)
{
Assert(m_vpglfdMembers.size() == m_vlnfMembers.size());
m_vpglfdMembers.push_back(pglfd);
m_vlnfMembers.push_back(lnf);
}
/*----------------------------------------------------------------------------------------------
Add a user-defined glyph attribute to the list. Note that we shouldn't have to check
for duplicates, due to the way the master glyph attribute list is managed (see
GrcMasterTable::AddItem(...)).
----------------------------------------------------------------------------------------------*/
void GdlGlyphClassDefn::AddGlyphAttr(Symbol psym, GdlAssignment * pasgn)
{
GdlGlyphAttrSetting * pglfa = new GdlGlyphAttrSetting(psym, pasgn);
pglfa->SetLineAndFile(pasgn->LineAndFile());
m_vpglfaAttrs.push_back(pglfa);
}
/*----------------------------------------------------------------------------------------------
Add an attribute of the form component.<compname>.<corner>. Note that we shouldn't have
to check for duplicates, due to the way the master glyph attribute list is managed
(see GrcMasterTable::AddItem(...)).
----------------------------------------------------------------------------------------------*/
void GdlGlyphClassDefn::AddComponent(Symbol psym, GdlAssignment * pasgn)
{
AddGlyphAttr(psym, pasgn);
// Add this component to the list.
// std::string staCompName = psym->FieldAt(2);
// m_vstaComponentNames.Push(staCompName);
// GdlGlyphAttrSetting * pglfa = new RldGlyphAttrSetting(psym, pasgn);
// m_vglfaComponents.Push(pglfa);
}
/*----------------------------------------------------------------------------------------------
Return true if the given glyph is a member of the class.
----------------------------------------------------------------------------------------------*/
bool GdlGlyphClassDefn::IncludesGlyph(utf16 w)
{
for (size_t iglfd = 0; iglfd < m_vpglfdMembers.size(); iglfd++)
{
if (m_vpglfdMembers[iglfd]->IncludesGlyph(w))
return true;
}
return false;
}
/*----------------------------------------------------------------------------------------------
Return true if the class include a bad glyph definition
----------------------------------------------------------------------------------------------*/
bool GdlGlyphClassDefn::HasBadGlyph()
{
for (size_t iglfd = 0; iglfd < m_vpglfdMembers.size(); iglfd++)
{
if (m_vpglfdMembers[iglfd]->HasBadGlyph())
return true;
}
return false;
}
/*----------------------------------------------------------------------------------------------
Add this glyph's list of glyphs to the flat list.
Assumes method is called after list of glyphs is complete.
----------------------------------------------------------------------------------------------*/
void GdlGlyphClassDefn::FlattenGlyphList(std::vector<utf16> & vgidFlattened)
{
if (!m_fHasFlatList)
FlattenMyGlyphList();
for (size_t igid = 0; igid < m_vgidFlattened.size(); igid++)
{
vgidFlattened.push_back(m_vgidFlattened[igid]);
}
}
#if 0
/*----------------------------------------------------------------------------------------------
Set the directionality attribute.
----------------------------------------------------------------------------------------------*/
void GdlGlyphClassDefn::SetDirection(GdlExpression * pglfaDir, int nStmtNo, bool fAttrOverride)
{
if (m_pglfaDirection == NULL ||
(fAttrOverride && nStmtNo > m_pglfaDirection->LineNumber()))
{
m_pexpDirection = pglfaDir;
}
}
/*----------------------------------------------------------------------------------------------
Set the breakweight attribute.
----------------------------------------------------------------------------------------------*/
void GdlGlyphClassDefn::SetBreakweight(GdlExpression * pexpBw, int nStmtNo, bool fAttrOverride)
{
if (m_pexpBreakweight == NULL || (fAttrOverride && nStmtNo > m_nBwStmtNo))
m_pexpBreakweight = pexpBw;
}
#endif // 0
|