[Libreoffice-commits] core.git: sw/inc sw/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Thu Nov 19 13:20:11 UTC 2020
sw/inc/doc.hxx | 4 +++-
sw/source/core/doc/doctxm.cxx | 6 ++++--
sw/source/core/docnode/ndsect.cxx | 4 ++--
sw/source/core/inc/UndoSection.hxx | 6 ++++--
sw/source/core/undo/unsect.cxx | 21 +++++++++++++--------
5 files changed, 26 insertions(+), 15 deletions(-)
New commits:
commit 4cf151aa73fdfca2f18abb2740e5e55c491af7fe
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Nov 19 10:44:02 2020 +0100
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Thu Nov 19 14:19:29 2020 +0100
sw_fieldmarkhide: adapt SwUndoInsSection with ToX
... similar to commit 405661a98f01416c596083262691cedd941733a1.
Change-Id: Id4faa6334816f361d5543ba38af50b85dbc2b2a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106127
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 74d356324cc0..75ab76a7c471 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -43,6 +43,7 @@
#include <atomic>
#include <memory>
#include <set>
+#include <tuple>
#include <unordered_map>
#include <vector>
@@ -139,6 +140,7 @@ enum class RndStdIds;
namespace sw::mark { class MarkManager; }
namespace sw {
enum class RedlineMode;
+ enum class FieldmarkMode;
class MetaFieldManager;
class UndoManager;
class IShellCursorSupplier;
@@ -1326,7 +1328,7 @@ public:
// insert section (the ODF kind of section, not the nodesarray kind)
SwSection * InsertSwSection(SwPaM const& rRange, SwSectionData &,
- std::pair<SwTOXBase const*, sw::RedlineMode> const* pTOXBase,
+ std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode> const* pTOXBase,
SfxItemSet const*const pAttr, bool const bUpdate = true);
static sal_uInt16 IsInsRegionAvailable( const SwPaM& rRange,
const SwNode** ppSttNd = nullptr );
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index c221b87def1b..9f274cb1f8c0 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -365,10 +365,12 @@ SwTOXBaseSection* SwDoc::InsertTableOf( const SwPaM& aPam,
OUString sSectNm = GetUniqueTOXBaseName( *rTOX.GetTOXType(), rTOX.GetTOXName() );
SwSectionData aSectionData( SectionType::ToxContent, sSectNm );
- std::pair<SwTOXBase const*, sw::RedlineMode> const tmp(&rTOX,
+ std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode> const tmp(
+ &rTOX,
pLayout && pLayout->IsHideRedlines()
? sw::RedlineMode::Hidden
- : sw::RedlineMode::Shown);
+ : sw::RedlineMode::Shown,
+ pLayout ? pLayout->GetFieldmarkMode() : sw::FieldmarkMode::ShowBoth);
SwTOXBaseSection *const pNewSection = dynamic_cast<SwTOXBaseSection *>(
InsertSwSection(aPam, aSectionData, & tmp, pSet, false));
if (pNewSection)
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 23a7b7e0cc02..be7774ae238a 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -149,7 +149,7 @@ static void lcl_CheckEmptyLayFrame( SwNodes const & rNds, SwSectionData& rSectio
SwSection *
SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData,
- std::pair<SwTOXBase const*, sw::RedlineMode> const*const pTOXBaseAndMode,
+ std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode> const*const pTOXBaseAndMode,
SfxItemSet const*const pAttr, bool const bUpdate)
{
const SwNode* pPrvNd = nullptr;
@@ -197,7 +197,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData,
pFormat->SetFormatAttr( *pAttr );
}
- SwTOXBase const*const pTOXBase(pTOXBaseAndMode ? pTOXBaseAndMode->first : nullptr);
+ SwTOXBase const*const pTOXBase(pTOXBaseAndMode ? std::get<0>(*pTOXBaseAndMode) : nullptr);
SwSectionNode* pNewSectNode = nullptr;
RedlineFlags eOld = getIDocumentRedlineAccess().GetRedlineFlags();
diff --git a/sw/source/core/inc/UndoSection.hxx b/sw/source/core/inc/UndoSection.hxx
index ac7858063e2a..29065404cbdb 100644
--- a/sw/source/core/inc/UndoSection.hxx
+++ b/sw/source/core/inc/UndoSection.hxx
@@ -22,6 +22,7 @@
#include <o3tl/deleter.hxx>
#include <undobj.hxx>
+#include <tuple>
#include <memory>
class SfxItemSet;
@@ -32,13 +33,14 @@ class SwTOXBase;
namespace sw {
enum class RedlineMode;
+ enum class FieldmarkMode;
};
class SwUndoInsSection : public SwUndo, private SwUndRng
{
private:
const std::unique_ptr<SwSectionData> m_pSectionData;
- const std::unique_ptr<std::pair<SwTOXBase *, sw::RedlineMode>> m_pTOXBase; /// set iff section is TOX
+ const std::unique_ptr<std::tuple<SwTOXBase *, sw::RedlineMode, sw::FieldmarkMode>> m_pTOXBase; /// set iff section is TOX
const std::unique_ptr<SfxItemSet> m_pAttrSet;
std::unique_ptr<SwHistory> m_pHistory;
std::unique_ptr<SwRedlineData> m_pRedlData;
@@ -53,7 +55,7 @@ private:
public:
SwUndoInsSection(SwPaM const&, SwSectionData const&,
SfxItemSet const* pSet,
- std::pair<SwTOXBase const*, sw::RedlineMode> const* pTOXBase);
+ std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode> const* pTOXBase);
virtual ~SwUndoInsSection() override;
diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index 473033599310..ea1d9ec3e2da 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -76,12 +76,12 @@ static std::unique_ptr<SfxItemSet> lcl_GetAttrSet( const SwSection& rSect )
SwUndoInsSection::SwUndoInsSection(
SwPaM const& rPam, SwSectionData const& rNewData,
SfxItemSet const*const pSet,
- std::pair<SwTOXBase const*, sw::RedlineMode> const*const pTOXBase)
+ std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode> const*const pTOXBase)
: SwUndo( SwUndoId::INSSECTION, &rPam.GetDoc() ), SwUndRng( rPam )
, m_pSectionData(new SwSectionData(rNewData))
, m_pTOXBase( pTOXBase
- ? std::make_unique<std::pair<SwTOXBase *, sw::RedlineMode>>(
- new SwTOXBase(*pTOXBase->first), pTOXBase->second)
+ ? std::make_unique<std::tuple<SwTOXBase *, sw::RedlineMode, sw::FieldmarkMode>>(
+ new SwTOXBase(*std::get<0>(*pTOXBase)), std::get<1>(*pTOXBase), std::get<2>(*pTOXBase))
: nullptr )
, m_pAttrSet( (pSet && pSet->Count()) ? new SfxItemSet( *pSet ) : nullptr )
, m_nSectionNodePos(0)
@@ -183,16 +183,19 @@ void SwUndoInsSection::RedoImpl(::sw::UndoRedoContext & rContext)
{
SwRootFrame const* pLayout(nullptr);
SwRootFrame * pLayoutToReset(nullptr);
+ sw::FieldmarkMode eFieldmarkMode{};
comphelper::ScopeGuard g([&]() {
if (pLayoutToReset)
{
- pLayoutToReset->SetHideRedlines(m_pTOXBase->second == sw::RedlineMode::Shown);
+ pLayoutToReset->SetHideRedlines(std::get<1>(*m_pTOXBase) == sw::RedlineMode::Shown);
+ pLayoutToReset->SetFieldmarkMode(eFieldmarkMode);
}
});
o3tl::sorted_vector<SwRootFrame *> layouts(rDoc.GetAllLayouts());
for (SwRootFrame const*const p : layouts)
{
- if ((m_pTOXBase->second == sw::RedlineMode::Hidden) == p->IsHideRedlines())
+ if ((std::get<1>(*m_pTOXBase) == sw::RedlineMode::Hidden) == p->IsHideRedlines()
+ && std::get<2>(*m_pTOXBase) == p->GetFieldmarkMode())
{
pLayout = p;
break;
@@ -202,12 +205,14 @@ void SwUndoInsSection::RedoImpl(::sw::UndoRedoContext & rContext)
{
assert(!layouts.empty()); // must have one layout
pLayoutToReset = *layouts.begin();
- pLayoutToReset->SetHideRedlines(m_pTOXBase->second == sw::RedlineMode::Hidden);
+ eFieldmarkMode = pLayoutToReset->GetFieldmarkMode();
+ pLayoutToReset->SetHideRedlines(std::get<1>(*m_pTOXBase) == sw::RedlineMode::Hidden);
+ pLayoutToReset->SetFieldmarkMode(std::get<2>(*m_pTOXBase));
pLayout = pLayoutToReset;
}
pUpdateTOX = rDoc.InsertTableOf( *rPam.GetPoint(),
// don't expand: will be done by SwUndoUpdateIndex::RedoImpl()
- *m_pTOXBase->first, m_pAttrSet.get(), false, pLayout);
+ *std::get<0>(*m_pTOXBase), m_pAttrSet.get(), false, pLayout);
}
else
{
@@ -256,7 +261,7 @@ void SwUndoInsSection::RepeatImpl(::sw::RepeatContext & rContext)
if (m_pTOXBase)
{
rDoc.InsertTableOf(*rContext.GetRepeatPaM().GetPoint(),
- *m_pTOXBase->first, m_pAttrSet.get(), true,
+ *std::get<0>(*m_pTOXBase), m_pAttrSet.get(), true,
rDoc.getIDocumentLayoutAccess().GetCurrentLayout()); // TODO add shell to RepeatContext?
}
else
More information about the Libreoffice-commits
mailing list