AtkAttributeSet * getDocumentAttributesCB(AtkDocument *aDocument) { nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument)); if (!accWrap || !accWrap->IsDoc()) return nsnull; // according to atkobject.h, AtkAttributeSet is a GSList GSList* attributes = nsnull; nsDocAccessible* document = accWrap->AsDoc(); nsAutoString aURL; nsresult rv = document->GetURL(aURL); if (NS_SUCCEEDED(rv)) attributes = prependToList(attributes, kDocUrlName, aURL); nsAutoString aW3CDocType; rv = document->GetDocType(aW3CDocType); if (NS_SUCCEEDED(rv)) attributes = prependToList(attributes, kDocTypeName, aW3CDocType); nsAutoString aMimeType; rv = document->GetMimeType(aMimeType); if (NS_SUCCEEDED(rv)) attributes = prependToList(attributes, kMimeTypeName, aMimeType); return attributes; }
AtkAttributeSet * getDocumentAttributesCB(AtkDocument *aDocument) { nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument)); if (!accWrap) return nsnull; nsCOMPtr<nsIAccessibleDocument> accDocument; accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument), getter_AddRefs(accDocument)); NS_ENSURE_TRUE(accDocument, nsnull); // according to atkobject.h, AtkAttributeSet is a GSList GSList *attributes = nsnull; nsAutoString aURL; nsresult rv = accDocument->GetURL(aURL); if (NS_SUCCEEDED(rv)) { attributes = prependToList(attributes, kDocUrlName, aURL); } nsAutoString aW3CDocType; rv = accDocument->GetDocType(aW3CDocType); if (NS_SUCCEEDED(rv)) { attributes = prependToList(attributes, kDocTypeName, aW3CDocType); } nsAutoString aMimeType; rv = accDocument->GetMimeType(aMimeType); if (NS_SUCCEEDED(rv)) { attributes = prependToList(attributes, kMimeTypeName, aMimeType); } return attributes; }
listPo replaceListEl(heapPo H, listPo list, integer px, termPo vl) { if (px >= listSize(list)) return appendToList(H, list, vl); else if (px < 0) return prependToList(H, list, vl); else { basePo base = C_BASE(list->base); int root = gcAddRoot(H, (ptrPo) (&base)); gcAddRoot(H, (ptrPo) (&list)); gcAddRoot(H, (ptrPo) (&vl)); integer delta = base->length / 8; basePo nb = copyBase(H, base, list->start, list->length, delta); nb->els[nb->min + px] = vl; gcAddRoot(H, (ptrPo) &nb); listPo slice = (listPo) newSlice(H, nb, nb->min, list->length); assert(saneList(H, slice)); gcReleaseRoot(H, root); releaseHeapLock(H); return slice; } }
listPo insertListEl(heapPo H, listPo list, integer px, termPo vl) { basePo base = C_BASE(list->base); if (px <= 0) return prependToList(H, list, vl); else if (px >= listSize(list)) return appendToList(H, list, vl); else { int root = gcAddRoot(H, (ptrPo) (&base)); gcAddRoot(H, (ptrPo) (&list)); gcAddRoot(H, (ptrPo) (&vl)); integer delta = base->length / 8; integer newLen = base->length + delta + 1; basePo nb = (basePo) allocateObject(H, baseClass, BaseCellCount(newLen)); integer ocount = list->length; assert(ocount >= 0); integer extra = newLen - ocount; nb->min = extra / 2 - 1; nb->max = nb->min + ocount + 1; nb->length = newLen; for (integer ix = 0; ix < px; ix++) { nb->els[nb->min + ix] = base->els[base->min + ix]; } nb->els[nb->min + px] = vl; for (integer ix = px; ix < ocount; ix++) { nb->els[nb->min + ix + 1] = base->els[base->min + ix]; } gcAddRoot(H, (ptrPo) (&nb)); listPo slice = (listPo) newSlice(H, nb, nb->min, ocount + 1); gcReleaseRoot(H, root); releaseHeapLock(H); assert(saneList(H, slice)); return slice; } }
XeTeXFontMgr::NameCollection* XeTeXFontMgr_FC::readNames(FcPattern* pat) { NameCollection* names = new NameCollection; char* pathname; if (FcPatternGetString(pat, FC_FILE, 0, (FcChar8**)&pathname) != FcResultMatch) return names; int index; if (FcPatternGetInteger(pat, FC_INDEX, 0, &index) != FcResultMatch) return names; FT_Face face; if (FT_New_Face(gFreeTypeLibrary, pathname, index, &face) != 0) return names; const char* name = FT_Get_Postscript_Name(face); if (name == NULL) return names; names->psName = name; // for sfnt containers, we'll read the name table ourselves, not rely on Fontconfig if (FT_IS_SFNT(face)) { std::list<std::string> familyNames; std::list<std::string> subFamilyNames; FT_SfntName nameRec; for (index = 0; index < FT_Get_Sfnt_Name_Count(face); ++index) { char* utf8name = NULL; if (FT_Get_Sfnt_Name(face, index, &nameRec) != 0) continue; switch (nameRec.name_id) { case kFontFullName: case kFontFamilyName: case kFontStyleName: case kPreferredFamilyName: case kPreferredSubfamilyName: { bool preferredName = false; if (nameRec.platform_id == TT_PLATFORM_MACINTOSH && nameRec.encoding_id == TT_MAC_ID_ROMAN && nameRec.language_id == 0) { utf8name = convertToUtf8(macRomanConv, nameRec.string, nameRec.string_len); preferredName = true; } else if ((nameRec.platform_id == TT_PLATFORM_APPLE_UNICODE) || (nameRec.platform_id == TT_PLATFORM_MICROSOFT)) utf8name = convertToUtf8(utf16beConv, nameRec.string, nameRec.string_len); if (utf8name != NULL) { std::list<std::string>* nameList = NULL; switch (nameRec.name_id) { case kFontFullName: nameList = &names->fullNames; break; case kFontFamilyName: nameList = &names->familyNames; break; case kFontStyleName: nameList = &names->styleNames; break; case kPreferredFamilyName: nameList = &familyNames; break; case kPreferredSubfamilyName: nameList = &subFamilyNames; break; } if (preferredName) prependToList(nameList, utf8name); else appendToList(nameList, utf8name); } } break; } } if (familyNames.size() > 0) names->familyNames = familyNames; if (subFamilyNames.size() > 0) names->styleNames = subFamilyNames; } else { index = 0; while (FcPatternGetString(pat, FC_FULLNAME, index++, (FcChar8**)&name) == FcResultMatch) appendToList(&names->fullNames, name); index = 0; while (FcPatternGetString(pat, FC_FAMILY, index++, (FcChar8**)&name) == FcResultMatch) appendToList(&names->familyNames, name); index = 0; while (FcPatternGetString(pat, FC_STYLE, index++, (FcChar8**)&name) == FcResultMatch) appendToList(&names->styleNames, name); if (names->fullNames.size() == 0) { std::string fullName(names->familyNames.front()); if (names->styleNames.size() > 0) { fullName += " "; fullName += names->styleNames.front(); } names->fullNames.push_back(fullName); } } FT_Done_Face(face); return names; }