deepCopy

fun DocumentInfo.deepCopy(type: DocumentType = this.type, name: String? = this.name, authors: List<DocumentAuthor> = this.authors, locale: Locale? = this.locale, numbering: DocumentNumbering? = this.numbering, numberingHeadings: NumberingFormat? = numbering?.headings, numberingHeadingsSymbols: List<NumberingSymbol>? = numberingHeadings?.symbols, numberingFigures: NumberingFormat? = numbering?.figures, numberingFiguresSymbols: List<NumberingSymbol>? = numberingFigures?.symbols, numberingTables: NumberingFormat? = numbering?.tables, numberingTablesSymbols: List<NumberingSymbol>? = numberingTables?.symbols, numberingMath: NumberingFormat? = numbering?.math, numberingMathSymbols: List<NumberingSymbol>? = numberingMath?.symbols, numberingCodeBlocks: NumberingFormat? = numbering?.codeBlocks, numberingCodeBlocksSymbols: List<NumberingSymbol>? = numberingCodeBlocks?.symbols, numberingFootnotes: NumberingFormat? = numbering?.footnotes, numberingFootnotesSymbols: List<NumberingSymbol>? = numberingFootnotes?.symbols, numberingExtra: Map<String, NumberingFormat>? = numbering?.extra, theme: DocumentTheme? = this.theme, themeColor: String? = theme?.color, themeLayout: String? = theme?.layout, tex: TexInfo = this.tex, texMacros: Map<String, String> = tex.macros, layout: DocumentLayoutInfo = this.layout, layoutPageFormat: PageFormatInfo = layout.pageFormat, layoutPageFormatPageWidth: Size? = layoutPageFormat.pageWidth, layoutPageFormatPageWidthValue: Double? = layoutPageFormatPageWidth?.value, layoutPageFormatPageWidthUnit: Size.Unit? = layoutPageFormatPageWidth?.unit, layoutPageFormatPageHeight: Size? = layoutPageFormat.pageHeight, layoutPageFormatPageHeightValue: Double? = layoutPageFormatPageHeight?.value, layoutPageFormatPageHeightUnit: Size.Unit? = layoutPageFormatPageHeight?.unit, layoutPageFormatMargin: Sizes? = layoutPageFormat.margin, layoutPageFormatMarginTop: Size? = layoutPageFormatMargin?.top, layoutPageFormatMarginTopValue: Double? = layoutPageFormatMarginTop?.value, layoutPageFormatMarginTopUnit: Size.Unit? = layoutPageFormatMarginTop?.unit, layoutPageFormatMarginRight: Size? = layoutPageFormatMargin?.right, layoutPageFormatMarginRightValue: Double? = layoutPageFormatMarginRight?.value, layoutPageFormatMarginRightUnit: Size.Unit? = layoutPageFormatMarginRight?.unit, layoutPageFormatMarginBottom: Size? = layoutPageFormatMargin?.bottom, layoutPageFormatMarginBottomValue: Double? = layoutPageFormatMarginBottom?.value, layoutPageFormatMarginBottomUnit: Size.Unit? = layoutPageFormatMarginBottom?.unit, layoutPageFormatMarginLeft: Size? = layoutPageFormatMargin?.left, layoutPageFormatMarginLeftValue: Double? = layoutPageFormatMarginLeft?.value, layoutPageFormatMarginLeftUnit: Size.Unit? = layoutPageFormatMarginLeft?.unit, layoutPageFormatContentBorderWidth: Sizes? = layoutPageFormat.contentBorderWidth, layoutPageFormatContentBorderWidthTop: Size? = layoutPageFormatContentBorderWidth?.top, layoutPageFormatContentBorderWidthTopValue: Double? = layoutPageFormatContentBorderWidthTop?.value, layoutPageFormatContentBorderWidthTopUnit: Size.Unit? = layoutPageFormatContentBorderWidthTop?.unit, layoutPageFormatContentBorderWidthRight: Size? = layoutPageFormatContentBorderWidth?.right, layoutPageFormatContentBorderWidthRightValue: Double? = layoutPageFormatContentBorderWidthRight?.value, layoutPageFormatContentBorderWidthRightUnit: Size.Unit? = layoutPageFormatContentBorderWidthRight?.unit, layoutPageFormatContentBorderWidthBottom: Size? = layoutPageFormatContentBorderWidth?.bottom, layoutPageFormatContentBorderWidthBottomValue: Double? = layoutPageFormatContentBorderWidthBottom?.value, layoutPageFormatContentBorderWidthBottomUnit: Size.Unit? = layoutPageFormatContentBorderWidthBottom?.unit, layoutPageFormatContentBorderWidthLeft: Size? = layoutPageFormatContentBorderWidth?.left, layoutPageFormatContentBorderWidthLeftValue: Double? = layoutPageFormatContentBorderWidthLeft?.value, layoutPageFormatContentBorderWidthLeftUnit: Size.Unit? = layoutPageFormatContentBorderWidthLeft?.unit, layoutPageFormatContentBorderColor: Color? = layoutPageFormat.contentBorderColor, layoutPageFormatContentBorderColorRed: Int? = layoutPageFormatContentBorderColor?.red, layoutPageFormatContentBorderColorGreen: Int? = layoutPageFormatContentBorderColor?.green, layoutPageFormatContentBorderColorBlue: Int? = layoutPageFormatContentBorderColor?.blue, layoutPageFormatContentBorderColorAlpha: Double? = layoutPageFormatContentBorderColor?.alpha, layoutPageFormatColumnCount: Int? = layoutPageFormat.columnCount, layoutPageFormatAlignment: Container.TextAlignment? = layoutPageFormat.alignment, layoutFont: FontInfo = layout.font, layoutFontMainFamily: FontFamily? = layoutFont.mainFamily, layoutFontHeadingFamily: FontFamily? = layoutFont.headingFamily, layoutFontCodeFamily: FontFamily? = layoutFont.codeFamily, layoutFontSize: Size? = layoutFont.size, layoutFontSizeValue: Double? = layoutFontSize?.value, layoutFontSizeUnit: Size.Unit? = layoutFontSize?.unit, layoutParagraphStyle: ParagraphStyleInfo = layout.paragraphStyle, layoutParagraphStyleLineHeight: Double? = layoutParagraphStyle.lineHeight, layoutParagraphStyleLetterSpacing: Double? = layoutParagraphStyle.letterSpacing, layoutParagraphStyleSpacing: Double? = layoutParagraphStyle.spacing, layoutParagraphStyleIndent: Double? = layoutParagraphStyle.indent, layoutCaptionPosition: CaptionPositionInfo = layout.captionPosition, layoutCaptionPositionDefault: CaptionPosition = layoutCaptionPosition.default, layoutCaptionPositionFigures: CaptionPosition? = layoutCaptionPosition.figures, layoutCaptionPositionTables: CaptionPosition? = layoutCaptionPosition.tables, layoutCaptionPositionCodeBlocks: CaptionPosition? = layoutCaptionPosition.codeBlocks): DocumentInfo

Creates a deep copy of this data class, with optional modification of nested properties.

This generated function exposes parameters for every property in the data class, including nested properties of other data class types.

Example usage:

val original = OuterData(inner = InnerData(value = 42))
val modified = original.deepCopy(innerValue = 100)
// Result: OuterData(inner = InnerData(value = 100))

Note: This function deep-copies only data classes and their properties. It does not handle collections or other complex types on its own.

Note: Consider the following:

data class First(val second: Second)
data class Second(val third: Third)
data class Third(val value: Int)

Nested parameters will take precedence over parent parameters:

val first = First(Second(Third(42)))
val modified = first.deepCopy(second = Second(Third(100)), secondThirdValue = 200)
// Result: First(Second(Third(200)))

Note: A nested property cannot be set if any of its parent properties are null:

data class First(val second: Second?)
data class Second(val value: Int)

val first = First(null)
first.deepCopy(secondValue = 100) // First(null)
first.deepCopy(second = Second(100)) // First(Second(100))
first.deepCopy(second = Second(100), secondValue = 200) // First(Second(200))

Return

A new instance of the data class with updated properties as specified.