| 305 | } |
| 306 | |
| 307 | string* DefaultTeXFontParser::parseDefaultTextStyleMappins() throw(ex_res_parse) { |
| 308 | string* res = new string[4]; |
| 309 | const XMLElement* mappings = _root->FirstChildElement("DefaultTextStyleMapping"); |
| 310 | if (mappings == nullptr) return res; |
| 311 | |
| 312 | #ifdef HAVE_LOG |
| 313 | __dbg("tag name:%s <should be DefaultTextStyleMapping>\n", mappings->Name()); |
| 314 | #endif |
| 315 | |
| 316 | // iterate all mappings |
| 317 | const XMLElement* mapping = mappings->FirstChildElement("MapStyle"); |
| 318 | while (mapping != nullptr) { |
| 319 | // get range name and check |
| 320 | const string code = getAttrValueAndCheckIfNotNull("code", mapping); |
| 321 | auto mit = _rangeTypeMappings.find(code); |
| 322 | if (mit == _rangeTypeMappings.end()) { |
| 323 | throw ex_xml_parse( |
| 324 | RESOURCE_NAME, |
| 325 | "MapStyle", "code", "contains an unknown 'range name' '" + code + "'!"); |
| 326 | } |
| 327 | int codeMapping = mit->second; |
| 328 | // get mapped style and check |
| 329 | const string textStyleName = getAttrValueAndCheckIfNotNull("textStyle", mapping); |
| 330 | |
| 331 | const auto& it = _parsedTextStyles.find(textStyleName); |
| 332 | if (it == _parsedTextStyles.end()) { |
| 333 | throw ex_xml_parse( |
| 334 | RESOURCE_NAME, |
| 335 | "Mapstyle", "textStyle", |
| 336 | "contains an unknown 'range name' '" + textStyleName + "'!"); |
| 337 | } |
| 338 | |
| 339 | const auto& charFonts = it->second; |
| 340 | // now check if the range is defined within the mapped text style |
| 341 | int index = codeMapping; |
| 342 | if (charFonts[index] == nullptr) |
| 343 | throw ex_xml_parse( |
| 344 | RESOURCE_NAME + ": the default text style mapping '" + |
| 345 | textStyleName + "' for the range '" + code + |
| 346 | "' contains no mapping for that range!"); |
| 347 | |
| 348 | res[index] = textStyleName; |
| 349 | mapping = mapping->NextSiblingElement("MapStyle"); |
| 350 | } |
| 351 | return res; |
| 352 | } |
| 353 | |
| 354 | map<string, vector<CharFont*>> DefaultTeXFontParser::parseTextStyleMappings() { |
| 355 | if (_parsedTextStyles.empty()) parseStyleMappings(_parsedTextStyles); |
nothing calls this directly
no test coverage detected