Files
loongoffice/sw/source/core/attr/formatflysplit.cxx
Miklos Vajna 00b9b33334 sw: call FormatEmpty() in SwTextFrame::Format() for split fly masters
The problem was that the text in the anchor frame of a split fly frame
was duplicated on the old page and the new page as well. The reason for
this seems to be that the master has no content and the follow has all
the content (this is wanted), but then there is no code to explicitly
clear the master.

In other cases the master always gets some new content where portion
building for that new content starts by throwing away the old portions.

Once SwTextFrame::Format() and SwTextFrame::FormatEmpty() explicitly
checks for these master anchors, the unwanted text in the master anchor
disappears.

An extra tweak is needed in SwTextFrame::PaintEmpty() to even hide the
paragraph marker: this frame is empty but has a follow frame, so we
should not show a paragraph marker there.

Finally introduce a SwTextFrame::HasNonLastSplitFlyDrawObj() to be able
to check for this "empty master anchor for split fly" case at a single
place.

With this <https://bugs.documentfoundation.org/attachment.cgi?id=185144>
from <https://bugs.documentfoundation.org/show_bug.cgi?id=61594> gets
laid out reasonably: the position is not perfect but we detect that only
1 para of the text frame fits page 1, we create a 2nd page and we
correctly move exactly the text frame's 2nd para to page 2.

Change-Id: I871bba2de5b829e667d5cfb1cbe0ba4cc2274edd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146680
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2023-02-09 08:25:07 +00:00

61 lines
2.4 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <formatflysplit.hxx>
#include <libxml/xmlwriter.h>
SwFormatFlySplit::SwFormatFlySplit(bool bSplit)
: SfxBoolItem(RES_FLY_SPLIT, bSplit)
{
// Once this pool item is true, a floating table (text frame + table inside it) is meant to
// split across multiple pages.
//
// The layout representation is the following:
//
// - We assume that the anchor type is at-para for such fly frames, and SwFlyAtContentFrame
// derives from SwFlowFrame to be able to split in general.
//
// - Both the master fly and the follow flys need an anchor. At the same time, we want all text
// of the anchor frame to be wrapped around the last follow fly frame, for Word compatibility.
// These are solved by splitting the anchor frame as many times as needed, always at text
// TextFrameIndex 0.
if (getenv("SW_FORCE_FLY_SPLIT"))
{
SetValue(true);
}
}
SwFormatFlySplit* SwFormatFlySplit::Clone(SfxItemPool*) const
{
return new SwFormatFlySplit(*this);
}
void SwFormatFlySplit::dumpAsXml(xmlTextWriterPtr pWriter) const
{
(void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFormatFlySplit"));
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"),
BAD_CAST(OString::number(Which()).getStr()));
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
BAD_CAST(OString::boolean(GetValue()).getStr()));
(void)xmlTextWriterEndElement(pWriter);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */