offapi/com/sun/star/text/BaseFrameProperties.idl | 6 ++ sw/Library_sw.mk | 1 sw/inc/format.hxx | 1 sw/inc/formatflysplit.hxx | 52 ++++++++++++++++++++++ sw/inc/hintids.hxx | 53 +++++++++++------------ sw/inc/swatrset.hxx | 2 sw/qa/core/attr/attr.cxx | 23 +++++++++ sw/qa/core/unocore/unocore.cxx | 28 ++++++++++++ sw/source/core/attr/formatflysplit.cxx | 39 ++++++++++++++++ sw/source/core/bastyp/init.cxx | 5 +- sw/source/core/inc/flyfrms.hxx | 5 +- sw/source/core/layout/flycnt.cxx | 16 ++++++ sw/source/core/unocore/unomap1.cxx | 1 13 files changed, 202 insertions(+), 30 deletions(-)
New commits: commit 1bf5650dfcc8ee2e653a5d4e0f2c0f956f7f2051 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Jan 27 09:25:44 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Feb 24 11:05:48 2023 +0100 sw: add an SwFlyAtContentFrame ctor that creates a follow fly frame This is meant to be a called by a future SwFrame::GetNextFlyLeaf() (similar to the existing SwFrame::GetNextSctLeaf()), which still has to be added. What an anchor should be for a follow fly frame is a bit unclear to me, let's go with an explicit nullptr for now and we can clarify that later. Towards an initial layout for multi-page fly frames. (cherry picked from commit a6b64d02843d186485ff5c82106e6f9268a539c7) Change-Id: I2429f47aef90dfe61340bfe244353dcefeb4ef1f diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx index 063ce72610c7..4f6bc91922f2 100644 --- a/sw/source/core/inc/flyfrms.hxx +++ b/sw/source/core/inc/flyfrms.hxx @@ -178,6 +178,7 @@ public: // #i28701# SwFlyAtContentFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor ); + SwFlyAtContentFrame(SwFlyAtContentFrame& rPrecede); void SetAbsPos( const Point &rNew ); diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index c24a3a1e908a..afe01a91897f 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -50,6 +50,7 @@ #include <textboxhelper.hxx> #include <fmtfollowtextflow.hxx> #include <unoprnms.hxx> +#include <rootfrm.hxx> using namespace ::com::sun::star; @@ -81,6 +82,13 @@ SwFlyAtContentFrame::SwFlyAtContentFrame( SwFlyFrameFormat *pFormat, SwFrame* pS m_bAutoPosition = (RndStdIds::FLY_AT_CHAR == pFormat->GetAnchor().GetAnchorId()); } +SwFlyAtContentFrame::SwFlyAtContentFrame(SwFlyAtContentFrame& rPrecede) + : SwFlyAtContentFrame(rPrecede.GetFormat(), rPrecede.getRootFrame(), /*pAnchor=*/nullptr) +{ + SetFollow(rPrecede.GetFollow()); + rPrecede.SetFollow(this); +} + // #i28701# void SwFlyAtContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) commit fe5bdabefca7aafa31374c27e2eb667f970e87c9 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Jan 26 11:10:25 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Feb 24 11:05:48 2023 +0100 sw: inherit SwFlyAtContentFrame from SwFlowFrame Checking how e.g. section frames are split in SwFrame::GetNextLeaf(), we call into SwFrame::GetNextSctLeaf() which then calls a dedicated SwSectionFrame ctor that connects the master with its follow. Add infrastructure to be able to do the same for fly at-content frames. (At-fly anchored and as-char anchored frames are not relevant for the broader multi-page floating table picture. Also, SwFrame::GetLeaf() wants to work with a non-abstract type, so allocating SwFlyFrame there would make no sense, so inherit SwFlyAtContentFrame and not SwFlyFrame from SwFlowFrame.) This is meant to be a minimal change, that can be unconditional, seeing that the only dynamic_cast to SwFlowFrame in RestoreContent() only does something if the frame has a follow, which is never the case at the moment. Towards an initial layout for multi-page fly frames. (cherry picked from commit bef6c5ca4edf55e64284d9dd264ba9a76476adab) Change-Id: I8ea930bed4bbddb96b181796ab893e810ba9dcd4 diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx index cf79bf2fe92b..063ce72610c7 100644 --- a/sw/source/core/inc/flyfrms.hxx +++ b/sw/source/core/inc/flyfrms.hxx @@ -22,6 +22,7 @@ #include <sal/config.h> #include "flyfrm.hxx" +#include "flowfrm.hxx" class SwNoTextFrame; @@ -156,7 +157,7 @@ public: }; // Flys that are bound to Content but not in Content -class SwFlyAtContentFrame final: public SwFlyFreeFrame +class SwFlyAtContentFrame final: public SwFlyFreeFrame, public SwFlowFrame { virtual void MakeAll(vcl::RenderContext* pRenderContext) override; @@ -171,6 +172,7 @@ class SwFlyAtContentFrame final: public SwFlyFreeFrame virtual void RegisterAtCorrectPage() override; virtual void RegisterAtPage(SwPageFrame &) override; virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + bool ShouldBwdMoved(SwLayoutFrame* pNewUpper, bool& rReformat) override; public: // #i28701# diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 8ba6655cd7de..c24a3a1e908a 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -74,7 +74,8 @@ SwTwips lcl_GetTopForObjPos(const SwContentFrame* pCnt, const bool bVert, const } SwFlyAtContentFrame::SwFlyAtContentFrame( SwFlyFrameFormat *pFormat, SwFrame* pSib, SwFrame *pAnch ) : - SwFlyFreeFrame( pFormat, pSib, pAnch ) + SwFlyFreeFrame( pFormat, pSib, pAnch ), + SwFlowFrame(static_cast<SwFrame&>(*this)) { m_bAtCnt = true; m_bAutoPosition = (RndStdIds::FLY_AT_CHAR == pFormat->GetAnchor().GetAnchorId()); @@ -1518,4 +1519,9 @@ bool SwFlyAtContentFrame::InvalidationAllowed( const InvalidationType _nInvalid return bAllowed; } +bool SwFlyAtContentFrame::ShouldBwdMoved(SwLayoutFrame* /*pNewUpper*/, bool& /*rReformat*/) +{ + return false; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 5deee74dfba49ef904da995f164f38b6ce06319b Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Jan 25 09:27:28 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Feb 24 11:05:48 2023 +0100 sw: add UNO API for multi-page fly frames This exposes the internal property added in 0bb90afaeb193181d7b98b79e962549d8a1dd85a (sw: add document model for multi-page fly frames, 2023-01-24) on the UNO API. (cherry picked from commit fd3d4d894d96f16a28d5b58c5bcf5a44fb83617f) Change-Id: If9acd2d2130f727bc9481980445c0da01be04729 diff --git a/offapi/com/sun/star/text/BaseFrameProperties.idl b/offapi/com/sun/star/text/BaseFrameProperties.idl index 3108067a0ad5..9b82601c896e 100644 --- a/offapi/com/sun/star/text/BaseFrameProperties.idl +++ b/offapi/com/sun/star/text/BaseFrameProperties.idl @@ -373,6 +373,12 @@ published service BaseFrameProperties */ [optional, property] boolean Decorative; + /** If `TRUE`, the frame is allowed to be split at page breaks. + + @since LibreOffice 7.6 + */ + [optional, property] boolean IsSplitAllowed; + }; diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 0c2da1b0524a..d17b1e19940a 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -28,6 +28,7 @@ #include <ndtxt.hxx> #include <textlinebreak.hxx> #include <textcontentcontrol.hxx> +#include <frmmgr.hxx> using namespace ::com::sun::star; @@ -902,6 +903,33 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testParagraphMarkerFormattedRun) getXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/SwFieldPortion", "font-weight")); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testFlySplit) +{ + // Given a document with a fly frame: + 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()); + uno::Reference<text::XTextFramesSupplier> xDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xFrame(xDocument->getTextFrames()->getByName("Frame1"), + uno::UNO_QUERY); + bool bIsSplitAllowed{}; + // Without the accompanying fix in place, this test would have failed with: + // An uncaught exception of type com.sun.star.beans.UnknownPropertyException + // - Unknown property: IsSplitAllowed + // i.e. the property was missing. + xFrame->getPropertyValue("IsSplitAllowed") >>= bIsSplitAllowed; + CPPUNIT_ASSERT(!bIsSplitAllowed); + + // When marking it as IsSplitAllowed=true: + xFrame->setPropertyValue("IsSplitAllowed", uno::Any(true)); + + // Then make sure that IsSplitAllowed is true when asking back: + xFrame->getPropertyValue("IsSplitAllowed") >>= bIsSplitAllowed; + CPPUNIT_ASSERT(bIsSplitAllowed); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx index c42a49bd1b26..4496a65bae07 100644 --- a/sw/source/core/unocore/unomap1.cxx +++ b/sw/source/core/unocore/unomap1.cxx @@ -772,6 +772,7 @@ o3tl::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetFrameProp { UNO_NAME_SIZE_TYPE, RES_FRM_SIZE, cppu::UnoType<sal_Int16>::get() , PROPERTY_NONE, MID_FRMSIZE_SIZE_TYPE }, { UNO_NAME_WIDTH_TYPE, RES_FRM_SIZE, cppu::UnoType<sal_Int16>::get() , PROPERTY_NONE, MID_FRMSIZE_WIDTH_TYPE }, { UNO_NAME_WRITING_MODE, RES_FRAMEDIR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0 }, + { UNO_NAME_IS_SPLIT_ALLOWED, RES_FLY_SPLIT, cppu::UnoType<bool>::get(), PropertyAttribute::MAYBEVOID, 0 }, // added FillProperties for SW, same as FILL_PROPERTIES in svx // but need own defines in Writer due to later association of strings commit 131b97cd937a13d2ddf1f77bf59cf58ada7cec76 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Jan 24 15:32:29 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Feb 24 11:05:47 2023 +0100 sw: add document model for multi-page fly frames Currently we can have multi-page tables and fly frames (where the content wraps around the fly frame), but not both at the same time. Allowing multi-page fly frames in general would probably go too far, but handling this in case the fly frame only contains a table would make sense to support Word's multi-page floating tables. Fix this by adding a new SwFormatFlySplit property on fly frames: this is meant to be enabled when the fly frame is part of a multi-page floating table. Unlike table split, this is off by default. Some logic will be needed later to enable this in case the fly frame originates from a Word floating table. (And obvously this is just the doc model, everything else still needs doing.) (cherry picked from commit 0bb90afaeb193181d7b98b79e962549d8a1dd85a) Change-Id: Id92130c684016cd7e7153e15b0ec6821e4471879 diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index fa2ca1663512..05dd36258649 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -138,6 +138,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/core/attr/fmtfollowtextflow \ sw/source/core/attr/fmtwrapinfluenceonobjpos \ sw/source/core/attr/format \ + sw/source/core/attr/formatflysplit \ 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 23acd68f0883..be36f33841c2 100644 --- a/sw/inc/format.hxx +++ b/sw/inc/format.hxx @@ -233,6 +233,7 @@ public: inline const SwFormatEditInReadonly &GetEditInReadonly( bool = true ) const; inline const SwFormatLayoutSplit &GetLayoutSplit( bool = true ) const; inline const SwFormatRowSplit &GetRowSplit( bool = true ) const; + inline const SwFormatFlySplit &GetFlySplit( 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/formatflysplit.hxx b/sw/inc/formatflysplit.hxx new file mode 100644 index 000000000000..a7cbb82847bb --- /dev/null +++ b/sw/inc/formatflysplit.hxx @@ -0,0 +1,52 @@ +/* -*- 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 a fly frame can be split across multiple pages. +class SW_DLLPUBLIC SwFormatFlySplit final : public SfxBoolItem +{ +public: + SwFormatFlySplit(bool bSplit = false) + : SfxBoolItem(RES_FLY_SPLIT, bSplit) + { + } + + SwFormatFlySplit* Clone(SfxItemPool* pPool = nullptr) const override; + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +inline const SwFormatFlySplit& SwAttrSet::GetFlySplit(bool bInP) const +{ + return Get(RES_FLY_SPLIT, bInP); +} + +inline const SwFormatFlySplit& SwFormat::GetFlySplit(bool bInP) const +{ + return m_aSet.GetFlySplit(bInP); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index e2392cf0007e..8d0c14f23572 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -116,6 +116,7 @@ class SwFormatLineNumber; class SwFormatNoBalancedColumns; class SwFormatPageDesc; class SwFormatRowSplit; +class SwFormatFlySplit; class SwFormatSurround; class SwFormatURL; class SwFormatVertOrient; @@ -358,35 +359,35 @@ constexpr TypedWhichId<SwFormatNoBalancedColumns> RES_COLUMNBALANCE(119); constexpr TypedWhichId<SvxFrameDirectionItem> RES_FRAMEDIR(120); constexpr TypedWhichId<SwHeaderAndFooterEatSpacingItem> RES_HEADER_FOOTER_EAT_SPACING(121); constexpr TypedWhichId<SwFormatRowSplit> RES_ROW_SPLIT(122); -constexpr TypedWhichId<SwFormatFollowTextFlow> RES_FOLLOW_TEXT_FLOW(123); -constexpr TypedWhichId<SfxBoolItem> RES_COLLAPSING_BORDERS(124); -constexpr TypedWhichId<SwFormatWrapInfluenceOnObjPos> RES_WRAP_INFLUENCE_ON_OBJPOS(125); -constexpr TypedWhichId<SwFormatAutoFormat> RES_AUTO_STYLE(126); -constexpr TypedWhichId<SfxStringItem> RES_FRMATR_STYLE_NAME(127); -constexpr TypedWhichId<SfxStringItem> RES_FRMATR_CONDITIONAL_STYLE_NAME(128); -constexpr TypedWhichId<SfxGrabBagItem> RES_FRMATR_GRABBAG(129); -constexpr TypedWhichId<SdrTextVertAdjustItem> RES_TEXT_VERT_ADJUST(130); -constexpr TypedWhichId<SfxBoolItem> RES_BACKGROUND_FULL_SIZE(131); -constexpr TypedWhichId<SfxBoolItem> RES_RTL_GUTTER(132); -constexpr TypedWhichId<SfxBoolItem> RES_DECORATIVE(133); -constexpr sal_uInt16 RES_FRMATR_END(134); +constexpr TypedWhichId<SwFormatFlySplit> RES_FLY_SPLIT(123); +constexpr TypedWhichId<SwFormatFollowTextFlow> RES_FOLLOW_TEXT_FLOW(124); +constexpr TypedWhichId<SfxBoolItem> RES_COLLAPSING_BORDERS(125); +constexpr TypedWhichId<SwFormatWrapInfluenceOnObjPos> RES_WRAP_INFLUENCE_ON_OBJPOS(126); +constexpr TypedWhichId<SwFormatAutoFormat> RES_AUTO_STYLE(127); +constexpr TypedWhichId<SfxStringItem> RES_FRMATR_STYLE_NAME(128); +constexpr TypedWhichId<SfxStringItem> RES_FRMATR_CONDITIONAL_STYLE_NAME(129); +constexpr TypedWhichId<SfxGrabBagItem> RES_FRMATR_GRABBAG(130); +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 sal_uInt16 RES_GRFATR_BEGIN(RES_FRMATR_END); constexpr TypedWhichId<SwMirrorGrf> RES_GRFATR_MIRRORGRF(RES_GRFATR_BEGIN); -constexpr TypedWhichId<SwCropGrf> RES_GRFATR_CROPGRF(135); - -constexpr TypedWhichId<SwRotationGrf> RES_GRFATR_ROTATION(136); -constexpr TypedWhichId<SwLuminanceGrf> RES_GRFATR_LUMINANCE(137); -constexpr TypedWhichId<SwContrastGrf> RES_GRFATR_CONTRAST(138); -constexpr TypedWhichId<SwChannelRGrf> RES_GRFATR_CHANNELR(139); -constexpr TypedWhichId<SwChannelGGrf> RES_GRFATR_CHANNELG(140); -constexpr TypedWhichId<SwChannelBGrf> RES_GRFATR_CHANNELB(141); -constexpr TypedWhichId<SwGammaGrf> RES_GRFATR_GAMMA(142); -constexpr TypedWhichId<SwInvertGrf> RES_GRFATR_INVERT(143); -constexpr TypedWhichId<SwTransparencyGrf> RES_GRFATR_TRANSPARENCY(144); -constexpr TypedWhichId<SwDrawModeGrf> RES_GRFATR_DRAWMODE(145); - -constexpr TypedWhichId<SfxBoolItem> RES_GRFATR_DUMMY2(146); +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<SfxBoolItem> RES_GRFATR_DUMMY4(148); constexpr TypedWhichId<SfxBoolItem> RES_GRFATR_DUMMY5(149); diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx index 1129914b378b..6fd2662186d8 100644 --- a/sw/inc/swatrset.hxx +++ b/sw/inc/swatrset.hxx @@ -81,6 +81,7 @@ class SwFormatLineNumber; class SwFormatEditInReadonly; class SwFormatLayoutSplit; class SwFormatRowSplit; +class SwFormatFlySplit; class SwFormatChain; class SwFormatFootnoteAtTextEnd; class SwFormatEndAtTextEnd; @@ -262,6 +263,7 @@ public: inline const SwFormatEditInReadonly &GetEditInReadonly( bool = true ) const; inline const SwFormatLayoutSplit &GetLayoutSplit( bool = true ) const; inline const SwFormatRowSplit &GetRowSplit( bool = true ) const; + inline const SwFormatFlySplit &GetFlySplit( 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 3ba2a3b9a1eb..25d2a8025020 100644 --- a/sw/qa/core/attr/attr.cxx +++ b/sw/qa/core/attr/attr.cxx @@ -12,6 +12,9 @@ #include <docsh.hxx> #include <swdtflvr.hxx> #include <swmodule.hxx> +#include <frmmgr.hxx> +#include <frameformats.hxx> +#include <formatflysplit.hxx> namespace { @@ -50,6 +53,26 @@ CPPUNIT_TEST_FIXTURE(Test, testSwAttrSet) CPPUNIT_ASSERT(aData.hasValue()); pMod->m_pXSelection = pOldTransferable; } + +CPPUNIT_TEST_FIXTURE(Test, testFormatFlySplit) +{ + 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().GetFlySplit().GetValue()); + + SfxItemSet aSet(pFly->GetAttrSet()); + SwFormatFlySplit aItem(true); + aSet.Put(aItem); + pDoc->SetFlyFrameAttr(*pFly, aSet); + + CPPUNIT_ASSERT(pFly->GetAttrSet().GetFlySplit().GetValue()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/attr/formatflysplit.cxx b/sw/source/core/attr/formatflysplit.cxx new file mode 100644 index 000000000000..72816b2ead4e --- /dev/null +++ b/sw/source/core/attr/formatflysplit.cxx @@ -0,0 +1,39 @@ +/* -*- 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::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: */ diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index a7e1a41db639..4f7ee52b7ab6 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -105,6 +105,7 @@ #include <fmtpdsc.hxx> #include <fmtrfmrk.hxx> #include <fmtrowsplt.hxx> +#include <formatflysplit.hxx> #include <fmtruby.hxx> #include <fmtsrnd.hxx> #include <fmturl.hxx> @@ -391,6 +392,7 @@ SfxItemInfo aSlotTab[] = { SID_ATTR_HDFT_DYNAMIC_SPACING, true },// RES_HEADER_FOOTER_EAT_SPACING { FN_TABLE_ROW_SPLIT, true }, // RES_ROW_SPLIT + { 0, true } , // RES_FLY_SPLIT // #i18732# - use slot-id define in svx { SID_SW_FOLLOW_TEXT_FLOW, true }, // RES_FOLLOW_TEXT_FLOW // #i29550# @@ -417,7 +419,6 @@ SfxItemInfo aSlotTab[] = { 0, true }, // RES_GRFATR_GAMMA, { 0, true }, // RES_GRFATR_INVERT, { 0, true }, // RES_GRFATR_TRANSPARENCY, - { 0, true }, // RES_GRFATR_DUMMY2, { 0, true }, // RES_GRFATR_DUMMY3, { 0, true }, // RES_GRFATR_DUMMY4, { 0, true }, // RES_GRFATR_DUMMY5, @@ -593,6 +594,7 @@ void InitCore() aAttrTab[ RES_COLUMNBALANCE - POOLATTR_BEGIN ] = new SwFormatNoBalancedColumns; aAttrTab[ RES_FRAMEDIR - POOLATTR_BEGIN ] = new SvxFrameDirectionItem( SvxFrameDirection::Environment, RES_FRAMEDIR ); aAttrTab[ RES_ROW_SPLIT - POOLATTR_BEGIN ] = new SwFormatRowSplit; + aAttrTab[ RES_FLY_SPLIT - POOLATTR_BEGIN ] = new SwFormatFlySplit; // #i18732# aAttrTab[ RES_FOLLOW_TEXT_FLOW - POOLATTR_BEGIN ] = new SwFormatFollowTextFlow(false); @@ -625,7 +627,6 @@ void InitCore() aAttrTab[ RES_GRFATR_DRAWMODE - POOLATTR_BEGIN ] = new SwDrawModeGrf; // GraphicAttr - Dummies - aAttrTab[ RES_GRFATR_DUMMY2 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_GRFATR_DUMMY2 ); 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 );