This PR closes the suggestions 1- 3 at the bottom of #606.
Suggestion 4 will be part of another PR.
Summary from NEWS.md:
layout_properties() gains a type_idx column to index phs of the same type on a layout. Indexing is performed based on ph position, following a top-to-bottom, left-to-right order.
plot_layout_properties() plots more information by default now: layout name, ph label, ph id, ph type + index by default.
ph_location_type(): new type_idx arg replaces the deprecated id arg.
1. layout_properties() gains a new type_idx column.
It is an index for placeholders of the same type on a layout. The index is sorted by ph position (top -> bottom, left -> right), for a user-friendly ordering logic (sorted by offy, then offx). (See change 2 below for a visual impression).
layout_properties(x, "Comparison")[, c(1:6, 8:9)]
master_name name type type_idx id ph_label offx offy
22 Office Theme Comparison title 1 2 Title 1 0.500000 0.3003478
23 Office Theme Comparison body 1 3 Text Placeholder 2 0.500000 1.6788200
24 Office Theme Comparison body 2 5 Text Placeholder 4 5.079861 1.6788200
25 Office Theme Comparison body 3 4 Content Placeholder 3 0.500000 2.3784722
26 Office Theme Comparison body 4 6 Content Placeholder 5 5.079861 2.3784722
27 Office Theme Comparison dt 1 7 Date Placeholder 6 0.500000 6.9513889
28 Office Theme Comparison ftr 1 8 Footer Placeholder 7 3.416667 6.9513889
29 Office Theme Comparison sldNum 1 9 Slide Number Placeholder 8 7.166667 6.9513889
2. plot_layout_properties(): with more ph info by default
The function now prints the ph label, type, type index, and layout name by default. The new args type = T/F and id = T/F allow to show or hide them. The type index also has an intuitive order (top->bottom, left->right). Previously, the indexing was done along the ph ids, which may result in an arbitrary index order.
ph label (red, column ph_label from layout_properties()))
type + type_idx (blue, column type and type_index from layout_properties())
id (green, unique per ph) (, i.e. column id from layout_properties()).
plot_layout_properties(x, "Comparison")
3. ph_location_type() gains new type_idx argument.
type_idx will replace the id arg. id is preserved for now to avoid a breaking change, but throws a deprecation warning. The arg name is changed to avoid confusion with the id column from layout_properties() which has another meaning.
In the example below, both args (type_idx and id) are used. Note that only type_idxuses the new indexing order. The index order of id is unchanged (using the old indexing logic along the ph id) to avoid a breaking change.
x <- x |> add_slide("Comparison")
x |> ph_with("NEW: type_idx", ph_location_label("Title 1"))
for (type_idx in 1:4) {
x |> ph_with(paste("type_idx:", type_idx), ph_location_type(type_idx = type_idx))
}
x <- x |> add_slide("Comparison")
x |> ph_with("OLD: id", ph_location_label("Title 1"))
for (id in 1:4) {
x |> ph_with(paste("id:", id), ph_location_type(id = id))
}
file <- tempfile(fileext = ".pptx")
print(x, file)
file.show(file)
Warning:
1: ! The `id` argument in `ph_location_type()` is deprecated as of officer 0.6.7.
ℹ Please use the `type_idx` argument instead.
✖ Caution: new index logic in `type_idx` (see docs).
2: ! The `id` argument in `ph_location_type()` is deprecated as of officer 0.6.7.
ℹ Please use the `type_idx` argument instead.
✖ Caution: new index logic in `type_idx` (see docs).
3: ! The `id` argument in `ph_location_type()` is deprecated as of officer 0.6.7.
ℹ Please use the `type_idx` argument instead.
✖ Caution: new index logic in `type_idx` (see docs).
4: ! The `id` argument in `ph_location_type()` is deprecated as of officer 0.6.7.
ℹ Please use the `type_idx` argument instead.
✖ Caution: new index logic in `type_idx` (see docs).
This PR closes the suggestions 1- 3 at the bottom of #606.
Suggestion 4 will be part of another PR.
Summary from
NEWS.md
:layout_properties()
gains atype_idx
column to index phs of the same type on a layout. Indexing is performed based on ph position, following a top-to-bottom, left-to-right order.plot_layout_properties()
plots more information by default now: layout name, ph label, ph id, ph type + index by default.ph_location_type()
: newtype_idx
arg replaces the deprecatedid
arg.1.
layout_properties()
gains a newtype_idx
column.It is an index for placeholders of the same type on a layout. The index is sorted by ph position (top -> bottom, left -> right), for a user-friendly ordering logic (sorted by
offy
, thenoffx
). (See change 2 below for a visual impression).2.
plot_layout_properties()
: with more ph info by defaultThe function now prints the ph label, type, type index, and layout name by default. The new args
type = T/F
andid = T/F
allow to show or hide them. The type index also has an intuitive order (top->bottom, left->right). Previously, the indexing was done along the ph ids, which may result in an arbitrary index order.ph_label
fromlayout_properties()
))type
andtype_index
fromlayout_properties()
)id
fromlayout_properties()
).3.
ph_location_type()
gains newtype_idx
argument.type_idx
will replace theid
arg.id
is preserved for now to avoid a breaking change, but throws a deprecation warning. The arg name is changed to avoid confusion with theid
column fromlayout_properties()
which has another meaning.In the example below, both args (
type_idx
andid
) are used. Note that onlytype_idx
uses the new indexing order. The index order ofid
is unchanged (using the old indexing logic along the ph id) to avoid a breaking change.