From 13b2291c5209c3cbd02f4073b048bc705fdd2bcc Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Fri, 18 Jul 2025 14:19:09 -0700 Subject: [PATCH 01/12] Add support for columns --- src/WriteDocx.jl | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/WriteDocx.jl b/src/WriteDocx.jl index abfa7d6..77b0abd 100644 --- a/src/WriteDocx.jl +++ b/src/WriteDocx.jl @@ -1037,6 +1037,19 @@ Base.@kwdef struct Footers even::Maybe{Footer} = nothing end +Base.@kwdef struct Column + width::Maybe{Twip} = nothing + space::Maybe{Twip} = nothing +end + +Base.@kwdef struct Columns + equal::Bool = true + sep::Bool = false + space::Maybe{Twip} = nothing + num::Int = 1 + cols::Vector{Column} = Column[] +end + """ SectionProperties(; kwargs...) @@ -1050,12 +1063,14 @@ Holds properties for a [`Section`](@ref). | `valign::PageVerticalAlign.T` | The vertical alignment of content on each page of the section. | | `headers::`[`Headers`](@ref) | Defines the header content shown at the top of each page of the section. | | `footers::`[`Footers`](@ref) | Defines the footer content shown at the bottom of each page of the section. | +| `columns::`[`Columns`](@ref) | Configures the columns in the section | """ Base.@kwdef struct SectionProperties pagesize::Maybe{PageSize} = nothing valign::Maybe{PageVerticalAlign.T} = nothing headers::Maybe{Headers} = nothing footers::Maybe{Footers} = nothing + columns::Maybe{Columns} = nothing end """ @@ -1593,6 +1608,9 @@ function to_xml(body::Body, rels) if props.valign !== nothing E.link!(section_params_node, to_xml(props.valign, rels)) end + if props.columns !== nothing + E.link!(section_params_node, to_xml(props.columns, rels)) + end if props.headers !== nothing for type in (:default, :first, :even) x = getproperty(props.headers, type) @@ -1827,6 +1845,14 @@ function children(p::ParagraphProperties) return c end +function children(p::Columns) + c = [] + if !p.equal + append!(c, p.cols) + end + return c +end + function children(p::TableCellProperties) c = [] p.borders === nothing || push!(c, p.borders) @@ -1915,6 +1941,19 @@ end attributes(p::ParagraphStyle) = (("w:val", p.name),) attributes(p::RunStyle) = (("w:val", p.name),) attributes(p::VerticalAlignment.T) = (("w:val", p),) +attributes(p::Column) = (("w:w", p.width), ("w:space", p.space)) +function attributes(p::Columns) + attrs = Tuple{String, Any}[] + if p.num > 1 && p.equal + push!(attrs, ("w:num", p.num)) + p.sep === false || push!(attrs, ("w:sep", p.sep)) + p.space === nothing || push!(attrs, ("w:space", p.space)) + elseif !p.equal + push!(attrs, ("w:equalWidth", p.equal)) + p.sep === false || push!(attrs, ("w:sep", p.sep)) + end + return attrs +end function attributes(f::Fonts) attrs = Tuple{String, Any}[] f.ascii === nothing || push!(attrs, ("w:ascii", f.ascii)) @@ -2012,6 +2051,8 @@ function xmltag(t::Tuple{ParagraphBorder, Symbol}) end xmltag(::PageSize) = "w:pgSz" xmltag(::PageVerticalAlign.T) = "w:vAlign" +xmltag(::Columns) = "w:cols" +xmltag(::Column) = "w:col" xmltag(::Style) = "w:style" xmltag(::Justification.T) = "w:jc" xmltag(::Fonts) = "w:rFonts" From b40cc5af671b36d51b5e1499645eb40afec06dcd Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Fri, 18 Jul 2025 14:35:49 -0700 Subject: [PATCH 02/12] Allow specifying page/section margins --- src/WriteDocx.jl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/WriteDocx.jl b/src/WriteDocx.jl index 77b0abd..998ee23 100644 --- a/src/WriteDocx.jl +++ b/src/WriteDocx.jl @@ -1050,6 +1050,16 @@ Base.@kwdef struct Columns cols::Vector{Column} = Column[] end +Base.@kwdef struct PageMargins + top::Twip + right::Twip + bottom::Twip + left::Twip + header::Twip = top + footer::Twip = bottom + gutter::Twip = Twip(0) +end + """ SectionProperties(; kwargs...) @@ -1060,6 +1070,7 @@ Holds properties for a [`Section`](@ref). | Keyword | Description | | :-- | :-- | | `pagesize::PageSize` | The size of each page in the section. | +| `margins::PageMargins` | The margins for each page in the section | | `valign::PageVerticalAlign.T` | The vertical alignment of content on each page of the section. | | `headers::`[`Headers`](@ref) | Defines the header content shown at the top of each page of the section. | | `footers::`[`Footers`](@ref) | Defines the footer content shown at the bottom of each page of the section. | @@ -1067,6 +1078,7 @@ Holds properties for a [`Section`](@ref). """ Base.@kwdef struct SectionProperties pagesize::Maybe{PageSize} = nothing + margins::Maybe{PageMargins} = nothing valign::Maybe{PageVerticalAlign.T} = nothing headers::Maybe{Headers} = nothing footers::Maybe{Footers} = nothing @@ -1605,6 +1617,9 @@ function to_xml(body::Body, rels) if props.pagesize !== nothing E.link!(section_params_node, to_xml(props.pagesize, rels)) end + if props.margins !== nothing + E.link!(section_params_node, to_xml(props.margins, rels)) + end if props.valign !== nothing E.link!(section_params_node, to_xml(props.valign, rels)) end @@ -1925,6 +1940,7 @@ function attributes(t::Union{TableCellBorder, ParagraphBorder}) return attrs end attributes(p::PageSize) = (("w:h", p.height), ("w:w", p.width), ("w:orient", p.orientation)) +attributes(p::PageMargins) = (("w:top", p.top), ("w:right", p.right), ("w:bottom", p.bottom), ("w:left", p.left), ("w:header", p.header), ("w:footer", p.footer), ("w:gutter", p.gutter)) attributes(p::PageVerticalAlign.T) = (("w:val", p),) attributes(p::Justification.T) = (("w:val", p),) function attributes(s::Style) @@ -2050,6 +2066,7 @@ function xmltag(t::Tuple{ParagraphBorder, Symbol}) throw(ArgumentError("Invalid symbol $(repr(sym)), options are :top, :left, :right, :bottom, :between.")) end xmltag(::PageSize) = "w:pgSz" +xmltag(::PageMargins) = "w:pgMar" xmltag(::PageVerticalAlign.T) = "w:vAlign" xmltag(::Columns) = "w:cols" xmltag(::Column) = "w:col" From c386edf0b1142fa51807e4586347bb72ed989a4b Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Fri, 25 Jul 2025 16:57:10 -0700 Subject: [PATCH 03/12] fixup columns --- src/WriteDocx.jl | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/WriteDocx.jl b/src/WriteDocx.jl index 998ee23..c781845 100644 --- a/src/WriteDocx.jl +++ b/src/WriteDocx.jl @@ -1037,17 +1037,39 @@ Base.@kwdef struct Footers even::Maybe{Footer} = nothing end +""" + Column(; [width::Twip, space::Twip]) + +Describes a single column. `width` sets the column width, and `space` sets the whitespace after the column (before the next column). + +See also: [`Columns`](@ref) +""" Base.@kwdef struct Column width::Maybe{Twip} = nothing space::Maybe{Twip} = nothing end +""" + Columns(; kwargs...) + +Sets the columns for a [`Section`](@ref). + +## Keyword arguments + +| Keyword | Description | +| :-- | :-- | +| `equal::Bool = true` | Whether all columns are equal-width with the same space between every column | +| `num::Int` | The number of equal-width columns to layout. | +| `space::`[`Twip`](@ref) | The space between equal-width columns. | +| `sep::Bool = false` | Sets whether a vertical separator line is drawn between columns | +| `cols::Vector{`[`Column`](@ref)`}` | A vector of custom columns. `equal`, `num`, and `space` are ignored if `cols` is provided. | +""" Base.@kwdef struct Columns - equal::Bool = true - sep::Bool = false - space::Maybe{Twip} = nothing num::Int = 1 + space::Maybe{Twip} = nothing + sep::Bool = false cols::Vector{Column} = Column[] + equal::Bool = isempty(cols) end Base.@kwdef struct PageMargins @@ -1957,10 +1979,16 @@ end attributes(p::ParagraphStyle) = (("w:val", p.name),) attributes(p::RunStyle) = (("w:val", p.name),) attributes(p::VerticalAlignment.T) = (("w:val", p),) -attributes(p::Column) = (("w:w", p.width), ("w:space", p.space)) +function attributes(p::Column) + attrs = Tuple{String, Any}[] + p.width === nothing || push!(attrs, ("w:w", p.width)) + p.space === nothing || push!(attrs, ("w:space", p.space)) + return attrs +end function attributes(p::Columns) attrs = Tuple{String, Any}[] if p.num > 1 && p.equal + push!(attrs, ("w:equalWidth", p.equal)) push!(attrs, ("w:num", p.num)) p.sep === false || push!(attrs, ("w:sep", p.sep)) p.space === nothing || push!(attrs, ("w:space", p.space)) From a1c0252648c0a7100caecd609a56ef8b2fca2ea8 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Fri, 25 Jul 2025 16:57:29 -0700 Subject: [PATCH 04/12] fixup pagemargins --- src/WriteDocx.jl | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/WriteDocx.jl b/src/WriteDocx.jl index c781845..b7a6f06 100644 --- a/src/WriteDocx.jl +++ b/src/WriteDocx.jl @@ -1072,13 +1072,30 @@ Base.@kwdef struct Columns equal::Bool = isempty(cols) end +""" + PageMargins(; top, right, bottom, left, kwargs...) + +Describes page margins in a [`Section`](@ref). + +## Keyword arguments + +| Keyword | Description | +| :-- | :-- | +| `top::`[`Twip`](@ref) | The top margin. | +| `right::`[`Twip`](@ref) | The right margin. | +| `bottom::`[`Twip`](@ref) | The bottom margin. | +| `left::`[`Twip`](@ref) | The left margin. | +| `header::`[`Twip`](@ref)`=Twip(0)` | The header margin. | +| `footer::`[`Twip`](@ref)`=Twip(0)` | The footer margin. | +| `gutter::`[`Twip`](@ref)`=Twip(0)` | The gutter margin. | +""" Base.@kwdef struct PageMargins top::Twip right::Twip bottom::Twip left::Twip - header::Twip = top - footer::Twip = bottom + header::Twip = Twip(0) + footer::Twip = Twip(0) gutter::Twip = Twip(0) end From 87aecc32e7209c68ba4a7c7202f284232494ad89 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Fri, 25 Jul 2025 16:58:58 -0700 Subject: [PATCH 05/12] Add tests for columns and page margins --- test/references/breaks/word/document.xml | 18 ++- test/references/columns/[Content_Types].xml | 10 ++ test/references/columns/_rels/.rels | 5 + .../columns/word/_rels/document.xml.rels | 4 + test/references/columns/word/document.xml | 44 ++++++ test/references/columns/word/styles.xml | 142 ++++++++++++++++++ .../page_margins/[Content_Types].xml | 10 ++ test/references/page_margins/_rels/.rels | 5 + .../page_margins/word/_rels/document.xml.rels | 4 + .../references/page_margins/word/document.xml | 27 ++++ test/references/page_margins/word/styles.xml | 142 ++++++++++++++++++ test/runtests.jl | 64 ++++++++ 12 files changed, 474 insertions(+), 1 deletion(-) create mode 100644 test/references/columns/[Content_Types].xml create mode 100644 test/references/columns/_rels/.rels create mode 100644 test/references/columns/word/_rels/document.xml.rels create mode 100644 test/references/columns/word/document.xml create mode 100644 test/references/columns/word/styles.xml create mode 100644 test/references/page_margins/[Content_Types].xml create mode 100644 test/references/page_margins/_rels/.rels create mode 100644 test/references/page_margins/word/_rels/document.xml.rels create mode 100644 test/references/page_margins/word/document.xml create mode 100644 test/references/page_margins/word/styles.xml diff --git a/test/references/breaks/word/document.xml b/test/references/breaks/word/document.xml index 4ae1d18..f4270f6 100644 --- a/test/references/breaks/word/document.xml +++ b/test/references/breaks/word/document.xml @@ -12,6 +12,22 @@ after page break - + + + + + + + + + + column 1 + + column 2 + + + + + diff --git a/test/references/columns/[Content_Types].xml b/test/references/columns/[Content_Types].xml new file mode 100644 index 0000000..95c03c6 --- /dev/null +++ b/test/references/columns/[Content_Types].xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/test/references/columns/_rels/.rels b/test/references/columns/_rels/.rels new file mode 100644 index 0000000..27e1e49 --- /dev/null +++ b/test/references/columns/_rels/.rels @@ -0,0 +1,5 @@ + + + + diff --git a/test/references/columns/word/_rels/document.xml.rels b/test/references/columns/word/_rels/document.xml.rels new file mode 100644 index 0000000..66cfbbf --- /dev/null +++ b/test/references/columns/word/_rels/document.xml.rels @@ -0,0 +1,4 @@ + + + + diff --git a/test/references/columns/word/document.xml b/test/references/columns/word/document.xml new file mode 100644 index 0000000..c4526b4 --- /dev/null +++ b/test/references/columns/word/document.xml @@ -0,0 +1,44 @@ + + + + + + + + Section 1 + + + + + + + + + + + + 2 columns + + + + + + + + + + + + + + different width columns + + + + + + + + + + diff --git a/test/references/columns/word/styles.xml b/test/references/columns/word/styles.xml new file mode 100644 index 0000000..7b8142b --- /dev/null +++ b/test/references/columns/word/styles.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/references/page_margins/[Content_Types].xml b/test/references/page_margins/[Content_Types].xml new file mode 100644 index 0000000..95c03c6 --- /dev/null +++ b/test/references/page_margins/[Content_Types].xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/test/references/page_margins/_rels/.rels b/test/references/page_margins/_rels/.rels new file mode 100644 index 0000000..27e1e49 --- /dev/null +++ b/test/references/page_margins/_rels/.rels @@ -0,0 +1,5 @@ + + + + diff --git a/test/references/page_margins/word/_rels/document.xml.rels b/test/references/page_margins/word/_rels/document.xml.rels new file mode 100644 index 0000000..66cfbbf --- /dev/null +++ b/test/references/page_margins/word/_rels/document.xml.rels @@ -0,0 +1,4 @@ + + + + diff --git a/test/references/page_margins/word/document.xml b/test/references/page_margins/word/document.xml new file mode 100644 index 0000000..06ab4f1 --- /dev/null +++ b/test/references/page_margins/word/document.xml @@ -0,0 +1,27 @@ + + + + + + + + no margins + + + + + + + + + + + + thiccc margins + + + + + + + diff --git a/test/references/page_margins/word/styles.xml b/test/references/page_margins/word/styles.xml new file mode 100644 index 0000000..7b8142b --- /dev/null +++ b/test/references/page_margins/word/styles.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/runtests.jl b/test/runtests.jl index aefa5ca..0e5c931 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -708,6 +708,59 @@ Base.show(io::IO, ::MIME"image/png", p::PNG) = write(io, p.bytes) reftest_docx(doc, "multiple_sections") end + @testset "Columns" begin + doc = W.Document( + W.Body([ + W.Section([ + W.Paragraph([ + W.Run([ + W.Text("Section 1") + ]) + ]) + ]) + W.Section([ + W.Paragraph([ + W.Run([ + W.Text("2 columns") + ]) + ]) + ]; columns=W.Columns(;num=2)) + W.Section([ + W.Paragraph([ + W.Run([ + W.Text("different width columns") + ]) + ]) + ]; columns=W.Columns(;cols=[W.Column(;width=4W.inch, space=0.5W.inch), W.Column(;width=2W.inch)])) + ]) + ) + + reftest_docx(doc, "columns") + end + + @testset "Page margins" begin + doc = W.Document( + W.Body([ + W.Section([ + W.Paragraph([ + W.Run([ + W.Text("no margins") + ]) + ]) + ]) + W.Section([ + W.Paragraph([ + W.Run([ + W.Text("thiccc margins") + ]) + ]) + ]; margins=W.PageMargins(;top=2.5W.inch, right=2.5W.inch, bottom=2.5W.inch, left=2.5W.inch)) + ]) + ) + + reftest_docx(doc, "page_margins") + end + @testset "Page sizes" begin doc = W.Document( W.Body( @@ -892,6 +945,17 @@ Base.show(io::IO, ::MIME"image/png", p::PNG) = write(io, p.bytes) ) ]) ]) + W.Section([ + W.Paragraph([ + W.Run( + [ + W.Text("column 1"), + W.Break(W.BreakType.column), + W.Text("column 2"), + ] + ) + ]) + ]; columns=W.Columns(;num=2)) ] ) ) From 805def27eeab55974375d3e2612af29c6aae5e3b Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Tue, 19 Aug 2025 14:35:51 -0700 Subject: [PATCH 06/12] Column input types only need to be convertible to twip --- src/WriteDocx.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WriteDocx.jl b/src/WriteDocx.jl index b7a6f06..ed6e10c 100644 --- a/src/WriteDocx.jl +++ b/src/WriteDocx.jl @@ -1038,7 +1038,7 @@ Base.@kwdef struct Footers end """ - Column(; [width::Twip, space::Twip]) + Column(; [width, space]) Describes a single column. `width` sets the column width, and `space` sets the whitespace after the column (before the next column). From 5e67b13a9f72d93272c776c0bbc7fd329c3dd18a Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Tue, 19 Aug 2025 14:58:19 -0700 Subject: [PATCH 07/12] Prevent incompatible kwargs combo in `Columns` constructor --- src/WriteDocx.jl | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/WriteDocx.jl b/src/WriteDocx.jl index ed6e10c..e913c66 100644 --- a/src/WriteDocx.jl +++ b/src/WriteDocx.jl @@ -1058,18 +1058,34 @@ Sets the columns for a [`Section`](@ref). | Keyword | Description | | :-- | :-- | -| `equal::Bool = true` | Whether all columns are equal-width with the same space between every column | -| `num::Int` | The number of equal-width columns to layout. | -| `space::`[`Twip`](@ref) | The space between equal-width columns. | +| `equal::Bool = true` | Sets all columns to be equal-width with `space` between every column | +| `num::Int` | The number of columns to layout. Ignored if `equal==false`. | +| `space::`[`Twip`](@ref) | The space between columns. Ignored if `equal==false`. | | `sep::Bool = false` | Sets whether a vertical separator line is drawn between columns | -| `cols::Vector{`[`Column`](@ref)`}` | A vector of custom columns. `equal`, `num`, and `space` are ignored if `cols` is provided. | -""" -Base.@kwdef struct Columns - num::Int = 1 - space::Maybe{Twip} = nothing - sep::Bool = false - cols::Vector{Column} = Column[] - equal::Bool = isempty(cols) +| `cols::Vector{`[`Column`](@ref)`}` | A vector of custom columns. May not be specified with `equal==true`. | +""" +struct Columns + num::Int + space::Maybe{Twip} + sep::Bool + cols::Vector{Column} + equal::Bool + + function Columns(;kwargs...) + sd = setdiff(kwargs, (:num, :space, :sep, :cols, :equal)) + isempty(sd) || throw(ArgumentError("got unsupported keyword argument(s): $(sd)")) + if haskey(kwargs, :cols) && haskey(kwargs, :equal) && kwargs[:equal] + throw(ArgumentError("keyword arguments \"cols\" and \"equal\" (or equal=true) are mutually incompatible. If \"cols\" is given, \"equal\" must be false or not defined")) + elseif !haskey(kwargs, :cols) && haskey(kwargs, :equal) && !kwargs[:equal] + throw(ArgumentError("\"cols\" must be defined/non-empty when \"equal=false\"")) + end + + return new( + get(kwargs, :num, 1), + get(kwargs, :space, nothing), + get(kwargs, :cols, Column[]), + get(kwargs, :equal, true)) + end end """ From cd23333e342e4be9aa680fc73246908538ac8802 Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Thu, 21 Aug 2025 06:58:58 +0200 Subject: [PATCH 08/12] fix kwargs --- src/WriteDocx.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WriteDocx.jl b/src/WriteDocx.jl index e913c66..e00af2d 100644 --- a/src/WriteDocx.jl +++ b/src/WriteDocx.jl @@ -1072,7 +1072,7 @@ struct Columns equal::Bool function Columns(;kwargs...) - sd = setdiff(kwargs, (:num, :space, :sep, :cols, :equal)) + sd = setdiff(keys(kwargs), (:num, :space, :sep, :cols, :equal)) isempty(sd) || throw(ArgumentError("got unsupported keyword argument(s): $(sd)")) if haskey(kwargs, :cols) && haskey(kwargs, :equal) && kwargs[:equal] throw(ArgumentError("keyword arguments \"cols\" and \"equal\" (or equal=true) are mutually incompatible. If \"cols\" is given, \"equal\" must be false or not defined")) @@ -1083,6 +1083,7 @@ struct Columns return new( get(kwargs, :num, 1), get(kwargs, :space, nothing), + get(kwargs, :sep, false), get(kwargs, :cols, Column[]), get(kwargs, :equal, true)) end From 010aa1ee6001f3661142716fff73c5c18449fab4 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Thu, 21 Aug 2025 09:39:59 -0700 Subject: [PATCH 09/12] Fix `Columns` constructor defaults --- src/WriteDocx.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WriteDocx.jl b/src/WriteDocx.jl index e00af2d..b1357cb 100644 --- a/src/WriteDocx.jl +++ b/src/WriteDocx.jl @@ -1079,13 +1079,14 @@ struct Columns elseif !haskey(kwargs, :cols) && haskey(kwargs, :equal) && !kwargs[:equal] throw(ArgumentError("\"cols\" must be defined/non-empty when \"equal=false\"")) end + haskey(kwargs, :cols) && isempty(kwargs[:cols]) && throw(ArgumentError("\"cols\" must not be empty")) return new( get(kwargs, :num, 1), get(kwargs, :space, nothing), get(kwargs, :sep, false), get(kwargs, :cols, Column[]), - get(kwargs, :equal, true)) + get(kwargs, :equal, !haskey(kwargs, :cols))) end end From 655ab93ced089319f6fd09612dec732cd243ac5f Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Tue, 2 Sep 2025 12:46:25 -0700 Subject: [PATCH 10/12] Print the actual number of columns --- src/WriteDocx.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WriteDocx.jl b/src/WriteDocx.jl index b1357cb..8995541 100644 --- a/src/WriteDocx.jl +++ b/src/WriteDocx.jl @@ -2029,6 +2029,7 @@ function attributes(p::Columns) p.space === nothing || push!(attrs, ("w:space", p.space)) elseif !p.equal push!(attrs, ("w:equalWidth", p.equal)) + push!(attrs, ("w:num", length(p.cols))) p.sep === false || push!(attrs, ("w:sep", p.sep)) end return attrs From fd465d3e84cd8edf019406bf40d93a43d8125231 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Tue, 2 Sep 2025 12:53:25 -0700 Subject: [PATCH 11/12] Update columns test xml --- test/references/columns/word/document.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/references/columns/word/document.xml b/test/references/columns/word/document.xml index c4526b4..9f38a0e 100644 --- a/test/references/columns/word/document.xml +++ b/test/references/columns/word/document.xml @@ -35,7 +35,7 @@ - + From db08c892587db47b513b6ead81655abec2df658e Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Thu, 4 Sep 2025 13:42:00 +0200 Subject: [PATCH 12/12] make columns visible in tests --- test/references/columns/word/document.xml | 18 ++++++++++++------ test/runtests.jl | 21 ++++++++++++--------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/test/references/columns/word/document.xml b/test/references/columns/word/document.xml index 9f38a0e..34cb0c6 100644 --- a/test/references/columns/word/document.xml +++ b/test/references/columns/word/document.xml @@ -4,8 +4,10 @@ - - Section 1 + + + + No columns No columns No columns No columns No columns No columns No columns No columns No columns No columns @@ -16,8 +18,10 @@ - - 2 columns + + + + 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns 2 columns @@ -30,8 +34,10 @@ - - different width columns + + + + different width columns different width columns different width columns different width columns different width columns different width columns different width columns different width columns different width columns different width columns different width columns different width columns diff --git a/test/runtests.jl b/test/runtests.jl index 0e5c931..60d6a33 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -713,23 +713,26 @@ Base.show(io::IO, ::MIME"image/png", p::PNG) = write(io, p.bytes) W.Body([ W.Section([ W.Paragraph([ - W.Run([ - W.Text("Section 1") - ]) + W.Run( + [W.Text("No columns " ^ 10)], + W.RunProperties(size = 40W.pt) + ) ]) ]) W.Section([ W.Paragraph([ - W.Run([ - W.Text("2 columns") - ]) + W.Run( + [W.Text("2 columns " ^ 20)], + W.RunProperties(size = 40W.pt) + ) ]) ]; columns=W.Columns(;num=2)) W.Section([ W.Paragraph([ - W.Run([ - W.Text("different width columns") - ]) + W.Run( + [W.Text("different width columns " ^ 12)], + W.RunProperties(size = 40W.pt) + ) ]) ]; columns=W.Columns(;cols=[W.Column(;width=4W.inch, space=0.5W.inch), W.Column(;width=2W.inch)])) ])