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 b1b0cc1b0bb473155b5b089199ca99bb1dc40e42 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Nov 23 08:38:19 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Nov 23 09:54:27 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. Change-Id: I8f562102c2bc366a36c08895b681c4a2ab256bd9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159847 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index f49117e58f86..bd5d831f7f2f 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -140,6 +140,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 f420afcf512e..8ded8c6f61f3 100644 --- a/sw/inc/format.hxx +++ b/sw/inc/format.hxx @@ -240,6 +240,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 e81626167ae2..011a35edd4db 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -122,6 +122,7 @@ class SwFormatNoBalancedColumns; class SwFormatPageDesc; class SwFormatRowSplit; class SwFormatFlySplit; +class SwFormatWrapTextAtFlyStart; class SwFormatSurround; class SwFormatURL; class SwFormatVertOrient; @@ -379,24 +380,24 @@ constexpr TypedWhichId<SdrTextVertAdjustItem> RES_TEXT_VERT_ADJUST(137); constexpr TypedWhichId<SfxBoolItem> RES_BACKGROUND_FULL_SIZE(138); constexpr TypedWhichId<SfxBoolItem> RES_RTL_GUTTER(139); constexpr TypedWhichId<SfxBoolItem> RES_DECORATIVE(140); -constexpr sal_uInt16 RES_FRMATR_END(141); +constexpr TypedWhichId<SwFormatWrapTextAtFlyStart> RES_WRAP_TEXT_AT_FLY_START(141); +constexpr sal_uInt16 RES_FRMATR_END(142); constexpr sal_uInt16 RES_GRFATR_BEGIN(RES_FRMATR_END); constexpr TypedWhichId<SwMirrorGrf> RES_GRFATR_MIRRORGRF(RES_GRFATR_BEGIN); -constexpr TypedWhichId<SwCropGrf> RES_GRFATR_CROPGRF(142); - -constexpr TypedWhichId<SwRotationGrf> RES_GRFATR_ROTATION(143); -constexpr TypedWhichId<SwLuminanceGrf> RES_GRFATR_LUMINANCE(144); -constexpr TypedWhichId<SwContrastGrf> RES_GRFATR_CONTRAST(145); -constexpr TypedWhichId<SwChannelRGrf> RES_GRFATR_CHANNELR(146); -constexpr TypedWhichId<SwChannelGGrf> RES_GRFATR_CHANNELG(147); -constexpr TypedWhichId<SwChannelBGrf> RES_GRFATR_CHANNELB(148); -constexpr TypedWhichId<SwGammaGrf> RES_GRFATR_GAMMA(149); -constexpr TypedWhichId<SwInvertGrf> RES_GRFATR_INVERT(150); -constexpr TypedWhichId<SwTransparencyGrf> RES_GRFATR_TRANSPARENCY(151); -constexpr TypedWhichId<SwDrawModeGrf> RES_GRFATR_DRAWMODE(152); - -constexpr TypedWhichId<SfxBoolItem> RES_GRFATR_DUMMY3(153); +constexpr TypedWhichId<SwCropGrf> RES_GRFATR_CROPGRF(143); + +constexpr TypedWhichId<SwRotationGrf> RES_GRFATR_ROTATION(144); +constexpr TypedWhichId<SwLuminanceGrf> RES_GRFATR_LUMINANCE(145); +constexpr TypedWhichId<SwContrastGrf> RES_GRFATR_CONTRAST(146); +constexpr TypedWhichId<SwChannelRGrf> RES_GRFATR_CHANNELR(147); +constexpr TypedWhichId<SwChannelGGrf> RES_GRFATR_CHANNELG(148); +constexpr TypedWhichId<SwChannelBGrf> RES_GRFATR_CHANNELB(149); +constexpr TypedWhichId<SwGammaGrf> RES_GRFATR_GAMMA(150); +constexpr TypedWhichId<SwInvertGrf> RES_GRFATR_INVERT(151); +constexpr TypedWhichId<SwTransparencyGrf> RES_GRFATR_TRANSPARENCY(152); +constexpr TypedWhichId<SwDrawModeGrf> RES_GRFATR_DRAWMODE(153); + constexpr TypedWhichId<SfxBoolItem> RES_GRFATR_DUMMY4(154); constexpr TypedWhichId<SfxBoolItem> RES_GRFATR_DUMMY5(155); constexpr sal_uInt16 RES_GRFATR_END(156); diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx index 667121f35327..b729ac14aaac 100644 --- a/sw/inc/swatrset.hxx +++ b/sw/inc/swatrset.hxx @@ -88,6 +88,7 @@ class SwFormatEditInReadonly; class SwFormatLayoutSplit; class SwFormatRowSplit; class SwFormatFlySplit; +class SwFormatWrapTextAtFlyStart; class SwFormatChain; class SwFormatFootnoteAtTextEnd; class SwFormatEndAtTextEnd; @@ -287,6 +288,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 d123ed858b57..a83a3228dd1d 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(); + sw::SpzFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormat* 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 f0080719c28d..ce14c81e4d1d 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -107,6 +107,7 @@ #include <fmtrfmrk.hxx> #include <fmtrowsplt.hxx> #include <formatflysplit.hxx> +#include <formatwraptextatflystart.hxx> #include <fmtruby.hxx> #include <fmtsrnd.hxx> #include <fmturl.hxx> @@ -417,6 +418,7 @@ SfxItemInfo aSlotTab[] = { 0, false, true }, // RES_BACKGROUND_FULL_SIZE { 0, false, true }, // RES_RTL_GUTTER { 0, false, true }, // RES_DECORATIVE + { 0, false, true }, // RES_WRAP_TEXT_AT_FLY_START { 0, false, true }, // RES_GRFATR_MIRRORGRF { SID_ATTR_GRAF_CROP, false, true }, // RES_GRFATR_CROPGRF @@ -429,7 +431,6 @@ SfxItemInfo aSlotTab[] = { 0, false, true }, // RES_GRFATR_GAMMA, { 0, false, true }, // RES_GRFATR_INVERT, { 0, false, true }, // RES_GRFATR_TRANSPARENCY, - { 0, false, true }, // RES_GRFATR_DUMMY3, { 0, false, true }, // RES_GRFATR_DUMMY4, { 0, false, true }, // RES_GRFATR_DUMMY5, { 0, false, true }, // RES_GRFATR_DUMMY6, @@ -629,6 +630,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; @@ -644,7 +646,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 );