| 1805 | |
| 1806 | template< class Format, class OcdTextSymbol > |
| 1807 | void OcdFileExport::exportTextSymbol(OcdFile<Format>& file, const TextSymbol* text_symbol) |
| 1808 | { |
| 1809 | auto symbol_number = symbol_numbers.at(text_symbol); |
| 1810 | |
| 1811 | text_format_mapping.push_back({ text_symbol, TextObject::AlignLeft, 0, symbol_number }); |
| 1812 | text_format_mapping.push_back({ text_symbol, TextObject::AlignHCenter, 0, symbol_number }); |
| 1813 | text_format_mapping.push_back({ text_symbol, TextObject::AlignRight, 0, symbol_number }); |
| 1814 | auto text_format = text_format_mapping.end() - 3; |
| 1815 | auto count = [text_format](const auto* object) { |
| 1816 | auto alignment = static_cast<const TextObject*>(object)->getHorizontalAlignment(); |
| 1817 | switch (alignment) |
| 1818 | { |
| 1819 | case TextObject::AlignLeft: |
| 1820 | text_format->count++; |
| 1821 | break; |
| 1822 | case TextObject::AlignHCenter: |
| 1823 | (text_format+1)->count++; |
| 1824 | break; |
| 1825 | case TextObject::AlignRight: |
| 1826 | (text_format+2)->count++; |
| 1827 | break; |
| 1828 | } |
| 1829 | }; |
| 1830 | map->applyOnMatchingObjects(count, ObjectOp::HasSymbol{text_symbol}); |
| 1831 | |
| 1832 | // The most frequent usage is to get the regular number. |
| 1833 | std::sort(text_format, end(text_format_mapping), [](const auto& a, const auto& b) { return a.count > b.count; }); |
| 1834 | |
| 1835 | text_format = text_format_mapping.end() - 3; |
| 1836 | if (text_format->count == 0) |
| 1837 | text_format->alignment = TextObject::AlignHCenter; // default if unused: centered |
| 1838 | auto ocd_symbol = exportTextSymbol<typename Format::TextSymbol>(text_symbol, text_format->symbol_number, text_format->alignment); |
| 1839 | FILEFORMAT_ASSERT(!ocd_symbol.isEmpty()); |
| 1840 | file.symbols().insert(ocd_symbol); |
| 1841 | |
| 1842 | ++text_format; |
| 1843 | if (text_format->count > 0) |
| 1844 | { |
| 1845 | text_format->symbol_number = makeUniqueSymbolNumber(symbol_number); |
| 1846 | temporary_symbols.emplace_back(new PointSymbol()); |
| 1847 | symbol_numbers[temporary_symbols.back().get()] = text_format->symbol_number; |
| 1848 | ocd_symbol = exportTextSymbol<typename Format::TextSymbol>(text_symbol, text_format->symbol_number, text_format->alignment); |
| 1849 | FILEFORMAT_ASSERT(!ocd_symbol.isEmpty()); |
| 1850 | file.symbols().insert(ocd_symbol); |
| 1851 | |
| 1852 | ++text_format; |
| 1853 | if (text_format->count > 0) |
| 1854 | { |
| 1855 | text_format->symbol_number = makeUniqueSymbolNumber(symbol_number); |
| 1856 | temporary_symbols.emplace_back(new PointSymbol()); |
| 1857 | symbol_numbers[temporary_symbols.back().get()] = text_format->symbol_number; |
| 1858 | ocd_symbol = exportTextSymbol<typename Format::TextSymbol>(text_symbol, text_format->symbol_number, text_format->alignment); |
| 1859 | FILEFORMAT_ASSERT(!ocd_symbol.isEmpty()); |
| 1860 | file.symbols().insert(ocd_symbol); |
| 1861 | |
| 1862 | ++text_format; |
| 1863 | } |
| 1864 | } |
nothing calls this directly
no test coverage detected