diff --git a/DESCRIPTION b/DESCRIPTION index 3bd01199..19e01edf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: flextable Type: Package Title: Functions for Tabular Reporting -Version: 0.9.5 +Version: 0.9.6.001 Authors@R: c( person("David", "Gohel", role = c("aut", "cre"), email = "david.gohel@ardata.fr"), diff --git a/NAMESPACE b/NAMESPACE index ed5388ee..3eaf6b94 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -374,6 +374,3 @@ importFrom(utils,packageVersion) importFrom(utils,tail) importFrom(uuid,UUIDgenerate) importFrom(xml2,as_xml_document) -importFrom(xml2,xml_find_first) -importFrom(xml2,xml_parent) -importFrom(xml2,xml_replace) diff --git a/NEWS.md b/NEWS.md index 8ca788bb..a41f7d64 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# flextable 0.9.6 + +## Changes + +- `headers_flextable_at_bkm()` and `footers_flextable_at_bkm()` are defunct. + # flextable 0.9.5 ## new features diff --git a/R/body_add_flextable.R b/R/body_add_flextable.R index b3b99295..7708a70a 100644 --- a/R/body_add_flextable.R +++ b/R/body_add_flextable.R @@ -158,63 +158,10 @@ body_add_flextable <- function(x, value, #' @param split set to TRUE if you want to activate Word #' option 'Allow row to break across pages'. #' @importFrom officer cursor_bookmark -#' @importFrom xml2 xml_replace as_xml_document xml_find_first xml_parent +#' @importFrom xml2 as_xml_document body_replace_flextable_at_bkm <- function(x, bookmark, value, align = "center", split = FALSE) { x <- cursor_bookmark(x, bookmark) x <- body_add_flextable(x = x, value = value, pos = "on", align = align, split = split) x } -#' @export -#' @title Add flextable at a bookmark location in document's header -#' @description replace in the header of a document a paragraph containing a bookmark by a flextable. -#' A bookmark will be considered as valid if enclosing words -#' within a paragraph; i.e., a bookmark along two or more paragraphs is invalid, -#' a bookmark set on a whole paragraph is also invalid, but bookmarking few words -#' inside a paragraph is valid. -#' @param x an rdocx object -#' @param bookmark bookmark id -#' @param value a flextable object -#' @keywords internal -headers_flextable_at_bkm <- function(x, bookmark, value) { - stopifnot(inherits(x, "rdocx"), inherits(value, "flextable")) - .Deprecated(new = "use `prop_section(header_default = block_list(your_flextable))`") - str <- gen_raw_wml(value, doc = x) - xml_elt <- as_xml_document(str) - for (header in x$headers) { - node <- xml_find_first(header$get(), sprintf('//w:bookmarkStart[@w:name="%s"]', bookmark)) - if (!inherits(node, "xml_missing")) { - node <- xml_parent(node) - xml_replace(node, xml_elt) - } - } - - x -} - -#' @export -#' @title Add flextable at a bookmark location in document's footer -#' @description replace in the footer of a document a paragraph containing a bookmark by a flextable. -#' A bookmark will be considered as valid if enclosing words -#' within a paragraph; i.e., a bookmark along two or more paragraphs is invalid, -#' a bookmark set on a whole paragraph is also invalid, but bookmarking few words -#' inside a paragraph is valid. -#' @param x an rdocx object -#' @param bookmark bookmark id -#' @param value a flextable object -#' @keywords internal -footers_flextable_at_bkm <- function(x, bookmark, value) { - stopifnot(inherits(x, "rdocx"), inherits(value, "flextable")) - .Deprecated(new = "use `prop_section(footer_default = block_list(your_flextable))`") - str <- gen_raw_wml(value, doc = x) - xml_elt <- as_xml_document(str) - for (footer in x$footers) { - node <- xml_find_first(footer$get(), sprintf('//w:bookmarkStart[@w:name="%s"]', bookmark)) - if (!inherits(node, "xml_missing")) { - node <- xml_parent(node) - xml_replace(node, xml_elt) - } - } - - x -} diff --git a/R/zz-defunct.R b/R/zz-defunct.R new file mode 100644 index 00000000..bf1b4c9b --- /dev/null +++ b/R/zz-defunct.R @@ -0,0 +1,17 @@ +#' @export +#' @title Add flextable at a bookmark location in document's header +#' @description Function is now defunct, use [prop_section()] instead. +#' @param ... unused +#' @keywords internal +headers_flextable_at_bkm <- function(...) { + .Defunct(new = "prop_section", package = "officer") +} + +#' @export +#' @title Add flextable at a bookmark location in document's footer +#' @description Function is now defunct, use [prop_section()] instead. +#' @param ... unused +#' @keywords internal +footers_flextable_at_bkm <- function(...) { + .Defunct(new = "prop_section", package = "officer") +} diff --git a/man/footers_flextable_at_bkm.Rd b/man/footers_flextable_at_bkm.Rd index c53da5c8..952dce95 100644 --- a/man/footers_flextable_at_bkm.Rd +++ b/man/footers_flextable_at_bkm.Rd @@ -1,23 +1,15 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/body_add_flextable.R +% Please edit documentation in R/zz-defunct.R \name{footers_flextable_at_bkm} \alias{footers_flextable_at_bkm} \title{Add flextable at a bookmark location in document's footer} \usage{ -footers_flextable_at_bkm(x, bookmark, value) +footers_flextable_at_bkm(...) } \arguments{ -\item{x}{an rdocx object} - -\item{bookmark}{bookmark id} - -\item{value}{a flextable object} +\item{...}{unused} } \description{ -replace in the footer of a document a paragraph containing a bookmark by a flextable. -A bookmark will be considered as valid if enclosing words -within a paragraph; i.e., a bookmark along two or more paragraphs is invalid, -a bookmark set on a whole paragraph is also invalid, but bookmarking few words -inside a paragraph is valid. +Function is now defunct, use \code{\link[=prop_section]{prop_section()}} instead. } \keyword{internal} diff --git a/man/headers_flextable_at_bkm.Rd b/man/headers_flextable_at_bkm.Rd index 8f248737..1c56035a 100644 --- a/man/headers_flextable_at_bkm.Rd +++ b/man/headers_flextable_at_bkm.Rd @@ -1,23 +1,15 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/body_add_flextable.R +% Please edit documentation in R/zz-defunct.R \name{headers_flextable_at_bkm} \alias{headers_flextable_at_bkm} \title{Add flextable at a bookmark location in document's header} \usage{ -headers_flextable_at_bkm(x, bookmark, value) +headers_flextable_at_bkm(...) } \arguments{ -\item{x}{an rdocx object} - -\item{bookmark}{bookmark id} - -\item{value}{a flextable object} +\item{...}{unused} } \description{ -replace in the header of a document a paragraph containing a bookmark by a flextable. -A bookmark will be considered as valid if enclosing words -within a paragraph; i.e., a bookmark along two or more paragraphs is invalid, -a bookmark set on a whole paragraph is also invalid, but bookmarking few words -inside a paragraph is valid. +Function is now defunct, use \code{\link[=prop_section]{prop_section()}} instead. } \keyword{internal}