[Libreoffice-commits] core.git: sw/inc sw/source

2023-11-25 Thread Noel Grandin (via logerrit)
 sw/inc/IDocumentFieldsAccess.hxx |5 
 sw/inc/calc.hxx  |   61 ---
 sw/source/core/bastyp/calc.cxx   |  226 +++
 sw/source/core/doc/DocumentFieldsManager.cxx |   73 ++--
 sw/source/core/doc/docfld.cxx|   48 +
 sw/source/core/edit/editsh.cxx   |2 
 sw/source/core/fields/expfld.cxx |2 
 sw/source/core/inc/DocumentFieldsManager.hxx |2 
 sw/source/core/inc/docfld.hxx|   29 +--
 9 files changed, 114 insertions(+), 334 deletions(-)

New commits:
commit 947b23c20780ede6b4d588fb9b944f572e9f8bc8
Author: Noel Grandin 
AuthorDate: Sat Nov 25 00:53:37 2023 +0200
Commit: Noel Grandin 
CommitDate: Sat Nov 25 11:25:25 2023 +0100

Convert SwHashTable to std::unordered_map

Change-Id: I88b082dc61c05761fd162ea4cf1d30940c2dfccd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159941
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/IDocumentFieldsAccess.hxx b/sw/inc/IDocumentFieldsAccess.hxx
index 4664ae3bc846..4ffe7779833f 100644
--- a/sw/inc/IDocumentFieldsAccess.hxx
+++ b/sw/inc/IDocumentFieldsAccess.hxx
@@ -25,6 +25,7 @@
 #include 
 #include "swtypes.hxx"
 #include "nodeoffset.hxx"
+#include 
 
 class SwFieldTypes;
 class SwFieldType;
@@ -40,8 +41,6 @@ class SetGetExpField;
 class SwNode;
 class SwTable;
 enum class SwFieldIds : sal_uInt16;
-template  class SwHashTable;
-struct HashStr;
 class SwRootFrame;
 class IDocumentRedlineAccess;
 
@@ -128,7 +127,7 @@ namespace com::sun::star::uno { class Any; }
 
 virtual void FieldsToCalc(SwCalc& rCalc, const SetGetExpField& 
rToThisField, SwRootFrame const* pLayout) = 0;
 
-virtual void FieldsToExpand(SwHashTable & rTable, const 
SetGetExpField& rToThisField, SwRootFrame const& rLayout) = 0;
+virtual void FieldsToExpand(std::unordered_map & 
rTable, const SetGetExpField& rToThisField, SwRootFrame const& rLayout) = 0;
 
 virtual bool IsNewFieldLst() const = 0;
 
diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index 87583f752ff4..0e066bae145f 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -22,6 +22,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -37,8 +38,6 @@ class SwFieldType;
 class SwDoc;
 class SwUserFieldType;
 
-#define TBLSZ 47// should be a prime, because of hash table
-
 const sal_Unicode cListDelim= '|';
 
 enum SwCalcOper
@@ -131,62 +130,12 @@ public:
 void SetDBvalue(bool bSet) {m_bDBvalue = bSet;}
 };
 
-// Calculate HashTables for VarTable and Operations
-struct SwHash
-{
-SwHash( OUString aStr );
-virtual ~SwHash();
-OUString aStr;
-std::unique_ptr pNext;
-};
-
-struct SwCalcExp final : public SwHash
+struct SwCalcExp
 {
 SwSbxValue  nValue;
 const SwFieldType* pFieldType;
 
-SwCalcExp( const OUString& rStr, SwSbxValue aVal,
-const SwFieldType* pFieldType );
-};
-
-/// T should be a subclass of SwHash
-template
-class SwHashTable
-{
-std::vector> m_aData;
-public:
-SwHashTable(size_t nSize) : m_aData(nSize)
-{
-assert(nSize < SAL_MAX_UINT32);
-}
-std::unique_ptr & operator[](size_t idx) { return m_aData[idx]; }
-std::unique_ptr const & operator[](size_t idx) const { return 
m_aData[idx]; }
-void resize(size_t nSize) { m_aData.resize(nSize); }
-
-T* Find( std::u16string_view aStr, sal_uInt32* pPos = nullptr ) const
-{
-size_t nTableSize = m_aData.size();
-assert(nTableSize < SAL_MAX_UINT32);
-sal_uInt32 ii = 0;
-for( size_t n = 0; n < aStr.size(); ++n )
-{
-ii = ii << 1 ^ aStr[n];
-}
-ii %= nTableSize;
-
-if( pPos )
-*pPos = ii;
-
-for( T* pEntry = m_aData[ii].get(); pEntry; pEntry = 
static_cast(pEntry->pNext.get()) )
-{
-if( aStr == pEntry->aStr )
-{
-return pEntry;
-}
-}
-return nullptr;
-}
-
+SwCalcExp( SwSbxValue aVal, const SwFieldType* pFieldType );
 };
 
 
@@ -198,7 +147,7 @@ extern "C" typedef double (*pfCalc)(double);
 
 class SwCalc
 {
-SwHashTable m_aVarTable;
+std::unordered_map m_aVarTable;
 OUStringBuffer m_aVarName;
 OUStringm_sCurrSym;
 OUStringm_sCommand;
@@ -245,7 +194,7 @@ public:
 SwCalcExp*  VarLook( const OUString , bool bIns = false );
 voidVarChange( const OUString& rStr, const SwSbxValue& rValue );
 voidVarChange( const OUString& rStr, double );
-SwHashTable & GetVarTable() { return m_aVarTable; }
+std::unordered_map & GetVarTable() { return 
m_aVarTable; }
 
 boolPush(const SwUserFieldType* pUserFieldType);
 voidPop();
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 62d300f60ba7..0c9643317a4e 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-11-20 Thread Matt K (via logerrit)
 sw/inc/comcore.hxx  |4 +++-
 sw/inc/utlui.hrc|4 +++-
 sw/source/core/edit/autofmt.cxx |   40 
 3 files changed, 46 insertions(+), 2 deletions(-)

New commits:
commit 2fa88bfbfa4c9befe1be8a1953c018437a621254
Author: Matt K 
AuthorDate: Fri Jul 7 17:18:28 2023 -0500
Commit: Mike Kaganski 
CommitDate: Tue Nov 21 06:52:29 2023 +0100

tdf#117651 Add AutoCorrect support for italic and strikethrough

The AutoCorrect "Apply" command calls SwAutoFormat::AutoCorrect
in sw/source/core/edit/autofmt.cxx, as mentioned in the bug
comments.  This change just adds new cases for "/" (italic)
and "-" (strikethrough), so that when "Tools" -> "AutoCorrect"
->  "Apply" is invoked it changes any text between 2 "/"s or
2 "-"s (assuming your AutoCorrect options enable the setting
for this).  The new code is just mostly copied from the case
statement above it (for bold and underline), and the only
additional changes that were needed were to add the comment
strings for the 2 new cases.

Change-Id: I02238690a40fd0113e3e9acbecf93ef5c34e0785
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154207
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/comcore.hxx b/sw/inc/comcore.hxx
index 96a53fc84b2d..9da3d19e2aa0 100644
--- a/sw/inc/comcore.hxx
+++ b/sw/inc/comcore.hxx
@@ -45,8 +45,10 @@
 #define STR_AUTOFMTREDL_NON_BREAK_SPACE 21
 #define STR_AUTOFMTREDL_TRANSLITERATE_RTL   22
 #define STR_AUTOFMTREDL_DETECT_DOI  23
+#define STR_AUTOFMTREDL_ITALIC  24
+#define STR_AUTOFMTREDL_STRIKETHROUGH   25
 // !!  always set the correct end 
-#define STR_AUTOFMTREDL_END 24
+#define STR_AUTOFMTREDL_END 26
 
 #endif
 
diff --git a/sw/inc/utlui.hrc b/sw/inc/utlui.hrc
index db13af5b517c..417123331e46 100644
--- a/sw/inc/utlui.hrc
+++ b/sw/inc/utlui.hrc
@@ -50,7 +50,9 @@ const TranslateId RID_SHELLRES_AUTOFMTSTRS[] =
 NC_("RID_SHELLRES_AUTOFMTSTRS", "Combine paragraphs"),
 NC_("RID_SHELLRES_AUTOFMTSTRS", "Add non breaking space"),
 NC_("RID_SHELLRES_AUTOFMTSTRS", "Transliterates RTL Hungarian text to Old 
Hungarian script"),
-NC_("RID_SHELLRES_AUTOFMTSTRS", "DOI citation recognition")
+NC_("RID_SHELLRES_AUTOFMTSTRS", "DOI citation recognition"),
+NC_("RID_SHELLRES_AUTOFMTSTRS", "Automatic /italic/"),
+NC_("RID_SHELLRES_AUTOFMTSTRS", "Automatic -strikethrough-"),
 };
 
 #endif
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 555eec327a5d..65324e0eb296 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -282,6 +282,8 @@ void SwAutoFormat::SetRedlineText_( sal_uInt16 nActionId )
 case STR_AUTOFMTREDL_ORDINAL:
 case STR_AUTOFMTREDL_NON_BREAK_SPACE:
 case STR_AUTOFMTREDL_TRANSLITERATE_RTL:
+case STR_AUTOFMTREDL_ITALIC:
+case STR_AUTOFMTREDL_STRIKETHROUGH:
 nSeqNo = ++m_nRedlAutoFormatSeqId;
 break;
 }
@@ -2109,6 +2111,44 @@ void SwAutoFormat::AutoCorrect(TextFrameIndex nPos)
 SetRedlineText( STR_AUTOFMTREDL_NON_BREAK_SPACE );
 if (pATst->FnAddNonBrkSpace(aACorrDoc, *pText, 
sal_Int32(nPos), eLang, bNbspRunNext))
 --nPos;
+break;
+}
+[[fallthrough]];
+case '-':
+if (m_aFlags.bChgWeightUnderl)
+{
+// consider Symbolfonts!
+if (!aFInfo.GetFrame())
+aFInfo.SetFrame(GetFrame(*m_pCurTextNd));
+if (!aFInfo.IsBullet(nPos))
+{
+SetRedlineText('/' == cChar ? STR_AUTOFMTREDL_ITALIC : 
STR_AUTOFMTREDL_STRIKETHROUGH);
+
+sal_Unicode cBlank = nSttPos ? 
(*pText)[sal_Int32(nSttPos) - 1] : 0;
+*m_aDelPam.GetPoint() = 
m_pCurTextFrame->MapViewToModelPos(nPos);
+
+if (pATst->FnChgWeightUnderl(aACorrDoc, *pText, 
sal_Int32(nPos)))
+{
+if (m_aFlags.bWithRedlining)
+{
+m_aNdIdx = m_aDelPam.GetPoint()->GetNode();
+m_pCurTextNd = 
m_aNdIdx.GetNode().GetTextNode();
+m_pCurTextFrame = GetFrame(*m_pCurTextNd);
+pText = _pCurTextFrame->GetText();
+m_aDelPam.SetMark();
+m_aDelPam.DeleteMark();
+aFInfo.SetFrame(nullptr);
+}
+//#125102# in case of the mode 
RedlineFlags::ShowDelete the ** are still contained in pText
+

[Libreoffice-commits] core.git: sw/inc sw/source sw/uiconfig

2023-11-20 Thread Balazs Varga (via logerrit)
 sw/inc/SwCapConfigProp.hxx   |   38 ++
 sw/source/ui/config/optload.cxx  |  503 ++-
 sw/source/uibase/inc/optload.hxx |   11 
 sw/uiconfig/swriter/ui/optcaptionpage.ui |  206 ++--
 4 files changed, 725 insertions(+), 33 deletions(-)

New commits:
commit 3e81415f7f71b7fe99342c82b3c54011fbcb2dbb
Author: Balazs Varga 
AuthorDate: Fri Nov 17 19:03:51 2023 +0100
Commit: Balazs Varga 
CommitDate: Mon Nov 20 12:55:55 2023 +0100

tdf#158136 - UI: Part 31 - Unify lockdown behavior of Options dialog

for Writer - AutoCaption Page.

Change-Id: Ia3c37510477542556c3302d2013fe10a4ae00545
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159594
Tested-by: Jenkins
Reviewed-by: Balazs Varga 

diff --git a/sw/inc/SwCapConfigProp.hxx b/sw/inc/SwCapConfigProp.hxx
new file mode 100644
index ..20257f3d9716
--- /dev/null
+++ b/sw/inc/SwCapConfigProp.hxx
@@ -0,0 +1,38 @@
+/* -*- 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 .
+ */
+#ifndef INCLUDED_SW_INC_SWCAPCONFIGPROP_HXX
+#define INCLUDED_SW_INC_SWCAPCONFIGPROP_HXX
+
+enum CapConfigProp
+{
+PROP_CAP_OBJECT_ENABLE = 0, //0
+PROP_CAP_OBJECT_CATEGORY, //1
+PROP_CAP_OBJECT_NUMBERING, //2
+PROP_CAP_OBJECT_NUMBERINGSEPARATOR, //3
+PROP_CAP_OBJECT_CAPTIONTEXT, //4
+PROP_CAP_OBJECT_DELIMITER, //5
+PROP_CAP_OBJECT_LEVEL, //6
+PROP_CAP_OBJECT_POSITION, //7
+PROP_CAP_OBJECT_CHARACTERSTYLE, //8
+PROP_CAP_OBJECT_APPLYATTRIBUTES, //9
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx
index 675a2d48e8d6..3adf4dce4e34 100644
--- a/sw/source/ui/config/optload.cxx
+++ b/sw/source/ui/config/optload.cxx
@@ -55,6 +55,436 @@
 
 using namespace ::com::sun::star;
 
+static bool lcl_isPropertyReadOnly(const SwCapObjType eType, const 
CapConfigProp ePropType, const SvGlobalName& rOleId)
+{
+bool bReadOnly = false;
+
+switch (ePropType)
+{
+case PROP_CAP_OBJECT_ENABLE:
+{
+switch (eType)
+{
+case TABLE_CAP:
+bReadOnly = 
officecfg::Office::Writer::Insert::Caption::WriterObject::Table::Enable::isReadOnly();
+break;
+case FRAME_CAP:
+bReadOnly = 
officecfg::Office::Writer::Insert::Caption::WriterObject::Frame::Enable::isReadOnly();
+break;
+case GRAPHIC_CAP:
+bReadOnly = 
officecfg::Office::Writer::Insert::Caption::WriterObject::Graphic::Enable::isReadOnly();
+break;
+case OLE_CAP:
+{
+if (rOleId == SvGlobalName(SO3_SC_CLASSID)) {
+bReadOnly = 
officecfg::Office::Writer::Insert::Caption::OfficeObject::Calc::Enable::isReadOnly();
+} else if (rOleId == SvGlobalName(SO3_SIMPRESS_CLASSID)) {
+bReadOnly = 
officecfg::Office::Writer::Insert::Caption::OfficeObject::Impress::Enable::isReadOnly();
+} else if (rOleId == SvGlobalName(SO3_SCH_CLASSID)) {
+bReadOnly = 
officecfg::Office::Writer::Insert::Caption::OfficeObject::Chart::Enable::isReadOnly();
+} else if (rOleId == SvGlobalName(SO3_SM_CLASSID)) {
+bReadOnly = 
officecfg::Office::Writer::Insert::Caption::OfficeObject::Formula::Enable::isReadOnly();
+} else if (rOleId == SvGlobalName(SO3_SDRAW_CLASSID)) {
+bReadOnly = 
officecfg::Office::Writer::Insert::Caption::OfficeObject::Draw::Enable::isReadOnly();
+} else if (rOleId == SvGlobalName(SO3_OUT_CLASSID)) {
+bReadOnly = 
officecfg::Office::Writer::Insert::Caption::OfficeObject::OLEMisc::Enable::isReadOnly();
+} else {
+// Should not reach it.
+}
+}
+break;
+default:
+break;
+

[Libreoffice-commits] core.git: sw/inc sw/source

2023-11-20 Thread Julien Nabet (via logerrit)
 sw/inc/doc.hxx|5 +
 sw/source/core/attr/calbck.cxx|7 +++
 sw/source/core/edit/edfcol.cxx|6 ++
 sw/source/core/inc/layfrm.hxx |5 +
 sw/source/core/txtnode/attrcontentcontrol.cxx |4 +---
 sw/source/core/txtnode/fmtatr2.cxx|5 +
 sw/source/core/unocore/unochart.cxx   |4 ++--
 sw/source/core/unocore/unoobj2.cxx|3 +--
 sw/source/core/view/viewsh.cxx|2 +-
 sw/source/filter/html/htmltab.cxx |2 +-
 sw/source/filter/ww8/writerwordglue.cxx   |3 +--
 sw/source/ui/dbui/mmaddressblockpage.cxx  |2 +-
 sw/source/ui/misc/bookmark.cxx|4 +---
 sw/source/uibase/docvw/PostItMgr.cxx  |2 +-
 sw/source/uibase/uiview/uivwimp.cxx   |4 ++--
 sw/source/uibase/uno/unodispatch.cxx  |7 +++
 sw/source/uibase/utlui/content.cxx|3 +--
 17 files changed, 24 insertions(+), 44 deletions(-)

New commits:
commit 950bee9154c9854364c72a3b48ddbc137803
Author: Julien Nabet 
AuthorDate: Sun Nov 19 21:29:12 2023 +0100
Commit: Julien Nabet 
CommitDate: Mon Nov 20 12:06:28 2023 +0100

c++20: use std::erase(_if) instead of std::remove(_if)+erase (sw)

Change-Id: I67c231441b56f05da001beab5b893bc6a6a6a392
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159704
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 5d1814210801..ea95cef85636 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1675,10 +1675,7 @@ public:
 {
 auto & rTable = const_cast(this)->mvUnoCursorTable;
 // In most cases we'll remove most of the elements.
-rTable.erase( std::remove_if(rTable.begin(),
- rTable.end(),
- [] (std::weak_ptr const & x) 
{ return x.expired(); }),
-  rTable.end());
+std::erase_if(rTable, [] (std::weak_ptr const & x) { 
return x.expired(); });
 }
 
 /**
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 81a249203dc8..871dff43477b 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -284,13 +284,12 @@ bool sw::WriterMultiListener::IsListeningTo(const 
SwModify* const pBroadcaster)
 
 void sw::WriterMultiListener::EndListening(SwModify* pBroadcaster)
 {
-m_vDepends.erase(
-std::remove_if( m_vDepends.begin(), m_vDepends.end(),
+std::erase_if(
+m_vDepends,
 [](const ListenerEntry& aListener)
 {
 return aListener.GetRegisteredIn() == nullptr || 
aListener.GetRegisteredIn() == pBroadcaster;
-}),
-m_vDepends.end());
+});
 }
 
 void sw::WriterMultiListener::EndListeningAll()
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 2ce0caa01f91..f02273e07318 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -1190,11 +1190,9 @@ static void lcl_ApplyParagraphClassification(SwDoc* pDoc,
 // need to insert in reverse order.
 std::reverse(aResults.begin(), aResults.end());
 // Ignore "PARAGRAPH" types
-aResults.erase(std::remove_if(aResults.begin(),
-  aResults.end(),
+std::erase_if(aResults,
   [](const svx::ClassificationResult& 
rResult)-> bool
-{ return rResult.meType == 
svx::ClassificationType::PARAGRAPH; }),
-  aResults.end());
+{ return rResult.meType == 
svx::ClassificationType::PARAGRAPH; });
 
 sfx::ClassificationKeyCreator 
aKeyCreator(SfxClassificationHelper::getPolicyType());
 std::vector aFieldNames;
diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index 52e22829d4ad..981fbb34f649 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -178,10 +178,7 @@ public:
 
 void ClearVertPosOrientFrameFor(SwAnchoredObject *pObj)
 {
-m_VertPosOrientFramesFor.erase(
-std::remove(m_VertPosOrientFramesFor.begin(),
-m_VertPosOrientFramesFor.end(), pObj),
-m_VertPosOrientFramesFor.end());
+std::erase(m_VertPosOrientFramesFor, pObj);
 }
 void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override;
 };
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx 
b/sw/source/core/txtnode/attrcontentcontrol.cxx
index 1782f23fb526..c894615fa41d 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -830,9 +830,7 @@ void SwContentControlManager::Insert(SwTextContentControl* 
pTextContentControl)
 
 void SwContentControlManager::Erase(SwTextContentControl* 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-11-17 Thread Caolán McNamara (via logerrit)
 sw/inc/swurl.hxx |5 
 sw/source/uibase/shells/drwtxtex.cxx |2 -
 sw/source/uibase/wrtsh/wrtsh2.cxx|   39 +--
 3 files changed, 20 insertions(+), 26 deletions(-)

New commits:
commit 521ca9cf6acbae96cf95d9740859c9682212013d
Author: Caolán McNamara 
AuthorDate: Fri Nov 17 08:57:09 2023 +
Commit: Caolán McNamara 
CommitDate: Fri Nov 17 11:33:08 2023 +0100

we can have just one LoadURL for writer

Change-Id: Ia0162ee1c275292fcf200bad4662e4c2c6b7b972
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159557
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/swurl.hxx b/sw/inc/swurl.hxx
index ec88a639a4e9..87375f30c8b7 100644
--- a/sw/inc/swurl.hxx
+++ b/sw/inc/swurl.hxx
@@ -23,7 +23,6 @@
 #include 
 
 class SwViewShell;
-class SwView;
 
 enum class LoadUrlFlags {
 NONE= 0x00,
@@ -36,10 +35,6 @@ namespace o3tl {
 void LoadURL( SwViewShell& rSh, const OUString& rName,
   LoadUrlFlags nFilter, const OUString& rTargetFrameName );
 
-void LoadURL( SwView& rView, const OUString& rName,
-  LoadUrlFlags nFilter, const OUString& rTargetFrameName );
-
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/drwtxtex.cxx 
b/sw/source/uibase/shells/drwtxtex.cxx
index aac07e855f05..3d7eecab6f07 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -499,7 +499,7 @@ void SwDrawTextShell::Execute( SfxRequest  )
 const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : 
nullptr;
 if (const SvxURLField* pURLField = dynamic_cast(pField))
 {
-::LoadURL(GetView(), pURLField->GetURL(), LoadUrlFlags::NONE,
+::LoadURL(GetShell(), pURLField->GetURL(), LoadUrlFlags::NONE,
   pURLField->GetTargetFrame());
 }
 }
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx 
b/sw/source/uibase/wrtsh/wrtsh2.cxx
index d2451442c600..e3af36a1c54b 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -553,26 +553,8 @@ bool SwWrtShell::ClickToINetGrf( const Point& rDocPt, 
LoadUrlFlags nFilter )
 return bRet;
 }
 
-void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter,
-  const OUString& rTargetFrameName )
-{
-OSL_ENSURE( !rURL.isEmpty(), "what should be loaded here?" );
-if( rURL.isEmpty() )
-return ;
-
-// The shell could be 0 also!
-if ( dynamic_cast( ) ==  nullptr )
-return;
-
-//A CursorShell is always a WrtShell
-SwWrtShell  = static_cast(rVSh);
-
-::LoadURL(rSh.GetView(), rURL, nFilter, rTargetFrameName);
-
-}
-
-void LoadURL(SwView& rView, const OUString& rURL, LoadUrlFlags nFilter,
-  const OUString& rTargetFrameName)
+static void LoadURL(SwView& rView, const OUString& rURL, LoadUrlFlags nFilter,
+const OUString& rTargetFrameName)
 {
 SwDocShell* pDShell = rView.GetDocShell();
 OSL_ENSURE( pDShell, "No DocShell?!");
@@ -629,6 +611,23 @@ void LoadURL(SwView& rView, const OUString& rURL, 
LoadUrlFlags nFilter,
 {  } );
 }
 
+void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter,
+  const OUString& rTargetFrameName )
+{
+OSL_ENSURE( !rURL.isEmpty(), "what should be loaded here?" );
+if( rURL.isEmpty() )
+return ;
+
+// The shell could be 0 also!
+if ( dynamic_cast( ) ==  nullptr )
+return;
+
+//A CursorShell is always a WrtShell
+SwWrtShell  = static_cast(rVSh);
+
+::LoadURL(rSh.GetView(), rURL, nFilter, rTargetFrameName);
+}
+
 void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk,
 const sal_uInt16 nAction )
 {


[Libreoffice-commits] core.git: sw/inc sw/source

2023-11-13 Thread Andreas Heinisch (via logerrit)
 sw/inc/viewopt.hxx  |9 +
 sw/source/ui/index/cnttab.cxx   |   16 +++-
 sw/source/uibase/config/viewopt.cxx |4 
 3 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 8bf614179f5664d7cdd49db41ef462073cc8608d
Author: Andreas Heinisch 
AuthorDate: Thu Nov 9 16:00:10 2023 +0100
Commit: Andreas Heinisch 
CommitDate: Mon Nov 13 18:16:38 2023 +0100

tdf#135266 - Remember last used entry level depending on the index type

Change-Id: I4fe9342c28fc9135b73286e67464b16a1d910a9f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159217
Reviewed-by: Noel Grandin 
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index 3c847acfd6fe..72659849a627 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -274,6 +274,9 @@ class SW_DLLPUBLIC SwViewOption
 boolm_bShowPlaceHolderFields : 1; // Only used in printing!
 mutable boolm_bIdle;
 sal_Int32   m_nDefaultAnchor; // GetDefaultAnchorType() to convert 
int to RndStdIds
+// tdf#135266 - tox dialog: remember last used entry level depending on 
the index type
+sal_uInt8 m_nTocEntryLvl;
+sal_uInt8 m_nIdxEntryLvl;
 
 // Scale
 sal_uInt16  m_nZoom;  // In percent.
@@ -845,6 +848,12 @@ public:
 
 RndStdIds GetDefaultAnchorType() const;
 
+// tdf#135266 - tox dialog: remember last used entry level depending on 
the index type
+sal_uInt8 GetTocEntryLvl() const { return m_nTocEntryLvl; }
+void SetTocEntryLvl(sal_uInt8 n) { m_nTocEntryLvl = n; }
+sal_uInt8 GetIdxEntryLvl() const { return m_nIdxEntryLvl; }
+void SetIdxEntryLvl(sal_uInt8 n) { m_nIdxEntryLvl = n; }
+
 // Useful for when getting the current view SwViewOption is not possible 
otherwise
 static const SwViewOption& GetCurrentViewOptions();
 };
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 829beb6e9499..a5d3bf92ddef 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -2065,6 +2065,17 @@ SwTOXEntryTabPage::SwTOXEntryTabPage(weld::Container* 
pPage, weld::DialogControl
 SwTOXEntryTabPage::~SwTOXEntryTabPage()
 {
 m_xTokenWIN.reset();
+
+// tdf#135266 - remember last used entry level depending on the index type
+if (const auto aSelectedIndex = m_xLevelLB->get_selected_index(); 
aSelectedIndex != -1)
+{
+auto& rSh = 
static_cast(GetDialogController())->GetWrtShell();
+SwViewOption* pVOpt = const_cast(rSh.GetViewOptions());
+if (m_aLastTOXType == TOX_INDEX)
+pVOpt->SetIdxEntryLvl(aSelectedIndex);
+else
+pVOpt->SetTocEntryLvl(aSelectedIndex);
+}
 }
 
 IMPL_LINK_NOARG(SwTOXEntryTabPage, ModifyClickHdl, weld::Toggleable&, void)
@@ -2240,7 +2251,10 @@ void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& 
/*rSet*/)
 else
 m_xLevelFT->set_label(m_sLevelStr);
 
-m_xLevelLB->select(bToxIsIndex ? 1 : 0);
+// tdf#135266 - remember last used entry level depending on the index 
type
+m_xLevelLB->select(bToxIsIndex ? 
pTOXDlg->GetWrtShell().GetViewOptions()->GetIdxEntryLvl()
+   : 
pTOXDlg->GetWrtShell().GetViewOptions()->GetTocEntryLvl());
+
 
 //show or hide controls
 ShowHideControls(aCurType.eType);
diff --git a/sw/source/uibase/config/viewopt.cxx 
b/sw/source/uibase/config/viewopt.cxx
index 1e78b1fdac02..36fdf1fd4484 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -292,6 +292,10 @@ SwViewOption::SwViewOption() :
 
 m_nDefaultAnchor = 1; //FLY_TO_CHAR
 
+// tdf#135266 - tox dialog: remember last used entry level depending on 
the index type
+m_nTocEntryLvl = 0;
+m_nIdxEntryLvl = 1;
+
 #ifdef DBG_UTIL
 // correspond to the statements in ui/config/cfgvw.src
 m_bTest1 = m_bTest2 = m_bTest3 = m_bTest4 =


[Libreoffice-commits] core.git: sw/inc sw/source

2023-11-08 Thread Noel Grandin (via logerrit)
 sw/inc/docsh.hxx  |3 ++-
 sw/source/uibase/app/docshini.cxx |2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit dae818cf81763dedad573c86b352f1cfedcfeb64
Author: Noel Grandin 
AuthorDate: Wed Nov 8 09:27:02 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Nov 9 06:25:25 2023 +0100

loplugin:fieldcast in SwDocShell

Change-Id: I81739c24ae1174ff9f889490b8152dda7b61f328
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159171
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 301ba4748fd1..3cbc43c98803 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -52,6 +52,7 @@ class IDocumentChartDataProviderAccess;
 class SwDocShell;
 class SwDrawModel;
 class SwViewShell;
+class SwDocStyleSheetPool;
 namespace svt
 {
 class EmbeddedObjectRef;
@@ -69,7 +70,7 @@ class SW_DLLPUBLIC SwDocShell
 , public SfxListener
 {
 rtl::Reference< SwDoc > m_xDoc;  ///< Document.
-rtl::Reference< SfxStyleSheetBasePool > m_xBasePool; ///< Passing through 
for formats.
+rtl::Reference< SwDocStyleSheetPool > m_xBasePool; ///< Passing through 
for formats.
 std::unique_ptr m_pFontList;  ///< Current Fontlist.
 boolm_IsInUpdateFontList; ///< prevent nested calls of 
UpdateFontList
 
diff --git a/sw/source/uibase/app/docshini.cxx 
b/sw/source/uibase/app/docshini.cxx
index 2dbe6095a554..6d3cf42a7858 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -436,7 +436,7 @@ void SwDocShell::RemoveLink()
 {
 if (m_xBasePool.is())
 {
-static_cast(m_xBasePool.get())->dispose();
+m_xBasePool->dispose();
 m_xBasePool.clear();
 }
 m_xDoc->SetOle2Link(Link());


[Libreoffice-commits] core.git: sw/inc sw/source

2023-11-08 Thread Noel Grandin (via logerrit)
 sw/inc/viscrs.hxx  |4 ++--
 sw/source/core/crsr/viscrs.cxx |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit ce98f8d033ab9dfd505448860981472153970e96
Author: Noel Grandin 
AuthorDate: Tue Nov 7 16:18:05 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Nov 9 06:21:25 2023 +0100

loplugin:fieldcast in SwSelPaintRects

Change-Id: I62471db74c30baf8bd42a3679624c767c68c66f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159137
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index 24b632cca22c..2aba4bbd7110 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -28,7 +28,7 @@
 
 #include 
 
-namespace sdr::overlay { class OverlayObject; }
+namespace sdr::overlay { class OverlaySelection; }
 
 class SwCursorShell;
 class SfxViewShell;
@@ -87,7 +87,7 @@ class SwSelPaintRects : public SwRects
 const SwCursorShell* m_pCursorShell;
 
 #if HAVE_FEATURE_DESKTOP || defined(ANDROID)
-std::unique_ptr m_pCursorOverlay;
+std::unique_ptr m_pCursorOverlay;
 #endif
 
 bool m_bShowTextInputFieldOverlay;
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index f681f3a32815..0385ce85f71c 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -448,7 +448,7 @@ void SwSelPaintRects::Show(std::vector* 
pSelectionRectangles)
 {
 if(!aNewRanges.empty())
 {
-
static_cast(m_pCursorOverlay.get())->setRanges(std::move(aNewRanges));
+m_pCursorOverlay->setRanges(std::move(aNewRanges));
 }
 else
 {


[Libreoffice-commits] core.git: sw/inc sw/source

2023-11-03 Thread EMartinGube (via logerrit)
 sw/inc/dbmgr.hxx|4 ++--
 sw/source/uibase/dbui/dbmgr.cxx |   11 ++-
 2 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit d7a5e7643f3540b1490c1e2f1a91ff86c721d7b6
Author: EMartinGube 
AuthorDate: Mon Aug 14 21:31:24 2023 +0200
Commit: Hossein 
CommitDate: Sat Nov 4 02:34:56 2023 +0100

tdf#114441 Convert use of sal_uLong to better integer types

Return type of GetColumnFormat() is changed to sal_uInt32. All the
values from the function calls inside GetCloumnFormat() which were
involved in the return value seem to be positive right now.

Change-Id: Id19b2982d8372e10fee5fc0fd4233576076ec3df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155680
Tested-by: Hossein 
Reviewed-by: Hossein 

diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index b0d4b756917d..4c6a0c1e7499 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -325,13 +325,13 @@ public:
 css::uno::Reference< css::sdbc::XConnection> const 
& xConnection,
 const OUString& rTableName);
 
-static sal_uLong GetColumnFormat( css::uno::Reference< 
css::sdbc::XDataSource> const & xSource,
+static sal_uInt32 GetColumnFormat( css::uno::Reference< 
css::sdbc::XDataSource> const & xSource,
 css::uno::Reference< css::sdbc::XConnection> const 
& xConnection,
 css::uno::Reference< css::beans::XPropertySet> 
const & xColumn,
 SvNumberFormatter* pNFormatr,
 LanguageType nLanguage );
 
-sal_uLong GetColumnFormat( const OUString& rDBName,
+sal_uInt32 GetColumnFormat( const OUString& rDBName,
 const OUString& rTableName,
 const OUString& rColNm,
 SvNumberFormatter* pNFormatr,
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 0cc225e0c3de..bb4cdc12cdbe 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -591,7 +591,7 @@ void SwDBManager::ImportFromConnection(  SwWrtShell* pSh )
 std::optional oWait;
 
 {
-sal_uLong i = 0;
+sal_uInt32 i = 0;
 do {
 
 ImportDBEntry(pSh);
@@ -1670,13 +1670,13 @@ void SwDBManager::MergeCancel()
 
 // determine the column's Numberformat and transfer to the forwarded Formatter,
 // if applicable.
-sal_uLong SwDBManager::GetColumnFormat( const OUString& rDBName,
+sal_uInt32 SwDBManager::GetColumnFormat( const OUString& rDBName,
 const OUString& rTableName,
 const OUString& rColNm,
 SvNumberFormatter* pNFormatr,
 LanguageType nLanguage )
 {
-sal_uLong nRet = 0;
+sal_uInt32 nRet = 0;
 if(pNFormatr)
 {
 uno::Reference< sdbc::XDataSource> xSource;
@@ -1750,7 +1750,7 @@ sal_uLong SwDBManager::GetColumnFormat( const OUString& 
rDBName,
 return nRet;
 }
 
-sal_uLong SwDBManager::GetColumnFormat( uno::Reference< sdbc::XDataSource> 
const & xSource_in,
+sal_uInt32 SwDBManager::GetColumnFormat( uno::Reference< sdbc::XDataSource> 
const & xSource_in,
 uno::Reference< sdbc::XConnection> const & xConnection,
 uno::Reference< beans::XPropertySet> const & xColumn,
 SvNumberFormatter* pNFormatr,
@@ -1759,7 +1759,7 @@ sal_uLong SwDBManager::GetColumnFormat( uno::Reference< 
sdbc::XDataSource> const
 auto xSource = xSource_in;
 
 // set the NumberFormat in the doc if applicable
-sal_uLong nRet = 0;
+sal_uInt32 nRet = 0;
 
 if(!xSource.is())
 {
@@ -1813,6 +1813,7 @@ sal_uLong SwDBManager::GetColumnFormat( uno::Reference< 
sdbc::XDataSource> const
 nFormat = xDocNumberFormats->queryKey( sFormat, aLoc, 
false );
 if(NUMBERFORMAT_ENTRY_NOT_FOUND == 
sal::static_int_cast< sal_uInt32, sal_Int32>(nFormat))
 nFormat = xDocNumberFormats->addNew( sFormat, aLoc 
);
+
 nRet = nFormat;
 bUseDefault = false;
 }


[Libreoffice-commits] core.git: sw/inc sw/source

2023-11-02 Thread Michael Stahl (via logerrit)
 sw/inc/EnhancedPDFExportHelper.hxx  |1 +
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   14 ++
 sw/source/core/text/itrpaint.cxx|2 ++
 3 files changed, 17 insertions(+)

New commits:
commit a71da3b7a80ca32b595a8ca0ea3da650b0af376c
Author: Michael Stahl 
AuthorDate: Wed Nov 1 20:31:44 2023 +0100
Commit: Michael Stahl 
CommitDate: Thu Nov 2 11:53:42 2023 +0100

tdf#156565 sw: PDF/UA export: split Link SE at line break

There must be one Link SE per Link Annotation, so ensure that a new one
is created for a new line.

(regression from commit 4c5283a3a11008a06a995c49ed34dc1f6066)

Change-Id: I2585d9e22a435d7716f48fec89a78149c129f71d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158775
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx 
b/sw/inc/EnhancedPDFExportHelper.hxx
index be3c45383061..6b2e2655ea43 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -183,6 +183,7 @@ class SwTaggedPDFHelper
 ~SwTaggedPDFHelper();
 
 static bool IsExportTaggedPDF( const OutputDevice& rOut );
+static void EndCurrentLink(OutputDevice const&);
 };
 
 /*
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index e224d33901a4..48c938264994 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1698,6 +1698,20 @@ void SwTaggedPDFHelper::EndStructureElements()
 CheckRestoreTag();
 }
 
+void SwTaggedPDFHelper::EndCurrentLink(OutputDevice const& rOut)
+{
+vcl::PDFExtOutDevData *const pPDFExtOutDevData(
+dynamic_cast(rOut.GetExtOutDevData()));
+if (pPDFExtOutDevData && 
pPDFExtOutDevData->GetSwPDFState()->m_oCurrentLink)
+{
+pPDFExtOutDevData->GetSwPDFState()->m_oCurrentLink.reset();
+pPDFExtOutDevData->EndStructureElement();
+#if OSL_DEBUG_LEVEL > 1
+aStructStack.pop_back();
+#endif
+}
+}
+
 void SwTaggedPDFHelper::EndCurrentAll()
 {
 if (mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan)
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 4f0d412f2597..5b6bb1288d57 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -162,6 +162,8 @@ void SwTextPainter::DrawTextLine( const SwRect , 
SwSaveClip ,
 roTaggedParagraph.emplace(nullptr, , nullptr, 
*GetInfo().GetOut());
 }
 
+SwTaggedPDFHelper::EndCurrentLink(*GetInfo().GetOut());
+
 // Optimization!
 SwTwips nMaxRight = std::min( rPaint.Right(), Right() );
 const SwTwips nTmpLeft = GetInfo().X();


[Libreoffice-commits] core.git: sw/inc sw/source

2023-10-30 Thread Skyler Grey (via logerrit)
 sw/inc/numrule.hxx   |4 -
 sw/inc/reffld.hxx|5 -
 sw/source/core/doc/number.cxx|  121 ++-
 sw/source/core/fields/reffld.cxx |   44 +++---
 sw/source/core/txtnode/ndtxt.cxx |1 
 sw/source/ui/fldui/fldref.cxx|   48 +--
 sw/source/ui/fldui/fldref.hxx|1 
 7 files changed, 152 insertions(+), 72 deletions(-)

New commits:
commit 2ddd1378fc232fbc1d5162f2c44ecf71c6725732
Author: Skyler Grey 
AuthorDate: Tue Oct 24 16:22:30 2023 +
Commit: Caolán McNamara 
CommitDate: Mon Oct 30 20:10:27 2023 +0100

Improve HIDE_NON_NUMERICAL compatibility with Word

The previous implementation of REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL had
some major incompatibilites with Word. In particular, it stripped
letters even if they were included in the "numbering" system.

This commit fixes a lot of the flaws in the previous implementation, so
it's now a lot closer to Word.

Change-Id: Ifaa67fbc2d53b0d4fb85e7305b2dbdf78cf0a1ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158451
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx
index f642e21e746c..b21cc5259656 100644
--- a/sw/inc/numrule.hxx
+++ b/sw/inc/numrule.hxx
@@ -169,11 +169,13 @@ public:
 OUString MakeNumString( const SwNumberTree::tNumberVector & rNumVector,
   const bool bInclStrings = true,
   const unsigned int _nRestrictToThisLevel = MAXLEVEL,
+  const bool bHideNonNumerical = false,
   Extremities* pExtremities = nullptr,
   LanguageType nLang = LANGUAGE_SYSTEM) const;
 OUString MakeRefNumString( const SwNodeNum& rNodeNum,
  const bool bInclSuperiorNumLabels,
- const int nRestrictInclToThisLevel ) const;
+ const int nRestrictInclToThisLevel,
+ const bool bHideNonNumerical ) const;
 OUString MakeParagraphStyleListString() const;
 
 /** @return list of associated text nodes */
diff --git a/sw/inc/reffld.hxx b/sw/inc/reffld.hxx
index 3c1e3c63b5e6..b65e8c209633 100644
--- a/sw/inc/reffld.hxx
+++ b/sw/inc/reffld.hxx
@@ -117,11 +117,6 @@ private:
 
 virtual OUStringExpandImpl(SwRootFrame const* pLayout) const override;
 virtual std::unique_ptr Copy() const override;
-
-/// Strip out text that is not either a number or a delimiter. Used in 
STYLEREF for when you
-/// have chapters labelled "Chapter X.Y" and want to just keep the "X.Y". 
Distinct from
-/// GetExpandedTextOfReferencedTextNode so you can run it after any other 
processing
-void StylerefStripNonnumerical(OUString& rText) const;
 public:
 SwGetRefField( SwGetRefFieldType*, OUString aSetRef, OUString 
aReferenceLanguage,
 sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uInt16 nFlags, 
sal_uLong nFormat );
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 3ab36c63c160..d2cb98924e0f 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -648,9 +648,51 @@ OUString SwNumRule::MakeNumString( const SwNodeNum& rNum, 
bool bInclStrings ) co
 return OUString();
 }
 
+namespace {
+/// Strip out text that is not a delimiter. Used in STYLEREF for when you
+/// have chapters labelled "Chapter X.Y" and want to just keep the "X.Y"
+/// Only used on the prefix/infix/suffix, so the numbers are not modified
+void StripNonDelimiter(OUString& rText)
+{
+std::vector charactersToKeep;
+
+for (int i = 0; i < rText.getLength(); i++) {
+auto character = rText[i];
+
+ // tdf#86790# for Word compatibility: I haven't found any better way 
to determine whether a
+ // character is a delimiter than testing in Word and listing them 
out. Furthermore, I haven't
+ // found a list so I can't be certain this is the complete set- if 
there's a compatibility issue
+ // with this in the future, here's the first place to look...
+if (
+character == '.'
+|| character == ','
+|| character == ':'
+|| character == ';'
+|| character == '-'
+|| character == '('
+|| character == ')'
+|| character == '['
+|| character == ']'
+|| character == '{'
+|| character == '}'
+|| character == '/'
+|| character == '\\'
+|| character == '|'
+)
+charactersToKeep.push_back(character);
+}
+
+if (charactersToKeep.size())
+rText = OUString(charactersToKeep.data(), charactersToKeep.size());
+else
+rText = OUString();
+}
+}
+
 OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & 
rNumVector,
   

[Libreoffice-commits] core.git: sw/inc sw/source

2023-10-30 Thread Skyler Grey (via logerrit)
 sw/inc/reffld.hxx|1 
 sw/source/core/doc/DocumentFieldsManager.cxx |5 
 sw/source/core/fields/reffld.cxx |   29 ++-
 3 files changed, 34 insertions(+), 1 deletion(-)

New commits:
commit 15972993ff6e106a02954125269612179e1f33aa
Author: Skyler Grey 
AuthorDate: Mon Oct 23 16:17:17 2023 +
Commit: Caolán McNamara 
CommitDate: Mon Oct 30 20:08:56 2023 +0100

Fix incorrect marginal STYLEREF content in docx

STYLEREF fields were previously not importing with the correct content
when loading a docx document. This is because they were not updating
when the document had finished loading- only partway through, and where
a STYLEREF field is in relation to everything else in the document can
change its content.

This commit fixes that issue by adding STYLEREF fields to be refreshed
whenever other fields that can change based on pages (e.g. page number)
fields are updated. I suspect this could lead to double updates in some
cases where both reference and page fields are being updated. I consider
this a relatively minor issue in comparison to incorrect field content
when specific documents are loaded, but a followup could be made
improving this.

This commit also fixes a minor typo in reffld.cxx where m_sText is
always the filtered text when updating fields, even if we are updating
m_sTextRLHidden instead.

Change-Id: Iecd3e83a6bd3f8c2c6adba5c7eba9ee55b773510
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158450
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/reffld.hxx b/sw/inc/reffld.hxx
index 293b913c406b..3c1e3c63b5e6 100644
--- a/sw/inc/reffld.hxx
+++ b/sw/inc/reffld.hxx
@@ -100,6 +100,7 @@ public:
 SwRootFrame const* pLayout = nullptr,
 SwTextNode* pSelf = nullptr, SwFrame* 
pFrame = nullptr);
 void UpdateGetReferences();
+void UpdateStyleReferences();
 };
 
 class SW_DLLPUBLIC SwGetRefField final : public SwField
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx 
b/sw/source/core/doc/DocumentFieldsManager.cxx
index c8703e7f06ef..a7be3bb96394 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -1292,6 +1292,11 @@ void DocumentFieldsManager::UpdatePageFields(const 
SwTwips nDocPos)
 case SwFieldIds::DocStat:
 pFieldType->CallSwClientNotify(sw::LegacyModifyHint(nullptr, 
nullptr));
 break;
+case SwFieldIds::GetRef:
+
static_cast(pFieldType)->UpdateStyleReferences();
+// Style references can vary across different pages (e.g. in 
header/footer)
+// so they must be updated when page fields are
+break;
 default: break;
 }
 }
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 638baf0a5474..ee7791a68753 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -706,7 +706,7 @@ void SwGetRefField::UpdateField(const SwTextField* 
pFieldTextAttr, SwFrame* pFra
 rText = pTextNd->GetExpandText(pLayout, nStart, nEnd - 
nStart, false, false,
false, ExpandMode(0));
 }
-FilterText(m_sText, GetLanguage(), m_sSetReferenceLanguage);
+FilterText(rText, GetLanguage(), m_sSetReferenceLanguage);
 }
 }
 break;
@@ -1167,6 +1167,33 @@ void SwGetRefFieldType::UpdateGetReferences()
 CallSwClientNotify(sw::LegacyModifyHint(nullptr, nullptr));
 }
 
+void SwGetRefFieldType::UpdateStyleReferences()
+{
+std::vector vFields;
+GatherFields(vFields, false);
+bool bModified = false;
+for(auto pFormatField: vFields)
+{
+// update only the GetRef fields which are also STYLEREF fields
+SwGetRefField* pGRef = 
static_cast(pFormatField->GetField());
+
+if (pGRef->GetSubType() != REF_STYLE) continue;
+
+const SwTextField* pTField;
+if(!pGRef->GetLanguage() &&
+nullptr != (pTField = pFormatField->GetTextField()) &&
+pTField->GetpTextNode())
+{
+
pGRef->SetLanguage(pTField->GetpTextNode()->GetLang(pTField->GetStart()));
+}
+
+pGRef->UpdateField(pFormatField->GetTextField(), nullptr);
+bModified = true;
+}
+if (bModified)
+CallSwClientNotify(sw::LegacyModifyHint(nullptr, nullptr));
+}
+
 void SwGetRefFieldType::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
 if (rHint.GetId() != SfxHintId::SwLegacyModify)


[Libreoffice-commits] core.git: sw/inc sw/source

2023-10-29 Thread Attila Szűcs (via logerrit)
 sw/inc/IDocumentRedlineAccess.hxx |3 +-
 sw/source/core/doc/DocumentRedlineManager.cxx |   33 +-
 sw/source/core/doc/docnum.cxx |2 -
 sw/source/core/inc/DocumentRedlineManager.hxx |5 +++
 4 files changed, 39 insertions(+), 4 deletions(-)

New commits:
commit b40e469887d973e1eea242749a90c3c2370da3a5
Author: Attila Szűcs 
AuthorDate: Thu Oct 26 01:51:40 2023 +0200
Commit: Caolán McNamara 
CommitDate: Mon Oct 30 01:55:54 2023 +0100

tdf#157663 SW: fix redline continueing a move

Subsequent moves generated new MoveID's, like if they were separete moves.
That cause moves to forgot their other parts.

Now, if we move a redline that was moved by us it will re-use its moveID
as if it was just the continue of the previous movement.
It does not work if we move more then 1 of our own movement redlines

Note: There are complex cases what it cannot handle.. in those case it
just use the new ID, so the newly moved part, will forgot its relation
with the old move oroginal parts.
Complex case is like.. if we move 2 of our own move redlines,
that means there will be 2 MoveId we would want to continue, but only 1
insert redline to write that MoveID.
But as long as we moved only 1 of our redlines it will work, even if
there are more text redlines, even move redlines of other author.
Other move redlines will be separate move anyway.

Note2: In complex cases, we may could connect movements.
Or we could split the new inserted move part.
but those are design questions, they may be not good idea..
and the split one is probably more work to implement.

Change-Id: Icb2adf43272181c6a63a4a84750352f4b163383a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158473
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158615
Tested-by: Jenkins

diff --git a/sw/inc/IDocumentRedlineAccess.hxx 
b/sw/inc/IDocumentRedlineAccess.hxx
index 6e28f1340deb..9d97eb43ff7e 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -147,7 +147,8 @@ public:
 MERGED if pNewRedl was deleted but has been merged with existing 
one
 IGNORED if pNewRedl was deleted and ignored/invalid
 */
-virtual AppendResult AppendRedline(/*[in]*/SwRangeRedline* pNewRedl, 
/*[in]*/bool bCallDelete) = 0;
+virtual AppendResult AppendRedline(/*[in]*/ SwRangeRedline* pNewRedl, 
/*[in]*/ bool bCallDelete,
+   /*[in]*/ sal_uInt32 nMoveIDToDelete = 
0) = 0;
 
 virtual bool AppendTableRowRedline(/*[in]*/SwTableRowRedline* pPtr) = 0;
 virtual bool AppendTableCellRedline(/*[in]*/SwTableCellRedline* pPtr) = 0;
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index 468449ecfbe9..8d52c814e81a 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -1309,7 +1309,8 @@ Behaviour of Delete-Redline:
   the Delete
 */
 IDocumentRedlineAccess::AppendResult
-DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const 
bCallDelete)
+DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const 
bCallDelete,
+  sal_uInt32 nMoveIDToDelete)
 {
 CHECK_REDLINE( *this )
 
@@ -1330,6 +1331,9 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* 
pNewRedl, bool const bCall
 return AppendResult::IGNORED;
 }
 
+// Collect MoveID's of the redlines we delete.
+// If there is only 1, then we should use its ID. (continuing the move)
+std::set deletedMoveIDs;
 
 bool bMerged = false;
 
@@ -1807,6 +1811,16 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* 
pNewRedl, bool const bCall
 // and anonymized insertion, i.e. with the same dummy 
timestamp
 !pRedl->GetRedlineData(0).IsAnonymized() )
 {
+// Collect MoveID's of the redlines we delete.
+if (nMoveIDToDelete > 1 && maRedlineTable[n]->GetMoved() > 0
+&& (eCmpPos == SwComparePosition::Equal
+|| eCmpPos == SwComparePosition::Inside
+|| eCmpPos == SwComparePosition::Outside
+|| eCmpPos == SwComparePosition::OverlapBefore
+|| eCmpPos == SwComparePosition::OverlapBehind))
+{
+deletedMoveIDs.insert(maRedlineTable[n]->GetMoved());
+}
 
 // Set to NONE, so that the Delete::Redo merges the 
Redline data correctly!
 // The ShowMode needs to be retained!
@@ -2421,6 +2435,23 @@ 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-10-29 Thread Attila Szűcs (via logerrit)
 sw/inc/IDocumentRedlineAccess.hxx   |9 ++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |9 ++
 sw/source/core/doc/DocumentRedlineManager.cxx   |   53 +++-
 sw/source/core/inc/DocumentRedlineManager.hxx   |   10 +++
 4 files changed, 78 insertions(+), 3 deletions(-)

New commits:
commit 5e726afaf08c8cc59124d9551bb083220a38821e
Author: Attila Szűcs 
AuthorDate: Wed Oct 25 12:46:10 2023 +0200
Commit: Caolán McNamara 
CommitDate: Mon Oct 30 00:39:30 2023 +0100

SW: fixed redline SwPosition update problem

When nodes are removed, SwPosition nNode is updated,
but its nContent is not.
If nNode change from a non-ContentNodo to a ContentNode, then it is
a problem, as nContent 's m_pContentNode remains nullptr, so the
Position seems to be inconsistent.

Now when redline remove nodes, it check what redlines may effected it,
and update them after the node deletion happened.

Probably this bug should be handled deeper, as this problem probably
effect every SwPosition.. not sure if it can be a problem elsewhere.

A special case when it happens, if there is a Table between 2 text.
And there are 2 redlines..
1: any redline positioned 'text start'-'table start'
2: delete redline: 'table begin'-'table end'
now if we accept the 2. redline .. that remove the table
the 1. redline position will change to: 'text start'-'next text start'
but its end's nContent.m_pContentNode remain nullptr
so lcl_CheckPosition(...) will assert

Change-Id: I2981fd0218a375994d3f55cb5d3463b17ca35849
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158456
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158614
Tested-by: Jenkins

diff --git a/sw/inc/IDocumentRedlineAccess.hxx 
b/sw/inc/IDocumentRedlineAccess.hxx
index c2b71aa1005a..6e28f1340deb 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -168,6 +168,11 @@ public:
 /*[in]*/const SwNode& rNode,
 /*[in]*/RedlineType nType) const = 0;
 
+virtual SwRedlineTable::size_type GetRedlineEndPos(
+/*[in]*/ SwRedlineTable::size_type nStartPos,
+/*[in]*/ const SwNode& rNode,
+/*[in]*/ RedlineType nType) const = 0;
+
 virtual bool HasRedline(
 /*[in]*/const SwPaM& rPam,
 /*[in]*/RedlineType nType,
@@ -226,6 +231,10 @@ public:
 virtual void SetRedlinePassword(
 /*[in]*/const css::uno::Sequence & rNewPassword) = 0;
 
+virtual void UpdateRedlineContentNode(/*[in]*/ SwRedlineTable::size_type 
nStartPos,
+  /*[in]*/ SwRedlineTable::size_type 
nEndPos) const = 0;
+
+
 protected:
  virtual ~IDocumentRedlineAccess() {};
 };
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 60f9d1b96890..3f4c99a8f487 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2142,8 +2142,17 @@ void DocumentContentOperationsManager::DeleteDummyChar(
 
 void DocumentContentOperationsManager::DeleteRange( SwPaM & rPam )
 {
+// Seek all redlines that are in that PaM to be deleted..
+SwRedlineTable::size_type nRedlStart = 
m_rDoc.getIDocumentRedlineAccess().GetRedlinePos(
+rPam.Start()->GetNode(), RedlineType::Any);
+SwRedlineTable::size_type nRedlEnd = 
m_rDoc.getIDocumentRedlineAccess().GetRedlineEndPos(
+nRedlStart, rPam.End()->GetNode(), RedlineType::Any);
+
 lcl_DoWithBreaks(*this, rPam, SwDeleteFlags::Default, 
::DeleteRangeImpl);
 
+// update all redlines was in the Pam that is
+m_rDoc.getIDocumentRedlineAccess().UpdateRedlineContentNode(nRedlStart, 
nRedlEnd);
+
 if (!m_rDoc.getIDocumentRedlineAccess().IsIgnoreRedline()
 && !m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty())
 {
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index b09ad5bedcaa..468449ecfbe9 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -54,9 +54,8 @@ using namespace com::sun::star;
 // 2. check that position is valid and doesn't point after text
 void lcl_CheckPosition( const SwPosition* pPos )
 {
-// Commented out because of a random problem, that happened even 
before my patch
-//assert(dynamic_cast(>GetNode())
-//== pPos->GetContentNode());
+assert(dynamic_cast(>GetNode())
+== pPos->GetContentNode());
 
 SwTextNode* pTextNode = pPos->GetNode().GetTextNode();
 if( pTextNode == nullptr )
@@ -2801,6 +2800,54 @@ SwRedlineTable::size_type 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-10-25 Thread Mike Kaganski (via logerrit)
 sw/inc/fldbas.hxx|5 +
 sw/source/core/fields/fldbas.cxx |   10 --
 2 files changed, 1 insertion(+), 14 deletions(-)

New commits:
commit 6448c83a8740711172b3c59175a2abd15c00114b
Author: Mike Kaganski 
AuthorDate: Wed Oct 25 09:59:51 2023 +0200
Commit: Mike Kaganski 
CommitDate: Wed Oct 25 11:42:13 2023 +0200

DBG_UTIL implementation differs only by never-wrong assert

Change-Id: Ifb879d6536c80f00da61707fb0aa0700dcd19bcc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158288
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 4aa874c3021d..7518c47582f3 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -349,13 +349,10 @@ public:
 
 /// ResId
 SwFieldIds  Which() const
-#ifdef DBG_UTIL
-;   // implemented in fldbas.cxx
-#else
 {
+assert(m_pType);
 return m_pType->Which();
 }
-#endif
 
 // TYP_ID
 SwFieldTypesEnumGetTypeId() const;
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index c528f2a0d65a..b3fab811f1c2 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -257,16 +257,6 @@ SwField::~SwField()
 {
 }
 
-// instead of indirectly via the type
-
-#ifdef DBG_UTIL
-SwFieldIds SwField::Which() const
-{
-assert(m_pType);
-return m_pType->Which();
-}
-#endif
-
 SwFieldTypesEnum SwField::GetTypeId() const
 {
 


[Libreoffice-commits] core.git: sw/inc sw/source vcl/qa

2023-10-24 Thread Michael Stahl (via logerrit)
 sw/inc/EnhancedPDFExportHelper.hxx  |3 
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   49 ++-
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |  102 ++--
 3 files changed, 141 insertions(+), 13 deletions(-)

New commits:
commit 4c5283a3a11008a06a995c49ed34dc1f6066
Author: Michael Stahl 
AuthorDate: Tue Oct 24 13:51:39 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue Oct 24 16:44:45 2023 +0200

tdf#156565 sw: PDF/UA export: only one Link ILSE per link

The problem is that for a hyperlink, multiple Link SEs are created, but
only one Link annotation; the Link SEs all point to the annotation but
the annotation can only point to one Link SE.

So try to create only one Link SE for a hyperlink, similar to commit
ee3c3fcf5c48964f7bc1d64484409f072c614866.  This could be
further subdivided by Spans when formatting properties change but it
looks complicated and rarely needed.

Change-Id: I7d158b599ec744b03e78eeca88d717183f2ba1dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158387
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx 
b/sw/inc/EnhancedPDFExportHelper.hxx
index 1ab0f8868af4..542138157d2f 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -39,6 +39,7 @@ class SwPrintData;
 class SwTextPainter;
 class SwEditShell;
 class StringRangeEnumerator;
+class SwTextAttr;
 class SwTextNode;
 class SwTable;
 class SwNumberTreeNode;
@@ -161,7 +162,7 @@ class SwTaggedPDFHelper
 
 void EndCurrentSpan();
 void CreateCurrentSpan(SwTextPaintInfo const& rInf, OUString const& 
rStyleName);
-bool CheckContinueSpan(SwTextPaintInfo const& rInf, std::u16string_view 
rStyleName);
+bool CheckContinueSpan(SwTextPaintInfo const& rInf, std::u16string_view 
rStyleName, SwTextAttr const* pInetFormatAttr);
 
 bool CheckReopenTag();
 void CheckRestoreTag() const;
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index ff47a693769f..999e599b4478 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -156,6 +156,7 @@ struct SwEnhancedPDFState
 };
 
 ::std::optional m_oCurrentSpan;
+::std::optional m_oCurrentLink;
 
 SwEnhancedPDFState(LanguageType const eLanguageDefault)
 : m_eLanguageDefault(eLanguageDefault)
@@ -1597,13 +1598,18 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
 
 void SwTaggedPDFHelper::EndStructureElements()
 {
-if (mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan)
+if (mpFrameInfo != nullptr)
 {
-if (mpFrameInfo != nullptr)
+if (mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan)
 {   // close span at end of paragraph
 mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan.reset();
 ++m_nEndStructureElement;
 }
+if (mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentLink)
+{   // close link at end of paragraph
+mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentLink.reset();
+++m_nEndStructureElement;
+}
 }
 
 while ( m_nEndStructureElement > 0 )
@@ -1640,8 +1646,32 @@ void SwTaggedPDFHelper::CreateCurrentSpan(
 }
 
 bool SwTaggedPDFHelper::CheckContinueSpan(
-SwTextPaintInfo const& rInf, std::u16string_view const rStyleName)
+SwTextPaintInfo const& rInf, std::u16string_view const rStyleName,
+SwTextAttr const*const pInetFormatAttr)
 {
+// for now, don't create span inside of link - this should be very rare
+// situation and it looks complicated to implement.
+assert(!mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan
+|| !mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentLink);
+if (mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentLink)
+{
+if (pInetFormatAttr && pInetFormatAttr == 
*mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentLink)
+{
+return true;
+}
+else
+{
+mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentLink.reset();
+EndTag();
+return false;
+}
+}
+if (mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan && pInetFormatAttr)
+{
+EndCurrentSpan();
+return false;
+}
+
 if (!mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan)
 return false;
 
@@ -1691,7 +1721,7 @@ void SwTaggedPDFHelper::BeginInlineStructureElements()
 }
 
 // note: ILSE may be nested, so only end the span if needed to start new 
one
-bool const isContinueSpan(CheckContinueSpan(rInf, sStyleName));
+bool const isContinueSpan(CheckContinueSpan(rInf, sStyleName, 
pInetFormatAttr));
 
 sal_uInt16 nPDFType = USHRT_MAX;
 OUString aPDFType;
@@ -1714,8 +1744,15 @@ void SwTaggedPDFHelper::BeginInlineStructureElements()
 // 

[Libreoffice-commits] core.git: sw/inc sw/source writerfilter/source

2023-10-20 Thread Miklos Vajna (via logerrit)
 sw/inc/IDocumentSettingAccess.hxx |1 -
 sw/source/core/doc/DocumentSettingManager.cxx |   11 ---
 sw/source/core/inc/DocumentSettingManager.hxx |1 -
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   13 -
 writerfilter/source/filter/WriterFilter.cxx   |1 -
 5 files changed, 27 deletions(-)

New commits:
commit 5e7f7917fd589f661982d481a45bf84337e4c03c
Author: Miklos Vajna 
AuthorDate: Fri Oct 20 12:12:44 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Oct 20 14:15:20 2023 +0200

sw floattable: remove now unused FloattableNomargins compat flag

This was noop since commit 626fe9ab5ebebc4ef36e35f4aa597c03a3564d22
(tdf#157573 sw floattable: fix incorrect lack of left margin after
table, 2023-10-18).

Change-Id: I89a197313ac4ffbcff9bbff534e5411085282ac8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158237
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index b8077ea9ad56..b8088440163d 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -106,7 +106,6 @@ enum class DocumentSettingId
 KERN_ASIAN_PUNCTUATION,
 MATH_BASELINE_ALIGNMENT,
 STYLES_NODEFAULT,
-FLOATTABLE_NOMARGINS,
 EMBED_FONTS,
 EMBED_USED_FONTS,
 EMBED_LATIN_SCRIPT_FONTS,
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index 86aa3ede7e81..ebe116c68276 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -62,7 +62,6 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
)
 mbUseHiResolutionVirtualDevice(true),
 mbMathBaselineAlignment(false), // default for *old* documents is 'off'
 mbStylesNoDefault(false),
-mbFloattableNomargins(false),
 mEmbedFonts(false),
 mEmbedUsedFonts(false),
 mEmbedLatinScriptFonts(true),
@@ -230,7 +229,6 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
 case DocumentSettingId::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: return 
mbDoNotResetParaAttrsForNumFont;
 case DocumentSettingId::MATH_BASELINE_ALIGNMENT: return 
mbMathBaselineAlignment;
 case DocumentSettingId::STYLES_NODEFAULT: return mbStylesNoDefault;
-case DocumentSettingId::FLOATTABLE_NOMARGINS: return 
mbFloattableNomargins;
 case DocumentSettingId::EMBED_FONTS: return mEmbedFonts;
 case DocumentSettingId::EMBED_USED_FONTS: return mEmbedUsedFonts;
 case DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS: return 
mEmbedLatinScriptFonts;
@@ -509,9 +507,6 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
 case DocumentSettingId::STYLES_NODEFAULT:
 mbStylesNoDefault  = value;
 break;
-case DocumentSettingId::FLOATTABLE_NOMARGINS:
-mbFloattableNomargins = value;
-break;
 case DocumentSettingId::EMBED_FONTS:
 mEmbedFonts = value;
 break;
@@ -700,7 +695,6 @@ void 
sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
 mbConsiderWrapOnObjPos = rSource.mbConsiderWrapOnObjPos;
 mbMathBaselineAlignment = rSource.mbMathBaselineAlignment;
 mbStylesNoDefault = rSource.mbStylesNoDefault;
-mbFloattableNomargins = rSource.mbFloattableNomargins;
 mbOldNumbering = rSource.mbOldNumbering;
 mbIgnoreFirstLineIndentInNumbering = 
rSource.mbIgnoreFirstLineIndentInNumbering;
 mbDoNotJustifyLinesWithManualBreak = 
rSource.mbDoNotJustifyLinesWithManualBreak;
@@ -875,11 +869,6 @@ void 
sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
 
BAD_CAST(OString::boolean(mbStylesNoDefault).getStr()));
 (void)xmlTextWriterEndElement(pWriter);
 
-(void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("mbFloattableNomargins"));
-(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
-
BAD_CAST(OString::boolean(mbFloattableNomargins).getStr()));
-(void)xmlTextWriterEndElement(pWriter);
-
 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbOldNumbering"));
 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
 
BAD_CAST(OString::boolean(mbOldNumbering).getStr()));
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 
b/sw/source/core/inc/DocumentSettingManager.hxx
index 34b26c476e28..284dccf9cf37 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -122,7 +122,6 @@ class DocumentSettingManager final :
 // attribute 
'WrapInfluenceOnObjPos'.
 bool mbMathBaselineAlignment: 1;// TL  2010-10-29 #i972#
 bool mbStylesNoDefault  : 1;
-bool 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-10-14 Thread EMartinGube (via logerrit)
 sw/inc/editsh.hxx   |4 +++
 sw/source/core/edit/eddel.cxx   |   46 
 sw/source/core/edit/edlingu.cxx |   15 ---
 sw/source/uibase/shells/textsh1.cxx |   23 ++
 4 files changed, 54 insertions(+), 34 deletions(-)

New commits:
commit 6da9d629f7f17ec569e7fb6d0f1931dd410b1d28
Author: EMartinGube 
AuthorDate: Thu Jul 20 23:33:37 2023 +0200
Commit: Mike Kaganski 
CommitDate: Sun Oct 15 07:42:07 2023 +0200

tdf#156250: sw: Keep comments when spell correction replaces a word

New method SwEditShell:ReplaceKeepComments for comment preserving
spell correction.

Change-Id: Ifdb9d5664ab8d457a16ad8f7ec62dd968c89d580
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154761
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 8fc1afb9483a..a3b181440237 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -172,6 +172,10 @@ public:
--> "xx\t..zzz..&" */
 bool Replace( const OUString& rNewStr, bool bRegExpRplc );
 
+/** Replace a selected range in a TextNode by given string.
+ Possible comments will be kept (moved to the end of the selection). */
+bool ReplaceKeepComments( const OUString& rNewStr);
+
 /** Delete content of all ranges.
  If whole nodes are selected, these nodes get deleted. */
 bool Delete(bool isArtificialSelection = false);
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 10d086bbac63..989cddfd3a28 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -359,6 +359,52 @@ bool SwEditShell::Replace( const OUString& rNewStr, bool 
bRegExpRplc )
 return bRet;
 }
 
+/** Replace a selected area in a text node with a given string.
+ *
+ * Method to replace a text selection with a new string while
+ * keeping possible comments (they will be moved to the end
+ * of the selection).
+ *
+ * @param rNewStr the new string which the selected area is to be replaced 
with
+ * @returntrue, if something has been replaced, false otherwise.
+ */
+bool SwEditShell::ReplaceKeepComments( const OUString& rNewStr)
+{
+bool bRet   = false;
+SwPaM *pCursor  = GetCursor();
+
+if(pCursor != nullptr)
+{
+// go sure that the text selection pointed to by pCursor is valid
+if(pCursor->HasMark())
+{
+// preserve comments inside of the number by deleting number 
portions starting from the back
+OUString aSelectedText = pCursor->GetText();
+sal_Int32 nCommentPos(aSelectedText.lastIndexOf(CH_TXTATR_INWORD));
+// go sure that we have a valid selection and a comment has been 
found
+while((nCommentPos > -1) && (aSelectedText.getLength() > 0) && 
(pCursor->HasMark()))
+{
+// select the part of the text after the last found comment
+// selection start:
+pCursor->GetPoint()->AdjustContent(nCommentPos + 1);
+// selection end ist left where it is -> will be adjusted 
later on
+// delete the part of the word after the last found comment
+Replace(OUString(), false);
+// put the selection start back to the beginning of the word
+pCursor->GetPoint()->AdjustContent(-(nCommentPos + 1));
+// adjust the selection end, so that the last comment is no 
longer selected:
+pCursor->GetMark()->AdjustContent(-1);
+// search for the next possible comment
+aSelectedText = pCursor->GetText();
+nCommentPos = aSelectedText.lastIndexOf(CH_TXTATR_INWORD);
+}
+bRet = Replace(rNewStr, false);
+}
+}
+
+return bRet;
+}
+
 /// special method for JOE's wizards
 bool SwEditShell::DelFullPara()
 {
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index ab89fc5b7241..63ea37ba8233 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -1167,20 +1167,7 @@ void SwEditShell::ApplyChangedSentence(const 
svx::SpellPortions& rNewPortions, b
 
 // if there is a comment inside the original word, don't 
delete it:
 // but keep it at the end of the replacement
-// TODO: keep all the comments with a recursive function
-sal_Int32 
nCommentPos(pCursor->GetText().indexOf(OUStringChar(CH_TXTATR_INWORD)));
-if ( nCommentPos > -1 )
-{
-// delete the original word after the comment
-pCursor->GetPoint()->AdjustContent(nCommentPos + 1);
-
-
mxDoc->getIDocumentContentOperations().ReplaceRange(*pCursor, OUString(), 
false);
-// and select only the remaining part before the comment
-

[Libreoffice-commits] core.git: sw/inc sw/source

2023-10-02 Thread Jim Raykowski (via logerrit)
 sw/inc/view.hxx  |   16 
 sw/source/core/access/AccessibilityIssue.cxx |   86 ++
 sw/source/uibase/uiview/view.cxx |  104 ++-
 3 files changed, 205 insertions(+), 1 deletion(-)

New commits:
commit c603d37223d4f7c3594515fb2bbac22015bc146b
Author: Jim Raykowski 
AuthorDate: Fri Sep 22 16:35:05 2023 -0800
Commit: Jim Raykowski 
CommitDate: Tue Oct 3 06:50:02 2023 +0200

tdf#157370 Bring A11y issue to attention in the document view

when issue is clicked on in the A11y sidebar

Change-Id: I9122e608e88568fa2d91b6cf4616b0f61db8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157200
Tested-by: Jenkins
Reviewed-by: Jim Raykowski 

diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index dee2363dedd9..c6add7e23364 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -32,6 +32,8 @@
 #include "swtypes.hxx"
 #include "shellid.hxx"
 
+#include 
+
 class SwTextFormatColl;
 class SwPageDesc;
 class SwFrameFormat;
@@ -68,6 +70,7 @@ enum class SotExchangeDest;
 class SwCursorShell;
 enum class SvxSearchCmd;
 enum class SelectionType : sal_Int32;
+class SwNode;
 
 namespace com::sun::star::view { class XSelectionSupplier; }
 namespace sfx2 { class FileDialogHelper; }
@@ -716,6 +719,19 @@ public:
 virtual std::optional getLOKPayload(int nType, int nViewId) const 
override;
 
 bool IsHighlightCharDF() { return m_bIsHighlightCharDF; }
+
+private:
+AutoTimer m_aBringToAttentionBlinkTimer;
+size_t m_nBringToAttentionBlinkTimeOutsRemaining;
+
+std::unique_ptr 
m_xBringToAttentionOverlayObject;
+
+DECL_LINK(BringToAttentionBlinkTimerHdl, Timer*, void);
+
+public:
+void BringToAttention(std::vector&& aRanges = {});
+void BringToAttention(const tools::Rectangle& rRect);
+void BringToAttention(const SwNode* pNode);
 };
 
 inline tools::Long SwView::GetXScroll() const
diff --git a/sw/source/core/access/AccessibilityIssue.cxx 
b/sw/source/core/access/AccessibilityIssue.cxx
index 6ec39238cda9..8056408a5b02 100644
--- a/sw/source/core/access/AccessibilityIssue.cxx
+++ b/sw/source/core/access/AccessibilityIssue.cxx
@@ -28,6 +28,11 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
+#include 
+
 namespace sw
 {
 AccessibilityIssue::AccessibilityIssue(sfx::AccessibilityIssueID eIssueID)
@@ -75,6 +80,21 @@ void AccessibilityIssue::gotoIssue() const
 {
 SwWrtShell* pWrtShell = 
TempIssueObject.m_pDoc->GetDocShell()->GetWrtShell();
 bool bSelected = pWrtShell->GotoFly(TempIssueObject.m_sObjectID, 
FLYCNTTYPE_ALL, true);
+
+// bring issue to attention
+if (bSelected)
+{
+if (const SwFlyFrameFormat* pFlyFormat
+= m_pDoc->FindFlyByName(TempIssueObject.m_sObjectID, 
SwNodeType::NONE))
+{
+if (SwFlyFrame* pFlyFrame
+= SwIterator(*pFlyFormat).First())
+{
+
pWrtShell->GetView().BringToAttention(pFlyFrame->getFrameArea().SVRect());
+}
+}
+}
+
 if (bSelected && pWrtShell->IsFrameSelected())
 {
 pWrtShell->HideCursor();
@@ -82,8 +102,19 @@ void AccessibilityIssue::gotoIssue() const
 }
 
 if (!bSelected && TempIssueObject.m_eIssueObject == 
IssueObject::TEXTFRAME)
+{
 pWrtShell->GotoDrawingObject(TempIssueObject.m_sObjectID);
 
+// bring issue to attention
+if (SdrPage* pPage
+= 
pWrtShell->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0))
+{
+if (SdrObject* pObj = 
pPage->GetObjByName(TempIssueObject.m_sObjectID))
+{
+
pWrtShell->GetView().BringToAttention(pObj->GetLogicRect());
+}
+}
+}
 if (comphelper::LibreOfficeKit::isActive())
 pWrtShell->ShowCursor();
 }
@@ -94,6 +125,17 @@ void AccessibilityIssue::gotoIssue() const
 if (pWrtShell->IsFrameSelected())
 pWrtShell->LeaveSelFrameMode();
 pWrtShell->GotoDrawingObject(TempIssueObject.m_sObjectID);
+
+// bring issue to attention
+if (SdrPage* pPage
+= 
pWrtShell->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0))
+{
+if (SdrObject* pObj = 
pPage->GetObjByName(TempIssueObject.m_sObjectID))
+{
+
pWrtShell->GetView().BringToAttention(pObj->GetLogicRect());
+}
+}
+
 if (comphelper::LibreOfficeKit::isActive())
 pWrtShell->ShowCursor();
 }
@@ -107,6 +149,17 @@ void AccessibilityIssue::gotoIssue() const
 if (!bIsDesignMode)
 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-09-27 Thread Noel Grandin (via logerrit)
 sw/inc/swatrset.hxx|1 
 sw/source/core/attr/swatrset.cxx   |8 ++
 sw/source/core/doc/doclay.cxx  |  114 +
 sw/source/core/model/ThemeColorChanger.cxx |   40 +-
 sw/source/ui/dialog/uiregionsw.cxx |   18 ++--
 5 files changed, 93 insertions(+), 88 deletions(-)

New commits:
commit 8eb53f735eba218b6911e7aa5a805972dfb54809
Author: Noel Grandin 
AuthorDate: Wed Sep 27 16:47:13 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Sep 27 19:13:04 2023 +0200

reduce allocation when cloning SwAttrSet

Change-Id: Ic37355cd2a6091576426c48ff694023e24ae6342
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157334
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx
index 64841ade79c9..667121f35327 100644
--- a/sw/inc/swatrset.hxx
+++ b/sw/inc/swatrset.hxx
@@ -183,6 +183,7 @@ public:
 SwAttrSet( const SwAttrSet& );
 
 virtual std::unique_ptr Clone(bool bItems = true, SfxItemPool 
*pToPool = nullptr) const override;
+SwAttrSet CloneAsValue(bool bItems = true) const;
 
 bool Put_BC( const SfxPoolItem& rAttr, SwAttrSet* pOld, SwAttrSet* pNew );
 bool Put_BC( const SfxItemSet& rSet, SwAttrSet* pOld, SwAttrSet* pNew );
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index 7821f9db366d..6d778c1cb6b2 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -222,6 +222,14 @@ std::unique_ptr SwAttrSet::Clone( bool bItems, 
SfxItemPool *pToPool
 : new SwAttrSet( *GetPool(), GetRanges() ));
 }
 
+SwAttrSet SwAttrSet::CloneAsValue( bool bItems ) const
+{
+if (bItems)
+return *this;
+else
+return SwAttrSet( *GetPool(), GetRanges() );
+}
+
 bool SwAttrSet::Put_BC( const SfxPoolItem& rAttr,
SwAttrSet* pOld, SwAttrSet* pNew )
 {
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index b6398ee8ce7f..c9881b848d29 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -741,19 +741,19 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const 
pTextFormatCollTable,
 
 /* #i6447#: Only the selected items are copied from the old
format. */
-std::unique_ptr pNewSet = 
pNewFormat->GetAttrSet().Clone();
+SwAttrSet aNewSet = pNewFormat->GetAttrSet().CloneAsValue();
 
 // Copy only the set attributes.
 // The others should apply from the Templates.
-lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_PRINT );
-lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_OPAQUE );
-lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_PROTECT );
-lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_SURROUND 
);
-lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), 
RES_VERT_ORIENT );
-lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), 
RES_HORI_ORIENT );
-lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_LR_SPACE 
);
-lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_UL_SPACE 
);
-lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), 
RES_BACKGROUND );
+lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_PRINT );
+lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_OPAQUE );
+lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_PROTECT );
+lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_SURROUND );
+lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), 
RES_VERT_ORIENT );
+lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), 
RES_HORI_ORIENT );
+lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_LR_SPACE );
+lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_UL_SPACE );
+lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_BACKGROUND 
);
 if( bCpyBrd )
 {
 // If there's no BoxItem at graphic, but the new Format 
has one, then set the
@@ -761,40 +761,40 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const 
pTextFormatCollTable,
 const SfxPoolItem *pItem;
 if( SfxItemState::SET == pOldFormat->GetAttrSet().
 GetItemState( RES_BOX, true,  ))
-pNewSet->Put( *pItem );
+aNewSet.Put( *pItem );
 else if( SfxItemState::SET == pNewFormat->GetAttrSet().
 GetItemState( RES_BOX ))
-pNewSet->Put( *GetDfltAttr( RES_BOX ) );
+aNewSet.Put( *GetDfltAttr( RES_BOX ) );
 
 if( SfxItemState::SET == pOldFormat->GetAttrSet().
 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-09-27 Thread Noel Grandin (via logerrit)
 sw/inc/istyleaccess.hxx   |5 +++
 sw/inc/node.hxx   |4 +-
 sw/source/core/doc/swstylemanager.cxx |   15 ++
 sw/source/core/docnode/node.cxx   |   50 +-
 4 files changed, 47 insertions(+), 27 deletions(-)

New commits:
commit c2ab40af9efd19d386a486a934986731b7a80d6d
Author: Noel Grandin 
AuthorDate: Wed Sep 27 13:14:49 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Sep 27 14:20:24 2023 +0200

pass SwAttrSet around explicitly

instead of using SfxItemSet and static_cast'ing it everywhere

Change-Id: I12d1a6bd2dec7035fa16206ea01346a3a73c1457
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157309
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/istyleaccess.hxx b/sw/inc/istyleaccess.hxx
index b547d55bac56..755f10bf15d8 100644
--- a/sw/inc/istyleaccess.hxx
+++ b/sw/inc/istyleaccess.hxx
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+class SwAttrSet;
+
 // Management of (automatic) styles
 class IStyleAccess
 {
@@ -40,6 +42,9 @@ public:
 virtual std::shared_ptr getAutomaticStyle( const SfxItemSet& 
rSet,

SwAutoStyleFamily eFamily,
const OUString* 
pParentName = nullptr ) = 0;
+virtual std::shared_ptr getAutomaticStyle( const SwAttrSet& 
rSet,
+   
SwAutoStyleFamily eFamily,
+   const OUString* 
pParentName = nullptr ) = 0;
 virtual void getAllStyles( std::vector> 
,

SwAutoStyleFamily eFamily ) = 0;
 /** It's slow to iterate through a stylepool looking for a special name, 
but if
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 79d1a3792935..de7e24a0b152 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -410,7 +410,7 @@ protected:
 
 /**  Attribute-set for all auto attributes of a ContentNode.
   (e.g. TextNode or NoTextNode). */
-std::shared_ptr mpAttrSet;
+std::shared_ptr mpAttrSet;
 
 /// Make respective nodes create the specific AttrSets.
 virtual void NewAttrSet( SwAttrPool& ) = 0;
@@ -490,7 +490,7 @@ public:
 /** Does node has already its own auto-attributes?
  Access to SwAttrSet. */
 inline const SwAttrSet () const;
-const SwAttrSet *GetpSwAttrSet() const { return static_cast(mpAttrSet.get()); }
+const SwAttrSet *GetpSwAttrSet() const { return mpAttrSet.get(); }
 bool  HasSwAttrSet() const { return mpAttrSet != nullptr; }
 
 virtual SwFormatColl* ChgFormatColl( SwFormatColl* );
diff --git a/sw/source/core/doc/swstylemanager.cxx 
b/sw/source/core/doc/swstylemanager.cxx
index 7f73555fc8ff..6372ab10c89d 100644
--- a/sw/source/core/doc/swstylemanager.cxx
+++ b/sw/source/core/doc/swstylemanager.cxx
@@ -72,6 +72,9 @@ public:
 virtual std::shared_ptr getAutomaticStyle( const SfxItemSet& 
rSet,

IStyleAccess::SwAutoStyleFamily eFamily,
const OUString* 
pParentName = nullptr ) override;
+virtual std::shared_ptr getAutomaticStyle( const SwAttrSet& 
rSet,
+   
IStyleAccess::SwAutoStyleFamily eFamily,
+   const OUString* 
pParentName = nullptr ) override;
 virtual std::shared_ptr getByName( const OUString& rName,

IStyleAccess::SwAutoStyleFamily eFamily ) override;
 virtual void getAllStyles( std::vector> 
,
@@ -104,6 +107,18 @@ std::shared_ptr 
SwStyleManager::getAutomaticStyle( const SfxItemSet&
 return rAutoPool.insertItemSet( rSet, pParentName );
 }
 
+std::shared_ptr SwStyleManager::getAutomaticStyle( const SwAttrSet& 
rSet,
+   
IStyleAccess::SwAutoStyleFamily eFamily,
+   const 
OUString* pParentName )
+{
+StylePool& rAutoPool
+= eFamily == IStyleAccess::AUTO_STYLE_CHAR ? m_aAutoCharPool : 
m_aAutoParaPool;
+std::shared_ptr pItemSet = rAutoPool.insertItemSet( rSet, 
pParentName );
+std::shared_ptr pAttrSet = 
std::dynamic_pointer_cast(pItemSet);
+assert(bool(pItemSet) == bool(pAttrSet) && "types do not match");
+return pAttrSet;
+}
+
 std::shared_ptr SwStyleManager::cacheAutomaticStyle( const 
SfxItemSet& rSet,

IStyleAccess::SwAutoStyleFamily eFamily )
 {
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index c9abe227643a..6cfab7801f43 100644
--- a/sw/source/core/docnode/node.cxx
+++ 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-09-08 Thread Miklos Vajna (via logerrit)
 sw/inc/redline.hxx  |2 +
 sw/source/core/doc/docredln.cxx |   54 +---
 2 files changed, 37 insertions(+), 19 deletions(-)

New commits:
commit edd121dd668e141cd61f0992340fa07eb6df8e76
Author: Miklos Vajna 
AuthorDate: Thu Sep 7 20:09:15 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Sep 8 08:15:13 2023 +0200

sw doc model xml dump: show all redline data of a range redline

E.g. Alice does an insert, then Bob does a delete in the middle, then
the deletion redline will have 2 redline data, the first will be the
delete, the second will be the original insert, show this in the xml
dump.

Change-Id: Ide9777cdbc8a5460fe28c646104901c968a33382
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156680
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index 1fccb405e192..7ef6b9cad20f 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -157,6 +157,8 @@ public:
 void SetSeqNo( sal_uInt16 nNo ) { m_nSeqNo = nNo; }
 
 OUString GetDescr() const;
+
+void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
 class SW_DLLPUBLIC SwRangeRedline final : public SwPaM
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 54d853065629..752de518accb 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1141,6 +1141,37 @@ OUString SwRedlineData::GetDescr() const
 return SwResId(STR_REDLINE_ARY[static_cast(GetType())]);
 }
 
+void SwRedlineData::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+(void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwRedlineData"));
+
+(void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
+(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), 
BAD_CAST(OString::number(GetSeqNo()).getStr()));
+(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("author"), 
BAD_CAST(SW_MOD()->GetRedlineAuthor(GetAuthor()).toUtf8().getStr()));
+(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("date"), 
BAD_CAST(DateTimeToOString(GetTimeStamp()).getStr()));
+(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("descr"), 
BAD_CAST(GetDescr().toUtf8().getStr()));
+
+OString sRedlineType;
+switch (GetType())
+{
+case RedlineType::Insert:
+sRedlineType = "REDLINE_INSERT";
+break;
+case RedlineType::Delete:
+sRedlineType = "REDLINE_DELETE";
+break;
+case RedlineType::Format:
+sRedlineType = "REDLINE_FORMAT";
+break;
+default:
+sRedlineType = "UNKNOWN";
+break;
+}
+(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), 
BAD_CAST(sRedlineType.getStr()));
+
+(void)xmlTextWriterEndElement(pWriter);
+}
+
 sal_uInt32 SwRangeRedline::s_nLastId = 1;
 
 SwRangeRedline::SwRangeRedline(RedlineType eTyp, const SwPaM& rPam )
@@ -2073,28 +2104,13 @@ void SwRangeRedline::dumpAsXml(xmlTextWriterPtr 
pWriter) const
 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwRangeRedline"));
 
 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), 
BAD_CAST(OString::number(GetSeqNo()).getStr()));
-(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("author"), 
BAD_CAST(SW_MOD()->GetRedlineAuthor(GetAuthor()).toUtf8().getStr()));
-(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("date"), 
BAD_CAST(DateTimeToOString(GetTimeStamp()).getStr()));
-(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("descr"), 
BAD_CAST(const_cast(this)->GetDescr().toUtf8().getStr()));
 
-OString sRedlineType;
-switch (GetType())
+const SwRedlineData* pRedlineData = m_pRedlineData;
+while (pRedlineData)
 {
-case RedlineType::Insert:
-sRedlineType = "REDLINE_INSERT";
-break;
-case RedlineType::Delete:
-sRedlineType = "REDLINE_DELETE";
-break;
-case RedlineType::Format:
-sRedlineType = "REDLINE_FORMAT";
-break;
-default:
-sRedlineType = "UNKNOWN";
-break;
+pRedlineData->dumpAsXml(pWriter);
+pRedlineData = pRedlineData->Next();
 }
-(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), 
BAD_CAST(sRedlineType.getStr()));
 
 SwPaM::dumpAsXml(pWriter);
 


[Libreoffice-commits] core.git: sw/inc sw/source vcl/qa

2023-09-01 Thread Michael Stahl (via logerrit)
 sw/inc/EnhancedPDFExportHelper.hxx  |5 
 sw/source/core/text/EnhancedPDFExportHelper.cxx |  129 ++--
 vcl/qa/cppunit/pdfexport/data/spanlist.fodt |  207 
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |  385 
 4 files changed, 704 insertions(+), 22 deletions(-)

New commits:
commit ee3c3fcf5c48964f7bc1d64484409f072c614866
Author: Michael Stahl 
AuthorDate: Wed Aug 30 16:24:50 2023 +0200
Commit: Michael Stahl 
CommitDate: Fri Sep 1 22:07:13 2023 +0200

tdf#157028 sw: PDF/UA export: reduce the number of Span ILSEs

Currently every text portion produces its own Span ILSE, which means
there's at least one per line.

But that seems a bit excessive, let's try to merge the portions and
create new Spans only when needed, i.e. when the formatting properties
that are exported change.

ILSEs may even be nested, e.g. a Span may contain Link or Span.

This will only merge within one SwTextFrame; merging across split
SwTextFrames looks too difficult to implement.

Change-Id: Id9b02332c580266f78da048be80ecceff1b28eca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156299
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx 
b/sw/inc/EnhancedPDFExportHelper.hxx
index b6a051647f1a..1ab0f8868af4 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -42,6 +42,7 @@ class StringRangeEnumerator;
 class SwTextNode;
 class SwTable;
 class SwNumberTreeNode;
+class SwTextPaintInfo;
 
 /*
  * Mapping of OOo elements to tagged pdf elements:
@@ -158,6 +159,10 @@ class SwTaggedPDFHelper
 void BeginInlineStructureElements();
 void EndStructureElements();
 
+void EndCurrentSpan();
+void CreateCurrentSpan(SwTextPaintInfo const& rInf, OUString const& 
rStyleName);
+bool CheckContinueSpan(SwTextPaintInfo const& rInf, std::u16string_view 
rStyleName);
+
 bool CheckReopenTag();
 void CheckRestoreTag() const;
 
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index e69639dad1e4..3cd5176cb786 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -91,6 +91,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 
@@ -141,6 +142,20 @@ struct SwEnhancedPDFState
 
 LanguageType m_eLanguageDefault;
 
+struct Span
+{
+FontLineStyle eUnderline;
+FontLineStyle eOverline;
+FontStrikeout eStrikeout;
+FontEmphasisMark eFontEmphasis;
+short nEscapement;
+SwFontScript nScript;
+LanguageType nLang;
+OUString StyleName;
+};
+
+::std::optional m_oCurrentSpan;
+
 SwEnhancedPDFState(LanguageType const eLanguageDefault)
 : m_eLanguageDefault(eLanguageDefault)
 {
@@ -1556,6 +1571,15 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
 
 void SwTaggedPDFHelper::EndStructureElements()
 {
+if (mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan)
+{
+if (mpFrameInfo != nullptr)
+{   // close span at end of paragraph
+mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan.reset();
+++m_nEndStructureElement;
+}
+}
+
 while ( m_nEndStructureElement > 0 )
 {
 EndTag();
@@ -1565,6 +1589,53 @@ void SwTaggedPDFHelper::EndStructureElements()
 CheckRestoreTag();
 }
 
+void SwTaggedPDFHelper::EndCurrentSpan()
+{
+mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan.reset();
+EndTag(); // close span
+}
+
+void SwTaggedPDFHelper::CreateCurrentSpan(
+SwTextPaintInfo const& rInf, OUString const& rStyleName)
+{
+assert(!mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan);
+mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan.emplace(
+SwEnhancedPDFState::Span{
+rInf.GetFont()->GetUnderline(),
+rInf.GetFont()->GetOverline(),
+rInf.GetFont()->GetStrikeout(),
+rInf.GetFont()->GetEmphasisMark(),
+rInf.GetFont()->GetEscapement(),
+rInf.GetFont()->GetActual(),
+rInf.GetFont()->GetLanguage(),
+rStyleName});
+// leave it open to let next portion decide to merge or close
+--m_nEndStructureElement;
+}
+
+bool SwTaggedPDFHelper::CheckContinueSpan(
+SwTextPaintInfo const& rInf, std::u16string_view const rStyleName)
+{
+if (!mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan)
+return false;
+
+SwEnhancedPDFState::Span const& 
rCurrent(*mpPDFExtOutDevData->GetSwPDFState()->m_oCurrentSpan);
+
+bool const ret(rCurrent.eUnderline == rInf.GetFont()->GetUnderline()
+&& rCurrent.eOverline == rInf.GetFont()->GetOverline()
+&& rCurrent.eStrikeout == rInf.GetFont()->GetStrikeout()
+&& rCurrent.eFontEmphasis == 

[Libreoffice-commits] core.git: sw/inc sw/source vcl/qa

2023-09-01 Thread Michael Stahl (via logerrit)
 sw/inc/EnhancedPDFExportHelper.hxx   |1 
 sw/source/core/text/EnhancedPDFExportHelper.cxx  |   44 ++-
 vcl/qa/cppunit/pdfexport/data/nestedsection.fodt |  132 ++
 vcl/qa/cppunit/pdfexport/pdfexport.cxx   |  137 +++
 4 files changed, 306 insertions(+), 8 deletions(-)

New commits:
commit d5f68529a79c615f989fcfeef248d887a6e10f5a
Author: Michael Stahl 
AuthorDate: Thu Aug 31 19:50:55 2023 +0200
Commit: Michael Stahl 
CommitDate: Fri Sep 1 19:16:15 2023 +0200

sw: PDF/UA export: produce nested Sect SEs for nested sections

Change-Id: I5b142acf00629ffd00562e2c8791587b7a7761df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156357
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx 
b/sw/inc/EnhancedPDFExportHelper.hxx
index c75e7cfe70ce..b6a051647f1a 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -145,6 +145,7 @@ class SwTaggedPDFHelper
 const Frame_Info* mpFrameInfo;
 const Por_Info* mpPorInfo;
 
+void OpenTagImpl(void const* pKey);
 sal_Int32 BeginTagImpl(void const* pKey,vcl::PDFWriter::StructElement 
aTagRole, const OUString& rTagName);
 void BeginTag( vcl::PDFWriter::StructElement aTagRole, const OUString& 
rTagName );
 void EndTag();
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index d3529e54b7f9..e69639dad1e4 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -437,13 +437,7 @@ bool SwTaggedPDFHelper::CheckReopenTag()
 
 if (pReopenKey)
 {
-sal_Int32 const id = 
mpPDFExtOutDevData->EnsureStructureElement(pReopenKey);
-mpPDFExtOutDevData->BeginStructureElement(id);
-++m_nEndStructureElement;
-
-#if OSL_DEBUG_LEVEL > 1
-aStructStack.push_back( 99 );
-#endif
+OpenTagImpl(pReopenKey);
 
 bRet = true;
 }
@@ -464,6 +458,17 @@ void SwTaggedPDFHelper::CheckRestoreTag() const
 }
 }
 
+void SwTaggedPDFHelper::OpenTagImpl(void const*const pKey)
+{
+sal_Int32 const id = mpPDFExtOutDevData->EnsureStructureElement(pKey);
+mpPDFExtOutDevData->BeginStructureElement(id);
+++m_nEndStructureElement;
+
+#if OSL_DEBUG_LEVEL > 1
+aStructStack.push_back( 99 );
+#endif
+}
+
 sal_Int32 SwTaggedPDFHelper::BeginTagImpl(void const*const pKey,
 vcl::PDFWriter::StructElement const eType, const OUString& rString)
 {
@@ -1213,7 +1218,30 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
 {
 const SwSection* pSection =
 static_cast(pFrame)->GetSection();
-if ( SectionType::ToxContent == pSection->GetType() )
+
+// open all parent sections, so that the SEs of sections
+// are nested in the same way as their SwSectionNodes
+std::vector parents;
+for (SwSection const* pParent = pSection->GetParent();
+ pParent != nullptr; pParent = pParent->GetParent())
+{
+parents.push_back(pParent);
+}
+for (auto it = parents.rbegin(); it != parents.rend(); ++it)
+{
+// key is the SwSection - see lcl_GetKeyFromFrame()
+OpenTagImpl(*it);
+}
+
+FrameTagSet& 
rFrameTagSet(mpPDFExtOutDevData->GetSwPDFState()->m_FrameTagSet);
+if (rFrameTagSet.find(pSection) != rFrameTagSet.end())
+{
+// special case: section may have *multiple* master frames,
+// when it is interrupted by nested section - reopen!
+OpenTagImpl(pSection);
+break;
+}
+else if (SectionType::ToxContent == pSection->GetType())
 {
 const SwTOXBase* pTOXBase = pSection->GetTOXBase();
 if ( pTOXBase )
diff --git a/vcl/qa/cppunit/pdfexport/data/nestedsection.fodt 
b/vcl/qa/cppunit/pdfexport/data/nestedsection.fodt
new file mode 100644
index ..ab743058f5e7
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/nestedsection.fodt
@@ -0,0 +1,132 @@
+
+http://www.w3.org/TR/css3-text/; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; 
xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
xmlns:xforms="http://www.w3.org/2002/xforms; 
xmlns:dom="http://www.w3.org/2001/xml-events; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office; 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-09-01 Thread Michael Stahl (via logerrit)
 sw/inc/EnhancedPDFExportHelper.hxx  |1 
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   52 +++-
 2 files changed, 26 insertions(+), 27 deletions(-)

New commits:
commit 7aca867aa1e1e675c0a9d27d76bd069bc6d5f512
Author: Michael Stahl 
AuthorDate: Thu Aug 31 19:01:47 2023 +0200
Commit: Michael Stahl 
CommitDate: Fri Sep 1 10:23:46 2023 +0200

tdf#156306 sw: PDF export: refactor, split out BeginTagImpl()

Change-Id: Ifcb8db6d9a5caaf50c0ca2794266fb501b59dee0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156356
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx 
b/sw/inc/EnhancedPDFExportHelper.hxx
index 6a505ff7..c75e7cfe70ce 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -145,6 +145,7 @@ class SwTaggedPDFHelper
 const Frame_Info* mpFrameInfo;
 const Por_Info* mpPorInfo;
 
+sal_Int32 BeginTagImpl(void const* pKey,vcl::PDFWriter::StructElement 
aTagRole, const OUString& rTagName);
 void BeginTag( vcl::PDFWriter::StructElement aTagRole, const OUString& 
rTagName );
 void EndTag();
 
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 0b4fe669b7d8..d3529e54b7f9 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -464,11 +464,27 @@ void SwTaggedPDFHelper::CheckRestoreTag() const
 }
 }
 
+sal_Int32 SwTaggedPDFHelper::BeginTagImpl(void const*const pKey,
+vcl::PDFWriter::StructElement const eType, const OUString& rString)
+{
+// write new tag
+const sal_Int32 nId = mpPDFExtOutDevData->EnsureStructureElement(pKey);
+mpPDFExtOutDevData->InitStructureElement(nId, eType, rString);
+mpPDFExtOutDevData->BeginStructureElement(nId);
+++m_nEndStructureElement;
+
+#if OSL_DEBUG_LEVEL > 1
+aStructStack.push_back( o3tl::narrowing(eType) );
+#endif
+
+return nId;
+}
+
 void SwTaggedPDFHelper::BeginTag( vcl::PDFWriter::StructElement eType, const 
OUString& rString )
 {
 void const* pKey(nullptr);
 
-if (mpFrameInfo && eType != vcl::PDFWriter::LIBody && eType != 
vcl::PDFWriter::TOCI)
+if (mpFrameInfo)
 {
 const SwFrame& rFrame = mpFrameInfo->mrFrame;
 
@@ -489,15 +505,7 @@ void SwTaggedPDFHelper::BeginTag( 
vcl::PDFWriter::StructElement eType, const OUS
 }
 }
 
-// write new tag
-const sal_Int32 nId = mpPDFExtOutDevData->EnsureStructureElement(pKey);
-mpPDFExtOutDevData->InitStructureElement(nId, eType, rString);
-mpPDFExtOutDevData->BeginStructureElement(nId);
-++m_nEndStructureElement;
-
-#if OSL_DEBUG_LEVEL > 1
-aStructStack.push_back( o3tl::narrowing(eType) );
-#endif
+sal_Int32 const nId = BeginTagImpl(pKey, eType, rString);
 
 // Store the id of the current structure element if
 // - it is a list structure element
@@ -524,19 +532,6 @@ void SwTaggedPDFHelper::BeginTag( 
vcl::PDFWriter::StructElement eType, const OUS
 rNumListBodyIdMap[ pNodeNum ] = nId;
 }
 }
-else if ( mpFrameInfo )
-{
-const SwFrame& rFrame = mpFrameInfo->mrFrame;
-
-if (vcl::PDFWriter::LIBody == eType && rFrame.IsTextFrame())
-{
-SwTextFrame const& rTextFrame(static_cast(rFrame));
-SwTextNode const*const 
pTextNd(rTextFrame.GetTextNodeForParaProps());
-SwNodeNum const*const 
pNodeNum(pTextNd->GetNum(rTextFrame.getRootFrame()));
-NumListBodyIdMap& 
rNumListBodyIdMap(mpPDFExtOutDevData->GetSwPDFState()->m_NumListBodyIdMap);
-rNumListBodyIdMap[ pNodeNum ] = nId;
-}
-}
 
 SetAttributes( eType );
 }
@@ -1250,14 +1245,17 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
 case SwFrameType::Txt :
 {
 SwTextFrame const& rTextFrame(*static_cast(pFrame));
+const SwTextNode *const 
pTextNd(rTextFrame.GetTextNodeForParaProps());
+
 // lazy open LBody after Lbl
 if 
(rTextFrame.GetPara()->HasNumberingPortion(SwParaPortion::OnlyNumbering))
 {
-BeginTag(vcl::PDFWriter::LIBody, aListBodyString);
+sal_Int32 const nId = BeginTagImpl(nullptr, 
vcl::PDFWriter::LIBody, aListBodyString);
+SwNodeNum const*const 
pNodeNum(pTextNd->GetNum(rTextFrame.getRootFrame()));
+NumListBodyIdMap& 
rNumListBodyIdMap(mpPDFExtOutDevData->GetSwPDFState()->m_NumListBodyIdMap);
+rNumListBodyIdMap[ pNodeNum ] = nId;
 }
 
-const SwTextNode *const 
pTextNd(rTextFrame.GetTextNodeForParaProps());
-
 const SwFormat* pTextFormat = pTextNd->GetFormatColl();
 const SwFormat* pParentTextFormat = pTextFormat ? 
pTextFormat->DerivedFrom() : nullptr;
 
@@ -1371,7 +1369,7 @@ void 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-09-01 Thread Noel Grandin (via logerrit)
 sw/inc/accmap.hxx|2 -
 sw/source/core/access/accmap.cxx |   77 +--
 2 files changed, 35 insertions(+), 44 deletions(-)

New commits:
commit a3bd81335c4128cb2f62487868a94882a97eaf66
Author: Noel Grandin 
AuthorDate: Wed Aug 30 16:09:57 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Sep 1 09:10:35 2023 +0200

use concrete type for SwAccessibleShapeMap_Impl

avoid some unnecessary casting

Change-Id: I422428fa3c31141d73171a22c6c58242a1c1be2b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156319
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx
index 42a73cbf4fe9..6e5c189a97b4 100644
--- a/sw/inc/accmap.hxx
+++ b/sw/inc/accmap.hxx
@@ -176,7 +176,7 @@ public:
 }
 static bool IsInSameLevel(const SdrObject* pObj, const SwFEShell* pFESh);
 void AddShapeContext(const SdrObject *pObj,
- css::uno::Reference < 
css::accessibility::XAccessible > const & xAccShape);
+ rtl::Reference < ::accessibility::AccessibleShape 
> const & xAccShape);
 
 void AddGroupContext(const SdrObject *pParentObj,
 css::uno::Reference < css::accessibility::XAccessible > 
const & xAccParent);
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index b8b87289286a..3babe9e879d0 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -258,7 +258,7 @@ class SwAccessibleShapeMap_Impl
 public:
 
 typedef const SdrObject *   
key_type;
-typedef uno::WeakReference 
mapped_type;
+typedef unotools::WeakReference<::accessibility::AccessibleShape>   
mapped_type;
 typedef std::pair   
value_type;
 typedef std::map::iterator iterator;
 typedef std::map::const_iterator const_iterator;
@@ -326,23 +326,19 @@ std::unique_ptr
 for( const auto& rEntry : maMap )
 {
 const SdrObject *pObj = rEntry.first;
-uno::Reference < XAccessible > xAcc( rEntry.second );
+rtl::Reference < ::accessibility::AccessibleShape > xAcc( 
rEntry.second );
 if( nSelShapes && pFESh && pFESh->IsObjSelected( *pObj ) )
 {
 // selected objects are inserted from the back
 --pSelShape;
 pSelShape->first = pObj;
-pSelShape->second =
-static_cast < ::accessibility::AccessibleShape* >(
-xAcc.get() );
+pSelShape->second = xAcc.get();
 --nSelShapes;
 }
 else
 {
 pShape->first = pObj;
-pShape->second =
-static_cast < ::accessibility::AccessibleShape* >(
-xAcc.get() );
+pShape->second = xAcc.get();
 ++pShape;
 }
 }
@@ -1165,9 +1161,9 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
 {
 while( aIter != aEndIter )
 {
-uno::Reference < XAccessible > xAcc( (*aIter).second );
+rtl::Reference<::accessibility::AccessibleShape> xAcc( 
(*aIter).second );
 if( xAcc.is() )
-static_cast < ::accessibility::AccessibleShape* 
>(xAcc.get())->SetState( AccessibleStateType::SELECTED );
+xAcc->SetState( AccessibleStateType::SELECTED );
 
 ++aIter;
 }
@@ -1187,9 +1183,9 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
 
 if(rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
 {
-uno::Reference < XAccessible > xAcc( (*aIter).second );
+rtl::Reference < ::accessibility::AccessibleShape > xAcc( 
(*aIter).second );
 if(xAcc.is())
-static_cast < ::accessibility::AccessibleShape* 
>(xAcc.get())->ResetState( AccessibleStateType::SELECTED );
+xAcc->ResetState( AccessibleStateType::SELECTED );
 
 ++aIter;
 continue;
@@ -1239,44 +1235,44 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
 if( ( ((nHere == nStartIndex) && 
(nIndex >= pStart->GetContentIndex())) || (nHere > nStartIndex) )
 &&( ((nHere == nEndIndex) && 
(nIndex < pEnd->GetContentIndex())) || (nHere < nEndIndex) ) )
 {
-uno::Reference < XAccessible > 
xAcc( (*aIter).second );
+rtl::Reference < 
::accessibility::AccessibleShape > xAcc( (*aIter).second );
 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-09-01 Thread Noel Grandin (via logerrit)
 sw/inc/accmap.hxx|4 
 sw/source/core/access/accmap.cxx |  196 ++-
 2 files changed, 76 insertions(+), 124 deletions(-)

New commits:
commit 14dc749f575a8faea301472ed22f9c6b24044e8d
Author: Noel Grandin 
AuthorDate: Wed Aug 30 16:02:29 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Sep 1 08:49:17 2023 +0200

use concrete type for SwAccessibleMap::mxCursorContext

avoid some unnecessary casting

Change-Id: I354ac67aa7a0c7f8ebe676315c66c97af31dc4e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156318
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx
index 33f3a2d93f94..42a73cbf4fe9 100644
--- a/sw/inc/accmap.hxx
+++ b/sw/inc/accmap.hxx
@@ -27,7 +27,7 @@
 
 #include 
 #include 
-
+#include 
 #include 
 #include 
 #include 
@@ -108,7 +108,7 @@ class SwAccessibleMap final : public 
::accessibility::IAccessibleViewForwarder,
 /// preview-to-display coordinates
 std::unique_ptr mpPreview;
 
-css::uno::WeakReference < css::accessibility::XAccessible > 
mxCursorContext;
+unotools::WeakReference< SwAccessibleContext > mxCursorContext;
 
 bool mbShapeSelected;
 
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 02038f14fc25..b8b87289286a 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -86,8 +86,8 @@ using namespace ::sw::access;
 class SwAccessibleContextMap_Impl
 {
 public:
-typedef const SwFrame *   
key_type;
-typedef uno::WeakReference < XAccessible >  
mapped_type;
+typedef const SwFrame * 
key_type;
+typedef unotools::WeakReference < SwAccessibleContext >  
mapped_type;
 typedef std::pair   
value_type;
 typedef std::unordered_map::iterator iterator;
 typedef std::unordered_map::const_iterator 
const_iterator;
@@ -647,8 +647,8 @@ struct SwAccessibleParaSelection
 
 struct SwXAccWeakRefComp
 {
-bool operator()( const uno::WeakReference& _rXAccWeakRef1,
- const uno::WeakReference& _rXAccWeakRef2 
) const
+bool operator()( const unotools::WeakReference& 
_rXAccWeakRef1,
+ const unotools::WeakReference& 
_rXAccWeakRef2 ) const
 {
 return _rXAccWeakRef1.get() < _rXAccWeakRef2.get();
 }
@@ -659,7 +659,7 @@ struct SwXAccWeakRefComp
 class SwAccessibleSelectedParas_Impl
 {
 public:
-typedef uno::WeakReference < XAccessible >  
key_type;
+typedef unotools::WeakReference < SwAccessibleContext > 
key_type;
 typedef SwAccessibleParaSelection   
mapped_type;
 typedef std::pair   
value_type;
 typedef SwXAccWeakRefComp   
key_compare;
@@ -859,7 +859,7 @@ void SwAccPreviewData::AdjustLogicPgRectToVisibleArea(
 _iorLogicPgSwRect.AddBottom( - nTmpDiff );
 }
 
-static bool AreInSameTable( const uno::Reference< XAccessible >& rAcc,
+static bool AreInSameTable( const rtl::Reference< SwAccessibleContext >& rAcc,
   const SwFrame *pFrame )
 {
 bool bRet = false;
@@ -870,11 +870,9 @@ static bool AreInSameTable( const uno::Reference< 
XAccessible >& rAcc,
 // by comparing the last table frame in the
 // follow chain, because that's cheaper than
 // searching the first one.
-SwAccessibleContext *pAccImpl =
-static_cast< SwAccessibleContext *>( rAcc.get() );
-if( pAccImpl->GetFrame()->IsCellFrame() )
+if( rAcc->GetFrame()->IsCellFrame() )
 {
-const SwTabFrame *pTabFrame1 = 
pAccImpl->GetFrame()->FindTabFrame();
+const SwTabFrame *pTabFrame1 = rAcc->GetFrame()->FindTabFrame();
 if (pTabFrame1)
 {
 while (pTabFrame1->GetFollow())
@@ -904,14 +902,10 @@ void SwAccessibleMap::FireEvent( const 
SwAccessibleEvent_Impl& rEvent )
 mpFrameMap->find( rEvent.mpParentFrame );
 if( aIter != mpFrameMap->end() )
 {
-uno::Reference < XAccessible > xAcc( (*aIter).second );
-if (xAcc.is())
+rtl::Reference < SwAccessibleContext > xContext( 
(*aIter).second.get() );
+if (xContext.is() && xContext->getAccessibleRole() == 
AccessibleRole::PARAGRAPH)
 {
-uno::Reference < XAccessibleContext >  
xContext(xAcc,uno::UNO_QUERY);
-if (xContext.is() && xContext->getAccessibleRole() == 
AccessibleRole::PARAGRAPH)
-{
-xAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() 
);
-}
+xAccImpl = xContext.get();
 }
 }
 }
@@ -1324,7 +1318,7 @@ void 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-08-23 Thread Balazs Varga (via logerrit)
 sw/inc/OnlineAccessibilityCheck.hxx |4 ++--
 sw/inc/node.hxx |2 +-
 sw/source/core/docnode/node.cxx |4 ++--
 sw/source/core/layout/atrfrm.cxx|   10 ++
 sw/source/core/txtnode/OnlineAccessibilityCheck.cxx |9 ++---
 sw/source/uibase/shells/drwbassh.cxx|8 
 6 files changed, 29 insertions(+), 8 deletions(-)

New commits:
commit 069569e4a095f2fe42e94c2dad15356e2038727a
Author: Balazs Varga 
AuthorDate: Mon Aug 21 19:42:38 2023 +0200
Commit: Balazs Varga 
CommitDate: Wed Aug 23 12:40:11 2023 +0200

tdf#156116 - A11Y - fix object name does not update in accessibility sidebar

when we modify the name on the Navigator sidebar.
Update the related accessibility issue after we modify the name on the 
sidebar.

Change-Id: I8f4b8780ff1ffe7cfb86ff837c9579d6b785b832
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155904
Tested-by: Jenkins
Reviewed-by: Balazs Varga 

diff --git a/sw/inc/OnlineAccessibilityCheck.hxx 
b/sw/inc/OnlineAccessibilityCheck.hxx
index 1055c7e67d53..1e320554f8fc 100644
--- a/sw/inc/OnlineAccessibilityCheck.hxx
+++ b/sw/inc/OnlineAccessibilityCheck.hxx
@@ -57,7 +57,7 @@ private:
 
 void runAccessibilityCheck(SwNode* pNode);
 void updateStatusbar();
-void updateNodeStatus(SwNode* pContentNode);
+void updateNodeStatus(SwNode* pContentNode, bool bIssueObjectNameChanged = 
false);
 void initialCheck();
 void lookForPreviousNodeAndUpdate(SwPosition const& rNewPos);
 void clearAccessibilityIssuesFromAllNodes();
@@ -66,7 +66,7 @@ private:
 public:
 OnlineAccessibilityCheck(SwDoc& rDocument);
 void update(SwPosition const& rNewPos);
-void resetAndQueue(SwNode* pNode);
+void resetAndQueue(SwNode* pNode, bool bIssueObjectNameChanged = false);
 void resetAndQueueDocumentLevel();
 void updateCheckerActivity();
 sal_Int32 getNumberOfAccessibilityIssues() { return 
m_nAccessibilityIssues; }
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 84e466dfefa0..79d1a3792935 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -336,7 +336,7 @@ public:
 return m_aAccessibilityCheckStatus;
 }
 
-void resetAndQueueAccessibilityCheck();
+void resetAndQueueAccessibilityCheck(bool bIssueObjectNameChanged = false);
 
 private:
 SwNode( const SwNode & rNodes ) = delete;
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 64a9e86137c5..4304b875c4d7 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -2179,9 +2179,9 @@ void SwNode::RemoveAnchoredFly(SwFrameFormat *const 
pFlyFormat)
 m_aAnchoredFlys.erase(it);
 }
 
-void SwNode::resetAndQueueAccessibilityCheck()
+void SwNode::resetAndQueueAccessibilityCheck(bool bIssueObjectNameChanged)
 {
-GetDoc().getOnlineAccessibilityCheck()->resetAndQueue(this);
+GetDoc().getOnlineAccessibilityCheck()->resetAndQueue(this, 
bIssueObjectNameChanged);
 }
 
 
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 5a48a3965545..a272292be46b 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2614,6 +2614,16 @@ void SwFrameFormat::SetFormatName( const OUString& 
rNewName, bool bBroadcast )
 if (bBroadcast) {
 GetNotifier().Broadcast(aHint);
 }
+
+// update accessibility sidebar object name if we modify the object 
name on the navigator bar
+if (!aHint.m_sOld.isEmpty() && aHint.m_sOld != aHint.m_sNew)
+{
+if (SwFlyFrame* pSFly = SwIterator(*this).First())
+{
+if (SwNode* pSwNode = 
static_cast(pSFly->Lower())->GetNode())
+pSwNode->resetAndQueueAccessibilityCheck(true);
+}
+}
 }
 else
 SwFormat::SetFormatName( rNewName, bBroadcast );
diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx 
b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
index 025dba8c5f25..27d4d5d56f12 100644
--- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
+++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
@@ -79,13 +79,16 @@ OnlineAccessibilityCheck::OnlineAccessibilityCheck(SwDoc& 
rDocument)
 {
 }
 
-void OnlineAccessibilityCheck::updateNodeStatus(SwNode* pNode)
+void OnlineAccessibilityCheck::updateNodeStatus(SwNode* pNode, bool 
bIssueObjectNameChanged)
 {
 if (!pNode->IsContentNode() && !pNode->IsTableNode())
 return;
 
 m_nAccessibilityIssues = 0;
 
+if (bIssueObjectNameChanged)
+return;
+
 auto it = m_aNodes.find(pNode);
 if (it == m_aNodes.end())
 {
@@ -291,7 +294,7 @@ void 
OnlineAccessibilityCheck::clearAccessibilityIssuesFromAllNodes()
 updateStatusbar();
 }
 
-void OnlineAccessibilityCheck::resetAndQueue(SwNode* pNode)
+void OnlineAccessibilityCheck::resetAndQueue(SwNode* pNode, 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-08-03 Thread Rafael Lima (via logerrit)
 sw/inc/helpids.h   |6 
 sw/source/uibase/utlui/content.cxx |   49 ++---
 2 files changed, 46 insertions(+), 9 deletions(-)

New commits:
commit 490cf5393d30dd2e9ab201286ef863b3c266a8b4
Author: Rafael Lima 
AuthorDate: Tue Aug 1 02:42:15 2023 +0200
Commit: Rafael Lima 
CommitDate: Thu Aug 3 18:15:52 2023 +0200

tdf#154210 Add help IDs for the Navigator context menu

This patch adds the missing HIDs for all entries in submenus of the context 
menu in the Navigator. The entries in the main level already work.

For this patch to work, the related patch in the "help" repo needs to be 
accepted to create the target HIDs.

Change-Id: Ic5917ce16a1430c6f7031ea6b9eb71a09f52624a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155049
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 
Reviewed-by: Rafael Lima 

diff --git a/sw/inc/helpids.h b/sw/inc/helpids.h
index 6bf90929ab00..cc3b2d791613 100644
--- a/sw/inc/helpids.h
+++ b/sw/inc/helpids.h
@@ -116,6 +116,12 @@ inline constexpr OUStringLiteral HID_TBX_FORMULA_CALC = 
u"SW_HID_TBX_FORMULA_CAL
 inline constexpr OUStringLiteral HID_TBX_FORMULA_CANCEL = 
u"SW_HID_TBX_FORMULA_CANCEL";
 inline constexpr OUStringLiteral HID_TBX_FORMULA_APPLY = 
u"SW_HID_TBX_FORMULA_APPLY";
 
+// Navigator context menu
+inline constexpr OUStringLiteral HID_NAV_OUTLINE_TRACKING = 
u"SW_HID_NAV_OUTLINE_TRACKING";
+inline constexpr OUStringLiteral HID_NAV_OUTLINE_LEVEL = 
u"SW_HID_NAV_OUTLINE_LEVEL";
+inline constexpr OUStringLiteral HID_NAV_DRAG_MODE = u"SW_HID_NAV_DRAG_MODE";
+inline constexpr OUStringLiteral HID_NAV_DISPLAY = u"SW_HID_NAV_DISPLAY";
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index a57df3fd0630..5238dde260b6 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1575,19 +1575,42 @@ IMPL_LINK(SwContentTree, CommandHdl, const 
CommandEvent&, rCEvt, bool)
 
xSubPopOutlineContent->append(OUString::number(SHOW_OUTLINE_CONTENT_VISIBILITY),
   
SwResId(STR_OUTLINE_CONTENT_VISIBILITY_SHOW_ALL));
 
+
xSubPopOutlineContent->set_item_help_id(OUString::number(TOGGLE_OUTLINE_CONTENT_VISIBILITY),
+HID_NAVIGATOR_TREELIST);
+
xSubPopOutlineContent->set_item_help_id(OUString::number(HIDE_OUTLINE_CONTENT_VISIBILITY),
+HID_NAVIGATOR_TREELIST);
+
xSubPopOutlineContent->set_item_help_id(OUString::number(SHOW_OUTLINE_CONTENT_VISIBILITY),
+HID_NAVIGATOR_TREELIST);
+
+// Add entries to the Outline Tracking submenu
+OUString sId;
 for(int i = 1; i <= 3; ++i)
-xSubPopOutlineTracking->append_radio(OUString::number(i + 10), 
m_aContextStrings[IDX_STR_OUTLINE_TRACKING + i]);
+{
+sId = OUString::number(i + 10);
+xSubPopOutlineTracking->append_radio(sId, 
m_aContextStrings[IDX_STR_OUTLINE_TRACKING + i]);
+xSubPopOutlineTracking->set_item_help_id(sId, 
HID_NAV_OUTLINE_TRACKING);
+}
 xSubPopOutlineTracking->set_active(OUString::number(10 + 
m_nOutlineTracking), true);
 
+// Add entries to the Outline Level submenu
 for (int i = 1; i <= MAXLEVEL; ++i)
-xSubPop1->append_radio(OUString::number(i + 100), OUString::number(i));
+{
+sId = OUString::number(i + 100);
+xSubPop1->append_radio(sId, OUString::number(i));
+xSubPop1->set_item_help_id(sId, HID_NAV_OUTLINE_LEVEL);
+}
 xSubPop1->set_active(OUString::number(100 + m_nOutlineLevel), true);
 
+// Add entries to the Drag Mode submenu
 for (int i=0; i < 3; ++i)
-xSubPop2->append_radio(OUString::number(i + 201), 
m_aContextStrings[IDX_STR_HYPERLINK + i]);
+{
+sId = OUString::number(i + 201);
+xSubPop2->append_radio(sId, m_aContextStrings[IDX_STR_HYPERLINK + i]);
+xSubPop2->set_item_help_id(sId, HID_NAV_DRAG_MODE);
+}
 xSubPop2->set_active(OUString::number(201 + 
static_cast(GetParentWindow()->GetRegionDropMode())), true);
 
-// Insert the list of the open files
+// Insert the list of the open files in the Display submenu
 {
 sal_uInt16 nId = 301;
 SwView *pView = SwModule::GetFirstView();
@@ -1596,20 +1619,28 @@ IMPL_LINK(SwContentTree, CommandHdl, const 
CommandEvent&, rCEvt, bool)
 OUString sInsert = pView->GetDocShell()->GetTitle() + " (" +
 m_aContextStrings[pView == GetActiveView() ? IDX_STR_ACTIVE :
  IDX_STR_INACTIVE] 
+ ")";
-xSubPop3->append_radio(OUString::number(nId), sInsert);
+sId = OUString::number(nId);
+xSubPop3->append_radio(sId, sInsert);
+xSubPop3->set_item_help_id(sId, HID_NAV_DISPLAY);
 if (State::CONSTANT == 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-08-02 Thread Michael Stahl (via logerrit)
 sw/inc/undobj.hxx  |   11 +--
 sw/source/core/undo/undobj.cxx |   21 +
 sw/source/core/undo/unins.cxx  |4 ++--
 sw/source/core/undo/untblk.cxx |6 +++---
 4 files changed, 19 insertions(+), 23 deletions(-)

New commits:
commit 2d96d69322ac18f53668b75397c8587f94cd043b
Author: Michael Stahl 
AuthorDate: Wed Aug 2 13:26:39 2023 +0200
Commit: Michael Stahl 
CommitDate: Wed Aug 2 20:40:37 2023 +0200

tdf#156546 sw: fix infinite loop in SwUndoInsert::RedoImpl()

The problem is that SwUndoSaveContent::MovePtBackward() sets the point
of a shell cursor to the document body's start node, which is not a
valid position for a shell cursor; FindParentText() then loops forever.

The purpose of this appears to be to move the point temporarily
somewhere where subsequent inserting operations won't move it further,
so that it can be restored to the start of the inserted stuff.

Refactor a bit to use a temporary SwNodeIndex instead, which should work
as nothing should delete the node it's pointing to.

(regression from commit d81379db730a163c5ff75d4f3a3cddbd7b5eddda)

Change-Id: I471bcced1741c77c07239ed124d4fd39ff7a7515
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155227
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index f95a3aa78bfc..9feaec0521b7 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -179,12 +179,11 @@ protected:
   const SwNodeOffset* pEndNdIdx = nullptr,
   bool bForceCreateFrames = false);
 
-// These two methods move the SPoint back/forth from PaM. With it
-// a range can be spanned for Undo/Redo. (In this case the SPoint
-// is before the manipulated range!!)
-// The flag indicates if there is content before the SPoint.
-static bool MovePtBackward( SwPaM& rPam );
-static void MovePtForward( SwPaM& rPam, bool bMvBkwrd );
+// These two methods save and restore the Point of PaM.
+// If the point cannot be moved, a "backup" is created on the previous 
node.
+// Either way, it will not be moved by inserting at its original position.
+static ::std::optional MovePtBackward(SwPaM& rPam);
+static void MovePtForward(SwPaM& rPam, ::std::optional && 
oMvBkwrd);
 
 // Before moving stuff into UndoNodes-Array care has to be taken that
 // the content-bearing attributes are removed from the nodes-array.
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index c0a8427b0361..dce7f3eb2724 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -860,29 +860,26 @@ void SwUndoSaveContent::MoveFromUndoNds( SwDoc& rDoc, 
SwNodeOffset nNodeIdx,
 }
 }
 
-// These two methods move the Point of Pam backwards/forwards. With that, one
-// can span an area for a Undo/Redo. (The Point is then positioned in front of
-// the area to manipulate!)
-// The flag indicates if there is still content in front of Point.
-bool SwUndoSaveContent::MovePtBackward( SwPaM& rPam )
+// These two methods save and restore the Point of PaM.
+// If the point cannot be moved, a "backup" is created on the previous node.
+// Either way, returned, inserting at its original position will not move it.
+::std::optional SwUndoSaveContent::MovePtBackward(SwPaM & rPam)
 {
 rPam.SetMark();
 if( rPam.Move( fnMoveBackward ))
-return true;
+return {};
 
-// If there is no content onwards, set Point simply to the previous 
position
-// (Node and Content, so that Content will be detached!)
-rPam.GetPoint()->Adjust(SwNodeOffset(-1));
-return false;
+return { SwNodeIndex(rPam.GetPoint()->GetNode(), -1) };
 }
 
-void SwUndoSaveContent::MovePtForward( SwPaM& rPam, bool bMvBkwrd )
+void SwUndoSaveContent::MovePtForward(SwPaM& rPam, 
::std::optional && oMvBkwrd)
 {
 // Was there content before this position?
-if( bMvBkwrd )
+if (!oMvBkwrd)
 rPam.Move( fnMoveForward );
 else
 {
+*rPam.GetPoint() = SwPosition(*oMvBkwrd);
 rPam.GetPoint()->Adjust(SwNodeOffset(1));
 SwContentNode* pCNd = rPam.GetPointContentNode();
 if( !pCNd )
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 38ac9d49c65b..0ac95d0c192f 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -321,7 +321,7 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & 
rContext)
 
 if( m_nLen )
 {
-const bool bMvBkwrd = MovePtBackward( *pPam );
+::std::optional oMvBkwrd = MovePtBackward(*pPam);
 
 if (maText)
 {
@@ -348,7 +348,7 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & 
rContext)
 m_nNode = pPam->GetMark()->GetNodeIndex();
 m_nContent = pPam->GetMark()->GetContentIndex();
 
-MovePtForward( *pPam, 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-08-01 Thread Miklos Vajna (via logerrit)
 sw/inc/fmtinfmt.hxx |4 ++--
 sw/inc/fmturl.hxx   |3 ++-
 sw/inc/txtinet.hxx  |2 +-
 sw/source/core/txtnode/txatbase.cxx |3 +++
 4 files changed, 8 insertions(+), 4 deletions(-)

New commits:
commit b54776293ad21363e8a1251bf71ff1ae74f61365
Author: Miklos Vajna 
AuthorDate: Mon Jul 31 21:23:26 2023 +0200
Commit: Miklos Vajna 
CommitDate: Tue Aug 1 08:19:21 2023 +0200

sw: document SwFormatINetFormat

Especially how it relates to SwFormatURL, which is for images, not for
Writer text.

Change-Id: Idc00f3b9803d2fb603647b692de2c1a6ce068361
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155115
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/fmtinfmt.hxx b/sw/inc/fmtinfmt.hxx
index 32e05f6bd3a9..a76db5521c52 100644
--- a/sw/inc/fmtinfmt.hxx
+++ b/sw/inc/fmtinfmt.hxx
@@ -30,8 +30,8 @@ class SwTextINetFormat;
 class IntlWrapper;
 enum class SvMacroItemId : sal_uInt16;
 
-// ATT_INETFMT
-
+/// SfxPoolItem subclass that contains data about an inserted hyperlink / URL 
in Writer text. Its
+/// location is tracked by the wrapping SwTextINetFormat.
 class SW_DLLPUBLIC SwFormatINetFormat final
 : public SfxPoolItem
 , public sw::BroadcasterMixin
diff --git a/sw/inc/fmturl.hxx b/sw/inc/fmturl.hxx
index dcfcb9f9e830..c3bca0789aa4 100644
--- a/sw/inc/fmturl.hxx
+++ b/sw/inc/fmturl.hxx
@@ -28,7 +28,8 @@
 class ImageMap;
 class IntlWrapper;
 
-/// SfxPoolItem subclass that wraps a URL.
+/// SfxPoolItem subclass that wraps a URL. This can appear in the item set of 
e.g. a
+/// sw::SpzFrameFormat (Writer image).
 class SW_DLLPUBLIC SwFormatURL final : public SfxPoolItem
 {
 OUString  m_sTargetFrameName; ///< Target frame for URL.
diff --git a/sw/inc/txtinet.hxx b/sw/inc/txtinet.hxx
index 1f3b4ab36ed2..6459b84a3e59 100644
--- a/sw/inc/txtinet.hxx
+++ b/sw/inc/txtinet.hxx
@@ -25,7 +25,7 @@
 class SwTextNode;
 class SwCharFormat;
 
-/// SwTextAttr subclass that tracks the location of the wrapped SwFormatURL.
+/// SwTextAttr subclass that tracks the location of the wrapped 
SwFormatINetFormat.
 class SW_DLLPUBLIC SwTextINetFormat final: public SwTextAttrNesting, public 
SwClient
 {
 private:
diff --git a/sw/source/core/txtnode/txatbase.cxx 
b/sw/source/core/txtnode/txatbase.cxx
index 9fdd1212543f..df347860db11 100644
--- a/sw/source/core/txtnode/txatbase.cxx
+++ b/sw/source/core/txtnode/txatbase.cxx
@@ -173,6 +173,9 @@ void SwTextAttr::dumpAsXml(xmlTextWriterPtr pWriter) const
 case RES_TXTATR_REFMARK:
 GetRefMark().dumpAsXml(pWriter);
 break;
+case RES_TXTATR_INETFMT:
+GetINetFormat().dumpAsXml(pWriter);
+break;
 default:
 SAL_WARN("sw.core", "Unhandled TXTATR");
 break;


[Libreoffice-commits] core.git: sw/inc sw/source

2023-07-27 Thread Caolán McNamara (via logerrit)
 sw/inc/viewsh.hxx  |2 
 sw/source/core/inc/hffrm.hxx   |6 +
 sw/source/core/inc/pagefrm.hxx |3 
 sw/source/core/layout/paintfrm.cxx |  156 +++--
 sw/source/core/view/viewsh.cxx |   18 +++-
 5 files changed, 144 insertions(+), 41 deletions(-)

New commits:
commit ba0c39064fd97816774f4c06ca84c92c4a137450
Author: Caolán McNamara 
AuthorDate: Wed Jul 26 16:31:04 2023 +0100
Commit: Caolán McNamara 
CommitDate: Thu Jul 27 09:37:08 2023 +0200

Invalidate less on entering/leaving header/footer

Instead of invalidating the entire window, just invalidate the
parts that need to change.

Invalidate a sequence of Rectangles rather than bundle them
into a vcl::Region. Currently Window::Invalidate(const vcl::Region&...
does a LogicInvalidate(rRegion.GetBoundRect()) so get a mega rectangle
that covers everthing which is the opposite of what I want to get here.
It might be worth using GetRegionRectangles there.

Change-Id: Idc3f5f7d19dd57da725072ec4161d932c0c26902
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154973
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 8976452a0dc4..66eec0f5060e 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -188,6 +188,8 @@ class SW_DLLPUBLIC SwViewShell : public 
sw::Ring
 
 SAL_DLLPRIVATE void InvalidateAll(std::vector& rReasons);
 
+SAL_DLLPRIVATE void InvalidatePageAndHFSubsidiaryLines();
+
 protected:
 static ShellResource*  spShellRes;  ///< Resources for the Shell.
 static vcl::DeleteOnDeinit< std::shared_ptr > spCareDialog;  
  ///< Avoid this window.
diff --git a/sw/source/core/inc/hffrm.hxx b/sw/source/core/inc/hffrm.hxx
index 32af4dab9e30..4fed2517db1e 100644
--- a/sw/source/core/inc/hffrm.hxx
+++ b/sw/source/core/inc/hffrm.hxx
@@ -22,8 +22,13 @@
 
 #include "layfrm.hxx"
 
+class SwViewShell;
+
 class SwHeadFootFrame : public SwLayoutFrame
 {
+private:
+std::vector GetSubsidiaryLinesPolygons(const 
SwViewShell& rViewShell) const;
+
 protected:
 void FormatSize(SwTwips nUL, const SwBorderAttrs * pAttrs);
 void FormatPrt(SwTwips & nUL, const SwBorderAttrs * pAttrs);
@@ -37,6 +42,7 @@ public:
 virtual SwTwips ShrinkFrame( SwTwips,
bool bTst = false, bool bInfo = false ) 
override;
 virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) 
const override;
+void AddSubsidiaryLinesBounds(const SwViewShell& rViewShell, 
RectangleVector& rRects) const;
 };
 
 /// Header in the document layout, inside a page.
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index d85ddaecd116..53bf27a24bbc 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -123,6 +123,8 @@ class SW_DLLPUBLIC SwPageFrame final: public 
SwFootnoteBossFrame
 /// Calculate the content height of a page (without columns).
 size_t GetContentHeight(const tools::Long nTop, const tools::Long nBottom) 
const;
 
+std::vector GetSubsidiaryLinesPolygons(const 
SwViewShell& rViewShell) const;
+
 public:
 SwPageFrame( SwFrameFormat*, SwFrame*, SwPageDesc* );
 
@@ -189,6 +191,7 @@ public:
 
 void PaintDecorators( ) const;
 virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) 
const override;
+void AddSubsidiaryLinesBounds(const SwViewShell& rShell, RectangleVector& 
rRects) const;
 virtual void PaintBreak() const override;
 
 /// Paint line number etc.
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index 117ac8eb5e61..7c757e4d19ca 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -18,6 +18,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -6969,12 +6970,10 @@ static void lcl_RefreshLine( const SwLayoutFrame *pLay,
 }
 }
 
-static drawinglayer::primitive2d::Primitive2DContainer 
lcl_CreatePageAreaDelimiterPrimitives(
-const SwRect& rRect )
+static std::vector 
lcl_CreatePageAreaDelimiterPolygons(const SwRect& rRect)
 {
-drawinglayer::primitive2d::Primitive2DContainer aSeq( 4 );
+std::vector aPolygons;
 
-basegfx::BColor aLineColor = 
SwViewOption::GetCurrentViewOptions().GetDocBoundariesColor().getBColor();
 double nLineLength = 200.0; // in Twips
 
 Point aPoints[] = { rRect.TopLeft(), rRect.TopRight(), 
rRect.BottomRight(), rRect.BottomLeft() };
@@ -6994,30 +6993,39 @@ static drawinglayer::primitive2d::Primitive2DContainer 
lcl_CreatePageAreaDelimit
 aPolygon.append( aBPoint );
 aPolygon.append( aBPoint + aVertVector * nLineLength );
 
-aSeq[i] = new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
-std::move(aPolygon), aLineColor );
+aPolygons.emplace_back(aPolygon);
 }
 
-return aSeq;
+return aPolygons;
 }
 
-static 

[Libreoffice-commits] core.git: sw/inc sw/source sw/uiconfig

2023-07-26 Thread Heiko Tietze (via logerrit)
 sw/inc/docstat.hxx   |1 
 sw/source/core/doc/docstat.cxx   |2 
 sw/source/ui/dialog/wordcountdialog.cxx  |5 
 sw/source/uibase/inc/wordcountdialog.hxx |1 
 sw/source/uibase/uiview/view2.cxx|5 
 sw/uiconfig/swriter/ui/wordcount.ui  |  192 +--
 6 files changed, 122 insertions(+), 84 deletions(-)

New commits:
commit 90e3af16c12f94f487ff7516048a239db1d2ff7d
Author: Heiko Tietze 
AuthorDate: Tue Jul 18 15:02:58 2023 +0200
Commit: Heiko Tietze 
CommitDate: Wed Jul 26 10:37:35 2023 +0200

Resolves tdf#95329 - Number of comments in word count dialog

Change-Id: I29ca811065cce83f9c8630f79a2b78c2c3fe0da1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154581
Tested-by: Jenkins
Reviewed-by: Heiko Tietze 

diff --git a/sw/inc/docstat.hxx b/sw/inc/docstat.hxx
index fd53d80bfcbf..84476db5c065 100644
--- a/sw/inc/docstat.hxx
+++ b/sw/inc/docstat.hxx
@@ -36,6 +36,7 @@ struct SW_DLLPUBLIC SwDocStat
 sal_uLong   nAsianWord;
 sal_uLong   nChar;
 sal_uLong   nCharExcludingSpaces;
+sal_uLong   nComments;
 boolbModified;
 
 SwDocStat();
diff --git a/sw/source/core/doc/docstat.cxx b/sw/source/core/doc/docstat.cxx
index c34e8d094ba2..959c61833dd6 100644
--- a/sw/source/core/doc/docstat.cxx
+++ b/sw/source/core/doc/docstat.cxx
@@ -30,6 +30,7 @@ SwDocStat::SwDocStat() :
 nAsianWord(0),
 nChar(0),
 nCharExcludingSpaces(0),
+nComments(0),
 bModified(true)
 {}
 
@@ -45,6 +46,7 @@ void SwDocStat::Reset()
 nAsianWord = 0;
 nChar   = 0;
 nCharExcludingSpaces = 0;
+nComments = 0;
 bModified = true;
 }
 
diff --git a/sw/source/ui/dialog/wordcountdialog.cxx 
b/sw/source/ui/dialog/wordcountdialog.cxx
index a96e1c50b3be..b0b92a6ae1a7 100644
--- a/sw/source/ui/dialog/wordcountdialog.cxx
+++ b/sw/source/ui/dialog/wordcountdialog.cxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define IS_MOBILE_PHONE (comphelper::LibreOfficeKit::isActive() && 
SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())
 
@@ -64,6 +65,7 @@ void SwWordCountFloatDlg::SetValues(const SwDocStat& 
rCurrent, const SwDocStat&
 setValue(*m_xDocCharacterFT, rDoc.nChar, rLocaleData);
 setValue(*m_xDocCharacterExcludingSpacesFT, rDoc.nCharExcludingSpaces, 
rLocaleData);
 setValue(*m_xDocCjkcharsFT, rDoc.nAsianWord, rLocaleData);
+setValue(*m_xDocComments, rCurrent.nComments, rLocaleData);
 
 if (m_xStandardizedPagesLabelFT->get_visible())
 {
@@ -120,6 +122,7 @@ SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* 
_pBindings,
 , m_xCjkcharsLabelFT2(m_xBuilder->weld_label("cjkcharsft2"))
 , m_xStandardizedPagesLabelFT(m_xBuilder->weld_label("standardizedpages"))
 , 
m_xStandardizedPagesLabelFT2(m_xBuilder->weld_label("standardizedpages2"))
+, m_xDocComments(m_xBuilder->weld_label("docComments"))
 {
 showCJK(SvtCJKOptions::IsAnyEnabled());
 
showStandardizedPages(officecfg::Office::Writer::WordCount::ShowStandardizedPageCount::get());
@@ -143,6 +146,8 @@ void SwWordCountFloatDlg::UpdateCounts()
 aDocStat = rSh.GetUpdatedDocStat();
 rSh.EndAction();
 }
+SwPostItMgr* pPostItMgr = rSh.GetPostItMgr();
+aCurrCnt.nComments = pPostItMgr->end() - pPostItMgr->begin();
 SetValues(aCurrCnt, aDocStat);
 }
 }
diff --git a/sw/source/uibase/inc/wordcountdialog.hxx 
b/sw/source/uibase/inc/wordcountdialog.hxx
index c5b23f0c5307..ffa0b6478dcc 100644
--- a/sw/source/uibase/inc/wordcountdialog.hxx
+++ b/sw/source/uibase/inc/wordcountdialog.hxx
@@ -43,6 +43,7 @@ class SwWordCountFloatDlg final : public 
SfxModelessDialogController
 std::unique_ptr m_xCjkcharsLabelFT2;
 std::unique_ptr m_xStandardizedPagesLabelFT;
 std::unique_ptr m_xStandardizedPagesLabelFT2;
+std::unique_ptr m_xDocComments;
 
 public:
 SwWordCountFloatDlg(SfxBindings* pBindings,
diff --git a/sw/source/uibase/uiview/view2.cxx 
b/sw/source/uibase/uiview/view2.cxx
index 2903bbf19c03..0fb4f0e22a2b 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -1875,9 +1875,12 @@ void SwView::StateStatusLine(SfxItemSet )
 OUString aWordCount(SwResId(pResId));
 aWordCount = aWordCount.replaceAll("$1", aWordArg);
 aWordCount = aWordCount.replaceAll("$2", aCharArg);
-
 rSet.Put( SfxStringItem( FN_STAT_WORDCOUNT, aWordCount ) );
 
+SwPostItMgr* pPostItMgr = rShell.GetPostItMgr();
+if (pPostItMgr)
+selectionStats.nComments = pPostItMgr->end() - 
pPostItMgr->begin();
+
 SwWordCountWrapper *pWrdCnt = 
static_cast(GetViewFrame().GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
 if (pWrdCnt)
 pWrdCnt->SetCounts(selectionStats, documentStats);
diff --git 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-07-21 Thread Balazs Varga (via logerrit)
 sw/inc/AccessibilityCheckStrings.hrc |1 
 sw/source/core/access/AccessibilityCheck.cxx |   45 +++
 2 files changed, 46 insertions(+)

New commits:
commit 3f6ad9d3cdd6fe97989d85b7ec31fe9b8ae340cd
Author: Balazs Varga 
AuthorDate: Fri Jul 21 12:31:20 2023 +0200
Commit: Balazs Varga 
CommitDate: Fri Jul 21 17:57:36 2023 +0200

tdf#155000 - A11Y - Add warning message if content control in header/footer

Add warning message if content controls are in the header or footer.

Change-Id: Ie2a0a8aa1bfaf629f8e17828f2f99e590ea4e3af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154715
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
Reviewed-by: Balazs Varga 

diff --git a/sw/inc/AccessibilityCheckStrings.hrc 
b/sw/inc/AccessibilityCheckStrings.hrc
index 0186c062273b..1412f66372ec 100644
--- a/sw/inc/AccessibilityCheckStrings.hrc
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -37,6 +37,7 @@
 #define STR_HEADING_START   NC_("STR_HEADING_START", "Outline 
levels should start with level 1, instead of level %LEVEL_CURRENT%.")
 #define STR_FONTWORKS   NC_("STR_FONTWORKS", "Avoid Fontwork 
objects in your documents. Make sure you use it for samples or other 
meaningless text.")
 #define STR_TABLE_FORMATTINGNC_("STR_TABLE_FORMATTING", "Avoid 
using empty table cells for formatting.")
+#define STR_CONTENT_CONTROL_IN_HEADER_OR_FOOTER 
NC_("STR_CONTENT_CONTROL_IN_HEADER", "Avoid content controls in header or 
footer.")
 
 #define STR_DOCUMENT_DEFAULT_LANGUAGE   NC_("STR_DOCUMENT_DEFAULT_LANGUAGE", 
"Document default language is not set.")
 #define STR_STYLE_NO_LANGUAGE   NC_("STR_STYLE_NO_LANGUAGE", "Style 
“%STYLE_NAME%” has no language set.")
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index 4cde7b8a..9a990b0fa981 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -1224,6 +1224,50 @@ private:
 int m_prevLevel = 0;
 };
 
+/// Checking content controls in header or footer
+class ContentControlCheck : public NodeCheck
+{
+private:
+// Boolean indicating if content controls in header or footer warning is 
already triggered.
+bool m_bPrevPassed;
+
+public:
+ContentControlCheck(sfx::AccessibilityIssueCollection& rIssueCollection)
+: NodeCheck(rIssueCollection)
+, m_bPrevPassed(true)
+{
+}
+
+void check(SwNode* pCurrent) override
+{
+if (!m_bPrevPassed)
+return;
+
+const SwTextNode* pTextNode = pCurrent->GetTextNode();
+if (pTextNode)
+{
+if (pCurrent->FindHeaderStartNode() || 
pCurrent->FindFooterStartNode())
+{
+const SwpHints* pHts = pTextNode->GetpSwpHints();
+if (pHts)
+{
+for (size_t i = 0; i < pHts->Count(); ++i)
+{
+const SwTextAttr* pHt = pHts->Get(i);
+if (pHt->Which() == RES_TXTATR_CONTENTCONTROL)
+{
+m_bPrevPassed = false;
+lclAddIssue(m_rIssueCollection,
+
SwResId(STR_CONTENT_CONTROL_IN_HEADER_OR_FOOTER));
+break;
+}
+}
+}
+}
+}
+}
+};
+
 class DocumentCheck : public BaseCheck
 {
 public:
@@ -1458,6 +1502,7 @@ void AccessibilityCheck::init()
 m_aNodeChecks.emplace_back(new SpaceSpacingCheck(m_aIssueCollection));
 m_aNodeChecks.emplace_back(new FakeFootnoteCheck(m_aIssueCollection));
 m_aNodeChecks.emplace_back(new FakeCaptionCheck(m_aIssueCollection));
+m_aNodeChecks.emplace_back(new 
ContentControlCheck(m_aIssueCollection));
 }
 }
 


[Libreoffice-commits] core.git: sw/inc sw/source

2023-07-19 Thread Balazs Varga (via logerrit)
 sw/inc/AccessibilityCheckStrings.hrc |1 +
 sw/source/core/access/AccessibilityCheck.cxx |   19 ---
 2 files changed, 13 insertions(+), 7 deletions(-)

New commits:
commit 5c43adc8e6f9948038be6c1fb20f4ac5718a74ea
Author: Balazs Varga 
AuthorDate: Thu Jul 6 17:42:38 2023 +0200
Commit: Balazs Varga 
CommitDate: Wed Jul 19 09:45:55 2023 +0200

tdf#156139 - A11Y - Improve issue text when document starts with wrong

outline level.

Change-Id: I68bff66171af61089f0f8b06a0842f1f3dfdd7bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154139
Tested-by: Jenkins
Reviewed-by: Balazs Varga 

diff --git a/sw/inc/AccessibilityCheckStrings.hrc 
b/sw/inc/AccessibilityCheckStrings.hrc
index 0efaee64ca4b..0186c062273b 100644
--- a/sw/inc/AccessibilityCheckStrings.hrc
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -34,6 +34,7 @@
 #define STR_FLOATING_TEXT   NC_("STR_FLOATING_TEXT", "Avoid 
floating text.")
 #define STR_HEADING_IN_TABLENC_("STR_HEADING_IN_TABLE", "Tables 
must not contain headings.")
 #define STR_HEADING_ORDER   NC_("STR_HEADING_ORDER", "A heading 
with outline level %LEVEL_CURRENT% must not follow a heading with outline level 
%LEVEL_PREV%.")
+#define STR_HEADING_START   NC_("STR_HEADING_START", "Outline 
levels should start with level 1, instead of level %LEVEL_CURRENT%.")
 #define STR_FONTWORKS   NC_("STR_FONTWORKS", "Avoid Fontwork 
objects in your documents. Make sure you use it for samples or other 
meaningless text.")
 #define STR_TABLE_FORMATTINGNC_("STR_TABLE_FORMATTING", "Avoid 
using empty table cells for formatting.")
 
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index 5dc306192ce0..7b63729550a1 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -1196,15 +1196,20 @@ public:
 if (currentLevel - m_prevLevel > 1)
 {
 // Preparing and posting a warning.
-OUString resultString = SwResId(STR_HEADING_ORDER);
+OUString resultString;
+if (!m_prevLevel)
+{
+resultString = SwResId(STR_HEADING_START);
+}
+else
+{
+resultString = SwResId(STR_HEADING_ORDER);
+resultString
+= resultString.replaceAll("%LEVEL_PREV%", 
OUString::number(m_prevLevel));
+}
 resultString
 = resultString.replaceAll("%LEVEL_CURRENT%", 
OUString::number(currentLevel));
-resultString = resultString.replaceAll("%LEVEL_PREV%", 
OUString::number(m_prevLevel));
-
-auto pIssue = lclAddIssue(m_rIssueCollection, resultString);
-pIssue->setIssueObject(IssueObject::TEXT);
-pIssue->setDoc(pCurrent->GetDoc());
-pIssue->setNode(pCurrent);
+lclAddIssue(m_rIssueCollection, resultString);
 }
 
 // Updating previous level.


[Libreoffice-commits] core.git: sw/inc sw/source

2023-07-14 Thread Mike Kaganski (via logerrit)
 sw/inc/anchoreddrawobject.hxx |2 +-
 sw/source/core/draw/dcontact.cxx  |4 +---
 sw/source/core/inc/flyfrm.hxx |2 +-
 sw/source/core/layout/flylay.cxx  |   24 ++--
 sw/source/core/layout/frmtool.cxx |5 +
 sw/source/core/layout/tabfrm.cxx  |   11 ++-
 6 files changed, 8 insertions(+), 40 deletions(-)

New commits:
commit a051601a4cef506bc257c647cbce6288ba8068d4
Author: Mike Kaganski 
AuthorDate: Fri Jul 14 21:10:24 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Jul 14 23:22:09 2023 +0200

Use SwAnchoredObject::RegisterAtPage

Change-Id: Icdc8266656bea5b44ce744457ad6a1d0ba87c473
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154447
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/anchoreddrawobject.hxx b/sw/inc/anchoreddrawobject.hxx
index eb457701a98d..609582d4d326 100644
--- a/sw/inc/anchoreddrawobject.hxx
+++ b/sw/inc/anchoreddrawobject.hxx
@@ -94,7 +94,6 @@ class SwAnchoredDrawObject final : public SwAnchoredObject
 page frame
 */
 virtual void RegisterAtCorrectPage() override;
-virtual void RegisterAtPage(SwPageFrame &) override;
 
 virtual bool SetObjTop_( const SwTwips _nTop) override;
 virtual bool SetObjLeft_( const SwTwips _nLeft) override;
@@ -109,6 +108,7 @@ class SwAnchoredDrawObject final : public SwAnchoredObject
 // declaration of pure virtual methods of base class 
 virtual void MakeObjPos() override;
 virtual void InvalidateObjPos() override;
+virtual void RegisterAtPage(SwPageFrame&) override;
 bool IsValidPos() const
 {
 return mbValidPos;
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index e5b0c3d50314..2de9544640f3 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -2074,9 +2074,7 @@ void SwDrawContact::ChkPage()
 else
 {
 // --> #i28701# - use methods  and 
-if ( GetPageFrame() )
-GetPageFrame()->RemoveDrawObjFromPage( maAnchoredDrawObj );
-pPg->AppendDrawObjToPage( maAnchoredDrawObj );
+maAnchoredDrawObj.RegisterAtPage(*pPg);
 maAnchoredDrawObj.SetPageFrame( pPg );
 }
 }
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index d3815a82835a..bbcf2845e5d7 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -156,7 +156,6 @@ protected:
 page frame
 */
 virtual void RegisterAtCorrectPage() override;
-virtual void RegisterAtPage(SwPageFrame &) override;
 
 virtual bool SetObjTop_( const SwTwips _nTop ) override;
 virtual bool SetObjLeft_( const SwTwips _nLeft ) override;
@@ -267,6 +266,7 @@ public:
 // #i26791# - pure virtual methods of base class 
 virtual void MakeObjPos() override;
 virtual void InvalidateObjPos() override;
+virtual void RegisterAtPage(SwPageFrame&) override;
 
 virtual SwFrameFormat& GetFrameFormat() override;
 virtual const SwFrameFormat& GetFrameFormat() const override;
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 40b8547811fd..8c40a22fe0cd 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -900,11 +900,7 @@ void SwPageFrame::AppendFlyToPage( SwFlyFrame *pNew )
 // #i87493#
 if ( pTmpObj->GetPageFrame() != this )
 {
-if ( pTmpObj->GetPageFrame() != nullptr )
-{
-pTmpObj->GetPageFrame()->RemoveDrawObjFromPage( *pTmpObj );
-}
-AppendDrawObjToPage( *pTmpObj );
+pTmpObj->RegisterAtPage(*this);
 }
 }
 }
@@ -1057,23 +1053,7 @@ void SwPageFrame::MoveFly( SwFlyFrame *pToMove, 
SwPageFrame *pDest )
 SwSortedObjs  = *pToMove->GetDrawObjs();
 for (SwAnchoredObject* pObj : rObjs)
 {
-if ( auto pFly = pObj->DynCastFlyFrame() )
-{
-if ( pFly->IsFlyFreeFrame() )
-{
-// #i28701# - use new method 
-SwPageFrame* pPageFrame = pFly->GetPageFrame();
-if ( pPageFrame )
-pPageFrame->MoveFly( pFly, pDest );
-else
-pDest->AppendFlyToPage( pFly );
-}
-}
-else if ( dynamic_cast( pObj) !=  nullptr 
)
-{
-RemoveDrawObjFromPage( *pObj );
-pDest->AppendDrawObjToPage( *pObj );
-}
+pObj->RegisterAtPage(*pDest);
 }
 }
 
diff --git a/sw/source/core/layout/frmtool.cxx 
b/sw/source/core/layout/frmtool.cxx
index 6b1647b5..9c8d6cbe85bf 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -3209,10 +3209,7 @@ static void lcl_Regist( SwPageFrame *pPage, const 
SwFrame *pAnch )
 // #i87493#
 if ( pPage != 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-07-12 Thread Mike Kaganski (via logerrit)
 sw/inc/doc.hxx |2 +-
 sw/inc/fmtmeta.hxx |2 +-
 sw/source/core/docnode/ndtbl.cxx   |   15 ---
 sw/source/core/txtnode/fmtatr2.cxx |2 +-
 4 files changed, 7 insertions(+), 14 deletions(-)

New commits:
commit 375d423573cf237fb082ed2b4908d8067036d8b2
Author: Mike Kaganski 
AuthorDate: Wed Jul 12 12:50:44 2023 +0300
Commit: Mike Kaganski 
CommitDate: Wed Jul 12 14:20:39 2023 +0200

Simplify a bit

Change-Id: I452619c5a1d0b414f09c1e3178fac9905b6d0374
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154349
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 9fce6c92e4c9..a84df42b8c87 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1276,7 +1276,7 @@ public:
 SwTableLineFormat* MakeTableLineFormat();
 
 // helper function: cleanup before checking number value
-bool IsNumberFormat( std::u16string_view aString, sal_uInt32& F_Index, 
double& fOutNumber);
+bool IsNumberFormat( const OUString& aString, sal_uInt32& F_Index, double& 
fOutNumber);
 // Check if box has numerical value. Change format of box if required.
 void ChkBoxNumFormat( SwTableBox& rCurrentBox, bool bCallUpdate );
 void SetTableBoxFormulaAttrs( SwTableBox& rBox, const SfxItemSet& rSet );
diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx
index 93b5f9f49cb5..b7f9758484c4 100644
--- a/sw/inc/fmtmeta.hxx
+++ b/sw/inc/fmtmeta.hxx
@@ -182,7 +182,7 @@ private:
 sal_uInt32 m_nNumberFormat;
 bool   m_bIsFixedLanguage;
 
-sal_uInt32 GetNumberFormat(std::u16string_view aContent) const;
+sal_uInt32 GetNumberFormat(const OUString& aContent) const;
 void SetNumberFormat(sal_uInt32 nNumberFormat);
 bool IsFixedLanguage() const{ return m_bIsFixedLanguage; }
 void SetIsFixedLanguage(bool b) { m_bIsFixedLanguage = b; }
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 07216640f354..08775066cb91 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -4007,21 +4007,14 @@ void SwDoc::SetColRowWidthHeight( SwTableBox& 
rCurrentBox, TableChgWidthHeightTy
 }
 }
 
-bool SwDoc::IsNumberFormat( std::u16string_view aString, sal_uInt32& F_Index, 
double& fOutNumber )
+bool SwDoc::IsNumberFormat( const OUString& aString, sal_uInt32& F_Index, 
double& fOutNumber )
 {
-if( aString.size() > 308 ) // optimization matches svl:IsNumberFormat 
arbitrary value
+if( aString.getLength() > 308 ) // optimization matches svl:IsNumberFormat 
arbitrary value
 return false;
 
 // remove any comment anchor marks
-OUStringBuffer sStringBuffer(aString);
-sal_Int32 nCommentPosition = sStringBuffer.indexOf( CH_TXTATR_INWORD );
-while( nCommentPosition != -1 )
-{
-sStringBuffer.remove( nCommentPosition, 1 );
-nCommentPosition = sStringBuffer.indexOf( CH_TXTATR_INWORD, 
nCommentPosition );
-}
-
-return GetNumberFormatter()->IsNumberFormat( 
sStringBuffer.makeStringAndClear(), F_Index, fOutNumber );
+return GetNumberFormatter()->IsNumberFormat(
+aString.replaceAll(OUStringChar(CH_TXTATR_INWORD), u""), F_Index, 
fOutNumber);
 }
 
 void SwDoc::ChkBoxNumFormat( SwTableBox& rBox, bool bCallUpdate )
diff --git a/sw/source/core/txtnode/fmtatr2.cxx 
b/sw/source/core/txtnode/fmtatr2.cxx
index c776116a4ecc..2e5a562e0690 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -767,7 +767,7 @@ void MetaField::GetPrefixAndSuffix(
 }
 }
 
-sal_uInt32 MetaField::GetNumberFormat(std::u16string_view aContent) const
+sal_uInt32 MetaField::GetNumberFormat(const OUString& aContent) const
 {
 //TODO: this probably lacks treatment for some special cases
 sal_uInt32 nNumberFormat( m_nNumberFormat );


[Libreoffice-commits] core.git: sw/inc sw/source vcl/qa

2023-07-11 Thread Michael Stahl (via logerrit)
 sw/inc/EnhancedPDFExportHelper.hxx |5 
 sw/source/core/layout/paintfrm.cxx |   14 
 sw/source/core/text/EnhancedPDFExportHelper.cxx|   45 ++-
 sw/source/core/text/frmpaint.cxx   |2 
 sw/source/core/text/itrpaint.cxx   |6 
 vcl/qa/cppunit/pdfexport/data/image-hyperlink-alttext.fodt |  195 +
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |  130 
 7 files changed, 381 insertions(+), 16 deletions(-)

New commits:
commit f2d5653a6792a19e9a45d34ac9dce22e717b8cbf
Author: Michael Stahl 
AuthorDate: Mon Jul 10 17:39:03 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue Jul 11 11:10:14 2023 +0200

tdf#154939 sw: PDF/UA export: produce Link StructElem inside Figure

... for a fly frame with a hyperlink set.

  Specification: ISO 14289-1:2014, Clause: 7.18.5, Test number: 1
  Links shall be tagged according to ISO 32000-1:2008, 14.8.4.4.2, Link 
Element.
  A Link annotation is nested within null tag instead of Link

Change-Id: I7a2bef8d6100adffb1f40085bba8f18fc68bd8d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154280
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx 
b/sw/inc/EnhancedPDFExportHelper.hxx
index e928e417a0f0..a52a03f786ae 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -103,7 +103,10 @@ struct Num_Info
 struct Frame_Info
 {
 const SwFrame& mrFrame;
-Frame_Info( const SwFrame& rFrame ) : mrFrame( rFrame ) {};
+bool const m_isLink;
+
+Frame_Info(const SwFrame& rFrame, bool const isLink)
+: mrFrame(rFrame), m_isLink(isLink) {}
 };
 
 struct Por_Info
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index 47e56b390712..69f78db19c59 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3503,8 +3504,19 @@ SwShortCut::SwShortCut( const SwFrame& rFrame, const 
SwRect& rRect )
 void SwLayoutFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const) const
 {
 // #i16816# tagged pdf support
-Frame_Info aFrameInfo( *this );
+Frame_Info aFrameInfo(*this, false);
 SwTaggedPDFHelper aTaggedPDFHelper( nullptr, , nullptr, 
rRenderContext );
+::std::optional oTaggedLink;
+if (IsFlyFrame())
+{
+// tdf#154939 Link nested inside Figure
+auto const pItem(GetFormat()->GetAttrSet().GetItemIfSet(RES_URL));
+if (pItem && !pItem->GetURL().isEmpty())
+{
+Frame_Info linkInfo(*this, true);
+oTaggedLink.emplace(nullptr, , nullptr, rRenderContext);
+}
+}
 
 const SwFrame *pFrame = Lower();
 if ( !pFrame )
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 25be18e0d521..7b5732e925da 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -408,7 +408,7 @@ bool SwTaggedPDFHelper::CheckReopenTag()
 {
 pKeyFrame = 
 }
-else if ( rFrame.IsFlyFrame() )
+else if (rFrame.IsFlyFrame() && !mpFrameInfo->m_isLink)
 {
 const SwFormatAnchor& rAnchor =
 static_cast()->GetFormat()->GetAnchor();
@@ -532,6 +532,23 @@ void SwTaggedPDFHelper::EndTag()
 #endif
 }
 
+namespace {
+
+// link the link annotation to the link structured element
+void LinkLinkLink(vcl::PDFExtOutDevData & rPDFExtOutDevData, SwRect const& 
rRect)
+{
+const LinkIdMap& rLinkIdMap = 
SwEnhancedPDFExportHelper::GetLinkIdMap();
+const Point aCenter = rRect.Center();
+auto aIter = std::find_if(rLinkIdMap.begin(), rLinkIdMap.end(),
+[](const IdMapEntry& rEntry) { return 
rEntry.first.Contains(aCenter); });
+if (aIter != rLinkIdMap.end())
+{
+sal_Int32 nLinkId = (*aIter).second;
+
rPDFExtOutDevData.SetStructureAttributeNumerical(vcl::PDFWriter::LinkAnnotation,
 nLinkId);
+}
+}
+}
+
 // Sets the attributes according to the structure type.
 void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType )
 {
@@ -806,6 +823,12 @@ void SwTaggedPDFHelper::SetAttributes( 
vcl::PDFWriter::StructElement eType )
 }
 }
 }
+
+if (mpFrameInfo->m_isLink)
+{
+SwRect const aRect(mpFrameInfo->mrFrame.getFrameArea());
+LinkLinkLink(*mpPDFExtOutDevData, aRect);
+}
 }
 
 /*
@@ -906,17 +929,9 @@ void SwTaggedPDFHelper::SetAttributes( 
vcl::PDFWriter::StructElement eType )
 
 if ( bLinkAttribute )
 {
-const LinkIdMap& rLinkIdMap = 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-07-06 Thread Mike Kaganski (via logerrit)
 sw/inc/autostyle_helper.hxx   |2 +-
 sw/source/core/doc/swstylemanager.cxx |5 +
 sw/source/core/unocore/unoobj.cxx |2 +-
 sw/source/core/unocore/unostyle.cxx   |2 +-
 4 files changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 732d0e89363abb009ff13a23957ab7257a378a11
Author: Mike Kaganski 
AuthorDate: Thu Jul 6 14:04:12 2023 +0300
Commit: Mike Kaganski 
CommitDate: Thu Jul 6 14:41:31 2023 +0200

Related: tdf#141969 Make sure to use SwAttrSet for paragraph autostyles

See 
https://gerrit.libreoffice.org/c/core/+/153947/8#message-45a748bf68235bf143bec07cda2d704abb2b140f

> This started to cause e.g.  CppunitTest_sw_rtfexport3  to fail with
>   /sw/inc/node.hxx:493:53: runtime error: downcast of address 
0x606000617540 which does not point to an object of type 'const SwAttrSet'
>   0x606000617540: note: object is of type 'SfxItemSet'
>00 00 00 00  30 15 0f a9 a6 7f 00 00  50 6a 4a 01 40 60 00 00  c8 98 
0f 00 30 61 00 00  80 30 6c 00
> ^~~
> vptr for 'SfxItemSet'
>   #0 0x7fa671d1b765 in SwContentNode::GetpSwAttrSet() const 
/sw/inc/node.hxx:493:53
>   #1 0x7fa671d7159e in SwContentNode::GetSwAttrSet() const 
/sw/inc/node.hxx:729:25
>   #2 0x7fa673be6c4a in 
SwDoc::TextToTable(std::__debug::vector >, std::allocator > > > const&) 
/sw/source/core/docnode/ndtbl.cxx:1236:51
>   #3 0x7fa6775f46a5 in 
SwXText::convertToTable(com::sun::star::uno::Sequence
 > > > const&, 
com::sun::star::uno::Sequence
 > > const&, 
com::sun::star::uno::Sequence
 > const&, com::sun::star::uno::Sequence 
const&) /sw/source/core/unocore/unotext.cxx:2279:51
>   #4 0x7fa6775fba56 in non-virtual thunk to 
SwXText::convertToTable(com::sun::star::uno::Sequence
 > > > const&, 
com::sun::star::uno::Sequence
 > > const&, 
com::sun::star::uno::Sequence
 > const&, com::sun::star::uno::Sequence 
const&) /sw/source/core/unocore/unotext.cxx
>   #5 0x7fa61c596a81 in 
writerfilter::dmapper::DomainMapperTableHandler::endTable(unsigned int, bool) 
/writerfilter/source/dmapper/DomainMapperTableHandler.cxx:1481:35
>   #6 0x7fa61cf2fdee in 
writerfilter::dmapper::TableManager::resolveCurrentTable() 
/writerfilter/source/dmapper/TableManager.cxx:409:33
>   #7 0x7fa61cf30bb1 in 
writerfilter::dmapper::TableManager::endLevel() 
/writerfilter/source/dmapper/TableManager.cxx:427:9
>   #8 0x7fa61c642f37 in 
writerfilter::dmapper::DomainMapperTableManager::endLevel() 
/writerfilter/source/dmapper/DomainMapperTableManager.cxx:496:19
>   #9 0x7fa61cf2cae1 in 
writerfilter::dmapper::TableManager::endParagraphGroup() 
/writerfilter/source/dmapper/TableManager.cxx:338:9
> ()

Regression after commit b036e563e699595fa7625888f11ab0c76f1abd66
(tdf#141969: use paragraph autostyle to mimic Word's table style,
2023-07-04).

Change-Id: Idc905cdea35bd0c5f3cfbd562d63894f44e64446
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154106
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/autostyle_helper.hxx b/sw/inc/autostyle_helper.hxx
index 9336085db02e..956bf01a8a62 100644
--- a/sw/inc/autostyle_helper.hxx
+++ b/sw/inc/autostyle_helper.hxx
@@ -26,6 +26,6 @@ class SwDoc;
 std::shared_ptr
 PropValuesToAutoStyleItemSet(SwDoc& rDoc, IStyleAccess::SwAutoStyleFamily 
eFamily,
  const 
css::uno::Sequence& Values,
- SfxItemSet& rSet);
+ SwAttrSet& rSet);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/sw/source/core/doc/swstylemanager.cxx 
b/sw/source/core/doc/swstylemanager.cxx
index 38f79d679af3..7f73555fc8ff 100644
--- a/sw/source/core/doc/swstylemanager.cxx
+++ b/sw/source/core/doc/swstylemanager.cxx
@@ -20,6 +20,7 @@
 #include "swstylemanager.hxx"
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -97,6 +98,7 @@ std::shared_ptr 
SwStyleManager::getAutomaticStyle( const SfxItemSet&

IStyleAccess::SwAutoStyleFamily eFamily,
const 
OUString* pParentName )
 {
+assert(eFamily != IStyleAccess::AUTO_STYLE_PARA || dynamic_cast());
 StylePool& rAutoPool
 = eFamily == IStyleAccess::AUTO_STYLE_CHAR ? m_aAutoCharPool : 
m_aAutoParaPool;
 return rAutoPool.insertItemSet( rSet, pParentName );
@@ -105,6 +107,7 @@ std::shared_ptr 
SwStyleManager::getAutomaticStyle( const SfxItemSet&
 std::shared_ptr SwStyleManager::cacheAutomaticStyle( const 
SfxItemSet& rSet,

IStyleAccess::SwAutoStyleFamily eFamily )
 {
+assert(eFamily != IStyleAccess::AUTO_STYLE_PARA || dynamic_cast());
 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-07-05 Thread Mike Kaganski (via logerrit)
 sw/inc/crsrsh.hxx|   11 ++-
 sw/source/core/crsr/crstrvl.cxx  |   13 +++--
 sw/source/uibase/uiview/viewport.cxx |8 +++-
 3 files changed, 20 insertions(+), 12 deletions(-)

New commits:
commit 7e997097eb0e36bbb6f1eb8519acfc4e8eb6337a
Author: Mike Kaganski 
AuthorDate: Wed Jul 5 18:08:54 2023 +0300
Commit: Mike Kaganski 
CommitDate: Thu Jul 6 06:05:34 2023 +0200

tdf#155462: fix the scrollbar tooltip text

Over the time when it was completely unused, it regressed in a couple
of aspects:

1. It got assembled in incorrect order: instead of appending chapter,
   it got prepended in commit 832e5aadbff006ec24959162c29756fe2b1982be
   (Related: fdo#38838 remove UniString::SearchAndReplaceAll, 2013-10-08);
2. It started to show chapters, only when the respective heading are
   at the very top of screen, and show only page elsewhere, likely in
   commit 835cd06a047717dfe5e0f117959f3c042e13b21b (tdf#38093 Writer
   outline folding - outline visibility and on canvas ui, 2020-07-30),
   where a call to SwNode::FindOutlineNodeOfLevel was replaced with
   SwOutlineNodes::Seek_Entry in SwCursorShell::GetContentAtPos.

Change-Id: I3f427f7ecb3b6c58a441220c555b22e765a533c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154077
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index cfba5cb852c1..233edb71c240 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -88,15 +88,16 @@ enum class IsAttrAtPos
 SmartTag = 0x0800,
 FormControl  = 0x1000,
 TableRedline = 0x2000,
-TableColRedline  = 0x4000
+TableColRedline  = 0x4000,
 #ifdef DBG_UTIL
-,CurrAttrs   = 0x8000///< only for debugging
-,TableBoxValue   = 0x1   ///< only for debugging
+CurrAttrs   = 0x8000,///< only for debugging
+TableBoxValue   = 0x1,   ///< only for debugging
 #endif
-, ContentControl = 0x2
+ContentControl = 0x2,
+AllowContaining = 0x4, // With Outline, finds an outline node for 
non-outline position
 };
 namespace o3tl {
-template<> struct typed_flags : is_typed_flags {};
+template<> struct typed_flags : is_typed_flags {};
 }
 
 struct SwContentAtPos
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index a1656233cfc9..d5e430bb8711 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1466,8 +1466,17 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
 && !rNds.GetOutLineNds().empty() )
 {
 // only for nodes in outline nodes
-SwOutlineNodes::size_type nPos;
-if(rNds.GetOutLineNds().Seek_Entry(pTextNd, ))
+SwOutlineNodes::size_type nPos = 0;
+bool bFoundOutline = rNds.GetOutLineNds().Seek_Entry(pTextNd, );
+if (!bFoundOutline && nPos && (IsAttrAtPos::AllowContaining & 
rContentAtPos.eContentAtPos))
+{
+// nPos points to the first found outline node not before pTextNd, 
or to end();
+// when bFoundOutline is false, and nPos is not 0, it means that 
there were
+// outline nodes before pTextNd, and nPos-1 points to the last of 
those.
+pTextNd = rNds.GetOutLineNds()[nPos - 1]->GetTextNode();
+bFoundOutline = true;
+}
+if (bFoundOutline)
 {
 rContentAtPos.eContentAtPos = IsAttrAtPos::Outline;
 rContentAtPos.sStr = sw::GetExpandTextMerged(GetLayout(), 
*pTextNd, true, false, ExpandMode::ExpandFootnote);
diff --git a/sw/source/uibase/uiview/viewport.cxx 
b/sw/source/uibase/uiview/viewport.cxx
index 415771aae940..306f8844dda8 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -714,16 +714,14 @@ IMPL_LINK(SwView, VertScrollHdl, weld::Scrollbar&, 
rScrollbar, void)
 aRect.SetBottom( aRect.Top() );
 
 OUString sPageStr( GetPageStr( nPhNum, nVirtNum, 
sDisplay ));
-SwContentAtPos aCnt( IsAttrAtPos::Outline );
+SwContentAtPos aCnt(IsAttrAtPos::Outline | 
IsAttrAtPos::AllowContaining);
 bool bSuccess = m_pWrtShell->GetContentAtPos(aPos, 
aCnt);
 if (bSuccess && !aCnt.sStr.isEmpty())
 {
-sPageStr += "  - ";
 sal_Int32 nChunkLen = 
std::min(aCnt.sStr.getLength(), 80);
 std::u16string_view sChunk = aCnt.sStr.subView(0, 
nChunkLen);
-sPageStr = sChunk + sPageStr;
-sPageStr = sPageStr.replace('\t', ' ');
-sPageStr = sPageStr.replace(0x0a, ' ');
+sPageStr = sPageStr + "  - " + sChunk;
+sPageStr = 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-06-30 Thread Noel Grandin (via logerrit)
 sw/inc/viewsh.hxx|3 ---
 sw/source/core/view/vnew.cxx |4 ++--
 sw/source/uibase/uiview/viewport.cxx |2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)

New commits:
commit 396f7dfc17ceb24de8cfa0a9480943f7b397f8f4
Author: Noel Grandin 
AuthorDate: Fri Jun 30 15:33:43 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Jun 30 20:29:05 2023 +0200

mbFrameView is dead since

commit 407731c9f403c35357a0d1428c9b99835f79a5f7
Author: Noel Grandin 
Date:   Tue Jul 21 10:44:17 2015 +0200
loplugin:unusedmethods sw

removed the SetFrameView() method, which in turn
was dead since

commit 1c6da69ba2bc437d826573c7909a220290a67311
Author: Frank Schoenheit [fs] 
Date:   Mon Nov 30 12:56:05 2009 +0100
[CWS autorecovery] removed some dead/unused stuff

Change-Id: I6e74dd7609ecd6ce459b6397a852caa6bde7fac8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153812
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 583b795a1b22..1fb861748f20 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -153,7 +153,6 @@ class SW_DLLPUBLIC SwViewShell : public 
sw::Ring
 // in this case MakeVisible is ineffectual.
 bool  mbInEndAction :1;  // Avoid problems, cf. viewsh.cxx.
 bool  mbPreview :1;  // If true it is a Preview-SwViewShell.
-bool  mbFrameView   :1;  // If true it is a  (HTML-)Frame.
 bool  mbEnableSmooth:1;  // Disable SmoothScroll, e.g. for drag
 // of scrollbars.
 bool  mbShowHeaderSeparator:1; ///< Flag to say that we are showing 
the header control
@@ -515,8 +514,6 @@ public:
 
 bool IsPreview() const { return mbPreview; }
 
-bool IsFrameView()  const { return mbFrameView; }
-
 // Invalidates pages and contents.
 // When bSizeChanged==true, adds/removes
 // headers and footers as necessary.
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index 0d097f0a9475..613a15df633b 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -168,7 +168,7 @@ SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window 
*pWindow,
 //  during construction of  instance
 mbInConstructor = true;
 
-mbPaintInProgress = mbViewLocked = mbInEndAction = mbFrameView = false;
+mbPaintInProgress = mbViewLocked = mbInEndAction = false;
 mbPaintWorks = mbEnableSmooth = true;
 mbPreview = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );
 
@@ -237,7 +237,7 @@ SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window 
*pWindow,
 mbInConstructor = true;
 
 mbPaintWorks = mbEnableSmooth = true;
-mbPaintInProgress = mbViewLocked = mbInEndAction = mbFrameView = false;
+mbPaintInProgress = mbViewLocked = mbInEndAction = false;
 mbPreview = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );
 
 if( nFlags & VSHELLFLAG_SHARELAYOUT )
diff --git a/sw/source/uibase/uiview/viewport.cxx 
b/sw/source/uibase/uiview/viewport.cxx
index 5446c708a5e9..415771aae940 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -294,7 +294,7 @@ void SwView::SetVisArea( const Point , bool 
bUpdateScrollbar )
 // Let's see how far we get with half BrushSize.
 Point aPt = GetEditWin().LogicToPixel( rPt );
 #if HAVE_FEATURE_DESKTOP
-const tools::Long nTmp = GetWrtShell().IsFrameView() ? 4 : 8;
+const tools::Long nTmp = 8;
 aPt.AdjustX( -(aPt.X() % nTmp) );
 aPt.AdjustY( -(aPt.Y() % nTmp) );
 #endif


[Libreoffice-commits] core.git: sw/inc sw/source

2023-06-23 Thread Balazs Varga (via logerrit)
 sw/inc/AccessibilityCheckStrings.hrc|1 
 sw/inc/OnlineAccessibilityCheck.hxx |6 
 sw/source/core/access/AccessibilityCheck.cxx|6 ++--
 sw/source/core/access/AccessibilityIssue.cxx|   28 ++--
 sw/source/core/inc/AccessibilityIssue.hxx   |1 
 sw/source/core/txtnode/OnlineAccessibilityCheck.cxx |   15 ++
 sw/source/uibase/uiview/view2.cxx   |3 +-
 7 files changed, 55 insertions(+), 5 deletions(-)

New commits:
commit bbb104ea2b8f3e48273f316cfad406e904a2f331
Author: Balazs Varga 
AuthorDate: Tue Jun 20 15:38:40 2023 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Fri Jun 23 10:17:29 2023 +0200

tdf#155503 - A11Y sidebar: Add quick fix action to set document title

Add fix button to set the document title.
Fix updates issue of document level changes.

Change-Id: Ibab5cab3b595de4df68c3022a5864b2d2d4bed2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153352
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 

diff --git a/sw/inc/AccessibilityCheckStrings.hrc 
b/sw/inc/AccessibilityCheckStrings.hrc
index 12e2e1fa2b8d..0efaee64ca4b 100644
--- a/sw/inc/AccessibilityCheckStrings.hrc
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -40,6 +40,7 @@
 #define STR_DOCUMENT_DEFAULT_LANGUAGE   NC_("STR_DOCUMENT_DEFAULT_LANGUAGE", 
"Document default language is not set.")
 #define STR_STYLE_NO_LANGUAGE   NC_("STR_STYLE_NO_LANGUAGE", "Style 
“%STYLE_NAME%” has no language set.")
 #define STR_DOCUMENT_TITLE  NC_("STR_DOCUMENT_TITLE", "Document 
title is not set.")
+#define STR_ENTER_DOCUMENT_TITLENC_("STR_ENTER_DOCUMENT_TITLE", "Enter 
document title:")
 
 #define STR_ENTER_ALT   NC_("STR_ENTER_ALT", "Enter 
alternative text:")
 
diff --git a/sw/inc/OnlineAccessibilityCheck.hxx 
b/sw/inc/OnlineAccessibilityCheck.hxx
index fc158e28db7e..1055c7e67d53 100644
--- a/sw/inc/OnlineAccessibilityCheck.hxx
+++ b/sw/inc/OnlineAccessibilityCheck.hxx
@@ -67,8 +67,14 @@ public:
 OnlineAccessibilityCheck(SwDoc& rDocument);
 void update(SwPosition const& rNewPos);
 void resetAndQueue(SwNode* pNode);
+void resetAndQueueDocumentLevel();
 void updateCheckerActivity();
 sal_Int32 getNumberOfAccessibilityIssues() { return 
m_nAccessibilityIssues; }
+sal_Int32 getNumberOfDocumentLevelAccessibilityIssues()
+{
+return m_pDocumentAccessibilityIssues ? 
m_pDocumentAccessibilityIssues->getIssues().size()
+  : sal_Int32(0);
+}
 };
 
 } // end sw
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index 802ad2c8dea3..ec2a101795e5 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -1263,8 +1263,10 @@ public:
 OUString sTitle = xDocumentProperties->getTitle();
 if (o3tl::trim(sTitle).empty())
 {
-lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_TITLE),
-sfx::AccessibilityIssueID::DOCUMENT_TITLE);
+auto pIssue = lclAddIssue(m_rIssueCollection, 
SwResId(STR_DOCUMENT_TITLE),
+  
sfx::AccessibilityIssueID::DOCUMENT_TITLE);
+pIssue->setDoc(*pDoc);
+pIssue->setIssueObject(IssueObject::DOCUMENT_TITLE);
 }
 }
 };
diff --git a/sw/source/core/access/AccessibilityIssue.cxx 
b/sw/source/core/access/AccessibilityIssue.cxx
index d1ebb53bdeeb..d0366b1ef3e2 100644
--- a/sw/source/core/access/AccessibilityIssue.cxx
+++ b/sw/source/core/access/AccessibilityIssue.cxx
@@ -8,6 +8,8 @@
  *
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -42,7 +44,8 @@ void AccessibilityIssue::setObjectID(OUString const& rID) { 
m_sObjectID = rID; }
 
 bool AccessibilityIssue::canGotoIssue() const
 {
-if (m_pDoc && m_eIssueObject != IssueObject::UNKNOWN)
+if (m_pDoc && m_eIssueObject != IssueObject::UNKNOWN
+&& m_eIssueObject != IssueObject::DOCUMENT_TITLE)
 return true;
 return false;
 }
@@ -119,7 +122,8 @@ void AccessibilityIssue::gotoIssue() const
 bool AccessibilityIssue::canQuickFixIssue() const
 {
 return m_eIssueObject == IssueObject::GRAPHIC || m_eIssueObject == 
IssueObject::OLE
-   || m_eIssueObject == IssueObject::SHAPE || m_eIssueObject == 
IssueObject::FORM;
+   || m_eIssueObject == IssueObject::SHAPE || m_eIssueObject == 
IssueObject::FORM
+   || m_eIssueObject == IssueObject::DOCUMENT_TITLE;
 }
 
 void AccessibilityIssue::quickFixIssue() const
@@ -158,6 +162,26 @@ void AccessibilityIssue::quickFixIssue() const
 }
 }
 break;
+case IssueObject::DOCUMENT_TITLE:
+{
+OUString aDesc = SwResId(STR_ENTER_DOCUMENT_TITLE);
+SvxNameDialog aNameDialog(m_pParent, "", aDesc);
+if (aNameDialog.run() == 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-06-23 Thread Maxim Monastirsky (via logerrit)
 sw/inc/doc.hxx   |2 -
 sw/source/core/doc/docfmt.cxx|8 --
 sw/source/core/inc/UndoAttribute.hxx |8 +++---
 sw/source/core/undo/unattr.cxx   |   42 +++
 sw/source/uibase/app/docstyle.cxx|   15 ++--
 5 files changed, 46 insertions(+), 29 deletions(-)

New commits:
commit 6cc71f3eef4e5108e44ab6c1943def1d3a0f707a
Author: Maxim Monastirsky 
AuthorDate: Wed Jun 21 07:30:53 2023 +0300
Commit: Maxim Monastirsky 
CommitDate: Fri Jun 23 08:31:13 2023 +0200

tdf#103064 Fix reset to parent style handling

If the style ends up empty, it still needs modification
broadcasting if it used to be non-empty. So let's just
trust the pool notification for when to notify clients.
And given that broadcasting happens now always after
EnsureStyleHierarchy, I assume that the explicit
broadcasting in SetParent is no longer needed.

Also added broadcasting to the undo of a reset. And the
undo actions were combined, so we don't get separate
notifications for each reset attribute.

Change-Id: Ia2895fe346ef337cc0b4fe5dc4275f5b2dc60cd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153478
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index c729e0b2a983..c709db694d07 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -729,7 +729,7 @@ public:
 void SetAttr( const SfxItemSet&, SwFormat& );
 
 // method to reset a certain attribute at the given format
-void ResetAttrAtFormat( const sal_uInt16 nWhichId,
+void ResetAttrAtFormat( const std::vector& rIds,
 SwFormat& rChangedFormat );
 
 /** Set attribute as new default attribute in current document.
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 8ed9c4c9d249..3a503407c90f 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -498,14 +498,16 @@ void SwDoc::SetAttr( const SfxItemSet& rSet, SwFormat& 
rFormat )
 getIDocumentState().SetModified();
 }
 
-void SwDoc::ResetAttrAtFormat( const sal_uInt16 nWhichId,
+void SwDoc::ResetAttrAtFormat( const std::vector& rIds,
SwFormat& rChangedFormat )
 {
 std::unique_ptr pUndo;
 if (GetIDocumentUndoRedo().DoesUndo())
-pUndo.reset(new SwUndoFormatResetAttr( rChangedFormat, nWhichId ));
+pUndo.reset(new SwUndoFormatResetAttr( rChangedFormat, rIds ));
 
-const bool bAttrReset = rChangedFormat.ResetFormatAttr( nWhichId );
+bool bAttrReset = false;
+for (const auto& nWhichId : rIds)
+bAttrReset = rChangedFormat.ResetFormatAttr(nWhichId) || bAttrReset;
 
 if ( bAttrReset )
 {
diff --git a/sw/source/core/inc/UndoAttribute.hxx 
b/sw/source/core/inc/UndoAttribute.hxx
index 7fbbb5b522cd..f6905cafc6cf 100644
--- a/sw/source/core/inc/UndoAttribute.hxx
+++ b/sw/source/core/inc/UndoAttribute.hxx
@@ -132,7 +132,7 @@ class SwUndoFormatResetAttr final : public SwUndo
 {
 public:
 SwUndoFormatResetAttr( SwFormat& rChangedFormat,
-const sal_uInt16 nWhichId );
+   const std::vector& rIds );
 virtual ~SwUndoFormatResetAttr() override;
 
 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
@@ -141,10 +141,10 @@ class SwUndoFormatResetAttr final : public SwUndo
 private:
 // format at which a certain attribute is reset.
 SwFormat * const m_pChangedFormat;
-// which ID of the reset attribute
-const sal_uInt16 m_nWhichId;
 // old attribute which has been reset - needed for undo.
-std::unique_ptr m_pOldItem;
+SfxItemSet m_aSet;
+
+void BroadcastStyleChange();
 };
 
 class SwUndoDontExpandFormat final : public SwUndo
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index acc1503ee35c..66ccb4073bc3 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -233,7 +233,7 @@ void SwUndoFormatAttr::UndoImpl(::sw::UndoRedoContext & 
rContext)
 else if (RES_CHRFMT == m_nFormatWhich)
 nFamily = SfxStyleFamily::Char;
 
-if (pFormat && nFamily != SfxStyleFamily::None)
+if (m_oOldSet && m_oOldSet->Count() > 0 && nFamily != SfxStyleFamily::None)
 rContext.GetDoc().BroadcastStyleOperation(pFormat->GetName(), nFamily, 
SfxHintId::StyleSheetModified);
 }
 
@@ -549,14 +549,16 @@ bool 
SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
 }
 
 SwUndoFormatResetAttr::SwUndoFormatResetAttr( SwFormat& rChangedFormat,
-const sal_uInt16 nWhichId )
+  const std::vector& 
rIds )
 : SwUndo( SwUndoId::RESETATTR, rChangedFormat.GetDoc() )
 , m_pChangedFormat(  )
-, m_nWhichId( nWhichId )
+, m_aSet(*rChangedFormat.GetAttrSet().GetPool())
 {
-

[Libreoffice-commits] core.git: sw/inc sw/source

2023-06-23 Thread Maxim Monastirsky (via logerrit)
 sw/inc/docstyle.hxx   |2 +-
 sw/source/uibase/app/docstyle.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 9cfed79cc1eb6182a807dafec796c0423d6003d6
Author: Maxim Monastirsky 
AuthorDate: Wed Jun 21 10:10:03 2023 +0300
Commit: Maxim Monastirsky 
CommitDate: Fri Jun 23 08:30:51 2023 +0200

This can be const

Change-Id: Ie69b8a926c20d1923c4e1ad580838f1b57bbd3f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153480
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx
index 82b33adf4efd..7d0a07de2dc8 100644
--- a/sw/inc/docstyle.hxx
+++ b/sw/inc/docstyle.hxx
@@ -181,7 +181,7 @@ class SwStyleSheetIterator final : public 
SfxStyleSheetIterator, public SfxListe
 sal_uInt32  m_nLastPos;
 boolm_bFirstCalled;
 
-bool IsUsedInComments(const OUString& rName);
+bool IsUsedInComments(const OUString& rName) const;
 voidAppendStyleList(const std::vector& rLst,
 boolbUsed,
 boolbTestHidden,
diff --git a/sw/source/uibase/app/docstyle.cxx 
b/sw/source/uibase/app/docstyle.cxx
index d43d5f652ff1..8f8e9eb94c19 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -3409,7 +3409,7 @@ void SwStyleSheetIterator::AppendStyleList(const 
std::vector& rList,
 }
 }
 
-bool SwStyleSheetIterator::IsUsedInComments(const OUString& rName)
+bool SwStyleSheetIterator::IsUsedInComments(const OUString& rName) const
 {
 auto pPool = static_cast(pBasePool)->GetEEStyleSheetPool();
 SfxStyleSheetIterator aIter(pPool, GetSearchFamily(), 
SfxStyleSearchBits::Used);


[Libreoffice-commits] core.git: sw/inc sw/source

2023-06-13 Thread Noel Grandin (via logerrit)
 sw/inc/AnnotationWin.hxx  |3 +++
 sw/source/uibase/docvw/AnnotationWin2.cxx |   23 +--
 2 files changed, 20 insertions(+), 6 deletions(-)

New commits:
commit 8d18b5af883bb6b56e758801ee730a08bb88a8f5
Author: Noel Grandin 
AuthorDate: Tue Jun 13 10:11:08 2023 +0200
Commit: Caolán McNamara 
CommitDate: Tue Jun 13 17:11:45 2023 +0200

speed up rendering annotatins, cache meta height

shaves 2% off scrolling profile on a large word doc

Change-Id: I283e3f99c1c385f3d20ea573d15ca59b4629c14d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152978
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 8499c392516a..c3d556085a03 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -29,6 +29,7 @@
 #include "postithelper.hxx"
 #include "swrect.hxx"
 #include "SidebarWindowsTypes.hxx"
+#include 
 
 class EditView;
 class PopupMenu;
@@ -212,6 +213,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
 
 virtual voidLoseFocus() override;
 virtual voidGetFocus() override;
+virtual voidDataChanged( const DataChangedEvent& rDCEvt ) override;
 
 voidSetSizePixel( const Size& rNewSize ) override;
 SfxItemSet  DefaultItem();
@@ -280,6 +282,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
 SwPostItField*   mpField;
 
 rtl::Reference 
mxSidebarWinAccessible;
+mutable std::optional moMetaHeight;
 };
 
 } // end of namespace sw::annotation
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index 06efbfdb581f..2c4bc7ce3d5e 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1262,14 +1262,25 @@ int SwAnnotationWin::GetPrefScrollbarWidth() const
 
 sal_Int32 SwAnnotationWin::GetMetaHeight() const
 {
-const int fields = GetNumFields();
+if (!moMetaHeight)
+{
+const int fields = GetNumFields();
 
-sal_Int32 nRequiredHeight = 0;
-weld::Label* aLabels[3] = { mxMetadataAuthor.get(), mxMetadataDate.get(), 
mxMetadataResolved.get() };
-for (int i = 0; i < fields; ++i)
-nRequiredHeight += aLabels[i]->get_preferred_size().Height();
+sal_Int32 nRequiredHeight = 0;
+weld::Label* aLabels[3] = { mxMetadataAuthor.get(), 
mxMetadataDate.get(), mxMetadataResolved.get() };
+for (int i = 0; i < fields; ++i)
+nRequiredHeight += aLabels[i]->get_preferred_size().Height();
+moMetaHeight = nRequiredHeight;
+}
+return *moMetaHeight;
+}
 
-return nRequiredHeight;
+void SwAnnotationWin::DataChanged(const DataChangedEvent& rDCEvt)
+{
+if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && 
(rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
+{
+moMetaHeight.reset();
+}
 }
 
 sal_Int32 SwAnnotationWin::GetNumFields() const


[Libreoffice-commits] core.git: sw/inc sw/source

2023-06-12 Thread Balazs Varga (via logerrit)
 sw/inc/editsh.hxx|7 +++
 sw/inc/strings.hrc   |4 
 sw/source/core/access/AccessibilityCheck.cxx |   11 +--
 sw/source/core/access/AccessibilityIssue.cxx |   17 -
 sw/source/core/inc/AccessibilityIssue.hxx|1 +
 sw/source/uibase/inc/wrtsh.hxx   |1 +
 sw/source/uibase/wrtsh/wrtsh1.cxx|   11 +++
 7 files changed, 49 insertions(+), 3 deletions(-)

New commits:
commit c5cde93cd4327f55fdd23e6230c2cb101192374d
Author: Balazs Varga 
AuthorDate: Wed Jun 7 12:21:24 2023 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Mon Jun 12 20:38:36 2023 +0200

tdf#155041 - A11Y sidebar: fix warning about missing form control 
description

Add form control objects to "Go to" and "Fix" functions.
In case of "Go to" a warning dialoge shows up if it is not in Design mode
and ask to switch on Design mode or not.

Change-Id: I79b6d67568e2ddfd121081d4c47ce7588f5d51b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152698
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 41650792e10b..766e504b4072 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -637,6 +637,13 @@ public:
 return true;
 }
 
+/// Switch to Design mode for Forms
+virtual bool WarnSwitchToDesignModeDialog() const
+{
+// override in SwWrtShell
+return false;
+}
+
 /** Query text within selection. */
 void GetSelectedText( OUString ,
 ParaBreakType nHndlParaBreak = ParaBreakType::ToBlank 
);
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index c18aff49639a..38ae2f61bff9 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -1469,6 +1469,10 @@
 // in order to change %PRODUCTNAME at runtime is expensive, so limit doing 
that as much as possible.
 #define STR_A11Y_DESC_AUTO  
NC_("insertcaption|extended_tip|auto", "Opens the Caption dialog. It has the 
same information as the dialog you get by menu %PRODUCTNAME Writer - 
AutoCaption in the Options dialog box.")
 
+#define STR_A11Y_DESIGN_MODE_TITLE  
NC_("STR_A11Y_DESIGN_MODE_TITLE", "The Forms are not editable")
+#define STR_A11Y_DESIGN_MODE_PRIMARY
NC_("STR_A11Y_DESIGN_MODE_PRIMARY", "Would you like to switch to Design mode?")
+#define STR_A11Y_DESIGN_MODE_SECONDARY  
NC_("STR_A11Y_DESIGN_MODE_SECONDARY", "You need to switch to design mode to 
edit Forms.")
+
 #define STR_MARK_COPY NC_("STR_MARK_COPY", "%1 Copy ")
 
 #define STR_INFORODLG_FOLDED_PRIMARY
NC_("STR_INFORODLG_FOLDED_PRIMARY", "You are trying to delete folded (hidden) 
content.")
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index 302d26c9c06f..05d2634db863 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -1360,9 +1360,11 @@ void AccessibilityCheck::checkObject(SdrObject* pObject)
 lclAddIssue(m_aIssueCollection, SwResId(STR_FLOATING_TEXT));
 
 const SdrObjKind nObjId = pObject->GetObjIdentifier();
+const SdrInventor nInv = pObject->GetObjInventor();
 
 if (nObjId == SdrObjKind::CustomShape || nObjId == SdrObjKind::Text
-|| nObjId == SdrObjKind::Media || nObjId == SdrObjKind::Group)
+|| nObjId == SdrObjKind::Media || nObjId == SdrObjKind::Group
+|| nInv == SdrInventor::FmForm)
 {
 OUString sAlternative = pObject->GetTitle();
 if (sAlternative.isEmpty())
@@ -1371,7 +1373,12 @@ void AccessibilityCheck::checkObject(SdrObject* pObject)
 OUString sIssueText = 
SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", sName);
 auto pIssue = lclAddIssue(m_aIssueCollection, sIssueText,
   sfx::AccessibilityIssueID::NO_ALT_SHAPE);
-pIssue->setIssueObject(IssueObject::SHAPE);
+// Set FORM Issue for Form objects because of the design mode
+if (nInv == SdrInventor::FmForm)
+pIssue->setIssueObject(IssueObject::FORM);
+else
+pIssue->setIssueObject(IssueObject::SHAPE);
+
 pIssue->setObjectID(pObject->GetName());
 pIssue->setDoc(*m_pDoc);
 }
diff --git a/sw/source/core/access/AccessibilityIssue.cxx 
b/sw/source/core/access/AccessibilityIssue.cxx
index 7f09b9d7cf05..d1ebb53bdeeb 100644
--- a/sw/source/core/access/AccessibilityIssue.cxx
+++ b/sw/source/core/access/AccessibilityIssue.cxx
@@ -71,6 +71,20 @@ void AccessibilityIssue::gotoIssue() const
 pWrtShell->ShowCursor();
 }
 break;
+case IssueObject::FORM:
+{
+SwWrtShell* pWrtShell = m_pDoc->GetDocShell()->GetWrtShell();
+bool bIsDesignMode = 
pWrtShell->GetView().GetFormShell()->IsDesignMode();
+if 

[Libreoffice-commits] core.git: sw/inc sw/source sw/uiconfig

2023-06-07 Thread Samuel Mehrbrodt (via logerrit)
 sw/inc/AccessibilityCheckStrings.hrc  |2 
 sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx |  164 +-
 sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx |   29 ++
 sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui|  251 +-
 4 files changed, 432 insertions(+), 14 deletions(-)

New commits:
commit ee8405d7567c35ae240e014fe1da289b4bb1abe2
Author: Samuel Mehrbrodt 
AuthorDate: Mon Jun 5 14:20:37 2023 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Thu Jun 8 07:56:16 2023 +0200

tdf#155505 Group issues by type in a11y sidebar panel

Change-Id: I87349e9d3f5680751a91264e055e4579c97fa93e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152617
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 

diff --git a/sw/inc/AccessibilityCheckStrings.hrc 
b/sw/inc/AccessibilityCheckStrings.hrc
index cb461b1013f8..12e2e1fa2b8d 100644
--- a/sw/inc/AccessibilityCheckStrings.hrc
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -13,7 +13,7 @@
 
 #define NC_(Context, String) TranslateId(Context, reinterpret_cast(u8##String))
 
-#define STR_NO_ALT  NC_("STR_NO_ALT", "No alt or 
description text for graphic “%OBJECT_NAME%”.")
+#define STR_NO_ALT  NC_("STR_NO_ALT", "%OBJECT_NAME%")
 #define STR_TABLE_MERGE_SPLIT   NC_("STR_TABLE_MERGE_SPLIT", "Table 
“%OBJECT_NAME%” contains merges or splits.")
 #define STR_FAKE_NUMBERING  NC_("STR_FAKE_NUMBERING", "Simulated 
numbering “%NUMBERING%”.")
 #define STR_HYPERLINK_TEXT_IS_LINK  NC_("STR_HYPERLINK_TEXT_IS_LINK", 
"Hyperlink text is the same as the link address “%LINK%”.")
diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx 
b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
index c0c8595408c6..1728ed58e266 100644
--- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
+++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
@@ -69,7 +69,24 @@ std::unique_ptr 
A11yCheckIssuesPanel::Create(weld::Widget* pParent,
 
 A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* 
pBindings)
 : PanelLayout(pParent, "A11yCheckIssuesPanel", 
"modules/swriter/ui/a11ycheckissuespanel.ui")
-, m_xAccessibilityCheckBox(m_xBuilder->weld_box("accessibilityCheckBox"))
+, m_xExpanderDocument(m_xBuilder->weld_expander("expand_document"))
+, m_xExpanderStyles(m_xBuilder->weld_expander("expand_styles"))
+, m_xExpanderNoAlt(m_xBuilder->weld_expander("expand_no_alt"))
+, m_xExpanderTable(m_xBuilder->weld_expander("expand_table"))
+, m_xExpanderFormatting(m_xBuilder->weld_expander("expand_formatting"))
+, m_xExpanderHyperlink(m_xBuilder->weld_expander("expand_hyperlink"))
+, m_xExpanderFakes(m_xBuilder->weld_expander("expand_fakes"))
+, m_xExpanderNumbering(m_xBuilder->weld_expander("expand_numbering"))
+, m_xExpanderOther(m_xBuilder->weld_expander("expand_other"))
+, m_xBoxDocument(m_xBuilder->weld_box("box_document"))
+, m_xBoxStyles(m_xBuilder->weld_box("box_styles"))
+, m_xBoxNoAlt(m_xBuilder->weld_box("box_no_alt"))
+, m_xBoxTable(m_xBuilder->weld_box("box_table"))
+, m_xBoxFormatting(m_xBuilder->weld_box("box_formatting"))
+, m_xBoxHyperlink(m_xBuilder->weld_box("box_hyperlink"))
+, m_xBoxFakes(m_xBuilder->weld_box("box_fakes"))
+, m_xBoxNumbering(m_xBuilder->weld_box("box_numbering"))
+, m_xBoxOther(m_xBuilder->weld_box("box_other"))
 , mpBindings(pBindings)
 , mpDoc(nullptr)
 , maA11yCheckController(FN_STAT_ACCESSIBILITY_CHECK, *pBindings, *this)
@@ -108,7 +125,24 @@ void A11yCheckIssuesPanel::ImplDestroy()
 batch->commit();
 mpBindings->Invalidate(SID_ACCESSIBILITY_CHECK_ONLINE);
 }
-m_xAccessibilityCheckBox.reset();
+m_xExpanderDocument.reset();
+m_xExpanderStyles.reset();
+m_xExpanderNoAlt.reset();
+m_xExpanderTable.reset();
+m_xExpanderFormatting.reset();
+m_xExpanderHyperlink.reset();
+m_xExpanderFakes.reset();
+m_xExpanderNumbering.reset();
+m_xExpanderOther.reset();
+m_xBoxDocument.reset();
+m_xBoxStyles.reset();
+m_xBoxNoAlt.reset();
+m_xBoxTable.reset();
+m_xBoxFormatting.reset();
+m_xBoxHyperlink.reset();
+m_xBoxFakes.reset();
+m_xBoxNumbering.reset();
+m_xBoxOther.reset();
 }
 
 A11yCheckIssuesPanel::~A11yCheckIssuesPanel() { 
suppress_fun_call_w_exception(ImplDestroy()); }
@@ -122,23 +156,133 @@ void A11yCheckIssuesPanel::populateIssues()
 m_aIssueCollection = aCheck.getIssueCollection();
 
 // Remove old issue widgets
-for (auto const& xEntry : m_aAccessibilityCheckEntries)
-m_xAccessibilityCheckBox->move(xEntry->get_widget(), nullptr);
+for (auto const& xEntry : m_aDocumentEntries)
+m_xBoxDocument->move(xEntry->get_widget(), nullptr);
+for (auto const& xEntry : m_aStylesEntries)
+m_xBoxStyles->move(xEntry->get_widget(), nullptr);
+for (auto const& xEntry : m_aNoAltEntries)
+

[Libreoffice-commits] core.git: sw/inc sw/source

2023-06-06 Thread Michael Stahl (via logerrit)
 sw/inc/crsrsh.hxx|2 
 sw/inc/doc.hxx   |1 
 sw/source/core/crsr/crsrsh.cxx   |   38 -
 sw/source/core/docnode/ndtbl.cxx |  262 ---
 sw/source/core/edit/eddel.cxx|   15 +-
 sw/source/core/edit/edglss.cxx   |8 -
 6 files changed, 181 insertions(+), 145 deletions(-)

New commits:
commit f66d5331c1f55dfc88b1439f1b8e10ebe41d3f98
Author: Michael Stahl 
AuthorDate: Mon Jun 5 20:24:45 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue Jun 6 12:02:41 2023 +0200

tdf#155685 sw: fix crash on undo of ExtendedSelectAll with table at end

While the selection with table at the end works for Copy, unfortunately
it doesn't work for Delete, because SwUndoDelete can't handle it,
and an empty SwTableNode+SwEndNode pair remains.

This needs some extra code, extract a SwDoc::DelTable() out of
SwDoc::DeleteRowCol() and call it from SwEditShell::DeleteSel() to
create separate SwUndoDelete objects per table, which appears to work.

(regression from commit d81379db730a163c5ff75d4f3a3cddbd7b5eddda)

Change-Id: I1534b100d31bc279bce298d3c2bd235cffc1f9d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152628
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 6efdceee2838..cfba5cb852c1 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -332,7 +332,7 @@ public:
 // only for usage in special cases allowed!
 void ExtendedSelectAll(bool bFootnotes = true);
 /// If ExtendedSelectAll() was called and selection didn't change since 
then.
-SwNode const* ExtendedSelectedAll() const;
+::std::optional<::std::pair>> 
ExtendedSelectedAll() const;
 enum class StartsWith { None, Table, HiddenPara };
 /// If document body starts with a table or starts/ends with hidden 
paragraph.
 StartsWith StartsWith_();
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index c3ac513c4b52..c729e0b2a983 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1210,6 +1210,7 @@ public:
 
 // Delete Columns/Rows in table.
 enum class RowColMode { DeleteRow = 0, DeleteColumn = 1, DeleteProtected = 
2 };
+void DelTable(SwTableNode * pTable);
 bool DeleteRowCol(const SwSelBoxes& rBoxes, RowColMode eMode = 
RowColMode::DeleteRow);
 void DeleteRow( const SwCursor& rCursor );
 void DeleteCol( const SwCursor& rCursor );
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index c34827f092d8..325ff54d52cd 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -819,11 +819,12 @@ static typename SwCursorShell::StartsWith 
EndsWith(SwStartNode const& rStart)
 
 // return the node that is the start of the extended selection (to include 
table
 // or section start nodes; looks like extending for end nodes is not required)
-SwNode const* SwCursorShell::ExtendedSelectedAll() const
+::std::optional<::std::pair>>
+SwCursorShell::ExtendedSelectedAll() const
 {
 if (m_pTableCursor)
 {
-return nullptr;
+return {};
 }
 
 SwNodes& rNodes = GetDoc()->GetNodes();
@@ -834,27 +835,48 @@ SwNode const* SwCursorShell::ExtendedSelectedAll() const
 SwContentNode* pStart = rNodes.GoNext();
 if (!pStart)
 {
-return nullptr;
+return {};
 }
 
 nNode = *pStartNode->EndOfSectionNode();
 SwContentNode* pEnd = SwNodes::GoPrevious();
 if (!pEnd)
 {
-return nullptr;
+return {};
 }
 
 SwPosition aStart(*pStart, 0);
 SwPosition aEnd(*pEnd, pEnd->Len());
 if (!(aStart == *pShellCursor->Start() && aEnd == *pShellCursor->End()))
 {
-return nullptr;
+return {};
 }
 
+auto const ends(::EndsWith(*pStartNode));
 if (::StartsWith(*pStartNode) == StartsWith::None
-&& ::EndsWith(*pStartNode) == StartsWith::None)
+&& ends == StartsWith::None)
 {
-return nullptr; // "ordinary" selection will work
+return {}; // "ordinary" selection will work
+}
+
+::std::vector tablesAtEnd;
+if (ends == StartsWith::Table)
+{
+SwNode * pLastNode(rNodes[pStartNode->EndOfSectionIndex() - 1]);
+while (pLastNode->IsEndNode())
+{
+SwNode *const pNode(pLastNode->StartOfSectionNode());
+if (pNode->IsTableNode())
+{
+tablesAtEnd.push_back(pNode->GetTableNode());
+pLastNode = rNodes[pNode->GetIndex() - 1];
+}
+else if (pNode->IsSectionNode())
+{
+pLastNode = rNodes[pLastNode->GetIndex() - 1];
+}
+}
+assert(!tablesAtEnd.empty());
 }
 
 // tdf#133990 ensure directly containing section is included in 
SwUndoDelete
@@ -867,7 +889,7 @@ SwNode const* SwCursorShell::ExtendedSelectedAll() const
 
 // pStartNode is the node that fully contains the selection - the 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-05-19 Thread László Németh (via logerrit)
 sw/inc/crsrsh.hxx  |   11 ++-
 sw/inc/strings.hrc |2 ++
 sw/source/core/crsr/crstrvl.cxx|   36 +++-
 sw/source/uibase/docvw/edtwin2.cxx |   22 --
 4 files changed, 51 insertions(+), 20 deletions(-)

New commits:
commit 5facae7614a1a82ed51241f50cec8e82bfb2cbda
Author: László Németh 
AuthorDate: Fri May 19 10:29:29 2023 +0200
Commit: László Németh 
CommitDate: Fri May 19 16:10:05 2023 +0200

tdf#155343 sw tracked table column: add tooltip

Tooltip of a deleted table column shows "Column Deleted",
an inserted table column (will) show "Column Inserted".

Follow-up to commit ffd8d20d368a885d6d786749278fa438573227a7
"tdf#150673 sw xmloff: import/export tracked table column" and
commit 84fbb3398f7486f00e7b7dea415e1ea2510a9535
"tdf#146144 sw: add tooltip to table rows with change tracking".

Change-Id: I79fd2397410328b320bd2536285cc5cc835da9fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151998
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 57bb90a11a5d..6efdceee2838 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -87,15 +87,16 @@ enum class IsAttrAtPos
 ContentCheck = 0x0400,
 SmartTag = 0x0800,
 FormControl  = 0x1000,
-TableRedline = 0x2000
+TableRedline = 0x2000,
+TableColRedline  = 0x4000
 #ifdef DBG_UTIL
-,CurrAttrs   = 0x4000///< only for debugging
-,TableBoxValue   = 0x8000///< only for debugging
+,CurrAttrs   = 0x8000///< only for debugging
+,TableBoxValue   = 0x1   ///< only for debugging
 #endif
-, ContentControl = 0x1
+, ContentControl = 0x2
 };
 namespace o3tl {
-template<> struct typed_flags : is_typed_flags {};
+template<> struct typed_flags : is_typed_flags {};
 }
 
 struct SwContentAtPos
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index b7c8137c8275..c18aff49639a 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -1268,6 +1268,8 @@
 #define STR_REDLINE_PARAGRAPH_FORMAT
NC_("STR_REDLINE_PARAGRAPH_FORMAT", "Paragraph formatting changed")
 #define STR_REDLINE_TABLE_ROW_INSERT
NC_("STR_REDLINE_TABLE_ROW_INSERT", "Row Inserted")
 #define STR_REDLINE_TABLE_ROW_DELETE
NC_("STR_REDLINE_TABLE_ROW_DELETE", "Row Deleted")
+#define STR_REDLINE_TABLE_COLUMN_INSERT 
NC_("STR_REDLINE_TABLE_COLUMN_INSERT", "Column Inserted")
+#define STR_REDLINE_TABLE_COLUMN_DELETE 
NC_("STR_REDLINE_TABLE_COLUMN_DELETE", "Column Deleted")
 #define STR_REDLINE_TABLE_CELL_INSERT   
NC_("STR_REDLINE_TABLE_CELL_INSERT", "Cell Inserted")
 #define STR_REDLINE_TABLE_CELL_DELETE   
NC_("STR_REDLINE_TABLE_CELL_DELETE", "Cell Deleted")
 #define STR_REDLINE_INSERT_MOVED
NC_("STR_REDLINE_INSERT_MOVED", "Moved (insertion)")
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 3ea5db46ccc9..a1656233cfc9 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1879,7 +1879,8 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
 }
 }
 
-if( !bRet && ( IsAttrAtPos::TableRedline & rContentAtPos.eContentAtPos 
) )
+if( !bRet && ( ( IsAttrAtPos::TableRedline & 
rContentAtPos.eContentAtPos ) ||
+ ( IsAttrAtPos::TableColRedline & 
rContentAtPos.eContentAtPos ) ) )
 {
 const SwTableNode* pTableNd;
 const SwTableBox* pBox;
@@ -1889,17 +1890,34 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
 nullptr != ( pBox = pTableNd->GetTable().GetTableBox(
 pSttNd->GetIndex() )) &&
 nullptr != ( pTableLine = pBox->GetUpper() ) &&
-RedlineType::None != pTableLine->GetRedlineType() )
+( RedlineType::None != pBox->GetRedlineType() ||
+RedlineType::None != pTableLine->GetRedlineType() ) )
 {
-SwRedlineTable::size_type nPos = 0;
-nPos = pTableLine->UpdateTextChangesOnly(nPos);
-if ( nPos != SwRedlineTable::npos )
+const SwRedlineTable& aRedlineTable = 
GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+if ( RedlineType::None != pTableLine->GetRedlineType() )
 {
-rContentAtPos.aFnd.pRedl = 
GetDoc()->getIDocumentRedlineAccess().GetRedlineTable()[nPos];
-rContentAtPos.eContentAtPos = IsAttrAtPos::TableRedline;
-bRet = true;
+SwRedlineTable::size_type nPos = 0;
+nPos = pTableLine->UpdateTextChangesOnly(nPos);
+if ( nPos != SwRedlineTable::npos )
+{
+rContentAtPos.aFnd.pRedl 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-05-19 Thread Caolán McNamara (via logerrit)
 sw/inc/viewsh.hxx |5 ---
 sw/source/core/doc/htmltbl.cxx|4 +-
 sw/source/core/inc/rootfrm.hxx|2 -
 sw/source/core/layout/pagechg.cxx |5 ---
 sw/source/core/view/viewsh.cxx|   61 --
 sw/source/core/view/vnew.cxx  |6 +--
 sw/source/filter/html/swhtml.cxx  |3 -
 7 files changed, 7 insertions(+), 79 deletions(-)

New commits:
commit 669b95e6c99f9fc0ade7c23322b7142ef497133b
Author: Caolán McNamara 
AuthorDate: Tue May 16 20:58:05 2023 +0100
Commit: Caolán McNamara 
CommitDate: Fri May 19 09:59:18 2023 +0200

Related: tdf#155349 drop SetEndActionByVirDev from the html import

EndActionByVirDev only arises in the non-mainstream use html web document 
case and precedes the introduction of DoubleBuffer. It would be helpful to have 
one less corner case to consider.

Change-Id: Ibb9064cf5b37b1806f90c24ad9fbf84a8e37c0c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151854
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 3c8bc31b88c0..656e47347c02 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -137,8 +137,6 @@ class SW_DLLPUBLIC SwViewShell : public 
sw::Ring
 bool  mbFrameView   :1;  // If true it is a  (HTML-)Frame.
 bool  mbEnableSmooth:1;  // Disable SmoothScroll, e.g. for drag
 // of scrollbars.
-bool  mbEndActionByVirDev:1; // Paints from EndAction always via virtual 
device
-// (e.g. when browsing).
 bool  mbShowHeaderSeparator:1; ///< Flag to say that we are showing 
the header control
 bool  mbShowFooterSeparator:1; ///< Flag to say that we are showing 
the footer control
 bool  mbHeaderFooterEdit:1;  ///< Flag to say that we are editing 
header or footer (according to the bShow(Header|Footer)Separator above)
@@ -204,9 +202,6 @@ public:
 bool ActionPend() const { return mnStartAction != 0; }
 bool IsInEndAction() const { return mbInEndAction; }
 
-void SetEndActionByVirDev( bool b ) { mbEndActionByVirDev = b; }
-bool IsEndActionByVirDev() const{ return mbEndActionByVirDev; }
-
 // The ActionCount for all Shells is temporarily set to zero and then
 // restored at the RootFrame via UNO.
 voidSetRestoreActions(sal_uInt16 nSet);
diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx
index ffa1a63267e2..4711a123ad0f 100644
--- a/sw/source/core/doc/htmltbl.cxx
+++ b/sw/source/core/doc/htmltbl.cxx
@@ -1684,8 +1684,8 @@ void SwHTMLTableLayout::Resize_( sal_uInt16 nAbsAvail, 
bool bRecalc )
 // Else we can set the widths, in which we have to run Pass 2 in each case.
 SetWidths( true, nAbsAvail );
 
-if ( pRoot && pRoot->IsCallbackActionEnabled() )
-pRoot->EndAllAction( true );//True per VirDev (browsing is calmer)
+if (pRoot && pRoot->IsCallbackActionEnabled())
+pRoot->EndAllAction();
 }
 
 IMPL_LINK_NOARG( SwHTMLTableLayout, DelayedResize_Impl, Timer*, void )
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index 0caf4012862d..80e104c9c63b 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -223,7 +223,7 @@ public:
  * automatically in the EndAllAction.
  */
 void StartAllAction();
-void EndAllAction( bool bVirDev = false );
+void EndAllAction();
 
 /**
  * Certain UNO Actions (e.g. table cursor) require that all Actions are 
reset temporarily
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index c38201a5ed9d..6f11380fc030 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1929,15 +1929,13 @@ void SwRootFrame::StartAllAction()
 }
 }
 
-void SwRootFrame::EndAllAction( bool bVirDev )
+void SwRootFrame::EndAllAction()
 {
 if ( !GetCurrShell() )
 return;
 
 for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
 {
-const bool bOldEndActionByVirDev = rSh.IsEndActionByVirDev();
-rSh.SetEndActionByVirDev( bVirDev );
 if ( auto pCursorShell = dynamic_cast( ) )
 {
 pCursorShell->EndAction();
@@ -1947,7 +1945,6 @@ void SwRootFrame::EndAllAction( bool bVirDev )
 }
 else
 rSh.EndAction();
-rSh.SetEndActionByVirDev( bOldEndActionByVirDev );
 }
 }
 
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index a6197e994c51..16717f4e540d 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -337,71 +337,12 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
 oRegion->LimitToOrigin();
 oRegion->Compress( SwRegionRects::CompressFuzzy );
 
-ScopedVclPtr pVout;
 while ( !oRegion->empty() )
 {
 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-05-18 Thread Miklos Vajna (via logerrit)
 sw/inc/strings.hrc  |1 +
 sw/inc/swundo.hxx   |1 +
 sw/source/core/undo/undobj.cxx  |3 +++
 sw/source/uibase/shells/textsh1.cxx |4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit f5b3f8d6d9d7c060e35b6da295c043576cd36a57
Author: Miklos Vajna 
AuthorDate: Wed May 17 20:14:57 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu May 18 08:22:10 2023 +0200

sw: fix undo comment of FN_DELETE_SECTIONS

It's sections, not section. One has to dispatch .uno:DeleteSections to
see this in action, which does something if the document already has
existing sections.

I think this was the last place where the relatively new biblio-related
UNO commands had a wrong undo comment.

Change-Id: I55074174a498f26ea7bda721988940a86ad2e458
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151930
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index e9f4927c6200..b7c8137c8275 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -445,6 +445,7 @@
 #define STR_UPDATE_FIELDS   NC_("STR_UPDATE_FIELDS", 
"Update fields")
 #define STR_DELETE_FIELDS   NC_("STR_DELETE_FIELDS", 
"Delete fields")
 #define STR_UPDATE_SECTIONS NC_("STR_UPDATE_SECTIONS", 
"Update sections")
+#define STR_DELETE_SECTIONS NC_("STR_DELETE_SECTIONS", 
"Delete sections")
 #define STR_SORT_TBLNC_("STR_SORT_TBL", "Sort 
table")
 #define STR_SORT_TXTNC_("STR_SORT_TXT", "Sort 
text")
 #define STR_INSTABLE_UNDO   NC_("STR_INSTABLE_UNDO", 
"Insert table: $1$2$3")
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index b8bf714aa580..a0a7d918d017 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -178,6 +178,7 @@ enum class SwUndoId
 DELETE_FIELDS, // 146
 UPDATE_SECTIONS,   // 147
 CHANGE_THEME = 148,
+DELETE_SECTIONS = 149,
 };
 
 OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index e5d8469feb3c..712b8252e79d 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -679,6 +679,9 @@ OUString GetUndoComment(SwUndoId eId)
 case SwUndoId::CHANGE_THEME:
 pId = STR_UNDO_CHANGE_THEME_COLORS;
 break;
+case SwUndoId::DELETE_SECTIONS:
+pId = STR_DELETE_SECTIONS;
+break;
 }
 
 assert(pId);
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index a03c8b7249ef..774f6299559a 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -480,13 +480,13 @@ void DeleteSections(SfxRequest& rReq, SwWrtShell& rWrtSh)
 aSectionNamePrefix = pSectionNamePrefix->GetValue();
 }
 
-rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::DELSECTION, 
nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::DELETE_SECTIONS, 
nullptr);
 rWrtSh.StartAction();
 comphelper::ScopeGuard g(
 []
 {
 rWrtSh.EndAction();
-
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::DELSECTION, nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::DELETE_SECTIONS, 
nullptr);
 });
 
 SwDoc* pDoc = rWrtSh.GetDoc();


[Libreoffice-commits] core.git: sw/inc sw/source

2023-05-08 Thread László Németh (via logerrit)
 sw/inc/swscanner.hxx  |2 
 sw/source/core/txtnode/txtedt.cxx |  125 ++
 2 files changed, 88 insertions(+), 39 deletions(-)

New commits:
commit 5619fc438273cd15e78539e78b8af751bca24b1a
Author: László Németh 
AuthorDate: Sun May 7 23:17:26 2023 +0200
Commit: László Németh 
CommitDate: Mon May 8 19:00:28 2023 +0200

tdf#154499 sw spell checking: add 2-word phrase checking

Hunspell dictionaries can contain phrases, i.e. space
separated word sequences, which were used only to reject
compounds and to give better suggestions. Now recognize
2-word phrases in the text, no need to break the phrase
into single words, e.g. "et" and "cetera", which resulted
acceptance of typos (e.g. "et" without "cetera"), also
bad suggestions (e.g. "et" and "cetera" independently from
the context).

More example:

== old .dic file ==
...
et
cetera
von
Neumann
veni
vidi
vici
...

List the 2-word phrases, and break the 3 or more word
into 2-word phrases:

== new .dic file ==
...
et cetera
von Neumann
veni vidi
vidi vici
...

Note: words of the phrase are separated by a space, but
recognized also with punctuation, e.g. in the previous
example, "Veni, vidi, vici."

Note: during typing, the second word of the phrase
will be accepted only at ending the paragraph, i.e.
pressing Enter.

Change-Id: I4a1487abc0e4ab31d09750ee8c817353e6325ca3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151487
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/swscanner.hxx b/sw/inc/swscanner.hxx
index 5dd118ad0049..88433bfe4bb1 100644
--- a/sw/inc/swscanner.hxx
+++ b/sw/inc/swscanner.hxx
@@ -33,6 +33,7 @@ class SwScanner
 {
 std::function m_pGetLangOfChar;
 OUString m_aWord;
+OUString m_aPrevWord;
 const OUString m_aPreDashReplacementText;
 OUString m_aText;
 const LanguageType* m_pLanguage;
@@ -62,6 +63,7 @@ public:
 bool NextWord();
 
 const OUString& GetWord() const{ return m_aWord; }
+const OUString& GetPrevWord() const { return m_aPrevWord; }
 
 sal_Int32 GetBegin() const { return m_nBegin; }
 sal_Int32 GetEnd() const   { return m_nBegin + m_nLength; }
diff --git a/sw/source/core/txtnode/txtedt.cxx 
b/sw/source/core/txtnode/txtedt.cxx
index 528afabed561..1e9082201f7a 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -961,6 +961,7 @@ bool SwScanner::NextWord()
 if ( m_nWordType == i18n::WordType::WORD_COUNT )
 m_nLength = forceEachAsianCodePointToWord(m_aText, m_nBegin, 
m_nLength);
 
+m_aPrevWord = m_aWord;
 m_aWord = m_aPreDashReplacementText.copy( m_nBegin, m_nLength );
 
 return true;
@@ -1035,8 +1036,11 @@ bool SwTextNode::Spell(SwSpellArgs* pArgs)
 SwScanner aScanner( *this, m_Text, nullptr, ModelToViewHelper(),
 WordType::DICTIONARY_WORD,
 nBegin, nEnd );
-while( !pArgs->xSpellAlt.is() && aScanner.NextWord() )
+bool bNextWord = aScanner.NextWord();
+while( !pArgs->xSpellAlt.is() && bNextWord )
 {
+bool bCalledNextWord = false;
+
 const OUString& rWord = aScanner.GetWord();
 
 // get next language for next word, consider language attributes
@@ -1066,25 +1070,45 @@ bool SwTextNode::Spell(SwSpellArgs* pArgs)
 }
 else
 {
-// make sure the selection build later from the data
-// below does not include "in word" character to the
-// left and right in order to preserve those. Therefore
-// count those "in words" in order to modify the
-// selection accordingly.
-const sal_Unicode* pChar = rWord.getStr();
-sal_Int32 nLeft = 0;
-while (*pChar++ == CH_TXTATR_INWORD)
-++nLeft;
-pChar = rWord.getLength() ? rWord.getStr() + 
rWord.getLength() - 1 : nullptr;
-sal_Int32 nRight = 0;
-while (pChar && *pChar-- == CH_TXTATR_INWORD)
-++nRight;
-
-pArgs->pStartPos->Assign(*this, aScanner.GetEnd() - 
nRight );
-pArgs->pEndPos->Assign(*this, aScanner.GetBegin() + 
nLeft );
+OUString sPrevWord = aScanner.GetPrevWord();
+auto nWordBegin = aScanner.GetBegin();
+auto nWordEnd = aScanner.GetEnd();
+bNextWord = aScanner.NextWord();
+const OUString& rActualWord = aScanner.GetPrevWord();
+   

[Libreoffice-commits] core.git: sw/inc sw/source

2023-05-08 Thread Julien Nabet (via logerrit)
 sw/inc/pvprtdat.hxx   |   10 +-
 sw/source/uibase/inc/pview.hxx|   12 ++--
 sw/source/uibase/uiview/pview.cxx |   14 +++---
 sw/source/uibase/uno/unotxdoc.cxx |8 
 4 files changed, 22 insertions(+), 22 deletions(-)

New commits:
commit 23c9a5a2719c8ca6a7919db55989b0bb67f73f81
Author: Julien Nabet 
AuthorDate: Mon May 8 11:24:30 2023 +0200
Commit: Julien Nabet 
CommitDate: Mon May 8 16:40:08 2023 +0200

Row and Cols in sw preview page part should be sal_Int16 instead of 
sal_uInt8

Following offapi/com/sun/star/text/PagePrintSettings.idl which defines
[property] short PageRows;
[property] short PageColumns;
and "short" is defined as signed 16-bit integer type
see 
https://wiki.documentfoundation.org/Documentation/DevGuide/Professional_UNO

it allows to avoid some static_cast

Change-Id: I5f497a27cd56f7d07c9440e9d6e6718a5e418345
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151499
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/sw/inc/pvprtdat.hxx b/sw/inc/pvprtdat.hxx
index 2a8d5fb0c108..8150a11a5163 100644
--- a/sw/inc/pvprtdat.hxx
+++ b/sw/inc/pvprtdat.hxx
@@ -27,7 +27,7 @@ class SwPagePreviewPrtData
 
 sal_Int32 m_nLeftSpace, m_nRightSpace, m_nTopSpace, m_nBottomSpace,
 m_nHorzSpace, m_nVertSpace;
-sal_uInt8 m_nRow, m_nCol;
+sal_Int16 m_nRow, m_nCol;
 bool m_bLandscape : 1;
 public:
 SwPagePreviewPrtData()
@@ -54,11 +54,11 @@ public:
 sal_Int32 GetVertSpace() const  { return m_nVertSpace; }
 void SetVertSpace( sal_Int32 n ){ m_nVertSpace = n; }
 
-sal_uInt8 GetRow() const{ return m_nRow; }
-void SetRow(sal_uInt8 n )   { m_nRow = n; }
+sal_Int16 GetRow() const{ return m_nRow; }
+void SetRow(sal_Int16 n )   { m_nRow = n; }
 
-sal_uInt8 GetCol() const{ return m_nCol; }
-void SetCol( sal_uInt8 n )  { m_nCol = n; }
+sal_Int16 GetCol() const{ return m_nCol; }
+void SetCol( sal_Int16 n )  { m_nCol = n; }
 
 bool GetLandscape() const   { return m_bLandscape; }
 void SetLandscape( bool b ) { m_bLandscape = b; }
diff --git a/sw/source/uibase/inc/pview.hxx b/sw/source/uibase/inc/pview.hxx
index af0f31d94788..6a46814facd6 100644
--- a/sw/source/uibase/inc/pview.hxx
+++ b/sw/source/uibase/inc/pview.hxx
@@ -47,8 +47,8 @@ class SAL_DLLPUBLIC_RTTI SwPagePreviewWin final : public 
vcl::Window
 {
 SwViewShell* mpViewShell;
 sal_uInt16 mnSttPage;
-sal_uInt8 mnRow;
-sal_uInt8 mnCol;
+sal_Int16 mnRow;
+sal_Int16 mnCol;
 Size maPxWinSize;
 Fraction maScale;
 SwPagePreview& mrView;
@@ -56,7 +56,7 @@ class SAL_DLLPUBLIC_RTTI SwPagePreviewWin final : public 
vcl::Window
 tools::Rectangle maPaintedPreviewDocRect;
 SwPagePreviewLayout* mpPgPreviewLayout;
 
-void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol );
+void SetPagePreview( sal_Int16 nRow, sal_Int16 nCol );
 
 using Window::Scroll;
 
@@ -78,12 +78,12 @@ public:
 return mpViewShell;
 }
 
-sal_uInt8 GetRow() const
+sal_Int16 GetRow() const
 {
 return mnRow;
 }
 
-sal_uInt8 GetCol() const
+sal_Int16 GetCol() const
 {
 return mnCol;
 }
@@ -114,7 +114,7 @@ public:
 // If we only have one column we do not have a oth page
 sal_uInt16 GetDefSttPage() const   { return 1 == mnCol ? 1 : 0; }
 
-void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol );
+void CalcWish( sal_Int16 nNewRow, sal_Int16 nNewCol );
 
 void SetWinSize( const Size& rNewSize );
 
diff --git a/sw/source/uibase/uiview/pview.cxx 
b/sw/source/uibase/uiview/pview.cxx
index 0ca186c74c3e..9df4a8828daf 100644
--- a/sw/source/uibase/uiview/pview.cxx
+++ b/sw/source/uibase/uiview/pview.cxx
@@ -156,7 +156,7 @@ public:
 {
 if (run() == RET_OK)
 {
-m_rParent.CalcWish(sal_uInt8(m_xRowEdit->get_value()), 
sal_uInt8(m_xColEdit->get_value()));
+m_rParent.CalcWish(m_xRowEdit->get_value(), 
m_xColEdit->get_value());
 }
 }
 };
@@ -218,12 +218,12 @@ void  SwPagePreviewWin::Paint(vcl::RenderContext& 
rRenderContext, const tools::R
 }
 }
 
-void SwPagePreviewWin::CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol )
+void SwPagePreviewWin::CalcWish( sal_Int16 nNewRow, sal_Int16 nNewCol )
 {
 if( !mpViewShell || !mpViewShell->GetLayout() )
 return;
 
-const sal_uInt8 nOldCol = mnCol;
+const sal_Int16 nOldCol = mnCol;
 mnRow = nNewRow;
 mnCol = nNewCol;
 const sal_uInt16 nPages = mnRow * mnCol;
@@ -514,7 +514,7 @@ void SwPagePreviewWin::MouseButtonDown( const MouseEvent& 
rMEvt )
 
 // Set user prefs or view options
 
-void SwPagePreviewWin::SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol )
+void SwPagePreviewWin::SetPagePreview( sal_Int16 nRow, sal_Int16 nCol )
 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-05-07 Thread Mike Kaganski (via logerrit)
 sw/inc/pam.hxx  |   16 
 sw/source/core/crsr/pam.cxx |   12 
 2 files changed, 4 insertions(+), 24 deletions(-)

New commits:
commit 059892da740e4272477ad0d69183b0e9b77129d7
Author: Mike Kaganski 
AuthorDate: Sun May 7 17:39:01 2023 +0200
Commit: Mike Kaganski 
CommitDate: Sun May 7 21:03:41 2023 +0200

Simplify a bit

Change-Id: Ibcf59feaa1631c06a393017d1b6342d4a646b9a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151387
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 2a7a0cdb8bd3..62721beb0c4c 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -27,6 +27,7 @@
 #include "nodeoffset.hxx"
 
 #include 
+#include 
 
 class SwDoc;
 class SwPaM;
@@ -230,7 +231,7 @@ public:
 
 void DeleteMark()
 {
-if (m_pMark != m_pPoint)
+if (HasMark())
 {
 /** clear the mark position; this helps if mark's SwContentIndex is
registered at some node, and that node is then deleted */
@@ -238,20 +239,11 @@ public:
 m_pMark = m_pPoint;
 }
 }
-#ifdef DBG_UTIL
-void Exchange();
-
-#else
 void Exchange()
 {
-if (m_pPoint != m_pMark)
-{
-SwPosition *pTmp = m_pPoint;
-m_pPoint = m_pMark;
-m_pMark = pTmp;
-}
+if (HasMark())
+std::swap(m_pPoint, m_pMark);
 }
-#endif
 
 /** A PaM marks a selection if Point and Mark are distinct positions.
 @return true if the PaM spans a selection
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 06690354a8b9..eafa38907fcd 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -652,18 +652,6 @@ void SwPaM::SetMark()
 (*m_pMark) = *m_pPoint;
 }
 
-#ifdef DBG_UTIL
-void SwPaM::Exchange()
-{
-if (m_pPoint != m_pMark)
-{
-SwPosition *pTmp = m_pPoint;
-m_pPoint = m_pMark;
-m_pMark = pTmp;
-}
-}
-#endif
-
 /// movement of cursor
 bool SwPaM::Move( SwMoveFnCollection const & fnMove, SwGoInDoc fnGo )
 {


[Libreoffice-commits] core.git: sw/inc sw/source

2023-05-05 Thread Miklos Vajna (via logerrit)
 sw/inc/anchoredobject.hxx   |2 +-
 sw/source/core/inc/flyfrm.hxx   |2 +-
 sw/source/core/layout/fly.cxx   |   27 +++
 sw/source/core/text/xmldump.cxx |8 
 4 files changed, 29 insertions(+), 10 deletions(-)

New commits:
commit 5d66979a58363e0362b13c637b7eade0fc28505d
Author: Miklos Vajna 
AuthorDate: Thu May 4 19:57:47 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 5 08:48:14 2023 +0200

sw layout xml dump: extract SwFlyFrame::dumpAsXml() from SwFrame

Ideally SwFrame should not really know anything about fly frames.

Change-Id: Idc10a3c8130a961b01a0abbf6f52b093937fd0dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151401
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/anchoredobject.hxx b/sw/inc/anchoredobject.hxx
index 114380d6f04d..ea8104882b4d 100644
--- a/sw/inc/anchoredobject.hxx
+++ b/sw/inc/anchoredobject.hxx
@@ -485,7 +485,7 @@ class SW_DLLPUBLIC SwAnchoredObject
 /** Dump a bunch of useful data to an XML representation to ease
 layout understanding, debugging and testing.
   */
-virtual void dumpAsXml( xmlTextWriterPtr pWriter ) const;
+virtual void dumpAsXml( xmlTextWriterPtr pWriter = nullptr ) const;
 
 /** The element name to show in the XML dump. */
 virtual const char* getElementName( ) const { return 
"SwAnchoredObject"; }
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index cc6d969401bf..d3815a82835a 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -289,7 +289,7 @@ public:
 virtual const SwFlyFrameFormat *GetFormat() const override;
 virtual   SwFlyFrameFormat *GetFormat() override;
 
-virtual void dumpAsXml( xmlTextWriterPtr writer ) const override { 
SwLayoutFrame::dumpAsXml( writer ); };
+virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override;
 
 virtual void Calc(vcl::RenderContext* pRenderContext) const override;
 
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 387095bbdeed..6d80daf74efc 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -3075,6 +3075,33 @@ SwFlyFrameFormat * SwFlyFrame::GetFormat()
 return static_cast< SwFlyFrameFormat * >( GetDep() );
 }
 
+void SwFlyFrame::dumpAsXml(xmlTextWriterPtr writer) const
+{
+(void)xmlTextWriterStartElement(writer, reinterpret_cast("fly"));
+dumpAsXmlAttributes(writer);
+
+(void)xmlTextWriterStartElement(writer, BAD_CAST("infos"));
+dumpInfosAsXml(writer);
+(void)xmlTextWriterEndElement(writer);
+const SwSortedObjs* pAnchored = GetDrawObjs();
+if (pAnchored && pAnchored->size() > 0)
+{
+(void)xmlTextWriterStartElement(writer, BAD_CAST("anchored"));
+
+for (SwAnchoredObject* pObject : *pAnchored)
+{
+pObject->dumpAsXml(writer);
+}
+
+(void)xmlTextWriterEndElement(writer);
+}
+dumpChildrenAsXml(writer);
+
+SwAnchoredObject::dumpAsXml(writer);
+
+(void)xmlTextWriterEndElement(writer);
+}
+
 void SwFlyFrame::Calc(vcl::RenderContext* pRenderContext) const
 {
 if ( !m_bValidContentPos )
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 39231f410e56..4c66104c12af 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -174,9 +174,6 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const
 
 switch ( GetType(  ) )
 {
-case SwFrameType::Fly:
-name = "fly";
-break;
 case SwFrameType::Section:
 name = "section";
 break;
@@ -298,11 +295,6 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const
 else
 {
 dumpChildrenAsXml( writer );
-if (IsFlyFrame())
-{
-auto pFlyFrame = static_cast(this);
-pFlyFrame->SwAnchoredObject::dumpAsXml(writer);
-}
 }
 (void)xmlTextWriterEndElement( writer );
 }


[Libreoffice-commits] core.git: sw/inc sw/source

2023-05-04 Thread Miklos Vajna (via logerrit)
 sw/inc/strings.hrc  |1 +
 sw/inc/swundo.hxx   |1 +
 sw/source/core/undo/undobj.cxx  |3 +++
 sw/source/uibase/shells/textsh1.cxx |4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 55f6141b65411f15a99d509ad5bd7bbab63cd129
Author: Miklos Vajna 
AuthorDate: Wed May 3 20:02:36 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu May 4 08:14:46 2023 +0200

sw: fix undo comment of FN_UPDATE_SECTIONS

It's an update of sections, not insert of a section. One has to dispatch
.uno:UpdateSections to see this in action, which does something if the
document already has existing sections.

Change-Id: Iaca5448feceea3fc2bc450586e5f67981550d8f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151339
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index a29a9c9e6e52..cfdd1f00fd64 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -444,6 +444,7 @@
 #define STR_UPDATE_FIELDNC_("STR_UPDATE_FIELD", 
"Update field: $1")
 #define STR_UPDATE_FIELDS   NC_("STR_UPDATE_FIELDS", 
"Update fields")
 #define STR_DELETE_FIELDS   NC_("STR_DELETE_FIELDS", 
"Delete fields")
+#define STR_UPDATE_SECTIONS NC_("STR_UPDATE_SECTIONS", 
"Update sections")
 #define STR_SORT_TBLNC_("STR_SORT_TBL", "Sort 
table")
 #define STR_SORT_TXTNC_("STR_SORT_TXT", "Sort 
text")
 #define STR_INSTABLE_UNDO   NC_("STR_INSTABLE_UNDO", 
"Insert table: $1$2$3")
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index bf0fd165d3c6..5f0e006114f8 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -176,6 +176,7 @@ enum class SwUndoId
 UPDATE_FIELD,  // 144
 UPDATE_FIELDS, // 145
 DELETE_FIELDS, // 146
+UPDATE_SECTIONS,   // 147
 };
 
 OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 523d065989f4..6b6785d79c1e 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -673,6 +673,9 @@ OUString GetUndoComment(SwUndoId eId)
 case SwUndoId::DELETE_FIELDS:
 pId = STR_DELETE_FIELDS;
 break;
+case SwUndoId::UPDATE_SECTIONS:
+pId = STR_UPDATE_SECTIONS;
+break;
 }
 
 assert(pId);
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index b66772a6dbca..4f2a3629101f 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -401,7 +401,7 @@ void UpdateSections(SfxRequest& rReq, SwWrtShell& rWrtSh)
 pSections->GetValue() >>= aSections;
 }
 
-rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSSECTION, 
nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_SECTIONS, 
nullptr);
 rWrtSh.StartAction();
 
 SwDoc* pDoc = rWrtSh.GetDoc();
@@ -449,7 +449,7 @@ void UpdateSections(SfxRequest& rReq, SwWrtShell& rWrtSh)
 }
 
 rWrtSh.EndAction();
-rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSSECTION, 
nullptr);
+rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_SECTIONS, 
nullptr);
 }
 
 void DeleteSections(SfxRequest& rReq, SwWrtShell& rWrtSh)


[Libreoffice-commits] core.git: sw/inc sw/source sw/uiconfig

2023-05-02 Thread Justin Luth (via logerrit)
 sw/inc/swabstdlg.hxx|1 +
 sw/source/ui/dialog/swdlgfact.cxx   |5 +
 sw/source/ui/dialog/swdlgfact.hxx   |1 +
 sw/source/ui/misc/pagenumberdlg.cxx |7 +++
 sw/source/uibase/inc/pagenumberdlg.hxx  |2 ++
 sw/source/uibase/shells/textfld.cxx |   29 +
 sw/uiconfig/swriter/ui/pagenumberdlg.ui |   26 --
 7 files changed, 65 insertions(+), 6 deletions(-)

New commits:
commit 751cb2cf874a2d017cae699a7983e4419dcbe6f6
Author: Justin Luth 
AuthorDate: Fri Apr 28 13:38:13 2023 -0400
Commit: Miklos Vajna 
CommitDate: Tue May 2 15:36:07 2023 +0200

tdf#86630 sw page number wizard: add page total

1 - 3 is the format of the output.
Not totally clear, but it is at least not in English,
and I'm fairly certain I've seen this format used numerous times.

At least everything is there, and all the user needs to do is
modify the - to be whatever they want.

I checked to see if by some miracle localedata had a specification
for "X of Y" but it doesn't.

Change-Id: Iae1e74e612ec449f72086b3f5a5e32713fee4d27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151173
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 49eefef5e4a3..fe6bab309ef9 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -239,6 +239,7 @@ public:
 virtual int GetPageNumberPosition() const = 0;
 virtual int GetPageNumberAlignment() const = 0;
 virtual bool GetMirrorOnEvenPages() const = 0;
+virtual bool GetIncludePageTotal() const = 0;
 virtual SvxNumType GetPageNumberType() const = 0;
 virtual void SetPageNumberType(SvxNumType nSet) = 0;
 };
diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index 6ec8e23a6304..90f7c6e34d84 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -647,6 +647,11 @@ bool AbstractSwPageNumberDlg_Impl::GetMirrorOnEvenPages() 
const
 return m_xDlg->GetMirrorOnEvenPages();
 }
 
+bool AbstractSwPageNumberDlg_Impl::GetIncludePageTotal() const
+{
+return m_xDlg->GetIncludePageTotal();
+}
+
 SvxNumType AbstractSwPageNumberDlg_Impl::GetPageNumberType() const
 {
 return m_xDlg->GetPageNumberType();
diff --git a/sw/source/ui/dialog/swdlgfact.hxx 
b/sw/source/ui/dialog/swdlgfact.hxx
index 6d3f37aa6a47..0b6f67b1da23 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -167,6 +167,7 @@ public:
 virtual int GetPageNumberPosition() const override;
 virtual int GetPageNumberAlignment() const override;
 bool GetMirrorOnEvenPages() const override;
+bool GetIncludePageTotal() const override;
 SvxNumType GetPageNumberType() const override;
 void SetPageNumberType(SvxNumType nSet) override;
 };
diff --git a/sw/source/ui/misc/pagenumberdlg.cxx 
b/sw/source/ui/misc/pagenumberdlg.cxx
index 06facf1bff22..1b5084c5e94b 100644
--- a/sw/source/ui/misc/pagenumberdlg.cxx
+++ b/sw/source/ui/misc/pagenumberdlg.cxx
@@ -31,6 +31,7 @@ SwPageNumberDlg::SwPageNumberDlg(weld::Window* pParent)
 , m_xPageNumberPosition(m_xBuilder->weld_combo_box("positionCombo"))
 , m_xPageNumberAlignment(m_xBuilder->weld_combo_box("alignmentCombo"))
 , m_xMirrorOnEvenPages(m_xBuilder->weld_check_button("mirrorCheckbox"))
+, m_xIncludePageTotal(m_xBuilder->weld_check_button("pagetotalCheckbox"))
 , m_xPageNumberTypeLB(new 
SvxPageNumberListBox(m_xBuilder->weld_combo_box("numfmtlb")))
 , m_xPreviewImage(m_xBuilder->weld_image("previewImage"))
 , m_aPageNumberPosition(1) // bottom
@@ -44,6 +45,7 @@ SwPageNumberDlg::SwPageNumberDlg(weld::Window* pParent)
 m_xPageNumberAlignment->set_active(m_aPageNumberAlignment);
 m_xMirrorOnEvenPages->set_sensitive(false);
 m_xMirrorOnEvenPages->set_state(TRISTATE_TRUE);
+m_xIncludePageTotal->set_state(TRISTATE_FALSE);
 
SvxNumOptionsTabPageHelper::GetI18nNumbering(m_xPageNumberTypeLB->get_widget(),
  
::std::numeric_limits::max());
 m_xPageNumberTypeLB->connect_changed(LINK(this, SwPageNumberDlg, 
NumberTypeSelectHdl));
@@ -80,6 +82,11 @@ bool SwPageNumberDlg::GetMirrorOnEvenPages()
&& m_xMirrorOnEvenPages->get_state() == TRISTATE_TRUE;
 }
 
+bool SwPageNumberDlg::GetIncludePageTotal()
+{
+return m_xIncludePageTotal->get_state() == TRISTATE_TRUE;
+}
+
 void SwPageNumberDlg::SetPageNumberType(SvxNumType nSet)
 {
 m_nPageNumberType = nSet;
diff --git a/sw/source/uibase/inc/pagenumberdlg.hxx 
b/sw/source/uibase/inc/pagenumberdlg.hxx
index b5dccd93127a..cf719b492a33 100644
--- a/sw/source/uibase/inc/pagenumberdlg.hxx
+++ b/sw/source/uibase/inc/pagenumberdlg.hxx
@@ -32,6 +32,7 @@ class SwPageNumberDlg final : public SfxDialogController
 std::unique_ptr m_xPageNumberPosition;
 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-28 Thread Noel Grandin (via logerrit)
 sw/inc/doc.hxx   |2 +-
 sw/source/core/doc/doclay.cxx|4 ++--
 sw/source/core/draw/dcontact.cxx |7 ---
 sw/source/core/frmedt/fecopy.cxx |   33 -
 4 files changed, 23 insertions(+), 23 deletions(-)

New commits:
commit ea5c846fd5630acef26a3ee96d47c4a43fb5c24d
Author: Noel Grandin 
AuthorDate: Thu Apr 27 18:45:46 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Apr 28 09:12:15 2023 +0200

tdf#155028 Crash in: `anonymous namespace'::lcl_PasteFlyOrDrawFormat

since
commit 8611f6e259b807b4f19c8dc0eab86ca648891ce3
Author: Noel Grandin 
Date:   Thu May 27 10:27:46 2021 +0200
ref-count SdrObject
The CloneSdrObj() call needs to return a rtl::Reference or the
created object might get destroyed before we return a (now stale)
pointer to it.

Change-Id: I3de46b025887e6d460860b37677d2b18b90fb3e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151137
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index d9ff583fcdec..abd55424f359 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1539,7 +1539,7 @@ public:
 void Unchain( SwFrameFormat  );
 
 // For Copy/Move from FrameShell.
-SdrObject* CloneSdrObj( const SdrObject&, bool bMoveWithinDoc = false,
+rtl::Reference CloneSdrObj( const SdrObject&, bool 
bMoveWithinDoc = false,
 bool bInsInPage = true );
 
 // FeShell - Interface end
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 94229dbc968f..4ec0f8922da2 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -105,7 +105,7 @@ static bool lcl_IsItemSet(const SwContentNode & rNode, 
sal_uInt16 which)
 return bResult;
 }
 
-SdrObject* SwDoc::CloneSdrObj( const SdrObject& rObj, bool bMoveWithinDoc,
+rtl::Reference SwDoc::CloneSdrObj( const SdrObject& rObj, bool 
bMoveWithinDoc,
 bool bInsInPage )
 {
 // #i52858# - method name changed
@@ -150,7 +150,7 @@ SdrObject* SwDoc::CloneSdrObj( const SdrObject& rObj, bool 
bMoveWithinDoc,
 }
 pObj->SetLayer( nLayerIdForClone );
 
-return pObj.get();
+return pObj;
 }
 
 SwFlyFrameFormat* SwDoc::MakeFlySection_( const SwPosition& rAnchPos,
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 8675f62e72c9..8e26a42af34f 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1567,11 +1567,12 @@ void SwDrawContact::SwClientNotify(const SwModify& 
rMod, const SfxHint& rHint)
 {
 auto pDrawFormatLayoutCopyHint = static_cast();
 const SwDrawFrameFormat& rFormat = static_cast(rMod);
-new SwDrawContact(
->m_rDestFormat,
+rtl::Reference xNewObj =
 pDrawFormatLayoutCopyHint->m_rDestDoc.CloneSdrObj(
 *GetMaster(),
-pDrawFormatLayoutCopyHint->m_rDestDoc.IsCopyIsMove() 
&& >m_rDestDoc == rFormat.GetDoc()));
+pDrawFormatLayoutCopyHint->m_rDestDoc.IsCopyIsMove() 
&& >m_rDestDoc == rFormat.GetDoc());
+new SwDrawContact(
+>m_rDestFormat, xNewObj.get() );
 // #i49730# - notify draw frame format that position attributes are
 // already set, if the position attributes are already set at the
 // source draw frame format.
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 11a3d945d447..beb014cd5fc4 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -188,11 +188,10 @@ void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* 
pNewClpText )
 aAnchor.SetAnchor(  );
 aSet.Put( aAnchor );
 
-SdrObject *const pNew =
-rClpDoc.CloneSdrObj( *pObj );
+rtl::Reference xNew = rClpDoc.CloneSdrObj( *pObj );
 
 SwPaM aTemp(aPos);
-rClpDoc.getIDocumentContentOperations().InsertDrawObj(aTemp, 
*pNew, aSet );
+rClpDoc.getIDocumentContentOperations().InsertDrawObj(aTemp, 
*xNew, aSet );
 }
 else
 {
@@ -311,10 +310,10 @@ bool SwFEShell::CopyDrawSel( SwFEShell& rDestShell, const 
Point& rSttPt,
 (RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId()) )
 
 {
-SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove &&
+rtl::Reference xNew = pDestDoc->CloneSdrObj( *pObj, 
bIsMove &&
 GetDoc() == pDestDoc, false );
-pNew->NbcMove( aSiz );
-pDestDrwView->InsertObjectAtView( pNew, *pDestPgView );
+xNew->NbcMove( aSiz );
+pDestDrwView->InsertObjectAtView( xNew.get(), *pDestPgView );
 bInsWithFormat = false;
 }
   

[Libreoffice-commits] core.git: sw/inc sw/source sw/uiconfig

2023-04-28 Thread Justin Luth (via logerrit)
 sw/inc/crsrsh.hxx   |2 
 sw/inc/swabstdlg.hxx|1 
 sw/source/core/crsr/crstrvl.cxx |   11 ++-
 sw/source/ui/dialog/swdlgfact.cxx   |5 +
 sw/source/ui/dialog/swdlgfact.hxx   |1 
 sw/source/ui/misc/pagenumberdlg.cxx |   14 
 sw/source/uibase/inc/pagenumberdlg.hxx  |2 
 sw/source/uibase/shells/textfld.cxx |  103 +++-
 sw/uiconfig/swriter/ui/pagenumberdlg.ui |   24 ++-
 9 files changed, 153 insertions(+), 10 deletions(-)

New commits:
commit 21fad629e72791f6cc1791fdba858bf52b9bfeff
Author: Justin Luth 
AuthorDate: Wed Apr 26 13:29:25 2023 -0400
Commit: Miklos Vajna 
CommitDate: Fri Apr 28 08:08:06 2023 +0200

tdf#86630 sw page number wizard: mirror right/left

If the user puts the page numbers on the left or right
side of the page, they usually want that mirrored
on even and odd pages.

This got rather tricky, but in the end
I have enough safeguards that it seems
to work logically and stablely.
So I think it is ready to be submitted.

Change-Id: I321e575cd9f6718579ffee99f1258bffe26581f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151152
Reviewed-by: Justin Luth 
Tested-by: Jenkins

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 319911a33e65..5f99deff126b 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -675,7 +675,7 @@ public:
 bool GotoHeaderText();   ///< jump from the content to the header
 bool GotoFooterText();   ///< jump from the content to the footer
 // jump to the header/footer of the given or current PageDesc
-bool SetCursorInHdFt( size_t nDescNo, bool bInHeader );
+bool SetCursorInHdFt(size_t nDescNo, bool bInHeader, bool bEven = false, 
bool bFirst = false);
 // is point of cursor in header/footer. pbInHeader return true if it is
 // in a headerframe otherwise in a footerframe
 bool IsInHeaderFooter( bool* pbInHeader = nullptr ) const;
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 9749539c5643..49eefef5e4a3 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -238,6 +238,7 @@ protected:
 public:
 virtual int GetPageNumberPosition() const = 0;
 virtual int GetPageNumberAlignment() const = 0;
+virtual bool GetMirrorOnEvenPages() const = 0;
 virtual SvxNumType GetPageNumberType() const = 0;
 virtual void SetPageNumberType(SvxNumType nSet) = 0;
 };
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index c5c0c741f5dd..c8b1e3d8513a 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -189,7 +189,7 @@ bool SwCursorShell::GotoFooterText()
 return nullptr != pFrame;
 }
 
-bool SwCursorShell::SetCursorInHdFt( size_t nDescNo, bool bInHeader )
+bool SwCursorShell::SetCursorInHdFt(size_t nDescNo, bool bInHeader, bool 
bEven, bool bFirst)
 {
 SwDoc *pMyDoc = GetDoc();
 const SwPageDesc* pDesc = nullptr;
@@ -216,14 +216,17 @@ bool SwCursorShell::SetCursorInHdFt( size_t nDescNo, bool 
bInHeader )
 const SwFormatContent* pCnt = nullptr;
 if( bInHeader )
 {
-// mirrored pages? ignore for now
-const SwFormatHeader& rHd = pDesc->GetMaster().GetHeader();
+const SwFormatHeader& rHd
+= bEven ? bFirst ? pDesc->GetFirstLeft().GetHeader() : 
pDesc->GetLeft().GetHeader()
+: bFirst ? pDesc->GetFirstMaster().GetHeader() : 
pDesc->GetMaster().GetHeader();
 if( rHd.GetHeaderFormat() )
 pCnt = ()->GetContent();
 }
 else
 {
-const SwFormatFooter& rFt = pDesc->GetMaster().GetFooter();
+const SwFormatFooter& rFt
+= bEven ? bFirst ? pDesc->GetFirstLeft().GetFooter() : 
pDesc->GetLeft().GetFooter()
+: bFirst ? pDesc->GetFirstMaster().GetFooter() : 
pDesc->GetMaster().GetFooter();
 if( rFt.GetFooterFormat() )
 pCnt = ()->GetContent();
 }
diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index 672b953ff8e2..6ec8e23a6304 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -642,6 +642,11 @@ int AbstractSwPageNumberDlg_Impl::GetPageNumberAlignment() 
const
 return m_xDlg->GetPageNumberAlignment();
 }
 
+bool AbstractSwPageNumberDlg_Impl::GetMirrorOnEvenPages() const
+{
+return m_xDlg->GetMirrorOnEvenPages();
+}
+
 SvxNumType AbstractSwPageNumberDlg_Impl::GetPageNumberType() const
 {
 return m_xDlg->GetPageNumberType();
diff --git a/sw/source/ui/dialog/swdlgfact.hxx 
b/sw/source/ui/dialog/swdlgfact.hxx
index 788aaa9c6f80..6d3f37aa6a47 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -166,6 +166,7 @@ public:
 virtual bool StartExecuteAsync(AsyncContext ) override;
 virtual int GetPageNumberPosition() const override;
 virtual int GetPageNumberAlignment() const 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-27 Thread Noel Grandin (via logerrit)
 sw/inc/accmap.hxx|1 
 sw/source/core/access/accmap.cxx |  681 ++-
 2 files changed, 319 insertions(+), 363 deletions(-)

New commits:
commit 59036776b92c0f4ad2edd1bafd332f7a4ee87cdc
Author: Noel Grandin 
AuthorDate: Wed Apr 26 15:15:01 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Apr 27 08:14:31 2023 +0200

tdf#136749 no need to use maMutex in SwAccessibleMap

we already need to be running under the SolarMutex, so just use that.

Shaves some 5% off time here.

Change-Id: Ife13f44d2e52171638bebcee946f5a1f07248cb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151062
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx
index 0090d7837876..33f3a2d93f94 100644
--- a/sw/inc/accmap.hxx
+++ b/sw/inc/accmap.hxx
@@ -89,7 +89,6 @@ class SwAccessibleMap final : public 
::accessibility::IAccessibleViewForwarder,
 public ::accessibility::IAccessibleParent
 , public std::enable_shared_from_this
 {
-mutable ::osl::Mutex maMutex;
 ::osl::Mutex maEventMutex;
 std::unique_ptr mpFrameMap;
 std::unique_ptr mpShapeMap;
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index fdee09f67722..6dc1feaa8dd5 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -1142,6 +1142,8 @@ void SwAccessibleMap::InvalidateShapeSelection()
 //3.find the paragraph objects and set the selected state.
 void SwAccessibleMap::InvalidateShapeInParaSelection()
 {
+DBG_TESTSOLARMUTEX();
+
 std::unique_ptr pShapes;
 SwAccessibleObjShape_Impl *pSelShape = nullptr;
 size_t nShapes = 0;
@@ -1152,11 +1154,8 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
 
 //const size_t nSelShapes = pFESh ? pFESh->IsObjSelected() : 0;
 
-{
-osl::MutexGuard aGuard( maMutex );
-if( mpShapeMap )
-pShapes = mpShapeMap->Copy( nShapes, pFESh,  );
-}
+if( mpShapeMap )
+pShapes = mpShapeMap->Copy( nShapes, pFESh,  );
 
 bool bIsSelAll =IsDocumentSelAll();
 
@@ -1478,6 +1477,8 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
 //Merge with DoInvalidateShapeFocus
 void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode 
/*=false*/)
 {
+DBG_TESTSOLARMUTEX();
+
 std::unique_ptr pShapes;
 SwAccessibleObjShape_Impl *pSelShape = nullptr;
 size_t nShapes = 0;
@@ -1492,11 +1493,8 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool 
bInvalidateFocusMode /*=fa
 {
 return;
 }
-{
-osl::MutexGuard aGuard( maMutex );
-if( mpShapeMap )
-pShapes = mpShapeMap->Copy( nShapes, pFESh,  );
-}
+if( mpShapeMap )
+pShapes = mpShapeMap->Copy( nShapes, pFESh,  );
 
 if( !pShapes )
 return;
@@ -1650,19 +1648,17 @@ SwAccessibleMap::SwAccessibleMap( SwViewShell *pSh ) :
 SwAccessibleMap::~SwAccessibleMap()
 {
 DBG_TESTSOLARMUTEX();
+
 uno::Reference < XAccessible > xAcc;
+if( mpFrameMap )
 {
-osl::MutexGuard aGuard( maMutex );
-if( mpFrameMap )
-{
-const SwRootFrame *pRootFrame = GetShell()->GetLayout();
-SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( 
pRootFrame );
-if( aIter != mpFrameMap->end() )
-xAcc = (*aIter).second;
-if( !xAcc.is() )
-assert(false); // let's hope this can't happen? the 
vcl::Window apparently owns the top-level
-//xAcc = new SwAccessibleDocument(shared_from_this());
-}
+const SwRootFrame *pRootFrame = GetShell()->GetLayout();
+SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( 
pRootFrame );
+if( aIter != mpFrameMap->end() )
+xAcc = (*aIter).second;
+if( !xAcc.is() )
+assert(false); // let's hope this can't happen? the vcl::Window 
apparently owns the top-level
+//xAcc = new SwAccessibleDocument(shared_from_this());
 }
 
 if(xAcc.is())
@@ -1687,17 +1683,14 @@ SwAccessibleMap::~SwAccessibleMap()
 }
 }
 #endif
-{
-osl::MutexGuard aGuard( maMutex );
-assert((!mpFrameMap || mpFrameMap->empty()) &&
-"Frame map should be empty after disposing the root frame");
-assert((!mpShapeMap || mpShapeMap->empty()) &&
-"Object map should be empty after disposing the root frame");
-mpFrameMap.reset();
-mpShapeMap.reset();
-mvShapes.clear();
-mpSelectedParas.reset();
-}
+assert((!mpFrameMap || mpFrameMap->empty()) &&
+"Frame map should be empty after disposing the root frame");
+assert((!mpShapeMap || mpShapeMap->empty()) &&
+"Object map should be empty after disposing the root frame");
+mpFrameMap.reset();
+mpShapeMap.reset();
+

[Libreoffice-commits] core.git: sw/inc sw/source sw/uiconfig

2023-04-26 Thread Justin Luth (via logerrit)
 sw/inc/swabstdlg.hxx|3 ++
 sw/source/ui/dialog/swdlgfact.cxx   |   10 +++
 sw/source/ui/dialog/swdlgfact.hxx   |2 +
 sw/source/ui/misc/pagenumberdlg.cxx |   16 +++
 sw/source/uibase/inc/pagenumberdlg.hxx  |7 +
 sw/source/uibase/shells/textfld.cxx |   17 +++-
 sw/uiconfig/swriter/ui/pagenumberdlg.ui |   43 
 7 files changed, 97 insertions(+), 1 deletion(-)

New commits:
commit f6f14b98b8be8319c810708e73cffdb189c467ca
Author: Justin Luth 
AuthorDate: Tue Apr 25 16:45:52 2023 -0400
Commit: Miklos Vajna 
CommitDate: Wed Apr 26 09:35:31 2023 +0200

tdf#86630 sw page number wizard: set page style numbering type

Giving the user the opportunity to change the number type
is rather important. Well, maybe not too critical since I
assume that the default page number style is relatively accurate
for each locale, and at least for English we always just
use numbers for the page style.

However, a wizard is the perfect place to expose such a setting,
otherwise it is buried in page style settings - far from
where anyone would look when inserting a page number.

Change-Id: I9053504fa55d16ebf5424946b480cb044b79988c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151005
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index cbe4cd9aaf80..9749539c5643 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -19,6 +19,7 @@
 #ifndef INCLUDED_SW_INC_SWABSTDLG_HXX
 #define INCLUDED_SW_INC_SWABSTDLG_HXX
 
+#include 
 #include 
 #include 
 #include 
@@ -237,6 +238,8 @@ protected:
 public:
 virtual int GetPageNumberPosition() const = 0;
 virtual int GetPageNumberAlignment() const = 0;
+virtual SvxNumType GetPageNumberType() const = 0;
+virtual void SetPageNumberType(SvxNumType nSet) = 0;
 };
 
 /**
diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index 694813bbb51a..672b953ff8e2 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -642,6 +642,16 @@ int AbstractSwPageNumberDlg_Impl::GetPageNumberAlignment() 
const
 return m_xDlg->GetPageNumberAlignment();
 }
 
+SvxNumType AbstractSwPageNumberDlg_Impl::GetPageNumberType() const
+{
+return m_xDlg->GetPageNumberType();
+}
+
+void AbstractSwPageNumberDlg_Impl::SetPageNumberType(SvxNumType nSet)
+{
+m_xDlg->SetPageNumberType(nSet);
+}
+
 bool AbstractInsFootNoteDlg_Impl::IsEndNote()
 {
 return m_xDlg->IsEndNote();
diff --git a/sw/source/ui/dialog/swdlgfact.hxx 
b/sw/source/ui/dialog/swdlgfact.hxx
index 8fee741ff96b..788aaa9c6f80 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -166,6 +166,8 @@ public:
 virtual bool StartExecuteAsync(AsyncContext ) override;
 virtual int GetPageNumberPosition() const override;
 virtual int GetPageNumberAlignment() const override;
+SvxNumType GetPageNumberType() const override;
+void SetPageNumberType(SvxNumType nSet) override;
 };
 
 class AbstractGenericDialog_Impl : public VclAbstractDialog
diff --git a/sw/source/ui/misc/pagenumberdlg.cxx 
b/sw/source/ui/misc/pagenumberdlg.cxx
index ed889a277852..0c6357e7ef99 100644
--- a/sw/source/ui/misc/pagenumberdlg.cxx
+++ b/sw/source/ui/misc/pagenumberdlg.cxx
@@ -18,6 +18,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -29,6 +30,7 @@ SwPageNumberDlg::SwPageNumberDlg(weld::Window* pParent)
 , m_xCancel(m_xBuilder->weld_button("cancel"))
 , m_xPageNumberPosition(m_xBuilder->weld_combo_box("positionCombo"))
 , m_xPageNumberAlignment(m_xBuilder->weld_combo_box("alignmentCombo"))
+, m_xPageNumberTypeLB(new 
SvxPageNumberListBox(m_xBuilder->weld_combo_box("numfmtlb")))
 , m_xPreviewImage(m_xBuilder->weld_image("previewImage"))
 , m_aPageNumberPosition(1) // bottom
 , m_aPageNumberAlignment(1) // center
@@ -38,6 +40,9 @@ SwPageNumberDlg::SwPageNumberDlg(weld::Window* pParent)
 m_xPageNumberAlignment->connect_changed(LINK(this, SwPageNumberDlg, 
AlignmentSelectHdl));
 m_xPageNumberPosition->set_active(m_aPageNumberPosition);
 m_xPageNumberAlignment->set_active(m_aPageNumberAlignment);
+
SvxNumOptionsTabPageHelper::GetI18nNumbering(m_xPageNumberTypeLB->get_widget(),
+ 
::std::numeric_limits::max());
+m_xPageNumberTypeLB->connect_changed(LINK(this, SwPageNumberDlg, 
NumberTypeSelectHdl));
 updateImage();
 }
 
@@ -55,6 +60,17 @@ IMPL_LINK_NOARG(SwPageNumberDlg, AlignmentSelectHdl, 
weld::ComboBox&, void)
 updateImage();
 }
 
+IMPL_LINK_NOARG(SwPageNumberDlg, NumberTypeSelectHdl, weld::ComboBox&, void)
+{
+m_nPageNumberType = m_xPageNumberTypeLB->get_active_id();
+}
+
+void SwPageNumberDlg::SetPageNumberType(SvxNumType nSet)
+{
+m_nPageNumberType = nSet;
+

[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-24 Thread László Németh (via logerrit)
 sw/inc/swtable.hxx|2 ++
 sw/source/core/table/swtable.cxx  |   10 --
 sw/source/uibase/shells/tabsh.cxx |   14 +-
 3 files changed, 15 insertions(+), 11 deletions(-)

New commits:
commit 5e6d8efbf3fb456ca370df04b21d2e340d9831ad
Author: László Németh 
AuthorDate: Mon Apr 24 13:08:55 2023 +0200
Commit: László Németh 
CommitDate: Mon Apr 24 17:22:39 2023 +0200

tdf#154859 sw: fix deletion of tracked row insertion

Row deletion of tracked row insertions resulted an
empty, not tracked row. To fix this, disable row
deletion on tracked row insertions, allowing only to
manage changes for removing the row, e.g. by clicking
on Reject Change of the context menu of the table row,
like MSO does.

This also avoids of clicking again on the row deletion
to create an empty tracked row deletion from the
empty not tracked row, and originally, from the tracked
row insertion.

Regression from commit 05366b8e6683363688de8708a3d88cf144c7a2bf
"tdf#60382 sw offapi: add change tracking of table/row deletion".

Follow-up to commit 0204c00f241313e1d292b4c3ea117d42af7dec69
"tdf#147453 sw: disable Delete Table functions on tracked deletions".

See also commit 95c003d75e0f8b255344715a35358072b5eba99d
"tdf#146145 sw: 1-click Accept/Reject of table row changes".

Change-Id: Ied38860939359caa52e09987cf968953399611ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150938
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 3015223ef451..272ba18393f1 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -426,6 +426,8 @@ public:
 // Cache also the type of the redline associated to the changed table row.
 SwRedlineTable::size_type UpdateTextChangesOnly(
 SwRedlineTable::size_type& rRedlinePos, bool bUpdateProperty = true) 
const;
+// is it a tracked row
+bool IsTracked(SwRedlineTable::size_type& rRedlinePos, bool bOnlyDeleted = 
false) const;
 // is it a tracked deleted row
 bool IsDeleted(SwRedlineTable::size_type& rRedlinePos) const;
 // set/get (if it's possible, cached) redline type
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 889f4820e0fd..523f14e0c46f 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1892,19 +1892,25 @@ SwRedlineTable::size_type 
SwTableLine::UpdateTextChangesOnly(
 return nRet;
 }
 
-bool SwTableLine::IsDeleted(SwRedlineTable::size_type& rRedlinePos) const
+bool SwTableLine::IsTracked(SwRedlineTable::size_type& rRedlinePos, bool 
bOnlyDeleted) const
 {
SwRedlineTable::size_type nPos = UpdateTextChangesOnly(rRedlinePos);
if ( nPos != SwRedlineTable::npos )
{
const SwRedlineTable& aRedlineTable =

GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
-   if ( RedlineType::Delete == aRedlineTable[nPos]->GetType() )
+   if ( RedlineType::Delete == aRedlineTable[nPos]->GetType() ||
+( !bOnlyDeleted && RedlineType::Insert == 
aRedlineTable[nPos]->GetType() ) )
return true;
}
return false;
 }
 
+bool SwTableLine::IsDeleted(SwRedlineTable::size_type& rRedlinePos) const
+{
+   return IsTracked(rRedlinePos, true);
+}
+
 RedlineType SwTableLine::GetRedlineType() const
 {
 const SwRedlineTable& aRedlineTable = 
GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
diff --git a/sw/source/uibase/shells/tabsh.cxx 
b/sw/source/uibase/shells/tabsh.cxx
index d85c132c15bc..855685eda05d 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -446,17 +446,13 @@ static void lcl_TabGetMaxLineWidth(const SvxBorderLine* 
pBorderLine, SvxBorderLi
 rBorderLine.SetColor(pBorderLine->GetColor());
 }
 
-static bool lcl_BoxesInDeletedRows(SwWrtShell , const SwSelBoxes& rBoxes)
+static bool lcl_BoxesInTrackedRows(SwWrtShell , const SwSelBoxes& rBoxes)
 {
-// cursor and selection are there only in deleted rows in Show Changes mode
-if ( rSh.GetLayout()->IsHideRedlines() )
-return false;
-
-// not selected or all selected rows are deleted
+// cursor and selection are there only in tracked rows
 bool bRet = true;
 SwRedlineTable::size_type nRedlinePos = 0;
 if ( rBoxes.empty() )
-bRet = 
rSh.GetCursor()->GetPointNode().GetTableBox()->GetUpper()->IsDeleted(nRedlinePos);
+bRet = 
rSh.GetCursor()->GetPointNode().GetTableBox()->GetUpper()->IsTracked(nRedlinePos);
 else
 {
 tools::Long nBoxes = rBoxes.size();
@@ -465,7 +461,7 @@ static bool lcl_BoxesInDeletedRows(SwWrtShell , const 
SwSelBoxes& rBoxes)
 {
 SwTableLine* pLine = rBoxes[i]->GetUpper();
 if ( pLine != pPrevLine )
-bRet &= pLine->IsDeleted(nRedlinePos);
+bRet &= 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-21 Thread Noel Grandin (via logerrit)
 sw/inc/unodraw.hxx |3 +--
 sw/source/core/unocore/unodraw.cxx |9 -
 2 files changed, 1 insertion(+), 11 deletions(-)

New commits:
commit 89cbbbe7f11b941be27b81eb50cfac614d195c2e
Author: Noel Grandin 
AuthorDate: Fri Apr 21 09:33:01 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Apr 21 13:41:09 2023 +0200

SwXShape no longer needs to extend SvtListener

after
commit 40babcfa637957bf7b59caa3cd12a630189e3e63
tdf#154827 and tdf#154428 graphics anchored in Writer as character.

Change-Id: Iad3ad440690fa9b8530f32e17a113b8365656a05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150746
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx
index cc3daaf49d69..3353843219e9 100644
--- a/sw/inc/unodraw.hxx
+++ b/sw/inc/unodraw.hxx
@@ -127,7 +127,7 @@ cppu::WeakImplHelper
 css::drawing::XShape
 >
 SwXShapeBaseClass;
-class SwXShape : public SwXShapeBaseClass, public SvtListener
+class SwXShape : public SwXShapeBaseClass
 {
 friend class SwXGroupShape;
 friend class SwFmDrawPage;
@@ -200,7 +200,6 @@ protected:
 public:
 SwXShape(css::uno::Reference & xShape, SwDoc 
const*const pDoc);
 
-virtual void Notify(const SfxHint&) override;
 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType 
) override;
 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes(  ) 
override;
diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index 61e2649f212b..a096f4f12268 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -995,7 +995,6 @@ SwXShape::~SwXShape()
 m_xShapeAgg->setDelegator(xRef);
 }
 m_pImpl.reset();
-EndListeningAll();
 if(m_pPage)
const_cast(m_pPage)->RemoveShape(this);
 }
@@ -2084,14 +2083,6 @@ void SwXShape::removeVetoableChangeListener(
 OSL_FAIL("not implemented");
 }
 
-void SwXShape::Notify(const SfxHint& rHint)
-{
-if(rHint.GetId() == SfxHintId::Dying)
-{
-EndListeningAll();
-}
-}
-
 void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange)
 {
 SolarMutexGuard aGuard;


[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-20 Thread Noel Grandin (via logerrit)
 sw/inc/unodraw.hxx |9 +
 sw/source/core/unocore/unodraw.cxx |   28 +---
 2 files changed, 10 insertions(+), 27 deletions(-)

New commits:
commit 40babcfa637957bf7b59caa3cd12a630189e3e63
Author: Noel Grandin 
AuthorDate: Thu Apr 20 13:49:44 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Apr 20 15:05:02 2023 +0200

tdf#154827 and tdf#154428 graphics anchored in Writer as character..

..become anchored at paragraph when reopening the document

regression from
commit 8611f6e259b807b4f19c8dc0eab86ca648891ce3
ref-count SdrObject

This used to work by accident, previously, the SwXGroupShape that we
need would get created and destroyed and handful of times, and then
properly created.

Now, however, the first time we create it it sticks around, which means
it does not get the m_pFormat field configured correctly.

Fix this by removing the caching of m_pFormat from SwXShape, and just
fetching it from the model when we need it.

Change-Id: I10fe2ad0b877b3d928d5288e73cfed373b27a506
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150687
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx
index 1f9efea10eac..cc3daaf49d69 100644
--- a/sw/inc/unodraw.hxx
+++ b/sw/inc/unodraw.hxx
@@ -132,7 +132,6 @@ class SwXShape : public SwXShapeBaseClass, public 
SvtListener
 friend class SwXGroupShape;
 friend class SwFmDrawPage;
 const SwFmDrawPage* m_pPage;
-SwFrameFormat* m_pFormat;
 
 css::uno::Reference< css::uno::XAggregation > m_xShapeAgg;
 // reference to , determined in the
@@ -195,12 +194,6 @@ class SwXShape : public SwXShapeBaseClass, public 
SvtListener
 @throws css::uno::RuntimeException
 */
 css::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName );
-void SetFrameFormat(SwFrameFormat* pFormat)
-{
-EndListeningAll();
-StartListening(pFormat->GetNotifier());
-m_pFormat = pFormat;
-}
 
 protected:
 virtual ~SwXShape() override;
@@ -252,7 +245,7 @@ public:
 virtual OUString SAL_CALL getShapeType(  ) override;
 
 SwShapeDescriptor_Impl* GetDescImpl() {return m_pImpl.get();}
-SwFrameFormat* GetFrameFormat() const { return m_pFormat; }
+SwFrameFormat* GetFrameFormat() const;
 const css::uno::Reference< css::uno::XAggregation >& 
GetAggregationInterface() const {return m_xShapeAgg;}
 
 // helper
diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index 7337ce297895..61e2649f212b 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -639,7 +639,7 @@ void SwFmDrawPage::add(const uno::Reference< 
drawing::XShape > & xShape)
 static_cast< cppu::OWeakObject * > ( this 
) );
 
 // we're already registered in the model / SwXDrawPage::add() already 
called
-if(pShape->m_pPage || pShape->m_pFormat || !pShape->m_bDescriptor )
+if(pShape->m_pPage || !pShape->m_bDescriptor )
 return;
 
 // we're inserted elsewhere already
@@ -787,7 +787,6 @@ void SwFmDrawPage::add(const uno::Reference< 
drawing::XShape > & xShape)
 {
 pFormat->SetFormatName(pSvxShape->GetSdrObject()->GetName(), 
false);
 }
-pShape->SetFrameFormat(pFormat);
 }
 pShape->m_bDescriptor = false;
 
@@ -917,7 +916,6 @@ SwXShape::SwXShape(
 uno::Reference & xShape,
 SwDoc const*const pDoc)
 : m_pPage(nullptr)
-, m_pFormat(nullptr)
 , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SHAPE))
 , 
m_pPropertyMapEntries(aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_TEXT_SHAPE))
 , m_pImpl(new SwShapeDescriptor_Impl(pDoc))
@@ -948,16 +946,20 @@ SwXShape::SwXShape(
 SdrObject* pObj = SdrObject::getSdrObjectFromXShape(m_xShapeAgg);
 if(pObj)
 {
-auto pFormat = ::FindFrameFormat( pObj );
-if(pFormat)
-SetFrameFormat(pFormat);
-
 lcl_addShapePropertyEventFactories( *pObj, *this );
 m_pImpl->m_bInitializedPropertyNotifier = true;
 }
 
 }
 
+SwFrameFormat* SwXShape::GetFrameFormat() const
+{
+SdrObject* pObj = SdrObject::getSdrObjectFromXShape(m_xShapeAgg);
+if(pObj)
+return ::FindFrameFormat( pObj );
+return nullptr;
+}
+
 void SwXShape::AddExistingShapeToFormat( SdrObject const & _rObj )
 {
 SdrObjListIter aIter( _rObj, SdrIterMode::DeepNoGroups );
@@ -972,12 +974,7 @@ void SwXShape::AddExistingShapeToFormat( SdrObject const & 
_rObj )
 if ( pSwShape )
 {
 if ( pSwShape->m_bDescriptor )
-{
-auto pFormat = ::FindFrameFormat( pCurrent );
-if ( pFormat )
-pSwShape->SetFrameFormat(pFormat);
 pSwShape->m_bDescriptor = false;
-}
 
 if ( 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-19 Thread Noel Grandin (via logerrit)
 sw/inc/fldbas.hxx   |   11 ++-
 sw/source/core/fields/fldbas.cxx|8 
 sw/source/core/unocore/unofield.cxx |2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit e5e4472e4ebe0f84087cfaa551e3fc28e94fd399
Author: Noel Grandin 
AuthorDate: Tue Apr 18 22:52:02 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Apr 19 11:25:21 2023 +0200

use more concrete UNO type in SwFieldType

Change-Id: Iffb0ffad6daf102299fa7ce072bfc117cdf38b55
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150589
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 8ece6e214da1..4aa874c3021d 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -28,6 +28,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -39,6 +41,7 @@ class SwRootFrame;
 class SvNumberFormatter;
 class IDocumentRedlineAccess;
 class SwGetRefField;
+class SwXFieldMaster;
 namespace com::sun::star::uno { class Any; }
 
 typedef struct _xmlTextWriter* xmlTextWriterPtr;
@@ -242,7 +245,7 @@ SwFieldTypesEnum SwFieldTypeFromString(std::u16string_view 
rString);
 
 class SW_DLLPUBLIC SwFieldType : public sw::BroadcastingModify
 {
-css::uno::WeakReference m_wXFieldMaster;
+unotools::WeakReference m_wXFieldMaster;
 
 SwFieldIds m_nWhich;
 
@@ -257,12 +260,10 @@ protected:
 
 public:
 
-SAL_DLLPRIVATE css::uno::WeakReference const& 
GetXObject() const {
+unotools::WeakReference const& GetXObject() const {
 return m_wXFieldMaster;
 }
-SAL_DLLPRIVATE void 
SetXObject(css::uno::Reference const& xFieldMaster) {
-m_wXFieldMaster = xFieldMaster;
-}
+void SetXObject(rtl::Reference const& xFieldMaster);
 
 static const OUString & GetTypeStr( SwFieldTypesEnum nTypeId );
 
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index f511c047b183..c528f2a0d65a 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace nsSwDocInfoSubType;
@@ -220,6 +221,11 @@ void SwFieldType::UpdateFields()
 CallSwClientNotify(sw::LegacyModifyHint(nullptr, nullptr));
 };
 
+void SwFieldType::SetXObject(rtl::Reference const& 
xFieldMaster)
+{
+m_wXFieldMaster = xFieldMaster.get();
+}
+
 void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes"));
@@ -229,6 +235,8 @@ void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const
 (void)xmlTextWriterEndElement(pWriter);
 }
 
+
+
 // Base class for all fields.
 // A field (multiple can exist) references a field type (can exists only once)
 SwField::SwField(
diff --git a/sw/source/core/unocore/unofield.cxx 
b/sw/source/core/unocore/unofield.cxx
index 019da24f7241..36a4f5b27bc6 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -528,7 +528,7 @@ SwXFieldMaster::CreateXFieldMaster(SwDoc * pDoc, 
SwFieldType *const pType,
 rtl::Reference xFM;
 if (pType)
 {
-xFM = dynamic_cast(pType->GetXObject().get().get());
+xFM = pType->GetXObject().get();
 }
 if (!xFM.is())
 {


[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-19 Thread Noel Grandin (via logerrit)
 sw/inc/tblafmt.hxx  |   15 +--
 sw/source/core/doc/tblafmt.cxx  |6 ++
 sw/source/core/unocore/unostyle.cxx |   33 ++---
 3 files changed, 29 insertions(+), 25 deletions(-)

New commits:
commit 6f6a31d3e3b2ff113d5cc3a1ea960059cf09ceae
Author: Noel Grandin 
AuthorDate: Tue Apr 18 21:20:12 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Apr 19 08:07:08 2023 +0200

use more concrete UNO type in SwBoxAutoFormat

rather than hiding the relationship behind XInterface

Change-Id: Ie5e6e527d39ab2b4a26ae7830a196b354d2a6f04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150586
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index 2f6c8f788f11..d007130f1fa8 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -34,6 +34,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "fmtornt.hxx"
 #include "swdllapi.h"
 
@@ -41,8 +43,9 @@ struct SwAfVersions;
 
 class SvNumberFormatter;
 class SwTable;
+class SwXTextCellStyle;
 
-class SwBoxAutoFormat : public AutoFormatBase
+class SW_DLLPUBLIC SwBoxAutoFormat : public AutoFormatBase
 {
 private:
 // Writer specific
@@ -54,7 +57,8 @@ private:
 LanguageTypem_eSysLanguage;
 LanguageTypem_eNumFormatLanguage;
 
-css::uno::WeakReference m_wXObject;
+// associated UNO object, if such exists
+unotools::WeakReference m_xAutoFormatUnoObject;
 
 public:
 SwBoxAutoFormat();
@@ -89,10 +93,9 @@ public:
 void SetSysLanguage(const LanguageType& rNew) { m_eSysLanguage = rNew; }
 void SetNumFormatLanguage(const LanguageType& rNew) { m_eNumFormatLanguage 
= rNew; }
 
-css::uno::WeakReference const& GetXObject() const
-{ return m_wXObject; }
-void SetXObject(css::uno::Reference const& xObject)
-{ m_wXObject = xObject; }
+unotools::WeakReference const& GetXObject() const
+{ return m_xAutoFormatUnoObject; }
+void SetXObject(rtl::Reference const& xObject);
 
 bool Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 
nVer );
 bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index d90760532a44..858441f87b6c 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -361,6 +362,11 @@ bool SwBoxAutoFormat::Save( SvStream& rStream, sal_uInt16 
fileVersion ) const
 return ERRCODE_NONE == rStream.GetError();
 }
 
+void SwBoxAutoFormat::SetXObject(rtl::Reference const& 
xObject)
+{
+m_xAutoFormatUnoObject = xObject.get();
+}
+
 SwTableAutoFormat::SwTableAutoFormat( OUString aName )
 : m_aName( std::move(aName) )
 , m_nStrResId( USHRT_MAX )
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 81f74230b6de..d6272e3a5f59 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -4314,7 +4314,7 @@ void SwXTextTableStyle::UpdateCellStylesMapping()
 for (sal_Int32 i=0; iGetBoxFormat(aTableTemplateMap[i]);
-uno::Reference xCellStyle(pBoxFormat->GetXObject(), 
uno::UNO_QUERY);
+rtl::Reference xCellStyle(pBoxFormat->GetXObject());
 if (!xCellStyle.is())
 {
 xCellStyle.set(new SwXTextCellStyle(m_pDocShell, pBoxFormat, 
m_pTableAutoFormat->GetName()));
@@ -4383,12 +4383,11 @@ void SwXTextTableStyle::SetPhysical()
 for (size_t i=0; iGetBoxFormat(aTableTemplateMap[i]);
-uno::Reference 
xCellStyle(pOldBoxFormat->GetXObject(), uno::UNO_QUERY);
+rtl::Reference 
xCellStyle(pOldBoxFormat->GetXObject());
 if (!xCellStyle.is())
 continue;
-SwXTextCellStyle& rStyle = 
dynamic_cast(*xCellStyle);
 SwBoxAutoFormat& rNewBoxFormat = 
pTableAutoFormat->GetBoxFormat(aTableTemplateMap[i]);
-rStyle.SetBoxFormat();
+xCellStyle->SetBoxFormat();
 rNewBoxFormat.SetXObject(xCellStyle);
 }
 m_pTableAutoFormat_Impl = nullptr;
@@ -4549,30 +4548,26 @@ void SAL_CALL SwXTextTableStyle::replaceByName(const 
OUString& rName, const uno:
 throw container::NoSuchElementException();
 const sal_Int32 nCellStyle = iter->second;
 
-uno::Reference xStyle = 
rElement.get>();
-if (!xStyle.is())
+rtl::Reference xStyleToReplaceWith = 
dynamic_cast(rElement.get>().get());
+if (!xStyleToReplaceWith.is())
 throw lang::IllegalArgumentException();
 
-SwXTextCellStyle* pStyleToReplaceWith = 
dynamic_cast(xStyle.get());
-if (!pStyleToReplaceWith)
- throw lang::IllegalArgumentException();
-
 // replace only with physical ...
-if 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-13 Thread Miklos Vajna (via logerrit)
 sw/inc/strings.hrc  |1 +
 sw/inc/swundo.hxx   |1 +
 sw/source/core/undo/undobj.cxx  |3 +++
 sw/source/uibase/shells/textsh1.cxx |4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 95eb99866b3ac1a1639d3399f42f82a0670eb23a
Author: Miklos Vajna 
AuthorDate: Wed Apr 12 20:09:20 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Apr 13 08:12:21 2023 +0200

sw: fix undo comment of FN_DELETE_FIELDS

It's fields, not field. One has to dispatch .uno:DeleteFields to see
this in action, which does something if the document already has
existing reference marks.

Change-Id: I81e3be3f2b68bfee2ed85a2a060dd05c3eb56670
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150300
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index ee573c4d2c93..a9e5a78828e0 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -443,6 +443,7 @@
 #define STR_UPDATE_BOOKMARKSNC_("STR_UPDATE_BOOKMARKS", 
"Update bookmarks")
 #define STR_UPDATE_FIELDNC_("STR_UPDATE_FIELD", 
"Update field: $1")
 #define STR_UPDATE_FIELDS   NC_("STR_UPDATE_FIELDS", 
"Update fields")
+#define STR_DELETE_FIELDS   NC_("STR_DELETE_FIELDS", 
"Delete fields")
 #define STR_SORT_TBLNC_("STR_SORT_TBL", "Sort 
table")
 #define STR_SORT_TXTNC_("STR_SORT_TXT", "Sort 
text")
 #define STR_INSTABLE_UNDO   NC_("STR_INSTABLE_UNDO", 
"Insert table: $1$2$3")
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index 105991347fdb..bf0fd165d3c6 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -175,6 +175,7 @@ enum class SwUndoId
 DELETE_BOOKMARKS,  // 143
 UPDATE_FIELD,  // 144
 UPDATE_FIELDS, // 145
+DELETE_FIELDS, // 146
 };
 
 OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 27a637616608..e1fa8570f054 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -670,6 +670,9 @@ OUString GetUndoComment(SwUndoId eId)
 case SwUndoId::UPDATE_FIELDS:
 pId = STR_UPDATE_FIELDS;
 break;
+case SwUndoId::DELETE_FIELDS:
+pId = STR_DELETE_FIELDS;
+break;
 }
 
 assert(pId);
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index 4f1ace85cbcb..f5f33c12e0e3 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -725,13 +725,13 @@ void DeleteFields(SfxRequest& rReq, SwWrtShell& rWrtSh)
 }
 
 SwDoc* pDoc = rWrtSh.GetDoc();
-pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::DELBOOKMARK, nullptr);
+pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::DELETE_FIELDS, nullptr);
 rWrtSh.StartAction();
 comphelper::ScopeGuard g(
 []
 {
 rWrtSh.EndAction();
-
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::DELBOOKMARK, nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::DELETE_FIELDS, 
nullptr);
 });
 
 std::vector aRemovals;


[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-11 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/frmfmt.hxx  |3 --
 sw/inc/hintids.hxx |1 
 sw/inc/section.hxx |2 +
 sw/source/core/docnode/node.cxx|   18 ---
 sw/source/core/docnode/section.cxx |   42 ++---
 sw/source/core/inc/doctxm.hxx  |3 --
 sw/source/core/layout/atrfrm.cxx   |   24 -
 sw/source/core/table/swtable.cxx   |4 ---
 sw/source/uibase/utlui/content.cxx |   10 ++--
 sw/source/uibase/wrtsh/wrtsh1.cxx  |9 +--
 10 files changed, 36 insertions(+), 80 deletions(-)

New commits:
commit b614797a34d25b35c06e20153495795ecfe4e4fe
Author: Bjoern Michaelsen 
AuthorDate: Wed Apr 5 08:28:14 2023 +0200
Commit: Bjoern Michaelsen 
CommitDate: Tue Apr 11 08:13:17 2023 +0200

introduce SwFrameFormat::IsVisible()

- as a replacement for RES_CONTENT_VISIBLE
- broadly: if a FrameFormat has at least one Frame, it is visible
- however, sections are special and need to recurse into their childs
- SwFlyFrameFormat::GetInfo then does not need to override anymore

Change-Id: I01c469e7330a7daaccd2be0541af1d83c7d1a424
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150038
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen 

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index eb97de392d15..ec67847247f8 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -183,6 +183,7 @@ public:
 
 virtual void SetFormatName( const OUString& rNewName, bool 
bBroadcast=false ) override;
 void MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat);
+virtual bool IsVisible() const;
 };
 
 // The FlyFrame-Format
@@ -219,8 +220,6 @@ public:
 
 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 
nMaximumQuadraticPixels = 50, const std::optional& rTargetDPI = 
std::nullopt ) override;
 
-virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
-
 OUString GetObjTitle() const;
 void SetObjTitle( const OUString& rTitle, bool bBroadcast = false );
 
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 0673e724552c..0428d5e1258a 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -438,7 +438,6 @@ constexpr TypedWhichId 
RES_VIRTPAGENUM_INFO(180);
 constexpr TypedWhichId RES_REMOVE_UNO_OBJECT(181);
 // empty
 constexpr TypedWhichId RES_FINDNEARESTNODE(184);
-constexpr TypedWhichId RES_CONTENT_VISIBLE(185);
 constexpr sal_uInt16 RES_FORMAT_MSG_END(190);
 
 // An ID for the RTF-reader. The stylesheets are treated like attributes,
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index 9e29e952cdec..f75c68b13f80 100644
--- a/sw/inc/section.hxx
+++ b/sw/inc/section.hxx
@@ -299,6 +299,8 @@ public:
 // Get information from Format.
 virtual bool GetInfo( SfxPoolItem& ) const override;
 
+virtual bool IsVisible() const override;
+
 SwSection* GetSection() const;
 inline SwSectionFormat* GetParent() const;
 inline SwSection* GetParentSection() const;
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 6002830a2525..91ac1697ea30 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1564,31 +1564,23 @@ SwContentNode *SwContentNode::JoinNext()
 return this;
 }
 
+
 /// Get info from Modify
 bool SwContentNode::GetInfo( SfxPoolItem& rInfo ) const
 {
 switch( rInfo.Which() )
 {
-case RES_AUTOFMT_DOCNODE:
-if( () == static_cast(rInfo).pNodes )
-{
-return false;
-}
-break;
-
 case RES_FINDNEARESTNODE:
 if( GetAttr( RES_PAGEDESC ).GetPageDesc() )
 static_cast(rInfo).CheckNode( *this );
 return true;
-
-case RES_CONTENT_VISIBLE:
+case RES_AUTOFMT_DOCNODE:
+if( () == static_cast(rInfo).pNodes )
 {
-static_cast(rInfo).pObject =
-SwIterator(*this).First();
+return false;
 }
-return false;
+break;
 }
-
 return sw::BroadcastingModify::GetInfo( rInfo );
 }
 
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index 46ac8308abd5..bce8f371f9ee 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -810,39 +810,31 @@ void 
SwSectionFormat::SetXTextSection(rtl::Reference const& xTex
 m_wXTextSection = xTextSection.get();
 }
 
+bool SwSectionFormat::IsVisible() const
+{
+if(SwFrameFormat::IsVisible())
+return true;
+SwIterator aFormatIter(*this);
+for(SwSectionFormat* pChild = aFormatIter.First(); pChild; pChild = 
aFormatIter.Next())
+if(pChild->IsVisible())
+return true;
+return false;
+}
+
 // Get info from the Format
-bool SwSectionFormat::GetInfo( SfxPoolItem& rInfo ) const
+bool SwSectionFormat::GetInfo(SfxPoolItem& rInfo) const
 {
-switch( rInfo.Which() )
+if(rInfo.Which() == RES_FINDNEARESTNODE)
 {
-case 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-09 Thread Eike Rathke (via logerrit)
 sw/inc/fldbas.hxx|5 
 sw/inc/usrfld.hxx|4 ++-
 sw/source/core/fields/fldbas.cxx |   37 
 sw/source/core/fields/usrfld.cxx |7 +-
 sw/source/ui/fldui/fldvar.cxx|   44 ---
 5 files changed, 79 insertions(+), 18 deletions(-)

New commits:
commit 185cf4496d8750c9e4905c4e384252b01b85d130
Author: Eike Rathke 
AuthorDate: Sun Apr 9 14:47:41 2023 +0200
Commit: Eike Rathke 
CommitDate: Mon Apr 10 00:56:42 2023 +0200

Resolves: tdf#154217 Edit date+time User Field and Set Variable

... instead of the raw numeric value.

Change-Id: I256cb4fde1e4ea6b0580b3208c5d4948e2573448
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150169
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 5768d822d853..8ece6e214da1 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -442,6 +442,8 @@ public:
 OUStringExpandValue(const double& rVal, sal_uInt32 nFormat, 
LanguageType nLng) const;
 OUStringDoubleToString(const double , LanguageType eLng) 
const;
 OUStringDoubleToString(const double , sal_uInt32 nFormat) 
const;
+/// Query input or formatted value for dialog.
+OUStringGetInputOrDateTime( const OUString& rInput, const double& 
rVal, sal_uInt32 nFormat ) const;
 };
 
 class SW_DLLPUBLIC SwValueField : public SwField
@@ -489,6 +491,9 @@ public:
 
 voidSetExpandedFormula(const OUString& rStr);
 OUStringGetExpandedFormula() const;
+
+/// Query formula or formatted value for dialog.
+OUStringGetInputOrDateTime() const;
 };
 
 #endif // INCLUDED_SW_INC_FLDBAS_HXX
diff --git a/sw/inc/usrfld.hxx b/sw/inc/usrfld.hxx
index faedb80671a8..28d582c4c5ac 100644
--- a/sw/inc/usrfld.hxx
+++ b/sw/inc/usrfld.hxx
@@ -52,9 +52,11 @@ public:
 
 OUStringExpand(sal_uInt32 nFormat, sal_uInt16 nSubType, 
LanguageType nLng);
 
-OUStringGetContent( sal_uInt32 nFormat = 0 );
+OUStringGetContent( sal_uInt32 nFormat = 0 ) const;
void SetContent( const OUString& rStr, sal_uInt32 
nFormat = 0 );
 
+OUStringGetInputOrDateTime( sal_uInt32 nFormat ) const;
+
 inline bool IsValid() const;
 
double   GetValue(SwCalc& rCalc);// Recalculate member 
nValue.
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 2f816d208938..f511c047b183 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -24,6 +24,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -648,6 +649,22 @@ OUString SwValueFieldType::DoubleToString( const double 
,
 pFormatter->GetNumDecimalSep()[0], true );
 }
 
+OUString SwValueFieldType::GetInputOrDateTime( const OUString& rInput, const 
double& rVal, sal_uInt32 nFormat ) const
+{
+if (nFormat && nFormat != SAL_MAX_UINT32 && UseFormat())
+{
+SvNumberFormatter* pFormatter = m_pDoc->GetNumberFormatter();
+const SvNumberformat* pEntry = pFormatter->GetEntry(nFormat);
+if (pEntry && (pEntry->GetType() & SvNumFormatType::DATETIME))
+{
+OUString aEdit;
+pFormatter->GetInputLineString( rVal, nFormat, aEdit);
+return aEdit;
+}
+}
+return rInput;
+}
+
 SwValueField::SwValueField( SwValueFieldType* pFieldType, sal_uInt32 nFormat,
 LanguageType nLng, const double fVal )
 : SwField(pFieldType, nFormat, nLng)
@@ -861,6 +878,26 @@ OUString SwFormulaField::GetExpandedFormula() const
 return GetFormula();
 }
 
+OUString SwFormulaField::GetInputOrDateTime() const
+{
+// GetFormula() leads to problems with date formats because only the
+// number string without formatting is returned (additionally that may or
+// may not use a localized decimal separator due to the convoluted handling
+// of "formula"). It must be used for expressions though because otherwise
+// with GetPar2() only the value calculated by SwCalc would be displayed
+// (instead of test2 = test + 1).
+// Force a formatted edit value for date+time formats, assuming they are
+// not editable calculated expressions if the formula doesn't contain
+// arithmetic operators or assignment.
+
+const OUString aFormula( GetFormula());
+
+if (comphelper::string::indexOfAny( aFormula, u"=+-*/", 0) == -1)
+return static_cast(GetTyp())->GetInputOrDateTime( 
aFormula, GetValue(), GetFormat());
+
+return aFormula;
+}
+
 OUString SwField::GetDescription() const
 {
 return SwResId(STR_FIELD);
diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx
index 4f84b8b7bcbb..b24123c552d3 100644
--- 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-04 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/IDocumentFieldsAccess.hxx |2 +-
 sw/inc/SwUndoField.hxx   |8 
 sw/inc/fmtfld.hxx|2 +-
 sw/inc/hintids.hxx   |1 -
 sw/source/core/doc/DocumentFieldsManager.cxx |   13 +
 sw/source/core/edit/edfld.cxx|6 --
 sw/source/core/inc/DocumentFieldsManager.hxx |2 +-
 sw/source/core/txtnode/atrfld.cxx|   20 
 sw/source/core/undo/SwUndoField.cxx  |7 +++
 sw/source/uibase/docvw/AnnotationWin.cxx |4 ++--
 10 files changed, 25 insertions(+), 40 deletions(-)

New commits:
commit 309469a3863c1ce7a2d463f3a62f5101c39ac89c
Author: Bjoern Michaelsen 
AuthorDate: Mon Apr 3 21:12:14 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue Apr 4 11:27:40 2023 +0200

RES_REFMARKFLD_UPDATE no more (lots of zombie code)

- RES_REFMARKFLD_UPDATE is only instantiated in SwEditShell::UpdateOneField
- ... which passes it to DocumentFieldsManager::UpdateField, which
  * puts it in an SwUndoFieldFromDoc into the undo stack
  * and passes it to UpdateTextNode
- SwUndoFieldFromDoc::UpdateField only uses it to pass it back again to
  DocumentFieldsManager::UpdateField
- in UpdateTextNode RES_REFMARKFLD_UPDATE does not trigger any specific
  code

thus:
- replace UpdateTextNode with ForceUpdateTextNode
- remove the message item from the SwUndoFieldFromDoc ctor
- remove the message item as a parameter to
  DocumentFieldsManager::UpdateField as it was only ever used for
  RES_REFMARKFLD_UPDATE
- remove the instantiation in SwEditShell::UpdateOneField
- and finally: remove RES_REFMARKFLD_UPDATE itself

Change-Id: I3f7e27a555a24630d6d5a2c1a40db9096195b826
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150004
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/IDocumentFieldsAccess.hxx b/sw/inc/IDocumentFieldsAccess.hxx
index d0bdfe34589b..4664ae3bc846 100644
--- a/sw/inc/IDocumentFieldsAccess.hxx
+++ b/sw/inc/IDocumentFieldsAccess.hxx
@@ -92,7 +92,7 @@ namespace com::sun::star::uno { class Any; }
 @retval true update was successful
 @retval falseelse
 */
-virtual bool UpdateField(SwTextField * rDstFormatField, SwField & 
rSrcField, const SwMsgPoolItem * pMsgHint, bool bUpdateTableFields) = 0;
+virtual bool UpdateField(SwTextField * rDstFormatField, SwField & 
rSrcField, bool bUpdateTableFields) = 0;
 
 virtual void UpdateRefFields() = 0;
 
diff --git a/sw/inc/SwUndoField.hxx b/sw/inc/SwUndoField.hxx
index 95cb676c5de2..dcdc57b0b9bd 100644
--- a/sw/inc/SwUndoField.hxx
+++ b/sw/inc/SwUndoField.hxx
@@ -44,15 +44,15 @@ public:
 class SwUndoFieldFromDoc final : public SwUndoField
 {
 std::unique_ptr m_pOldField, m_pNewField;
-const SwMsgPoolItem * m_pHint;
 bool m_bUpdate;
 
 void DoImpl();
 
 public:
-SwUndoFieldFromDoc(const SwPosition & rPos, const SwField & aOldField,
-   const SwField & aNewField,
-   const SwMsgPoolItem * pHint, bool bUpdate);
+SwUndoFieldFromDoc(const SwPosition& rPos,
+const SwField& aOldField,
+const SwField& aNewField,
+bool bUpdate);
 
 virtual ~SwUndoFieldFromDoc() override;
 
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index 4bbd6d4cdf05..6f5811539b17 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -168,7 +168,7 @@ public:
 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 
 void ForceUpdateTextNode();
-void UpdateTextNode(const SfxPoolItem* pOld, const SfxPoolItem* pNew);
+void UpdateTextNode(const SfxHint& rHint);
 void UpdateDocPos(const SwTwips nDocPos);
 };
 
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 17c1fe545136..0673e724552c 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -432,7 +432,6 @@ constexpr TypedWhichId 
RES_OBJECTDYING(RES_FORMAT_MSG_BEGIN);
 constexpr TypedWhichId RES_FMT_CHG(168);
 constexpr TypedWhichId RES_ATTRSET_CHG(169);
 constexpr TypedWhichId RES_UPDATE_ATTR(170);
-constexpr TypedWhichId RES_REFMARKFLD_UPDATE(171);
 constexpr TypedWhichId RES_AUTOFMT_DOCNODE(176);
 constexpr TypedWhichId RES_HIDDENPARA_PRINT(178);
 constexpr TypedWhichId RES_VIRTPAGENUM_INFO(180);
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx 
b/sw/source/core/doc/DocumentFieldsManager.cxx
index cff26818dd34..c8703e7f06ef 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -491,10 +491,9 @@ void DocumentFieldsManager::PutValueToField(const 
SwPosition & rPos,
 pField->PutValue(rVal, nWhich);
 }
 
-bool DocumentFieldsManager::UpdateField(SwTextField * pDstTextField, SwField & 
rSrcField,
-  const SwMsgPoolItem * pMsgHint,
-  bool bUpdateFields)
+bool 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-02 Thread Eike Rathke (via logerrit)
 sw/inc/calc.hxx  |3 +++
 sw/source/core/bastyp/calc.cxx   |3 ++-
 sw/source/core/fields/fldbas.cxx |6 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 82ed010cd39351adcd4015e2bdd1591aa869cf18
Author: Eike Rathke 
AuthorDate: Sat Apr 1 17:30:54 2023 +0200
Commit: Eike Rathke 
CommitDate: Sun Apr 2 11:29:11 2023 +0200

Resolves: tdf#154218 Use the proper document's SwCalc locale for formula 
field

... instead of the format's locale to generate the expanded value
string to be reinterpreted again. i.e. inherited by SwSetExpField
used with Set variable.

Change-Id: I0bb545282a50032f2d8d2965020a36e3c5c8914e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149911
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index e91ede14e6a5..87583f752ff4 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -22,6 +22,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -260,6 +261,8 @@ public:
 static bool Str2Double( const OUString& rStr, sal_Int32& rPos,
 double& rVal, SwDoc const *const pDoc );
 
+static LanguageType GetDocAppScriptLang( SwDoc const & rDoc );
+
 SW_DLLPUBLIC static bool IsValidVarName( const OUString& rStr,
 OUString* pValidName = nullptr );
 };
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 592f969bde0b..d6b09766fb40 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -195,7 +195,8 @@ CalcOp* FindOperator( const OUString& rSrch )
   OperatorCompare ));
 }
 
-static LanguageType GetDocAppScriptLang( SwDoc const & rDoc )
+// static
+LanguageType SwCalc::GetDocAppScriptLang( SwDoc const & rDoc )
 {
 TypedWhichId nWhich =
GetWhichOfScript( RES_CHRATR_LANGUAGE,
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 80ae487f93fe..2f816d208938 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -807,6 +807,7 @@ void SwFormulaField::SetFormula(const OUString& rStr)
 {
 sal_Int32 nPos = 0;
 double fTmpValue;
+// Uses the SwCalc document locale.
 if( SwCalc::Str2Double( rStr, nPos, fTmpValue, GetDoc() ) )
 SwValueField::SetValue( fTmpValue );
 }
@@ -824,7 +825,10 @@ void SwFormulaField::SetExpandedFormula( const OUString& 
rStr )
 {
 SwValueField::SetValue(fTmpValue);
 
-m_sFormula = static_cast(GetTyp())->DoubleToString(fTmpValue, nFormat);
+// Will get reinterpreted by SwCalc when updating fields, so use
+// the proper locale.
+m_sFormula = static_cast(GetTyp())->DoubleToString( fTmpValue,
+SwCalc::GetDocAppScriptLang( *GetDoc()));
 return;
 }
 }


[Libreoffice-commits] core.git: sw/inc sw/source

2023-04-01 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/hintids.hxx   |1 -
 sw/source/core/fields/ddefld.cxx |7 ---
 sw/source/core/fields/ddetbl.cxx |   10 +-
 3 files changed, 1 insertion(+), 17 deletions(-)

New commits:
commit 383f70fa9ed0ec7acd6fbc4e921bb5b91fde4689
Author: Bjoern Michaelsen 
AuthorDate: Tue Mar 28 00:39:39 2023 +0200
Commit: Bjoern Michaelsen 
CommitDate: Sat Apr 1 20:02:38 2023 +0200

RES_UPDATEDDETBL no more

- SwDDETable doesnt handle the hint anymore (it used to do a
  ChangeContent triggered by it)
- SwDDEFieldType::UpdateDDE doesnt create the hint anymore -- it used
  to send it via UpdateTextNode, which would call
  SwTextNode::TriggerNodeUpdate for some types, but not for SwFieldIds::Dde
- ... so the hint sent is never received by anyone who cares

- SwDDEFieldType::UpdateDDE calls ChangeContent on all DDETables
  directly in UpdateDDE anyway, so the dead code is likely just
  obsolete.

Change-Id: I85301ef89998508031833f35c4a2c93e7acb112e

Change-Id: Iaef54e27869947fb7f57d1575e9e0f59f903befd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149656
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen 

diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index a8418566f5ec..5e84921ec832 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -433,7 +433,6 @@ constexpr TypedWhichId RES_FMT_CHG(168);
 constexpr TypedWhichId RES_ATTRSET_CHG(169);
 constexpr TypedWhichId RES_UPDATE_ATTR(170);
 constexpr TypedWhichId RES_REFMARKFLD_UPDATE(171);
-constexpr TypedWhichId RES_UPDATEDDETBL(174);
 constexpr TypedWhichId RES_TBLHEADLINECHG(175);
 constexpr TypedWhichId RES_AUTOFMT_DOCNODE(176);
 constexpr TypedWhichId RES_HIDDENPARA_PRINT(178);
diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx
index cf4c93c97122..46ac3d504955 100644
--- a/sw/source/core/fields/ddefld.cxx
+++ b/sw/source/core/fields/ddefld.cxx
@@ -315,13 +315,6 @@ void SwDDEFieldType::UpdateDDE(const bool bNotifyShells)
 pSh->StartAction();
 }
 
-// DDE fields attribute in the text
-SwMsgPoolItem aUpdateDDE(RES_UPDATEDDETBL);
-for(auto pFormatField: vFields)
-{
-if(pFormatField->GetTextField())
-pFormatField->UpdateTextNode(nullptr, );
-}
 // a DDE tables in the text
 for(auto pTable: vTables)
 pTable->ChangeContent();
diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx
index 01bfa5209dd6..7324c24c5db9 100644
--- a/sw/source/core/fields/ddetbl.cxx
+++ b/sw/source/core/fields/ddetbl.cxx
@@ -87,15 +87,7 @@ void SwDDETable::SwClientNotify(const SwModify& rModify, 
const SfxHint& rHint)
 {
 if (rHint.GetId() == SfxHintId::SwLegacyModify)
 {
-auto pLegacy = static_cast();
-switch(pLegacy->GetWhich())
-{
-case RES_UPDATEDDETBL:
-ChangeContent();
-break;
-default:
-SwTable::SwClientNotify(rModify, rHint);
-}
+SwTable::SwClientNotify(rModify, rHint);
 }
 else if (rHint.GetId() == SfxHintId::SwField)
 {


[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-31 Thread Mike Kaganski (via logerrit)
 sw/inc/doc.hxx|3 ++-
 sw/source/core/docnode/ndtbl.cxx  |7 +--
 sw/source/core/unocore/unotbl.cxx |   33 ++---
 sw/source/filter/xml/xmltbli.cxx  |5 +++--
 4 files changed, 28 insertions(+), 20 deletions(-)

New commits:
commit d893a40c81357a25a4a89a62f6cf6122046068d5
Author: Mike Kaganski 
AuthorDate: Fri Mar 31 17:38:42 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 31 18:19:44 2023 +0200

tdf#154486: Use known name when inserting the table into the document

... instead of assinging a unique name at insertion time, then changing
to the final value.

As discussed in commit 1dd71d79e15bd8098e7c17c8fcea3748592a902f (tdf#154486:
use importer-local map to deduplicate table names, 2023-03-31), the lookup
for a unique table name has an O(n^2) complexity, and can make loading of
thousands tables impossible.

This changes import time from 23 s to ~2.5 s, and the time now depends on 
the
number of tables linearly (e.g., 200 000 tables load in ~45 s).

Change-Id: I0f2b5e37db2d370bccbc8c3430f895c864d9a4c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149840
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 17d130a51be4..df07fbae0043 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1178,7 +1178,8 @@ public:
 const SwTableAutoFormat* pTAFormat = nullptr,
 const std::vector *pColArr = 
nullptr,
 bool bCalledFromShell = false,
-bool bNewModel = true );
+bool bNewModel = true,
+const OUString& rTableName = {} );
 
 // If index is in a table, return TableNode, else 0.
 static SwTableNode* IsIdxInTable( const SwNodeIndex& rIdx );
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index c405b4bca84a..111daec55ef3 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -340,7 +340,8 @@ const SwTable* SwDoc::InsertTable( const 
SwInsertTableOptions& rInsTableOpts,
const SwTableAutoFormat* pTAFormat,
const std::vector *pColArr,
bool bCalledFromShell,
-   bool bNewModel )
+   bool bNewModel,
+   const OUString& rTableName )
 {
 assert(nRows && "Table without line?");
 assert(nCols && "Table without rows?");
@@ -357,7 +358,9 @@ const SwTable* SwDoc::InsertTable( const 
SwInsertTableOptions& rInsTableOpts,
 pColArr = nullptr;
 }
 
-OUString aTableName = GetUniqueTableName();
+OUString aTableName = rTableName;
+if (aTableName.isEmpty() || FindTableFormatByName(aTableName) != nullptr)
+aTableName = GetUniqueTableName();
 
 if( GetIDocumentUndoRedo().DoesUndo() )
 {
diff --git a/sw/source/core/unocore/unotbl.cxx 
b/sw/source/core/unocore/unotbl.cxx
index 15eba1dfd116..f09f8f22c69a 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2081,11 +2081,28 @@ SwXTextTable::attach(const 
uno::Reference & xTextRange)
 pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
 aPam.DeleteMark();
 }
+
+OUString tableName;
+if (const::uno::Any* pName;
+m_pImpl->m_pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName))
+{
+tableName = pName->get();
+}
+else if (!m_pImpl->m_sTableName.isEmpty())
+{
+sal_uInt16 nIndex = 1;
+tableName = m_pImpl->m_sTableName;
+while (pDoc->FindTableFormatByName(tableName, true) && nIndex < 
USHRT_MAX)
+tableName = m_pImpl->m_sTableName + OUString::number(nIndex++);
+}
+
 pTable = pDoc->InsertTable(SwInsertTableOptions( 
SwInsertTableFlags::Headline | SwInsertTableFlags::DefaultBorder | 
SwInsertTableFlags::SplitLayout, 0 ),
 *aPam.GetPoint(),
 m_pImpl->m_nRows,
 m_pImpl->m_nColumns,
-text::HoriOrientation::FULL);
+text::HoriOrientation::FULL,
+nullptr, nullptr, false, true,
+tableName);
 if(pTable)
 {
 // here, the properties of the descriptor need to be analyzed
@@ -2095,20 +2112,6 @@ SwXTextTable::attach(const 
uno::Reference & xTextRange)
 
 m_pImpl->SetFrameFormat(*pTableFormat);
 
-if (!m_pImpl->m_sTableName.isEmpty())
-{
-sal_uInt16 nIndex = 1;
-OUString sTmpNameIndex(m_pImpl->m_sTableName);
-while(pDoc->FindTableFormatByName(sTmpNameIndex, true) && 
nIndex < USHRT_MAX)

[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-30 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/IDocumentFieldsAccess.hxx |3 +-
 sw/inc/cellatr.hxx   |   15 +-
 sw/inc/hintids.hxx   |1 
 sw/inc/hints.hxx |2 -
 sw/source/core/attr/cellatr.cxx  |   39 ---
 sw/source/core/attr/hints.cxx|9 +++---
 sw/source/core/doc/DocumentFieldsManager.cxx |   31 ++---
 sw/source/core/docnode/ndtbl.cxx |3 --
 sw/source/core/edit/edtab.cxx|3 --
 sw/source/core/inc/DocumentFieldsManager.hxx |2 -
 sw/source/core/table/swtable.cxx |4 --
 sw/source/core/undo/untbl.cxx|3 --
 sw/source/core/unocore/unotbl.cxx|6 +---
 13 files changed, 39 insertions(+), 82 deletions(-)

New commits:
commit 1bdd92bceb5997d5d0ed27b59734c88f7546a4da
Author: Bjoern Michaelsen 
AuthorDate: Wed Mar 22 23:18:27 2023 +0100
Commit: Bjoern Michaelsen 
CommitDate: Thu Mar 30 21:49:59 2023 +

SwTableFormulaUpdate: SwMsgPoolItem no more

- get rid of legacy call with unused WhichId (TABLEFML_UPDATE)
- simplify and inlune ChangeSate, by now only handling TBL_CALC
- simplify params for UpdateTableFields (explictly just one SwTable*)

Change-Id: Ie356c2a17eab0b557efb54719d33e278b887eef5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149591
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen 

diff --git a/sw/inc/IDocumentFieldsAccess.hxx b/sw/inc/IDocumentFieldsAccess.hxx
index c31e6a646ed0..d0bdfe34589b 100644
--- a/sw/inc/IDocumentFieldsAccess.hxx
+++ b/sw/inc/IDocumentFieldsAccess.hxx
@@ -38,6 +38,7 @@ class SwMsgPoolItem;
 class DateTime;
 class SetGetExpField;
 class SwNode;
+class SwTable;
 enum class SwFieldIds : sal_uInt16;
 template  class SwHashTable;
 struct HashStr;
@@ -95,7 +96,7 @@ namespace com::sun::star::uno { class Any; }
 
 virtual void UpdateRefFields() = 0;
 
-virtual void UpdateTableFields(SfxPoolItem* pHt) = 0;
+virtual void UpdateTableFields(const SwTable* pTable) = 0;
 
 virtual void UpdateExpFields(SwTextField* pField, bool bUpdateRefFields) = 
0;
 
diff --git a/sw/inc/cellatr.hxx b/sw/inc/cellatr.hxx
index 2d85015a8901..05b1e965ef0b 100644
--- a/sw/inc/cellatr.hxx
+++ b/sw/inc/cellatr.hxx
@@ -26,6 +26,7 @@
 #include "format.hxx"
 #include "hintids.hxx"
 #include "cellfml.hxx"
+#include "node.hxx"
 
 class SwHistory;
 
@@ -75,7 +76,19 @@ public:
 
 void TryBoxNmToPtr();
 void ToSplitMergeBoxNmWithHistory(SwTableFormulaUpdate& rUpdate, 
SwHistory* pHistory);
-void ChangeState( const SfxPoolItem* pItem );
+void ChangeState()
+{
+if(!m_pDefinedIn)
+return;
+// detect table that contains this attribute
+const SwNode* pNd = GetNodeOfFormula();
+if(!pNd) // || >GetNodes() != >GetDoc().GetNodes())
+return;
+const SwTableNode* pTableNd = pNd->FindTableNode();
+if(pTableNd == nullptr)
+return;
+ChgValid(false);
+}
 void Calc( SwTableCalcPara& rCalcPara, double& rValue );
 };
 
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 330b0042b3a9..a8418566f5ec 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -433,7 +433,6 @@ constexpr TypedWhichId RES_FMT_CHG(168);
 constexpr TypedWhichId RES_ATTRSET_CHG(169);
 constexpr TypedWhichId RES_UPDATE_ATTR(170);
 constexpr TypedWhichId RES_REFMARKFLD_UPDATE(171);
-constexpr TypedWhichId RES_TABLEFML_UPDATE(173);
 constexpr TypedWhichId RES_UPDATEDDETBL(174);
 constexpr TypedWhichId RES_TBLHEADLINECHG(175);
 constexpr TypedWhichId RES_AUTOFMT_DOCNODE(176);
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index 2b870373dcf1..6b993795c058 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -299,7 +299,7 @@ enum TableFormulaUpdateFlags { TBL_CALC = 0,
  TBL_MERGETBL,
  TBL_SPLITTBL
};
-class SwTableFormulaUpdate final : public SwMsgPoolItem
+class SwTableFormulaUpdate final
 {
 public:
 const SwTable* m_pTable; ///< Pointer to the current table
diff --git a/sw/source/core/attr/cellatr.cxx b/sw/source/core/attr/cellatr.cxx
index 1c445bb03067..9023cca2f793 100644
--- a/sw/source/core/attr/cellatr.cxx
+++ b/sw/source/core/attr/cellatr.cxx
@@ -126,45 +126,6 @@ void 
SwTableBoxFormula::ToSplitMergeBoxNmWithHistory(SwTableFormulaUpdate& rUpda
 pNd->FindTableBoxStartNode()->GetIndex());
 }
 }
-void SwTableBoxFormula::ChangeState( const SfxPoolItem* pItem )
-{
-if( !m_pDefinedIn )
-return ;
-
-SwTableFormulaUpdate* pUpdateField;
-if( !pItem || RES_TABLEFML_UPDATE != pItem->Which() )
-{
-// reset value flag
-ChgValid( false );
-return ;
-}
-
-pUpdateField = const_cast(static_cast(pItem));
-
-// detect table that contains this attribute
-const SwTableNode* pTableNd;
-

[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-27 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/cellatr.hxx   |3 +
 sw/inc/cellfml.hxx   |2 
 sw/inc/swtable.hxx   |3 -
 sw/source/core/attr/cellatr.cxx  |   55 +
 sw/source/core/doc/DocumentFieldsManager.cxx |2 
 sw/source/core/docnode/ndtbl.cxx |   23 ++---
 sw/source/core/table/swtable.cxx |   68 +--
 7 files changed, 80 insertions(+), 76 deletions(-)

New commits:
commit 31690100461d42fd93b9a1a6546b1e17a8d31720
Author: Bjoern Michaelsen 
AuthorDate: Fri Mar 17 00:26:42 2023 +0100
Commit: Bjoern Michaelsen 
CommitDate: Mon Mar 27 07:15:40 2023 +

refactor table split

Change-Id: Ifd7e77b29205fa505ed2fe41d08b4253f50a99a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149185
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen 

diff --git a/sw/inc/cellatr.hxx b/sw/inc/cellatr.hxx
index d1de3bbb9136..2d85015a8901 100644
--- a/sw/inc/cellatr.hxx
+++ b/sw/inc/cellatr.hxx
@@ -27,6 +27,8 @@
 #include "hintids.hxx"
 #include "cellfml.hxx"
 
+class SwHistory;
+
 /** The number formatter's default locale's @ Text format.
 Not necessarily system locale, but the locale the formatter was constructed
 with. For this SvNumberFormatter::IsTextFormat() always returns true.
@@ -72,6 +74,7 @@ public:
 { return const_cast(this)->GetTableBox(); }
 
 void TryBoxNmToPtr();
+void ToSplitMergeBoxNmWithHistory(SwTableFormulaUpdate& rUpdate, 
SwHistory* pHistory);
 void ChangeState( const SfxPoolItem* pItem );
 void Calc( SwTableCalcPara& rCalcPara, double& rValue );
 };
diff --git a/sw/inc/cellfml.hxx b/sw/inc/cellfml.hxx
index 16ca387305b8..f99c8f87041b 100644
--- a/sw/inc/cellfml.hxx
+++ b/sw/inc/cellfml.hxx
@@ -109,7 +109,6 @@ protected:
 *rCalcPara.m_pTable,  );
 }
 
-static sal_uInt16 GetLnPosInTable( const SwTable& rTable, const 
SwTableBox* pBox );
 
 public:
 
@@ -146,6 +145,7 @@ public:
 void GetBoxesOfFormula(const SwTable& rTable, SwSelBoxes& rBoxes);
 // are all boxes valid which this formula relies on?
 bool HasValidBoxes() const;
+static sal_uInt16 GetLnPosInTable( const SwTable& rTable, const 
SwTableBox* pBox );
 };
 
 #endif
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index f40059e3c986..3015223ef451 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -176,9 +176,9 @@ private:
 void ConvertSubtableBox(sal_uInt16 const nRow, sal_uInt16 const nBox);
 // Only used for TBL_BOXNAME and TBL_RELBOXNAME for now
 void UpdateFields(TableFormulaUpdateFlags eFlags);
+void GatherFormulas(std::vector& rvFormulas);
 
 public:
-
 SwHTMLTableLayout *GetHTMLTableLayout() { return m_xHTMLLayout.get(); }
 const SwHTMLTableLayout *GetHTMLTableLayout() const { return 
m_xHTMLLayout.get(); }
 void SetHTMLTableLayout(std::shared_ptr const& r);
//Change of property!
@@ -366,6 +366,7 @@ public:
 void SwitchFormulasToInternalRepresentation()
 { UpdateFields(TBL_BOXPTR); }
 void Merge(SwTable& rTable, SwHistory* pHistory);
+void Split(OUString sNewTableName, sal_uInt16 nSplitLine, SwHistory* 
pHistory);
 
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
diff --git a/sw/source/core/attr/cellatr.cxx b/sw/source/core/attr/cellatr.cxx
index 02b2923b9f88..1c445bb03067 100644
--- a/sw/source/core/attr/cellatr.cxx
+++ b/sw/source/core/attr/cellatr.cxx
@@ -104,6 +104,28 @@ void SwTableBoxFormula::TryBoxNmToPtr()
 BoxNmToPtr(>GetTable());
 }
 }
+void SwTableBoxFormula::ToSplitMergeBoxNmWithHistory(SwTableFormulaUpdate& 
rUpdate, SwHistory* pHistory)
+{
+if(!pHistory)
+{
+ToSplitMergeBoxNm(rUpdate);
+return;
+}
+auto pNd = GetNodeOfFormula();
+// for a history record the unchanged formula is needed
+SwTableBoxFormula aCopy(*this);
+rUpdate.m_bModified = false;
+ToSplitMergeBoxNm(rUpdate);
+if(rUpdate.m_bModified)
+{
+// external rendering
+aCopy.PtrToBoxNm(>FindTableNode()->GetTable());
+pHistory->Add(
+,
+,
+pNd->FindTableBoxStartNode()->GetIndex());
+}
+}
 void SwTableBoxFormula::ChangeState( const SfxPoolItem* pItem )
 {
 if( !m_pDefinedIn )
@@ -137,40 +159,9 @@ void SwTableBoxFormula::ChangeState( const SfxPoolItem* 
pItem )
 case TBL_BOXPTR:
 case TBL_RELBOXNAME:
 case TBL_BOXNAME:
-assert(false); // PtrToBoxNm, ToRelBoxNm and BoxNmToPtr are all public 
-- use just them directly
-break;
-
 case TBL_SPLITTBL:
-if( >GetTable() == pUpdateField->m_pTable )
-{
-sal_uInt16 nLnPos = SwTableFormula::GetLnPosInTable(
-pTableNd->GetTable(), GetTableBox() );
-pUpdateField->m_bBehindSplitLine = USHRT_MAX != nLnPos &&
-pUpdateField->m_nSplitLine <= 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-27 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/swtable.hxx   |1 
 sw/source/core/doc/DocumentFieldsManager.cxx |2 -
 sw/source/core/docnode/ndtbl.cxx |6 
 sw/source/core/table/swtable.cxx |   35 +++
 4 files changed, 38 insertions(+), 6 deletions(-)

New commits:
commit 7c680a96122f7f90114932ef5fdb48328c327268
Author: Bjoern Michaelsen 
AuthorDate: Tue Mar 7 01:28:56 2023 +0100
Commit: Bjoern Michaelsen 
CommitDate: Mon Mar 27 06:20:28 2023 +

refactor table merge

Change-Id: Ia4d5b3fc04cc032a182b4bf7f7570fc250ed8504
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148739
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen 

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 39e54edb2f33..f40059e3c986 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -365,6 +365,7 @@ public:
 { UpdateFields(TBL_RELBOXNAME); };
 void SwitchFormulasToInternalRepresentation()
 { UpdateFields(TBL_BOXPTR); }
+void Merge(SwTable& rTable, SwHistory* pHistory);
 
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx 
b/sw/source/core/doc/DocumentFieldsManager.cxx
index a395dc352392..3ba8c6314cea 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -602,7 +602,7 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* 
pHt )
 if(pHt && RES_TABLEFML_UPDATE == pHt->Which())
 pUpdateField = static_cast(pHt);
 assert(!pHt || pUpdateField);
-assert(!pUpdateField || pUpdateField->m_eFlags == TBL_CALC || 
pUpdateField->m_eFlags == TBL_SPLITTBL || pUpdateField->m_eFlags == 
TBL_MERGETBL);
+assert(!pUpdateField || pUpdateField->m_eFlags == TBL_CALC || 
pUpdateField->m_eFlags == TBL_SPLITTBL);
 auto pFieldType = GetFieldType( SwFieldIds::Table, OUString(), false );
 if(pFieldType && (!pUpdateField || pUpdateField->m_eFlags == TBL_CALC))
 {
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 9f0a89ccad51..4526721a3250 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3471,11 +3471,7 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool 
bWithPrev )
 }
 
 // Adapt all "TableFormulas"
-SwTableFormulaUpdate aMsgHint( >GetTable() );
-aMsgHint.m_aData.pDelTable = >GetTable();
-aMsgHint.m_eFlags = TBL_MERGETBL;
-aMsgHint.m_pHistory = pHistory.get();
-getIDocumentFieldsAccess().UpdateTableFields(  );
+pTableNd->GetTable().Merge(pDelTableNd->GetTable(), pHistory.get());
 
 // The actual merge
 bool bRet = rNds.MergeTable( bWithPrev ? *pTableNd : *pDelTableNd, 
!bWithPrev );
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 867e76deed1c..96d3b4903255 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef DBG_UTIL
 #define CHECK_TABLE(t) (t).CheckConsistency();
@@ -1613,6 +1614,40 @@ bool SwTable::IsDeleted() const
 return true;
 }
 
+void SwTable::Merge(SwTable& rTable, SwHistory* pHistory)
+{
+SwTableFormulaUpdate aHint(this);
+aHint.m_aData.pDelTable = 
+aHint.m_eFlags = TBL_MERGETBL;
+aHint.m_pHistory = pHistory;
+// process all table box formulas
+for(SfxPoolItem* pItem : 
GetFrameFormat()->GetDoc()->GetAttrPool().GetItemSurrogates(RES_BOXATR_FORMULA))
+{
+auto pBoxFormula = pItem->DynamicWhichCast(RES_BOXATR_FORMULA);
+assert(pBoxFormula);
+if(pBoxFormula->GetDefinedIn())
+{
+const SwNode* pNd = pBoxFormula->GetNodeOfFormula();
+// for a history record the unchanged formula is needed
+SwTableBoxFormula aCopy(*pBoxFormula);
+aHint.m_bModified = false;
+pBoxFormula->ToSplitMergeBoxNm(aHint);
+
+if(aHint.m_bModified)
+{
+// external rendering
+aCopy.PtrToBoxNm(this);
+aHint.m_pHistory->Add(
+,
+,
+pNd->FindTableBoxStartNode()->GetIndex());
+}
+}
+else
+pBoxFormula->ToSplitMergeBoxNm(aHint);
+}
+}
+
 void SwTable::UpdateFields(TableFormulaUpdateFlags eFlags)
 {
 auto pDoc = GetFrameFormat()->GetDoc();


[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-23 Thread Miklos Vajna (via logerrit)
 sw/inc/strings.hrc |1 +
 sw/inc/swundo.hxx  |1 +
 sw/source/core/undo/undobj.cxx |3 +++
 sw/source/uibase/shells/basesh.cxx |8 +---
 4 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 457af772f52e447ef4d2dd22c1eb4624e50e6df7
Author: Miklos Vajna 
AuthorDate: Wed Mar 22 20:01:50 2023 +0100
Commit: Miklos Vajna 
CommitDate: Thu Mar 23 07:08:05 2023 +

sw: fix undo comment of FN_UPDATE_FIELD

It's an update and the name was not set. One has to dispatch
.uno:UpdateField to see this in action, which does something if the
cursor is inside an exiting reference mark.

Change-Id: I1701c7c3ab0a395c2346d41fb517d13c9d9c5a3d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149350
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 57710c5a4524..38cdabf8ba01 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -441,6 +441,7 @@
 #define STR_INSBOOKMARK NC_("STR_INSBOOKMARK", "Insert 
bookmark: $1")
 #define STR_UPDATE_BOOKMARK NC_("STR_UPDATE_BOOKMARK", 
"Update bookmark: $1")
 #define STR_UPDATE_BOOKMARKSNC_("STR_UPDATE_BOOKMARKS", 
"Update bookmarks")
+#define STR_UPDATE_FIELDNC_("STR_UPDATE_FIELD", 
"Update field: $1")
 #define STR_SORT_TBLNC_("STR_SORT_TBL", "Sort 
table")
 #define STR_SORT_TXTNC_("STR_SORT_TXT", "Sort 
text")
 #define STR_INSTABLE_UNDO   NC_("STR_INSTABLE_UNDO", 
"Insert table: $1$2$3")
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index 9728f96b93de..ff806d430330 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -173,6 +173,7 @@ enum class SwUndoId
 UPDATE_BOOKMARK,   // 141
 UPDATE_BOOKMARKS,  // 142
 DELETE_BOOKMARKS,  // 143
+UPDATE_FIELD,  // 144
 };
 
 OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index af1388dec6ef..42f71be7c327 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -664,6 +664,9 @@ OUString GetUndoComment(SwUndoId eId)
 case SwUndoId::DELETE_BOOKMARKS:
 pId = STR_DELETE_BOOKMARKS;
 break;
+case SwUndoId::UPDATE_FIELD:
+pId = STR_UPDATE_FIELD;
+break;
 }
 
 assert(pId);
diff --git a/sw/source/uibase/shells/basesh.cxx 
b/sw/source/uibase/shells/basesh.cxx
index 5e5d07565b5d..61567a64cff1 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -929,13 +929,15 @@ void UpdateFieldContent(SfxRequest& rReq, SwWrtShell& 
rWrtSh)
 }
 
 SwDoc* pDoc = rWrtSh.GetDoc();
-pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSBOOKMARK, nullptr);
+SwRewriter aRewriter;
+aRewriter.AddRule(UndoArg1, rRefmark.GetRefName());
+pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_FIELD, );
 rWrtSh.StartAction();
 comphelper::ScopeGuard g(
-[]
+[, ]
 {
 rWrtSh.EndAction();
-
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSBOOKMARK, nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_FIELD, 
);
 });
 
 comphelper::SequenceAsHashMap aMap(aField);


[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-20 Thread Michael Weghorn (via logerrit)
 sw/inc/crsrsh.hxx|2 ++
 sw/source/core/access/accdoc.cxx |5 +
 sw/source/core/crsr/crsrsh.cxx   |   14 ++
 3 files changed, 21 insertions(+)

New commits:
commit 4a93739e619fd4f4ec369932e923554d71297900
Author: Michael Weghorn 
AuthorDate: Fri Mar 17 12:37:15 2023 +0100
Commit: Michael Weghorn 
CommitDate: Mon Mar 20 21:21:30 2023 +

tdf#136760 sw a11y: Provide page-relative cursor pos via doc attr

This introduce 2 new extended accessible attributes
"cursor-position-in-page-horizontal" and
"cursor-position-in-page-vertical" to expose
the page-relative position of the cursor in Writer
to assistive technology.

This is similar to how the current page
number is already exposed (attribute "page-number").

Together with a corresponding pull request for the NVDA
screen reader [1], this allows NVDA to announce the position
similar to how it is done for Microsoft Word (where the information
is not retrieved via the accessibility APIs but the
MS Office COM API, s. discussion
in the corresponding NVDA issue [2] for more details).

(Side note: Currently there is no a11y object for a Writer
page in the a11y tree, but "normal" paragraphs are direct
children of the document object.)

For performance reasons, introduce a new method
`SwCursorShell::GetCursorPagePos` to get the position
instead of passing the result from
`SwCursorShell::GetCursorDocPos` to
`SwFEShell::GetRelativePagePosition` to avoid
iterating over the doc pages.

[1] https://github.com/nvaccess/nvda/pull/14727
[2] https://github.com/nvaccess/nvda/issues/11696

Change-Id: I6fd56c5c7d051840bab836ce5fe525fdc061b376
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149051
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 8eac979b5617..ddb7b301beef 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -598,6 +598,8 @@ public:
 bool IsCursorInFootnote() const;
 
 inline Point& GetCursorDocPos() const;
+// get cursor position relative to the page it is in
+Point GetCursorPagePos() const;
 inline bool IsCursorPtAtEnd() const;
 
 inline const  SwPaM* GetTableCrs() const;
diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx
index 618425a68f9d..298b4270e5d8 100644
--- a/sw/source/core/access/accdoc.cxx
+++ b/sw/source/core/access/accdoc.cxx
@@ -533,6 +533,11 @@ uno::Any SAL_CALL 
SwAccessibleDocument::getExtendedAttributes()
 ";total-pages:" +
 OUString::number( pCursorShell->GetPageCnt() ) + ";";
 
+// cursor position relative to the page
+Point aCursorPagePos = pFEShell->GetCursorPagePos();
+sValue += "cursor-position-in-page-horizontal:" + 
OUString::number(aCursorPagePos.getX())
++ ";cursor-position-in-page-vertical:" + 
OUString::number(aCursorPagePos.getY()) + ";";
+
 SwContentFrame* pCurrFrame = pCursorShell->GetCurrFrame();
 SwPageFrame* 
pCurrPage=static_cast(pCurrFrame)->FindPageFrame();
 sal_uLong nLineNum = 0;
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 298801ace223..9d94c133f028 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1168,6 +1168,20 @@ bool SwCursorShell::IsCursorInFootnote() const
 return aStartNodeType == SwStartNodeType::SwFootnoteStartNode;
 }
 
+Point SwCursorShell::GetCursorPagePos() const
+{
+Point aRet(-1, -1);
+if (SwFrame *pFrame = GetCurrFrame())
+{
+if (SwPageFrame* pCurrentPage = pFrame->FindPageFrame())
+{
+const Point& rDocPos = GetCursorDocPos();
+aRet = rDocPos - pCurrentPage->getFrameArea().TopLeft();
+}
+}
+return aRet;
+}
+
 bool SwCursorShell::IsInFrontOfLabel() const
 {
 return m_pCurrentCursor->IsInFrontOfLabel();


[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-16 Thread Miklos Vajna (via logerrit)
 sw/inc/strings.hrc  |1 +
 sw/inc/swundo.hxx   |1 +
 sw/source/core/undo/undobj.cxx  |3 +++
 sw/source/uibase/shells/textsh1.cxx |4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 7a7eb4aa21ca0c83db825fe8d5a5278611b391d8
Author: Miklos Vajna 
AuthorDate: Thu Mar 16 08:27:33 2023 +0100
Commit: Miklos Vajna 
CommitDate: Thu Mar 16 08:42:06 2023 +

sw: fix undo comment of FN_DELETE_BOOKMARKS

It's bookmarks, not bookmark. One has to dispatch .uno:DeleteBookmarks
to see this in action, which does something if the document already
contains at least one bookmark.

Change-Id: I7678f6bc6a00a95cfd4ecc87e97e8db6d469216d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148945
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index cca6a14cd1e4..57710c5a4524 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -437,6 +437,7 @@
 #define STR_INSERT_DOC_UNDO NC_("STR_INSERT_DOC_UNDO", 
"Insert file")
 #define STR_INSERT_GLOSSARY NC_("STR_INSERT_GLOSSARY", 
"Insert AutoText")
 #define STR_DELBOOKMARK NC_("STR_DELBOOKMARK", "Delete 
bookmark: $1")
+#define STR_DELETE_BOOKMARKSNC_("STR_DELETE_BOOKMARKS", 
"Delete bookmarks")
 #define STR_INSBOOKMARK NC_("STR_INSBOOKMARK", "Insert 
bookmark: $1")
 #define STR_UPDATE_BOOKMARK NC_("STR_UPDATE_BOOKMARK", 
"Update bookmark: $1")
 #define STR_UPDATE_BOOKMARKSNC_("STR_UPDATE_BOOKMARKS", 
"Update bookmarks")
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index efca97bc1b23..9728f96b93de 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -172,6 +172,7 @@ enum class SwUndoId
 DELETE_FORM_FIELDS,// 140
 UPDATE_BOOKMARK,   // 141
 UPDATE_BOOKMARKS,  // 142
+DELETE_BOOKMARKS,  // 143
 };
 
 OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 8e5638205c61..af1388dec6ef 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -661,6 +661,9 @@ OUString GetUndoComment(SwUndoId eId)
 case SwUndoId::UPDATE_BOOKMARKS:
 pId = STR_UPDATE_BOOKMARKS;
 break;
+case SwUndoId::DELETE_BOOKMARKS:
+pId = STR_DELETE_BOOKMARKS;
+break;
 }
 
 assert(pId);
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index c79d2bec1fbe..d765b62f9328 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -675,13 +675,13 @@ void DeleteBookmarks(SfxRequest& rReq, SwWrtShell& rWrtSh)
 aBookmarkNamePrefix = pBookmarkNamePrefix->GetValue();
 }
 
-rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::DELBOOKMARK, 
nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::DELETE_BOOKMARKS, 
nullptr);
 rWrtSh.StartAction();
 comphelper::ScopeGuard g(
 []
 {
 rWrtSh.EndAction();
-
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::DELBOOKMARK, nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::DELETE_BOOKMARKS, 
nullptr);
 });
 
 IDocumentMarkAccess* pMarkAccess = 
rWrtSh.GetDoc()->getIDocumentMarkAccess();


[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-16 Thread Paris Oplopoios (via logerrit)
 sw/inc/viewopt.hxx   |  172 ++
 sw/source/core/access/accframe.cxx   |2 
 sw/source/core/access/accpara.cxx|2 
 sw/source/core/access/accportions.cxx|2 
 sw/source/core/inc/wrong.hxx |8 
 sw/source/core/layout/paintfrm.cxx   |   69 ++--
 sw/source/core/text/atrstck.cxx  |8 
 sw/source/core/text/inftxt.cxx   |   16 -
 sw/source/core/text/porfld.cxx   |4 
 sw/source/core/text/porref.cxx   |2 
 sw/source/core/text/porrst.cxx   |   10 
 sw/source/core/text/portox.cxx   |2 
 sw/source/core/text/portxt.cxx   |4 
 sw/source/core/text/txtdrop.cxx  |4 
 sw/source/core/txtnode/fntcache.cxx  |2 
 sw/source/core/view/viewimp.cxx  |2 
 sw/source/core/view/viewsh.cxx   |3 
 sw/source/filter/html/htmlfldw.cxx   |8 
 sw/source/ui/chrdlg/drpcps.cxx   |8 
 sw/source/ui/config/optpage.cxx  |5 
 sw/source/ui/envelp/envlop1.cxx  |   10 
 sw/source/ui/envelp/labfmt.cxx   |4 
 sw/source/ui/misc/outline.cxx|   12 
 sw/source/uibase/app/apphdl.cxx  |   11 
 sw/source/uibase/config/viewopt.cxx  |  300 ++-
 sw/source/uibase/docvw/AnnotationWin2.cxx|8 
 sw/source/uibase/docvw/DashedLine.cxx|6 
 sw/source/uibase/docvw/HeaderFooterWin.cxx   |4 
 sw/source/uibase/docvw/PageBreakWin.cxx  |2 
 sw/source/uibase/docvw/UnfloatTableButton.cxx|3 
 sw/source/uibase/docvw/contentcontrolaliasbutton.cxx |3 
 sw/source/uibase/docvw/edtwin.cxx|2 
 sw/source/uibase/frmdlg/colex.cxx|2 
 sw/source/uibase/inc/DashedLine.hxx  |5 
 sw/source/uibase/uiview/view0.cxx|   28 -
 sw/source/uibase/uiview/viewdraw.cxx |2 
 sw/source/uibase/uno/unomod.cxx  |   20 -
 sw/source/uibase/uno/unotxdoc.cxx|4 
 38 files changed, 424 insertions(+), 335 deletions(-)

New commits:
commit 1916d161902bdd52b8cfa5b29153c8f8c39fce52
Author: Paris Oplopoios 
AuthorDate: Wed Mar 8 17:34:02 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Mar 16 08:41:38 2023 +

De-static-izing colors in SwViewOption

The view colors in SwViewOption were static which means that two
separate views couldn't have different colors

Change-Id: Id595b00ba56bdb210ad1a784cf76e99ead0d6014
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148481
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index c399aa6b94dd..4c9dcf8e071b 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -193,30 +193,62 @@ namespace o3tl {
 template<> struct typed_flags : is_typed_flags {};
 }
 
+struct SwViewColors
+{
+SwViewColors();
+SwViewColors(const svtools::ColorConfig& rConfig);
+bool operator==(const SwViewColors& rOther) const
+{
+return m_aDocColor == rOther.m_aDocColor
+&& m_aDocBoundColor == rOther.m_aDocBoundColor
+&& m_aObjectBoundColor == rOther.m_aObjectBoundColor
+&& m_aAppBackgroundColor == rOther.m_aAppBackgroundColor
+&& m_aTableBoundColor == rOther.m_aTableBoundColor
+&& m_aFontColor == rOther.m_aFontColor
+&& m_aIndexShadingsColor == rOther.m_aIndexShadingsColor
+&& m_aLinksColor == rOther.m_aLinksColor
+&& m_aVisitedLinksColor == rOther.m_aVisitedLinksColor
+&& m_aDirectCursorColor == rOther.m_aDirectCursorColor
+&& m_aTextGridColor == rOther.m_aTextGridColor
+&& m_aSpellColor == rOther.m_aSpellColor
+&& m_aGrammarColor == rOther.m_aGrammarColor
+&& m_aSmarttagColor == rOther.m_aSmarttagColor
+&& m_aFieldShadingsColor == rOther.m_aFieldShadingsColor
+&& m_aSectionBoundColor == rOther.m_aSectionBoundColor
+&& m_aPageBreakColor == rOther.m_aPageBreakColor
+&& m_aScriptIndicatorColor == rOther.m_aScriptIndicatorColor
+&& m_aShadowColor == rOther.m_aShadowColor
+&& m_aHeaderFooterMarkColor == rOther.m_aHeaderFooterMarkColor
+&& m_nAppearanceFlags == rOther.m_nAppearanceFlags;
+}
+Color m_aDocColor;  // color of document boundaries
+Color m_aDocBoundColor;  // color of document boundaries
+Color m_aObjectBoundColor; // color of object boundaries
+Color m_aAppBackgroundColor; // application background
+Color 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-15 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/cellatr.hxx   |1 
 sw/inc/swtable.hxx   |3 +-
 sw/source/core/attr/cellatr.cxx  |   17 +++
 sw/source/core/doc/DocumentFieldsManager.cxx |   20 ++
 sw/source/core/docnode/ndtbl.cxx |   29 +--
 sw/source/core/layout/frmtool.cxx|4 ---
 sw/source/core/table/swtable.cxx |   15 +++--
 sw/source/core/undo/untbl.cxx|   23 -
 8 files changed, 46 insertions(+), 66 deletions(-)

New commits:
commit 7c954d09f70d262d44b2c63fff3376dc89722c60
Author: Bjoern Michaelsen 
AuthorDate: Sat Mar 4 16:51:32 2023 +0100
Commit: Michael Stahl 
CommitDate: Wed Mar 15 11:07:23 2023 +

Add SwTable::SwitchFormulasToInternalRepresentation

- and get rid of most of the TBL_BOXPTR stuff it replaces
- instead of using a TBL_BOXPTR on UpdateTableFields
  SwTable::SwitchFormulasToInternalRepresentation should
  be used
- TBL_BOXPTR is not used via UpdateTableFields anymore and
  an assert assures it will never be

Change-Id: I56eca0e339e0d87a60009ea4dd53f4fe96fe639a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148249
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/cellatr.hxx b/sw/inc/cellatr.hxx
index f5d4909fd1b6..d1de3bbb9136 100644
--- a/sw/inc/cellatr.hxx
+++ b/sw/inc/cellatr.hxx
@@ -71,6 +71,7 @@ public:
 const SwTableBox* GetTableBox() const
 { return const_cast(this)->GetTableBox(); }
 
+void TryBoxNmToPtr();
 void ChangeState( const SfxPoolItem* pItem );
 void Calc( SwTableCalcPara& rCalcPara, double& rValue );
 };
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index ee63cf1972e0..39e54edb2f33 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -363,7 +363,8 @@ public:
 { UpdateFields(TBL_BOXNAME); };
 void SwitchFormulasToRelativeRepresentation()
 { UpdateFields(TBL_RELBOXNAME); };
-
+void SwitchFormulasToInternalRepresentation()
+{ UpdateFields(TBL_BOXPTR); }
 
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
diff --git a/sw/source/core/attr/cellatr.cxx b/sw/source/core/attr/cellatr.cxx
index 4e4e9440463f..02b2923b9f88 100644
--- a/sw/source/core/attr/cellatr.cxx
+++ b/sw/source/core/attr/cellatr.cxx
@@ -94,6 +94,16 @@ SwTableBox* SwTableBoxFormula::GetTableBox()
 return m_pDefinedIn ? 
static_cast(m_pDefinedIn)->GetTableBox() : nullptr;
 }
 
+void SwTableBoxFormula::TryBoxNmToPtr()
+{
+const SwNode* pNd = GetNodeOfFormula();
+if (!pNd || >GetNodes() != >GetDoc().GetNodes())
+return;
+if(const SwTableNode* pTableNd = pNd->FindTableNode())
+{
+BoxNmToPtr(>GetTable());
+}
+}
 void SwTableBoxFormula::ChangeState( const SfxPoolItem* pItem )
 {
 if( !m_pDefinedIn )
@@ -124,13 +134,10 @@ void SwTableBoxFormula::ChangeState( const SfxPoolItem* 
pItem )
 // reset value flag
 ChgValid( false );
 break;
+case TBL_BOXPTR:
 case TBL_RELBOXNAME:
 case TBL_BOXNAME:
-assert(false); // PtrToBoxNm and ToRelBoxNm are both public -- use 
just them directly
-break;
-case TBL_BOXPTR:
-// internal rendering
-BoxNmToPtr( >GetTable() );
+assert(false); // PtrToBoxNm, ToRelBoxNm and BoxNmToPtr are all public 
-- use just them directly
 break;
 
 case TBL_SPLITTBL:
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx 
b/sw/source/core/doc/DocumentFieldsManager.cxx
index 3ccbbfe00ca4..6c983e891544 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -601,14 +601,15 @@ void DocumentFieldsManager::UpdateTableFields( 
SfxPoolItem* pHt )
 OSL_ENSURE( !pHt || RES_TABLEFML_UPDATE  == pHt->Which(),
 "What MessageItem is this?" );
 
+SwTableFormulaUpdate* pUpdateField = nullptr;
+if( pHt && RES_TABLEFML_UPDATE == pHt->Which() )
+pUpdateField = static_cast(pHt);
+assert(!pUpdateField || pUpdateField->m_eFlags != TBL_BOXPTR); // use 
SwTable::SwitchFormulasToInternalRepresentation
 auto pFieldType = GetFieldType( SwFieldIds::Table, OUString(), false );
 if(pFieldType)
 {
 std::vector vFields;
 pFieldType->GatherFields(vFields);
-SwTableFormulaUpdate* pUpdateField = nullptr;
-if( pHt && RES_TABLEFML_UPDATE == pHt->Which() )
-pUpdateField = static_cast(pHt);
 for(auto pFormatField : vFields)
 {
 SwTableField* pField = 
static_cast(pFormatField->GetField());
@@ -633,11 +634,6 @@ void DocumentFieldsManager::UpdateTableFields( 
SfxPoolItem* pHt )
 pField->ChgValid( false );
 break;
 case TBL_BOXPTR:
-// to the internal representation
-// JP 17.06.96: internal representation on all 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-13 Thread Michael Stahl (via logerrit)
 sw/inc/tblafmt.hxx  |1 +
 sw/source/core/doc/tblafmt.cxx  |7 +++
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   17 +
 3 files changed, 25 insertions(+)

New commits:
commit fff2b5d06c24bb36a498bdb869158ee09c487111
Author: Michael Stahl 
AuthorDate: Mon Mar 13 14:59:03 2023 +0100
Commit: Michael Stahl 
CommitDate: Mon Mar 13 18:35:03 2023 +

tdf#153935 sw: PDF/UA export: guess table headers based on autoformat

This is a bit of a disaster area because in contrast to SdrTableObj
(see commit 0bc96b8805f2cfa2278729a9f3e56a350ddd69ad)
the SwTableAutoFormat application doesn't have flags which "special"
formattings like "first-row" etc. should be applied to the table.

So add a horrible heuristic to guess depending on the content of its
formatting attributes.

Change-Id: Ie09538d37de6118409b04a4cec6ab46b74c4194d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148793
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index c056810450be..2f6c8f788f11 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -238,6 +238,7 @@ public:
 bool FirstRowStartColumnIsRow();
 bool LastRowEndColumnIsRow();
 bool LastRowStartColumnIsRow();
+bool HasHeaderRow() const;
 
 bool Load( SvStream& rStream, const SwAfVersions& );
 bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index fdfe2702149b..d90760532a44 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -731,6 +731,13 @@ bool SwTableAutoFormat::LastRowStartColumnIsRow()
 {
 return GetBoxFormat(12) == GetBoxFormat(13);
 }
+bool SwTableAutoFormat::HasHeaderRow() const
+{   // Wild guessing for PDF export: is header different from odd or body?
+// It would be vastly better to do like SdrTableObj and have flags that
+// determine which "special" styles apply, instead of horrible guessing.
+return !(GetBoxFormat(1) == GetBoxFormat(5))
+|| !(GetBoxFormat(1) == GetBoxFormat(10));
+}
 
 bool SwTableAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions 
)
 {
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 9939d0237cd1..fa5f05bc6854 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -80,6 +80,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -190,6 +191,22 @@ bool lcl_IsHeadlineCell( const SwCellFrame& rCellFrame )
 bRet = sStyleName == aTableHeadingName;
 }
 
+// tdf#153935 wild guessing for 1st row based on table autoformat
+if (!bRet && !rCellFrame.GetUpper()->GetPrev())
+{
+SwTable const*const pTable(rCellFrame.FindTabFrame()->GetTable());
+assert(pTable);
+OUString const& rStyleName(pTable->GetTableStyleName());
+if (!rStyleName.isEmpty())
+{
+if (SwTableAutoFormat const*const pTableAF =
+
pTable->GetFrameFormat()->GetDoc()->GetTableStyles().FindAutoFormat(rStyleName))
+{
+bRet |= pTableAF->HasHeaderRow();
+}
+}
+}
+
 return bRet;
 }
 


[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-12 Thread Mike Kaganski (via logerrit)
 sw/inc/ndindex.hxx  |2 -
 sw/source/filter/ww8/wrtww8.cxx |   74 ++--
 2 files changed, 21 insertions(+), 55 deletions(-)

New commits:
commit e11b63196ba6db33a6137382ba82bbcca2dd5bdc
Author: Mike Kaganski 
AuthorDate: Sun Mar 12 12:59:16 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sun Mar 12 16:29:34 2023 +

Drop some const_cast

Change-Id: I34458e6d16a5fddebf3673cc475204c914217a54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148734
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx
index 04848f00479e..d700ac11c2f0 100644
--- a/sw/inc/ndindex.hxx
+++ b/sw/inc/ndindex.hxx
@@ -119,7 +119,7 @@ public:
 const SwNodes& GetNodes() const { return m_pNode->GetNodes(); }
   SwNodes& GetNodes() { return m_pNode->GetNodes(); }
 
-SwNodeIndex* GetNext() { return GetNextInRing(); }
+const SwNodeIndex* GetNext() const { return GetNextInRing(); }
 SwNode& GetNode() const { return *m_pNode; }
 };
 
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index ad5ec5e8bcf2..c9415747cefd 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3142,9 +3142,6 @@ void MSWordExportBase::AddLinkTarget(std::u16string_view 
rURL)
 return;
 
 sCmp = sCmp.toAsciiLowerCase();
-SwNodeOffset nIdx(0);
-bool noBookmark = false;
-
 if( sCmp == "outline" )
 {
 SwPosition aPos(*m_pCurPam->GetPoint());
@@ -3153,81 +3150,57 @@ void 
MSWordExportBase::AddLinkTarget(std::u16string_view rURL)
 // save the name of the bookmark and the
 // node index number of where it points to
 if( m_rDoc.GotoOutline( aPos, aName ) )
-{
-nIdx = aPos.GetNodeIndex();
-noBookmark = true;
-}
+m_aImplicitBookmarks.emplace_back(aURL, aPos.GetNodeIndex());
 }
 else if( sCmp == "graphic" )
 {
-SwNodeIndex* pIdx;
 OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
-const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, 
SwNodeType::Grf);
-if (pFormat && nullptr != (pIdx = 
const_cast(pFormat->GetContent().GetContentIdx(
-{
-nIdx = pIdx->GetNext()->GetIndex();
-noBookmark = true;
-}
+if (const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, 
SwNodeType::Grf))
+if (const SwNodeIndex* pIdx = 
pFormat->GetContent().GetContentIdx())
+m_aImplicitBookmarks.emplace_back(aURL, 
pIdx->GetNext()->GetIndex());
 }
 else if( sCmp == "frame" )
 {
-SwNodeIndex* pIdx;
 OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
-const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, 
SwNodeType::Text);
-if (pFormat && nullptr != (pIdx = 
const_cast(pFormat->GetContent().GetContentIdx(
-{
-nIdx = pIdx->GetIndex() + 1;
-noBookmark = true;
-}
+if (const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, 
SwNodeType::Text))
+if (const SwNodeIndex* pIdx = 
pFormat->GetContent().GetContentIdx())
+m_aImplicitBookmarks.emplace_back(aURL, pIdx->GetIndex() + 1);
 }
 else if( sCmp == "ole" )
 {
-SwNodeIndex* pIdx;
 OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
-const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, 
SwNodeType::Ole);
-if (pFormat && nullptr != (pIdx = 
const_cast(pFormat->GetContent().GetContentIdx(
-{
-nIdx = pIdx->GetNext()->GetIndex();
-noBookmark = true;
-}
+if (const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, 
SwNodeType::Ole))
+if (const SwNodeIndex* pIdx = 
pFormat->GetContent().GetContentIdx())
+m_aImplicitBookmarks.emplace_back(aURL, 
pIdx->GetNext()->GetIndex());
 }
 else if( sCmp == "region" )
 {
-SwNodeIndex* pIdx;
 OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
 for (const SwSectionFormat* pFormat : m_rDoc.GetSections())
 {
-if (aName == pFormat->GetSection()->GetSectionName()
-&& nullptr != (pIdx = 
const_cast(pFormat->GetContent().GetContentIdx(
+if (aName == pFormat->GetSection()->GetSectionName())
 {
-nIdx = pIdx->GetIndex() + 1;
-noBookmark = true;
-break;
+if (const SwNodeIndex* pIdx = 
pFormat->GetContent().GetContentIdx())
+{
+m_aImplicitBookmarks.emplace_back(aURL, pIdx->GetIndex() + 
1);
+break;
+}
 }
 }
 }
 else if( sCmp == "table" )
 {
 OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
-const SwTable* 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-11 Thread Mike Kaganski (via logerrit)
 sw/inc/ndindex.hxx  |  215 +++-
 sw/source/core/crsr/swcrsr.cxx  |   10 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   12 
 sw/source/core/doc/DocumentRedlineManager.cxx   |3 
 sw/source/core/doc/docnew.cxx   |   12 
 sw/source/core/unocore/unotext.cxx  |2 
 sw/source/filter/docx/swdocxreader.cxx  |2 
 sw/source/filter/xml/XMLRedlineImportHelper.cxx |2 
 sw/source/uibase/docvw/UnfloatTableButton.cxx   |2 
 sw/source/uibase/wrtsh/wrtsh1.cxx   |6 
 10 files changed, 75 insertions(+), 191 deletions(-)

New commits:
commit b0b9e755d3b81ad453ebe8f800a1e7c005efc471
Author: Mike Kaganski 
AuthorDate: Sat Mar 11 17:40:37 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sat Mar 11 20:30:10 2023 +

Simplify SwNodeIndex

Change-Id: Ic3bb99d30445c2c355ec8634651bb308d198f714
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148683
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx
index 98c1357821e7..bbe76f1be706 100644
--- a/sw/inc/ndindex.hxx
+++ b/sw/inc/ndindex.hxx
@@ -31,8 +31,9 @@ class SAL_WARN_UNUSED SW_DLLPUBLIC SwNodeIndex final : public 
sw::Ring()
-{
-if( nDiff )
-m_pNode = rIdx.GetNodes()[ rIdx.GetIndex() + nDiff ];
-else
-m_pNode = rIdx.m_pNode;
-RegisterIndex( m_pNode->GetNodes() );
-}
-SwNodeIndex( const SwNodeIndex& rIdx ) : SwNodeIndex(rIdx, 0) {}
+SwNodeIndex( const SwNodeIndex& rIdx, SwNodeOffset nDiff = SwNodeOffset(0) 
)
+: SwNodeIndex( nDiff ? rIdx.GetNodes()[ rIdx.GetIndex() + nDiff ] : 
rIdx.m_pNode ) {}
 
 SwNodeIndex( const SwNode& rNd, sal_Int32 nDiff ) : SwNodeIndex(rNd, 
SwNodeOffset(nDiff)) {}
-explicit SwNodeIndex( const SwNode& rNd, SwNodeOffset nDiff = 
SwNodeOffset(0) )
-{
-if( nDiff )
-m_pNode = rNd.GetNodes()[ rNd.GetIndex() + nDiff ];
-else
-m_pNode = const_cast();
-RegisterIndex( m_pNode->GetNodes() );
-}
+explicit SwNodeIndex( const SwNode& rNd )
+: SwNodeIndex( const_cast() ) {}
+explicit SwNodeIndex( const SwNode& rNd, SwNodeOffset nDiff )
+: SwNodeIndex( nDiff ? *rNd.GetNodes()[ rNd.GetIndex() + nDiff ] : rNd 
) {}
 
-virtual  ~SwNodeIndex() override
-{ DeRegisterIndex( m_pNode->GetNodes() ); }
+virtual ~SwNodeIndex() override { DeRegisterIndex(); }
 
-inline SwNodeOffset operator++();
-inline SwNodeOffset operator--();
-inline SwNodeOffset operator++(int);
-inline SwNodeOffset operator--(int);
+SwNodeIndex& operator++() { return operator+=(SwNodeOffset(1)); }
+SwNodeIndex& operator--() { return operator-=(SwNodeOffset(1)); }
 
-inline SwNodeOffset operator+=( SwNodeOffset );
-inline SwNodeOffset operator-=( SwNodeOffset );
+SwNodeIndex& operator+=( SwNodeOffset nOffset ) { return 
operator=(GetIndex() + nOffset); }
+SwNodeIndex& operator-=( SwNodeOffset nOffset ) { return 
operator=(GetIndex() - nOffset); }
 
-inline bool operator< ( const SwNodeIndex& ) const;
-inline bool operator<=( const SwNodeIndex& ) const;
-inline bool operator> ( const SwNodeIndex& ) const;
-inline bool operator>=( const SwNodeIndex& ) const;
-inline bool operator==( const SwNodeIndex& ) const;
-inline bool operator!=( const SwNodeIndex& ) const;
+bool operator<( const SwNodeIndex& rIndex ) const { return 
operator<(rIndex.GetNode()); }
+bool operator<=( const SwNodeIndex& rIndex ) const { return 
operator<=(rIndex.GetNode()); }
+bool operator>( const SwNodeIndex& rIndex ) const { return 
operator>(rIndex.GetNode()); }
+bool operator>=( const SwNodeIndex& rIndex ) const { return 
operator>=(rIndex.GetNode()); }
+bool operator==( const SwNodeIndex& rIndex ) const { return 
operator==(rIndex.GetNode()); }
+bool operator!=( const SwNodeIndex& rIndex ) const { return 
operator!=(rIndex.GetNode()); }
 
-inline bool operator< ( SwNodeOffset ) const;
-inline bool operator<=( SwNodeOffset ) const;
-inline bool operator> ( SwNodeOffset ) const;
-inline bool operator>=( SwNodeOffset ) const;
-inline bool operator==( SwNodeOffset ) const;
-inline bool operator!=( SwNodeOffset ) const;
+bool operator<( SwNodeOffset nOther ) const { return GetIndex() < nOther; }
+bool operator<=( SwNodeOffset nOther ) const { return GetIndex() <= 
nOther; }
+bool operator>( SwNodeOffset nOther ) const { return GetIndex() > nOther; }
+bool operator>=( SwNodeOffset nOther ) const { return GetIndex() >= 
nOther; }
+bool operator==( SwNodeOffset nOther ) const { return GetIndex() == 
nOther; }
+bool operator!=( SwNodeOffset nOther ) const { return GetIndex() != 
nOther; }
 
 bool operator<( const SwNode& rNd ) const { return 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-09 Thread Miklos Vajna (via logerrit)
 sw/inc/doc.hxx |2 ++
 sw/source/core/bastyp/init.cxx |1 +
 sw/source/core/doc/docnew.cxx  |4 
 3 files changed, 7 insertions(+)

New commits:
commit ab61be6ed502349152b165bc3db4c61f04c2f20d
Author: Miklos Vajna 
AuthorDate: Thu Mar 9 08:01:34 2023 +0100
Commit: Miklos Vajna 
CommitDate: Thu Mar 9 09:54:03 2023 +

sw doc model dump: allow invoking this from outside sw/ in a debugger

There is only a single SwDoc instance in many cases, having an easy
to access pointer to that is helpful when the backtrace doesn't include
a frame in sw/ code.

This allows something like 'print SwDoc::s_pLast->dumpAsXml(0)' in gdb,
even if e.g. the current frame is xmloff/, without hunting for a parent
that is in sw/.

Change-Id: Id70baf7919ef6fde7b834704741dab70531e7e2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148522
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index dd2973fb7447..17d130a51be4 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -337,6 +337,8 @@ private:
 bool mbContainsAtPageObjWithContentAnchor : 1;
 
 static SwAutoCompleteWord *s_pAutoCompleteWords;  //< List of all words 
for AutoComplete
+/// The last, still alive SwDoc instance, for debugging.
+static SwDoc* s_pLast;
 
 // private methods
 SwFlyFrameFormat* MakeFlySection_( const SwPosition& rAnchPos,
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index 52e452bb4aa0..a5bcd736966e 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -440,6 +440,7 @@ SfxItemInfo aSlotTab[] =
 std::vector *pGlobalOLEExcludeList = nullptr;
 
 SwAutoCompleteWord* SwDoc::s_pAutoCompleteWords = nullptr;
+SwDoc* SwDoc::s_pLast = nullptr;
 
 SwCheckIt* pCheckIt = nullptr;
 static CharClass* pAppCharClass = nullptr;
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 716c31f0dbae..0a5aedf6a105 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -389,6 +389,8 @@ SwDoc::SwDoc()
 }
 
 getIDocumentState().ResetModified();
+
+s_pLast = this;
 }
 
 /**
@@ -398,6 +400,8 @@ SwDoc::SwDoc()
  */
 SwDoc::~SwDoc()
 {
+s_pLast = nullptr;
+
 mxVbaFind.clear();
 
 // nothing here should create Undo actions!


[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-08 Thread Miklos Vajna (via logerrit)
 sw/inc/strings.hrc  |1 +
 sw/inc/swundo.hxx   |1 +
 sw/source/core/undo/undobj.cxx  |3 +++
 sw/source/uibase/shells/textsh1.cxx |4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit db73d73c4031c20cede546e00b2fc34d673f3069
Author: Miklos Vajna 
AuthorDate: Wed Mar 8 20:13:41 2023 +0100
Commit: Miklos Vajna 
CommitDate: Thu Mar 9 07:00:12 2023 +

sw: fix undo comment of FN_UPDATE_BOOKMARKS

It's updates, not insert. One has to dispatch .uno:UpdateBookmarks to see
this in action, which does something if the document already contains at
least one bookmark.

Change-Id: I32d259b0b5c18cbbec2969cd189ca7ba4dd0dde4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148487
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 033a1a225a92..2965e6b884b2 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -439,6 +439,7 @@
 #define STR_DELBOOKMARK NC_("STR_DELBOOKMARK", "Delete 
bookmark: $1")
 #define STR_INSBOOKMARK NC_("STR_INSBOOKMARK", "Insert 
bookmark: $1")
 #define STR_UPDATE_BOOKMARK NC_("STR_UPDATE_BOOKMARK", 
"Update bookmark: $1")
+#define STR_UPDATE_BOOKMARKSNC_("STR_UPDATE_BOOKMARKS", 
"Update bookmarks")
 #define STR_SORT_TBLNC_("STR_SORT_TBL", "Sort 
table")
 #define STR_SORT_TXTNC_("STR_SORT_TXT", "Sort 
text")
 #define STR_INSTABLE_UNDO   NC_("STR_INSTABLE_UNDO", 
"Insert table: $1$2$3")
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index d4da619560cc..efca97bc1b23 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -171,6 +171,7 @@ enum class SwUndoId
 UPDATE_FORM_FIELDS,// 139
 DELETE_FORM_FIELDS,// 140
 UPDATE_BOOKMARK,   // 141
+UPDATE_BOOKMARKS,  // 142
 };
 
 OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index d872bc812166..8e5638205c61 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -658,6 +658,9 @@ OUString GetUndoComment(SwUndoId eId)
 case SwUndoId::UPDATE_BOOKMARK:
 pId = STR_UPDATE_BOOKMARK;
 break;
+case SwUndoId::UPDATE_BOOKMARKS:
+pId = STR_UPDATE_BOOKMARKS;
+break;
 }
 
 assert(pId);
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index f1d9522a89f7..b52e26778388 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -515,7 +515,7 @@ void UpdateBookmarks(SfxRequest& rReq, SwWrtShell& rWrtSh)
 pBookmarks->GetValue() >>= aBookmarks;
 }
 
-rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSBOOKMARK, 
nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_BOOKMARKS, 
nullptr);
 rWrtSh.StartAction();
 
 IDocumentMarkAccess& rIDMA = *rWrtSh.GetDoc()->getIDocumentMarkAccess();
@@ -578,7 +578,7 @@ void UpdateBookmarks(SfxRequest& rReq, SwWrtShell& rWrtSh)
 }
 
 rWrtSh.EndAction();
-rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSBOOKMARK, 
nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_BOOKMARKS, 
nullptr);
 }
 
 void UpdateBookmark(SfxRequest& rReq, SwWrtShell& rWrtSh)


[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-06 Thread László Németh (via logerrit)
 sw/inc/shellio.hxx|8 
 sw/source/filter/ascii/parasc.cxx |   11 +++
 2 files changed, 19 insertions(+)

New commits:
commit 13e34393e4564ef67d990c6dbe1991a0a6b288dd
Author: László Németh 
AuthorDate: Thu Mar 2 11:50:17 2023 +0100
Commit: László Németh 
CommitDate: Mon Mar 6 09:38:30 2023 +

tdf#154000 tdf#70423 sw: fix crash/freezing with huge text files

It was not possible to load or edit text files with very long
lines any more, because removed wrapping of the lines resulted
freezing and crash.

This reverts commit 745898eb2af2686ffbdfdc0e44984db67b172a59
"tdf#70423 Remove txtimport break in 10k chars line",
keeping only its unit test.

Fix also tdf#70423 by increasing the wrap limit from 1
to 25 characters, which still permit to load e.g. 50 MB
character or longer text lines, and to edit 5 MB or longer
text lines without crash or freezing.

Details: trying to load a relatively short 76 MB character
length text line shows a non-linear slowing down during the
load, resulting program crash after freezing 10 minutes.

Now this file is opened within seconds again, allowing to modify,
select and copy of the text before the full load of the document
(with linear speed). Loading a much shorter 5 MB character
length text line resulted an unusably slow editing previously:
waiting half minutes for changing, selecting or copying text
parts.

Manual test

Create a text file with a 76 MB character long line, and
open it:

$ seq 1000 | tr '\n' ' '  >numbers.txt
$ soffice numbers.txt

Note: the reverted commit had also a paragraph limit exceeded
error using unlimited paragraph length, because that is limited
in 4 GiB characters since version 4.3, see tdf#30668 and commit
ba27366f3d6bc6b209ecd5c5cb79a9ee5315316a "Resolves: #i17171#
Writer paragraph cannot be longer than 65534 characters".

Change-Id: If91e340a8aac4d4ebc4097b19cfa854b5659da3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148169
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index e666442d19a9..b3a18e65f510 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -51,6 +51,14 @@ struct Writer_Impl;
 namespace sw::mark { class IMark; }
 namespace com::sun::star::embed { class XStorage; }
 
+// Defines the count of chars at which a paragraph read via ASCII/W4W-Reader
+// is forced to wrap. It has to be always greater than 200!!!
+// Note: since version 4.3, maximum character count changed to 4 GiB from 64 
KiB
+// in a paragraph, but because of the other limitations, we set a lower wrap 
value
+// to get a working text editor e.g. without freezing and crash during loading 
of
+// a 50 MB text line, or unusably slow editing of a 5 MB text line.
+#define MAX_ASCII_PARA 25
+
 class SW_DLLPUBLIC SwAsciiOptions
 {
 OUString m_sFont;
diff --git a/sw/source/filter/ascii/parasc.cxx 
b/sw/source/filter/ascii/parasc.cxx
index eab7a59e898b..b29251bcbd8b 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -474,6 +474,17 @@ ErrCode SwASCIIParser::ReadChars()
 
 if( bIns )
 {
+if( ( nLineLen >= MAX_ASCII_PARA - 100 ) &&
+( ( *pStt == ' ' ) || ( nLineLen >= MAX_ASCII_PARA - 1 ) ) )
+{
+sal_Unicode c = *pStt;
+*pStt = 0;
+InsertText( OUString( pLastStt ));
+
m_rDoc.getIDocumentContentOperations().SplitNode(*m_oPam->GetPoint(), false);
+pLastStt = pStt;
+nLineLen = 0;
+*pStt = c;
+}
 ++pStt;
 ++nLineLen;
 }


[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-02 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/swtable.hxx   |7 
 sw/source/core/doc/DocumentFieldsManager.cxx |   12 +-
 sw/source/core/doc/docsort.cxx   |5 --
 sw/source/core/doc/tblcpy.cxx|   17 +
 sw/source/core/doc/tblrwcl.cxx   |   14 +---
 sw/source/core/docnode/ndtbl.cxx |4 --
 sw/source/core/edit/edtab.cxx|5 --
 sw/source/core/table/swtable.cxx |   47 +++
 sw/source/core/undo/rolbck.cxx   |   21 ++--
 sw/source/core/undo/untbl.cxx|   11 +++---
 10 files changed, 82 insertions(+), 61 deletions(-)

New commits:
commit b9716112219469fa4e0af33a6edb7eec0ff33026
Author: Bjoern Michaelsen 
AuthorDate: Wed Mar 1 23:15:47 2023 +0100
Commit: Bjoern Michaelsen 
CommitDate: Fri Mar 3 07:55:45 2023 +

Refactor TBL_{REL,}BOXNAME to SwTable

- because those only modify the fields of that one table
- also add lots of const_cast unfortunately, but not because it makes
  things worse:
  * this was modifying the table before (thus non-const)
  * at least now this is a bit more explicit

Change-Id: I0174daecabcc6de9b7c9867b24c94659c0dbcafe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148080
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
Reviewed-by: Bjoern Michaelsen 

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 3858c55217be..ee63cf1972e0 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -174,6 +174,8 @@ private:
 void NewSetTabCols( Parm , const SwTabCols , const SwTabCols ,
 const SwTableBox *pStart, bool bCurRowOnly );
 void ConvertSubtableBox(sal_uInt16 const nRow, sal_uInt16 const nBox);
+// Only used for TBL_BOXNAME and TBL_RELBOXNAME for now
+void UpdateFields(TableFormulaUpdateFlags eFlags);
 
 public:
 
@@ -357,6 +359,11 @@ public:
 // it doesn't contain box content (except single empty nested tables of 
the boxes
 // which could remain after deletion of text content of the selected table)
 bool IsEmpty() const;
+void SwitchFormulasToExternalRepresentation()
+{ UpdateFields(TBL_BOXNAME); };
+void SwitchFormulasToRelativeRepresentation()
+{ UpdateFields(TBL_RELBOXNAME); };
+
 
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx 
b/sw/source/core/doc/DocumentFieldsManager.cxx
index 62ed40812160..3ccbbfe00ca4 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -632,23 +632,15 @@ void DocumentFieldsManager::UpdateTableFields( 
SfxPoolItem* pHt )
 else
 pField->ChgValid( false );
 break;
-case TBL_BOXNAME:
-// is this the wanted table?
-if( >GetTable() == pUpdateField->m_pTable )
-// to the external representation
-pField->PtrToBoxNm( pUpdateField->m_pTable );
-break;
 case TBL_BOXPTR:
 // to the internal representation
 // JP 17.06.96: internal representation on all formulas
 //  (reference to other table!!!)
 pField->BoxNmToPtr( >GetTable() );
 break;
+case TBL_BOXNAME:
 case TBL_RELBOXNAME:
-// is this the wanted table?
-if( >GetTable() == pUpdateField->m_pTable )
-// to the relative representation
-pField->ToRelBoxNm( pUpdateField->m_pTable );
+assert(false); // use SwTable::SwitchTo...
 break;
 default:
 break;
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index f4693871c3e3..3601c119bbb3 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -506,10 +506,7 @@ bool SwDoc::SortTable(const SwSelBoxes& rBoxes, const 
SwSortOptions& rOpt)
 nStart = 0;
 }
 
-// Switch to relative Formulas
-SwTableFormulaUpdate aMsgHint( >GetTable() );
-aMsgHint.m_eFlags = TBL_RELBOXNAME;
-getIDocumentFieldsAccess().UpdateTableFields(  );
+pTableNd->GetTable().SwitchFormulasToRelativeRepresentation();
 
 // Table as a flat array structure
 FlatFndBox aFlatBox(this, aFndBox);
diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx
index 0343c9c35b27..c39d9c387a3c 100644
--- a/sw/source/core/doc/tblcpy.cxx
+++ b/sw/source/core/doc/tblcpy.cxx
@@ -673,10 +673,7 @@ bool SwTable::InsNewTable( const SwTable& rCpyTable, const 
SwSelBoxes& rSelBoxes
 aTarget.assignBoxes( aCopyStruct );
 
 {
-// Change table formulas into relative representation
-

[Libreoffice-commits] core.git: sw/inc sw/source

2023-03-01 Thread Miklos Vajna (via logerrit)
 sw/inc/strings.hrc  |1 +
 sw/inc/swundo.hxx   |1 +
 sw/source/core/undo/undobj.cxx  |3 +++
 sw/source/uibase/shells/textsh1.cxx |8 +---
 4 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 0449583616bf1a73936229ec2aa333b5ecf5e882
Author: Miklos Vajna 
AuthorDate: Wed Mar 1 20:02:19 2023 +0100
Commit: Miklos Vajna 
CommitDate: Thu Mar 2 07:01:08 2023 +

sw: fix undo comment of FN_UPDATE_BOOKMARK

It's an update and the name was not set. One has to dispatch
.uno:UpdateBookmark to see this in action, which does something if the
cursor is inside an exiting bookmark.

Change-Id: Ib9c54a28c5410cc001468952cfd8577a9412d664
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148073
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 40cbb9acb8c4..8b8b1df2731c 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -438,6 +438,7 @@
 #define STR_INSERT_GLOSSARY NC_("STR_INSERT_GLOSSARY", 
"Insert AutoText")
 #define STR_DELBOOKMARK NC_("STR_DELBOOKMARK", "Delete 
bookmark: $1")
 #define STR_INSBOOKMARK NC_("STR_INSBOOKMARK", "Insert 
bookmark: $1")
+#define STR_UPDATE_BOOKMARK NC_("STR_UPDATE_BOOKMARK", 
"Update bookmark: $1")
 #define STR_SORT_TBLNC_("STR_SORT_TBL", "Sort 
table")
 #define STR_SORT_TXTNC_("STR_SORT_TXT", "Sort 
text")
 #define STR_INSTABLE_UNDO   NC_("STR_INSTABLE_UNDO", 
"Insert table: $1$2$3")
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index 61261fb9769b..d4da619560cc 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -170,6 +170,7 @@ enum class SwUndoId
 UPDATE_FORM_FIELD, // 138
 UPDATE_FORM_FIELDS,// 139
 DELETE_FORM_FIELDS,// 140
+UPDATE_BOOKMARK,   // 141
 };
 
 OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 3c5f3844591e..d872bc812166 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -655,6 +655,9 @@ OUString GetUndoComment(SwUndoId eId)
 case SwUndoId::DELETE_FORM_FIELDS:
 pId = STR_UNDO_DELETE_FORM_FIELDS;
 break;
+case SwUndoId::UPDATE_BOOKMARK:
+pId = STR_UPDATE_BOOKMARK;
+break;
 }
 
 assert(pId);
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index b68d5cd83baa..156572854c19 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -610,13 +610,15 @@ void UpdateBookmark(SfxRequest& rReq, SwWrtShell& rWrtSh)
 return;
 }
 
-rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSBOOKMARK, 
nullptr);
+SwRewriter aRewriter;
+aRewriter.AddRule(UndoArg1, pBookmark->GetName());
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_BOOKMARK, 
);
 rWrtSh.StartAction();
 comphelper::ScopeGuard g(
-[]
+[, ]
 {
 rWrtSh.EndAction();
-
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSBOOKMARK, nullptr);
+
rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_BOOKMARK, 
);
 });
 
 


[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-28 Thread Mike Kaganski (via logerrit)
 sw/inc/ToxTextGenerator.hxx |2 +-
 sw/source/core/tox/ToxTextGenerator.cxx |   16 
 2 files changed, 13 insertions(+), 5 deletions(-)

New commits:
commit b7a5ac03e03066d36e05da786669a9243ad0116f
Author: Mike Kaganski 
AuthorDate: Tue Feb 28 16:09:32 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Feb 28 19:12:34 2023 +

tdf#114773: only add space between entry number and text

Modify the hack from commit ce95e39f8e952159844e9dc04a1df402bb103634
(tdf#44282 fix missing space for numbered lists in TOC, 2016-08-16),
which added the space after entry numbers unconditionally.

There are other possibilities, like custom separators between the entry
number and text (e.g., [E#][T][E][T][#]); or the entry number (maybe
with limited depth) used with page number (like in [E#][E][T][E#]-[#]).
Generally, when entry number is not immediately followed by entry text,
the space is not needed.

Additionally, the space is not needed when the number text already ends
with a space character.

Change-Id: Ifa6c474574bfb74466ab721eca49f421a3750942
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147997
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/inc/ToxTextGenerator.hxx b/sw/inc/ToxTextGenerator.hxx
index 30581e110a1e..35eefd0fb7ab 100644
--- a/sw/inc/ToxTextGenerator.hxx
+++ b/sw/inc/ToxTextGenerator.hxx
@@ -143,7 +143,7 @@ private:
  */
 static OUString
 GetNumStringOfFirstNode(const SwTOXSortTabBase& rBase, bool bUsePrefix,
-sal_uInt8 nLevel, SwRootFrame const* pLayout);
+sal_uInt8 nLevel, SwRootFrame const* pLayout, bool bAddSpace = 
true);
 
 /** Handle a chapter token.
  */
diff --git a/sw/source/core/tox/ToxTextGenerator.cxx 
b/sw/source/core/tox/ToxTextGenerator.cxx
index 97ca39666391..1ef2a59d55bf 100644
--- a/sw/source/core/tox/ToxTextGenerator.cxx
+++ b/sw/source/core/tox/ToxTextGenerator.cxx
@@ -61,6 +61,9 @@ bool sortTabHasNoToxSourcesOrFirstToxSourceHasNoNode(const 
SwTOXSortTabBase& sor
 return false;
 }
 
+// Similar to rtl::isAsciiWhiteSpace, but applicable to ToC entry number
+bool isWhiteSpace(sal_Unicode ch) { return ch == ' ' || ch == '\t'; }
+
 } // end anonymous namespace
 
 namespace sw {
@@ -68,7 +71,7 @@ namespace sw {
 OUString
 ToxTextGenerator::GetNumStringOfFirstNode(const SwTOXSortTabBase& rBase,
 bool bUsePrefix, sal_uInt8 nLevel,
-SwRootFrame const*const pLayout)
+SwRootFrame const*const pLayout, bool bAddSpace)
 {
 if (sortTabHasNoToxSourcesOrFirstToxSourceHasNoNode(rBase)) {
 return OUString();
@@ -97,7 +100,7 @@ ToxTextGenerator::GetNumStringOfFirstNode(const 
SwTOXSortTabBase& rBase,
 sRet = pNd->GetNumString(bUsePrefix, nLevel, pLayout);
 }
 
-if (!sRet.isEmpty()) {
+if (bAddSpace && !sRet.isEmpty() && !isWhiteSpace(sRet[sRet.getLength() - 
1])) {
 sRet += " ";// Makes sure spacing is done only when there is outline 
numbering
 }
 
@@ -190,17 +193,22 @@ ToxTextGenerator::GenerateText(SwDoc* pDoc,
 // #i21237#
 SwFormTokens aPattern = mToxForm.GetPattern(nLvl);
 // remove text from node
-for(const auto& aToken : aPattern) // #i21237#
+for (size_t i = 0; i < aPattern.size(); ++i) // #i21237#
 {
+const auto& aToken = aPattern[i];
 sal_Int32 nStartCharStyle = rText.getLength();
 OUString aCharStyleName = aToken.sCharStyleName;
 switch( aToken.eTokenType )
 {
 case TOKEN_ENTRY_NO:
 // for TOC numbering
+// Only add space when there is outline numbering, and also 
when the next token
+// is the entry text: it can also be e.g. a tab, or the entry 
number can be used
+// in page number area like "2-15" for chapter 2, page 15.
 rText += GetNumStringOfFirstNode(rBase,
 aToken.nChapterFormat == CF_NUMBER,
-static_cast(aToken.nOutlineLevel - 1), pLayout);
+static_cast(aToken.nOutlineLevel - 1), pLayout,
+i < aPattern.size() - 1 && aPattern[i + 1].eTokenType == 
TOKEN_ENTRY_TEXT);
 break;
 
 case TOKEN_ENTRY_TEXT: {


[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-23 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/IDocumentFieldsAccess.hxx |3 ++-
 sw/source/core/doc/DocumentFieldsManager.cxx |   12 +++-
 sw/source/core/inc/DocumentFieldsManager.hxx |2 +-
 sw/source/core/layout/newfrm.cxx |3 +--
 sw/source/core/layout/pagechg.cxx|9 +++--
 sw/source/core/layout/tabfrm.cxx |3 +--
 sw/source/core/layout/wsfrm.cxx  |3 +--
 sw/source/core/view/viewsh.cxx   |3 +--
 8 files changed, 17 insertions(+), 21 deletions(-)

New commits:
commit b4b3f281443fc64b420156eed11af773f80a4e2a
Author: Bjoern Michaelsen 
AuthorDate: Sun Feb 19 17:45:41 2023 +0100
Commit: Bjoern Michaelsen 
CommitDate: Fri Feb 24 07:33:59 2023 +

Use just plain straight-forward params for UpdatePageFields

- dont wrap parameters in a useless hint as superfluous indirection
- note: SwDocPosUpdate receives a special kind of abuse here:
  * it is used as pNew with pOld being nullptr when send to the
document field manager
  * it is sneakily modified to be the pOld when it is forwarded by
the field to the frame via the node
- full path of the message before this change:
  -> passed to the UpdatePageFields as parameter
  -> wrapped as the pNew there and send to the field types
  -> passed by the fieldtypes to the fields
  -> tweaked to be the pOld with pNew being the field itselfby the
 fields when passed from the field to the node
  -> passed from the node to the frames

Change-Id: I084c3a1abe6871abdb82655cc413902dd16071cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147302
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen 

diff --git a/sw/inc/IDocumentFieldsAccess.hxx b/sw/inc/IDocumentFieldsAccess.hxx
index ee3e2536b921..c31e6a646ed0 100644
--- a/sw/inc/IDocumentFieldsAccess.hxx
+++ b/sw/inc/IDocumentFieldsAccess.hxx
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include "swtypes.hxx"
 #include "nodeoffset.hxx"
 
 class SwFieldTypes;
@@ -100,7 +101,7 @@ namespace com::sun::star::uno { class Any; }
 
 virtual void UpdateUsrFields() = 0;
 
-virtual void UpdatePageFields(SfxPoolItem*) = 0;
+virtual void UpdatePageFields(const SwTwips) = 0;
 
 virtual void LockExpFields() = 0;
 
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx 
b/sw/source/core/doc/DocumentFieldsManager.cxx
index 79852fa52ce0..4d6486bca262 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -1335,18 +1335,20 @@ sal_Int32 
DocumentFieldsManager::GetRecordsPerDocument() const
 return nRecords;
 }
 
-void DocumentFieldsManager::UpdatePageFields( SfxPoolItem* pMsgHint )
+void DocumentFieldsManager::UpdatePageFields(const SwTwips nDocPos)
 {
-for( SwFieldTypes::size_type i = 0; i < INIT_FLDTYPES; ++i )
+SwDocPosUpdate aDosPosUpdate(nDocPos);
+sw::LegacyModifyHint aHint(nullptr, );
+for(SwFieldTypes::size_type i = 0; i < INIT_FLDTYPES; ++i)
 {
-SwFieldType* pFieldType = (*mpFieldTypes)[ i ].get();
-switch( pFieldType->Which() )
+SwFieldType* pFieldType = (*mpFieldTypes)[i].get();
+switch(pFieldType->Which())
 {
 case SwFieldIds::PageNumber:
 case SwFieldIds::Chapter:
 case SwFieldIds::GetExp:
 case SwFieldIds::RefPageGet:
-pFieldType->CallSwClientNotify(sw::LegacyModifyHint(nullptr, 
pMsgHint));
+pFieldType->CallSwClientNotify(aHint);
 break;
 case SwFieldIds::DocStat:
 pFieldType->CallSwClientNotify(sw::LegacyModifyHint(nullptr, 
nullptr));
diff --git a/sw/source/core/inc/DocumentFieldsManager.hxx 
b/sw/source/core/inc/DocumentFieldsManager.hxx
index 2b661604b8de..0f1aede584cb 100644
--- a/sw/source/core/inc/DocumentFieldsManager.hxx
+++ b/sw/source/core/inc/DocumentFieldsManager.hxx
@@ -48,7 +48,7 @@ public:
 virtual void UpdateTableFields(SfxPoolItem* pHt) override;
 virtual void UpdateExpFields(SwTextField* pField, bool bUpdateRefFields) 
override;
 virtual void UpdateUsrFields() override;
-virtual void UpdatePageFields(SfxPoolItem*) override;
+virtual void UpdatePageFields(const SwTwips) override;
 virtual void LockExpFields() override;
 virtual void UnlockExpFields() override;
 virtual bool IsExpFieldsLocked() const override;
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index 5ca11e34138b..95af08baa6e3 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -512,8 +512,7 @@ void SwRootFrame::Init( SwFrameFormat* pFormat )
 //b6433357: Update page fields after loading
 if ( !mpCurrShell || !mpCurrShell->Imp()->IsUpdateExpFields() )
 {
-SwDocPosUpdate aMsgHint( pPage->getFrameArea().Top() );
-rFieldsAccess.UpdatePageFields(  );
+rFieldsAccess.UpdatePageFields(pPage->getFrameArea().Top());
 }
 
 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-23 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/fmtfld.hxx|1 
 sw/inc/usrfld.hxx|1 
 sw/source/core/doc/DocumentFieldsManager.cxx |4 
 sw/source/core/doc/docfld.cxx|4 
 sw/source/core/fields/docufld.cxx|2 
 sw/source/core/fields/usrfld.cxx |8 +
 sw/source/core/txtnode/atrfld.cxx|  173 +++
 sw/source/core/unocore/unofield.cxx  |2 
 8 files changed, 117 insertions(+), 78 deletions(-)

New commits:
commit a10d0ce37be8a9f7fe4270d8b4d61567a9418c24
Author: Bjoern Michaelsen 
AuthorDate: Sat Feb 18 00:30:09 2023 +0100
Commit: Bjoern Michaelsen 
CommitDate: Thu Feb 23 10:35:13 2023 +

refactor SwFormatField again

- strip out some helper functions
- split of the "forced update" special case
- extract ensuring user fields to be valid

Change-Id: Iee9aa5b25ab7d8e7c102f0c0950c47a46966bb19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147269
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen 

diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index 5807ed8fba70..1efb7665c953 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -166,6 +166,7 @@ public:
 
 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 
+void ForceUpdateTextNode();
 void UpdateTextNode(const SfxPoolItem* pOld, const SfxPoolItem* pNew);
 };
 
diff --git a/sw/inc/usrfld.hxx b/sw/inc/usrfld.hxx
index d9ea9e407440..faedb80671a8 100644
--- a/sw/inc/usrfld.hxx
+++ b/sw/inc/usrfld.hxx
@@ -69,6 +69,7 @@ public:
 
 virtual voidQueryValue( css::uno::Any& rVal, sal_uInt16 nMId ) 
const override;
 virtual voidPutValue( const css::uno::Any& rVal, sal_uInt16 nMId ) 
override;
+void EnsureValid();
 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 
 private:
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx 
b/sw/source/core/doc/DocumentFieldsManager.cxx
index 0c5bcfb375d6..79852fa52ce0 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -1264,7 +1264,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl(
 pInputField->UnlockNotifyContentChange();
 }
 });
-pFormatField->UpdateTextNode(nullptr, nullptr); // trigger 
formatting
+pFormatField->ForceUpdateTextNode();
 }
 
 if (pUpdateField == pTextField) // if only this one is updated
@@ -1519,7 +1519,7 @@ void DocumentFieldsManager::SetFixFields( const DateTime* 
pNewDateTime )
 
 // Trigger formatting
 if( bChgd )
-pFormatField->UpdateTextNode(nullptr, nullptr);
+pFormatField->ForceUpdateTextNode();
 }
 }
 }
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 5cae8a66f8ee..45feaca8d581 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -984,7 +984,7 @@ void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int 
eGetMode )
 
 sFormula.clear();
 // trigger formatting
-
const_cast(pFormatField)->UpdateTextNode( nullptr, nullptr );
+
const_cast(pFormatField)->ForceUpdateTextNode();
 }
 break;
 
@@ -1004,7 +1004,7 @@ void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int 
eGetMode )
 // evaluate field
 const_cast(static_cast(pField))->Evaluate(rDoc);
 // trigger formatting
-
const_cast(pFormatField)->UpdateTextNode(nullptr, nullptr);
+
const_cast(pFormatField)->ForceUpdateTextNode();
 }
 break;
 
diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index 28d239de2a1e..e604985e7d0f 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -2363,7 +2363,7 @@ void SwRefPageGetFieldType::UpdateField( SwTextField 
const * pTextField,
 }
 }
 // start formatting
-
const_cast(pTextField->GetFormatField()).UpdateTextNode(nullptr,
 nullptr);
+
const_cast(pTextField->GetFormatField()).ForceUpdateTextNode();
 }
 
 // queries for relative page numbering
diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx
index 0067d3b6d7c4..33a5e7096dc4 100644
--- a/sw/source/core/fields/usrfld.cxx
+++ b/sw/source/core/fields/usrfld.cxx
@@ -371,6 +371,14 @@ void SwUserFieldType::PutValue( const uno::Any& rAny, 
sal_uInt16 nWhichId )
 }
 }
 
+void SwUserFieldType::EnsureValid()
+{
+if(IsValid())
+return;
+SwCalc aCalc(*GetDoc());
+GetValue(aCalc);
+}
+
 void SwUserFieldType::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-22 Thread Miklos Vajna (via logerrit)
 sw/inc/strings.hrc  |1 +
 sw/inc/swundo.hxx   |1 +
 sw/source/core/undo/undobj.cxx  |3 +++
 sw/source/uibase/shells/textfld.cxx |4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 7897143a7313c57aed262826b736619bf9432b48
Author: Miklos Vajna 
AuthorDate: Wed Feb 22 19:47:22 2023 +0100
Commit: Miklos Vajna 
CommitDate: Thu Feb 23 07:09:57 2023 +

sw: fix undo comment of FN_DELETE_TEXT_FORMFIELDS

It's deletes, not an insert. One has to dispatch
.uno:DeleteTextFormFields to see this in action.

Change-Id: I7c5afa6acc633e0d0a750d97ff6477b9511e816c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147489
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index ec0903f48560..40cbb9acb8c4 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -590,6 +590,7 @@
 #define STR_UNDO_INSERT_FORM_FIELD  
NC_("STR_UNDO_INSERT_FORM_FIELD", "Insert form field")
 #define STR_UNDO_UPDATE_FORM_FIELD  
NC_("STR_UNDO_UPDATE_FORM_FIELD", "Update form field")
 #define STR_UNDO_UPDATE_FORM_FIELDS 
NC_("STR_UNDO_UPDATE_FORM_FIELDS", "Update form fields")
+#define STR_UNDO_DELETE_FORM_FIELDS 
NC_("STR_UNDO_DELETE_FORM_FIELDS", "Delete form fields")
 #define STR_UNDO_INSERT_PAGE_NUMBER 
NC_("STR_UNDO_INSERT_PAGE_NUMBER", "Insert page number")
 #define STR_DROP_DOWN_FIELD_ITEM_LIMIT  
NC_("STR_DROP_DOWN_FIELD_ITEM_LIMIT", "You can specify maximum of 25 items for 
a drop-down form field.")
 
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index a387757bfd6b..61261fb9769b 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -169,6 +169,7 @@ enum class SwUndoId
 INSERT_PAGE_NUMBER,// 137
 UPDATE_FORM_FIELD, // 138
 UPDATE_FORM_FIELDS,// 139
+DELETE_FORM_FIELDS,// 140
 };
 
 OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 8a23ae1f03ff..3c5f3844591e 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -652,6 +652,9 @@ OUString GetUndoComment(SwUndoId eId)
 case SwUndoId::UPDATE_FORM_FIELDS:
 pId = STR_UNDO_UPDATE_FORM_FIELDS;
 break;
+case SwUndoId::DELETE_FORM_FIELDS:
+pId = STR_UNDO_DELETE_FORM_FIELDS;
+break;
 }
 
 assert(pId);
diff --git a/sw/source/uibase/shells/textfld.cxx 
b/sw/source/uibase/shells/textfld.cxx
index 785b2d95d6c9..e94b230a8f9d 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -982,7 +982,7 @@ FIELD_INSERT:
 {
 aFieldCommandPrefix = pFieldCommandPrefix->GetValue();
 }
-
rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, 
nullptr);
+
rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::DELETE_FORM_FIELDS, 
nullptr);
 rSh.StartAction();
 
 IDocumentMarkAccess* pMarkAccess = 
rSh.GetDoc()->getIDocumentMarkAccess();
@@ -1021,7 +1021,7 @@ FIELD_INSERT:
 }
 
 rSh.EndAction();
-
rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, 
nullptr);
+
rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::DELETE_FORM_FIELDS, 
nullptr);
 }
 break;
 case FN_PGNUMBER_WIZARD:


[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-20 Thread Noel Grandin (via logerrit)
 sw/inc/accmap.hxx|   13 ++---
 sw/source/core/access/accmap.cxx |   17 +
 2 files changed, 11 insertions(+), 19 deletions(-)

New commits:
commit c1131cdab3eb21a14822409c05697a91b4beda3e
Author: Noel Grandin 
AuthorDate: Mon Feb 20 11:46:41 2023 +0200
Commit: Noel Grandin 
CommitDate: Mon Feb 20 12:28:40 2023 +

tdf#153754 "Insert" - "Chart" in Writer hangs

  Revert "osl::Mutex->std::mutex in SwAccessibleMap"
  This reverts commit 2442fc19400e0e82b0375d3772a2e0b34a511600.

We have a recursive call stack that does not look easy to fix

 #7  0x7fffc2214c18 in 
std::unique_lock::unique_lock(std::mutex&) (this=0x7fff1c28, 
__m=...)
at 
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_lock.h:69
 #8  0x7fffc22b6c06 in 
SwAccessibleMap::AppendEvent(SwAccessibleEvent_Impl const&) 
(this=0x5b7e3aa0, rEvent=...) at sw/source/core/access/accmap.cxx:980
 #9  0x7fffc22b7f8c in 
SwAccessibleMap::InvalidateCursorPosition(com::sun::star::uno::Reference
 const&)
(this=0x5b7e3aa0, rAcc=uno::Reference to (SwAccessibleParagraph *) 
0x5b7cff00) at sw/source/core/access/accmap.cxx:1117
 #10 0x7fffc22bd595 in SwAccessibleMap::GetContext(SwFrame const*, 
bool) (this=0x5b7e3aa0, pFrame=0x5b6e68a0, bCreate=true)
at sw/source/core/access/accmap.cxx:1924
 #11 0x7fffc22bd83f in SwAccessibleMap::GetContextImpl(SwFrame const*, 
bool) (this=0x5b7e3aa0, pFrame=0x5b6e68a0, bCreate=true)
at sw/source/core/access/accmap.cxx:1935
 #12 0x7fffc228c8e8 in 
SwAccessibleContext::InvalidateChildPosOrSize(sw::access::SwAccessibleChild 
const&, SwRect const&)
(this=0x5b7e0630, rChildFrameOrObj=..., rOldFrame=SwRect = {...}) 
at sw/source/core/access/acccontext.cxx:1227
 #13 0x7fffc22b5540 in 
SwAccessibleMap::FireEvent(SwAccessibleEvent_Impl const&) (this=0x5b7e3aa0, 
rEvent=...) at sw/source/core/access/accmap.cxx:936
 #14 0x7fffc22b8216 in SwAccessibleMap::FireEvents() 
(this=0x5b7e3aa0) at sw/source/core/access/accmap.cxx:3019

Change-Id: If058cecf7bc7503d0767526c07c0ca2840b3638a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147314
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx
index df5f697841e2..0090d7837876 100644
--- a/sw/inc/accmap.hxx
+++ b/sw/inc/accmap.hxx
@@ -20,17 +20,17 @@
 #define INCLUDED_SW_INC_ACCMAP_HXX
 
 #include 
-#include 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
+
 #include 
+#include 
 
-#include 
-#include 
 #include 
+#include 
+#include 
 
 class SwAccessibleParagraph;
 class SwViewShell;
@@ -90,7 +90,7 @@ class SwAccessibleMap final : public 
::accessibility::IAccessibleViewForwarder,
 , public std::enable_shared_from_this
 {
 mutable ::osl::Mutex maMutex;
-std::mutex maEventMutex;
+::osl::Mutex maEventMutex;
 std::unique_ptr mpFrameMap;
 std::unique_ptr mpShapeMap;
 SwShapeList_Impl mvShapes;
@@ -115,7 +115,6 @@ class SwAccessibleMap final : public 
::accessibility::IAccessibleViewForwarder,
 
 void FireEvent( const SwAccessibleEvent_Impl& rEvent );
 
-void AppendEvent( std::unique_lock& rGuard, const 
SwAccessibleEvent_Impl& rEvent );
 void AppendEvent( const SwAccessibleEvent_Impl& rEvent );
 
 void InvalidateCursorPosition( const 
css::uno::Reference& rAcc );
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index a22a0219bd81..46c0dbaf0714 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -977,14 +977,7 @@ void SwAccessibleMap::FireEvent( const 
SwAccessibleEvent_Impl& rEvent )
 
 void SwAccessibleMap::AppendEvent( const SwAccessibleEvent_Impl& rEvent )
 {
-std::unique_lock aGuard(maEventMutex);
-AppendEvent(aGuard, rEvent);
-}
-
-void SwAccessibleMap::AppendEvent( std::unique_lock& rGuard, const 
SwAccessibleEvent_Impl& rEvent )
-{
-assert(rGuard.mutex() == );
-(void)rGuard;
+osl::MutexGuard aGuard( maEventMutex );
 
 if( !mpEvents )
 mpEvents.reset(new SwAccessibleEventList_Impl);
@@ -1709,7 +1702,7 @@ SwAccessibleMap::~SwAccessibleMap()
 mpPreview.reset();
 
 {
-std::unique_lock aGuard( maEventMutex );
+osl::MutexGuard aGuard( maEventMutex );
 assert(!mpEvents);
 assert(!mpEventMap);
 mpEventMap.reset();
@@ -2254,7 +2247,7 @@ void SwAccessibleMap::A11yDispose( const SwFrame *pFrame,
 
 // remove events stored for the frame
 {
-std::unique_lock aGuard( maEventMutex );
+osl::MutexGuard aGuard( maEventMutex );
 if( mpEvents )
 {
 SwAccessibleEventMap_Impl::iterator aIter =
@@ -2263,7 +2256,7 @@ void SwAccessibleMap::A11yDispose( const SwFrame *pFrame,
 {
 SwAccessibleEvent_Impl aEvent(
  

[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-17 Thread Caolán McNamara (via logerrit)
 sw/inc/gotodlg.hxx |4 ++--
 sw/source/uibase/uiview/view2.cxx  |2 +-
 sw/source/uibase/utlui/gotodlg.cxx |6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit fc1c9d7ce98a5405785907d8d18db9354b32b824
Author: Caolán McNamara 
AuthorDate: Fri Feb 17 12:40:54 2023 +
Commit: Caolán McNamara 
CommitDate: Fri Feb 17 19:38:53 2023 +

use a reference here to flag its never null

Change-Id: I92b3c71458b2d65711ea30a3e14b9e387c973a73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147216
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/gotodlg.hxx b/sw/inc/gotodlg.hxx
index 0007bc2788cc..0d10da367f68 100644
--- a/sw/inc/gotodlg.hxx
+++ b/sw/inc/gotodlg.hxx
@@ -28,7 +28,7 @@ class SwView;
 class SwGotoPageDlg final : public weld::GenericDialogController
 {
 public:
-SwGotoPageDlg(weld::Window *parent, SfxBindings* _pBindings);
+SwGotoPageDlg(weld::Window *parent, SfxBindings& rBindings);
 
 sal_uInt16 GetPageSelection() const
 {
@@ -37,7 +37,7 @@ public:
 
 private:
 SwView   *m_pCreateView;
-SfxBindings  *m_rBindings;
+SfxBindings& m_rBindings;
 sal_uInt16   mnMaxPageCnt;
 
 std::unique_ptr mxMtrPageCtrl;
diff --git a/sw/source/uibase/uiview/view2.cxx 
b/sw/source/uibase/uiview/view2.cxx
index a4458aaf5b21..fea09391a051 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -1195,7 +1195,7 @@ void SwView::Execute(SfxRequest )
 break;
 case FN_GOTO_PAGE:
 {
-SwGotoPageDlg aDlg(GetViewFrame().GetFrameWeld(), 
().GetBindings());
+SwGotoPageDlg aDlg(GetViewFrame().GetFrameWeld(), 
GetViewFrame().GetBindings());
 if (aDlg.run() == RET_OK)
 GetWrtShell().GotoPage(aDlg.GetPageSelection(), true);
 }
diff --git a/sw/source/uibase/utlui/gotodlg.cxx 
b/sw/source/uibase/utlui/gotodlg.cxx
index 666164495f63..711717ee44c1 100644
--- a/sw/source/uibase/utlui/gotodlg.cxx
+++ b/sw/source/uibase/utlui/gotodlg.cxx
@@ -26,10 +26,10 @@
 
 using namespace com::sun::star;
 
-SwGotoPageDlg::SwGotoPageDlg(weld::Window* pParent, SfxBindings* _pBindings)
+SwGotoPageDlg::SwGotoPageDlg(weld::Window* pParent, SfxBindings& rBindings)
 : GenericDialogController(pParent, "modules/swriter/ui/gotopagedialog.ui", 
"GotoPageDialog")
 , m_pCreateView(nullptr)
-, m_rBindings(_pBindings)
+, m_rBindings(rBindings)
 , mnMaxPageCnt(1)
 , mxMtrPageCtrl(m_xBuilder->weld_spin_button("page"))
 , mxPageNumberLbl(m_xBuilder->weld_label("page_count"))
@@ -71,7 +71,7 @@ SwView* SwGotoPageDlg::GetCreateView() const
 SwView* pView = SwModule::GetFirstView();
 while (pView)
 {
-if (>GetViewFrame().GetBindings() == m_rBindings)
+if (>GetViewFrame().GetBindings() == _rBindings)
 {
 const_cast(this)->m_pCreateView = pView;
 break;


[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-17 Thread Caolán McNamara (via logerrit)
 sw/inc/swabstdlg.hxx   |2 +-
 sw/source/ui/dialog/swdlgfact.cxx  |4 ++--
 sw/source/ui/dialog/swdlgfact.hxx  |2 +-
 sw/source/ui/frmdlg/frmdlg.cxx |6 +++---
 sw/source/uibase/inc/frmdlg.hxx|2 +-
 sw/source/uibase/shells/frmsh.cxx  |2 +-
 sw/source/uibase/shells/grfsh.cxx  |2 +-
 sw/source/uibase/shells/textsh.cxx |2 +-
 8 files changed, 11 insertions(+), 11 deletions(-)

New commits:
commit 6ef32deaff0d5cc271098aebf89b82be72420d9b
Author: Caolán McNamara 
AuthorDate: Fri Feb 17 12:32:19 2023 +
Commit: Caolán McNamara 
CommitDate: Fri Feb 17 14:23:08 2023 +

use a reference here to flag its always dereferenced

Change-Id: Ic157ec89e6e47560612924a9f70e6669235a9a45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147212
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 534d422cb781..da48badefdd8 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -489,7 +489,7 @@ public:
 
 virtual VclPtr  
CreateTableMergeDialog(weld::Window* pParent, bool& rWithPrev) = 0;
 virtual VclPtr   CreateFrameTabDialog(const 
OUString ,
-SfxViewFrame *pFrame, 
weld::Window *pParent,
+SfxViewFrame& rFrame, 
weld::Window *pParent,
 const SfxItemSet& rCoreSet,
 bool bNewFrame = true,
 const OString& sDefPage = 
OString()) = 0;
diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index ae224d00f78c..9bcae1e2ef33 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -1110,12 +1110,12 @@ VclPtr 
SwAbstractDialogFactory_Impl::CreateTableMergeDialog(w
 }
 
 VclPtr 
SwAbstractDialogFactory_Impl::CreateFrameTabDialog(const OUString ,
-SfxViewFrame *pFrame, 
weld::Window *pParent,
+SfxViewFrame& rFrame, 
weld::Window *pParent,
 const SfxItemSet& rCoreSet,
 boolbNewFrame,
 const OString&  sDefPage )
 {
-return 
VclPtr::Create(std::make_shared(pFrame, 
pParent, rCoreSet, bNewFrame, rDialogType, false/*bFormat*/, sDefPage, 
nullptr));
+return 
VclPtr::Create(std::make_shared(rFrame, 
pParent, rCoreSet, bNewFrame, rDialogType, false/*bFormat*/, sDefPage, 
nullptr));
 }
 
 VclPtr 
SwAbstractDialogFactory_Impl::CreateTemplateDialog(
diff --git a/sw/source/ui/dialog/swdlgfact.hxx 
b/sw/source/ui/dialog/swdlgfact.hxx
index 55aac3c8c858..7ee78f4a5c05 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -783,7 +783,7 @@ public:
 
 virtual VclPtr  
CreateTableMergeDialog(weld::Window* pParent, bool& rWithPrev) override;
 virtual VclPtr   CreateFrameTabDialog( const 
OUString ,
-SfxViewFrame *pFrame, 
weld::Window *pParent,
+SfxViewFrame& rFrame, 
weld::Window *pParent,
 const SfxItemSet& rCoreSet,
 bool bNewFrame  = true,
 const OString& sDefPage = 
OString()) override;
diff --git a/sw/source/ui/frmdlg/frmdlg.cxx b/sw/source/ui/frmdlg/frmdlg.cxx
index 2a958bcf3853..b7124046d617 100644
--- a/sw/source/ui/frmdlg/frmdlg.cxx
+++ b/sw/source/ui/frmdlg/frmdlg.cxx
@@ -41,8 +41,8 @@
 #include 
 
 // the dialog's carrier
-SwFrameDlg::SwFrameDlg(SfxViewFrame const * pViewFrame,
-   weld::Window*pParent,
+SwFrameDlg::SwFrameDlg(const SfxViewFrame& rViewFrame,
+   weld::Window*   pParent,
const SfxItemSet&   rCoreSet,
boolbNewFrame,
const OUString& sResType,
@@ -56,7 +56,7 @@ SwFrameDlg::SwFrameDlg(SfxViewFrame const * pViewFrame,
 , m_bNew(bNewFrame)
 , m_rSet(rCoreSet)
 , m_sDlgType(sResType)
-, 
m_pWrtShell(static_cast(pViewFrame->GetViewShell())->GetWrtShellPtr())
+, 
m_pWrtShell(static_cast(rViewFrame.GetViewShell())->GetWrtShellPtr())
 {
 sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
 bool bHTMLMode = (nHtmlMode & HTMLMODE_ON) != 0;
diff --git a/sw/source/uibase/inc/frmdlg.hxx b/sw/source/uibase/inc/frmdlg.hxx
index 87f03d8cc97a..438279a2a2da 100644
--- a/sw/source/uibase/inc/frmdlg.hxx
+++ b/sw/source/uibase/inc/frmdlg.hxx
@@ -37,7 +37,7 @@ class SwFrameDlg final : public SfxTabDialogController
 virtual void 

[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-17 Thread Noel Grandin (via logerrit)
 sw/inc/accmap.hxx|   13 +++--
 sw/source/core/access/accmap.cxx |   17 -
 2 files changed, 19 insertions(+), 11 deletions(-)

New commits:
commit 2442fc19400e0e82b0375d3772a2e0b34a511600
Author: Noel Grandin 
AuthorDate: Thu Feb 16 19:39:17 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Feb 17 12:59:41 2023 +

osl::Mutex->std::mutex in SwAccessibleMap

Change-Id: If7499b3fb165c904d32c9404161a7cdb2e29e5d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147187
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx
index 0090d7837876..df5f697841e2 100644
--- a/sw/inc/accmap.hxx
+++ b/sw/inc/accmap.hxx
@@ -20,17 +20,17 @@
 #define INCLUDED_SW_INC_ACCMAP_HXX
 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
-
 #include 
-#include 
 
-#include 
 #include 
-#include 
+#include 
+#include 
 
 class SwAccessibleParagraph;
 class SwViewShell;
@@ -90,7 +90,7 @@ class SwAccessibleMap final : public 
::accessibility::IAccessibleViewForwarder,
 , public std::enable_shared_from_this
 {
 mutable ::osl::Mutex maMutex;
-::osl::Mutex maEventMutex;
+std::mutex maEventMutex;
 std::unique_ptr mpFrameMap;
 std::unique_ptr mpShapeMap;
 SwShapeList_Impl mvShapes;
@@ -115,6 +115,7 @@ class SwAccessibleMap final : public 
::accessibility::IAccessibleViewForwarder,
 
 void FireEvent( const SwAccessibleEvent_Impl& rEvent );
 
+void AppendEvent( std::unique_lock& rGuard, const 
SwAccessibleEvent_Impl& rEvent );
 void AppendEvent( const SwAccessibleEvent_Impl& rEvent );
 
 void InvalidateCursorPosition( const 
css::uno::Reference& rAcc );
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 46c0dbaf0714..a22a0219bd81 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -977,7 +977,14 @@ void SwAccessibleMap::FireEvent( const 
SwAccessibleEvent_Impl& rEvent )
 
 void SwAccessibleMap::AppendEvent( const SwAccessibleEvent_Impl& rEvent )
 {
-osl::MutexGuard aGuard( maEventMutex );
+std::unique_lock aGuard(maEventMutex);
+AppendEvent(aGuard, rEvent);
+}
+
+void SwAccessibleMap::AppendEvent( std::unique_lock& rGuard, const 
SwAccessibleEvent_Impl& rEvent )
+{
+assert(rGuard.mutex() == );
+(void)rGuard;
 
 if( !mpEvents )
 mpEvents.reset(new SwAccessibleEventList_Impl);
@@ -1702,7 +1709,7 @@ SwAccessibleMap::~SwAccessibleMap()
 mpPreview.reset();
 
 {
-osl::MutexGuard aGuard( maEventMutex );
+std::unique_lock aGuard( maEventMutex );
 assert(!mpEvents);
 assert(!mpEventMap);
 mpEventMap.reset();
@@ -2247,7 +2254,7 @@ void SwAccessibleMap::A11yDispose( const SwFrame *pFrame,
 
 // remove events stored for the frame
 {
-osl::MutexGuard aGuard( maEventMutex );
+std::unique_lock aGuard( maEventMutex );
 if( mpEvents )
 {
 SwAccessibleEventMap_Impl::iterator aIter =
@@ -2256,7 +2263,7 @@ void SwAccessibleMap::A11yDispose( const SwFrame *pFrame,
 {
 SwAccessibleEvent_Impl aEvent(
 SwAccessibleEvent_Impl::DISPOSE, aFrameOrObj );
-AppendEvent( aEvent );
+AppendEvent( aGuard, aEvent );
 }
 }
 }
@@ -2998,7 +3005,7 @@ bool SwAccessibleMap::IsPageSelected( const SwPageFrame 
*pPageFrame ) const
 void SwAccessibleMap::FireEvents()
 {
 {
-osl::MutexGuard aGuard( maEventMutex );
+std::unique_lock aGuard( maEventMutex );
 if( mpEvents )
 {
 if (mpEvents->IsFiring())


[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-15 Thread Miklos Vajna (via logerrit)
 sw/inc/strings.hrc  |1 +
 sw/inc/swundo.hxx   |1 +
 sw/source/core/undo/undobj.cxx  |3 +++
 sw/source/uibase/shells/textfld.cxx |4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 5543faac1b4a92455c9c8e9f081688411f4a0cc5
Author: Miklos Vajna 
AuthorDate: Wed Feb 15 20:13:35 2023 +0100
Commit: Miklos Vajna 
CommitDate: Thu Feb 16 07:17:08 2023 +

sw: fix undo comment of FN_UPDATE_TEXT_FORMFIELDS

It's updates, not an insert. One has to dispatch .uno:TextFormFields to
see this in action.

Change-Id: I3049fa34110731e15082a0163de4b08e83c76098
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147109
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index af916bf78422..6c2119fb78dc 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -589,6 +589,7 @@
 #define STR_UNDO_TABLE_DELETE   NC_("STR_UNDO_TABLE_DELETE", 
"Delete table")
 #define STR_UNDO_INSERT_FORM_FIELD  
NC_("STR_UNDO_INSERT_FORM_FIELD", "Insert form field")
 #define STR_UNDO_UPDATE_FORM_FIELD  
NC_("STR_UNDO_UPDATE_FORM_FIELD", "Update form field")
+#define STR_UNDO_UPDATE_FORM_FIELDS 
NC_("STR_UNDO_UPDATE_FORM_FIELDS", "Update form fields")
 #define STR_UNDO_INSERT_PAGE_NUMBER 
NC_("STR_UNDO_INSERT_PAGE_NUMBER", "Insert page number")
 #define STR_DROP_DOWN_FIELD_ITEM_LIMIT  
NC_("STR_DROP_DOWN_FIELD_ITEM_LIMIT", "You can specify maximum of 25 items for 
a drop-down form field.")
 
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index 6b067dbec700..a387757bfd6b 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -168,6 +168,7 @@ enum class SwUndoId
 OUTLINE_EDIT,  // 136
 INSERT_PAGE_NUMBER,// 137
 UPDATE_FORM_FIELD, // 138
+UPDATE_FORM_FIELDS,// 139
 };
 
 OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 0f12d8ef96d0..8a23ae1f03ff 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -649,6 +649,9 @@ OUString GetUndoComment(SwUndoId eId)
 case SwUndoId::UPDATE_FORM_FIELD:
 pId = STR_UNDO_UPDATE_FORM_FIELD;
 break;
+case SwUndoId::UPDATE_FORM_FIELDS:
+pId = STR_UNDO_UPDATE_FORM_FIELDS;
+break;
 }
 
 assert(pId);
diff --git a/sw/source/uibase/shells/textfld.cxx 
b/sw/source/uibase/shells/textfld.cxx
index b60df6477bf5..02f6b8d29a63 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -917,7 +917,7 @@ FIELD_INSERT:
 pFields->GetValue() >>= aFields;
 }
 
-
rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, 
nullptr);
+
rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_FORM_FIELDS, 
nullptr);
 rSh.StartAction();
 
 IDocumentMarkAccess* pMarkAccess = 
rSh.GetDoc()->getIDocumentMarkAccess();
@@ -964,7 +964,7 @@ FIELD_INSERT:
 }
 
 rSh.EndAction();
-
rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, 
nullptr);
+
rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_FORM_FIELDS, 
nullptr);
 }
 break;
 case FN_DELETE_TEXT_FORMFIELDS:


[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-15 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/hintids.hxx |   12 
 sw/source/core/crsr/crsrsh.cxx |9 +
 2 files changed, 13 insertions(+), 8 deletions(-)

New commits:
commit 94eea5aed7b3a0bea2b41e4a9e0b677cf495d2c8
Author: Bjoern Michaelsen 
AuthorDate: Tue Feb 14 22:08:44 2023 +0100
Commit: Bjoern Michaelsen 
CommitDate: Wed Feb 15 21:50:11 2023 +

dont use RES_MSG_{BEGIN,END} outside hintids.hxx

Change-Id: Iee08120ec4ebfd39f03a949f4a759eaa415ca894
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147029
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen 

diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 4766d0799375..1119ca70dc8e 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -417,8 +417,8 @@ constexpr TypedWhichId 
RES_CONDTXTFMTCOLL(160);
 constexpr sal_uInt16 RES_FMT_END(161);
 
 // ID's for Messages in the Formats
-constexpr sal_uInt16 RES_MSG_BEGIN(RES_FMT_END);
-constexpr TypedWhichId RES_OBJECTDYING(RES_MSG_BEGIN); // 161
+constexpr sal_uInt16 RES_FORMAT_MSG_BEGIN(RES_FMT_END);
+constexpr TypedWhichId 
RES_OBJECTDYING(RES_FORMAT_MSG_BEGIN); // 161
 constexpr TypedWhichId RES_FMT_CHG(162);
 constexpr TypedWhichId RES_ATTRSET_CHG(163);
 constexpr TypedWhichId RES_UPDATE_ATTR(167);
@@ -436,13 +436,13 @@ constexpr TypedWhichId 
RES_FINDNEARESTNODE(184);
 constexpr TypedWhichId RES_CONTENT_VISIBLE(185);
 constexpr TypedWhichId RES_TITLE_CHANGED(188);
 constexpr TypedWhichId RES_DESCRIPTION_CHANGED(189);
-constexpr sal_uInt16 RES_MSG_END(190);
+constexpr sal_uInt16 RES_FORMAT_MSG_END(190);
 
 // An ID for the RTF-reader. The stylesheets are treated like attributes,
 // i.e. there is a StyleSheet-attribute. To avoid collision with other
 // Which()-values, the value is listed here. (The help system too defines
 // new attributes!)
-constexpr sal_uInt16 RES_FLTRATTR_BEGIN(RES_MSG_END);
+constexpr sal_uInt16 RES_FLTRATTR_BEGIN(RES_FORMAT_MSG_END);
 constexpr TypedWhichId RES_FLTR_BOOKMARK(RES_FLTRATTR_BEGIN);
 constexpr TypedWhichId RES_FLTR_ANCHOR(191);
 constexpr TypedWhichId RES_FLTR_NUMRULE(192);
@@ -508,6 +508,10 @@ inline bool isUNKNOWNATR(const sal_uInt16 nWhich)
 {
 return (RES_UNKNOWNATR_BEGIN <= nWhich) && (RES_UNKNOWNATR_END > nWhich);
 }
+inline bool isFormatMessage(const sal_uInt16 nWhich)
+{
+return (RES_FORMAT_MSG_BEGIN <= nWhich) && (RES_FORMAT_MSG_END > nWhich);
+}
 
 // Take the respective default attribute from the statistical default
 // attributes table over the Which-value.
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 6aef2801b0b7..132a3cd7c9db 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2525,11 +2525,12 @@ void SwCursorShell::SwClientNotify(const SwModify&, 
const SfxHint& rHint)
 auto pLegacy = static_cast();
 auto nWhich = pLegacy->GetWhich();
 if(!nWhich)
-nWhich = sal::static_int_cast(RES_MSG_BEGIN);
+nWhich = RES_OBJECTDYING;
 if( m_bCallChgLnk &&
-( nWhich < RES_MSG_BEGIN || nWhich >= RES_MSG_END ||
-nWhich == RES_FMT_CHG || nWhich == RES_UPDATE_ATTR ||
-nWhich == RES_ATTRSET_CHG ))
+( !isFormatMessage(nWhich)
+|| nWhich == RES_FMT_CHG
+|| nWhich == RES_UPDATE_ATTR
+|| nWhich == RES_ATTRSET_CHG ))
 // messages are not forwarded
 // #i6681#: RES_UPDATE_ATTR is implicitly unset in
 // SwTextNode::Insert(SwTextHint*, sal_uInt16); we react here and thus 
do


[Libreoffice-commits] core.git: sw/inc sw/source

2023-02-10 Thread Jim Raykowski (via logerrit)
 sw/inc/crsrsh.hxx   |6 +++---
 sw/source/core/crsr/crsrsh.cxx  |   15 +--
 sw/source/core/text/EnhancedPDFExportHelper.cxx |6 +++---
 sw/source/uibase/shells/textsh.cxx  |9 +
 sw/source/uibase/wrtsh/wrtsh1.cxx   |9 +++--
 5 files changed, 19 insertions(+), 26 deletions(-)

New commits:
commit 5bc7cb77df839f7dd3cc7d90aaf50ebccdc6
Author: Jim Raykowski 
AuthorDate: Tue Feb 7 23:17:17 2023 -0900
Commit: Jim Raykowski 
CommitDate: Fri Feb 10 17:07:50 2023 +

tdf#153205 related: Fix selection problems caused by cursor shell

push pop during insert state update

This patch renames the SelectHiddenRange function to IsInHiddenRange
and modifies it to take a bool argument that when true selects the
hidden range if the current cursor position is in a hidden range.
When the argument is false, the hidden range is not selected if the
current cursor position is in a hidden range. This makes using cursor
push pop unnecessary when all that is wanted to know is if the
current cursor position is in a hidden range.

Change-Id: I622dfaf8e73c5b432bb74a48d36433ff755542b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146725
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Jim Raykowski 

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index efc8aa1eec49..8eac979b5617 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -851,9 +851,9 @@ public:
 bool   bColumnChange();
 static void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 
nNewSection);
 static void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 
nNewColumn);
-// If the current cursor position is inside a hidden range, the hidden 
range
-// is selected and true is returned:
-bool SelectHiddenRange();
+// If the current cursor position is inside a hidden range true is 
returned. If bSelect is
+// true, the hidden range is selected. If bSelect is false, the hidden 
range is not selected.
+bool IsInHiddenRange(const bool bSelect);
 
 // remove all invalid cursors
 void ClearUpCursors();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index bc78d12cb594..6aef2801b0b7 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3453,9 +3453,9 @@ bool SwCursorShell::IsInRightToLeftText() const
 return SvxFrameDirection::Vertical_LR_TB == nDir || 
SvxFrameDirection::Horizontal_RL_TB == nDir;
 }
 
-/// If the current cursor position is inside a hidden range, the hidden range
-/// is selected.
-bool SwCursorShell::SelectHiddenRange()
+/// If the current cursor position is inside a hidden range true is returned. 
If bSelect is
+/// true, the hidden range is selected. If bSelect is false, the hidden range 
is not selected.
+bool SwCursorShell::IsInHiddenRange(const bool bSelect)
 {
 bool bRet = false;
 if ( !GetViewOptions()->IsShowHiddenChar() && !m_pCurrentCursor->HasMark() 
)
@@ -3472,9 +3472,12 @@ bool SwCursorShell::SelectHiddenRange()
 SwScriptInfo::GetBoundsOfHiddenRange( *pNode, nPos, nHiddenStart, 
nHiddenEnd );
 if ( COMPLETE_STRING != nHiddenStart )
 {
-// make selection:
-m_pCurrentCursor->SetMark();
-m_pCurrentCursor->GetMark()->SetContent(nHiddenEnd);
+if (bSelect)
+{
+// make selection:
+m_pCurrentCursor->SetMark();
+m_pCurrentCursor->GetMark()->SetContent(nHiddenEnd);
+}
 bRet = true;
 }
 }
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index c869413c3164..9e7a01c60a7f 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -274,7 +274,7 @@ bool lcl_TryMoveToNonHiddenField(SwEditShell& rShell, const 
SwTextNode& rNd, con
 // 3. Check for hidden text attribute
 if(rNd.IsHidden())
 return false;
-if(!rShell.GotoFormatField(rField) || rShell.SelectHiddenRange())
+if(!rShell.GotoFormatField(rField) || 
rShell.IsInHiddenRange(/*bSelect=*/false))
 {
 rShell.SwCursorShell::ClearMark();
 return false;
@@ -1673,7 +1673,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
 // 3. Check for hidden text attribute
 if ( !pTNd->IsHidden() &&
   mrSh.GotoINetAttr( p->rINetAttr ) &&
- !mrSh.SelectHiddenRange() )
+ !mrSh.IsInHiddenRange(/*bSelect=*/false) )
 {
 // Select the hyperlink:
 mrSh.SwCursorShell::Right( 1, SwCursorSkipMode::Chars );
@@ -1991,7 +1991,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
 
 // 1. 

  1   2   3   4   5   6   7   8   9   10   >