From 2811a40c6d00bb17f6a0eaf53a1d10a2baafde8f Mon Sep 17 00:00:00 2001 From: melekhin Date: Mon, 10 Aug 2026 14:48:49 +0700 Subject: [PATCH] Rotates 555 --- QWERTYkez.WordProcessor/MultiReplace.cs | 31 +++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/QWERTYkez.WordProcessor/MultiReplace.cs b/QWERTYkez.WordProcessor/MultiReplace.cs index 766e3ed..abc3eb1 100644 --- a/QWERTYkez.WordProcessor/MultiReplace.cs +++ b/QWERTYkez.WordProcessor/MultiReplace.cs @@ -540,14 +540,15 @@ internal static class MultiReplaceExt { if (!string.IsNullOrEmpty(item.Text)) { - // Если есть отложенная ориентация — применяем её + // Если есть отложенная ориентация — применяем её к этому тексту if (pendingOrientation.HasValue) { var newPara = CloneParagraphWithoutSection(original); resultParas.Add(newPara); currentPara = newPara; - bool addPageSize = (pendingOrientation.Value == BreakType.NewLandscapeSection); + // Для маркера перед текстом всегда addPageSize = true + bool addPageSize = true; AddSectionProperties(currentPara, pendingOrientation.Value, addPageSize, sourceSection, portraitSection); lastOrientation = pendingOrientation; sectionChangeInsideGroup = true; @@ -604,21 +605,16 @@ internal static class MultiReplaceExt { if (currentPara is null) { - var newPara = CloneParagraphWithoutSection(original); - resultParas.Add(newPara); - currentPara = newPara; - AddSectionProperties(currentPara, breakType, false, sourceSection, portraitSection); - lastOrientation = breakType; - sectionChangeInsideGroup = true; - firstSplitMarkerHandled = true; - pendingOrientation = null; - textCount = 0; - lastTextPara = null; + // Маркер перед первым текстом — просто запоминаем + pendingOrientation = breakType; + // Не создаём пустой параграф + firstSplitMarkerHandled = true; // чтобы не обрабатывать как первый после текста } else { if (!firstSplitMarkerHandled) { + // Это первый маркер после текста — применяем к последнему текстовому параграфу if (lastTextPara is not null) { if (lastTextPara.ParagraphProperties?.GetFirstChild() is null) @@ -629,19 +625,23 @@ internal static class MultiReplaceExt if (sourcePageSize is not null) { lastTextPara.ParagraphProperties.AppendChild(sourceSection.CloneNode(true)); + lastOrientation = breakType; + sectionChangeInsideGroup = true; } else { + // Если нет sourcePageSize, добавляем без PageSize (not set) AddSectionProperties(lastTextPara, breakType, false, sourceSection, portraitSection); + lastOrientation = breakType; + sectionChangeInsideGroup = true; } - lastOrientation = breakType; - sectionChangeInsideGroup = true; } firstSplitMarkerHandled = true; pendingOrientation = null; } else { + // Если нет lastTextPara, применяем к текущему AddSectionProperties(currentPara, breakType, false, sourceSection, portraitSection); lastOrientation = breakType; sectionChangeInsideGroup = true; @@ -651,6 +651,7 @@ internal static class MultiReplaceExt } else { + // Это не первый маркер — устанавливаем отложенную ориентацию для следующего текста pendingOrientation = breakType; } } @@ -683,7 +684,7 @@ internal static class MultiReplaceExt { var breakRun = new Run(new Break { Type = BreakValues.Page }); remainderPara.InsertAt(breakRun, 0); - bool addPageSize = (pendingOrientation.Value == BreakType.NewLandscapeSection); + bool addPageSize = true; // для остатка всегда с PageSize AddSectionProperties(remainderPara, pendingOrientation.Value, addPageSize, sourceSection, portraitSection); pendingOrientation = null; }