-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
layout_summary() layout order deviates from layout order in PPTX file #596
Comments
In class `dir_collection`, files are added to a container during initialization using alphabetical sorting. This caused the slide layout order to deviate from the one in the PPTX file, for example, when calling layout_summary(). Files are now added to a container in the order of their trailing numeric index. For example, `slideLayout2.xml` will now preceed `slideLayout10.xml`. Before, alphabetical sorting was used, where `slideLayout10.xml` comes before `slideLayout2.xml`.
@davidgohel I changed the order in which files are added to the container in this branch in this file. The layout order comes out as expected now: url <- "https://github.com/user-attachments/files/16825504/many_layouts.pptx"
file <- tempfile(fileext = ".pptx")
download.file(url, file)
x <- read_pptx(file)
layout_summary(x)
All tests are still passed. However, this is a change in a central class. So I would like to make sure, that there are no unwanted side effects. An alternative to this approach would be to do the reordering directly in @davidgohel What do you think? |
@markheckmann I think you are focused and accurate on these aspects. For professional reasons, I don't have the ability to focus on the subject these days (things should be better after September/October). So if you feel able to PR, again it will be welcome. If something break, I think the coverage test will show it (and if not, well I'll take time to fix what need to be fixed) |
okay, great. PR is ready |
The order of the layouts in
layout_summary()
may deviate from the layout order in the PPTX master.As this may irritate the user (in this case me :D), I suggest to return a layout order that matches the one in the PPTX file.
Example
File: many_layouts.pptx => This is the internal
template.pptx
with 4 new layouts (layout_8
tolayout_11
) added at the end.NB: I used
x$slideLayouts$get_metadata()
aslayout_summary()
calls this function internally.layout_10
andlayout_11
should appear at the end, like in the PPTX file. However, the ordering inx$slideLayouts$get_metadata()
appears to be lexicographical overfilename
. Hence,10
and11
come before2
, yielding a layout order that deviates from the PPTX file.Analysis
The reason for this lies in the way how the file names are read during initialization in class
dir_collection
(see line 10 in file ppt_class_dir_collection.R.As per the docs,
list.files
will apply an alphabetic sort here:The text was updated successfully, but these errors were encountered: