Skip to content

Commit

Permalink
internals: ph_with.xml_document gather images paths in slide
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgohel committed Dec 20, 2022
1 parent b32af49 commit 3b6dfc0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: officer
Type: Package
Title: Manipulation of Microsoft Word and PowerPoint Documents
Version: 0.4.5.013
Version: 0.4.5.014
Authors@R: c(
person("David", "Gohel", role = c("aut", "cre"),
email = "david.gohel@ardata.fr"),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ associated with a Word character style.
a match in the document.
- add function `docx_current_block_xml()` to let developpers access
the xml content where the cursor is.
- `ph_with.xml_document` now manages images paths in slide and
treats them in the relevant documents.

## Issues

Expand Down
7 changes: 7 additions & 0 deletions R/ppt_classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ slide <- R6Class(
xml_attr( cnvpr[[i]], "id") <- i
self
},
reference_img = function(src, dir_name){
src <- unique( src )
private$rels_doc$add_img(src, root_target = "../media")
dir.create(dir_name, recursive = TRUE, showWarnings = FALSE)
file.copy(from = src, to = file.path(dir_name, basename(src)))
self
},

reference_slide = function(slide_file){

Expand Down
5 changes: 3 additions & 2 deletions R/ppt_ph_with_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ ph_with.empty_content <- function( x, value, location, ... ){



xml_to_slide <- function(slide, location, value){
xml_to_slide <- function(slide, location, value, package_dir){
node <- xml_find_first( value, as_xpath_content_sel("//") )
if(xml_name(node) == "grpSp"){
node_sppr <- xml_child(node, "p:grpSpPr")
Expand Down Expand Up @@ -558,9 +558,10 @@ ph_with.xml_document <- function( x, value, location, ... ){

location <- fortify_location(location, doc = x)

xml_to_slide(slide, location, value)
xml_to_slide(slide, location, value, x$package_dir)

xml_add_child(xml_find_first(slide$get(), "//p:spTree"), value)
process_images(slide, slide$relationship(), x$package_dir, media_dir = "ppt/media", media_rel_dir = "../media")

slide$fortify_id()
x
Expand Down

0 comments on commit 3b6dfc0

Please sign in to comment.