Exemplo n.º 1
0
const char * AbiWordperfectInputStream::subStreamName(unsigned id)
{
	if (!m_ole)
		m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL)); 
	
	if (!m_ole)
		m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL)); 
	
	if (m_ole)
		{
			if ((int)id >= gsf_infile_num_children(m_ole))
			{
				return 0;
			}
			std::map<unsigned, std::string>::iterator i = m_substreams.lower_bound(id);
			if (i == m_substreams.end() || m_substreams.key_comp()(id, i->first))
				{
					std::string name = gsf_infile_name_by_index(m_ole, (int)id);
					i = m_substreams.insert(i, std::map<unsigned, std::string>::value_type(id, name));
				}
			return i->second.c_str();
		}
	
	return 0;
}
static inline void increaseColorUsage(uint32_t color, uint32_t usageCount, std::map<uint32_t, uint32_t> & colorUsage) {
	auto lb = colorUsage.lower_bound(color);
	if (lb != colorUsage.end() && !(colorUsage.key_comp()(color, lb->first))) {
		// Color already in map.
		lb->second += usageCount;
	} else {
		// Insert new color into map.
		colorUsage.insert(lb, std::make_pair(color, usageCount));
	}
}