pascal Handle SafeGet1NamedResource(ResType type, ConstStr255Param name) { Handle result = NULL; if (gLocaleResFile) { StAcroResourceContext resContext(gLocaleResFile); result = Get1NamedResource(type, name); } if (result == NULL && GetAcroPluginResourceMap()) { StAcroResourceContext resContext(GetAcroPluginResourceMap()); result = Get1NamedResource(type, name); } return result; }
/* loads and configures components in a SysContext @param doc the DOMDocument @return SysContext the system context where all components are loaded into */ RefCountedPtr<SysContext> SysComponentLoader::createComponentContext( const DOMDocument* doc ) { RefCountedPtr<SysContext> resContext(new SysContext); std::vector<DOMProcessingInstruction*> pis; DomUtils::findProcessingInstructions( doc, TARGET_NAME, pis ); // map of components to their configuration std::map< RefCountedPtr<iSysComponent>, DOMElement* > luckyComponents; for ( std::vector<DOMProcessingInstruction*>::const_iterator it = pis.begin(); it != pis.end(); it++ ) { // check to see if the processing instruction has the // following attributes: // "component-name" - name of the class to create // "component-config" - path of the config tree for the component // Mapping attrs; if ( DomUtils::getAttributes( (*it), attrs ) ) { String cmpName; attrs.getIfAvailable(CMP_NAME_ATTR, cmpName); RefCountedPtr<iSysComponent> cmp( SysComponentFactory::createObject( cmpName ) ); if ( cmp != NULL ) { // locate it's configuration and call it to initialize DOMElement* xmlNode = NULL; String xmlIsland; attrs.getIfAvailable(CMP_CFG_ATTR, xmlIsland); if ( xmlIsland.length() > 0 ) { const DOMNode* theNode = (const DOMNode*)doc->getDocumentElement(); DomUtils::selectSingleNode( theNode, xmlIsland, (DOMNode**)&xmlNode ); } int initRes = cmp->init( xmlNode, resContext ); if ( initRes == 0 ) { resContext->addComponent( cmp ); luckyComponents[ cmp ] = xmlNode; } } } } // now post initialize the components that were successfully initialized for ( std::map< RefCountedPtr<iSysComponent>, DOMElement* >::iterator lit = luckyComponents.begin(); lit != luckyComponents.end(); lit++ ) { (*lit).first->postInit( (*lit).second, resContext ); } return resContext; }
pascal Handle SafeGet1Resource(ResType type, short resNum) { Handle result = NULL; if (gLocaleResFile) { StAcroResourceContext resContext(gLocaleResFile); result = Get1Resource(type, resNum); } if (result == NULL && GetAcroPluginResourceMap()) { StAcroResourceContext resContext(GetAcroPluginResourceMap()); result = Get1Resource(type, resNum); } return result; }
pascal Handle SafeGet1Resource(ResType type, short resNum) { #if TARGET_API_MAC_CARBON Handle result = NULL; if (gLocaleResFile) { StAcroResourceContext resContext(gLocaleResFile); result = Get1Resource(type, resNum); } if (result == NULL && gResFile) { StAcroResourceContext resContext(gResFile); result = Get1Resource(type, resNum); } return result; #else Handle result; short oldResFile = CurResFile(); if( gLocaleResFile ) { // Look in the Locale file first UseResFile( gLocaleResFile ); result = Get1Resource(type, resNum); if( result ) { // If the resource was there, then UseResFile( oldResFile ); // restore the chain and exit return result; } } UseResFile( gResFile ); // Default to base resource file result = Get1Resource(type, resNum); // and get resource. UseResFile(oldResFile); // restore and return return result; #endif }