sw/Library_sw.mk | 1 sw/inc/format.hxx | 1 sw/inc/formatwraptextatflystart.hxx | 50 +++++++++++++++++++++++ sw/inc/hintids.hxx | 31 +++++++------- sw/inc/swatrset.hxx | 2 sw/qa/core/attr/attr.cxx | 21 +++++++++ sw/source/core/attr/formatwraptextatflystart.cxx | 46 +++++++++++++++++++++ sw/source/core/bastyp/init.cxx | 5 +- 8 files changed, 140 insertions(+), 17 deletions(-)
New commits: commit a7ff64fbe92bb34f6e632d72e770f063fba4fda0 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Nov 23 08:38:19 2023 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Fri Nov 24 12:22:19 2023 +0100 sw floattable: add per-frame wrap-on-all-pages mode Currently the wrap-on-all pages mode is off by default and a document-level setting can enable it for all split flys. Allowing this at a per-frame level (and not only per-doc level) is suggested in <https://issues.oasis-open.org/browse/OFFICE-4150>. Given that this floating table proposal is coming from us, it makes sense to also support this additional attribute from the proposal, even if it's not supported by Word. Fix this by adding a new SwFormatWrapTextAtFlyStart property on fly frames: this is meant to be enabled when wrap-on-all-pages is wanted for this fly, but it's disabled at a per-doc level. Unlike SwFormatFlySplit, this is meant to be easy at a layout level, since SwFlyAtContentFrame::IsWrapOnAllPages() is already a per-frame function, it is just backed with a per-doc setting. (cherry picked from commit b1b0cc1b0bb473155b5b089199ca99bb1dc40e42) Conflicts: sw/inc/hintids.hxx sw/source/core/bastyp/init.cxx Change-Id: I8f562102c2bc366a36c08895b681c4a2ab256bd9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159917 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index be2f30b3acb9..e137af600e48 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -139,6 +139,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/core/attr/fmtwrapinfluenceonobjpos \ sw/source/core/attr/format \ sw/source/core/attr/formatflysplit \ + sw/source/core/attr/formatwraptextatflystart \ sw/source/core/attr/hints \ sw/source/core/attr/swatrset \ sw/source/core/bastyp/SwSmartTagMgr \ diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx index be36f33841c2..229458ed3c19 100644 --- a/sw/inc/format.hxx +++ b/sw/inc/format.hxx @@ -234,6 +234,7 @@ public: inline const SwFormatLayoutSplit &GetLayoutSplit( bool = true ) const; inline const SwFormatRowSplit &GetRowSplit( bool = true ) const; inline const SwFormatFlySplit &GetFlySplit( bool = true ) const; + inline const SwFormatWrapTextAtFlyStart &GetWrapTextAtFlyStart( bool = true ) const; inline const SwFormatChain &GetChain( bool = true ) const; inline const SwFormatFootnoteAtTextEnd &GetFootnoteAtTextEnd( bool = true ) const; inline const SwFormatEndAtTextEnd &GetEndAtTextEnd( bool = true ) const; diff --git a/sw/inc/formatwraptextatflystart.hxx b/sw/inc/formatwraptextatflystart.hxx new file mode 100644 index 000000000000..02305247df7c --- /dev/null +++ b/sw/inc/formatwraptextatflystart.hxx @@ -0,0 +1,50 @@ +/* -*- 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 . + */ + +#pragma once + +#include <svl/eitem.hxx> + +#include "swdllapi.h" +#include "hintids.hxx" +#include "format.hxx" + +/// Determines if text wraps around a split fly on all pages (i.e. wrap text at fly start) or only +/// on the last page. +class SW_DLLPUBLIC SwFormatWrapTextAtFlyStart final : public SfxBoolItem +{ +public: + SwFormatWrapTextAtFlyStart(bool bAtStart = false); + + SwFormatWrapTextAtFlyStart* Clone(SfxItemPool* pPool = nullptr) const override; + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +inline const SwFormatWrapTextAtFlyStart& SwAttrSet::GetWrapTextAtFlyStart(bool bInP) const +{ + return Get(RES_WRAP_TEXT_AT_FLY_START, bInP); +} + +inline const SwFormatWrapTextAtFlyStart& SwFormat::GetWrapTextAtFlyStart(bool bInP) const +{ + return m_aSet.GetWrapTextAtFlyStart(bInP); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 8d0c14f23572..93784eac94c6 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -117,6 +117,7 @@ class SwFormatNoBalancedColumns; class SwFormatPageDesc; class SwFormatRowSplit; class SwFormatFlySplit; +class SwFormatWrapTextAtFlyStart; class SwFormatSurround; class SwFormatURL; class SwFormatVertOrient; @@ -371,24 +372,24 @@ constexpr TypedWhichId<SdrTextVertAdjustItem> RES_TEXT_VERT_ADJUST(131); constexpr TypedWhichId<SfxBoolItem> RES_BACKGROUND_FULL_SIZE(132); constexpr TypedWhichId<SfxBoolItem> RES_RTL_GUTTER(133); constexpr TypedWhichId<SfxBoolItem> RES_DECORATIVE(134); -constexpr sal_uInt16 RES_FRMATR_END(135); +constexpr TypedWhichId<SwFormatWrapTextAtFlyStart> RES_WRAP_TEXT_AT_FLY_START(135); +constexpr sal_uInt16 RES_FRMATR_END(136); constexpr sal_uInt16 RES_GRFATR_BEGIN(RES_FRMATR_END); constexpr TypedWhichId<SwMirrorGrf> RES_GRFATR_MIRRORGRF(RES_GRFATR_BEGIN); -constexpr TypedWhichId<SwCropGrf> RES_GRFATR_CROPGRF(136); - -constexpr TypedWhichId<SwRotationGrf> RES_GRFATR_ROTATION(137); -constexpr TypedWhichId<SwLuminanceGrf> RES_GRFATR_LUMINANCE(138); -constexpr TypedWhichId<SwContrastGrf> RES_GRFATR_CONTRAST(139); -constexpr TypedWhichId<SwChannelRGrf> RES_GRFATR_CHANNELR(140); -constexpr TypedWhichId<SwChannelGGrf> RES_GRFATR_CHANNELG(141); -constexpr TypedWhichId<SwChannelBGrf> RES_GRFATR_CHANNELB(142); -constexpr TypedWhichId<SwGammaGrf> RES_GRFATR_GAMMA(143); -constexpr TypedWhichId<SwInvertGrf> RES_GRFATR_INVERT(144); -constexpr TypedWhichId<SwTransparencyGrf> RES_GRFATR_TRANSPARENCY(145); -constexpr TypedWhichId<SwDrawModeGrf> RES_GRFATR_DRAWMODE(146); - -constexpr TypedWhichId<SfxBoolItem> RES_GRFATR_DUMMY3(147); +constexpr TypedWhichId<SwCropGrf> RES_GRFATR_CROPGRF(137); + +constexpr TypedWhichId<SwRotationGrf> RES_GRFATR_ROTATION(138); +constexpr TypedWhichId<SwLuminanceGrf> RES_GRFATR_LUMINANCE(139); +constexpr TypedWhichId<SwContrastGrf> RES_GRFATR_CONTRAST(140); +constexpr TypedWhichId<SwChannelRGrf> RES_GRFATR_CHANNELR(141); +constexpr TypedWhichId<SwChannelGGrf> RES_GRFATR_CHANNELG(142); +constexpr TypedWhichId<SwChannelBGrf> RES_GRFATR_CHANNELB(143); +constexpr TypedWhichId<SwGammaGrf> RES_GRFATR_GAMMA(144); +constexpr TypedWhichId<SwInvertGrf> RES_GRFATR_INVERT(145); +constexpr TypedWhichId<SwTransparencyGrf> RES_GRFATR_TRANSPARENCY(146); +constexpr TypedWhichId<SwDrawModeGrf> RES_GRFATR_DRAWMODE(147); + constexpr TypedWhichId<SfxBoolItem> RES_GRFATR_DUMMY4(148); constexpr TypedWhichId<SfxBoolItem> RES_GRFATR_DUMMY5(149); constexpr sal_uInt16 RES_GRFATR_END(150); diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx index 6fd2662186d8..a2df3cb701d0 100644 --- a/sw/inc/swatrset.hxx +++ b/sw/inc/swatrset.hxx @@ -82,6 +82,7 @@ class SwFormatEditInReadonly; class SwFormatLayoutSplit; class SwFormatRowSplit; class SwFormatFlySplit; +class SwFormatWrapTextAtFlyStart; class SwFormatChain; class SwFormatFootnoteAtTextEnd; class SwFormatEndAtTextEnd; @@ -264,6 +265,7 @@ public: inline const SwFormatLayoutSplit &GetLayoutSplit( bool = true ) const; inline const SwFormatRowSplit &GetRowSplit( bool = true ) const; inline const SwFormatFlySplit &GetFlySplit( bool = true ) const; + inline const SwFormatWrapTextAtFlyStart &GetWrapTextAtFlyStart( bool = true ) const; inline const SwFormatChain &GetChain( bool = true ) const; inline const SwFormatLineNumber &GetLineNumber( bool = true ) const; inline const SwFormatFootnoteAtTextEnd &GetFootnoteAtTextEnd( bool = true ) const; diff --git a/sw/qa/core/attr/attr.cxx b/sw/qa/core/attr/attr.cxx index 25d2a8025020..65ba88c7ec18 100644 --- a/sw/qa/core/attr/attr.cxx +++ b/sw/qa/core/attr/attr.cxx @@ -15,6 +15,7 @@ #include <frmmgr.hxx> #include <frameformats.hxx> #include <formatflysplit.hxx> +#include <formatwraptextatflystart.hxx> namespace { @@ -73,6 +74,26 @@ CPPUNIT_TEST_FIXTURE(Test, testFormatFlySplit) CPPUNIT_ASSERT(pFly->GetAttrSet().GetFlySplit().GetValue()); } + +CPPUNIT_TEST_FIXTURE(Test, testFormatWrapTextAtFlyStart) +{ + createSwDoc(); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr); + RndStdIds eAnchor = RndStdIds::FLY_AT_PARA; + aMgr.InsertFlyFrame(eAnchor, aMgr.GetPos(), aMgr.GetSize()); + SwDoc* pDoc = getSwDoc(); + SwFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); + SwFrameFormat* pFly = rFlys[0]; + CPPUNIT_ASSERT(!pFly->GetAttrSet().GetWrapTextAtFlyStart().GetValue()); + + SfxItemSet aSet(pFly->GetAttrSet()); + SwFormatWrapTextAtFlyStart aItem(true); + aSet.Put(aItem); + pDoc->SetFlyFrameAttr(*pFly, aSet); + + CPPUNIT_ASSERT(pFly->GetAttrSet().GetWrapTextAtFlyStart().GetValue()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/attr/formatwraptextatflystart.cxx b/sw/source/core/attr/formatwraptextatflystart.cxx new file mode 100644 index 000000000000..88a17d5ade33 --- /dev/null +++ b/sw/source/core/attr/formatwraptextatflystart.cxx @@ -0,0 +1,46 @@ +/* -*- 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 <formatwraptextatflystart.hxx> + +#include <libxml/xmlwriter.h> + +SwFormatWrapTextAtFlyStart::SwFormatWrapTextAtFlyStart(bool bAtStart) + : SfxBoolItem(RES_WRAP_TEXT_AT_FLY_START, bAtStart) +{ + // Once this pool item is true, the text from the anchor text of the fly wraps an all pages, not + // only on the last page of the fly chain. +} + +SwFormatWrapTextAtFlyStart* SwFormatWrapTextAtFlyStart::Clone(SfxItemPool*) const +{ + return new SwFormatWrapTextAtFlyStart(*this); +} + +void SwFormatWrapTextAtFlyStart::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFormatWrapTextAtFlyStart")); + (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: */ diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index 4f7ee52b7ab6..191390288e19 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -106,6 +106,7 @@ #include <fmtrfmrk.hxx> #include <fmtrowsplt.hxx> #include <formatflysplit.hxx> +#include <formatwraptextatflystart.hxx> #include <fmtruby.hxx> #include <fmtsrnd.hxx> #include <fmturl.hxx> @@ -407,6 +408,7 @@ SfxItemInfo aSlotTab[] = { 0, true }, // RES_BACKGROUND_FULL_SIZE { 0, true }, // RES_RTL_GUTTER { 0, true }, // RES_DECORATIVE + { 0, true }, // RES_WRAP_TEXT_AT_FLY_START { 0, true }, // RES_GRFATR_MIRRORGRF { SID_ATTR_GRAF_CROP, true }, // RES_GRFATR_CROPGRF @@ -419,7 +421,6 @@ SfxItemInfo aSlotTab[] = { 0, true }, // RES_GRFATR_GAMMA, { 0, true }, // RES_GRFATR_INVERT, { 0, true }, // RES_GRFATR_TRANSPARENCY, - { 0, true }, // RES_GRFATR_DUMMY3, { 0, true }, // RES_GRFATR_DUMMY4, { 0, true }, // RES_GRFATR_DUMMY5, { 0, true }, // RES_GRFATR_DUMMY6, @@ -612,6 +613,7 @@ void InitCore() aAttrTab[ RES_BACKGROUND_FULL_SIZE - POOLATTR_BEGIN ] = new SfxBoolItem(RES_BACKGROUND_FULL_SIZE, true); aAttrTab[ RES_RTL_GUTTER - POOLATTR_BEGIN ] = new SfxBoolItem(RES_RTL_GUTTER, false); aAttrTab[ RES_DECORATIVE - POOLATTR_BEGIN ] = new SfxBoolItem(RES_DECORATIVE, false); + aAttrTab[ RES_WRAP_TEXT_AT_FLY_START - POOLATTR_BEGIN ] = new SwFormatWrapTextAtFlyStart; aAttrTab[ RES_GRFATR_MIRRORGRF- POOLATTR_BEGIN ] = new SwMirrorGrf; aAttrTab[ RES_GRFATR_CROPGRF- POOLATTR_BEGIN ] = new SwCropGrf; @@ -627,7 +629,6 @@ void InitCore() aAttrTab[ RES_GRFATR_DRAWMODE - POOLATTR_BEGIN ] = new SwDrawModeGrf; // GraphicAttr - Dummies - aAttrTab[ RES_GRFATR_DUMMY3 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_GRFATR_DUMMY3 ); aAttrTab[ RES_GRFATR_DUMMY4 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_GRFATR_DUMMY4 ); aAttrTab[ RES_GRFATR_DUMMY5 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_GRFATR_DUMMY5 );