From 98cbf65b029df0cfb9f6b7d34538258fe4ee96c5 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Mon, 28 Oct 2019 12:32:35 +0100 Subject: refactor: TypedSPI --- src/widgets/fill-style.cpp | 8 ++++---- src/widgets/gradient-vector.cpp | 2 +- src/widgets/paint-selector.cpp | 2 +- src/widgets/stroke-style.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index f8eb00d7a..114cbb1b3 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -248,8 +248,8 @@ void FillNStroke::performUpdate() // query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection int result = sp_desktop_query_style(desktop, &query, (kind == FILL) ? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE); - SPIPaint &targPaint = (kind == FILL) ? query.fill : query.stroke; - SPIScale24 &targOpacity = (kind == FILL) ? query.fill_opacity : query.stroke_opacity; + SPIPaint &targPaint = *query.getFillOrStroke(kind == FILL); + SPIScale24 &targOpacity = *(kind == FILL ? query.fill_opacity.upcast() : query.stroke_opacity.upcast()); switch (result) { case QUERY_STYLE_NOTHING: @@ -561,7 +561,7 @@ void FillNStroke::updateFromPaint() SPStyle query(desktop->doc()); int result = objects_query_fillstroke(items, &query, kind == FILL); if (result == QUERY_STYLE_MULTIPLE_SAME) { - SPIPaint &targPaint = (kind == FILL) ? query.fill : query.stroke; + SPIPaint &targPaint = *query.getFillOrStroke(kind == FILL); SPColor common; if (!targPaint.isColor()) { common = sp_desktop_get_color(desktop, kind == FILL); @@ -755,7 +755,7 @@ void FillNStroke::updateFromPaint() SPObject *selobj = item; SPStyle *style = selobj->style; - if (style && ((kind == FILL) ? style->fill : style->stroke).isPaintserver()) { + if (style && ((kind == FILL) ? style->fill.isPaintserver() : style->stroke.isPaintserver())) { SPPaintServer *server = (kind == FILL) ? selobj->style->getFillPaintServer() : selobj->style->getStrokePaintServer(); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index cc5fe0185..b9bd99bd8 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -346,7 +346,7 @@ static void get_all_doc_items(std::vector &list, SPObject *from) */ static SPGradient * gr_item_get_gradient(SPItem *item, gboolean fillorstroke) { - SPIPaint *item_paint = (fillorstroke) ? &(item->style->fill) : &(item->style->stroke); + SPIPaint *item_paint = item->style->getFillOrStroke(fillorstroke); if (item_paint->isPaintserver()) { SPPaintServer *item_server = (fillorstroke) ? diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index e80951928..e108fa504 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -1545,7 +1545,7 @@ void SPPaintSelector::setFlatColor( SPDesktop *desktop, gchar const *color_prope SPPaintSelector::Mode SPPaintSelector::getModeForStyle(SPStyle const & style, FillOrStroke kind) { Mode mode = MODE_UNSET; - SPIPaint const & target = (kind == FILL) ? style.fill : style.stroke; + SPIPaint const &target = *style.getFillOrStroke(kind == FILL); if ( !target.set ) { mode = MODE_UNSET; diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 48f0e3d78..44f9ac714 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -877,7 +877,7 @@ StrokeStyle::updateLine() int result_order = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_PAINTORDER); - SPIPaint &targPaint = (kind == FILL) ? query.fill : query.stroke; + SPIPaint &targPaint = *query.getFillOrStroke(kind == FILL); if (!sel || sel->isEmpty()) { // Nothing selected, grey-out all controls in the stroke-style dialog -- cgit v1.2.3