Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
gnumeric
Commits
47d6c7ab
Commit
47d6c7ab
authored
Jan 18, 2021
by
Morten Welinder
Browse files
Conditional formatting: fix insert/delete col/row problems.
See
#547
, item 4.
parent
eee4e357
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/sheet-conditions.c
View file @
47d6c7ab
...
...
@@ -200,7 +200,7 @@ sheet_conditions_uninit (Sheet *sheet)
/**
* sheet_conditions_share_conditions_add:
* @conds: (transfer none):
* @conds: (transfer none):
*
* Returns: (transfer none) (nullable): Conditions equivalent to @conds, or
* %NULL if @conds had not been seen before.
...
...
@@ -227,7 +227,7 @@ sheet_conditions_share_conditions_add (GnmStyleConditions *conds)
/**
* sheet_conditions_share_conditions_remove:
* @conds: (transfer none):
* @conds: (transfer none):
*
* This notifies the sheet conditions manager that one use of the shared
* conditions has gone away.
...
...
@@ -374,7 +374,7 @@ sheet_conditions_remove (Sheet *sheet, GnmRange const *r, GnmStyle *style)
return
;
}
g_printerr
(
"Removing style %p from %s
\n
"
,
style
,
range_as_string
(
r
));
//
g_printerr ("Removing style %p from %s\n", style, range_as_string (r));
g
=
find_group
(
cd
,
style
);
if
(
!
g
)
{
g_warning
(
"Removing conditional style we don't have?"
);
...
...
@@ -436,6 +436,58 @@ sheet_conditions_remove (Sheet *sheet, GnmRange const *r, GnmStyle *style)
// ----------------------------------------------------------------------------
static
void
lu1
(
GnmDependent
*
dep
,
gboolean
qlink
)
{
if
(
dep
==
NULL
||
dep
->
texpr
==
NULL
||
qlink
==
!!
dependent_is_linked
(
dep
))
return
;
if
(
qlink
)
dependent_link
(
dep
);
else
dependent_unlink
(
dep
);
}
void
sheet_conditions_link_unlink_dependents
(
Sheet
*
sheet
,
GnmRange
const
*
r
,
gboolean
qlink
)
{
GnmSheetConditionsData
*
cd
=
sheet
->
conditions
;
GHashTableIter
hiter
;
gpointer
value
;
g_hash_table_iter_init
(
&
hiter
,
cd
->
groups
);
while
(
g_hash_table_iter_next
(
&
hiter
,
NULL
,
&
value
))
{
CSGroup
*
g
=
value
;
unsigned
ui
,
ri
;
gboolean
overlap
=
(
r
==
NULL
);
GPtrArray
const
*
ga
;
for
(
ri
=
0
;
!
overlap
&&
ri
<
g
->
ranges
->
len
;
ri
++
)
{
GnmRange
const
*
r1
=
&
g_array_index
(
g
->
ranges
,
GnmRange
,
ri
);
if
(
range_overlap
(
r
,
r1
))
overlap
=
TRUE
;
}
if
(
!
overlap
)
continue
;
lu1
(
&
g
->
dep
.
base
,
qlink
);
ga
=
gnm_style_conditions_details
(
g
->
conds
);
for
(
ui
=
0
;
ui
<
(
ga
?
ga
->
len
:
0u
);
ui
++
)
{
GnmStyleCond
*
cond
=
g_ptr_array_index
(
ga
,
ui
);
unsigned
ix
;
for
(
ix
=
0
;
ix
<
G_N_ELEMENTS
(
cond
->
deps
);
ix
++
)
lu1
(
&
cond
->
deps
[
ix
].
base
,
qlink
);
}
}
}
// ----------------------------------------------------------------------------
static
void
set_group_pos_and_expr
(
CSGroup
*
g
,
const
GnmCellPos
*
pos
,
GnmExprTop
const
*
texpr
)
{
...
...
src/sheet-conditions.h
View file @
47d6c7ab
...
...
@@ -18,6 +18,10 @@ void sheet_conditions_remove (Sheet *sheet, GnmRange const *r, GnmStyle *style);
void
sheet_conditions_simplify
(
Sheet
*
sheet
);
void
sheet_conditions_dump
(
Sheet
*
sheet
);
void
sheet_conditions_link_unlink_dependents
(
Sheet
*
sheet
,
GnmRange
const
*
r
,
gboolean
qlink
);
G_END_DECLS
#endif
src/sheet-style.c
View file @
47d6c7ab
...
...
@@ -328,17 +328,6 @@ rstyle_apply (GnmStyle **old, ReplacementStyle *rs, GnmRange const *r)
}
}
void
sheet_style_clear_style_dependents
(
Sheet
*
sheet
,
GnmRange
const
*
r
)
{
GSList
*
styles
=
sh_all_styles
(
sheet
->
style_data
->
style_hash
);
g_slist_foreach
(
styles
,
(
GFunc
)
gnm_style_unlink_dependents
,
(
gpointer
)
r
);
g_slist_free
(
styles
);
}
/****************************************************************************/
typedef
enum
{
...
...
src/sheet-style.h
View file @
47d6c7ab
...
...
@@ -108,8 +108,6 @@ void sheet_style_unlink (Sheet *sheet, GnmStyle *st);
void
sheet_style_optimize
(
Sheet
*
sheet
);
void
sheet_style_clear_style_dependents
(
Sheet
*
sheet
,
GnmRange
const
*
r
);
G_END_DECLS
#endif
/* _GNM_SHEET_STYLE_H_ */
src/sheet.c
View file @
47d6c7ab
...
...
@@ -5392,8 +5392,8 @@ sheet_insdel_colrow (Sheet *sheet, int pos, int count,
reloc_info
.
origin_sheet
=
reloc_info
.
target_sheet
=
sheet
;
parse_pos_init_sheet
(
&
reloc_info
.
pos
,
sheet
);
/
*
2. Get rid of style dependents, see #741197.
*/
sheet_
style_clear_style
_dependents
(
sheet
,
&
change_zone
);
/
/
2. Get rid of style dependents, see #741197.
sheet_
conditions_link_unlink
_dependents
(
sheet
,
&
change_zone
,
FALSE
);
/* 3. Invalidate references to kill zone. */
if
(
is_insert
)
{
...
...
@@ -5431,6 +5431,7 @@ sheet_insdel_colrow (Sheet *sheet, int pos, int count,
/* 7. Move formatting. */
sheet_style_insdel_colrow
(
&
reloc_info
);
sheet_conditions_link_unlink_dependents
(
sheet
,
NULL
,
TRUE
);
/* 8. Move objects. */
sheet_objects_relocate
(
&
reloc_info
,
FALSE
,
pundo
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment