/* * XpGetResolution returns an integer representing the printer resolution * in dots-per-inch for the specified print context. * * Note: This routine assumes the values found in the passed context's * attributes pools have been validated. */ int XpGetResolution( XpContextPtr pContext) { unsigned long resolution; resolution = XpGetCardAttr(pContext, XPPageAttr, xpoid_att_default_printer_resolution, (XpOidCardList*)NULL); if(0 == resolution) resolution = XpGetCardAttr(pContext, XPDocAttr, xpoid_att_default_printer_resolution, (XpOidCardList*)NULL); if(0 == resolution) { XpOidCardList* resolutions_supported; /* * default-printer-resolution not specified; default to 1st entry * in printer-resolutions-supported. */ resolutions_supported = XpGetCardListAttr(pContext, XPPrinterAttr, xpoid_att_printer_resolutions_supported, (XpOidCardList*)NULL); resolution = XpOidCardListGetCard(resolutions_supported, 0); XpOidCardListDelete(resolutions_supported); } return (int)resolution; }
void XpValidateCardAttr(XpContextPtr pContext, XPAttributes pool, XpOid oid, const XpOidCardList* valid_cards, unsigned long default_card) { unsigned long value_card; value_card = XpGetCardAttr(pContext, pool, oid, valid_cards); XpPutCardAttr(pContext, pool, oid, value_card == 0 ? default_card : value_card); }