Rotates 555

This commit is contained in:
melekhin
2026-08-10 14:48:49 +07:00
parent 9c81a084f1
commit 2811a40c6d
+15 -14
View File
@@ -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<SectionProperties>() 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;
}
}
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;
}