Skip to content

Commit ab0d3ce

Browse files
committed
fix: repair svg insertion into Word
see #700
1 parent 03a70be commit ab0d3ce

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: officer
33
Title: Manipulation of Microsoft Word and PowerPoint Documents
4-
Version: 0.7.2.004
4+
Version: 0.7.2.005
55
Authors@R: c(
66
person("David", "Gohel", , "david.gohel@ardata.fr", role = c("aut", "cre")),
77
person("Stefan", "Moog", , "moogs@gmx.de", role = "aut"),

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- RTF support strike text setting.
66
- fix an issue with bookmark selections in `docx_summary()`.
77
- fix `fp_par_lite()` management of argument `tabs`.
8+
- there was a regression with svg in docx, it is solved now.
89

910
## Features
1011

R/post-proc.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ sanitize_images <- function(x, warn_user = TRUE) {
213213
all_docs[[length(all_docs)+1]] <- x$doc_obj
214214
all_docs[[length(all_docs)+1]] <- x$footnotes
215215

216-
for (header in all_docs) {
216+
for (doc_part in all_docs) {
217217
suppressWarnings({
218-
blip_nodes <- xml_find_all(header$get(), "//a:blip[contains(@r:embed, 'rId')]")
218+
blip_nodes <- xml_find_all(doc_part$get(), "//a:blip[contains(@r:embed, 'rId')]|//asvg:svgBlip[contains(@r:embed, 'rId')]")
219219
})
220220
embed_list <- xml_attr(blip_nodes, "embed")
221221
embed_data <- filter(
222-
.data = header$rel_df(),
222+
.data = doc_part$rel_df(),
223223
basename(.data$type) %in% "image",
224224
.data$id %in% embed_list
225225
)

tests/testthat/test-images.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ test_that("add svg in docx", {
139139
expect_false(inherits(node_svgblip, "xml_missing"))
140140
expect_true(all(xml_attr(node_svgblip, "embed") %in% subset_rel$id))
141141
}
142+
new_file <- print(x, target = tempfile(fileext = ".docx"))
143+
new_folder <- unpack_folder(new_file, tempfile())
144+
media_files <- list.files(file.path(new_folder, "word", "media"))
145+
expect_length(media_files, 2)
142146
})
143147

144148
test_that("add svg in pptx", {

0 commit comments

Comments
 (0)