@@ -103,6 +103,35 @@ std::set<FileSystem::Identifier> CanvasParser::loading_;
103
103
104
104
/* === P R O C E D U R E S ================================================= */
105
105
106
+ // Guide lines storage changed:
107
+ // Before:
108
+ // guide_x -> list of X positions of vertical guide lines (separated by spaces)
109
+ // guide_y -> list of Y positions of horizontal guide lines (separated by spaces)
110
+ // Now:
111
+ // guide -> list of X*Y*radian-angle coordinates of guide lines (data from same guide is separated by star *) (items separated by spaces)
112
+ static void
113
+ upgrade_guide_metadata (std::string& content, const std::string& metadata, bool is_x_guide)
114
+ {
115
+ std::string new_content;
116
+ std::istringstream iss (content);
117
+ std::string item;
118
+ while (std::getline (iss, item, ' ' )) {
119
+ if (!item.empty ()) {
120
+ if (is_x_guide) {
121
+ // X * 0 * PI/2 radians -> vertical guide line
122
+ new_content += item + " *0*1.57079633 " ;
123
+ } else {
124
+ // 0 * Y * 0 radians -> horizontal guide line
125
+ new_content += " 0*" + item + " *0 " ;
126
+ }
127
+ }
128
+ }
129
+ // new_content already has a blank space appended
130
+ content = new_content + metadata;
131
+ if (content.back () == ' ' )
132
+ content.pop_back ();
133
+ }
134
+
106
135
OpenCanvasMap& synfig::get_open_canvas_map ()
107
136
{
108
137
static OpenCanvasMap open_canvas_map_;
@@ -3331,6 +3360,9 @@ CanvasParser::parse_canvas(xmlpp::Element *element,Canvas::Handle parent,bool in
3331
3360
continue ;
3332
3361
}
3333
3362
3363
+ std::string meta_name = child->get_attribute (" name" )->get_value ();
3364
+ std::string content = child->get_attribute (" content" )->get_value ();
3365
+
3334
3366
// In Synfig prior to version 1.0 we have messed decimal separator:
3335
3367
// some files use ".", but other ones use ","/
3336
3368
// Let's try to put a workaround for that.
@@ -3341,9 +3373,7 @@ CanvasParser::parse_canvas(xmlpp::Element *element,Canvas::Handle parent,bool in
3341
3373
replacelist.push_back (" grid_color" );
3342
3374
replacelist.push_back (" grid_size" );
3343
3375
replacelist.push_back (" jack_offset" );
3344
- String content;
3345
- content=child->get_attribute (" content" )->get_value ();
3346
- if (std::find (replacelist.begin (), replacelist.end (), child->get_attribute (" name" )->get_value ()) != replacelist.end ())
3376
+ if (std::find (replacelist.begin (), replacelist.end (), meta_name) != replacelist.end ())
3347
3377
{
3348
3378
size_t index = 0 ;
3349
3379
while (true ) {
@@ -3359,7 +3389,19 @@ CanvasParser::parse_canvas(xmlpp::Element *element,Canvas::Handle parent,bool in
3359
3389
}
3360
3390
3361
3391
}
3362
- canvas->set_meta_data (child->get_attribute (" name" )->get_value (),content);
3392
+
3393
+ // Commit b172e37 (#2777) changed guide lines storage to give them rotation ability
3394
+ if (meta_name == " guide_x" ) {
3395
+ upgrade_guide_metadata (content, canvas->get_meta_data (" guide" ), true );
3396
+ meta_name = " guide" ;
3397
+ }
3398
+
3399
+ if (meta_name == " guide_y" ) {
3400
+ upgrade_guide_metadata (content, canvas->get_meta_data (" guide" ), false );
3401
+ meta_name = " guide" ;
3402
+ }
3403
+
3404
+ canvas->set_meta_data (meta_name, content);
3363
3405
}
3364
3406
else if (child->get_name ()==" name" )
3365
3407
{
0 commit comments