| 2786 | } |
| 2787 | |
| 2788 | void |
| 2789 | LayoutViewBase::do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default) |
| 2790 | { |
| 2791 | std::vector<lay::LayerPropertiesList> props; |
| 2792 | bool single_list = false; |
| 2793 | |
| 2794 | // read the layer properties from the file |
| 2795 | try { |
| 2796 | tl::XMLFileSource in (fn); |
| 2797 | props.push_back (lay::LayerPropertiesList ()); |
| 2798 | props.back ().load (in); |
| 2799 | single_list = true; |
| 2800 | } catch (...) { |
| 2801 | props.clear (); |
| 2802 | tl::XMLFileSource in (fn); |
| 2803 | lay::LayerPropertiesList::load (in, props); |
| 2804 | } |
| 2805 | |
| 2806 | // expand the wildcards and map to the target cv. |
| 2807 | for (std::vector<lay::LayerPropertiesList>::iterator p = props.begin (); p != props.end (); ++p) { |
| 2808 | std::map <int, int> cv_map; |
| 2809 | if (map_cv) { |
| 2810 | cv_map.insert (std::make_pair (-1, cv_index)); |
| 2811 | } |
| 2812 | p->attach_view (this, p - props.begin ()); |
| 2813 | p->expand (cv_map, add_default); |
| 2814 | } |
| 2815 | |
| 2816 | transaction (tl::to_string (tr ("Load layer properties"))); |
| 2817 | |
| 2818 | if (single_list) { |
| 2819 | |
| 2820 | // a single list will only replace the current tab |
| 2821 | if (map_cv && cv_index >= 0) { |
| 2822 | lay::LayerPropertiesList new_props (get_properties ()); |
| 2823 | new_props.remove_cv_references (cv_index); |
| 2824 | new_props.append (props [0]); |
| 2825 | set_properties (new_props); |
| 2826 | } else { |
| 2827 | set_properties (props [0]); |
| 2828 | } |
| 2829 | |
| 2830 | } else { |
| 2831 | |
| 2832 | for (unsigned int i = 0; i < props.size (); ++i) { |
| 2833 | |
| 2834 | if (i < layer_lists ()) { |
| 2835 | |
| 2836 | if (map_cv && cv_index >= 0) { |
| 2837 | lay::LayerPropertiesList new_props (get_properties (i)); |
| 2838 | new_props.remove_cv_references (cv_index); |
| 2839 | new_props.append (props [i]); |
| 2840 | set_properties (i, new_props); |
| 2841 | } else { |
| 2842 | set_properties (i, props [i]); |
| 2843 | } |
| 2844 | |
| 2845 | } else { |
nothing calls this directly
no test coverage detected