From 4d75f1ecca2fcab4cbfec9fb84c5b1f3647dbc17 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Wed, 28 May 2014 23:28:17 +0200 Subject: SPPattern c++-sification: replaced function by methods (bzr r13341.6.21) --- src/desktop-style.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 37f537cc5..8c3dac382 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -538,8 +538,8 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill if (!SP_IS_PATTERN(server)) return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server - SPPattern *pat = pattern_getroot (SP_PATTERN (server)); - SPPattern *pat_res = pattern_getroot (SP_PATTERN (server_res)); + SPPattern *pat = SP_PATTERN (server)->get_root(); + SPPattern *pat_res = SP_PATTERN (server_res)->get_root(); if (pat_res != pat) return QUERY_STYLE_MULTIPLE_DIFFERENT; // different pattern roots } -- cgit v1.2.3 From a7f2b2ba3f13ceb60376802f4a31e104153839e8 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 17 Feb 2015 03:00:37 +0100 Subject: At first, I was thinking "I just have to go to the selection file, and change that GSList* with a std::list, then resolve the few problems" So, i tried that. And I will continue tomorrow, and the days after, on and on. (bzr r13922.1.1) --- src/desktop-style.cpp | 120 +++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index ee9fa39ec..39dfad44b 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -194,10 +194,10 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_write, css); sp_css_attr_unset_uris(css_write); prefs->mergeStyle("/desktop/style", css_write); - - for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) { + SelContainer const itemlist = desktop->selection->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { /* last used styles for 3D box faces are stored separately */ - SPObject *obj = reinterpret_cast(i->data); // TODO unsafe until Selection is refactored. + SPObject *obj = reinterpret_cast(*i); // TODO unsafe until Selection is refactored. Box3DSide *side = dynamic_cast(obj); if (side) { const char * descr = box3d_side_axes_string(side); @@ -234,8 +234,9 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_no_text, css); css_no_text = sp_css_attr_unset_text(css_no_text); - for (GSList const *i = desktop->selection->itemList(); i != NULL; i = i->next) { - SPItem *item = reinterpret_cast(i->data); + SelContainer const itemlist = desktop->selection->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = reinterpret_cast(*i); // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) if (isTextualItem(item)) { @@ -438,17 +439,16 @@ sp_desktop_get_font_size_tool(SPDesktop *desktop) /** Determine average stroke width, simple method */ // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually gdouble -stroke_average_width (GSList const *objects) +stroke_average_width (const SelContainer &objects) { - if (g_slist_length ((GSList *) objects) == 0) + if (objects.empty()) return Geom::infinity(); gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - - for (GSList const *l = objects; l != NULL; l = l->next) { - SPObject *obj = reinterpret_cast(l->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); SPItem *item = dynamic_cast(obj); if (!item) { continue; @@ -471,7 +471,7 @@ stroke_average_width (GSList const *objects) if (notstroked) return Geom::infinity(); - return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked); + return avgwidth / (objects.size() - n_notstroked); } static bool vectorsClose( std::vector const &lhs, std::vector const &rhs ) @@ -492,9 +492,9 @@ static bool vectorsClose( std::vector const &lhs, std::vector co * Write to style_res the average fill or stroke of list of objects, if applicable. */ int -objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill) +objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool const isfill) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -514,8 +514,8 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -674,7 +674,7 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill } // Not color - if (g_slist_length(objects) > 1) { + if (objects.size() > 1) { return QUERY_STYLE_MULTIPLE_SAME; } else { return QUERY_STYLE_SINGLE; @@ -685,9 +685,9 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill * Write to style_res the average opacity of a list of objects. */ int -objects_query_opacity (GSList *objects, SPStyle *style_res) +objects_query_opacity (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -698,8 +698,8 @@ objects_query_opacity (GSList *objects, SPStyle *style_res) guint opacity_items = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -739,9 +739,9 @@ objects_query_opacity (GSList *objects, SPStyle *style_res) * Write to style_res the average stroke width of a list of objects. */ int -objects_query_strokewidth (GSList *objects, SPStyle *style_res) +objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -754,8 +754,8 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) int n_stroked = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -815,9 +815,9 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) * Write to style_res the average miter limit of a list of objects. */ int -objects_query_miterlimit (GSList *objects, SPStyle *style_res) +objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -828,8 +828,8 @@ objects_query_miterlimit (GSList *objects, SPStyle *style_res) gdouble prev_ml = -1; bool same_ml = true; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; } @@ -875,9 +875,9 @@ objects_query_miterlimit (GSList *objects, SPStyle *style_res) * Write to style_res the stroke cap of a list of objects. */ int -objects_query_strokecap (GSList *objects, SPStyle *style_res) +objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -887,8 +887,8 @@ objects_query_strokecap (GSList *objects, SPStyle *style_res) bool same_cap = true; int n_stroked = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; } @@ -929,9 +929,9 @@ objects_query_strokecap (GSList *objects, SPStyle *style_res) * Write to style_res the stroke join of a list of objects. */ int -objects_query_strokejoin (GSList *objects, SPStyle *style_res) +objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -941,8 +941,8 @@ objects_query_strokejoin (GSList *objects, SPStyle *style_res) bool same_join = true; int n_stroked = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; } @@ -984,7 +984,7 @@ objects_query_strokejoin (GSList *objects, SPStyle *style_res) * Write to style_res the average font size and spacing of objects. */ int -objects_query_fontnumbers (GSList *objects, SPStyle *style_res) +objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) { bool different = false; @@ -1004,8 +1004,8 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) int texts = 0; int no_size = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { continue; @@ -1116,15 +1116,15 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) * Write to style_res the average font style of objects. */ int -objects_query_fontstyle (GSList *objects, SPStyle *style_res) +objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res) { bool different = false; bool set = false; int texts = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { continue; @@ -1173,7 +1173,7 @@ objects_query_fontstyle (GSList *objects, SPStyle *style_res) * Write to style_res the baseline numbers. */ static int -objects_query_baselines (GSList *objects, SPStyle *style_res) +objects_query_baselines (const SelContainer &objects, SPStyle *style_res) { bool different = false; @@ -1192,8 +1192,8 @@ objects_query_baselines (GSList *objects, SPStyle *style_res) int texts = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { continue; @@ -1269,7 +1269,7 @@ objects_query_baselines (GSList *objects, SPStyle *style_res) * Write to style_res the average font family of objects. */ int -objects_query_fontfamily (GSList *objects, SPStyle *style_res) +objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1280,8 +1280,8 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res) } style_res->font_family.set = FALSE; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { @@ -1325,7 +1325,7 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res) } static int -objects_query_fontspecification (GSList *objects, SPStyle *style_res) +objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1336,8 +1336,8 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res) } style_res->font_specification.set = FALSE; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { @@ -1385,7 +1385,7 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res) } static int -objects_query_blend (GSList *objects, SPStyle *style_res) +objects_query_blend (const SelContainer &objects, SPStyle *style_res) { const int empty_prev = -2; const int complex_filter = 5; @@ -1394,8 +1394,8 @@ objects_query_blend (GSList *objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -1471,9 +1471,9 @@ objects_query_blend (GSList *objects, SPStyle *style_res) * Write to style_res the average blurring of a list of objects. */ int -objects_query_blur (GSList *objects, SPStyle *style_res) +objects_query_blur (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -1484,8 +1484,8 @@ objects_query_blur (GSList *objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -1553,7 +1553,7 @@ objects_query_blur (GSList *objects, SPStyle *style_res) * the result to style, return appropriate flag. */ int -sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property) +sp_desktop_query_style_from_list (const SelContainer &list, SPStyle *style, int property) { if (property == QUERY_STYLE_PROPERTY_FILL) { return objects_query_fillstroke (list, style, true); @@ -1606,7 +1606,7 @@ sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property) // otherwise, do querying and averaging over selection if (desktop->selection != NULL) { - return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property); + return sp_desktop_query_style_from_list (desktop->selection->itemList(), style, property); } return QUERY_STYLE_NOTHING; -- cgit v1.2.3 From 5fd00cab14d48beaf2279a2b8f3ad5b02b76c87b Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 04:25:21 +0100 Subject: Put a few std::vector (bzr r13922.1.5) --- src/desktop-style.cpp | 66 +++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 39dfad44b..0c661ebfb 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -194,8 +194,8 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_write, css); sp_css_attr_unset_uris(css_write); prefs->mergeStyle("/desktop/style", css_write); - SelContainer const itemlist = desktop->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector const itemlist = desktop->selection->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { /* last used styles for 3D box faces are stored separately */ SPObject *obj = reinterpret_cast(*i); // TODO unsafe until Selection is refactored. Box3DSide *side = dynamic_cast(obj); @@ -234,8 +234,8 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_no_text, css); css_no_text = sp_css_attr_unset_text(css_no_text); - SelContainer const itemlist = desktop->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector const itemlist = desktop->selection->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = reinterpret_cast(*i); // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) @@ -439,7 +439,7 @@ sp_desktop_get_font_size_tool(SPDesktop *desktop) /** Determine average stroke width, simple method */ // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually gdouble -stroke_average_width (const SelContainer &objects) +stroke_average_width (const std::vector &objects) { if (objects.empty()) return Geom::infinity(); @@ -447,7 +447,7 @@ stroke_average_width (const SelContainer &objects) gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); SPItem *item = dynamic_cast(obj); if (!item) { @@ -492,7 +492,7 @@ static bool vectorsClose( std::vector const &lhs, std::vector co * Write to style_res the average fill or stroke of list of objects, if applicable. */ int -objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool const isfill) +objects_query_fillstroke (const std::vector &objects, SPStyle *style_res, bool const isfill) { if (objects.empty()) { /* No objects, set empty */ @@ -514,7 +514,7 @@ objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -685,7 +685,7 @@ objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool * Write to style_res the average opacity of a list of objects. */ int -objects_query_opacity (const SelContainer &objects, SPStyle *style_res) +objects_query_opacity (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -698,7 +698,7 @@ objects_query_opacity (const SelContainer &objects, SPStyle *style_res) guint opacity_items = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -739,7 +739,7 @@ objects_query_opacity (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average stroke width of a list of objects. */ int -objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) +objects_query_strokewidth (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -754,7 +754,7 @@ objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) int n_stroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -815,7 +815,7 @@ objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average miter limit of a list of objects. */ int -objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) +objects_query_miterlimit (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -828,7 +828,7 @@ objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) gdouble prev_ml = -1; bool same_ml = true; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -875,7 +875,7 @@ objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) * Write to style_res the stroke cap of a list of objects. */ int -objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) +objects_query_strokecap (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -887,7 +887,7 @@ objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) bool same_cap = true; int n_stroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -929,7 +929,7 @@ objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) * Write to style_res the stroke join of a list of objects. */ int -objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) +objects_query_strokejoin (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -941,7 +941,7 @@ objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) bool same_join = true; int n_stroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -984,7 +984,7 @@ objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average font size and spacing of objects. */ int -objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) +objects_query_fontnumbers (const std::vector &objects, SPStyle *style_res) { bool different = false; @@ -1004,7 +1004,7 @@ objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) int texts = 0; int no_size = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1116,14 +1116,14 @@ objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average font style of objects. */ int -objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res) +objects_query_fontstyle (const std::vector &objects, SPStyle *style_res) { bool different = false; bool set = false; int texts = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1173,7 +1173,7 @@ objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res) * Write to style_res the baseline numbers. */ static int -objects_query_baselines (const SelContainer &objects, SPStyle *style_res) +objects_query_baselines (const std::vector &objects, SPStyle *style_res) { bool different = false; @@ -1192,7 +1192,7 @@ objects_query_baselines (const SelContainer &objects, SPStyle *style_res) int texts = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1269,7 +1269,7 @@ objects_query_baselines (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average font family of objects. */ int -objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) +objects_query_fontfamily (const std::vector &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1280,7 +1280,7 @@ objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) } style_res->font_family.set = FALSE; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1325,7 +1325,7 @@ objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) } static int -objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res) +objects_query_fontspecification (const std::vector &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1336,7 +1336,7 @@ objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res } style_res->font_specification.set = FALSE; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1385,7 +1385,7 @@ objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res } static int -objects_query_blend (const SelContainer &objects, SPStyle *style_res) +objects_query_blend (const std::vector &objects, SPStyle *style_res) { const int empty_prev = -2; const int complex_filter = 5; @@ -1394,7 +1394,7 @@ objects_query_blend (const SelContainer &objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -1471,7 +1471,7 @@ objects_query_blend (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average blurring of a list of objects. */ int -objects_query_blur (const SelContainer &objects, SPStyle *style_res) +objects_query_blur (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -1484,7 +1484,7 @@ objects_query_blur (const SelContainer &objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -1553,7 +1553,7 @@ objects_query_blur (const SelContainer &objects, SPStyle *style_res) * the result to style, return appropriate flag. */ int -sp_desktop_query_style_from_list (const SelContainer &list, SPStyle *style, int property) +sp_desktop_query_style_from_list (const std::vector &list, SPStyle *style, int property) { if (property == QUERY_STYLE_PROPERTY_FILL) { return objects_query_fillstroke (list, style, true); -- cgit v1.2.3 From 9a7fa4d1899d30ec745107823f307b2a0bf3172f Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 03:10:36 +0100 Subject: corrected the casts (hopefully) (bzr r13922.1.10) --- src/desktop-style.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index e1a81f00a..82f66dcdf 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -195,9 +195,9 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_css_attr_unset_uris(css_write); prefs->mergeStyle("/desktop/style", css_write); std::vector const itemlist = desktop->selection->itemList(); - for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { /* last used styles for 3D box faces are stored separately */ - SPObject *obj = reinterpret_cast(*i); // TODO unsafe until Selection is refactored. + SPObject *obj = reinterpret_cast(*i); Box3DSide *side = dynamic_cast(obj); if (side) { const char * descr = box3d_side_axes_string(side); @@ -235,8 +235,8 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write css_no_text = sp_css_attr_unset_text(css_no_text); std::vector const itemlist = desktop->selection->itemList(); - for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = reinterpret_cast(*i); + for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { + SPItem *item = *i; // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) if (isTextualItem(item)) { @@ -447,9 +447,9 @@ stroke_average_width (const std::vector &objects) gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); - SPItem *item = dynamic_cast(obj); + SPItem *item = *i; if (!item) { continue; } @@ -514,7 +514,7 @@ objects_query_fillstroke (const std::vector &objects, SPStyle *style_re prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i!= objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -698,7 +698,7 @@ objects_query_opacity (const std::vector &objects, SPStyle *style_res) guint opacity_items = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -754,7 +754,7 @@ objects_query_strokewidth (const std::vector &objects, SPStyle *style_r int n_stroked = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -828,7 +828,7 @@ objects_query_miterlimit (const std::vector &objects, SPStyle *style_re gdouble prev_ml = -1; bool same_ml = true; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -887,7 +887,7 @@ objects_query_strokecap (const std::vector &objects, SPStyle *style_res bool same_cap = true; int n_stroked = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -941,7 +941,7 @@ objects_query_strokejoin (const std::vector &objects, SPStyle *style_re bool same_join = true; int n_stroked = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -1004,7 +1004,7 @@ objects_query_fontnumbers (const std::vector &objects, SPStyle *style_r int texts = 0; int no_size = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1123,7 +1123,7 @@ objects_query_fontstyle (const std::vector &objects, SPStyle *style_res int texts = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1192,7 +1192,7 @@ objects_query_baselines (const std::vector &objects, SPStyle *style_res int texts = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1280,7 +1280,7 @@ objects_query_fontfamily (const std::vector &objects, SPStyle *style_re } style_res->font_family.set = FALSE; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1336,7 +1336,7 @@ objects_query_fontspecification (const std::vector &objects, SPStyle *s } style_res->font_specification.set = FALSE; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1394,7 +1394,7 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -1484,7 +1484,7 @@ objects_query_blur (const std::vector &objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; -- cgit v1.2.3 From 9bdc157f705ca61516e599cb416580283d21ec35 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 04:21:48 +0100 Subject: more cast cleanup (bzr r13922.1.11) --- src/desktop-style.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 82f66dcdf..afdc3064a 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -197,7 +197,7 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write std::vector const itemlist = desktop->selection->itemList(); for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { /* last used styles for 3D box faces are stored separately */ - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; Box3DSide *side = dynamic_cast(obj); if (side) { const char * descr = box3d_side_axes_string(side); @@ -448,7 +448,6 @@ stroke_average_width (const std::vector &objects) bool notstroked = true; int n_notstroked = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); SPItem *item = *i; if (!item) { continue; @@ -515,7 +514,7 @@ objects_query_fillstroke (const std::vector &objects, SPStyle *style_re bool same_color = true; for (std::vector::const_iterator i = objects.begin(); i!= objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } @@ -699,7 +698,7 @@ objects_query_opacity (const std::vector &objects, SPStyle *style_res) for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } @@ -755,7 +754,7 @@ objects_query_strokewidth (const std::vector &objects, SPStyle *style_r int n_stroked = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } @@ -829,7 +828,7 @@ objects_query_miterlimit (const std::vector &objects, SPStyle *style_re bool same_ml = true; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!dynamic_cast(obj)) { continue; } @@ -888,7 +887,7 @@ objects_query_strokecap (const std::vector &objects, SPStyle *style_res int n_stroked = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!dynamic_cast(obj)) { continue; } @@ -942,7 +941,7 @@ objects_query_strokejoin (const std::vector &objects, SPStyle *style_re int n_stroked = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!dynamic_cast(obj)) { continue; } @@ -1005,7 +1004,7 @@ objects_query_fontnumbers (const std::vector &objects, SPStyle *style_r int no_size = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!isTextualItem(obj)) { continue; @@ -1124,7 +1123,7 @@ objects_query_fontstyle (const std::vector &objects, SPStyle *style_res int texts = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!isTextualItem(obj)) { continue; @@ -1193,7 +1192,7 @@ objects_query_baselines (const std::vector &objects, SPStyle *style_res int texts = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!isTextualItem(obj)) { continue; @@ -1281,7 +1280,7 @@ objects_query_fontfamily (const std::vector &objects, SPStyle *style_re style_res->font_family.set = FALSE; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { @@ -1337,7 +1336,7 @@ objects_query_fontspecification (const std::vector &objects, SPStyle *s style_res->font_specification.set = FALSE; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { @@ -1395,7 +1394,7 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) guint items = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } @@ -1485,7 +1484,7 @@ objects_query_blur (const std::vector &objects, SPStyle *style_res) guint items = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } -- cgit v1.2.3 From 705243e1266aec7527ae76065213ca7536ed7c41 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Sun, 3 May 2015 12:37:06 +0200 Subject: renamed SPPattern methods to match coding style (bzr r14059.1.20) --- src/desktop-style.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 275165c9c..fb92ffaf5 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -576,8 +576,8 @@ objects_query_fillstroke (const std::vector &objects, SPStyle *style_re return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server } - SPPattern *pat = SP_PATTERN (server)->get_root(); - SPPattern *pat_res = SP_PATTERN (server_res)->get_root(); + SPPattern *pat = SP_PATTERN (server)->rootPattern(); + SPPattern *pat_res = SP_PATTERN (server_res)->rootPattern(); if (pat_res != pat) { return QUERY_STYLE_MULTIPLE_DIFFERENT; // different pattern roots } -- cgit v1.2.3 From c1b1d511b45348d8bccc5d22cd3471bb540cde12 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 12 May 2015 21:43:24 +0200 Subject: GUI for font-variant-xxx, parse 'font-variant-ligatures'. This is a work in progress. (bzr r14148) --- src/desktop-style.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index afdc3064a..118f983bb 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1168,6 +1168,63 @@ objects_query_fontstyle (const std::vector &objects, SPStyle *style_res } } +int +objects_query_fontvariants (const std::vector &objects, SPStyle *style_res) +{ + bool set = false; + + int texts = 0; + + SPILigatures* ligatures_res = &(style_res->font_variant_ligatures); + ligatures_res->computed = + SP_CSS_FONT_VARIANT_LIGATURES_COMMON | + SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL; + ligatures_res->value = 0; + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + SPObject *obj = *i; + + if (!isTextualItem(obj)) { + continue; + } + + SPStyle *style = obj->style; + if (!style) { + continue; + } + + texts ++; + + SPILigatures* ligatures_in = &(style->font_variant_ligatures); + // computed stores which bits are on/off, only valid if same between all selected objects. + // value stores which bits are different between objects. This is a bit of an abuse of + // the values but then we don't need to add new variables to class. + if (set) { + ligatures_res->value |= (ligatures_res->computed ^ ligatures_in->computed ); + ligatures_res->computed &= ligatures_in->computed; + } else { + set = true; + ligatures_res->computed = ligatures_in->computed; + } + } + + bool different = (style_res->font_variant_position.value != + style_res->font_variant_position.computed ); + + if (texts == 0 || !set) + return QUERY_STYLE_NOTHING; + + if (texts > 1) { + if (different) { + return QUERY_STYLE_MULTIPLE_DIFFERENT; + } else { + return QUERY_STYLE_MULTIPLE_SAME; + } + } else { + return QUERY_STYLE_SINGLE; + } +} + + /** * Write to style_res the baseline numbers. */ @@ -1577,6 +1634,8 @@ sp_desktop_query_style_from_list (const std::vector &list, SPStyle *sty return objects_query_fontfamily (list, style); } else if (property == QUERY_STYLE_PROPERTY_FONTSTYLE) { return objects_query_fontstyle (list, style); + } else if (property == QUERY_STYLE_PROPERTY_FONTVARIANTS) { + return objects_query_fontvariants (list, style); } else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) { return objects_query_fontnumbers (list, style); } else if (property == QUERY_STYLE_PROPERTY_BASELINES) { @@ -1598,6 +1657,7 @@ sp_desktop_query_style_from_list (const std::vector &list, SPStyle *sty int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property) { + // Used by text tool and in gradient dragging int ret = desktop->_query_style_signal.emit(style, property); if (ret != QUERY_STYLE_NOTHING) -- cgit v1.2.3 From ddf9853ed86846c5cc4e22a1ede31dafcda5c99d Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 16 May 2015 14:50:10 +0200 Subject: Enable setting of 'font-variant-position' and 'font-variant-caps'. Rendering awaits Pango update. (bzr r14155) --- src/desktop-style.cpp | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 118f983bb..f25ce8fa8 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1176,10 +1176,19 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ int texts = 0; SPILigatures* ligatures_res = &(style_res->font_variant_ligatures); - ligatures_res->computed = - SP_CSS_FONT_VARIANT_LIGATURES_COMMON | - SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL; + SPIEnum* position_res = &(style_res->font_variant_position); + SPIEnum* caps_res = &(style_res->font_variant_caps); + + // Stores 'and' of all values + ligatures_res->computed = SP_CSS_FONT_VARIANT_LIGATURES_NORMAL; + position_res->computed = SP_CSS_FONT_VARIANT_POSITION_NORMAL; + caps_res->computed = SP_CSS_FONT_VARIANT_CAPS_NORMAL; + + // Stores only differences ligatures_res->value = 0; + position_res->value = 0; + caps_res->value = 0; + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = *i; @@ -1195,20 +1204,36 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ texts ++; SPILigatures* ligatures_in = &(style->font_variant_ligatures); + SPIEnum* position_in = &(style->font_variant_position); + SPIEnum* caps_in = &(style->font_variant_caps); // computed stores which bits are on/off, only valid if same between all selected objects. // value stores which bits are different between objects. This is a bit of an abuse of // the values but then we don't need to add new variables to class. if (set) { ligatures_res->value |= (ligatures_res->computed ^ ligatures_in->computed ); ligatures_res->computed &= ligatures_in->computed; + + position_res->value |= (position_res->computed ^ position_in->computed ); + position_res->computed &= position_in->computed; + + caps_res->value |= (caps_res->computed ^ caps_in->computed ); + caps_res->computed &= caps_in->computed; + } else { - set = true; ligatures_res->computed = ligatures_in->computed; + position_res->computed = position_in->computed; + caps_res->computed = caps_in->computed; } + + set = true; } - bool different = (style_res->font_variant_position.value != - style_res->font_variant_position.computed ); + bool different = (style_res->font_variant_ligatures.value != + style_res->font_variant_ligatures.computed || + style_res->font_variant_position.value != + style_res->font_variant_position.computed || + style_res->font_variant_caps.value != + style_res->font_variant_caps.computed ); if (texts == 0 || !set) return QUERY_STYLE_NOTHING; -- cgit v1.2.3 From 7c7e740dd76054367ceae7f545ac27f0d7cdc7f0 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 18 May 2015 21:50:54 +0200 Subject: Enable setting of 'font-variant-ligatures' (rendering waits on new Pango library). (bzr r14162) --- src/desktop-style.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 3bb0ce71a..d2109c03c 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1178,17 +1178,20 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ SPILigatures* ligatures_res = &(style_res->font_variant_ligatures); SPIEnum* position_res = &(style_res->font_variant_position); SPIEnum* caps_res = &(style_res->font_variant_caps); - + SPINumeric* numeric_res = &(style_res->font_variant_numeric); + // Stores 'and' of all values ligatures_res->computed = SP_CSS_FONT_VARIANT_LIGATURES_NORMAL; position_res->computed = SP_CSS_FONT_VARIANT_POSITION_NORMAL; caps_res->computed = SP_CSS_FONT_VARIANT_CAPS_NORMAL; + numeric_res->computed = SP_CSS_FONT_VARIANT_NUMERIC_NORMAL; // Stores only differences ligatures_res->value = 0; position_res->value = 0; caps_res->value = 0; - + numeric_res->value = 0; + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = *i; @@ -1204,8 +1207,9 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ texts ++; SPILigatures* ligatures_in = &(style->font_variant_ligatures); - SPIEnum* position_in = &(style->font_variant_position); - SPIEnum* caps_in = &(style->font_variant_caps); + SPIEnum* position_in = &(style->font_variant_position); + SPIEnum* caps_in = &(style->font_variant_caps); + SPINumeric* numeric_in = &(style->font_variant_numeric); // computed stores which bits are on/off, only valid if same between all selected objects. // value stores which bits are different between objects. This is a bit of an abuse of // the values but then we don't need to add new variables to class. @@ -1219,21 +1223,23 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ caps_res->value |= (caps_res->computed ^ caps_in->computed ); caps_res->computed &= caps_in->computed; + numeric_res->value |= (numeric_res->computed ^ numeric_in->computed ); + numeric_res->computed &= numeric_in->computed; + } else { ligatures_res->computed = ligatures_in->computed; - position_res->computed = position_in->computed; - caps_res->computed = caps_in->computed; + position_res->computed = position_in->computed; + caps_res->computed = caps_in->computed; + numeric_res->computed = numeric_in->computed; } set = true; } - bool different = (style_res->font_variant_ligatures.value != - style_res->font_variant_ligatures.computed || - style_res->font_variant_position.value != - style_res->font_variant_position.computed || - style_res->font_variant_caps.value != - style_res->font_variant_caps.computed ); + bool different = (style_res->font_variant_ligatures.value != 0 || + style_res->font_variant_position.value != 0 || + style_res->font_variant_caps.value != 0 || + style_res->font_variant_numeric.value != 0 ); if (texts == 0 || !set) return QUERY_STYLE_NOTHING; -- cgit v1.2.3 From 00a70f10f4c5c273a783f87f61e9d98b9d79deca Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 22 Jun 2015 16:13:38 +0200 Subject: Add simple GUI for 'font-feature-settings'. (bzr r14208) --- src/desktop-style.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index d2109c03c..02c18339b 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1179,7 +1179,7 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ SPIEnum* position_res = &(style_res->font_variant_position); SPIEnum* caps_res = &(style_res->font_variant_caps); SPINumeric* numeric_res = &(style_res->font_variant_numeric); - + // Stores 'and' of all values ligatures_res->computed = SP_CSS_FONT_VARIANT_LIGATURES_NORMAL; position_res->computed = SP_CSS_FONT_VARIANT_POSITION_NORMAL; @@ -1256,6 +1256,63 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ } +int +objects_query_fontfeaturesettings (const std::vector &objects, SPStyle *style_res) +{ + bool different = false; + int texts = 0; + + if (style_res->font_feature_settings.value) { + g_free(style_res->font_feature_settings.value); + style_res->font_feature_settings.value = NULL; + } + style_res->font_feature_settings.set = FALSE; + + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + SPObject *obj = *i; + + // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; + if (!isTextualItem(obj)) { + continue; + } + + SPStyle *style = obj->style; + if (!style) { + continue; + } + + texts ++; + + if (style_res->font_feature_settings.value && style->font_feature_settings.value && + strcmp (style_res->font_feature_settings.value, style->font_feature_settings.value)) { + different = true; // different fonts + } + + if (style_res->font_feature_settings.value) { + g_free(style_res->font_feature_settings.value); + style_res->font_feature_settings.value = NULL; + } + + style_res->font_feature_settings.set = TRUE; + style_res->font_feature_settings.value = g_strdup(style->font_feature_settings.value); + } + + if (texts == 0 || !style_res->font_feature_settings.set) { + return QUERY_STYLE_NOTHING; + } + + if (texts > 1) { + if (different) { + return QUERY_STYLE_MULTIPLE_DIFFERENT; + } else { + return QUERY_STYLE_MULTIPLE_SAME; + } + } else { + return QUERY_STYLE_SINGLE; + } +} + + /** * Write to style_res the baseline numbers. */ @@ -1667,6 +1724,8 @@ sp_desktop_query_style_from_list (const std::vector &list, SPStyle *sty return objects_query_fontstyle (list, style); } else if (property == QUERY_STYLE_PROPERTY_FONTVARIANTS) { return objects_query_fontvariants (list, style); + } else if (property == QUERY_STYLE_PROPERTY_FONTFEATURESETTINGS) { + return objects_query_fontfeaturesettings (list, style); } else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) { return objects_query_fontnumbers (list, style); } else if (property == QUERY_STYLE_PROPERTY_BASELINES) { -- cgit v1.2.3