diff --git a/src/actions/actions-object.cpp b/src/actions/actions-object.cpp index efa45366c940c72ee8777e068cb4b254b05d9c69..5ef36800d868998fde1fe6c9f418625bdf2a4a3d 100644 --- a/src/actions/actions-object.cpp +++ b/src/actions/actions-object.cpp @@ -159,9 +159,8 @@ object_set_attribute(const Glib::VariantBase& value, InkscapeApplication *app) } // Should this be a selection member function? - auto items = selection->items(); - for (auto i = items.begin(); i != items.end(); ++i) { - Inkscape::XML::Node *repr = (*i)->getRepr(); + for (auto obj : selection->objects()) { + Inkscape::XML::Node *repr = obj->getRepr(); repr->setAttribute(attribute, new_value); } @@ -189,9 +188,8 @@ object_set_property(const Glib::VariantBase& value, InkscapeApplication *app) } // Should this be a selection member function? - auto items = selection->items(); - for (auto i = items.begin(); i != items.end(); ++i) { - Inkscape::XML::Node *repr = (*i)->getRepr(); + for (auto obj : selection->objects()) { + Inkscape::XML::Node *repr = obj->getRepr(); SPCSSAttr *css = sp_repr_css_attr(repr, "style"); sp_repr_css_set_property(css, tokens[0].c_str(), tokens[1].c_str()); sp_repr_css_set(repr, css, "style"); diff --git a/src/actions/actions-selection.cpp b/src/actions/actions-selection.cpp index eaa021c001e5648ada84acaff9f74e32656ec1e7..f89f4772c726133bc904867db139866c9aeced9a 100644 --- a/src/actions/actions-selection.cpp +++ b/src/actions/actions-selection.cpp @@ -224,10 +224,9 @@ select_list(InkscapeApplication* app) return; } - auto items = selection->items(); - for (auto i = items.begin(); i != items.end(); ++i) { + for (auto obj : selection->objects()) { std::stringstream buffer; - buffer << **i; + buffer << *obj; show_output(buffer.str(), false); } } diff --git a/testfiles/cli_tests/CMakeLists.txt b/testfiles/cli_tests/CMakeLists.txt index 88ad0edc11a17d8f5f9e01f32ce3a25b39820854..bebd6559263ccbe22c4d5011578d0a2bbb6d18a0 100644 --- a/testfiles/cli_tests/CMakeLists.txt +++ b/testfiles/cli_tests/CMakeLists.txt @@ -808,10 +808,15 @@ add_cli_test(actions-object-distribute INPUT_FILENAME rects.svg REFERENCE_FILENAME actions-object-distribute_expected.png) # object-set-attribute -add_cli_test(actions-object-set-attribute INPUT_FILENAME rects.svg - PARAMETERS --actions=select-by-id:rect1$object-set-attribute:rx,15 - OUTPUT_FILENAME actions-object-set-attribute.png - REFERENCE_FILENAME actions-object-set-attribute_expected.png) +add_cli_test(actions-object-set-attribute INPUT_FILENAME rects.svg + PARAMETERS --actions=select-by-id:rect1$object-set-attribute:rx,15 + OUTPUT_FILENAME actions-object-set-attribute.png + REFERENCE_FILENAME actions-object-set-attribute_expected.png) + +add_cli_test(actions-object-set-attribute_filter INPUT_FILENAME gradient.svg + PARAMETERS --actions=select-by-id:stop1$object-set-attribute:offset,25% + OUTPUT_FILENAME actions-object-set-attribute.svg + TEST_SCRIPT match_regex.sh actions-object-set-attribute.svg "offset=\"25%\"") # object-get-attribute add_cli_test(actions-object-get-attribute INPUT_FILENAME rects.svg @@ -823,10 +828,15 @@ add_cli_test(actions-object-get-attribute_nonexistant INPUT_FILENAME rects.svg PASS_FOR_OUTPUT "\n$") # object-set-property -add_cli_test(actions-object-set-property INPUT_FILENAME areas.svg - PARAMETERS --actions=select-by-id:MyRect$object-set-property:fill,gold - OUTPUT_FILENAME actions-object-set-property.svg - TEST_SCRIPT match_regex.sh actions-object-set-property.svg "style=\"fill:gold\"") +add_cli_test(actions-object-set-property INPUT_FILENAME areas.svg + PARAMETERS --actions=select-by-id:MyRect$object-set-property:fill,gold + OUTPUT_FILENAME actions-object-set-property.svg + TEST_SCRIPT match_regex.sh actions-object-set-property.svg "style=\"fill:gold\"") + +add_cli_test(actions-object-set-property_filter INPUT_FILENAME gradient.svg + PARAMETERS --actions=select-by-id:stop1$object-set-property:stop-color,gold + OUTPUT_FILENAME actions-object-set-property.svg + TEST_SCRIPT match_regex.sh actions-object-set-property.svg "style=\"stop-color:gold\"") # object-get-property add_cli_test(actions-object-get-property INPUT_FILENAME areas.svg diff --git a/testfiles/cli_tests/match_regex.sh b/testfiles/cli_tests/match_regex.sh index 24a6347218ecd828a79b66aa8a9439bbe0daf92f..0fb088789e8d7bcde132208a5da8b98a54bd8375 100644 --- a/testfiles/cli_tests/match_regex.sh +++ b/testfiles/cli_tests/match_regex.sh @@ -5,7 +5,7 @@ testfile=$1 regex=$2 test -f "${testfile}" || { echo "match_regex.sh: testfile '${testfile}' not found."; exit 1; } -test -n "${regex}" || { echo "match_regex.sh: no regex to match spoecified."; exit 1; } +test -n "${regex}" || { echo "match_regex.sh: no regex to match specified."; exit 1; } if ! grep -E "${regex}" "${testfile}"; then echo "match_regex.sh: regex '${regex}' does not match in testfile '${testfile}'." diff --git a/testfiles/cli_tests/testcases/gradient.svg b/testfiles/cli_tests/testcases/gradient.svg index 3f5ab8c5ecea8670ea52e115a0cfbe50c6bdd1fa..c463453787f2d546067f18b7aa641c8e751316a4 100644 --- a/testfiles/cli_tests/testcases/gradient.svg +++ b/testfiles/cli_tests/testcases/gradient.svg @@ -2,8 +2,8 @@ - - + +